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-2023 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
33  to, the type of the mesh object (TopologicalMeshObject, GeometricMeshObject,
34  MoveableMeshObject, DistributeableMeshObject, UpdateableMeshObject) and the
35  type of the 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  - TopologicalMeshObject: mesh object to be deleted on topology change
58  - GeometricMeshObject: mesh object to be deleted on geometry change
59  - MoveableMeshObject: mesh object to be updated in movePoints
60  - UpdateableMeshObject: mesh object to be updated in topoChange or
61  movePoints
62  - PatchMeshObject: mesh object to be additionally updated patch changes
63 
64  DemandDrivenMeshObject should always be constructed and accessed via the New
65  methods provided so that they are held and maintained by the objectRegistry.
66  To ensure this use constructors of the concrete derived types should be
67  private or protected and friendship with the DemandDrivenMeshObject
68  base-class declared so that the New functions can call the the constructors.
69 
70 SourceFiles
71  DemandDrivenMeshObject.C
72 
73 \*---------------------------------------------------------------------------*/
74 
75 #ifndef DemandDrivenMeshObject_H
76 #define DemandDrivenMeshObject_H
77 
78 #include "MeshObjects.H"
79 
80 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
81 
82 namespace Foam
83 {
84 
85 /*---------------------------------------------------------------------------*\
86  Class DemandDrivenMeshObject Declaration
87 \*---------------------------------------------------------------------------*/
88 
89 template<class Mesh, template<class> class MeshObjectType, class Type>
91 :
92  public regIOobject,
93  public MeshObjectType<Mesh>
94 {
95  // Private member data
96 
97  // Reference to Mesh
98  const Mesh& mesh_;
99 
100 
101 protected:
102 
103  // Constructors
104 
105  //- Construct from mesh
106  // Only derived classes can construct DemandDrivenMeshObject
107  DemandDrivenMeshObject(const Mesh& mesh);
108 
109  //- Construct from mesh and IOobject
110  // Only derived classes can construct DemandDrivenMeshObject
111  DemandDrivenMeshObject(const Mesh& mesh, const IOobject& io);
112 
113 
114 public:
115 
116  // Constructors
117 
118  static Type& New(const Mesh& mesh);
119 
120  template<class... Args>
121  static Type& New
122  (
123  const Mesh& mesh,
124  const Args&... args
125  );
126 
127 
128  // Destructors
129 
130  virtual ~DemandDrivenMeshObject();
131 
132  //- Lookup DemandDrivenMeshObject and delete
133  static bool Delete(const Mesh& mesh);
134 
135 
136  // Member Functions
137 
138  //- Return true if this DemandDrivenMeshObject is found
139  // in the mesh registry
140  static bool found(const Mesh& mesh);
141 
142  const Mesh& mesh() const
143  {
144  return mesh_;
145  }
146 
147  virtual bool writeData(Foam::Ostream&) const
148  {
149  return true;
150  }
151 };
152 
153 
154 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
155 
156 } // End namespace Foam
157 
158 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
159 
160 #ifdef NoRepository
161  #include "DemandDrivenMeshObject.C"
162 #endif
163 
164 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
165 
166 #endif
167 
168 // ************************************************************************* //
Templated abstract base-class for demand-driven mesh objects used to automate their allocation to the...
static bool Delete(const Mesh &mesh)
Lookup DemandDrivenMeshObject and delete.
static Type & New(const Mesh &mesh)
virtual bool writeData(Foam::Ostream &) const
Pure virtual writaData function.
DemandDrivenMeshObject(const Mesh &mesh)
Construct from mesh.
static bool found(const Mesh &mesh)
Return true if this DemandDrivenMeshObject is found.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:99
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
Namespace for OpenFOAM.
Foam::argList args(argc, argv)