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 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 "MeshObject.H"
41 #include "HashSet.H"
42 #include "volFields.H"
43 #include "geometricOneField.H"
44 #include "fvMesh.H"
45 
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 
48 namespace Foam
49 {
50 
51 // Forward declaration of friend functions and operators
52 class fvModels;
53 
54 Ostream& operator<<(Ostream& os, const fvModels& models);
55 
56 
57 /*---------------------------------------------------------------------------*\
58  Class fvModels Declaration
59 \*---------------------------------------------------------------------------*/
60 
61 class fvModels
62 :
63  public MeshObject<fvMesh, UpdateableMeshObject, fvModels>,
64  public dictionary,
65  public PtrListDictionary<fvModel>
66 {
67  // Private Member Data
68 
69  //- Time index to check that all defined sources have been applied
70  mutable label checkTimeIndex_;
71 
72  //- Sets of the fields that have had sources added by the fvModels
73  mutable PtrList<wordHashSet> addSupFields_;
74 
75 
76  // Private Member Functions
77 
78  //- Create IO object if dictionary is present
79  IOobject createIOobject(const fvMesh& mesh) const;
80 
81  //- Check that all fvModels have been applied
82  void checkApplied() const;
83 
84  //- Return source for equation with specified name and dimensions
85  template<class Type, class ... AlphaRhoFieldTypes>
86  tmp<fvMatrix<Type>> source
87  (
89  const word& fieldName,
90  const dimensionSet& ds,
91  const AlphaRhoFieldTypes& ... alphaRhos
92  ) const;
93 
94 
95 public:
96 
97  //- Runtime type information
98  TypeName("fvModels");
99 
100 
101  // Constructors
102 
103  //- Construct from components with list of field names
104  fvModels(const fvMesh& mesh);
105 
106  //- Disallow default bitwise copy construction
107  fvModels(const fvModels&) = delete;
108 
109  //- Inherit the base New method
111 
112 
113  //- Destructor
114  virtual ~fvModels()
115  {}
116 
117 
118  // Member Functions
119 
120  //- Declare fvModels to be a global dictionary
121  virtual bool global() const
122  {
123  return true;
124  }
125 
126  //- Return complete path + object name if the file exists
127  // either in the case/processor or case otherwise null
128  virtual fileName filePath() const
129  {
130  return globalFilePath(type());
131  }
132 
133 
134  // Checks
135 
136  //- Return true if an fvModel adds a source term to the given
137  // field's transport equation
138  virtual bool addsSupToField(const word& fieldName) const;
139 
140 
141  // Sources
142 
143  //- Correct the fvModels
144  // e.g. solve equations, update model, for film, Lagrangian etc.
145  virtual void correct();
146 
147  //- Return source for an equation
148  template<class Type>
149  tmp<fvMatrix<Type>> source
150  (
152  ) const;
153 
154  //- Return source for an equation with a specified name
155  template<class Type>
156  tmp<fvMatrix<Type>> source
157  (
159  const word& fieldName
160  ) const;
161 
162  //- Return source for a compressible equation
163  template<class Type>
164  tmp<fvMatrix<Type>> source
165  (
166  const volScalarField& rho,
168  ) const;
169 
170  //- Return source for a compressible equation with a specified name
171  template<class Type>
172  tmp<fvMatrix<Type>> source
173  (
174  const volScalarField& rho,
176  const word& fieldName
177  ) const;
178 
179  //- Return source for a phase equation
180  template<class Type>
181  tmp<fvMatrix<Type>> source
182  (
183  const volScalarField& alpha,
184  const volScalarField& rho,
186  ) const;
187 
188  //- Return source for a phase equation with a specified name
189  template<class Type>
190  tmp<fvMatrix<Type>> source
191  (
192  const volScalarField& alpha,
193  const volScalarField& rho,
195  const word& fieldName
196  ) const;
197 
198  //- Return source for a phase equation
199  template<class Type>
200  tmp<fvMatrix<Type>> source
201  (
202  const volScalarField& alpha,
203  const geometricOneField& rho,
205  ) const;
206 
207  //- Return source for a phase equation
208  template<class Type>
209  tmp<fvMatrix<Type>> source
210  (
211  const geometricOneField& alpha,
212  const volScalarField& rho,
214  ) const;
215 
216  //- Return source for a phase equation
217  template<class Type>
218  tmp<fvMatrix<Type>> source
219  (
220  const geometricOneField& alpha,
221  const geometricOneField& rho,
223  ) const;
224 
225  //- Return source for an equation with a second time derivative
226  template<class Type>
228  (
230  ) const;
231 
232  //- Return source for an equation with a second time derivative
233  template<class Type>
235  (
237  const word& fieldName
238  ) const;
239 
240 
241  // Mesh changes
242 
243  //- Prepare for mesh update
244  virtual void preUpdateMesh();
245 
246  //- Update for mesh changes
247  virtual void updateMesh(const mapPolyMesh&);
248 
249  //- Update for mesh motion
250  virtual bool movePoints();
251 
252 
253  // IO
254 
255  //- ReadData function which reads the fvModels dictionary
256  // required for regIOobject read operation
257  virtual bool readData(Istream&);
258 
259  //- Write data to Ostream
260  virtual bool writeData(Ostream& os) const;
261 
262  //- Read the fvModels dictionary if it has changed
263  // and update the models
264  virtual bool read();
265 
266 
267  // Member Operators
268 
269  //- Inherit the PtrListDictionary index operators
271 
272  //- Disallow default bitwise assignment
273  void operator=(const fvModels&) = delete;
274 
275 
276  // IOstream Operators
277 
278  //- Ostream operator
279  friend Ostream& operator<<
280  (
281  Ostream& os,
282  const fvModels& models
283  );
284 };
285 
286 
287 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
288 
289 //- Template function for obtaining global status
290 template<>
291 inline bool typeGlobal<fvModels>()
292 {
293  return true;
294 }
295 
296 
297 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
298 
299 #ifdef NoRepository
300  #include "fvModelsTemplates.C"
301 #endif
302 
303 
304 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
305 
306 } // End namespace Foam
307 
308 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
309 
310 #endif
311 
312 // ************************************************************************* //
virtual bool global() const
Declare fvModels to be a global dictionary.
Definition: fvModels.H:120
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
A class for handling file names.
Definition: fileName.H:79
void operator=(const fvModels &)=delete
Disallow default bitwise assignment.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
volScalarField alpha(IOobject("alpha", runTime.timeName(), mesh, IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE), lambda *max(Ua &U, zeroSensitivity))
virtual void correct()
Correct the fvModels.
Definition: fvModels.C:316
virtual void preUpdateMesh()
Prepare for mesh update.
Definition: fvModels.C:240
Generic GeometricField class.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:158
Templated abstract base-class for optional mesh objects used to automate their allocation to the mesh...
Definition: MeshObject.H:85
Dimension set for the base types.
Definition: dimensionSet.H:120
Template dictionary class which manages the storage associated with it.
A class representing the concept of a GeometricField of 1 used to avoid unnecessary manipulations for...
A class for handling words, derived from string.
Definition: word.H:59
Finite volume models.
Definition: fvModels.H:60
TypeName("fvModels")
Runtime type information.
tmp< fvMatrix< Type > > d2dt2(const GeometricField< Type, fvPatchField, volMesh > &field) const
Return source for an equation with a second time derivative.
virtual void updateMesh(const mapPolyMesh &)
Update for mesh changes.
Definition: fvModels.C:251
fileName globalFilePath(const word &typeName) const
Helper for filePath that searches up if in parallel.
Definition: IOobject.C:392
bool typeGlobal< fvModels >()
Template function for obtaining global status.
Definition: fvModels.H:290
virtual bool readData(Istream &)
ReadData function which reads the fvModels dictionary.
Definition: fvModels.C:277
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
virtual fileName filePath() const
Return complete path + object name if the file exists.
Definition: fvModels.H:127
virtual ~fvModels()
Destructor.
Definition: fvModels.H:113
virtual bool writeData(Ostream &os) const
Write data to Ostream.
Definition: fvModels.C:284
Foam::fvModels & fvModels
virtual bool movePoints()
Update for mesh motion.
Definition: fvModels.C:262
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: List.H:70
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
Ostream & operator<<(Ostream &, const ensightPart &)
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
Definition: POSIX.C:488
rDeltaTY field()
A class for managing temporary objects.
Definition: PtrList.H:53
virtual bool addsSupToField(const word &fieldName) const
Return true if an fvModel adds a source term to the given.
Definition: fvModels.C:224
fvModels(const fvMesh &mesh)
Construct from components with list of field names.
Definition: fvModels.C:139
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:92
virtual bool read()
Read the fvModels dictionary if it has changed.
Definition: fvModels.C:291
Namespace for OpenFOAM.