FluidLagrangianThermo.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 "FluidLagrangianThermo.H"
27 
28 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
29 
30 template<class BaseThermo>
32 {}
33 
34 
35 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
36 
37 template<class BaseThermo>
39 (
40  const LagrangianSubMesh& subMesh
41 )
42 {
43  if (BaseThermo::debug) InfoInFunction << endl;
44 
45  const SubField<scalar> e = subMesh.sub(this->e_.primitiveField());
46 
47  SubField<scalar> p = subMesh.sub(this->p_.primitiveFieldRef());
48  SubField<scalar> T = subMesh.sub(this->T_.primitiveFieldRef());
49  SubField<scalar> psi = subMesh.sub(this->psi_.primitiveFieldRef());
50  SubField<scalar> rho = subMesh.sub(this->rho_.primitiveFieldRef());
51  SubField<scalar> Cv = subMesh.sub(this->Cv_.primitiveFieldRef());
52  SubField<scalar> kappa = subMesh.sub(this->kappa_.primitiveFieldRef());
53  SubField<scalar> mu = subMesh.sub(this->mu_.primitiveFieldRef());
54 
55  auto Yslicer = this->Yslicer();
56 
57  forAll(T, subi)
58  {
59  const label i = subMesh.start() + subi;
60 
61  auto composition = this->elementComposition(Yslicer, i);
62 
63  const typename BaseThermo::mixtureType::thermoMixtureType&
64  thermoMixture = this->thermoMixture(composition);
65 
66  const typename BaseThermo::mixtureType::transportMixtureType&
67  transportMixture =
68  this->transportMixture(composition, thermoMixture);
69 
70  T[subi] = thermoMixture.Tes(e[subi], p[subi], T[subi]);
71 
72  psi[subi] = thermoMixture.psi(p[subi], T[subi]);
73  rho[subi] = thermoMixture.rho(p[subi], T[subi]);
74  Cv[subi] = thermoMixture.Cv(p[subi], T[subi]);
75 
76  kappa[subi] = transportMixture.kappa(p[subi], T[subi]);
77  mu[subi] = transportMixture.mu(p[subi], T[subi]);
78  }
79 
80  if (BaseThermo::debug) Info<< " Finished" << endl;
81 }
82 
83 
84 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
85 
86 template<class BaseThermo>
89 (
91  const LagrangianInjection& injection
92 ) const
93 {
94  return
95  this->LagrangianInjectionProperty
96  (
97  injection,
98  T.mesh(),
99  "psi",
101  &BaseThermo::mixtureType::thermoMixture,
103  this->p(injection, T.mesh())(),
104  T
105  );
106 }
107 
108 
109 template<class BaseThermo>
112 (
114  const LagrangianInjection& injection
115 ) const
116 {
117  typedef decltype(this->Yslicer(injection, T.mesh())) YslicerType;
118 
119  typedef
120  decltype(this->injectionElementComposition(YslicerType(), -1))
121  compositionType;
122 
123  const typename BaseThermo::mixtureType::transportMixtureType&
124  (BaseThermo::mixtureType::*mixture)(const compositionType&) const =
125  &BaseThermo::mixtureType::transportMixture;
126 
127  return
128  this->LagrangianInjectionProperty
129  (
130  injection,
131  T.mesh(),
132  "mu",
134  mixture,
136  this->p(injection, T.mesh())(),
137  T
138  );
139 }
140 
141 
142 // ************************************************************************* //
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
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
virtual tmp< LagrangianSubScalarField > psi(const LagrangianSubScalarField &T, const LagrangianInjection &) const
Compressibility for an injection [m^2/s^2].
virtual tmp< LagrangianSubScalarField > mu(const LagrangianSubScalarField &T, const LagrangianInjection &) const
Dynamic viscosity for an injection [W/m/K].
virtual ~FluidLagrangianThermo()
Destructor.
virtual void correct(const LagrangianSubMesh &)
Update state.
Base class for Lagrangian injections. Minimal wrapper over LagrangianSource. Implements some utility ...
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.
Pre-declare related SubField type.
Definition: SubField.H:63
A class for managing temporary objects.
Definition: tmp.H:55
const volScalarField & psi
rho
Definition: pEqn.H:1
#define InfoInFunction
Report an information message using Foam::Info.
const dimensionedScalar e
Elementary charge.
const dimensionedScalar kappa
Coulomb constant: default SI units: [N.m2/C2].
const dimensionedScalar mu
Atomic mass unit.
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 & dimDynamicViscosity
Definition: dimensions.C:173
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:288
messageStream Info
const dimensionSet & dimDensity
Definition: dimensions.C:158
const dimensionSet & dimPressure
Definition: dimensions.C:163
void T(GeometricField< Type, GeoMesh, PrimitiveField1 > &gf, const GeometricField< Type, GeoMesh, PrimitiveField2 > &gf1)
volScalarField & p