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-2019 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 "regIOobject.H"
72 #include "objectRegistry.H"
73 
74 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
75 
76 namespace Foam
77 {
78 
79 // Forward declarations
80 class mapPolyMesh;
81 
82 /*---------------------------------------------------------------------------*\
83  Class MeshObject Declaration
84 \*---------------------------------------------------------------------------*/
85 
86 template<class Mesh, template<class> class MeshObjectType, class Type>
87 class MeshObject
88 :
89  public MeshObjectType<Mesh>
90 {
91 
92 protected:
93 
94  // Reference to Mesh
95  const Mesh& mesh_;
96 
97 
98 public:
99 
100  // Constructors
101 
102  explicit MeshObject(const Mesh& mesh);
103 
104  static const Type& New(const Mesh& mesh);
105 
106  template<class Data1>
107  static const Type& New
108  (
109  const Mesh& mesh,
110  const Data1& d
111  );
112 
113  template<class Data1, class Data2>
114  static const Type& New
115  (
116  const Mesh& mesh,
117  const Data1&,
118  const Data2&
119  );
120 
121  template<class Data1, class Data2, class Data3>
122  static const Type& New
123  (
124  const Mesh& mesh,
125  const Data1&,
126  const Data2&,
127  const Data3&
128  );
129 
130  template<class Data1, class Data2, class Data3, class Data4>
131  static const Type& New
132  (
133  const Mesh& mesh,
134  const Data1&,
135  const Data2&,
136  const Data3&,
137  const Data4&
138  );
139 
140 
141  // Destructors
142 
143  virtual ~MeshObject();
144 
145  static bool Delete(const Mesh& mesh);
146 
147 
148  // Member Functions
150  const Mesh& mesh() const
151  {
152  return mesh_;
153  }
155  virtual bool writeData(Foam::Ostream&) const
156  {
157  return true;
158  }
159 };
160 
161 
162 /*---------------------------------------------------------------------------*\
163  Class meshObject Declaration
164 \*---------------------------------------------------------------------------*/
166 class meshObject
167 :
168  public regIOobject
169 {
170 public:
171 
172  // Declare name of the class and its debug switch
173  ClassName("meshObject");
174 
175  // Constructors
176 
177  meshObject(const word& typeName, const objectRegistry& obr);
178 
179 
180  // Static member functions
181 
182  template<class Mesh>
183  static void movePoints(objectRegistry&);
184 
185  template<class Mesh>
186  static void updateMesh(objectRegistry&, const mapPolyMesh&);
187 
188  template<class Mesh>
189  static void addPatch(objectRegistry&, const label patchi);
190  template<class Mesh>
191  static void reorderPatches
192  (
194  const labelUList& newToOld,
195  const bool validBoundary
196  );
197 
198  template<class Mesh, template<class> class MeshObjectType>
199  static void clear(objectRegistry&);
200 
201  //- Clear all meshObject derived from FromType up to (but not including)
202  // ToType. Used to clear e.g. all non-updateable meshObjects
203  template
204  <
205  class Mesh,
206  template<class> class FromType,
207  template<class> class ToType
208  >
209  static void clearUpto(objectRegistry&);
210 };
211 
212 
213 /*---------------------------------------------------------------------------*\
214  Class TopologicalMeshObject Declaration
215 \*---------------------------------------------------------------------------*/
216 
217 template<class Mesh>
219 :
220  public meshObject
221 {
222 public:
224  TopologicalMeshObject(const word& typeName, const objectRegistry& obr)
225  :
226  meshObject(typeName, obr)
227  {}
228 };
229 
230 
231 /*---------------------------------------------------------------------------*\
232  Class GeometricMeshObject Declaration
233 \*---------------------------------------------------------------------------*/
234 
235 template<class Mesh>
237 :
238  public TopologicalMeshObject<Mesh>
239 {
240 public:
242  GeometricMeshObject(const word& typeName, const objectRegistry& obr)
243  :
244  TopologicalMeshObject<Mesh>(typeName, obr)
245  {}
246 };
247 
248 
249 /*---------------------------------------------------------------------------*\
250  Class MoveableMeshObject Declaration
251 \*---------------------------------------------------------------------------*/
252 
253 template<class Mesh>
254 class MoveableMeshObject
255 :
256  public GeometricMeshObject<Mesh>
257 {
258 public:
260  MoveableMeshObject(const word& typeName, const objectRegistry& obr)
261  :
262  GeometricMeshObject<Mesh>(typeName, obr)
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  {}
284 
285  virtual void updateMesh(const mapPolyMesh& mpm) = 0;
286 };
287 
288 
289 /*---------------------------------------------------------------------------*\
290  Class PatchMeshObject Declaration
291 \*---------------------------------------------------------------------------*/
292 
293 template<class Mesh>
294 class PatchMeshObject
295 :
296  public UpdateableMeshObject<Mesh>
297 {
298 public:
300  PatchMeshObject(const word& typeName, const objectRegistry& obr)
301  :
302  UpdateableMeshObject<Mesh>(typeName, obr)
303  {}
304 
305  //- Reordered/removed trailing patches. If validBoundary call is parallel
306  // synced and all add the same patch with same settings
307  virtual void reorderPatches
308  (
309  const labelUList& newToOld,
310  const bool validBoundary
311  ) = 0;
312 
313  //- Inserted patch at patchi
314  virtual void addPatch(const label patchi) = 0;
315 };
316 
317 
318 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
319 
320 } // End namespace Foam
321 
322 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
323 
324 #ifdef NoRepository
325  #include "MeshObject.C"
326 #endif
327 
328 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
329 
330 #endif
331 
332 // ************************************************************************* //
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:244
virtual bool writeData(Foam::Ostream &) const
Definition: MeshObject.H:154
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:158
static const Type & New(const Mesh &mesh)
Definition: MeshObject.C:44
virtual ~MeshObject()
Definition: MeshObject.C:279
#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:86
A class for handling words, derived from string.
Definition: word.H:59
const Mesh & mesh_
Definition: MeshObject.H:94
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
const Mesh & mesh() const
Definition: MeshObject.H:149
label patchi
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:55
Registry of regIOobjects.
MeshObject(const Mesh &mesh)
Definition: MeshObject.C:33
Namespace for OpenFOAM.