porosityModel.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2012-2018 OpenFOAM Foundation
9  Copyright (C) 2021-2023 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::porosityModel
29 
30 Description
31  Top level model for porosity models
32 
33 SourceFiles
34  porosityModel.C
35  porosityModelNew.C
36 
37 \*---------------------------------------------------------------------------*/
38 
39 #ifndef Foam_porosityModel_H
40 #define Foam_porosityModel_H
41 
42 #include "fvMesh.H"
43 #include "dictionary.H"
44 #include "fvMatricesFwd.H"
45 #include "runTimeSelectionTables.H"
46 #include "coordinateSystem.H"
47 #include "dimensionedVector.H"
48 
49 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50 
51 namespace Foam
52 {
53 
54 /*---------------------------------------------------------------------------*\
55  Class porosityModel Declaration
56 \*---------------------------------------------------------------------------*/
57 
58 class porosityModel
59 :
60  public regIOobject
61 {
62 protected:
63 
64  // Protected Data
65 
66  //- Porosity name
67  word name_;
68 
69  //- Reference to the mesh database
70  const fvMesh& mesh_;
71 
72  //- Dictionary used for model construction
73  const dictionary dict_;
74 
75  //- Model coefficients dictionary
77 
78  //- Porosity active flag
79  bool active_;
80 
81  //- Name(s) of cell-zone
83 
84  //- Cell zone IDs
86 
87  //- Local coordinate system
89 
90 
91  // Protected Member Functions
92 
93  //- Transform the model data wrt mesh changes
94  virtual void calcTransformModelData() = 0;
95 
96  //- Adjust negative resistance values to be multiplier of max value
98 
99  //- Calculate the porosity force
100  virtual void calcForce
101  (
102  const volVectorField& U,
103  const volScalarField& rho,
104  const volScalarField& mu,
106  ) const = 0;
107 
108  virtual void correct(fvVectorMatrix& UEqn) const = 0;
109 
110  virtual void correct
111  (
113  const volScalarField& rho,
114  const volScalarField& mu
115  ) const = 0;
116 
117  virtual void correct
118  (
119  const fvVectorMatrix& UEqn,
120  volTensorField& AU
121  ) const = 0;
122 
123 
124  //- Local coordinate system
125  inline const coordinateSystem& csys() const;
126 
127  //- Return label index
128  inline label fieldIndex(const label index) const;
129 
130  //- No copy construct
131  porosityModel(const porosityModel&) = delete;
132 
133  //- No copy assignment
134  void operator=(const porosityModel&) = delete;
135 
136 
137 public:
138 
139  //- Runtime type information
140  TypeName("porosityModel");
141 
142  //- Selection table
144  (
145  autoPtr,
147  mesh,
148  (
149  const word& modelName,
150  const word& name,
151  const fvMesh& mesh,
152  const dictionary& dict,
153  const wordRe& cellZoneName
154  ),
155  (modelName, name, mesh, dict, cellZoneName)
156  );
157 
158  //- Constructor
160  (
161  const word& name,
162  const word& modelType,
163  const fvMesh& mesh,
164  const dictionary& dict,
165  const wordRe& cellZoneName = wordRe::null
166  );
167 
168 
169  //- Return pointer to new porosityModel object created on the freestore
170  // from an Istream
171  class iNew
172  {
173  //- Reference to the mesh database
174  const fvMesh& mesh_;
175  const word& name_;
176 
177  public:
178 
179  iNew
180  (
181  const fvMesh& mesh,
182  const word& name
183  )
184  :
185  mesh_(mesh),
186  name_(name)
187  {}
188 
190  {
191  const dictionary dict(is);
192 
194  (
196  (
197  name_,
198  mesh_,
199  dict
200  )
201  );
202  }
203  };
204 
205  //- Selector
207  (
208  const word& name,
209  const fvMesh& mesh,
210  const dictionary& dict,
211  const wordRe& cellZoneName = wordRe::null
212  );
213 
214 
215  //- Destructor
216  virtual ~porosityModel() = default;
217 
218 
219  // Member Functions
220 
221  //- Return const access to the porosity model name
222  inline const word& name() const;
223 
224  //- Return const access to the porosity active flag
225  inline bool active() const;
226 
227  //- Return const access to the cell zone IDs
228  inline const labelList& cellZoneIDs() const;
229 
230  //- Return dictionary used for model construction
231  const dictionary& dict() const;
232 
233  //- Transform the model data wrt mesh changes
234  virtual void transformModelData();
235 
236  //- Return the force over the cell zone(s)
237  virtual tmp<vectorField> force
238  (
239  const volVectorField& U,
240  const volScalarField& rho,
241  const volScalarField& mu
242  );
243 
244  //- Add resistance
245  virtual void addResistance(fvVectorMatrix& UEqn);
246 
247  //- Add resistance
248  virtual void addResistance
249  (
251  const volScalarField& rho,
252  const volScalarField& mu
253  );
254 
255  //- Add resistance
256  virtual void addResistance
257  (
258  const fvVectorMatrix& UEqn,
259  volTensorField& AU,
260  bool correctAUprocBC
261  );
262 
263 
264  // I-O
265 
266  //- Write
267  virtual bool writeData(Ostream& os) const;
268 
269  //- Inherit read from regIOobject
270  using regIOobject::read;
271 
272  //- Is object global
273  virtual bool global() const
274  {
275  return true;
276  }
277 
278  //- Return complete path + object name if the file exists
279  // either in the case/processor or case otherwise null
280  virtual fileName filePath() const
281  {
282  return globalFilePath(type());
283  }
284 
285  //- Read porosity dictionary
286  virtual bool read(const dictionary& dict);
287 };
288 
289 
290 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
291 
292 //- Global file type for porosityModel
293 template<>
294 struct is_globalIOobject<porosityModel> : std::true_type {};
295 
296 
297 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
298 
299 } // End namespace Foam
300 
301 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
302 
303 #include "porosityModelI.H"
304 
305 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
306 
307 #endif
308 
309 // ************************************************************************* //
Base class for coordinate system specification, the default coordinate system type is cartesian ...
void operator=(const porosityModel &)=delete
No copy assignment.
A class for handling file names.
Definition: fileName.H:72
virtual bool writeData(Ostream &os) const
Write.
const dictionary & dict() const
Return dictionary used for model construction.
fileName globalFilePath(const word &typeName, const bool search=true) const
Redirect to fileHandler filePath, searching up if in parallel.
Definition: IOobject.C:547
virtual fileName filePath() const
Return complete path + object name if the file exists.
virtual ~porosityModel()=default
Destructor.
virtual bool read()
Read object.
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
dictionary coeffs_
Model coefficients dictionary.
Definition: porosityModel.H:79
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
virtual tmp< vectorField > force(const volVectorField &U, const volScalarField &rho, const volScalarField &mu)
Return the force over the cell zone(s)
iNew(const fvMesh &mesh, const word &name)
static autoPtr< porosityModel > New(const word &name, const fvMesh &mesh, const dictionary &dict, const wordRe &cellZoneName=wordRe::null)
Selector.
autoPtr< coordinateSystem > csysPtr_
Local coordinate system.
Definition: porosityModel.H:99
const labelList & cellZoneIDs() const
Return const access to the cell zone IDs.
bool active_
Porosity active flag.
Definition: porosityModel.H:84
bool active() const
Return const access to the porosity active flag.
TypeName("porosityModel")
Runtime type information.
label fieldIndex(const label index) const
Return label index.
porosityModel(const porosityModel &)=delete
No copy construct.
autoPtr< porosityModel > operator()(Istream &is) const
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition: POSIX.C:799
wordRe zoneName_
Name(s) of cell-zone.
Definition: porosityModel.H:89
word name_
Porosity name.
Definition: porosityModel.H:64
void adjustNegativeResistance(dimensionedVector &resist)
Adjust negative resistance values to be multiplier of max value.
Definition: porosityModel.C:36
dynamicFvMesh & mesh
A class for handling words, derived from Foam::string.
Definition: word.H:63
A special matrix type and solver, designed for finite volume solutions of scalar equations. Face addressing is used to make all matrix assembly and solution loops vectorise.
Definition: fvPatchField.H:64
virtual void correct(fvVectorMatrix &UEqn) const =0
A wordRe is a Foam::word, but can contain a regular expression for matching words or strings...
Definition: wordRe.H:78
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
const fvMesh & mesh_
Reference to the mesh database.
Definition: porosityModel.H:69
virtual void transformModelData()
Transform the model data wrt mesh changes.
const coordinateSystem & csys() const
Local coordinate system.
OBJstream os(runTime.globalPath()/outputName)
labelList cellZoneIDs_
Cell zone IDs.
Definition: porosityModel.H:94
Return pointer to new porosityModel object created on the freestore.
const dictionary dict_
Dictionary used for model construction.
Definition: porosityModel.H:74
const dimensionedScalar mu
Atomic mass unit.
Forward declarations of fvMatrix specializations.
U
Definition: pEqn.H:72
const word & name() const
Return const access to the porosity model name.
fvVectorMatrix & UEqn
Definition: UEqn.H:13
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:66
virtual void calcTransformModelData()=0
Transform the model data wrt mesh changes.
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
declareRunTimeSelectionTable(autoPtr, porosityModel, mesh,(const word &modelName, const word &name, const fvMesh &mesh, const dictionary &dict, const wordRe &cellZoneName),(modelName, name, mesh, dict, cellZoneName))
Selection table.
Macros to ease declaration of run-time selection tables.
A class for managing temporary objects.
Definition: HashPtrTable.H:50
virtual void addResistance(fvVectorMatrix &UEqn)
Add resistance.
virtual void calcForce(const volVectorField &U, const volScalarField &rho, const volScalarField &mu, vectorField &force) const =0
Calculate the porosity force.
virtual bool global() const
Is object global.
static const wordRe null
An empty wordRe.
Definition: wordRe.H:97
Top level model for porosity models.
Definition: porosityModel.H:53
Namespace for OpenFOAM.