All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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-2021 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, UpdateableMeshObject) and the type of the actual object
34  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 updateMesh 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 updateMesh 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 mapPolyMesh;
80 
81 /*---------------------------------------------------------------------------*\
82  Class MeshObject Declaration
83 \*---------------------------------------------------------------------------*/
84 
85 template<class Mesh, template<class> class MeshObjectType, class Type>
86 class MeshObject
87 :
88  public MeshObjectType<Mesh>
89 {
90 
91 protected:
92 
93  // Reference to Mesh
94  const Mesh& mesh_;
95 
96 
97 public:
98 
99  // Constructors
100 
101  explicit MeshObject(const Mesh& mesh);
102 
103  MeshObject(const Mesh& mesh, const IOobject& io);
104 
105  static Type& New(Mesh& mesh);
106 
107  static const Type& New(const Mesh& mesh);
108 
109  template<class... Args>
110  static Type& New
111  (
112  Mesh& mesh,
113  const Args&... args
114  );
115 
116  template<class... Args>
117  static const Type& New
118  (
119  const Mesh& mesh,
120  const Args&... args
121  );
122 
123 
124  // Destructors
125 
126  virtual ~MeshObject();
127 
128  static bool Delete(const Mesh& mesh);
129 
130 
131  // Member Functions
133  const Mesh& mesh() const
134  {
135  return mesh_;
136  }
138  virtual bool writeData(Foam::Ostream&) const
139  {
140  return true;
141  }
142 };
143 
144 
145 /*---------------------------------------------------------------------------*\
146  Class meshObject Declaration
147 \*---------------------------------------------------------------------------*/
149 class meshObject
150 :
151  public regIOobject
152 {
153 public:
154 
155  // Declare name of the class and its debug switch
156  ClassName("meshObject");
157 
158  // Constructors
159 
160  meshObject(const word& typeName, const objectRegistry& obr);
161 
162  meshObject(const word& typeName, const IOobject& io);
163 
164 
165  // Static member functions
166 
167  template<class Mesh>
168  static void movePoints(objectRegistry&);
169 
170  template<class Mesh>
171  static void updateMesh(objectRegistry&, const mapPolyMesh&);
172 
173  template<class Mesh>
174  static void addPatch(objectRegistry&, const label patchi);
175  template<class Mesh>
176  static void reorderPatches
177  (
179  const labelUList& newToOld,
180  const bool validBoundary
181  );
182 
183  template<class Mesh, template<class> class MeshObjectType>
184  static void clear(objectRegistry&);
185 
186  //- Clear all meshObject derived from FromType up to (but not including)
187  // ToType. Used to clear e.g. all non-updateable meshObjects
188  template
189  <
190  class Mesh,
191  template<class> class FromType,
192  template<class> class ToType
193  >
194  static void clearUpto(objectRegistry&);
195 };
196 
197 
198 /*---------------------------------------------------------------------------*\
199  Class TopologicalMeshObject Declaration
200 \*---------------------------------------------------------------------------*/
201 
202 template<class Mesh>
204 :
205  public meshObject
206 {
207 public:
209  TopologicalMeshObject(const word& typeName, const objectRegistry& obr)
210  :
211  meshObject(typeName, obr)
212  {}
214  TopologicalMeshObject(const word& typeName, const IOobject& io)
215  :
216  meshObject(typeName, io)
217  {}
218 };
219 
220 
221 /*---------------------------------------------------------------------------*\
222  Class GeometricMeshObject Declaration
223 \*---------------------------------------------------------------------------*/
224 
225 template<class Mesh>
227 :
228  public TopologicalMeshObject<Mesh>
229 {
230 public:
232  GeometricMeshObject(const word& typeName, const objectRegistry& obr)
233  :
234  TopologicalMeshObject<Mesh>(typeName, obr)
235  {}
237  GeometricMeshObject(const word& typeName, const IOobject& io)
238  :
239  TopologicalMeshObject<Mesh>(typeName, io)
240  {}
241 };
242 
243 
244 /*---------------------------------------------------------------------------*\
245  Class MoveableMeshObject Declaration
246 \*---------------------------------------------------------------------------*/
247 
248 template<class Mesh>
249 class MoveableMeshObject
250 :
251  public GeometricMeshObject<Mesh>
252 {
253 public:
255  MoveableMeshObject(const word& typeName, const objectRegistry& obr)
256  :
257  GeometricMeshObject<Mesh>(typeName, obr)
258  {}
260  MoveableMeshObject(const word& typeName, const IOobject& io)
261  :
262  GeometricMeshObject<Mesh>(typeName, io)
263  {}
264 
265  virtual bool movePoints() = 0;
266 };
267 
268 
269 /*---------------------------------------------------------------------------*\
270  Class UpdateableMeshObject Declaration
271 \*---------------------------------------------------------------------------*/
272 
273 template<class Mesh>
275 :
276  public MoveableMeshObject<Mesh>
277 {
278 public:
280  UpdateableMeshObject(const word& typeName, const objectRegistry& obr)
281  :
282  MoveableMeshObject<Mesh>(typeName, obr)
283  {}
285  UpdateableMeshObject(const word& typeName, const IOobject& io)
286  :
287  MoveableMeshObject<Mesh>(typeName, io)
288  {}
289 
290  virtual void updateMesh(const mapPolyMesh& mpm) = 0;
291 };
292 
293 
294 /*---------------------------------------------------------------------------*\
295  Class PatchMeshObject Declaration
296 \*---------------------------------------------------------------------------*/
297 
298 template<class Mesh>
299 class PatchMeshObject
300 :
301  public UpdateableMeshObject<Mesh>
302 {
303 public:
305  PatchMeshObject(const word& typeName, const objectRegistry& obr)
306  :
307  UpdateableMeshObject<Mesh>(typeName, obr)
308  {}
310  PatchMeshObject(const word& typeName, const IOobject& io)
311  :
312  UpdateableMeshObject<Mesh>(typeName, io)
313  {}
314 
315  //- Reordered/removed trailing patches. If validBoundary call is parallel
316  // synced and all add the same patch with same settings
317  virtual void reorderPatches
318  (
319  const labelUList& newToOld,
320  const bool validBoundary
321  ) = 0;
322 
323  //- Inserted patch at patchi
324  virtual void addPatch(const label patchi) = 0;
325 };
326 
327 
328 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
329 
330 } // End namespace Foam
331 
332 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
333 
334 #ifdef NoRepository
335  #include "MeshObject.C"
336 #endif
337 
338 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
339 
340 #endif
341 
342 // ************************************************************************* //
tUEqn clear()
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
static bool Delete(const Mesh &mesh)
Definition: MeshObject.C:207
virtual bool writeData(Foam::Ostream &) const
Definition: MeshObject.H:137
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:158
virtual ~MeshObject()
Definition: MeshObject.C:242
#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:85
A class for handling words, derived from string.
Definition: word.H:59
const Mesh & mesh_
Definition: MeshObject.H:93
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:132
label patchi
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:52
Registry of regIOobjects.
Foam::argList args(argc, argv)
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:92
MeshObject(const Mesh &mesh)
Definition: MeshObject.C:31
Namespace for OpenFOAM.