DemandDrivenMeshObject.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-2026 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::DemandDrivenMeshObject
26 
27 Description
28  Templated abstract base-class for demand-driven mesh objects used to
29  automate their allocation to the mesh database and the m esh-modifier
30  event-loop.
31 
32  DemandDrivenMeshObject is templated on the type of mesh it is allocated to,
33  the type of the mesh object (DeletableMeshObject, MoveableMeshObject,
34  DistributeableMeshObject, TopoChangeableMeshObject), the type of the object
35  it is created for and optionally the type of registered object
36  which defaults to regIOobject, e.g.:
37  \verbatim
38  class leastSquaresVectors
39  :
40  public DemandDrivenMeshObject
41  <
42  fvMesh,
43  MoveableMeshObject,
44  leastSquaresVectors
45  >
46  {
47  .
48  .
49  .
50  //- Delete the least square vectors when the mesh moves
51  virtual bool movePoints();
52  };
53  \endverbatim
54 
55  or if the object is read from a special IOdictionary it can be derived
56  from an IOdictionary stored by the DemandDrivenMeshObject, e.g.:
57  \verbatim
58  class fvModels
59  :
60  public DemandDrivenMeshObject
61  <
62  fvMesh,
63  TopoChangeableMeshObject,
64  fvModels,
65  IOdictionary
66  >,
67  public MRFZoneList
68  {
69  .
70  .
71  .
72  };
73  \endverbatim
74 
75  MeshObject types:
76 
77  - DeletableMeshObject:
78  mesh object to be deleted after any mesh change
79  - MoveableMeshObject:
80  mesh object to be updated after mesh motion otherwise deleted
81  - DistributeableMeshObject
82  mesh object to be updated after mesh redistribution or motion
83  otherwise deleted
84  - TopoChangeableMeshObject:
85  mesh object to be updated after mesh topology change,
86  mesh-to-mesh mapping, redistribution or motion otherwise deleted
87  - RepatchableMeshObject:
88  mesh object to be updated on patch or topology change,
89  mesh-to-mesh mapping, redistribution or motion otherwise deleted
90 
91  DemandDrivenMeshObject should always be constructed and accessed via the New
92  methods provided so that they are held and maintained by the objectRegistry.
93  To ensure this use constructors of the concrete derived types should be
94  private or protected and friendship with the DemandDrivenMeshObject
95  base-class declared so that the New functions can call the the constructors.
96 
97 SourceFiles
98  DemandDrivenMeshObject.C
99 
100 \*---------------------------------------------------------------------------*/
101 
102 #ifndef DemandDrivenMeshObject_H
103 #define DemandDrivenMeshObject_H
104 
105 #include "MeshObjects.H"
106 
107 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
108 
109 namespace Foam
110 {
111 
112 /*---------------------------------------------------------------------------*\
113  Class DemandDrivenMeshObject Declaration
114 \*---------------------------------------------------------------------------*/
115 
116 template
117 <
118  class Mesh,
119  template<class> class MeshObjectType,
120  class Type,
121  class RegIOobject = regIOobject
122 >
124 :
125  public RegIOobject,
126  public MeshObjectType<Mesh>
127 {
128  // Private Data
129 
130  // Reference to Mesh
131  const Mesh& mesh_;
132 
133 
134 protected:
135 
136  // Constructors
137 
138  //- Construct from mesh and IOobject
139  // Only derived classes can construct DemandDrivenMeshObject
140  DemandDrivenMeshObject(const IOobject& io, const Mesh& mesh);
141 
142  //- Construct from mesh and name
143  // Only derived classes can construct DemandDrivenMeshObject
144  DemandDrivenMeshObject(const word& name, const Mesh& mesh);
145 
146  //- Construct from mesh, the name is set to Type::typeName
147  // Only derived classes can construct DemandDrivenMeshObject
148  DemandDrivenMeshObject(const Mesh& mesh);
149 
150 
151 public:
152 
153  //- Runtime type information
154  virtual const word& type() const;
155 
156 
157  // Constructors
158 
159  //- Construct and return the named DemandDrivenMeshObject
160  static Type& New(const word& name, const Mesh& mesh);
161 
162  //- Construct and return the DemandDrivenMeshObject named Type::typeName
163  static Type& New(const Mesh& mesh);
164 
165  //- Construct and return the named DemandDrivenMeshObject
166  // with the additional arguments
167  template<class... Args>
168  static Type& New
169  (
170  const word& name,
171  const Mesh& mesh,
172  const Args&... args
173  );
174 
175  //- Construct and return the DemandDrivenMeshObject named Type::typeName
176  // with the additional arguments
177  template<class... Args>
178  static Type& New
179  (
180  const Mesh& mesh,
181  const Args&... args
182  );
183 
184 
185  // Destructors
186 
187  virtual ~DemandDrivenMeshObject();
188 
189 
190  // Member Functions
191 
192  //- Return true if the DemandDrivenMeshObject with the given name
193  // is found in the mesh registry
194  static bool found(const word& name, const Mesh& mesh);
195 
196  //- Return true if the DemandDrivenMeshObject named Type::typeName
197  // is found in the mesh registry
198  static bool found(const Mesh& mesh);
199 
200  const Mesh& mesh() const
201  {
202  return mesh_;
203  }
204 
205  virtual bool writeData(Foam::Ostream&) const
206  {
207  return true;
208  }
209 
210  //- Write using given format, version and compression
211  virtual bool writeObject
212  (
216  const bool write
217  ) const
218  {
219  return true;
220  }
221 };
222 
223 
224 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
225 
226 } // End namespace Foam
227 
228 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
229 
230 #ifdef NoRepository
231  #include "DemandDrivenMeshObject.C"
232 #endif
233 
234 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
235 
236 #endif
237 
238 // ************************************************************************* //
Templated abstract base-class for demand-driven mesh objects used to automate their allocation to the...
DemandDrivenMeshObject(const IOobject &io, const Mesh &mesh)
Construct from mesh and IOobject.
virtual bool writeData(Foam::Ostream &) const
Pure virtual writaData function.
static bool found(const word &name, const Mesh &mesh)
Return true if the DemandDrivenMeshObject with the given name.
virtual bool writeObject(IOstream::streamFormat, IOstream::versionNumber, IOstream::compressionType, const bool write) const
Write using given format, version and compression.
static Type & New(const word &name, const Mesh &mesh)
Construct and return the named DemandDrivenMeshObject.
virtual const word & type() const
Runtime type information.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:99
const word & name() const
Return name.
Definition: IOobject.H:307
Version number type.
Definition: IOstream.H:97
streamFormat
Enumeration for the format of data in the stream.
Definition: IOstream.H:87
compressionType
Enumeration for the format of data in the stream.
Definition: IOstream.H:194
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
virtual bool write(const bool write=true) const
Write using setting from DB.
A class for handling words, derived from string.
Definition: word.H:63
Namespace for OpenFOAM.
Foam::argList args(argc, argv)