phaseModel.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) 2015-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::phaseModel
26 
27 SourceFiles
28  phaseModel.C
29 
30 \*---------------------------------------------------------------------------*/
31 
32 #ifndef phaseModel_H
33 #define phaseModel_H
34 
35 #include "dictionary.H"
36 #include "dimensionedScalar.H"
37 #include "volFields.H"
38 #include "surfaceFields.H"
39 #include "fvMatricesFwd.H"
40 #include "rhoThermo.H"
41 #include "runTimeSelectionTables.H"
42 
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 
45 namespace Foam
46 {
47 
48 class phaseSystem;
49 class diameterModel;
50 
51 /*---------------------------------------------------------------------------*\
52  Class phaseModel Declaration
53 \*---------------------------------------------------------------------------*/
54 
55 class phaseModel
56 :
57  public volScalarField
58 {
59  // Private Data
60 
61  //- Reference to the phaseSystem to which this phase belongs
62  const phaseSystem& fluid_;
63 
64  //- Name of phase
65  word name_;
66 
67  //- Index of phase
68  label index_;
69 
70  //- Return the residual phase-fraction for given phase
71  // Used to stabilise the phase momentum as the phase-fraction -> 0
72  dimensionedScalar residualAlpha_;
73 
74  //- Optional maximum phase-fraction (e.g. packing limit)
75  scalar alphaMax_;
76 
77  //- Diameter model
78  autoPtr<diameterModel> diameterModel_;
79 
80 
81 public:
82 
83  //- Runtime type information
84  ClassName("phaseModel");
85 
86 
87  // Declare runtime construction
88 
90  (
91  autoPtr,
92  phaseModel,
93  phaseSystem,
94  (
95  const phaseSystem& fluid,
96  const word& phaseName,
97  const bool referencePhase,
98  const label index
99  ),
100  (fluid, phaseName, referencePhase, index)
101  );
102 
103 
104  // Constructors
105 
106  phaseModel
107  (
108  const phaseSystem& fluid,
109  const word& phaseName,
110  const bool referencePhase,
111  const label index
112  );
113 
114  //- Return clone
115  autoPtr<phaseModel> clone() const;
116 
117 
118  // Selectors
119 
120  static autoPtr<phaseModel> New
121  (
122  const phaseSystem& fluid,
123  const word& phaseName,
124  const bool referencePhase,
125  const label index
126  );
127 
128  //- Return a pointer to a new phase created on freestore
129  // from Istream
130  class iNew
131  {
132  const phaseSystem& fluid_;
133  const word& referencePhaseName_;
134  mutable label indexCounter_;
135 
136  public:
137 
139  (
140  const phaseSystem& fluid,
141  const word& referencePhaseName
142  )
143  :
144  fluid_(fluid),
145  referencePhaseName_(referencePhaseName),
146  indexCounter_(-1)
147  {}
150  {
151  indexCounter_++;
152 
153  const word phaseName(is);
154 
155  return autoPtr<phaseModel>
156  (
158  (
159  fluid_,
160  phaseName,
161  phaseName == referencePhaseName_,
162  indexCounter_
163  )
164  );
165  }
166  };
167 
168 
169  //- Destructor
170  virtual ~phaseModel();
171 
172 
173  // Member Functions
174 
175  //- Return the name of this phase
176  const word& name() const;
177 
178  //- Return the name of the phase for use as the keyword in PtrDictionary
179  const word& keyword() const;
180 
181  //- Return the index of the phase
182  label index() const;
183 
184  //- Return the system to which this phase belongs
185  const phaseSystem& fluid() const;
186 
187  //- Return the residual phase-fraction for given phase
188  // Used to stabilise the phase momentum as the phase-fraction -> 0
189  const dimensionedScalar& residualAlpha() const;
190 
191  //- Return the maximum phase-fraction (e.g. packing limit)
192  scalar alphaMax() const;
193 
194  //- Return the Sauter-mean diameter
195  tmp<volScalarField> d() const;
196 
197  //- Return const-reference to diameterModel of the phase
198  const autoPtr<diameterModel>& dPtr() const;
199 
200  //- Correct the phase properties
201  virtual void correct();
202 
203  //- Correct the continuity error
204  virtual void correctContinuityError(const volScalarField& source);
205 
206  //- Correct the kinematics
207  virtual void correctKinematics();
208 
209  //- Correct the thermodynamics
210  virtual void correctThermo();
211 
212  //- Correct the reactions
213  virtual void correctReactions();
214 
215  //- Correct the species concentrations
216  virtual void correctSpecies();
217 
218  //- Correct the turbulence
219  virtual void correctTurbulence();
220 
221  //- Correct the energy transport
222  virtual void correctEnergyTransport();
223 
224  //- Correct the face velocity for moving meshes
225  virtual void correctUf();
226 
227  //- Ensure that the flux at inflow/outflow BCs is preserved
229 
230  //- Read phase properties dictionary
231  virtual bool read();
232 
233 
234  // Density variation and compressibility
235 
236  //- Return true if the phase is incompressible otherwise false
237  virtual bool incompressible() const = 0;
238 
239  //- Return true if the phase is constant density otherwise false
240  virtual bool isochoric() const = 0;
241 
242  //- Return the phase dilatation rate (d(alpha)/dt + div(alpha*phi))
243  virtual tmp<volScalarField> divU() const = 0;
244 
245  //- Set the phase dilatation rate (d(alpha)/dt + div(alpha*phi))
246  virtual void divU(tmp<volScalarField> divU) = 0;
247 
248 
249  // Thermo
250 
251  //- Return the thermophysical model
252  virtual const rhoThermo& thermo() const = 0;
253 
254  //- Access the thermophysical model
255  virtual rhoThermo& thermoRef() = 0;
256 
257  //- Return the density field
258  virtual tmp<volScalarField> rho() const = 0;
259 
260  //- Return whether the phase is isothermal
261  virtual bool isothermal() const = 0;
262 
263  //- Return the enthalpy equation
264  virtual tmp<fvScalarMatrix> heEqn() = 0;
265 
266 
267  // Species
268 
269  //- Return whether the phase is pure (i.e., not multi-component)
270  virtual bool pure() const = 0;
271 
272  //- Return the species fraction equation
273  virtual tmp<fvScalarMatrix> YiEqn(volScalarField& Yi) = 0;
274 
275  //- Return the species mass fractions
276  virtual const PtrList<volScalarField>& Y() const = 0;
277 
278  //- Return a species mass fraction by name
279  virtual const volScalarField& Y(const word& name) const = 0;
280 
281  //- Access the species mass fractions
282  virtual PtrList<volScalarField>& YRef() = 0;
283 
284  //- Return the active species mass fractions
285  virtual const UPtrList<volScalarField>& YActive() const = 0;
286 
287  //- Access the active species mass fractions
288  virtual UPtrList<volScalarField>& YActiveRef() = 0;
289 
290  //- Return the fuel consumption rate matrix
291  virtual tmp<fvScalarMatrix> R(volScalarField& Yi) const = 0;
292 
293 
294  // Momentum
295 
296  //- Return whether the phase is stationary
297  virtual bool stationary() const = 0;
298 
299  //- Return the momentum equation
300  virtual tmp<fvVectorMatrix> UEqn() = 0;
301 
302  //- Return the momentum equation for the face-based algorithm
303  virtual tmp<fvVectorMatrix> UfEqn() = 0;
304 
305  //- Return the velocity
306  virtual tmp<volVectorField> U() const = 0;
307 
308  //- Access the velocity
309  virtual volVectorField& URef() = 0;
310 
311  //- Return the volumetric flux
312  virtual tmp<surfaceScalarField> phi() const = 0;
313 
314  //- Access the volumetric flux
315  virtual surfaceScalarField& phiRef() = 0;
316 
317  //- Return the face velocity
318  // Required for moving mesh cases
319  virtual tmp<surfaceVectorField> Uf() const = 0;
320 
321  //- Access the face velocity
322  // Required for moving mesh cases
323  virtual surfaceVectorField& UfRef() = 0;
324 
325  //- Return the volumetric flux of the phase
326  virtual tmp<surfaceScalarField> alphaPhi() const = 0;
327 
328  //- Access the volumetric flux of the phase
329  virtual surfaceScalarField& alphaPhiRef() = 0;
330 
331  //- Return the mass flux of the phase
332  virtual tmp<surfaceScalarField> alphaRhoPhi() const = 0;
333 
334  //- Access the mass flux of the phase
335  virtual surfaceScalarField& alphaRhoPhiRef() = 0;
336 
337  //- Return the substantive acceleration
338  virtual tmp<volVectorField> DUDt() const = 0;
339 
340  //- Return the substantive acceleration on the faces
341  virtual tmp<surfaceScalarField> DUDtf() const = 0;
342 
343  //- Return the continuity error
344  virtual tmp<volScalarField> continuityError() const = 0;
345 
346  //- Return the phase kinetic energy
347  virtual tmp<volScalarField> K() const = 0;
348 
349 
350  // Transport
351 
352  //- Effective thermal turbulent diffusivity for temperature
353  // of mixture for patch [W/m/K]
354  virtual tmp<scalarField> kappaEff(const label patchi) const = 0;
355 
356  //- Return the turbulent kinetic energy
357  virtual tmp<volScalarField> k() const = 0;
358 
359  //- Return the phase-pressure'
360  // (derivative of phase-pressure w.r.t. phase-fraction)
361  virtual tmp<volScalarField> pPrime() const = 0;
362 };
363 
364 
365 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
366 
367 } // End namespace Foam
368 
369 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
370 
371 #endif
372 
373 // ************************************************************************* //
Foam::surfaceFields.
virtual surfaceScalarField & phiRef()=0
Access the volumetric flux.
virtual UPtrList< volScalarField > & YActiveRef()=0
Access the active species mass fractions.
void correctInflowOutflow(surfaceScalarField &alphaPhi) const
Ensure that the flux at inflow/outflow BCs is preserved.
label index() const
Return the index of the phase.
FvWallInfoData< WallInfo, label > label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
virtual tmp< volScalarField > continuityError() const =0
Return the continuity error.
virtual surfaceScalarField & alphaRhoPhiRef()=0
Access the mass flux of the phase.
virtual tmp< volScalarField > divU() const =0
Return the phase dilatation rate (d(alpha)/dt + div(alpha*phi))
virtual tmp< surfaceVectorField > Uf() const =0
Return the face velocity.
virtual bool incompressible() const =0
Return true if the phase is incompressible otherwise false.
static autoPtr< phaseModel > New(const phaseSystem &fluid, const word &phaseName, const bool referencePhase, const label index)
virtual tmp< fvScalarMatrix > R(volScalarField &Yi) const =0
Return the fuel consumption rate matrix.
virtual tmp< volVectorField > U() const =0
Return the velocity.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
declareRunTimeSelectionTable(autoPtr, phaseModel, phaseSystem,(const phaseSystem &fluid, const word &phaseName, const bool referencePhase, const label index),(fluid, phaseName, referencePhase, index))
autoPtr< phaseModel > operator()(Istream &is) const
Definition: phaseModel.H:101
virtual void correctKinematics()
Correct the kinematics.
virtual tmp< volScalarField > rho() const =0
Return the density field.
autoPtr< phaseModel > clone() const
Return clone.
const word & name() const
Definition: phaseModel.H:110
virtual tmp< volVectorField > DUDt() const =0
Return the substantive acceleration.
tmp< volScalarField > d() const
Return the Sauter-mean diameter.
phaseModel(const word &phaseName, const volScalarField &p, const volScalarField &T)
Construct from components.
virtual bool isothermal() const =0
Return whether the phase is isothermal.
iNew(const volScalarField &p, const volScalarField &T)
Definition: phaseModel.H:92
virtual tmp< fvScalarMatrix > YiEqn(volScalarField &Yi)=0
Return the species fraction equation.
virtual tmp< surfaceScalarField > alphaPhi() const =0
Return the volumetric flux of the phase.
virtual void correctSpecies()
Correct the species concentrations.
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:58
virtual tmp< fvScalarMatrix > heEqn()=0
Return the enthalpy equation.
virtual tmp< surfaceScalarField > phi() const =0
Return the volumetric flux.
virtual ~phaseModel()
Destructor.
virtual tmp< scalarField > kappaEff(const label patchi) const =0
Effective thermal turbulent diffusivity for temperature.
virtual PtrList< volScalarField > & YRef()=0
Access the species mass fractions.
virtual bool read()
Read phase properties dictionary.
Class to represent a system of phases and model interfacial transfers between them.
Definition: phaseSystem.H:68
virtual tmp< volScalarField > k() const =0
Return the turbulent kinetic energy.
A class for handling words, derived from string.
Definition: word.H:59
virtual const UPtrList< volScalarField > & YActive() const =0
Return the active species mass fractions.
const rhoThermo & thermo() const
Return const-access to phase rhoThermo.
Definition: phaseModel.H:121
virtual bool pure() const =0
Return whether the phase is pure (i.e., not multi-component)
virtual void correctUf()
Correct the face velocity for moving meshes.
const word & keyword() const
Definition: phaseModel.H:115
virtual tmp< volScalarField > K() const =0
Return the phase kinetic energy.
virtual tmp< volScalarField > pPrime() const =0
Return the phase-pressure&#39;.
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: UPtrList.H:54
const dimensionedScalar & residualAlpha() const
Return the residual phase-fraction for given phase.
virtual const PtrList< volScalarField > & Y() const =0
Return the species mass fractions.
scalar alphaMax() const
Return the maximum phase-fraction (e.g. packing limit)
virtual tmp< fvVectorMatrix > UEqn()=0
Return the momentum equation.
virtual tmp< surfaceScalarField > alphaRhoPhi() const =0
Return the mass flux of the phase.
virtual surfaceVectorField & UfRef()=0
Access the face velocity.
virtual tmp< surfaceScalarField > DUDtf() const =0
Return the substantive acceleration on the faces.
Forward declarations of fvMatrix specialisations.
label patchi
virtual surfaceScalarField & alphaPhiRef()=0
Access the volumetric flux of the phase.
ClassName("phaseModel")
Runtime type information.
virtual bool isochoric() const =0
Return true if the phase is constant density otherwise false.
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: List.H:70
const phaseSystem & fluid() const
Return the system to which this phase belongs.
const autoPtr< diameterModel > & dPtr() const
Return const-reference to diameterModel of the phase.
virtual bool stationary() const =0
Return whether the phase is stationary.
Base-class for fluid thermodynamic properties based on density.
Definition: rhoThermo.H:52
virtual void correctThermo()
Correct the thermodynamics.
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.
A class for managing temporary objects.
Definition: PtrList.H:53
virtual void correctEnergyTransport()
Correct the energy transport.
virtual void correctTurbulence()
Correct the turbulence.
virtual void correctReactions()
Correct the reactions.
virtual tmp< fvVectorMatrix > UfEqn()=0
Return the momentum equation for the face-based algorithm.
virtual volVectorField & URef()=0
Access the velocity.
Namespace for OpenFOAM.
virtual void correctContinuityError(const volScalarField &source)
Correct the continuity error.
virtual rhoThermo & thermoRef()=0
Access the thermophysical model.