BasicLagrangianThermo.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) 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 "BasicLagrangianThermo.H"
28 
29 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
30 
31 template<class MixtureType, class BasicThermoType>
32 template<class Mixture, class Method, class ... Args>
36 (
37  const word& psiName,
38  const dimensionSet& psiDim,
39  Mixture mixture,
40  Method psiMethod,
41  const Args& ... args
42 ) const
43 {
45  (
47  (
48  IOobject::groupName(psiName, this->group()),
49  this->mesh(),
50  psiDim
51  )
52  );
54 
55  auto Yslicer = this->Yslicer();
56 
57  forAll(psi, i)
58  {
59  auto composition = this->elementComposition(Yslicer, i);
60 
61  psi[i] = ((this->*mixture)(composition).*psiMethod)(args[i] ...);
62  }
63 
64  return tPsi;
65 }
66 
67 
68 template<class MixtureType, class BasicThermoType>
69 template<class Mixture, class Method, class ... Args>
73 (
74  const LagrangianSubMesh& subMesh,
75  const word& psiName,
76  const dimensionSet& psiDim,
77  Mixture mixture,
78  Method psiMethod,
79  const Args& ... args
80 ) const
81 {
83  (
85  (
86  IOobject::groupName(subMesh.sub(psiName), this->group()),
87  subMesh,
88  psiDim
89  )
90  );
92 
93  auto Yslicer = this->Yslicer();
94 
95  forAll(psi, subi)
96  {
97  const label i = subMesh.start() + subi;
98 
99  auto composition = this->elementComposition(Yslicer, i);
100 
101  psi[subi] = ((this->*mixture)(composition).*psiMethod)(args[i] ...);
102  }
103 
104  return tPsi;
105 }
106 
107 
108 template<class MixtureType, class BasicThermoType>
109 template<class Mixture, class Method, class ... Args>
113 (
114  const LagrangianInjection& injection,
115  const LagrangianSubMesh& subMesh,
116  const word& psiName,
117  const dimensionSet& psiDim,
118  Mixture mixture,
119  Method psiMethod,
120  const Args& ... args
121 ) const
122 {
124  (
126  (
127  IOobject::groupName(subMesh.sub(psiName), this->group()),
128  subMesh,
129  psiDim
130  )
131  );
132  LagrangianSubScalarField& psi = tPsi.ref();
133 
134  auto Yslicer = this->Yslicer(injection, subMesh);
135 
136  forAll(psi, subi)
137  {
138  auto composition = this->injectionElementComposition(Yslicer, subi);
139 
140  psi[subi] = ((this->*mixture)(composition).*psiMethod)(args[subi] ...);
141  }
142 
143  return tPsi;
144 }
145 
146 
147 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
148 
149 template<class MixtureType, class BasicThermoType>
151 (
152  const LagrangianMesh& mesh,
153  const word& phaseName
154 )
155 :
156  physicalProperties(mesh, phaseName),
157  MixtureType(properties()),
158  BasicThermoType
159  (
160  properties(),
161  static_cast<const MixtureType&>(*this),
162  mesh,
163  phaseName
164  ),
165  e_
166  (
167  IOobject
168  (
169  IOobject::groupName
170  (
171  MixtureType::thermoType::heName(),
172  phaseName
173  ),
174  mesh.time().name(),
175  mesh,
176  IOobject::NO_READ,
177  IOobject::NO_WRITE
178  ),
179  LagrangianInternalScalarFieldProperty
180  (
181  "e",
183  &MixtureType::thermoMixture,
184  &MixtureType::thermoMixtureType::es,
185  this->p_,
186  this->T_
187  )(),
188  this->eBoundaryTypes(),
189  this->eBoundaryBaseTypes(),
190  this->template sourcesTypes<energyLagrangianScalarFieldSource>
191  (
192  this->T_
193  ),
194  this->T_.sources().errorLocation()
195  )
196 {}
197 
198 
199 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
200 
201 template<class MixtureType, class BasicThermoType>
204 {}
205 
206 
207 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
208 
209 template<class MixtureType, class BasicThermoType>
210 const Foam::IOdictionary&
212 {
213  return *this;
214 }
215 
216 
217 template<class MixtureType, class BasicThermoType>
220 {
221  return *this;
222 }
223 
224 
225 template<class MixtureType, class BasicThermoType>
228 {
230 }
231 
232 
233 template<class MixtureType, class BasicThermoType>
236 (
237  const LagrangianSubMesh& subMesh
238 ) const
239 {
240  return
241  LagrangianSubScalarFieldProperty
242  (
243  subMesh,
244  "W",
246  &MixtureType::thermoMixture,
248  );
249 }
250 
251 
252 template<class MixtureType, class BasicThermoType>
255 (
257  const LagrangianInjection& injection
258 ) const
259 {
260  return
261  LagrangianInjectionProperty
262  (
263  injection,
264  T.mesh(),
265  "rho",
266  dimDensity,
267  &MixtureType::thermoMixture,
269  this->p(injection, T.mesh())(),
270  T
271  );
272 }
273 
274 
275 template<class MixtureType, class BasicThermoType>
278 {
279  return e_;
280 }
281 
282 
283 template<class MixtureType, class BasicThermoType>
286 {
287  return e_;
288 }
289 
290 
291 template<class MixtureType, class BasicThermoType>
294 (
296  const LagrangianInjection& injection
297 ) const
298 {
299  return
300  LagrangianInjectionProperty
301  (
302  injection,
303  T.mesh(),
304  "e",
306  &MixtureType::thermoMixture,
308  this->p(injection, T.mesh())(),
309  T
310  );
311 }
312 
313 
314 template<class MixtureType, class BasicThermoType>
317 (
319  const LagrangianInjection& injection
320 ) const
321 {
322  return
323  LagrangianInjectionProperty
324  (
325  injection,
326  T.mesh(),
327  "Cv",
329  &MixtureType::thermoMixture,
331  this->p(injection, T.mesh())(),
332  T
333  );
334 }
335 
336 
337 template<class MixtureType, class BasicThermoType>
340 (
341  const LagrangianSubMesh& subMesh
342 ) const
343 {
344  return
345  LagrangianSubScalarFieldProperty
346  (
347  subMesh,
348  "Cp",
350  &MixtureType::thermoMixture,
352  this->p(subMesh)(),
353  subMesh.sub(this->T_)()
354  );
355 }
356 
357 
358 template<class MixtureType, class BasicThermoType>
361 (
362  const LagrangianSubMesh& subMesh
363 ) const
364 {
365  return
366  LagrangianSubScalarFieldProperty
367  (
368  subMesh,
369  "alphav",
371  &MixtureType::thermoMixture,
372  &MixtureType::thermoMixtureType::alphav,
373  this->p(subMesh)(),
374  subMesh.sub(this->T_)()
375  );
376 }
377 
378 
379 template<class MixtureType, class BasicThermoType>
382 (
384  const LagrangianInjection& injection
385 ) const
386 {
387  typedef decltype(this->Yslicer(injection, T.mesh())) YslicerType;
388 
389  typedef
390  decltype(this->injectionElementComposition(YslicerType(), -1))
391  compositionType;
392 
393  const typename MixtureType::transportMixtureType&
394  (MixtureType::*mixture)(const compositionType&) const =
395  &MixtureType::transportMixture;
396 
397  return
398  LagrangianInjectionProperty
399  (
400  injection,
401  T.mesh(),
402  "kappa",
404  mixture,
406  this->p(injection, T.mesh())(),
407  T
408  );
409 }
410 
411 
412 template<class MixtureType, class BasicThermoType>
414 {
416  {
417  MixtureType::read(*this);
418  BasicThermoType::read(*this);
419  return true;
420  }
421  else
422  {
423  return false;
424  }
425 }
426 
427 
428 // ************************************************************************* //
scalar Cp(const scalar p, const scalar T) const
Definition: EtoHthermo.H:2
scalar es(const scalar p, const scalar T) const
Definition: HtoEthermo.H:11
scalar Cv(const scalar p, const scalar T) const
Definition: HtoEthermo.H:2
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:449
virtual const IOdictionary & properties() const
Access the properties dictionary.
virtual tmp< LagrangianSubScalarField > rho(const LagrangianSubScalarField &T, const LagrangianInjection &) const
Density for an injection [kg/m^3].
virtual tmp< LagrangianSubScalarField > W(const LagrangianSubMesh &) const
Molecular weight for a sub-mesh [kg/kmol].
virtual tmp< LagrangianSubScalarField > Cp(const LagrangianSubMesh &) const
Heat capacity at constant pressure for a sub-mesh [J/kg/K].
BasicLagrangianThermo(const LagrangianMesh &, const word &phaseName)
Construct from mesh and phase name.
virtual const LagrangianScalarDynamicField & e() const
Internal energy [J/kg].
tmp< LagrangianSubScalarField > LagrangianInjectionProperty(const LagrangianInjection &injection, const LagrangianSubMesh &subMesh, const word &psiName, const dimensionSet &psiDim, Mixture mixture, Method psiMethod, const Args &... args) const
Return a LagrangianSubScalarField of the given property.
tmp< LagrangianSubScalarField > LagrangianSubScalarFieldProperty(const LagrangianSubMesh &subMesh, const word &psiName, const dimensionSet &psiDim, Mixture mixture, Method psiMethod, const Args &... args) const
Return a LagrangianSubScalarField of the given property.
tmp< LagrangianInternalScalarField > LagrangianInternalScalarFieldProperty(const word &psiName, const dimensionSet &psiDim, Mixture mixture, Method psiMethod, const Args &... args) const
Return a LagrangianInternalScalarField of the given property.
virtual word thermoName() const
Return the full name of the thermodynamic model.
virtual tmp< LagrangianSubScalarField > kappa(const LagrangianSubScalarField &T, const LagrangianInjection &) const
Thermal conductivity for an injection [W/m/K].
virtual tmp< LagrangianSubScalarField > alphav(const LagrangianSubMesh &) const
Coefficient of thermal expansion for a sub-mesh [1/K].
virtual tmp< LagrangianSubScalarField > Cv(const LagrangianSubScalarField &T, const LagrangianInjection &) const
Heat capacity at constant volume for an injection [J/kg/K].
virtual ~BasicLagrangianThermo()
Destructor.
virtual bool read()
Read thermophysical properties dictionary.
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
Base class for Lagrangian injections. Minimal wrapper over LagrangianSource. Implements some utility ...
Class containing Lagrangian geometry and topology.
Mesh that relates to a sub-section of a Lagrangian mesh. This is used to construct fields that relate...
word sub(const word &fieldName) const
Return the name of a field corresponding to this sub-mesh.
label start() const
Return start.
Dimension set for the base types.
Definition: dimensionSet.H:125
Source condition for energy. Applied to the energy model automatically by the Lagrangian thermodynami...
A base class for physical properties.
virtual bool read()
Read physicalProperties dictionary.
A class for managing temporary objects.
Definition: tmp.H:55
T & ref() const
Return non-const reference or generate a fatal error.
Definition: tmpI.H:197
A class for handling words, derived from string.
Definition: word.H:63
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
const volScalarField & psi
rho
Definition: pEqn.H:1
void read(Istream &, label &, const dictionary &)
In-place read with dictionary lookup.
const char *const group
Group name for atomic constants.
const dimensionedScalar kappa
Coulomb constant: default SI units: [N.m2/C2].
const dimensionSet time
const dimensionSet & dimMoles
Definition: dimensions.C:144
const dimensionSet & dimThermalConductivity
Definition: dimensions.C:175
const dimensionSet & dimless
Definition: dimensions.C:138
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
const dimensionSet & dimMass
Definition: dimensions.C:140
String typeName(const std::type_info &info)
Return the un-mangled name given the standard type info.
const dimensionSet & dimSpecificHeatCapacity
Definition: dimensions.C:169
const dimensionSet & dimDensity
Definition: dimensions.C:158
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
const dimensionSet & dimEnergy
Definition: dimensions.C:160
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)
const dimensionSet & dimTemperature
Definition: dimensions.C:143
Foam::argList args(argc, argv)
volScalarField & p
const scalarList W(::W(thermo))