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 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 porosityModel_H
40 #define 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  // Private Member Functions
63 
64  //- No copy construct
65  porosityModel(const porosityModel&) = delete;
66 
67  //- No copy assignment
68  void operator=(const porosityModel&) = delete;
69 
70 
71 protected:
72 
73  // Protected Data
74 
75  //- Porosity name
76  word name_;
77 
78  //- Reference to the mesh database
79  const fvMesh& mesh_;
80 
81  //- Dictionary used for model construction
82  const dictionary dict_;
83 
84  //- Model coefficients dictionary
86 
87  //- Porosity active flag
88  bool active_;
89 
90  //- Name(s) of cell-zone
92 
93  //- Cell zone IDs
95 
96  //- Local coordinate system
98 
99 
100  // Protected Member Functions
101 
102  //- Transform the model data wrt mesh changes
103  virtual void calcTransformModelData() = 0;
104 
105  //- Adjust negative resistance values to be multiplier of max value
107 
108  //- Calculate the porosity force
109  virtual void calcForce
110  (
111  const volVectorField& U,
112  const volScalarField& rho,
113  const volScalarField& mu,
115  ) const = 0;
116 
117  virtual void correct(fvVectorMatrix& UEqn) const = 0;
118 
119  virtual void correct
120  (
122  const volScalarField& rho,
123  const volScalarField& mu
124  ) const = 0;
125 
126  virtual void correct
127  (
128  const fvVectorMatrix& UEqn,
129  volTensorField& AU
130  ) const = 0;
131 
132 
133  //- Local coordinate system
134  inline const coordinateSystem& csys() const;
135 
136  //- Return label index
137  inline label fieldIndex(const label index) const;
138 
139 
140 public:
141 
142  //- Runtime type information
143  TypeName("porosityModel");
144 
145  //- Selection table
147  (
148  autoPtr,
150  mesh,
151  (
152  const word& modelName,
153  const word& name,
154  const fvMesh& mesh,
155  const dictionary& dict,
156  const word& cellZoneName
157  ),
158  (modelName, name, mesh, dict, cellZoneName)
159  );
160 
161  //- Constructor
163  (
164  const word& name,
165  const word& modelType,
166  const fvMesh& mesh,
167  const dictionary& dict,
168  const word& cellZoneName = word::null
169  );
170 
171  //- Return pointer to new porosityModel object created on the freestore
172  // from an Istream
173  class iNew
174  {
175  //- Reference to the mesh database
176  const fvMesh& mesh_;
177  const word& name_;
178 
179  public:
180 
182  (
183  const fvMesh& mesh,
184  const word& name
185  )
186  :
187  mesh_(mesh),
188  name_(name)
189  {}
190 
192  {
193  const dictionary dict(is);
194 
196  (
198  (
199  name_,
200  mesh_,
201  dict
202  )
203  );
204  }
205  };
206 
207  //- Selector
209  (
210  const word& name,
211  const fvMesh& mesh,
212  const dictionary& dict,
213  const word& cellZoneName = word::null
214  );
215 
216  //- Destructor
217  virtual ~porosityModel() = default;
218 
219 
220  // Member Functions
221 
222  //- Return const access to the porosity model name
223  inline const word& name() const;
224 
225  //- Return const access to the porosity active flag
226  inline bool active() const;
227 
228  //- Return const access to the cell zone IDs
229  inline const labelList& cellZoneIDs() const;
230 
231  //- Return dictionary used for model construction
232  const dictionary& dict() const;
233 
234  //- Transform the model data wrt mesh changes
235  virtual void transformModelData();
236 
237  //- Return the force over the cell zone(s)
238  virtual tmp<vectorField> force
239  (
240  const volVectorField& U,
241  const volScalarField& rho,
242  const volScalarField& mu
243  );
244 
245  //- Add resistance
246  virtual void addResistance(fvVectorMatrix& UEqn);
247 
248  //- Add resistance
249  virtual void addResistance
250  (
252  const volScalarField& rho,
253  const volScalarField& mu
254  );
255 
256  //- Add resistance
257  virtual void addResistance
258  (
259  const fvVectorMatrix& UEqn,
260  volTensorField& AU,
261  bool correctAUprocBC
262  );
263 
264 
265  // I-O
266 
267  //- Write
268  virtual bool writeData(Ostream& os) const;
269 
270  //- Inherit read from regIOobject
271  using regIOobject::read;
272 
273  //- Is object global
274  virtual bool global() const
275  {
276  return true;
277  }
278 
279  //- Return complete path + object name if the file exists
280  // either in the case/processor or case otherwise null
281  virtual fileName filePath() const
282  {
283  return globalFilePath(type());
284  }
285 
286  //- Read porosity dictionary
287  virtual bool read(const dictionary& dict);
288 };
289 
290 
291 //- Template function for obtaining global status
292 template<>
293 inline bool typeGlobal<porosityModel>()
294 {
295  return true;
296 }
297 
298 
299 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
300 
301 } // End namespace Foam
302 
303 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
304 
305 #include "porosityModelI.H"
306 
307 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
308 
309 #endif
310 
311 // ************************************************************************* //
Foam::porosityModel::~porosityModel
virtual ~porosityModel()=default
Destructor.
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::porosityModel::cellZoneIDs
const labelList & cellZoneIDs() const
Return const access to the cell zone IDs.
Definition: porosityModelI.H:62
Foam::porosityModel::calcTransformModelData
virtual void calcTransformModelData()=0
Transform the model data wrt mesh changes.
Foam::porosityModel::dict_
const dictionary dict_
Dictionary used for model construction.
Definition: porosityModel.H:81
Foam::fileName
A class for handling file names.
Definition: fileName.H:73
Foam::constant::physicoChemical::mu
const dimensionedScalar mu
Atomic mass unit.
Definition: createFieldRefs.H:4
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::porosityModel::name
const word & name() const
Return const access to the porosity model name.
Definition: porosityModelI.H:44
Foam::regIOobject::read
virtual bool read()
Read object.
Definition: regIOobjectRead.C:191
Foam::porosityModel::declareRunTimeSelectionTable
declareRunTimeSelectionTable(autoPtr, porosityModel, mesh,(const word &modelName, const word &name, const fvMesh &mesh, const dictionary &dict, const word &cellZoneName),(modelName, name, mesh, dict, cellZoneName))
Selection table.
Foam::porosityModel::active_
bool active_
Porosity active flag.
Definition: porosityModel.H:87
Foam::typeGlobal< porosityModel >
bool typeGlobal< porosityModel >()
Template function for obtaining global status.
Definition: porosityModel.H:292
fvMatricesFwd.H
Forward declarations of fvMatrix specializations.
Foam::porosityModel::cellZoneIDs_
labelList cellZoneIDs_
Cell zone IDs.
Definition: porosityModel.H:93
rho
rho
Definition: readInitialConditions.H:88
Foam::wordRe
A wordRe is a Foam::word, but can contain a regular expression for matching words or strings.
Definition: wordRe.H:80
coordinateSystem.H
Foam::porosityModel::coeffs_
dictionary coeffs_
Model coefficients dictionary.
Definition: porosityModel.H:84
Foam::porosityModel::calcForce
virtual void calcForce(const volVectorField &U, const volScalarField &rho, const volScalarField &mu, vectorField &force) const =0
Calculate the porosity force.
Foam::porosityModel::transformModelData
virtual void transformModelData()
Transform the model data wrt mesh changes.
Definition: porosityModel.C:154
Foam::porosityModel::force
virtual tmp< vectorField > force(const volVectorField &U, const volScalarField &rho, const volScalarField &mu)
Return the force over the cell zone(s)
Foam::Field< vector >
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
Foam::porosityModel::iNew::iNew
iNew(const fvMesh &mesh, const word &name)
Definition: porosityModel.H:181
Foam::porosityModel::filePath
virtual fileName filePath() const
Return complete path + object name if the file exists.
Definition: porosityModel.H:280
Foam::porosityModel::zoneName_
wordRe zoneName_
Name(s) of cell-zone.
Definition: porosityModel.H:90
Foam::porosityModel::adjustNegativeResistance
void adjustNegativeResistance(dimensionedVector &resist)
Adjust negative resistance values to be multiplier of max value.
Definition: porosityModel.C:43
Foam::porosityModel::iNew::operator()
autoPtr< porosityModel > operator()(Istream &is) const
Definition: porosityModel.H:190
Foam::porosityModel::TypeName
TypeName("porosityModel")
Runtime type information.
Foam::porosityModel::correct
virtual void correct(fvVectorMatrix &UEqn) const =0
dimensionedVector.H
Foam::IOobject::globalFilePath
fileName globalFilePath(const word &typeName, const bool search=true) const
Helper for filePath that searches up if in parallel.
Definition: IOobject.C:580
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
os
OBJstream os(runTime.globalPath()/outputName)
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::dimensioned< vector >
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:85
fvMesh.H
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::porosityModel::writeData
virtual bool writeData(Ostream &os) const
Write.
Definition: porosityModel.C:240
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
U
U
Definition: pEqn.H:72
Foam::porosityModel
Top level model for porosity models.
Definition: porosityModel.H:57
Foam::regIOobject
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:73
runTimeSelectionTables.H
Macros to ease declaration of run-time selection tables.
Foam::porosityModel::name_
word name_
Porosity name.
Definition: porosityModel.H:75
Foam::List< label >
Foam::porosityModel::fieldIndex
label fieldIndex(const label index) const
Return label index.
Definition: porosityModelI.H:36
Foam::type
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition: MSwindows.C:590
Foam::porosityModel::global
virtual bool global() const
Is object global.
Definition: porosityModel.H:273
dictionary.H
Foam::word::null
static const word null
An empty word.
Definition: word.H:80
Foam::porosityModel::active
bool active() const
Return const access to the porosity active flag.
Definition: porosityModelI.H:50
Foam::porosityModel::csys
const coordinateSystem & csys() const
Local coordinate system.
Definition: porosityModelI.H:30
Foam::fvMatrix
A special matrix type and solver, designed for finite volume solutions of scalar equations....
Definition: fvPatchField.H:68
UEqn
fvVectorMatrix & UEqn
Definition: UEqn.H:13
Foam::porosityModel::iNew
Return pointer to new porosityModel object created on the freestore.
Definition: porosityModel.H:172
Foam::porosityModel::addResistance
virtual void addResistance(fvVectorMatrix &UEqn)
Add resistance.
Definition: porosityModel.C:186
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::porosityModel::New
static autoPtr< porosityModel > New(const word &name, const fvMesh &mesh, const dictionary &dict, const word &cellZoneName=word::null)
Selector.
Definition: porosityModelNew.C:34
Foam::porosityModel::csysPtr_
autoPtr< coordinateSystem > csysPtr_
Local coordinate system.
Definition: porosityModel.H:96
Foam::GeometricField< vector, fvPatchField, volMesh >
Foam::porosityModel::dict
const dictionary & dict() const
Return dictionary used for model construction.
Definition: porosityModelI.H:56
Foam::porosityModel::mesh_
const fvMesh & mesh_
Reference to the mesh database.
Definition: porosityModel.H:78
Foam::coordinateSystem
Base class for coordinate system specification, the default coordinate system type is cartesian .
Definition: coordinateSystem.H:132
porosityModelI.H