porosityModel.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) 2012-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::porosityModel
26 
27 Description
28  Top level model for porosity models
29 
30 SourceFiles
31  porosityModel.C
32  porosityModelNew.C
33 
34 \*---------------------------------------------------------------------------*/
35 
36 #ifndef porosityModel_H
37 #define porosityModel_H
38 
39 #include "fvMesh.H"
40 #include "fvMatricesFwd.H"
41 #include "coordinateSystem.H"
42 #include "dimensionedVector.H"
43 #include "wordRe.H"
44 #include "runTimeSelectionTables.H"
45 
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 
48 namespace Foam
49 {
50 
51 /*---------------------------------------------------------------------------*\
52  Class porosityModel Declaration
53 \*---------------------------------------------------------------------------*/
54 
55 class porosityModel
56 :
57  public regIOobject
58 {
59  // Private Member Functions
60 
61  //- Disallow default bitwise copy construction
62  porosityModel(const porosityModel&) = delete;
63 
64  //- Disallow default bitwise assignment
65  void operator=(const porosityModel&) = delete;
66 
67 
68 protected:
69 
70  // Protected data
71 
72  //- Porosity name
73  word name_;
74 
75  //- Reference to the mesh database
76  const fvMesh& mesh_;
77 
78  //- Dictionary used for model construction
79  const dictionary dict_;
80 
81  //- Model coefficients dictionary
83 
84  //- Name(s) of cell-zone
86 
87  //- Cell zone IDs
89 
90  //- Local co-ordinate system
92 
93 
94  // Protected Member Functions
95 
96  //- Transform the model data wrt mesh changes
97  virtual void calcTransformModelData() = 0;
98 
99  //- Adjust negative resistance values to be multiplier of max value
101 
102  //- Calculate the porosity force
103  virtual void calcForce
104  (
105  const volVectorField& U,
106  const volScalarField& rho,
107  const volScalarField& mu,
109  ) const = 0;
110 
111  virtual void correct(fvVectorMatrix& UEqn) const = 0;
112 
113  virtual void correct
114  (
115  const fvVectorMatrix& UEqn,
116  volTensorField& AU
117  ) const = 0;
118 
119  //- Return label index
120  label fieldIndex(const label index) const;
121 
122 
123 public:
124 
125  //- Runtime type information
126  TypeName("porosityModel");
127 
128  //- Selection table
130  (
131  autoPtr,
133  mesh,
134  (
135  const word& modelName,
136  const word& name,
137  const fvMesh& mesh,
138  const dictionary& dict,
139  const word& cellZoneName
140  ),
141  (modelName, name, mesh, dict, cellZoneName)
142  );
143 
144  //- Constructor
146  (
147  const word& name,
148  const word& modelType,
149  const fvMesh& mesh,
150  const dictionary& dict,
151  const word& cellZoneName = word::null
152  );
153 
154  //- Return pointer to new porosityModel object created on the freestore
155  // from an Istream
156  class iNew
157  {
158  //- Reference to the mesh database
159  const fvMesh& mesh_;
160  const word& name_;
161 
162  public:
163 
165  (
166  const fvMesh& mesh,
167  const word& name
168  )
169  :
170  mesh_(mesh),
171  name_(name)
172  {}
175  {
176  const dictionary dict(is);
177 
179  (
181  (
182  name_,
183  mesh_,
184  dict
185  )
186  );
187  }
188  };
189 
190  //- Selector
192  (
193  const word& name,
194  const fvMesh& mesh,
195  const dictionary& dict,
196  const word& cellZoneName = word::null
197  );
198 
199  //- Destructor
200  virtual ~porosityModel();
201 
202 
203  // Member Functions
204 
205  //- Return const access to the porosity model name
206  inline const word& name() const;
207 
208  //- Return const access to the cell zone IDs
209  inline const labelList& cellZoneIDs() const;
210 
211  //- Return dictionary used for model construction
212  const dictionary& dict() const;
213 
214  //- Transform the model data wrt mesh changes
215  virtual void transformModelData();
216 
217  //- Return the force over the cell zone(s)
218  virtual tmp<vectorField> force
219  (
220  const volVectorField& U,
221  const volScalarField& rho,
222  const volScalarField& mu
223  ) const;
224 
225  //- Add resistance
226  virtual void addResistance(fvVectorMatrix& UEqn);
227 
228  //- Add resistance
229  virtual void addResistance
230  (
231  const fvVectorMatrix& UEqn,
232  volTensorField& AU,
233  bool correctAUprocBC
234  );
235 
236 
237  // I-O
238 
239  //- Write
240  virtual bool writeData(Ostream& os) const;
241 
242  //- Inherit read from regIOobject
243  using regIOobject::read;
244 
245  //- Read porosity dictionary
246  virtual bool read(const dictionary& dict);
247 };
248 
249 
250 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
251 
252 } // End namespace Foam
253 
254 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
255 
256 #include "porosityModelI.H"
257 
258 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
259 
260 #endif
261 
262 // ************************************************************************* //
Base class for other coordinate system specifications.
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
virtual bool writeData(Ostream &os) const
Write.
const dictionary & dict() const
Return dictionary used for model construction.
virtual bool read()
Read object.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
coordinateSystem coordSys_
Local co-ordinate system.
Definition: porosityModel.H:90
dictionary coeffs_
Model coefficients dictionary.
Definition: porosityModel.H:81
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
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.
iNew(const fvMesh &mesh, const word &name)
const labelList & cellZoneIDs() const
Return const access to the cell zone IDs.
TypeName("porosityModel")
Runtime type information.
label fieldIndex(const label index) const
Return label index.
Definition: porosityModel.C:66
virtual tmp< vectorField > force(const volVectorField &U, const volScalarField &rho, const volScalarField &mu) const
Return the force over the cell zone(s)
autoPtr< porosityModel > operator()(Istream &is) const
wordRe zoneName_
Name(s) of cell-zone.
Definition: porosityModel.H:84
word name_
Porosity name.
Definition: porosityModel.H:72
void adjustNegativeResistance(dimensionedVector &resist)
Adjust negative resistance values to be multiplier of max value.
Definition: porosityModel.C:40
dynamicFvMesh & mesh
A class for handling words, derived from string.
Definition: word.H:59
static const word null
An empty word.
Definition: word.H:77
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:72
virtual void correct(fvVectorMatrix &UEqn) const =0
A wordRe is a word, but can also have a regular expression for matching words.
Definition: wordRe.H:74
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
const fvMesh & mesh_
Reference to the mesh database.
Definition: porosityModel.H:75
virtual void transformModelData()
Transform the model data wrt mesh changes.
const dimensionedScalar mu
Atomic mass unit.
labelList cellZoneIDs_
Cell zone IDs.
Definition: porosityModel.H:87
Return pointer to new porosityModel object created on the freestore.
const dictionary dict_
Dictionary used for model construction.
Definition: porosityModel.H:78
virtual ~porosityModel()
Destructor.
Forward declarations of fvMatrix specialisations.
U
Definition: pEqn.H:72
const word & name() const
Return const access to the porosity model name.
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:52
virtual void calcTransformModelData()=0
Transform the model data wrt mesh changes.
static autoPtr< porosityModel > New(const word &name, const fvMesh &mesh, const dictionary &dict, const word &cellZoneName=word::null)
Selector.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
Macros to ease declaration of run-time selection tables.
static word modelName(Name name, const word &model)
Return the name of the object within the given model.
A class for managing temporary objects.
Definition: PtrList.H:53
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.
Top level model for porosity models.
Definition: porosityModel.H:54
Namespace for OpenFOAM.
fvVectorMatrix & UEqn
Definition: UEqn.H:13