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-2018 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 
57 Note
58  movePoints must be provided for MeshObjects of type MoveableMeshObject
59  and both movePoints and updateMesh functions must exist, provided for
60  MeshObjects of type UpdateableMeshObject.
61 
62 SourceFiles
63  MeshObject.C
64 
65 \*---------------------------------------------------------------------------*/
66 
67 #ifndef MeshObject_H
68 #define MeshObject_H
69 
70 #include "regIOobject.H"
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  static const Type& New(const Mesh& mesh);
104 
105  template<class Data1>
106  static const Type& New
107  (
108  const Mesh& mesh,
109  const Data1& d
110  );
111 
112  template<class Data1, class Data2>
113  static const Type& New
114  (
115  const Mesh& mesh,
116  const Data1&,
117  const Data2&
118  );
119 
120  template<class Data1, class Data2, class Data3>
121  static const Type& New
122  (
123  const Mesh& mesh,
124  const Data1&,
125  const Data2&,
126  const Data3&
127  );
128 
129  template<class Data1, class Data2, class Data3, class Data4>
130  static const Type& New
131  (
132  const Mesh& mesh,
133  const Data1&,
134  const Data2&,
135  const Data3&,
136  const Data4&
137  );
138 
139 
140  // Destructors
141 
142  virtual ~MeshObject();
143 
144  static bool Delete(const Mesh& mesh);
145 
146 
147  // Member Functions
149  const Mesh& mesh() const
150  {
151  return mesh_;
152  }
154  virtual bool writeData(Foam::Ostream&) const
155  {
156  return true;
157  }
158 };
159 
160 
161 /*---------------------------------------------------------------------------*\
162  Class meshObject Declaration
163 \*---------------------------------------------------------------------------*/
165 class meshObject
166 :
167  public regIOobject
168 {
169 public:
170 
171  // Declare name of the class and its debug switch
172  ClassName("meshObject");
173 
174  // Constructors
175 
176  meshObject(const word& typeName, const objectRegistry& obr);
177 
178 
179  // Static member functions
180 
181  template<class Mesh>
182  static void movePoints(objectRegistry&);
183 
184  template<class Mesh>
185  static void updateMesh(objectRegistry&, const mapPolyMesh&);
186 
187  template<class Mesh, template<class> class MeshObjectType>
188  static void clear(objectRegistry&);
189 
190  //- Clear all meshObject derived from FromType up to (but not including)
191  // ToType. Used to clear e.g. all non-updateable meshObjects
192  template
193  <
194  class Mesh,
195  template<class> class FromType,
196  template<class> class ToType
197  >
198  static void clearUpto(objectRegistry&);
199 };
200 
201 
202 /*---------------------------------------------------------------------------*\
203  Class TopologicalMeshObject Declaration
204 \*---------------------------------------------------------------------------*/
205 
206 template<class Mesh>
208 :
209  public meshObject
210 {
211 public:
213  TopologicalMeshObject(const word& typeName, const objectRegistry& obr)
214  :
215  meshObject(typeName, obr)
216  {}
217 };
218 
219 
220 /*---------------------------------------------------------------------------*\
221  Class GeometricMeshObject Declaration
222 \*---------------------------------------------------------------------------*/
223 
224 template<class Mesh>
226 :
227  public TopologicalMeshObject<Mesh>
228 {
229 public:
231  GeometricMeshObject(const word& typeName, const objectRegistry& obr)
232  :
233  TopologicalMeshObject<Mesh>(typeName, obr)
234  {}
235 };
236 
237 
238 /*---------------------------------------------------------------------------*\
239  Class MoveableMeshObject Declaration
240 \*---------------------------------------------------------------------------*/
241 
242 template<class Mesh>
243 class MoveableMeshObject
244 :
245  public GeometricMeshObject<Mesh>
246 {
247 public:
249  MoveableMeshObject(const word& typeName, const objectRegistry& obr)
250  :
251  GeometricMeshObject<Mesh>(typeName, obr)
252  {}
253 
254  virtual bool movePoints() = 0;
255 };
256 
257 
258 /*---------------------------------------------------------------------------*\
259  Class UpdateableMeshObject Declaration
260 \*---------------------------------------------------------------------------*/
261 
262 template<class Mesh>
264 :
265  public MoveableMeshObject<Mesh>
266 {
267 public:
269  UpdateableMeshObject(const word& typeName, const objectRegistry& obr)
270  :
271  MoveableMeshObject<Mesh>(typeName, obr)
272  {}
273 
274  virtual void updateMesh(const mapPolyMesh& mpm) = 0;
275 };
276 
277 
278 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
279 
280 } // End namespace Foam
281 
282 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
283 
284 #ifdef NoRepository
285  #include "MeshObject.C"
286 #endif
287 
288 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
289 
290 #endif
291 
292 // ************************************************************************* //
tUEqn clear()
static bool Delete(const Mesh &mesh)
Definition: MeshObject.C:244
virtual bool writeData(Foam::Ostream &) const
Definition: MeshObject.H:153
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:85
A class for handling words, derived from string.
Definition: word.H:59
const Mesh & mesh_
Definition: MeshObject.H:93
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
const Mesh & mesh() const
Definition: MeshObject.H:148
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:65
Registry of regIOobjects.
MeshObject(const Mesh &mesh)
Definition: MeshObject.C:33
Namespace for OpenFOAM.