AnisothermalPhaseModel.C
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) 2015-2021 OpenFOAM Foundation
9  Copyright (C) 2020-2021 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 \*---------------------------------------------------------------------------*/
28 
29 #include "AnisothermalPhaseModel.H"
30 #include "phaseSystem.H"
31 
32 // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
33 
34 template<class BasePhaseModel>
37 (
38  const tmp<volScalarField>& pressureWork
39 ) const
40 {
41  const volScalarField& alpha = *this;
42 
43  const scalar pressureWorkAlphaLimit =
44  this->thermo_->getOrDefault("pressureWorkAlphaLimit", scalar(0));
45 
46  if (pressureWorkAlphaLimit > 0)
47  {
48  return
49  (
50  max(alpha - pressureWorkAlphaLimit, scalar(0))
51  /max(alpha - pressureWorkAlphaLimit, pressureWorkAlphaLimit)
52  )*pressureWork;
53  }
54 
55  return pressureWork;
56 }
57 
58 
59 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
60 
61 template<class BasePhaseModel>
63 (
64  const phaseSystem& fluid,
65  const word& phaseName,
66  const label index
67 )
68 :
69  BasePhaseModel(fluid, phaseName, index)
70 {}
71 
72 
73 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
74 
75 template<class BasePhaseModel>
77 {
79 
80  this->thermo_->correct();
81 }
82 
83 
84 template<class BasePhaseModel>
86 {
87  return false;
88 }
89 
90 
91 template<class BasePhaseModel>
94 {
95  const volScalarField& alpha = *this;
96  const volScalarField& rho = this->rho();
97 
98  const tmp<volVectorField> tU(this->U());
99  const volVectorField& U(tU());
100 
103 
104  const tmp<surfaceScalarField> talphaRhoPhi(this->alphaRhoPhi());
105  const surfaceScalarField& alphaRhoPhi(talphaRhoPhi());
106 
107  const tmp<volScalarField> tcontErr(this->continuityError());
108  const volScalarField& contErr(tcontErr());
109 
110  tmp<volScalarField> tK(this->K());
111  const volScalarField& K(tK());
112 
113  volScalarField& he = this->thermo_->he();
114 
115  tmp<fvScalarMatrix> tEEqn
116  (
117  fvm::ddt(alpha, rho, he)
118  + fvm::div(alphaRhoPhi, he)
119  - fvm::Sp(contErr, he)
120 
121  + fvc::ddt(alpha, rho, K) + fvc::div(alphaRhoPhi, K)
122  - contErr*K
123 
125  (
127  *fvc::interpolate(this->alphaEff()),
128  he
129  )
130  ==
131  alpha*this->Qdot()
132  );
133 
134  // Add the appropriate pressure-work term
135  if (he.name() == this->thermo_->phasePropertyName("e"))
136  {
137  tEEqn.ref() += filterPressureWork
138  (
139  fvc::div(fvc::absolute(alphaPhi, alpha, U), this->thermo().p())
140  + (fvc::ddt(alpha) - contErr/rho)*this->thermo().p()
141  );
142  }
143  else if (this->thermo_->dpdt())
144  {
145  tEEqn.ref() -= filterPressureWork(alpha*this->fluid().dpdt());
146  }
147 
148  return tEEqn;
149 }
150 
151 
152 // ************************************************************************* //
contErr
volScalarField::Internal contErr((fvc::ddt(rho)+fvc::div(rhoPhi) -(fvOptions(alpha1, mixture.thermo1().rho())&rho1) -(fvOptions(alpha2, mixture.thermo2().rho())&rho2))())
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::AnisothermalPhaseModel::AnisothermalPhaseModel
AnisothermalPhaseModel(const phaseSystem &fluid, const word &phaseName, const label index)
Construct from phase system and phase name.
Definition: AnisothermalPhaseModel.C:63
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::constant::atomic::alpha
const dimensionedScalar alpha
Fine-structure constant: default SI units: [].
Definition: readThermalProperties.H:212
thermo
psiReactionThermo & thermo
Definition: createFields.H:28
Sp
zeroField Sp
Definition: alphaSuSp.H:2
Foam::AnisothermalPhaseModel::correctThermo
virtual void correctThermo()
Correct the thermodynamics.
Definition: AnisothermalPhaseModel.C:76
fluid
twoPhaseSystem & fluid
Definition: setRegionFluidFields.H:3
Foam::fac::div
tmp< GeometricField< Type, faPatchField, areaMesh > > div(const GeometricField< Type, faePatchField, edgeMesh > &ssf)
Definition: facDiv.C:50
rho
rho
Definition: readInitialConditions.H:88
K
CGAL::Exact_predicates_exact_constructions_kernel K
Definition: CGALTriangulation3DKernel.H:58
Foam::tmp::ref
T & ref() const
Definition: tmpI.H:227
AnisothermalPhaseModel.H
alphaPhi
surfaceScalarField alphaPhi(phi.name()+alpha1.name(), fvc::flux(phi, alpha1, alphaScheme))
Foam::volScalarField
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:57
Foam::AnisothermalPhaseModel::heEqn
virtual tmp< fvScalarMatrix > heEqn()
Return the enthalpy equation.
Definition: AnisothermalPhaseModel.C:93
Foam::max
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:47
Qdot
scalar Qdot
Definition: solveChemistry.H:2
Foam::AnisothermalPhaseModel
Class which represents a phase for which the temperature (strictly energy) varies....
Definition: AnisothermalPhaseModel.H:53
correctThermo
mixture correctThermo()
Foam::dimensioned::getOrDefault
static dimensioned< Type > getOrDefault(const word &name, const dictionary &dict, const dimensionSet &dims=dimless, const Type &deflt=Type(Zero))
Construct dimensioned from dictionary, with default value.
Definition: dimensionedType.C:348
U
U
Definition: pEqn.H:72
he
volScalarField & he
Definition: YEEqn.H:52
talphaPhi
tmp< surfaceScalarField > talphaPhi
Definition: alphaEqn.H:13
Foam::fac::ddt
tmp< GeometricField< Type, faPatchField, areaMesh > > ddt(const dimensioned< Type > dt, const faMesh &mesh)
Definition: facDdt.C:47
alphaEff
volScalarField alphaEff("alphaEff", turbulence->nu()/Pr+alphat)
Foam::AnisothermalPhaseModel::isothermal
virtual bool isothermal() const
Return whether the phase is isothermal.
Definition: AnisothermalPhaseModel.C:85
Foam::phaseSystem
Class to represent a system of phases and model interfacial transfers between them.
Definition: phaseSystem.H:66
dpdt
volScalarField & dpdt
Definition: setRegionFluidFields.H:32
Foam::fac::laplacian
tmp< GeometricField< Type, faPatchField, areaMesh > > laplacian(const GeometricField< Type, faPatchField, areaMesh > &vf, const word &name)
Definition: facLaplacian.C:47
Foam::GeometricField< scalar, fvPatchField, volMesh >
Foam::fac::interpolate
static tmp< GeometricField< Type, faePatchField, edgeMesh > > interpolate(const GeometricField< Type, faPatchField, areaMesh > &tvf, const edgeScalarField &faceFlux, Istream &schemeData)
Interpolate field onto faces using scheme given by Istream.
Foam::fvc::absolute
tmp< surfaceScalarField > absolute(const tmp< surfaceScalarField > &tphi, const volVectorField &U)
Return the given relative flux in absolute form.
Definition: fvcMeshPhi.C:190