ubRhoThermo.C
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) 2025-2026 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 \*---------------------------------------------------------------------------*/
25 
26 #include "ubRhoThermo.H"
27 
28 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
29 
30 namespace Foam
31 {
33 }
34 
35 
38 
39 
40 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
41 
43 :
44  b_
45  (
46  IOobject
47  (
48  "b",
49  mesh.time().name(),
50  mesh,
51  IOobject::MUST_READ,
52  IOobject::AUTO_WRITE
53  ),
54  mesh,
55  dimless
56  ),
57  c_("c", scalar(1) - b_),
58  uThermo_(uRhoMulticomponentThermo::New(mesh, unburntPhaseName)),
59  bThermo_(bRhoMulticomponentThermo::New(mesh, burntPhaseName)),
60  ubMixtureMap_(ubMixtureMap::New(uThermo_, bThermo_)),
61  rho_("rho", 1.0/(b_/uThermo_->rho() + c_/bThermo_->rho())),
62  psi_("psi", 1.0/(b_/uThermo_->psi() + c_/bThermo_->psi())),
63  mu_("mu", b_*uThermo_->mu() + c_*bThermo_->mu()),
64  kappa_("kappa", b_*uThermo_->kappa() + c_*bThermo_->kappa()),
65  alphau_
66  (
67  phasePropertyName("alpha", unburntPhaseName), rho_*b_/uThermo_->rho()
68  ),
69  alphab_
70  (
71  phasePropertyName("alpha", burntPhaseName), rho_*c_/bThermo_->rho()
72  )
73 {
74  uThermo_->validate
75  (
77  "h"
78  );
79 
80  bThermo_->validate
81  (
83  "h"
84  );
85 
86  b_.oldTime();
87  c_.oldTime();
88 }
89 
90 
91 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
92 
94 {}
95 
96 
97 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
98 
100 {
102  return uThermo_->properties();
103 }
104 
105 
107 {
109  return uThermo_->properties();
110 }
111 
112 
114 {
115  return uThermo_->mesh();
116 }
117 
118 
120 {
121  return word::null;
122 }
123 
124 
126 {
128  return word::null;
129 }
130 
131 
133 {
135  return word::null;
136 }
137 
138 
140 {
141  uThermo_->correct();
142  bThermo_->correct();
143 
144  rho_ = 1.0/(b_/uThermo_->rho() + c_/bThermo_->rho());
145  psi_ = 1.0/(b_/uThermo_->psi() + c_/bThermo_->psi());
146  mu_ = b_*uThermo_->mu() + c_*bThermo_->mu();
147  kappa_ = b_*uThermo_->kappa() + c_*bThermo_->kappa();
148 
149  alphau_ = rho_*b_/uThermo_->rho();
150  alphab_ = rho_*c_/bThermo_->rho();
151 }
152 
153 
155 {
156  return ubMixtureMap_->prompt(uThermo_->Y());
157 }
158 
159 
161 {
162  PtrList<volScalarField>& Yu = uThermo_->Y();
163  const PtrList<volScalarField>& Yb = bThermo_->Y();
164 
165  if (Yu.size())
166  {
167  for (label n=0; n<=Yu[0].nOldTimes(); n++)
168  {
169  UPtrList<volScalarField> Yu0(Yu.size());
170  forAll(Yu0, i)
171  {
172  Yu0.set(i, &Yu[i].oldTimeRef(n));
173  }
174 
176  forAll(Yb0, i)
177  {
178  Yb0.set(i, &Yb[i].oldTime(n));
179  }
180 
181  ubMixtureMap_->reset(b_.oldTime(n), Yu0, c_.oldTime(n), Yb0);
182  }
183 
184  uThermo_->reset(b_, c_, bThermo_->he());
185  }
186  else
187  {
189  << "Reset (EGR) not supported by " << uThermo_->type()
190  << exit(FatalError);
191  }
192 }
193 
194 
196 {
198  return uThermo_->W();
199 }
200 
201 
203 {
205  return uThermo_->W(patchi);
206 }
207 
208 
210 {
211  return uThermo_->p();
212 }
213 
214 
216 {
217  return uThermo_->p();
218 }
219 
220 
222 {
223  return psi_;
224 }
225 
226 
228 {
230  return uThermo_->T();
231 }
232 
233 
235 {
237  return uThermo_->T();
238 }
239 
241 {
243  return uThermo_->he();
244 }
245 
247 {
249  return uThermo_->he();
250 }
251 
253 {
255  return uThermo_->Cp();
256 }
257 
259 {
261  return uThermo_->Cv();
262 }
263 
265 {
267  return uThermo_->Cpv();
268 }
269 
270 
272 {
273  return rho_;
274 }
275 
276 
278 {
279  return rho_.boundaryField()[patchi];
280 }
281 
282 
284 {
285  return rho_;
286 }
287 
288 
290 {
291  uThermo_->correctRho(dp);
292  bThermo_->correctRho(dp);
293  rho_ = 1.0/(b_/uThermo_->rho() + c_/bThermo_->rho());
294 }
295 
296 
298 (
299  const Foam::volScalarField& p,
300  const Foam::volScalarField& T
301 ) const
302 {
304  return uThermo_->he(p, T);
305 }
306 
307 
309 (
312 ) const
313 {
315  return uThermo_->he(p, T);
316 }
317 
318 
320 (
321  const Foam::scalarField& T,
322  const labelList& cells
323 ) const
324 {
326  return uThermo_->he(T, cells);
327 }
328 
329 
331 (
332  const Foam::scalarField& T,
333  const label patchi
334 ) const
335 {
337  return uThermo_->he(T, patchi);
338 }
339 
340 
342 (
344  const fvSource& model,
345  const Foam::volScalarField::Internal& source
346 ) const
347 {
349  return uThermo_->he(T, model, source);
350 }
351 
352 
354 (
355  const Foam::scalarField& T,
356  const fvSource& model,
357  const Foam::scalarField& source,
358  const labelUList& cells
359 ) const
360 {
362  return uThermo_->he(T, model, source, cells);
363 }
364 
365 
367 {
369  return uThermo_->hs();
370 }
371 
373 (
374  const Foam::volScalarField& p,
375  const Foam::volScalarField& T
376 ) const
377 {
379  return uThermo_->hs(p, T);
380 }
381 
382 
384 (
387 ) const
388 {
390  return uThermo_->hs(p, T);
391 }
392 
393 
395 (
396  const Foam::scalarField& T,
397  const labelList& cells
398 ) const
399 {
401  return uThermo_->hs(T, cells);
402 }
403 
404 
406 (
407  const Foam::scalarField& T,
408  const label patchi
409 ) const
410 {
412  return uThermo_->hs(T, patchi);
413 }
414 
415 
417 {
419  return uThermo_->ha();
420 }
421 
422 
424 (
425  const Foam::volScalarField& p,
426  const Foam::volScalarField& T
427 ) const
428 {
430  return uThermo_->ha(p, T);
431 }
432 
433 
435 (
438 ) const
439 {
441  return uThermo_->ha(p, T);
442 }
443 
444 
446 (
447  const Foam::scalarField& T,
448  const labelList& cells
449 ) const
450 {
452  return uThermo_->ha(T, cells);
453 }
454 
455 
457 (
458  const Foam::scalarField& T,
459  const label patchi
460 ) const
461 {
463  return uThermo_->ha(T, patchi);
464 }
465 
466 
468 (
469  const Foam::scalarField& T,
470  const label patchi
471 ) const
472 {
474  return uThermo_->Cp(T, patchi);
475 }
476 
477 
479 (
480  const Foam::scalarField& T,
481  const label patchi
482 ) const
483 {
485  return uThermo_->Cv(T, patchi);
486 }
487 
488 
490 (
491  const Foam::scalarField& T,
492  const label patchi
493 ) const
494 {
496  return uThermo_->Cpv(T, patchi);
497 }
498 
499 
501 (
502  const Foam::volScalarField& h,
503  const Foam::volScalarField& p,
504  const Foam::volScalarField& T0
505 ) const
506 {
508  return uThermo_->The(h, p, T0);
509 }
510 
511 
513 (
514  const Foam::scalarField& h,
515  const Foam::scalarField& T0,
516  const labelList& cells
517 ) const
518 {
520  return uThermo_->The(h, T0, cells);
521 }
522 
523 
525 (
526  const Foam::scalarField& h,
527  const Foam::scalarField& T0,
528  const label patchi
529 ) const
530 {
532  return uThermo_->The(h, T0, patchi);
533 }
534 
535 
537 {
538  return mu_;
539 }
540 
541 
543 {
544  return kappa_;
545 }
546 
547 
548 // ************************************************************************* //
label n
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:449
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Generic GeometricField class.
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:57
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:99
static word groupName(Name name, const word &group)
const Field0Type & oldTime() const
Return the old-time field.
Definition: OldTimeField.C:322
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: PtrList.H:75
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: UPtrList.H:66
bool set(const label) const
Is element set.
Definition: UPtrListI.H:87
label size() const
Return the number of elements in the UPtrList.
Definition: UPtrListI.H:29
Base-class for combustion fluid thermodynamic properties based on compressibility.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:98
Base class for finite volume sources.
Definition: fvSource.H:53
A class for managing temporary objects.
Definition: tmp.H:55
Base-class for combustion fluid thermodynamic properties based on compressibility.
Base class for unburnt/burnt gas composition mapping.
Definition: ubMixtureMap.H:51
virtual tmp< volScalarField > W() const
Molecular weight [kg/kmol].
Definition: ubRhoThermo.C:195
virtual const IOdictionary & properties() const
Properties dictionary.
Definition: ubRhoThermo.C:99
virtual const volScalarField & T() const
Temperature [K].
Definition: ubRhoThermo.C:227
virtual void correct()
Update properties.
Definition: ubRhoThermo.C:139
virtual tmp< volScalarField > ha() const
Absolute enthalpy [J/kg].
Definition: ubRhoThermo.C:416
static const word burntPhaseName
Definition: ubRhoThermo.H:79
virtual const volScalarField & kappa() const
Thermal conductivity of mixture [W/m/K].
Definition: ubRhoThermo.C:542
virtual const word & phaseName() const
Phase name.
Definition: ubRhoThermo.C:119
virtual word thermoName() const
Name of the thermo physics (not implemented)
Definition: ubRhoThermo.C:132
static const word unburntPhaseName
Definition: ubRhoThermo.H:78
virtual const volScalarField & Cpv() const
Heat capacity at constant pressure/volume [J/kg/K].
Definition: ubRhoThermo.C:264
virtual const volScalarField & he() const
Enthalpy/Internal energy [J/kg].
Definition: ubRhoThermo.C:240
virtual word mixtureName() const
Return the name of the mixture (not implemented)
Definition: ubRhoThermo.C:125
PtrList< volScalarField::Internal > prompt() const
Return the burnt gas prompt specie mass fractions.
Definition: ubRhoThermo.C:154
virtual tmp< volScalarField > hs() const
Sensible enthalpy [J/kg].
Definition: ubRhoThermo.C:366
virtual const fvMesh & mesh() const
Return const access to the mesh.
Definition: ubRhoThermo.C:113
virtual const volScalarField & Cv() const
Heat capacity at constant volume [J/kg/K].
Definition: ubRhoThermo.C:258
virtual tmp< volScalarField > rho() const
Density [kg/m^3].
Definition: ubRhoThermo.C:271
void reset()
Reset the mixture to an unburnt state.
Definition: ubRhoThermo.C:160
ubRhoThermo(const fvMesh &mesh)
Construct from mesh.
Definition: ubRhoThermo.C:42
virtual const volScalarField & p() const
Pressure [Pa].
Definition: ubRhoThermo.C:209
virtual const volScalarField & Cp() const
Heat capacity at constant pressure [J/kg/K].
Definition: ubRhoThermo.C:252
virtual ~ubRhoThermo()
Destructor.
Definition: ubRhoThermo.C:93
virtual void correctRho(const volScalarField &dp)
Update the density corresponding to the given pressure change.
Definition: ubRhoThermo.C:289
virtual tmp< volScalarField > The(const volScalarField &h, const volScalarField &p, const volScalarField &T0) const
Temperature from enthalpy/internal energy.
Definition: ubRhoThermo.C:501
virtual const volScalarField & psi() const
Compressibility [s^2/m^2].
Definition: ubRhoThermo.C:221
virtual const volScalarField & mu() const
Dynamic viscosity of mixture [kg/m/s].
Definition: ubRhoThermo.C:536
A class for handling words, derived from string.
Definition: word.H:63
static const word null
An empty word.
Definition: word.H:78
const scalar T0
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:381
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:334
label patchi
const cellShapeList & cells
const volScalarField & psi
rho
Definition: pEqn.H:1
const dimensionedScalar kappa
Coulomb constant: default SI units: [N.m2/C2].
const dimensionedScalar mu
Atomic mass unit.
const dimensionedScalar h
Planck constant.
const dimensionSet dimless
const dimensionSet time
Namespace for OpenFOAM.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
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
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
error FatalError
defineTypeNameAndDebug(atmosphericBoundaryLayer, 0)
tmp< DimensionedField< TypeR, GeoMesh, Field > > New(const tmp< DimensionedField< TypeR, GeoMesh, Field >> &tdf1, const word &name, const dimensionSet &dimensions)
void T(GeometricField< Type, GeoMesh, PrimitiveField1 > &gf, const GeometricField< Type, GeoMesh, PrimitiveField2 > &gf1)
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
Definition: POSIX.C:488
volScalarField & p