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 meshSearch;
57 class polyTopoChangeMap;
58 class polyMeshMap;
59 class polyDistributionMap;
60 
61 /*---------------------------------------------------------------------------*\
62  Class sampledSet Declaration
63 \*---------------------------------------------------------------------------*/
64 
65 class sampledSet
66 :
67  public coordSet
68 {
69  // Private Data
70 
71  //- Name of the set
72  const word name_;
73 
74  //- Reference to mesh
75  const polyMesh& mesh_;
76 
77  //- Reference to mesh searching class
78  const meshSearch& searchEngine_;
79 
80 
81 protected:
82 
83  // Protected data
84 
85  //- Cell numbers
87 
88  //- Face numbers (-1 if not known)
90 
91 
92  // Protected Member Functions
93 
94  //- Sets sample data
95  void setSamples
96  (
97  const List<point>& samplingPositions,
98  const labelList& samplingSegments,
99  const labelList& samplingCells,
100  const labelList& samplingFaces
101  );
102 
103  //- Sets sample data
104  void setSamples
105  (
106  const List<point>& samplingPositions,
107  const List<scalar>& samplingDistances,
108  const labelList& samplingSegments,
109  const labelList& samplingCells,
110  const labelList& samplingFaces
111  );
112 
113  //- Generate the samples
114  virtual void genSamples() = 0;
115 
116 
117 public:
118 
119  //- Runtime type information
120  TypeName("sampledSet");
121 
122 
123  // Declare run-time constructor selection table
124 
126  (
127  autoPtr,
128  sampledSet,
129  word,
130  (
131  const word& name,
132  const polyMesh& mesh,
133  const meshSearch& searchEngine,
134  const dictionary& dict
135  ),
137  );
138 
139 
140  //- Class used for the read-construction of
141  // PtrLists of sampledSet
142  class iNew
143  {
144  const polyMesh& mesh_;
145  const meshSearch& searchEngine_;
146 
147  public:
148 
149  iNew(const polyMesh& mesh, const meshSearch& searchEngine)
150  :
151  mesh_(mesh),
152  searchEngine_(searchEngine)
153  {}
154 
156  {
157  word name(is);
158  dictionary dict(is);
159  return sampledSet::New(name, mesh_, searchEngine_, dict);
160  }
161  };
162 
163 
164  // Constructors
165 
166  //- Construct from components
167  sampledSet
168  (
169  const word& name,
170  const polyMesh& mesh,
171  const meshSearch& searchEngine,
172  const word& axis
173  );
174 
175  //- Construct from dictionary
176  sampledSet
177  (
178  const word& name,
179  const polyMesh& mesh,
180  const meshSearch& searchEngine,
181  const dictionary& dict
182  );
183 
184  //- Clone
185  autoPtr<sampledSet> clone() const
186  {
188  return autoPtr<sampledSet>(nullptr);
189  }
190 
191 
192  // Selectors
193 
194  //- Return a reference to the selected sampledSet
195  static autoPtr<sampledSet> New
196  (
197  const word& name,
198  const polyMesh& mesh,
199  const meshSearch& searchEngine,
200  const dictionary& dict
201  );
202 
203 
204  //- Destructor
205  virtual ~sampledSet();
206 
207 
208  // Member Functions
209 
210  //- Access the name
211  const word& name() const
212  {
213  return name_;
214  }
215 
216  //- Access the mesh
217  const polyMesh& mesh() const
218  {
219  return mesh_;
220  }
221 
222  //- Access the search engine
223  const meshSearch& searchEngine() const
224  {
225  return searchEngine_;
226  }
227 
228  //- Access the cells
229  const labelList& cells() const
230  {
231  return cells_;
232  }
233 
234  //- Access the faces
235  const labelList& faces() const
236  {
237  return faces_;
238  }
239 
240  //- Update for mesh point-motion
241  virtual void movePoints();
242 
243  //- Update topology using the given map
244  virtual void topoChange(const polyTopoChangeMap&);
245 
246  //- Update from another mesh using the given map
247  virtual void mapMesh(const polyMeshMap&);
248 
249  //- Redistribute or update using the given distribution map
250  virtual void distribute(const polyDistributionMap&);
251 };
252 
253 
254 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
255 
256 } // End namespace Foam
257 
258 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
259 
260 #endif
261 
262 // ************************************************************************* //
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
word axis() const
Return the axis name.
Definition: coordSet.H:147
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
Various (local, not parallel) searches on polyMesh; uses (demand driven) octree to search.
Definition: meshSearch.H:58
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:80
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Class used for the read-construction of.
Definition: sampledSet.H:142
autoPtr< sampledSet > operator()(Istream &is) const
Definition: sampledSet.H:154
iNew(const polyMesh &mesh, const meshSearch &searchEngine)
Definition: sampledSet.H:148
Holds list of sampling points which is filled at construction time. Various implementations of this b...
Definition: sampledSet.H:67
labelList faces_
Face numbers (-1 if not known)
Definition: sampledSet.H:88
const labelList & faces() const
Access the faces.
Definition: sampledSet.H:234
sampledSet(const word &name, const polyMesh &mesh, const meshSearch &searchEngine, const word &axis)
Construct from components.
Definition: sampledSet.C:136
const meshSearch & searchEngine() const
Access the search engine.
Definition: sampledSet.H:222
virtual void topoChange(const polyTopoChangeMap &)
Update topology using the given map.
Definition: sampledSet.C:259
virtual void distribute(const polyDistributionMap &)
Redistribute or update using the given distribution map.
Definition: sampledSet.C:272
virtual void movePoints()
Update for mesh point-motion.
Definition: sampledSet.C:253
labelList cells_
Cell numbers.
Definition: sampledSet.H:85
virtual ~sampledSet()
Destructor.
Definition: sampledSet.C:183
const labelList & cells() const
Access the cells.
Definition: sampledSet.H:228
virtual void genSamples()=0
Generate the samples.
virtual void mapMesh(const polyMeshMap &)
Update from another mesh using the given map.
Definition: sampledSet.C:265
autoPtr< sampledSet > clone() const
Clone.
Definition: sampledSet.H:184
declareRunTimeSelectionTable(autoPtr, sampledSet, word,(const word &name, const polyMesh &mesh, const meshSearch &searchEngine, const dictionary &dict),(name, mesh, searchEngine, dict))
const word & name() const
Access the name.
Definition: sampledSet.H:210
void setSamples(const List< point > &samplingPositions, const labelList &samplingSegments, const labelList &samplingCells, const labelList &samplingFaces)
Sets sample data.
Definition: sampledSet.C:47
static autoPtr< sampledSet > New(const word &name, const polyMesh &mesh, const meshSearch &searchEngine, const dictionary &dict)
Return a reference to the selected sampledSet.
Definition: sampledSet.C:190
const polyMesh & mesh() const
Access the mesh.
Definition: sampledSet.H:216
TypeName("sampledSet")
Runtime type information.
A class for handling words, derived from string.
Definition: word.H:62
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:381
Namespace for OpenFOAM.
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...