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-2023 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 of cellZone
86 
87  //- Local co-ordinate 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  (
112  const fvVectorMatrix& UEqn,
113  volTensorField& AU
114  ) const = 0;
115 
116  //- Return label index
117  label fieldIndex(const label index) const;
118 
119 
120 public:
121 
122  //- Runtime type information
123  TypeName("porosityModel");
124 
125  //- Selection table
127  (
128  autoPtr,
130  mesh,
131  (
132  const word& modelName,
133  const word& name,
134  const fvMesh& mesh,
135  const dictionary& dict,
136  const word& cellZoneName
137  ),
138  (modelName, name, mesh, dict, cellZoneName)
139  );
140 
141  //- Constructor
143  (
144  const word& name,
145  const word& modelType,
146  const fvMesh& mesh,
147  const dictionary& dict,
148  const word& cellZoneName = word::null
149  );
150 
151  //- Return pointer to new porosityModel object created on the freestore
152  // from an Istream
153  class iNew
154  {
155  //- Reference to the mesh database
156  const fvMesh& mesh_;
157  const word& name_;
158 
159  public:
160 
161  iNew
162  (
163  const fvMesh& mesh,
164  const word& name
165  )
166  :
167  mesh_(mesh),
168  name_(name)
169  {}
170 
172  {
173  const dictionary dict(is);
174 
176  (
178  (
179  name_,
180  mesh_,
181  dict
182  )
183  );
184  }
185  };
186 
187  //- Selector
189  (
190  const word& name,
191  const fvMesh& mesh,
192  const dictionary& dict,
193  const word& cellZoneName = word::null
194  );
195 
196  //- Destructor
197  virtual ~porosityModel();
198 
199 
200  // Member Functions
201 
202  //- Return const access to the porosity model name
203  inline const word& name() const;
204 
205  //- Return const access to the cell zone name
206  inline const word& zoneName() const;
207 
208  //- Return dictionary used for model construction
209  const dictionary& dict() const;
210 
211  //- Transform the model data wrt mesh changes
212  virtual void transformModelData();
213 
214  //- Return the force over the cell zone(s)
215  virtual tmp<vectorField> force
216  (
217  const volVectorField& U,
218  const volScalarField& rho,
219  const volScalarField& mu
220  ) const;
221 
222  //- Add resistance
223  virtual void addResistance(fvVectorMatrix& UEqn);
224 
225  //- Add resistance
226  virtual void addResistance
227  (
228  const fvVectorMatrix& UEqn,
229  volTensorField& AU,
230  bool correctAUprocBC
231  );
232 
233 
234  // I-O
235 
236  //- Write
237  virtual bool writeData(Ostream& os) const;
238 
239  //- Inherit read from regIOobject
240  using regIOobject::read;
241 
242  //- Read porosity dictionary
243  virtual bool read(const dictionary& dict);
244 };
245 
246 
247 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
248 
249 } // End namespace Foam
250 
251 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
252 
253 #include "porosityModelI.H"
254 
255 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
256 
257 #endif
258 
259 // ************************************************************************* //
Generic GeometricField class.
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:57
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
Base class for other coordinate system specifications.
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:162
A special matrix type and solver, designed for finite volume solutions of scalar equations....
Definition: fvMatrix.H:118
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:99
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.
Definition: porosityModel.H:57
virtual void addResistance(fvVectorMatrix &UEqn)
Add resistance.
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.
const fvMesh & mesh_
Reference to the mesh database.
Definition: porosityModel.H:75
const word & zoneName() const
Return const access to the cell zone name.
virtual ~porosityModel()
Destructor.
word zoneName_
Name of cellZone.
Definition: porosityModel.H:84
virtual bool writeData(Ostream &os) const
Write.
word name_
Porosity name.
Definition: porosityModel.H:72
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.
TypeName("porosityModel")
Runtime type information.
coordinateSystem coordSys_
Local co-ordinate system.
Definition: porosityModel.H:87
dictionary coeffs_
Model coefficients dictionary.
Definition: porosityModel.H:81
virtual void transformModelData()
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.
const dictionary dict_
Dictionary used for model construction.
Definition: porosityModel.H:78
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.
Definition: porosityModel.C:40
const word & name() const
Return const access to the porosity model name.
virtual tmp< vectorField > force(const volVectorField &U, const volScalarField &rho, const volScalarField &mu) const
Return the force over the cell zone(s)
virtual bool read()
Inherit read from regIOobject.
label fieldIndex(const label index) const
Return label index.
Definition: porosityModel.C:66
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:55
virtual bool read()
Read object.
A class for managing temporary objects.
Definition: tmp.H:55
A class for handling words, derived from string.
Definition: word.H:62
static const word null
An empty word.
Definition: word.H:77
fvVectorMatrix & UEqn
Definition: UEqn.H:11
Forward declarations of fvMatrix specialisations.
U
Definition: pEqn.H:72
const dimensionedScalar mu
Atomic mass unit.
Namespace for OpenFOAM.
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
Macros to ease declaration of run-time selection tables.