multiphaseMixtureThermo.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) 2013-2017 OpenFOAM Foundation
9  Copyright (C) 2019 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::multiphaseMixtureThermo
29 
30 Description
31 
32 SourceFiles
33  multiphaseMixtureThermo.C
34 
35 \*---------------------------------------------------------------------------*/
36 
37 #ifndef multiphaseMixtureThermo_H
38 #define multiphaseMixtureThermo_H
39 
40 #include "phaseModel.H"
41 #include "PtrDictionary.H"
42 #include "volFields.H"
43 #include "surfaceFields.H"
44 #include "rhoThermo.H"
45 #include "psiThermo.H"
46 
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 
49 namespace Foam
50 {
51 
52 /*---------------------------------------------------------------------------*\
53  Class multiphaseMixtureThermo Declaration
54 \*---------------------------------------------------------------------------*/
55 
57 :
58  public psiThermo
59 {
60 public:
61 
62  class interfacePair
63  :
64  public Pair<word>
65  {
66  public:
67 
68  struct hash
69  {
70  label operator()(const interfacePair& key) const
71  {
72  return word::hash()(key.first()) + word::hash()(key.second());
73  }
74  };
75 
76 
77  // Constructors
78 
79  interfacePair() {} // = default
80 
81  interfacePair(const word& alpha1Name, const word& alpha2Name)
82  :
83  Pair<word>(alpha1Name, alpha2Name)
84  {}
85 
87  :
89  {}
90 
91 
92  // Friend Operators
93 
94  friend bool operator==
95  (
96  const interfacePair& a,
97  const interfacePair& b
98  )
99  {
100  return
101  (
102  ((a.first() == b.first()) && (a.second() == b.second()))
103  || ((a.first() == b.second()) && (a.second() == b.first()))
104  );
105  }
106 
107  friend bool operator!=
108  (
109  const interfacePair& a,
110  const interfacePair& b
111  )
112  {
113  return (!(a == b));
114  }
115  };
116 
117 
118 private:
119 
120  // Private data
121 
122  //- Dictionary of phases
124 
125  const fvMesh& mesh_;
126  const volVectorField& U_;
127  const surfaceScalarField& phi_;
128 
129  surfaceScalarField rhoPhi_;
130 
131  volScalarField alphas_;
132 
134  sigmaTable;
135 
136  sigmaTable sigmas_;
137  dimensionSet dimSigma_;
138 
139  //- Stabilisation for normalisation of the interface normal
140  const dimensionedScalar deltaN_;
141 
142  //- Conversion factor for degrees into radians
143  static const scalar convertToRad;
144 
145 
146 
147  // Private member functions
148 
149  void calcAlphas();
150 
151  void solveAlphas(const scalar cAlpha);
152 
154  (
155  const volScalarField& alpha1,
156  const volScalarField& alpha2
157  ) const;
158 
160  (
161  const volScalarField& alpha1,
162  const volScalarField& alpha2
163  ) const;
164 
165  void correctContactAngle
166  (
167  const phaseModel& alpha1,
168  const phaseModel& alpha2,
169  surfaceVectorField::Boundary& nHatb
170  ) const;
171 
173  (
174  const phaseModel& alpha1,
175  const phaseModel& alpha2
176  ) const;
177 
178 
179 public:
180 
181  //- Runtime type information
182  TypeName("multiphaseMixtureThermo");
183 
184 
185  // Constructors
186 
187  //- Construct from components
189  (
190  const volVectorField& U,
191  const surfaceScalarField& phi
192  );
193 
194 
195  //- Destructor
196  virtual ~multiphaseMixtureThermo() = default;
197 
198 
199  // Member Functions
200 
201  //- Return the phases
202  const PtrDictionary<phaseModel>& phases() const
203  {
204  return phases_;
205  }
206 
207  //- Return non-const access to the phases
209  {
210  return phases_;
211  }
212 
213  //- Return the velocity
214  const volVectorField& U() const
215  {
216  return U_;
217  }
218 
219  //- Return the volumetric flux
220  const surfaceScalarField& phi() const
221  {
222  return phi_;
223  }
224 
225  const surfaceScalarField& rhoPhi() const
226  {
227  return rhoPhi_;
228  }
229 
230  //- Update properties
231  virtual void correct();
232 
233  //- Update densities for given pressure change
234  void correctRho(const volScalarField& dp);
235 
236  //- Return the name of the thermo physics
237  virtual word thermoName() const;
238 
239  //- Return true if the equation of state is incompressible
240  // i.e. rho != f(p)
241  virtual bool incompressible() const;
242 
243  //- Return true if the equation of state is isochoric
244  // i.e. rho = const
245  virtual bool isochoric() const;
246 
247 
248  // Access to thermodynamic state variables
249 
250  //- Enthalpy/Internal energy [J/kg]
251  // Non-const access allowed for transport equations
252  virtual volScalarField& he()
253  {
255  return phases_[0].thermo().he();
256  }
257 
258  //- Enthalpy/Internal energy [J/kg]
259  virtual const volScalarField& he() const
260  {
262  return phases_[0].thermo().he();
263  }
264 
265  //- Enthalpy/Internal energy
266  // for given pressure and temperature [J/kg]
267  virtual tmp<volScalarField> he
268  (
269  const volScalarField& p,
270  const volScalarField& T
271  ) const;
272 
273  //- Enthalpy/Internal energy for cell-set [J/kg]
274  virtual tmp<scalarField> he
275  (
276  const scalarField& p,
277  const scalarField& T,
278  const labelList& cells
279  ) const;
280 
281  //- Enthalpy/Internal energy for patch [J/kg]
282  virtual tmp<scalarField> he
283  (
284  const scalarField& p,
285  const scalarField& T,
286  const label patchi
287  ) const;
288 
289  //- Chemical enthalpy [J/kg]
290  virtual tmp<volScalarField> hc() const;
291 
292  //- Temperature from enthalpy/internal energy for cell-set
293  virtual tmp<scalarField> THE
294  (
295  const scalarField& h,
296  const scalarField& p,
297  const scalarField& T0, // starting temperature
298  const labelList& cells
299  ) const;
300 
301  //- Temperature from enthalpy/internal energy for patch
302  virtual tmp<scalarField> THE
303  (
304  const scalarField& h,
305  const scalarField& p,
306  const scalarField& T0, // starting temperature
307  const label patchi
308  ) const;
309 
310 
311  // Fields derived from thermodynamic state variables
312 
313  //- Density [kg/m^3]
314  virtual tmp<volScalarField> rho() const;
315 
316  //- Density for patch [kg/m^3]
317  virtual tmp<scalarField> rho(const label patchi) const;
318 
319  //- Heat capacity at constant pressure [J/kg/K]
320  virtual tmp<volScalarField> Cp() const;
321 
322  //- Heat capacity at constant pressure for patch [J/kg/K]
323  virtual tmp<scalarField> Cp
324  (
325  const scalarField& p,
326  const scalarField& T,
327  const label patchi
328  ) const;
329 
330  //- Heat capacity at constant volume [J/kg/K]
331  virtual tmp<volScalarField> Cv() const;
332 
333  //- Heat capacity at constant volume for patch [J/kg/K]
334  virtual tmp<scalarField> Cv
335  (
336  const scalarField& p,
337  const scalarField& T,
338  const label patchi
339  ) const;
340 
341  //- Gamma = Cp/Cv []
342  virtual tmp<volScalarField> gamma() const;
343 
344  //- Gamma = Cp/Cv for patch []
345  virtual tmp<scalarField> gamma
346  (
347  const scalarField& p,
348  const scalarField& T,
349  const label patchi
350  ) const;
351 
352  //- Heat capacity at constant pressure/volume [J/kg/K]
353  virtual tmp<volScalarField> Cpv() const;
354 
355  //- Heat capacity at constant pressure/volume for patch [J/kg/K]
356  virtual tmp<scalarField> Cpv
357  (
358  const scalarField& p,
359  const scalarField& T,
360  const label patchi
361  ) const;
362 
363  //- Heat capacity ratio []
364  virtual tmp<volScalarField> CpByCpv() const;
365 
366  //- Heat capacity ratio for patch []
367  virtual tmp<scalarField> CpByCpv
368  (
369  const scalarField& p,
370  const scalarField& T,
371  const label patchi
372  ) const;
373 
374  //- Molecular weight [kg/kmol]
375  virtual tmp<volScalarField> W() const;
376 
377 
378  // Fields derived from transport state variables
379 
380  //- Kinematic viscosity of mixture [m^2/s]
381  virtual tmp<volScalarField> nu() const;
382 
383  //- Kinematic viscosity of mixture for patch [m^2/s]
384  virtual tmp<scalarField> nu(const label patchi) const;
385 
386  //- Thermal diffusivity for temperature of mixture [J/m/s/K]
387  virtual tmp<volScalarField> kappa() const;
388 
389  //- Thermal diffusivity of mixture for patch [J/m/s/K]
390  virtual tmp<scalarField> kappa
391  (
392  const label patchi
393  ) const;
394 
395 
396  //- Thermal diffusivity for energy of mixture [kg/m/s]
397  virtual tmp<volScalarField> alphahe() const;
398 
399  //- Thermal diffusivity for energy of mixture for patch [kg/m/s]
400  virtual tmp<scalarField> alphahe(const label patchi) const;
401 
402  //- Effective thermal diffusivity of mixture [J/m/s/K]
404  (
405  const volScalarField& alphat
406  ) const;
407 
408  //- Effective thermal diffusivity of mixture for patch [J/m/s/K]
409  virtual tmp<scalarField> kappaEff
410  (
411  const scalarField& alphat,
412  const label patchi
413  ) const;
414 
415  //- Effective thermal diffusivity of mixture [J/m/s/K]
417  (
418  const volScalarField& alphat
419  ) const;
420 
421  //- Effective thermal diffusivity of mixture for patch [J/m/s/K]
422  virtual tmp<scalarField> alphaEff
423  (
424  const scalarField& alphat,
425  const label patchi
426  ) const;
427 
428 
429  //- Return the phase-averaged reciprocal Cv
430  tmp<volScalarField> rCv() const;
431 
433 
434  //- Indicator of the proximity of the interface
435  // Field values are 1 near and 0 away for the interface.
437 
438  //- Solve for the mixture phase-fractions
439  void solve();
440 };
441 
442 
443 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
444 
445 } // End namespace Foam
446 
447 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
448 
449 #endif
450 
451 // ************************************************************************* //
Foam::Pair::second
const T & second() const noexcept
Return second element, which is also the last element.
Definition: PairI.H:122
Foam::multiphaseMixtureThermo::nu
virtual tmp< volScalarField > nu() const
Kinematic viscosity of mixture [m^2/s].
volFields.H
Foam::phaseModel
Single incompressible phase derived from the phase-fraction. Used as part of the multiPhaseMixture fo...
Definition: phaseModel.H:57
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::multiphaseMixtureThermo::alphahe
virtual tmp< volScalarField > alphahe() const
Thermal diffusivity for energy of mixture [kg/m/s].
Foam::multiphaseMixtureThermo::CpByCpv
virtual tmp< volScalarField > CpByCpv() const
Heat capacity ratio [].
Foam::multiphaseMixtureThermo::U
const volVectorField & U() const
Return the velocity.
Definition: multiphaseMixtureThermo.H:213
Foam::basicThermo::p
virtual volScalarField & p()
Pressure [Pa].
Definition: basicThermo.C:512
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:59
Foam::multiphaseMixtureThermo::interfacePair
Definition: multiphaseMixtureThermo.H:61
alpha2
const volScalarField & alpha2
Definition: setRegionFluidFields.H:9
Foam::PtrDictionary
Template dictionary class which manages the storage associated with it.
Definition: PtrDictionary.H:55
PtrDictionary.H
Foam::multiphaseMixtureThermo::~multiphaseMixtureThermo
virtual ~multiphaseMixtureThermo()=default
Destructor.
Foam::multiphaseMixtureThermo::he
virtual const volScalarField & he() const
Enthalpy/Internal energy [J/kg].
Definition: multiphaseMixtureThermo.H:258
Foam::multiphaseMixtureThermo::interfacePair::hash::operator()
label operator()(const interfacePair &key) const
Definition: multiphaseMixtureThermo.H:69
surfaceFields.H
Foam::surfaceFields.
Foam::multiphaseMixtureThermo::Cpv
virtual tmp< volScalarField > Cpv() const
Heat capacity at constant pressure/volume [J/kg/K].
alpha1
const volScalarField & alpha1
Definition: setRegionFluidFields.H:8
Foam::multiphaseMixtureThermo::interfacePair::interfacePair
interfacePair()
Definition: multiphaseMixtureThermo.H:78
Foam::multiphaseMixtureThermo::interfacePair::interfacePair
interfacePair(const phaseModel &alpha1, const phaseModel &alpha2)
Definition: multiphaseMixtureThermo.H:85
Foam::multiphaseMixtureThermo::isochoric
virtual bool isochoric() const
Return true if the equation of state is isochoric.
Foam::dimensionSet
Dimension set for the base types.
Definition: dimensionSet.H:65
Foam::multiphaseMixtureThermo
Definition: multiphaseMixtureThermo.H:55
Foam::baseIOdictionary::name
const word & name() const
Definition: baseIOdictionary.C:82
Foam::multiphaseMixtureThermo::nearInterface
tmp< volScalarField > nearInterface() const
Indicator of the proximity of the interface.
h
volScalarField & h
Planck constant.
Definition: setRegionSolidFields.H:33
Foam::multiphaseMixtureThermo::surfaceTensionForce
tmp< surfaceScalarField > surfaceTensionForce() const
Foam::multiphaseMixtureThermo::phi
const surfaceScalarField & phi() const
Return the volumetric flux.
Definition: multiphaseMixtureThermo.H:219
K
CGAL::Exact_predicates_exact_constructions_kernel K
Definition: CGALTriangulation3DKernel.H:58
rhoThermo.H
Foam::multiphaseMixtureThermo::kappaEff
virtual tmp< volScalarField > kappaEff(const volScalarField &alphat) const
Effective thermal diffusivity of mixture [J/m/s/K].
NotImplemented
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:436
Foam::multiphaseMixtureThermo::interfacePair::interfacePair
interfacePair(const word &alpha1Name, const word &alpha2Name)
Definition: multiphaseMixtureThermo.H:80
Foam::constant::physicoChemical::b
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
Definition: createFields.H:27
Foam::Field< scalar >
Foam::string::hash
Hashing function for string and derived string classes.
Definition: string.H:151
Foam::psiThermo
Basic thermodynamic properties based on compressibility.
Definition: psiThermo.H:55
Foam::multiphaseMixtureThermo::Cv
virtual tmp< volScalarField > Cv() const
Heat capacity at constant volume [J/kg/K].
Foam::multiphaseMixtureThermo::rho
virtual tmp< volScalarField > rho() const
Density [kg/m^3].
Foam::multiphaseMixtureThermo::he
virtual volScalarField & he()
Enthalpy/Internal energy [J/kg].
Definition: multiphaseMixtureThermo.H:251
Foam::multiphaseMixtureThermo::thermoName
virtual word thermoName() const
Return the name of the thermo physics.
Foam::dimensioned< scalar >
Foam::multiphaseMixtureThermo::TypeName
TypeName("multiphaseMixtureThermo")
Runtime type information.
Foam::multiphaseMixtureThermo::W
virtual tmp< volScalarField > W() const
Molecular weight [kg/kmol].
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:84
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::multiphaseMixtureThermo::phases
const PtrDictionary< phaseModel > & phases() const
Return the phases.
Definition: multiphaseMixtureThermo.H:201
Foam::multiphaseMixtureThermo::interfacePair::hash
Definition: multiphaseMixtureThermo.H:67
Foam::multiphaseMixtureThermo::hc
virtual tmp< volScalarField > hc() const
Chemical enthalpy [J/kg].
Foam::HashTable< scalar, interfacePair, interfacePair::hash >
psiThermo.H
Foam::multiphaseMixtureThermo::rCv
tmp< volScalarField > rCv() const
Return the phase-averaged reciprocal Cv.
Foam::Pair
An ordered pair of two objects of type <T> with first() and second() elements.
Definition: Pair.H:54
Foam::basicThermo::T
virtual const volScalarField & T() const
Temperature [K].
Definition: basicThermo.C:524
Foam::multiphaseMixtureThermo::THE
virtual tmp< scalarField > THE(const scalarField &h, const scalarField &p, const scalarField &T0, const labelList &cells) const
Temperature from enthalpy/internal energy for cell-set.
Foam::multiphaseMixtureThermo::phases
PtrDictionary< phaseModel > & phases()
Return non-const access to the phases.
Definition: multiphaseMixtureThermo.H:207
Foam::List< label >
Foam::multiphaseMixtureThermo::Cp
virtual tmp< volScalarField > Cp() const
Heat capacity at constant pressure [J/kg/K].
Foam::multiphaseMixtureThermo::alphaEff
virtual tmp< volScalarField > alphaEff(const volScalarField &alphat) const
Effective thermal diffusivity of mixture [J/m/s/K].
Foam::multiphaseMixtureThermo::multiphaseMixtureThermo
multiphaseMixtureThermo(const volVectorField &U, const surfaceScalarField &phi)
Construct from components.
Foam::multiphaseMixtureThermo::kappa
virtual tmp< volScalarField > kappa() const
Thermal diffusivity for temperature of mixture [J/m/s/K].
Foam::multiphaseMixtureThermo::gamma
virtual tmp< volScalarField > gamma() const
Gamma = Cp/Cv [].
cells
const cellShapeList & cells
Definition: gmvOutputHeader.H:3
Foam::multiphaseMixtureThermo::solve
void solve()
Solve for the mixture phase-fractions.
Foam::multiphaseMixtureThermo::incompressible
virtual bool incompressible() const
Return true if the equation of state is incompressible.
Foam::multiphaseMixtureThermo::correct
virtual void correct()
Update properties.
Foam::GeometricField< vector, fvPatchField, volMesh >
T0
scalar T0
Definition: createFields.H:22
Foam::multiphaseMixtureThermo::rhoPhi
const surfaceScalarField & rhoPhi() const
Definition: multiphaseMixtureThermo.H:224
Foam::multiphaseMixtureThermo::correctRho
void correctRho(const volScalarField &dp)
Update densities for given pressure change.