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  ),
56  c_("c", scalar(1) - b_),
57  uThermo_(uRhoMulticomponentThermo::New(mesh, unburntPhaseName)),
58  bThermo_(bRhoMulticomponentThermo::New(mesh, burntPhaseName)),
59  ubMixtureMap_(ubMixtureMap::New(uThermo_, bThermo_)),
60  rho_("rho", 1.0/(b_/uThermo_->rho() + c_/bThermo_->rho())),
61  psi_("psi", 1.0/(b_/uThermo_->psi() + c_/bThermo_->psi())),
62  mu_("mu", b_*uThermo_->mu() + c_*bThermo_->mu()),
63  kappa_("kappa", b_*uThermo_->kappa() + c_*bThermo_->kappa()),
64  alphau_
65  (
66  phasePropertyName("alpha", unburntPhaseName), rho_*b_/uThermo_->rho()
67  ),
68  alphab_
69  (
70  phasePropertyName("alpha", burntPhaseName), rho_*c_/bThermo_->rho()
71  )
72 {
73  uThermo_->validate
74  (
76  "h"
77  );
78 
79  bThermo_->validate
80  (
82  "h"
83  );
84 
85  b_.oldTime();
86  c_.oldTime();
87 }
88 
89 
90 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
91 
93 {}
94 
95 
96 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
97 
99 {
101  return uThermo_->properties();
102 }
103 
104 
106 {
108  return uThermo_->properties();
109 }
110 
111 
113 {
114  return uThermo_->mesh();
115 }
116 
117 
119 {
120  return word::null;
121 }
122 
123 
125 {
127  return word::null;
128 }
129 
130 
132 {
134  return word::null;
135 }
136 
137 
139 {
140  uThermo_->correct();
141  bThermo_->correct();
142 
143  rho_ = 1.0/(b_/uThermo_->rho() + c_/bThermo_->rho());
144  psi_ = 1.0/(b_/uThermo_->psi() + c_/bThermo_->psi());
145  mu_ = b_*uThermo_->mu() + c_*bThermo_->mu();
146  kappa_ = b_*uThermo_->kappa() + c_*bThermo_->kappa();
147 
148  alphau_ = rho_*b_/uThermo_->rho();
149  alphab_ = rho_*c_/bThermo_->rho();
150 }
151 
152 
154 {
155  return ubMixtureMap_->prompt(uThermo_->Y());
156 }
157 
158 
160 {
161  PtrList<volScalarField>& Yu = uThermo_->Y();
162  const PtrList<volScalarField>& Yb = bThermo_->Y();
163 
164  if (Yu.size())
165  {
166  for (label n=0; n<=Yu[0].nOldTimes(); n++)
167  {
168  UPtrList<volScalarField> Yu0(Yu.size());
169  forAll(Yu0, i)
170  {
171  Yu0.set(i, &Yu[i].oldTimeRef(n));
172  }
173 
175  forAll(Yb0, i)
176  {
177  Yb0.set(i, &Yb[i].oldTime(n));
178  }
179 
180  ubMixtureMap_->reset(b_.oldTime(n), Yu0, c_.oldTime(n), Yb0);
181  }
182 
183  uThermo_->reset(b_, c_, bThermo_->he());
184  }
185  else
186  {
188  << "Reset (EGR) not supported by " << uThermo_->type()
189  << exit(FatalError);
190  }
191 }
192 
193 
195 {
197  return uThermo_->W();
198 }
199 
200 
202 {
204  return uThermo_->W(patchi);
205 }
206 
207 
209 {
210  return uThermo_->p();
211 }
212 
213 
215 {
216  return uThermo_->p();
217 }
218 
219 
221 {
222  return psi_;
223 }
224 
225 
227 {
229  return uThermo_->T();
230 }
231 
232 
234 {
236  return uThermo_->T();
237 }
238 
240 {
242  return uThermo_->he();
243 }
244 
246 {
248  return uThermo_->he();
249 }
250 
252 {
254  return uThermo_->Cp();
255 }
256 
258 {
260  return uThermo_->Cv();
261 }
262 
264 {
266  return uThermo_->Cpv();
267 }
268 
269 
271 {
272  return rho_;
273 }
274 
275 
277 {
278  return rho_.boundaryField()[patchi];
279 }
280 
281 
283 {
284  return rho_;
285 }
286 
287 
289 {
290  uThermo_->correctRho(dp);
291  bThermo_->correctRho(dp);
292  rho_ = 1.0/(b_/uThermo_->rho() + c_/bThermo_->rho());
293 }
294 
295 
297 (
298  const Foam::volScalarField& p,
299  const Foam::volScalarField& T
300 ) const
301 {
303  return uThermo_->he(p, T);
304 }
305 
306 
308 (
311 ) const
312 {
314  return uThermo_->he(p, T);
315 }
316 
317 
319 (
320  const Foam::scalarField& T,
321  const labelList& cells
322 ) const
323 {
325  return uThermo_->he(T, cells);
326 }
327 
328 
330 (
331  const Foam::scalarField& T,
332  const label patchi
333 ) const
334 {
336  return uThermo_->he(T, patchi);
337 }
338 
339 
341 (
343  const fvSource& model,
344  const Foam::volScalarField::Internal& source
345 ) const
346 {
348  return uThermo_->he(T, model, source);
349 }
350 
351 
353 (
354  const Foam::scalarField& T,
355  const fvSource& model,
356  const Foam::scalarField& source,
357  const labelUList& cells
358 ) const
359 {
361  return uThermo_->he(T, model, source, cells);
362 }
363 
364 
366 {
368  return uThermo_->hs();
369 }
370 
372 (
373  const Foam::volScalarField& p,
374  const Foam::volScalarField& T
375 ) const
376 {
378  return uThermo_->hs(p, T);
379 }
380 
381 
383 (
386 ) const
387 {
389  return uThermo_->hs(p, T);
390 }
391 
392 
394 (
395  const Foam::scalarField& T,
396  const labelList& cells
397 ) const
398 {
400  return uThermo_->hs(T, cells);
401 }
402 
403 
405 (
406  const Foam::scalarField& T,
407  const label patchi
408 ) const
409 {
411  return uThermo_->hs(T, patchi);
412 }
413 
414 
416 {
418  return uThermo_->ha();
419 }
420 
421 
423 (
424  const Foam::volScalarField& p,
425  const Foam::volScalarField& T
426 ) const
427 {
429  return uThermo_->ha(p, T);
430 }
431 
432 
434 (
437 ) const
438 {
440  return uThermo_->ha(p, T);
441 }
442 
443 
445 (
446  const Foam::scalarField& T,
447  const labelList& cells
448 ) const
449 {
451  return uThermo_->ha(T, cells);
452 }
453 
454 
456 (
457  const Foam::scalarField& T,
458  const label patchi
459 ) const
460 {
462  return uThermo_->ha(T, patchi);
463 }
464 
465 
467 (
468  const Foam::scalarField& T,
469  const label patchi
470 ) const
471 {
473  return uThermo_->Cp(T, patchi);
474 }
475 
476 
478 (
479  const Foam::scalarField& T,
480  const label patchi
481 ) const
482 {
484  return uThermo_->Cv(T, patchi);
485 }
486 
487 
489 (
490  const Foam::scalarField& T,
491  const label patchi
492 ) const
493 {
495  return uThermo_->Cpv(T, patchi);
496 }
497 
498 
500 (
501  const Foam::volScalarField& h,
502  const Foam::volScalarField& p,
503  const Foam::volScalarField& T0
504 ) const
505 {
507  return uThermo_->The(h, p, T0);
508 }
509 
510 
512 (
513  const Foam::scalarField& h,
514  const Foam::scalarField& T0,
515  const labelList& cells
516 ) const
517 {
519  return uThermo_->The(h, T0, cells);
520 }
521 
522 
524 (
525  const Foam::scalarField& h,
526  const Foam::scalarField& T0,
527  const label patchi
528 ) const
529 {
531  return uThermo_->The(h, T0, patchi);
532 }
533 
534 
536 {
537  return mu_;
538 }
539 
540 
542 {
543  return kappa_;
544 }
545 
546 
547 // ************************************************************************* //
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:194
virtual const IOdictionary & properties() const
Properties dictionary.
Definition: ubRhoThermo.C:98
virtual const volScalarField & T() const
Temperature [K].
Definition: ubRhoThermo.C:226
virtual void correct()
Update properties.
Definition: ubRhoThermo.C:138
virtual tmp< volScalarField > ha() const
Absolute enthalpy [J/kg].
Definition: ubRhoThermo.C:415
static const word burntPhaseName
Definition: ubRhoThermo.H:79
virtual const volScalarField & kappa() const
Thermal conductivity of mixture [W/m/K].
Definition: ubRhoThermo.C:541
virtual const word & phaseName() const
Phase name.
Definition: ubRhoThermo.C:118
virtual word thermoName() const
Name of the thermo physics (not implemented)
Definition: ubRhoThermo.C:131
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:263
virtual const volScalarField & he() const
Enthalpy/Internal energy [J/kg].
Definition: ubRhoThermo.C:239
virtual word mixtureName() const
Return the name of the mixture (not implemented)
Definition: ubRhoThermo.C:124
PtrList< volScalarField::Internal > prompt() const
Return the burnt gas prompt specie mass fractions.
Definition: ubRhoThermo.C:153
virtual tmp< volScalarField > hs() const
Sensible enthalpy [J/kg].
Definition: ubRhoThermo.C:365
virtual const fvMesh & mesh() const
Return const access to the mesh.
Definition: ubRhoThermo.C:112
virtual const volScalarField & Cv() const
Heat capacity at constant volume [J/kg/K].
Definition: ubRhoThermo.C:257
virtual tmp< volScalarField > rho() const
Density [kg/m^3].
Definition: ubRhoThermo.C:270
void reset()
Reset the mixture to an unburnt state.
Definition: ubRhoThermo.C:159
ubRhoThermo(const fvMesh &mesh)
Construct from mesh.
Definition: ubRhoThermo.C:42
virtual const volScalarField & p() const
Pressure [Pa].
Definition: ubRhoThermo.C:208
virtual const volScalarField & Cp() const
Heat capacity at constant pressure [J/kg/K].
Definition: ubRhoThermo.C:251
virtual ~ubRhoThermo()
Destructor.
Definition: ubRhoThermo.C:92
virtual void correctRho(const volScalarField &dp)
Update the density corresponding to the given pressure change.
Definition: ubRhoThermo.C:288
virtual tmp< volScalarField > The(const volScalarField &h, const volScalarField &p, const volScalarField &T0) const
Temperature from enthalpy/internal energy.
Definition: ubRhoThermo.C:500
virtual const volScalarField & psi() const
Compressibility [s^2/m^2].
Definition: ubRhoThermo.C:220
virtual const volScalarField & mu() const
Dynamic viscosity of mixture [kg/m/s].
Definition: ubRhoThermo.C:535
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 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