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-2024 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 mesh-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) and the type of the
35  actual object it is created for example:
36 
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  MeshObject types:
56 
57  - DeletableMeshObject:
58  mesh object to be deleted after any mesh change
59  - MoveableMeshObject:
60  mesh object to be updated after mesh motion otherwise deleted
61  - DistributeableMeshObject
62  mesh object to be updated after mesh redistribution or motion
63  otherwise deleted
64  - TopoChangeableMeshObject:
65  mesh object to be updated after mesh topology change,
66  mesh-to-mesh mapping, redistribution or motion otherwise deleted
67  - RepatchableMeshObject:
68  mesh object to be updated on patch or topology change,
69  mesh-to-mesh mapping, redistribution or motion otherwise deleted
70 
71  DemandDrivenMeshObject should always be constructed and accessed via the New
72  methods provided so that they are held and maintained by the objectRegistry.
73  To ensure this use constructors of the concrete derived types should be
74  private or protected and friendship with the DemandDrivenMeshObject
75  base-class declared so that the New functions can call the the constructors.
76 
77 SourceFiles
78  DemandDrivenMeshObject.C
79 
80 \*---------------------------------------------------------------------------*/
81 
82 #ifndef DemandDrivenMeshObject_H
83 #define DemandDrivenMeshObject_H
84 
85 #include "MeshObjects.H"
86 
87 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
88 
89 namespace Foam
90 {
91 
92 /*---------------------------------------------------------------------------*\
93  Class DemandDrivenMeshObject Declaration
94 \*---------------------------------------------------------------------------*/
95 
96 template<class Mesh, template<class> class MeshObjectType, class Type>
98 :
99  public regIOobject,
100  public MeshObjectType<Mesh>
101 {
102  // Private member data
103 
104  // Reference to Mesh
105  const Mesh& mesh_;
106 
107 
108 protected:
109 
110  // Constructors
111 
112  //- Construct from mesh and IOobject
113  // Only derived classes can construct DemandDrivenMeshObject
114  DemandDrivenMeshObject(const IOobject& io, const Mesh& mesh);
115 
116  //- Construct from mesh and name
117  // Only derived classes can construct DemandDrivenMeshObject
118  DemandDrivenMeshObject(const word& name, const Mesh& mesh);
119 
120  //- Construct from mesh, the name is set to Type::typeName
121  // Only derived classes can construct DemandDrivenMeshObject
122  DemandDrivenMeshObject(const Mesh& mesh);
123 
124 
125 public:
126 
127  //- Runtime type information
128  virtual const word& type() const;
129 
130 
131  // Constructors
132 
133  //- Construct and return the named DemandDrivenMeshObject
134  static Type& New(const word& name, const Mesh& mesh);
135 
136  //- Construct and return the DemandDrivenMeshObject named Type::typeName
137  static Type& New(const Mesh& mesh);
138 
139  //- Construct and return the named DemandDrivenMeshObject
140  // with the additional arguments
141  template<class... Args>
142  static Type& New
143  (
144  const word& name,
145  const Mesh& mesh,
146  const Args&... args
147  );
148 
149  //- Construct and return the DemandDrivenMeshObject named Type::typeName
150  // with the additional arguments
151  template<class... Args>
152  static Type& New
153  (
154  const Mesh& mesh,
155  const Args&... args
156  );
157 
158 
159  // Destructors
160 
161  virtual ~DemandDrivenMeshObject();
162 
163 
164  // Member Functions
165 
166  //- Return true if the DemandDrivenMeshObject with the given name
167  // is found in the mesh registry
168  static bool found(const word& name, const Mesh& mesh);
169 
170  //- Return true if the DemandDrivenMeshObject named Type::typeName
171  // is found in the mesh registry
172  static bool found(const Mesh& mesh);
173 
174  const Mesh& mesh() const
175  {
176  return mesh_;
177  }
178 
179  virtual bool writeData(Foam::Ostream&) const
180  {
181  return true;
182  }
183 };
184 
185 
186 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
187 
188 } // End namespace Foam
189 
190 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
191 
192 #ifdef NoRepository
193  #include "DemandDrivenMeshObject.C"
194 #endif
195 
196 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
197 
198 #endif
199 
200 // ************************************************************************* //
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.
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:310
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:55
A class for handling words, derived from string.
Definition: word.H:62
Namespace for OpenFOAM.
Foam::argList args(argc, argv)