MeshObject.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-2022 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::MeshObject
26 
27 Description
28  Templated abstract base-class for optional mesh objects used to automate
29  their allocation to the mesh database and the mesh-modifier event-loop.
30 
31  MeshObject is templated on the type of mesh it is allocated to, the type of
32  the mesh object (TopologicalMeshObject, GeometricMeshObject,
33  MoveableMeshObject, DistributeableMeshObject, UpdateableMeshObject) and the
34  type of the actual object it is created for example:
35 
36  \verbatim
37  class leastSquaresVectors
38  :
39  public MeshObject<fvMesh, MoveableMeshObject, leastSquaresVectors>
40  {
41  .
42  .
43  .
44  //- Delete the least square vectors when the mesh moves
45  virtual bool movePoints();
46  };
47  \endverbatim
48 
49  MeshObject types:
50 
51  - TopologicalMeshObject: mesh object to be deleted on topology change
52  - GeometricMeshObject: mesh object to be deleted on geometry change
53  - MoveableMeshObject: mesh object to be updated in movePoints
54  - UpdateableMeshObject: mesh object to be updated in topoChange or
55  movePoints
56  - PatchMeshObject: mesh object to be additionally updated patch changes
57 
58  Note:
59  movePoints must be provided for MeshObjects of type MoveableMeshObject
60  and both movePoints and topoChange functions must exist, provided for
61  MeshObjects of type UpdateableMeshObject.
62 
63 SourceFiles
64  MeshObject.C
65 
66 \*---------------------------------------------------------------------------*/
67 
68 #ifndef MeshObject_H
69 #define MeshObject_H
70 
71 #include "objectRegistry.H"
72 
73 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
74 
75 namespace Foam
76 {
77 
78 // Forward declarations
79 class polyTopoChangeMap;
80 class polyMeshMap;
81 class polyDistributionMap;
82 
83 /*---------------------------------------------------------------------------*\
84  Class MeshObject Declaration
85 \*---------------------------------------------------------------------------*/
86 
87 template<class Mesh, template<class> class MeshObjectType, class Type>
88 class MeshObject
89 :
90  public MeshObjectType<Mesh>
91 {
92 
93 protected:
94 
95  // Reference to Mesh
96  const Mesh& mesh_;
97 
98 
99 public:
100 
101  // Constructors
102 
103  explicit MeshObject(const Mesh& mesh);
104 
105  MeshObject(const Mesh& mesh, const IOobject& io);
106 
107  static Type& New(Mesh& mesh);
108 
109  static const Type& New(const Mesh& mesh);
110 
111  template<class... Args>
112  static Type& New
113  (
114  Mesh& mesh,
115  const Args&... args
116  );
117 
118  template<class... Args>
119  static const Type& New
120  (
121  const Mesh& mesh,
122  const Args&... args
123  );
124 
125 
126  // Destructors
127 
128  virtual ~MeshObject();
129 
130  static bool Delete(const Mesh& mesh);
131 
132 
133  // Member Functions
134 
135  //- Return true if this MeshObject is found in the mesh registry
136  static bool found(const Mesh& mesh);
138  const Mesh& mesh() const
139  {
140  return mesh_;
141  }
143  virtual bool writeData(Foam::Ostream&) const
144  {
145  return true;
146  }
147 };
148 
149 
150 /*---------------------------------------------------------------------------*\
151  Class meshObject Declaration
152 \*---------------------------------------------------------------------------*/
154 class meshObject
155 :
156  public regIOobject
157 {
158 public:
159 
160  // Declare name of the class and its debug switch
161  ClassName("meshObject");
162 
163 
164  // Constructors
165 
166  meshObject(const word& typeName, const objectRegistry& obr);
167 
168  meshObject(const word& typeName, const IOobject& io);
169 
170 
171  // Static member functions
172 
173  template<class Mesh>
174  static void movePoints(objectRegistry&);
175 
176  template<class Mesh>
177  static void topoChange(objectRegistry&, const polyTopoChangeMap&);
178 
179  template<class Mesh>
180  static void mapMesh(objectRegistry&, const polyMeshMap&);
181 
182  template<class Mesh>
183  static void distribute(objectRegistry&, const polyDistributionMap&);
184 
185  template<class Mesh>
186  static void addPatch(objectRegistry&, const label patchi);
187 
188  template<class Mesh>
189  static void reorderPatches
190  (
192  const labelUList& newToOld,
193  const bool validBoundary
194  );
195 
196  template<class Mesh, template<class> class MeshObjectType>
197  static void clear(objectRegistry&);
198 
199  //- Clear all meshObject derived from FromType up to (but not including)
200  // ToType. Used to clear e.g. all non-updateable meshObjects
201  template
202  <
203  class Mesh,
204  template<class> class FromType,
205  template<class> class ToType
206  >
207  static void clearUpto(objectRegistry&);
208 };
209 
210 
211 /*---------------------------------------------------------------------------*\
212  Class TopologicalMeshObject Declaration
213 \*---------------------------------------------------------------------------*/
214 
215 template<class Mesh>
217 :
218  public meshObject
219 {
220 public:
222  TopologicalMeshObject(const word& typeName, const objectRegistry& obr)
223  :
224  meshObject(typeName, obr)
225  {}
227  TopologicalMeshObject(const word& typeName, const IOobject& io)
228  :
229  meshObject(typeName, io)
230  {}
231 };
232 
233 
234 /*---------------------------------------------------------------------------*\
235  Class GeometricMeshObject Declaration
236 \*---------------------------------------------------------------------------*/
237 
238 template<class Mesh>
240 :
241  public TopologicalMeshObject<Mesh>
242 {
243 public:
245  GeometricMeshObject(const word& typeName, const objectRegistry& obr)
246  :
247  TopologicalMeshObject<Mesh>(typeName, obr)
248  {}
250  GeometricMeshObject(const word& typeName, const IOobject& io)
251  :
252  TopologicalMeshObject<Mesh>(typeName, io)
253  {}
254 };
255 
256 
257 /*---------------------------------------------------------------------------*\
258  Class MoveableMeshObject Declaration
259 \*---------------------------------------------------------------------------*/
260 
261 template<class Mesh>
262 class MoveableMeshObject
263 :
264  public GeometricMeshObject<Mesh>
265 {
266 public:
268  MoveableMeshObject(const word& typeName, const objectRegistry& obr)
269  :
270  GeometricMeshObject<Mesh>(typeName, obr)
271  {}
273  MoveableMeshObject(const word& typeName, const IOobject& io)
274  :
275  GeometricMeshObject<Mesh>(typeName, io)
276  {}
277 
278  virtual bool movePoints() = 0;
279 };
280 
281 
282 /*---------------------------------------------------------------------------*\
283  Class DistributeableMeshObject Declaration
284 \*---------------------------------------------------------------------------*/
285 
286 template<class Mesh>
288 :
289  public MoveableMeshObject<Mesh>
290 {
291 public:
293  DistributeableMeshObject(const word& typeName, const objectRegistry& obr)
294  :
295  MoveableMeshObject<Mesh>(typeName, obr)
296  {}
298  DistributeableMeshObject(const word& typeName, const IOobject& io)
299  :
300  MoveableMeshObject<Mesh>(typeName, io)
301  {}
302 
303  virtual void distribute(const polyDistributionMap& map) = 0;
304 };
305 
306 
307 /*---------------------------------------------------------------------------*\
308  Class UpdateableMeshObject Declaration
309 \*---------------------------------------------------------------------------*/
310 
311 template<class Mesh>
313 :
314  public DistributeableMeshObject<Mesh>
315 {
316 public:
318  UpdateableMeshObject(const word& typeName, const objectRegistry& obr)
319  :
320  DistributeableMeshObject<Mesh>(typeName, obr)
321  {}
323  UpdateableMeshObject(const word& typeName, const IOobject& io)
324  :
325  DistributeableMeshObject<Mesh>(typeName, io)
326  {}
327 
328  virtual void topoChange(const polyTopoChangeMap& map) = 0;
329 
330  virtual void mapMesh(const polyMeshMap& map) = 0;
331 };
332 
333 
334 /*---------------------------------------------------------------------------*\
335  Class PatchMeshObject Declaration
336 \*---------------------------------------------------------------------------*/
337 
338 template<class Mesh>
339 class PatchMeshObject
340 :
341  public UpdateableMeshObject<Mesh>
342 {
343 public:
345  PatchMeshObject(const word& typeName, const objectRegistry& obr)
346  :
347  UpdateableMeshObject<Mesh>(typeName, obr)
348  {}
350  PatchMeshObject(const word& typeName, const IOobject& io)
351  :
352  UpdateableMeshObject<Mesh>(typeName, io)
353  {}
354 
355  //- Reordered/removed trailing patches. If validBoundary call is parallel
356  // synced and all add the same patch with same settings
357  virtual void reorderPatches
358  (
359  const labelUList& newToOld,
360  const bool validBoundary
361  ) = 0;
362 
363  //- Inserted patch at patchi
364  virtual void addPatch(const label patchi) = 0;
365 };
366 
367 
368 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
369 
370 } // End namespace Foam
371 
372 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
373 
374 #ifdef NoRepository
375  #include "MeshObject.C"
376 #endif
377 
378 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
379 
380 #endif
381 
382 // ************************************************************************* //
Class containing mesh-to-mesh mapping information after a mesh distribution where we send parts of me...
tUEqn clear()
static bool Delete(const Mesh &mesh)
Definition: MeshObject.C:183
virtual bool writeData(Foam::Ostream &) const
Definition: MeshObject.H:142
static bool found(const Mesh &mesh)
Return true if this MeshObject is found in the mesh registry.
Definition: MeshObject.C:222
virtual ~MeshObject()
Definition: MeshObject.C:212
#define ClassName(TypeNameString)
Add typeName information from argument TypeNameString to a class.
Definition: className.H:65
Templated abstract base-class for optional mesh objects used to automate their allocation to the mesh...
Definition: MeshObject.H:87
A class for handling words, derived from string.
Definition: word.H:59
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
void mapMesh(const meshToMesh &interp, const HashSet< word > &selectedFields, const bool noLagrangian)
const Mesh & mesh_
Definition: MeshObject.H:95
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: HashTable.H:60
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
static Type & New(Mesh &mesh)
Definition: MeshObject.C:54
const Mesh & mesh() const
Definition: MeshObject.H:137
label patchi
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:52
Registry of regIOobjects.
Class containing mesh-to-mesh mapping information.
Definition: polyMeshMap.H:50
Foam::argList args(argc, argv)
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:98
MeshObject(const Mesh &mesh)
Definition: MeshObject.C:31
Namespace for OpenFOAM.