sampledSet.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2025 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::sampledSet
26 
27 Description
28  Holds list of sampling points which is filled at construction time.
29  Various implementations of this base class to e.g. get sampling points
30  at uniform distance along a line (lineUniformSet) or directly specified
31  (pointsSet)
32 
33  Each 'sampledSet' has a name and a specifier of how the axis should be
34  write (x/y/z component or all 3 components)
35 
36 SourceFiles
37  sampledSet.C
38 
39 \*---------------------------------------------------------------------------*/
40 
41 #ifndef sampledSet_H
42 #define sampledSet_H
43 
44 #include "coordSet.H"
45 #include "typeInfo.H"
46 #include "runTimeSelectionTables.H"
47 #include "autoPtr.H"
48 
49 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50 
51 namespace Foam
52 {
53 
54 // Forward declaration of classes
55 class polyMesh;
56 class polyTopoChangeMap;
57 class polyMeshMap;
58 class polyDistributionMap;
59 
60 /*---------------------------------------------------------------------------*\
61  Class sampledSet Declaration
62 \*---------------------------------------------------------------------------*/
63 
64 class sampledSet
65 {
66  // Private Data
67 
68  //- Name of the set
69  const word name_;
70 
71  //- Reference to mesh
72  const polyMesh& mesh_;
73 
74  //- Coordinate set
75  mutable autoPtr<coordSet> coordsPtr_;
76 
77  //- Cell numbers
78  mutable autoPtr<labelList> cellsPtr_;
79 
80  //- Face numbers (-1 if not known)
81  mutable autoPtr<labelList> facesPtr_;
82 
83  //- Axis
84  const coordSet::axisType axis_;
85 
86 
87  // Private Member Functions
88 
89  //- Calc the samples
90  virtual bool calcSamples
91  (
92  DynamicList<point>& samplingPositions,
93  DynamicList<scalar>& samplingDistances,
94  DynamicList<label>& samplingSegments,
95  DynamicList<label>& samplingCells,
96  DynamicList<label>& samplingFaces
97  ) const = 0;
98 
99  //- Generate the samples
100  void setSamples() const;
101 
102 
103 public:
104 
105  //- Runtime type information
106  TypeName("sampledSet");
107 
108 
109  // Declare run-time constructor selection table
110 
112  (
113  autoPtr,
114  sampledSet,
115  word,
116  (
117  const word& name,
118  const polyMesh& mesh,
119  const dictionary& dict
120  ),
121  (name, mesh, dict)
122  );
123 
124 
125  //- Class used for the read-construction of PtrLists of sampledSet
126  class iNew
127  {
128  const polyMesh& mesh_;
129 
130  public:
131 
132  iNew(const polyMesh& mesh)
133  :
134  mesh_(mesh)
135  {}
136 
138  {
139  word name(is);
140  dictionary dict(is);
141  return sampledSet::New(name, mesh_, dict);
142  }
143  };
144 
145 
146  // Constructors
147 
148  //- Construct from components
149  sampledSet
150  (
151  const word& name,
152  const polyMesh& mesh,
153  const word& axis
154  );
155 
156  //- Construct from dictionary
157  sampledSet
158  (
159  const word& name,
160  const polyMesh& mesh,
161  const dictionary& dict
162  );
163 
164  //- Clone
165  autoPtr<sampledSet> clone() const
166  {
168  return autoPtr<sampledSet>(nullptr);
169  }
170 
171 
172  // Selectors
173 
174  //- Return a reference to the selected sampledSet
175  static autoPtr<sampledSet> New
176  (
177  const word& name,
178  const polyMesh& mesh,
179  const dictionary& dict
180  );
181 
182 
183  //- Destructor
184  virtual ~sampledSet();
185 
186 
187  // Member Functions
188 
189  //- Access the name
190  inline const word& name() const;
191 
192  //- Access the mesh
193  inline const polyMesh& mesh() const;
194 
195  //- Access the coordinate set
196  inline const coordSet& coords() const;
197 
198  //- Return the size
199  inline label size() const;
200 
201  //- Return the size
202  inline const labelList& segments() const;
203 
204  //- Access the positions
205  inline const pointField& positions() const;
206 
207  //- Access the cells
208  inline const labelList& cells() const;
209 
210  //- Access the faces
211  inline const labelList& faces() const;
212 
213  //- Update for mesh point-motion
214  virtual void movePoints();
215 
216  //- Update topology using the given map
217  virtual void topoChange(const polyTopoChangeMap&);
218 
219  //- Update from another mesh using the given map
220  virtual void mapMesh(const polyMeshMap&);
221 
222  //- Redistribute or update using the given distribution map
223  virtual void distribute(const polyDistributionMap&);
224 
225 
226  // Member Operators
227 
228  //- Cast to the coordinate set
229  inline operator const coordSet&() const;
230 };
231 
232 
233 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
234 
235 } // End namespace Foam
236 
237 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
238 
239 #include "sampledSetI.H"
240 
241 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
242 
243 #endif
244 
245 // ************************************************************************* //
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Definition: DynamicList.H:78
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:60
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
Holds list of sampling positions.
Definition: coordSet.H:51
axisType
Enumeration defining the output format for coordinates.
Definition: coordSet.H:58
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
Class containing mesh-to-mesh mapping information after a mesh distribution where we send parts of me...
Class containing mesh-to-mesh mapping information.
Definition: polyMeshMap.H:51
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:78
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Class used for the read-construction of PtrLists of sampledSet.
Definition: sampledSet.H:126
autoPtr< sampledSet > operator()(Istream &is) const
Definition: sampledSet.H:136
iNew(const polyMesh &mesh)
Definition: sampledSet.H:131
Holds list of sampling points which is filled at construction time. Various implementations of this b...
Definition: sampledSet.H:64
const labelList & cells() const
Access the cells.
Definition: sampledSetI.H:70
static autoPtr< sampledSet > New(const word &name, const polyMesh &mesh, const dictionary &dict)
Return a reference to the selected sampledSet.
Definition: sampledSet.C:162
const polyMesh & mesh() const
Access the mesh.
Definition: sampledSetI.H:36
label size() const
Return the size.
Definition: sampledSetI.H:52
virtual void topoChange(const polyTopoChangeMap &)
Update topology using the given map.
Definition: sampledSet.C:231
virtual void distribute(const polyDistributionMap &)
Redistribute or update using the given distribution map.
Definition: sampledSet.C:248
sampledSet(const word &name, const polyMesh &mesh, const word &axis)
Construct from components.
Definition: sampledSet.C:112
virtual void movePoints()
Update for mesh point-motion.
Definition: sampledSet.C:223
declareRunTimeSelectionTable(autoPtr, sampledSet, word,(const word &name, const polyMesh &mesh, const dictionary &dict),(name, mesh, dict))
virtual ~sampledSet()
Destructor.
Definition: sampledSet.C:155
virtual void mapMesh(const polyMeshMap &)
Update from another mesh using the given map.
Definition: sampledSet.C:239
autoPtr< sampledSet > clone() const
Clone.
Definition: sampledSet.H:164
const coordSet & coords() const
Access the coordinate set.
Definition: sampledSetI.H:42
const labelList & segments() const
Return the size.
Definition: sampledSetI.H:58
const labelList & faces() const
Access the faces.
Definition: sampledSetI.H:80
const word & name() const
Access the name.
Definition: sampledSetI.H:30
const pointField & positions() const
Access the positions.
Definition: sampledSetI.H:64
TypeName("sampledSet")
Runtime type information.
A class for handling words, derived from string.
Definition: word.H:63
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:381
Namespace for OpenFOAM.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
Macros to ease declaration of run-time selection tables.
dictionary dict
Basic run-time type information using word as the type's name. Used to enhance the standard RTTI to c...