phaseModel.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) 2017-2022 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "phaseModel.H"
29 #include "multiphaseInterSystem.H"
30 
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
35 namespace multiphaseInter
36 {
37  defineTypeNameAndDebug(phaseModel, 0);
39 }
40 }
41 
42 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
43 
45 (
47  const word& phaseName
48 )
49 :
51  (
52  IOobject
53  (
54  IOobject::groupName("alpha", phaseName),
55  fluid.mesh().time().timeName(),
56  fluid.mesh(),
57  IOobject::READ_IF_PRESENT,
58  IOobject::AUTO_WRITE
59  ),
60  fluid.mesh(),
62  ),
63  fluid_(fluid),
64  name_(phaseName)
65 {}
66 
67 
68 // * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
69 
72 (
74  const word& phaseName
75 )
76 {
77  const dictionary& dict = fluid.subDict(phaseName);
78 
79  const word modelType(dict.get<word>("type"));
80 
81  Info<< "Selecting phaseModel for "
82  << phaseName << ": " << modelType << endl;
83 
84  auto* ctorPtr = multiphaseInterSystemConstructorTable(modelType);
85 
86  if (!ctorPtr)
87  {
89  (
90  dict,
91  "phaseModel",
92  modelType,
93  *multiphaseInterSystemConstructorTablePtr_
94  ) << exit(FatalIOError);
95  }
96 
97  return ctorPtr(fluid, phaseName);
98 }
99 
100 
101 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
102 
105 {
106  return fluid_;
107 }
108 
111 {
112  thermo().correct();
113 }
114 
117 {
118  // do nothing
119 }
120 
121 
123 {
124  return thermo().rho();
125 }
126 
127 
129 Foam::multiphaseInter::phaseModel::rho(const label patchI) const
130 {
131  return thermo().rho(patchI);
132 }
133 
136 {
137  return thermo().hc();
138 }
139 
140 
142 {
143  return thermo().Cp();
144 }
145 
146 
148 (
149  const scalarField& p,
150  const scalarField& T,
151  const label patchI
152 ) const
153 {
154  return (thermo().Cp(p, T, patchI));
155 }
156 
157 
159 {
160  return thermo().Cv();
161 }
162 
163 
165 (
166  const scalarField& p,
167  const scalarField& T,
168  const label patchI
169 ) const
170 {
171  return thermo().Cv(p, T, patchI);
172 }
173 
174 
176 {
177  return thermo().gamma();
178 }
179 
180 
182 (
183  const scalarField& p,
184  const scalarField& T,
185  const label patchI
186 ) const
187 {
188  return thermo().gamma(p, T, patchI);
189 }
190 
191 
193 {
194  return thermo().Cpv();
195 }
196 
197 
199 (
200  const scalarField& p,
201  const scalarField& T,
202  const label patchI
203 ) const
204 {
205  return thermo().Cpv(p, T, patchI);
206 }
207 
208 
210 {
211  return thermo().CpByCpv();
212 }
213 
214 
216 (
217  const scalarField& p,
218  const scalarField& T,
219  const label patchI
220 ) const
221 {
222  return thermo().CpByCpv(p, T, patchI);
223 }
224 
225 
227 {
228  return thermo().alpha();
229 }
230 
231 
233 Foam::multiphaseInter::phaseModel::alpha(const label patchI) const
234 {
235  return thermo().alpha(patchI);
236 }
237 
238 
240 {
241  return thermo().kappa();
242 }
243 
244 
247 {
248  return thermo().kappa(patchI);
249 }
250 
251 
254 {
255  return thermo().alphahe();
256 }
257 
258 
261 {
262  return thermo().alphahe(patchI);
263 }
264 
265 
267 (
268  const volScalarField& kappat
269 ) const
270 {
272  kappaEff.ref().rename("kappaEff" + name_);
273  return kappaEff;
274 }
275 
276 
278 (
279  const scalarField& kappat,
280  const label patchI
281 ) const
282 {
283  return (kappa(patchI) + kappat);
284 }
285 
286 
288 (
289  const volScalarField& alphat
290 ) const
291 {
292  return (thermo().alpha() + alphat);
293 }
294 
295 
297 (
298  const scalarField& alphat,
299  const label patchI
300 ) const
301 {
302  return (thermo().alpha(patchI) + alphat);
303 }
304 
305 
307 {
308  return thermo().mu();
309 }
310 
311 
313 Foam::multiphaseInter::phaseModel::mu(const label patchi) const
314 {
315  return thermo().mu(patchi);
316 }
317 
318 
320 {
321  return thermo().nu();
322 }
323 
324 
326 Foam::multiphaseInter::phaseModel::nu(const label patchi) const
327 {
328  return thermo().nu(patchi);
329 }
330 
331 
333 {
334  return true;
335 }
336 
337 
338 // ************************************************************************* //
twoPhaseSystem & fluid
dictionary dict
phaseModel(const multiphaseInterSystem &fluid, const word &phaseName)
Construct from multiphaseInterSystem and phaseName.
Definition: phaseModel.C:38
const volScalarField & alpha() const
Thermal diffusivity for enthalpy of mixture [kg/m/s].
Definition: phaseModel.C:219
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:125
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
tmp< volScalarField > kappaEff(const volScalarField &) const
Effective thermal diffusivity for temperature of phase [J/m/s/K].
Definition: phaseModel.C:260
static autoPtr< phaseModel > New(const multiphaseInterSystem &fluid, const word &phaseName)
Definition: phaseModel.C:65
tmp< volScalarField > alphaEff(const volScalarField &alphat) const
Effective thermal diffusivity of phase [kg/m/s].
Definition: phaseModel.C:281
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:531
const dimensionSet dimless
Dimensionless.
tmp< volScalarField > Cv() const
Return Cv of the phase.
Definition: phaseModel.C:151
kappaEff
Definition: TEqn.H:10
const dimensionedScalar kappa
Coulomb constant: default SI units: [N.m2/C2].
const dictionary & subDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary.
Definition: dictionary.C:441
virtual tmp< volScalarField > mu() const
Return the mixture dymanic viscosity.
Definition: phaseModel.C:299
psiReactionThermo & thermo
Definition: createFields.H:28
word timeName
Definition: getTimeIndex.H:3
tmp< volScalarField > hc() const
Chemical enthalpy for phase [J/kg].
Definition: phaseModel.C:128
tmp< volScalarField > gamma() const
Gamma = Cp/Cv of phase[].
Definition: phaseModel.C:168
dynamicFvMesh & mesh
A class for handling words, derived from Foam::string.
Definition: word.H:63
tmp< volScalarField > Cpv() const
Heat capacity at constant pressure/volume for phase [J/kg/K].
Definition: phaseModel.C:185
virtual void correctTurbulence()
Correct the turbulence.
Definition: phaseModel.C:109
tmp< volScalarField > Cp() const
Return phase Cp.
Definition: phaseModel.C:134
virtual void correct()
Correct phase thermo.
Definition: phaseModel.C:103
defineTypeNameAndDebug(interfaceCompositionModel, 0)
const volScalarField & Cp
Definition: EEqn.H:7
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
tmp< volScalarField > rho() const
Return the phase density.
Definition: phaseModel.C:115
const multiphaseInterSystem & fluid() const
Return the system to which this phase belongs.
Definition: phaseModel.C:97
tmp< volScalarField > alphahe() const
Thermal diffusivity for energy of mixture [kg/m/s].
Definition: phaseModel.C:246
virtual bool read()
Read phase properties dictionary.
Definition: phaseModel.C:325
virtual tmp< volScalarField > nu() const
Return the mixture kinematic viscosity.
Definition: phaseModel.C:312
messageStream Info
Information stream (stdout output on master, null elsewhere)
defineRunTimeSelectionTable(interfaceCompositionModel, dictionary)
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
tmp< volScalarField > CpByCpv() const
Heat capacity ratio for phase [].
Definition: phaseModel.C:202
volScalarField & p
A class for managing temporary objects.
Definition: HashPtrTable.H:50
const dimensionedScalar alpha
Fine-structure constant: default SI units: [].
Defines the attributes of an object for which implicit objectRegistry management is supported...
Definition: IOobject.H:172
#define FatalIOErrorInLookup(ios, lookupTag, lookupName, lookupTable)
Report an error message using Foam::FatalIOError.
Definition: error.H:635
Namespace for OpenFOAM.
tmp< volScalarField > kappa() const
Thermal diffusivity for temperature of phase [J/m/s/K].
Definition: phaseModel.C:232
IOerror FatalIOError
Error stream (stdout output on all processes), with additional &#39;FOAM FATAL IO ERROR&#39; header text and ...
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:127