MeshObject.H
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2011-2016 OpenFOAM Foundation
9 Copyright (C) 2018-2019 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27Class
28 Foam::MeshObject
29
30Description
31 Templated abstract base-class for optional mesh objects used to automate
32 their allocation to the mesh database and the mesh-modifier event-loop.
33
34 MeshObject is templated on the type of mesh it is allocated to, the type of
35 the mesh object (TopologicalMeshObject, GeometricMeshObject,
36 MoveableMeshObject, UpdateableMeshObject) and the type of the actual object
37 it is created for example:
38
39 \verbatim
40 class leastSquaresVectors
41 :
42 public MeshObject<fvMesh, MoveableMeshObject, leastSquaresVectors>
43 {
44 .
45 .
46 .
47 //- Delete the least square vectors when the mesh moves
48 virtual bool movePoints();
49 };
50 \endverbatim
51
52 MeshObject types:
53
54 - TopologicalMeshObject: mesh object to be deleted on topology change
55 - GeometricMeshObject: mesh object to be deleted on geometry change
56 - MoveableMeshObject: mesh object to be updated in movePoints
57 - UpdateableMeshObject: mesh object to be updated in updateMesh or
58 movePoints
59
60Note
61 movePoints must be provided for MeshObjects of type MoveableMeshObject
62 and both movePoints and updateMesh functions must exist, provided for
63 MeshObjects of type UpdateableMeshObject.
64
65SourceFiles
66 MeshObject.C
67
68\*---------------------------------------------------------------------------*/
69
70#ifndef MeshObject_H
71#define MeshObject_H
72
73#include "regIOobject.H"
74#include "objectRegistry.H"
75
76// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
77
78namespace Foam
79{
80
81// Forward declarations
82class mapPolyMesh;
83
84/*---------------------------------------------------------------------------*\
85 Class MeshObject Declaration
86\*---------------------------------------------------------------------------*/
87
88template<class Mesh, template<class> class MeshObjectType, class Type>
89class MeshObject
90:
91 public MeshObjectType<Mesh>
92{
93
94protected:
95
96 // Reference to Mesh
97 const Mesh& mesh_;
98
99
100public:
101
102 // Constructors
103
104 //- Construct on Mesh type
105 explicit MeshObject(const Mesh& mesh);
106
107 // Selectors
108
109 //- Get existing or create a new MeshObject
110 template<class... Args>
111 static const Type& New(const Mesh& mesh, Args&&... args);
112
113
114 //- Destructor
115 virtual ~MeshObject() = default;
116
117 //- Static destructor
118 static bool Delete(const Mesh& mesh);
119
120
121 // Member Functions
123 const Mesh& mesh() const
124 {
125 return mesh_;
126 }
128 virtual bool writeData(Ostream& os) const
129 {
130 return true;
131 }
132};
133
134
135/*---------------------------------------------------------------------------*\
136 Class meshObject Declaration
137\*---------------------------------------------------------------------------*/
139class meshObject
140:
141 public regIOobject
142{
143public:
144
145 // Declare name of the class and its debug switch
146 ClassName("meshObject");
147
148 // Constructors
149
150 //- Construct from name and instance on registry
151 meshObject(const word& typeName, const objectRegistry& obr);
152
153
154 // Static Member Functions
155
156 template<class Mesh>
157 static void movePoints(objectRegistry& obr);
158
159 template<class Mesh>
160 static void updateMesh(objectRegistry& obr, const mapPolyMesh& mpm);
161
162 template<class Mesh, template<class> class MeshObjectType>
163 static void clear(objectRegistry& obr);
164
165 //- Clear all meshObject derived from FromType up to
166 //- (but not including) ToType.
167 // Used to clear e.g. all non-updateable meshObjects
168 template
169 <
170 class Mesh,
171 template<class> class FromType,
172 template<class> class ToType
173 >
174 static void clearUpto(objectRegistry& obr);
175};
176
177
178/*---------------------------------------------------------------------------*\
179 Class TopologicalMeshObject Declaration
180\*---------------------------------------------------------------------------*/
181
182template<class Mesh>
184:
185 public meshObject
186{
187public:
188
189 //- Construct from name and instance on registry
190 TopologicalMeshObject(const word& typeName, const objectRegistry& obr)
191 :
192 meshObject(typeName, obr)
193 {}
194};
195
196
197/*---------------------------------------------------------------------------*\
198 Class GeometricMeshObject Declaration
199\*---------------------------------------------------------------------------*/
200
201template<class Mesh>
203:
204 public TopologicalMeshObject<Mesh>
205{
206public:
207
208 //- Construct from name and instance on registry
209 GeometricMeshObject(const word& typeName, const objectRegistry& obr)
210 :
211 TopologicalMeshObject<Mesh>(typeName, obr)
212 {}
213};
214
215
216/*---------------------------------------------------------------------------*\
217 Class MoveableMeshObject Declaration
218\*---------------------------------------------------------------------------*/
219
220template<class Mesh>
222:
223 public GeometricMeshObject<Mesh>
224{
225public:
226
227 //- Construct from name and instance on registry
228 MoveableMeshObject(const word& typeName, const objectRegistry& obr)
229 :
230 GeometricMeshObject<Mesh>(typeName, obr)
231 {}
233 virtual bool movePoints() = 0;
234};
235
236
237/*---------------------------------------------------------------------------*\
238 Class UpdateableMeshObject Declaration
239\*---------------------------------------------------------------------------*/
240
241template<class Mesh>
243:
244 public MoveableMeshObject<Mesh>
245{
246public:
247
248 //- Construct from name and instance on registry
249 UpdateableMeshObject(const word& typeName, const objectRegistry& obr)
250 :
251 MoveableMeshObject<Mesh>(typeName, obr)
252 {}
254 virtual void updateMesh(const mapPolyMesh& mpm) = 0;
255};
256
257
258// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
259
260} // End namespace Foam
261
262// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
263
264#ifdef NoRepository
265 #include "MeshObject.C"
266#endif
267
268// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
269
270#endif
271
272// ************************************************************************* //
GeometricMeshObject(const word &typeName, const objectRegistry &obr)
Construct from name and instance on registry.
Definition: MeshObject.H:208
Templated abstract base-class for optional mesh objects used to automate their allocation to the mesh...
Definition: MeshObject.H:91
static const Type & New(const Mesh &mesh, Args &&... args)
Get existing or create a new MeshObject.
Definition: MeshObject.C:48
static bool Delete(const Mesh &mesh)
Static destructor.
Definition: MeshObject.C:82
virtual ~MeshObject()=default
Destructor.
const Mesh & mesh() const
Definition: MeshObject.H:122
virtual bool writeData(Ostream &os) const
Definition: MeshObject.H:127
const Mesh & mesh_
Definition: MeshObject.H:96
virtual bool movePoints()=0
MoveableMeshObject(const word &typeName, const objectRegistry &obr)
Construct from name and instance on registry.
Definition: MeshObject.H:227
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
TopologicalMeshObject(const word &typeName, const objectRegistry &obr)
Construct from name and instance on registry.
Definition: MeshObject.H:189
UpdateableMeshObject(const word &typeName, const objectRegistry &obr)
Construct from name and instance on registry.
Definition: MeshObject.H:248
virtual void updateMesh(const mapPolyMesh &mpm)=0
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:162
static void clearUpto(objectRegistry &obr)
Definition: MeshObject.C:217
static void updateMesh(objectRegistry &obr, const mapPolyMesh &mpm)
Definition: MeshObject.C:146
ClassName("meshObject")
static void movePoints(objectRegistry &obr)
Definition: MeshObject.C:106
Registry of regIOobjects.
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:76
A class for handling words, derived from Foam::string.
Definition: word.H:68
#define ClassName(TypeNameString)
Add typeName information from argument TypeNameString to a class.
Definition: className.H:67
patchWriters clear()
OBJstream os(runTime.globalPath()/outputName)
Namespace for OpenFOAM.
Foam::argList args(argc, argv)