Loading...
Searching...
No Matches
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-------------------------------------------------------------------------------
11License
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
27Class
28 Foam::porosityModel
29
30Description
31 Top level model for porosity models
32
33SourceFiles
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"
46#include "coordinateSystem.H"
47#include "dimensionedVector.H"
48
49// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50
51namespace Foam
52{
54/*---------------------------------------------------------------------------*\
55 Class porosityModel Declaration
56\*---------------------------------------------------------------------------*/
57
58class porosityModel
59:
60 public regIOobject
61{
62protected:
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_;
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
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;
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,
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
137public:
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 );
168
169 //- Return pointer to new porosityModel object created on the freestore
170 // from an Istream
171 class iNew
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
290// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
291
292//- Global file type for porosityModel
293template<>
294struct 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// ************************************************************************* //
fileName globalFilePath(const word &typeName, const bool search=true) const
Redirect to fileHandler filePath, searching up if in parallel.
Definition IOobject.C:604
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition Istream.H:60
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition autoPtr.H:65
Base class for coordinate system specification, the default coordinate system type is cartesian .
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
A class for handling file names.
Definition fileName.H:75
Mesh data needed to do the Finite Volume discretisation.
Definition fvMesh.H:85
Return pointer to new porosityModel object created on the freestore.
autoPtr< porosityModel > operator()(Istream &is) const
iNew(const fvMesh &mesh, const word &name)
Top level model for porosity models.
virtual void addResistance(fvVectorMatrix &UEqn)
Add resistance.
virtual void correct(fvVectorMatrix &UEqn, const volScalarField &rho, const volScalarField &mu) const =0
virtual void calcTransformModelData()=0
Transform the model data wrt mesh changes.
virtual void calcForce(const volVectorField &U, const volScalarField &rho, const volScalarField &mu, vectorField &force) const =0
Calculate the porosity force.
bool active_
Porosity active flag.
const fvMesh & mesh_
Reference to the mesh database.
void operator=(const porosityModel &)=delete
No copy assignment.
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.
virtual bool writeData(Ostream &os) const
Write.
word name_
Porosity name.
virtual bool global() const
Is object global.
const labelList & cellZoneIDs() const
Return const access to the cell zone IDs.
TypeName("porosityModel")
Runtime type information.
virtual ~porosityModel()=default
Destructor.
autoPtr< coordinateSystem > csysPtr_
Local coordinate system.
dictionary coeffs_
Model coefficients dictionary.
porosityModel(const porosityModel &)=delete
No copy construct.
virtual void transformModelData()
Transform the model data wrt mesh changes.
const dictionary dict_
Dictionary used for model construction.
virtual fileName filePath() const
Return complete path + object name if the file exists.
wordRe zoneName_
Name(s) of cell-zone.
virtual void correct(const fvVectorMatrix &UEqn, volTensorField &AU) const =0
const coordinateSystem & csys() const
Local coordinate system.
virtual void correct(fvVectorMatrix &UEqn) const =0
const dictionary & dict() const
Return dictionary used for model construction.
void adjustNegativeResistance(dimensionedVector &resist)
Adjust negative resistance values to be multiplier of max value.
static autoPtr< porosityModel > New(const word &name, const fvMesh &mesh, const dictionary &dict, const wordRe &cellZoneName=wordRe::null)
Selector.
bool active() const
Return const access to the porosity active flag.
const word & name() const
Return const access to the porosity model name.
labelList cellZoneIDs_
Cell zone IDs.
virtual tmp< vectorField > force(const volVectorField &U, const volScalarField &rho, const volScalarField &mu)
Return the force over the cell zone(s).
virtual bool read()
Inherit read from regIOobject.
label fieldIndex(const label index) const
Return label index.
regIOobject(const IOobject &io, const bool isTimeObject=false)
Construct from IOobject. The optional flag adds special handling if the object is the top-level regIO...
Definition regIOobject.C:43
virtual bool read()
Read object.
A class for managing temporary objects.
Definition tmp.H:75
A wordRe is a Foam::word, but can contain a regular expression for matching words or strings.
Definition wordRe.H:81
static const wordRe null
An empty wordRe.
Definition wordRe.H:97
A class for handling words, derived from Foam::string.
Definition word.H:66
U
Definition pEqn.H:72
thermo correct()
fvVectorMatrix & UEqn
Definition UEqn.H:13
dynamicFvMesh & mesh
OBJstream os(runTime.globalPath()/outputName)
Forward declarations of fvMatrix specializations.
Namespace for OpenFOAM.
GeometricField< vector, fvPatchField, volMesh > volVectorField
List< label > labelList
A List of labels.
Definition List.H:62
GeometricField< scalar, fvPatchField, volMesh > volScalarField
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition POSIX.C:801
GeometricField< tensor, fvPatchField, volMesh > volTensorField
fvMatrix< vector > fvVectorMatrix
Field< vector > vectorField
Specialisation of Field<T> for vector.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition exprTraits.C:127
dimensioned< vector > dimensionedVector
Dimensioned vector obtained from generic dimensioned type.
Macros to ease declaration of run-time selection tables.
#define declareRunTimeSelectionTable(ptrWrapper, baseType, argNames, argList, parList)
Declare a run-time selection (variables and adder classes).
dictionary dict
Trait for specifying global vs. local IOobject file types.
Definition IOobject.H:175
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition typeInfo.H:68