fvModels.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) 2021-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::fvModels
26 
27 Description
28  Finite volume models
29 
30 SourceFiles
31  fvModels.C
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef fvModels_H
36 #define fvModels_H
37 
38 #include "fvModel.H"
39 #include "PtrListDictionary.H"
40 #include "DemandDrivenMeshObject.H"
41 #include "IOdictionary.H"
42 #include "HashSet.H"
43 #include "geometricOneField.H"
44 
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 
47 namespace Foam
48 {
49 
50 // Forward declaration of friend functions and operators
51 class fvModels;
52 
53 Ostream& operator<<(Ostream& os, const fvModels& models);
54 
55 
56 /*---------------------------------------------------------------------------*\
57  Class fvModels Declaration
58 \*---------------------------------------------------------------------------*/
59 
60 class fvModels
61 :
63  <
64  fvMesh,
65  TopoChangeableMeshObject,
66  fvModels,
67  IOdictionary
68  >,
69  public PtrListDictionary<fvModel>
70 {
71  // Private Data
72 
73  //- Time index to check that all defined sources have been applied
74  mutable label checkTimeIndex_;
75 
76  //- Sets of the fields that have had sources added by the fvModels
77  mutable PtrList<wordHashSet> addSupFields_;
78 
79 
80  // Private Member Functions
81 
82  //- Create IO object if dictionary is present
83  IOobject createIOobject(const fvMesh& mesh) const;
84 
85  //- Check that all fvModels have been applied
86  void checkApplied() const;
87 
88  //- Return a source for an equation
89  template<class Type, class ... AlphaRhoFieldTypes>
90  tmp<fvMatrix<Type>> sourceTerm
91  (
92  const VolField<Type>& eqnField,
93  const dimensionSet& ds,
94  const AlphaRhoFieldTypes& ... alphaRhoFields
95  ) const;
96 
97 
98 protected:
99 
100  friend class DemandDrivenMeshObject;
101 
102  // Protected Constructors
103 
104  //- Construct from fvMesh
105  explicit fvModels(const fvMesh& mesh);
106 
107 
108 public:
109 
110  //- Runtime type information
111  TypeName("fvModels");
112 
113 
114  // Constructors
115 
116  //- Disallow default bitwise copy construction
117  fvModels(const fvModels&) = delete;
118 
119  //- Inherit the base New method
121  <
122  fvMesh,
124  fvModels,
126  >::New;
127 
128 
129  //- Destructor
130  virtual ~fvModels()
131  {}
132 
133 
134  // Member Functions
135 
136  // Checks
137 
138  //- Return true if an fvModel adds a source term to the given
139  // field's transport equation
140  virtual bool addsSupToField(const word& fieldName) const;
141 
142  //- Return the maximum time-step for stable operation
143  virtual scalar maxDeltaT() const;
144 
145 
146  // Sources
147 
148  //- Correct the fvModels
149  // e.g. solve equations, update model, for film, Lagrangian etc.
150  virtual void correct();
151 
152  //- Return source for an equation
153  template<class Type>
155  (
156  const VolField<Type>& eqnField
157  ) const;
158 
159  //- Return source for an equation
160  template<class Type>
162  (
163  const VolField<Type>& field
164  ) const;
165 
166  //- Return source for an equation
167  template<class Type>
169  (
170  const VolField<Type>& field,
171  const VolField<Type>& eqnField
172  ) const;
173 
174  //- Return source for a compressible equation
175  template<class Type>
177  (
178  const volScalarField& rho,
179  const VolField<Type>& field
180  ) const;
181 
182  //- Return source for a compressible equation
183  template<class Type>
185  (
186  const volScalarField& rho,
187  const VolField<Type>& field,
188  const VolField<Type>& eqnField
189  ) const;
190 
191  //- Return source for a phase equation
192  template<class Type>
194  (
195  const volScalarField& alpha,
196  const volScalarField& rho,
197  const VolField<Type>& field
198  ) const;
199 
200  //- Return source for a phase equation
201  template<class Type>
203  (
204  const volScalarField& alpha,
205  const volScalarField& rho,
206  const VolField<Type>& field,
207  const VolField<Type>& eqnField
208  ) const;
209 
210  //- Return source for a phase equation
211  template<class Type>
213  (
214  const volScalarField& alpha,
215  const geometricOneField& rho,
216  const VolField<Type>& field
217  ) const;
218 
219  //- Return source for a phase equation
220  template<class Type>
222  (
223  const geometricOneField& alpha,
224  const volScalarField& rho,
225  const VolField<Type>& field
226  ) const;
227 
228  //- Return source for a phase equation
229  template<class Type>
231  (
232  const geometricOneField& alpha,
233  const geometricOneField& rho,
234  const VolField<Type>& field
235  ) const;
236 
237  //- Return source for an equation with a second time derivative
238  template<class Type>
240  (
241  const VolField<Type>& field
242  ) const;
243 
244 
245  // Mesh changes
246 
247  //- Prepare for mesh update
248  virtual void preUpdateMesh();
249 
250  //- Update for mesh motion
251  virtual bool movePoints();
252 
253  //- Update topology using the given map
254  virtual void topoChange(const polyTopoChangeMap&);
255 
256  //- Update from another mesh using the given map
257  virtual void mapMesh(const polyMeshMap&);
258 
259  //- Redistribute or update using the given distribution map
260  virtual void distribute(const polyDistributionMap&);
261 
262 
263  // IO
264 
265  //- Read the fvModels dictionary if it has changed
266  // and update the models
267  virtual bool read();
268 
269  //- Write the fvModels
270  virtual bool writeObject
271  (
275  const bool write
276  ) const;
277 
278 
279  // Member Operators
280 
281  //- Inherit the PtrListDictionary index operators
283 
284  //- Inherit the PtrListDictionary size function
286 
287  //- Disallow default bitwise assignment
288  void operator=(const fvModels&) = delete;
289 
290 
291  // IOstream Operators
292 
293  //- Ostream operator
294  friend Ostream& operator<<
295  (
296  Ostream& os,
297  const fvModels& models
298  );
299 };
300 
301 
302 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
303 
304 //- Trait for obtaining global status
305 template<>
306 struct typeGlobal<fvModels>
307 {
308  static const bool global = true;
309 };
310 
311 
312 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
313 
314 #ifdef NoRepository
315  #include "fvModelsTemplates.C"
316 #endif
317 
318 
319 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
320 
321 } // End namespace Foam
322 
323 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
324 
325 #endif
326 
327 // ************************************************************************* //
Templated abstract base-class for demand-driven mesh objects used to automate their allocation to the...
static fvModels & New(const word &name, const fvMesh &mesh)
Construct and return the named DemandDrivenMeshObject.
Generic GeometricField class.
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:57
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:99
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
Template dictionary class which manages the storage associated with it.
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: PtrList.H:75
void write(Ostream &, const bool subDict=true) const
Write dictionary, normally with sub-dictionary formatting.
Definition: dictionaryIO.C:214
Dimension set for the base types.
Definition: dimensionSet.H:125
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:98
Finite volume models.
Definition: fvModels.H:69
virtual bool movePoints()
Update for mesh motion.
Definition: fvModels.C:272
virtual bool writeObject(IOstream::streamFormat fmt, IOstream::versionNumber ver, IOstream::compressionType cmp, const bool write) const
Write the fvModels.
Definition: fvModels.C:346
tmp< fvMatrix< Type > > d2dt2(const VolField< Type > &field) const
Return source for an equation with a second time derivative.
tmp< fvMatrix< Type > > source(const VolField< Type > &field) const
Return source for an equation.
virtual void correct()
Correct the fvModels.
Definition: fvModels.C:367
TypeName("fvModels")
Runtime type information.
virtual void topoChange(const polyTopoChangeMap &)
Update topology using the given map.
Definition: fvModels.C:287
virtual void distribute(const polyDistributionMap &)
Redistribute or update using the given distribution map.
Definition: fvModels.C:309
virtual scalar maxDeltaT() const
Return the maximum time-step for stable operation.
Definition: fvModels.C:246
virtual ~fvModels()
Destructor.
Definition: fvModels.H:129
virtual void preUpdateMesh()
Prepare for mesh update.
Definition: fvModels.C:261
void operator=(const fvModels &)=delete
Disallow default bitwise assignment.
virtual void mapMesh(const polyMeshMap &)
Update from another mesh using the given map.
Definition: fvModels.C:298
tmp< fvMatrix< Type > > sourceProxy(const VolField< Type > &eqnField) const
Return source for an equation.
virtual bool addsSupToField(const word &fieldName) const
Return true if an fvModel adds a source term to the given.
Definition: fvModels.C:230
fvModels(const fvMesh &mesh)
Construct from fvMesh.
Definition: fvModels.C:145
virtual bool read()
Read the fvModels dictionary if it has changed.
Definition: fvModels.C:320
A class representing the concept of a GeometricField of 1 used to avoid unnecessary manipulations for...
Class containing mesh-to-mesh mapping information after a mesh distribution where we send parts of me...
Class containing mesh-to-mesh mapping information.
Definition: polyMeshMap.H:51
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
A class for managing temporary objects.
Definition: tmp.H:55
A class for handling words, derived from string.
Definition: word.H:63
Foam::fvModels & fvModels(Foam::fvModels::New(mesh))
rho
Definition: pEqn.H:1
volScalarField alpha(IOobject("alpha", runTime.name(), mesh, IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE), lambda *max(Ua &U, zeroSensitivity))
Namespace for OpenFOAM.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
Ostream & operator<<(Ostream &os, const fvConstraints &constraints)
Trait for obtaining global status.
Definition: IOobject.H:518
static const bool global
Definition: IOobject.H:519