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 | Copyright (C) 2011-2013 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  class leastSquaresVectors
37  :
38  public MeshObject<fvMesh, MoveableMeshObject, leastSquaresVectors>
39  {
40  .
41  .
42  .
43  //- Delete the least square vectors when the mesh moves
44  virtual bool movePoints();
45  };
46 
47  MeshObject types:
48 
49  TopologicalMeshObject: mesh object to be deleted on topology change
50  GeometricMeshObject: mesh object to be deleted on geometry change
51  MoveableMeshObject: mesh object to be updated in movePoints
52  UpdateableMeshObject: mesh object to be updated in updateMesh or movePoints
53 
54  Note that movePoints must be provided for MeshObjects of type
55  MoveableMeshObject and both movePoints and updateMesh functions must exist
56  provided for MeshObjects of type UpdateableMeshObject.
57 
58 SourceFiles
59  MeshObject.C
60 
61 \*---------------------------------------------------------------------------*/
62 
63 #ifndef MeshObject_H
64 #define MeshObject_H
65 
66 #include "regIOobject.H"
67 #include "objectRegistry.H"
68 
69 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
70 
71 namespace Foam
72 {
73 
74 // Forward declarations
75 class mapPolyMesh;
76 
77 /*---------------------------------------------------------------------------*\
78  Class MeshObject Declaration
79 \*---------------------------------------------------------------------------*/
80 
81 template<class Mesh, template<class> class MeshObjectType, class Type>
82 class MeshObject
83 :
84  public MeshObjectType<Mesh>
85 {
86 
87 protected:
88 
89  // Reference to Mesh
90  const Mesh& mesh_;
91 
92 
93 public:
94 
95  // Constructors
96 
97  explicit MeshObject(const Mesh& mesh);
98 
99  static const Type& New(const Mesh& mesh);
100 
101  template<class Data1>
102  static const Type& New
103  (
104  const Mesh& mesh,
105  const Data1& d
106  );
107 
108  template<class Data1, class Data2>
109  static const Type& New
110  (
111  const Mesh& mesh,
112  const Data1&,
113  const Data2&
114  );
115 
116  template<class Data1, class Data2, class Data3>
117  static const Type& New
118  (
119  const Mesh& mesh,
120  const Data1&,
121  const Data2&,
122  const Data3&
123  );
124 
125  template<class Data1, class Data2, class Data3, class Data4>
126  static const Type& New
127  (
128  const Mesh& mesh,
129  const Data1&,
130  const Data2&,
131  const Data3&,
132  const Data4&
133  );
134 
135 
136  // Destructors
137 
138  virtual ~MeshObject();
139 
140  static bool Delete(const Mesh& mesh);
141 
142 
143  // Member Functions
144 
145  const Mesh& mesh() const
146  {
147  return mesh_;
148  }
149 
150  virtual bool writeData(Foam::Ostream&) const
151  {
152  return true;
153  }
154 };
155 
156 
157 /*---------------------------------------------------------------------------*\
158  Class meshObject Declaration
159 \*---------------------------------------------------------------------------*/
160 
161 class meshObject
162 :
163  public regIOobject
164 {
165 public:
166 
167  // Declare name of the class and its debug switch
168  ClassName("meshObject");
169 
170  // Constructors
171 
172  meshObject(const word& typeName, const objectRegistry& obr);
173 
174 
175  // Static member functions
176 
177  template<class Mesh>
178  static void movePoints(objectRegistry&);
179 
180  template<class Mesh>
181  static void updateMesh(objectRegistry&, const mapPolyMesh&);
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:
208 
209  TopologicalMeshObject(const word& typeName, const objectRegistry& obr)
210  :
211  meshObject(typeName, obr)
212  {}
213 };
214 
215 
216 /*---------------------------------------------------------------------------*\
217  Class GeometricMeshObject Declaration
218 \*---------------------------------------------------------------------------*/
219 
220 template<class Mesh>
222 :
223  public TopologicalMeshObject<Mesh>
224 {
225 public:
226 
227  GeometricMeshObject(const word& typeName, const objectRegistry& obr)
228  :
229  TopologicalMeshObject<Mesh>(typeName, obr)
230  {}
231 };
232 
233 
234 /*---------------------------------------------------------------------------*\
235  Class MoveableMeshObject Declaration
236 \*---------------------------------------------------------------------------*/
237 
238 template<class Mesh>
239 class MoveableMeshObject
240 :
241  public GeometricMeshObject<Mesh>
242 {
243 public:
244 
245  MoveableMeshObject(const word& typeName, const objectRegistry& obr)
246  :
247  GeometricMeshObject<Mesh>(typeName, obr)
248  {}
249 
250  virtual bool movePoints() = 0;
251 };
252 
253 
254 /*---------------------------------------------------------------------------*\
255  Class UpdateableMeshObject Declaration
256 \*---------------------------------------------------------------------------*/
257 
258 template<class Mesh>
260 :
261  public MoveableMeshObject<Mesh>
262 {
263 public:
264 
265  UpdateableMeshObject(const word& typeName, const objectRegistry& obr)
266  :
267  MoveableMeshObject<Mesh>(typeName, obr)
268  {}
269 
270  virtual void updateMesh(const mapPolyMesh& mpm) = 0;
271 };
272 
273 
274 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
275 
276 } // End namespace Foam
277 
278 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
279 
280 #ifdef NoRepository
281 # include "MeshObject.C"
282 #endif
283 
284 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
285 
286 #endif
287 
288 // ************************************************************************* //
regIOobject.H
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::GeometricMeshObject
Definition: MeshObject.H:220
Foam::MeshObject::MeshObject
MeshObject(const Mesh &mesh)
Definition: MeshObject.C:33
objectRegistry.H
Foam::MoveableMeshObject
Definition: MeshObject.H:238
Foam::UpdateableMeshObject
Definition: MeshObject.H:258
Foam::MeshObject::New
static const Type & New(const Mesh &mesh)
Definition: MeshObject.C:44
Foam::objectRegistry
Registry of regIOobjects.
Definition: objectRegistry.H:50
Foam::meshObject::movePoints
static void movePoints(objectRegistry &)
Definition: MeshObject.C:286
Foam::meshObject::clearUpto
static void clearUpto(objectRegistry &)
Clear all meshObject derived from FromType up to (but not including)
Definition: MeshObject.C:401
Foam::meshObject::clear
static void clear(objectRegistry &)
Definition: MeshObject.C:370
Foam::MeshObject::mesh
const Mesh & mesh() const
Definition: MeshObject.H:144
Foam::MoveableMeshObject::MoveableMeshObject
MoveableMeshObject(const word &typeName, const objectRegistry &obr)
Definition: MeshObject.H:244
MeshObject.C
Foam::UpdateableMeshObject::UpdateableMeshObject
UpdateableMeshObject(const word &typeName, const objectRegistry &obr)
Definition: MeshObject.H:264
Foam::MoveableMeshObject::movePoints
virtual bool movePoints()=0
Foam::MeshObject::mesh_
const Mesh & mesh_
Definition: MeshObject.H:89
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::meshObject::updateMesh
static void updateMesh(objectRegistry &, const mapPolyMesh &)
Definition: MeshObject.C:328
Foam::GeometricMeshObject::GeometricMeshObject
GeometricMeshObject(const word &typeName, const objectRegistry &obr)
Definition: MeshObject.H:226
Foam::meshObject
Definition: MeshObject.H:160
Foam::MeshObject::Delete
static bool Delete(const Mesh &mesh)
Definition: MeshObject.C:244
Foam::regIOobject
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:60
Foam::meshObject::ClassName
ClassName("meshObject")
Foam::TopologicalMeshObject::TopologicalMeshObject
TopologicalMeshObject(const word &typeName, const objectRegistry &obr)
Definition: MeshObject.H:208
Foam::TopologicalMeshObject
Definition: MeshObject.H:202
Foam::meshObject::meshObject
meshObject(const word &typeName, const objectRegistry &obr)
Definition: meshObject.C:38
Foam::mapPolyMesh
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:158
Foam::MeshObject
Templated abstract base-class for optional mesh objects used to automate their allocation to the mesh...
Definition: MeshObject.H:81
Foam::MeshObject::~MeshObject
virtual ~MeshObject()
Definition: MeshObject.C:279
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
Foam::MeshObject::writeData
virtual bool writeData(Foam::Ostream &) const
Definition: MeshObject.H:149
Foam::UpdateableMeshObject::updateMesh
virtual void updateMesh(const mapPolyMesh &mpm)=0