coupledToThermalFluid.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 "coupledToThermalFluid.H"
27 #include "basicThermo.H"
28 #include "multicomponentThermo.H"
29 #include "fluidThermo.H"
32 
33 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
34 
35 namespace Foam
36 {
37 namespace clouds
38 {
40 }
41 }
42 
43 
44 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
45 
47 (
48  const cloud& c,
49  const carried& carriedCloud,
50  const thermal& thermalCloud
51 )
52 :
53  coupledToFluid(c, carriedCloud),
54  mesh_(c.mesh()),
55  thermoc_
56  (
57  mesh_.poly().foundObject<fluidThermo>
58  (
59  IOobject::groupName
60  (
62  carriedCloud.carrierPhaseName()
63  )
64  )
65  ? mesh_.poly().lookupObject<fluidThermo>
66  (
67  IOobject::groupName
68  (
70  carriedCloud.carrierPhaseName()
71  )
72  )
73  : NullObjectRef<const fluidThermo>()
74  ),
75  multicomponentThermoc_
76  (
77  refCastNull<const fluidMulticomponentThermo>(thermoc_)
78  ),
79  thermocPhase_
80  (
81  carriedCloud.hasPhase()
82  ? mesh_.poly().lookupObject<basicThermo>
83  (
84  IOobject::groupName
85  (
87  carriedCloud.phaseName()
88  )
89  )
91  ),
92  multicomponentThermocPhase_
93  (
94  refCastNull<const multicomponentThermo>(thermocPhase_)
95  ),
96  pc
97  (
98  carriedCloud.carrierField<scalar>
99  (
100  notNull(thermoc_)
101  ? thermoc_.p()
102  : mesh_.poly().lookupObject<volScalarField>("p")
103  )
104  ),
105  Tc
106  (
107  carriedCloud.carrierField<scalar>
108  (
109  notNull(thermoc_)
110  ? thermoc_.T()
111  : mesh_.poly().lookupObject<volScalarField>("T")
112  )
113  ),
114  hec
115  (
116  notNull(thermoc_)
117  ? carriedCloud.carrierField<scalar>(thermoc_.he())
118  : carriedCloud.noCarrierField<scalar>("he", "enthalpy/energy", false)
119  ),
120  hecPhase
121  (
122  carriedCloud.hasPhase()
123  ? carriedCloud.carrierField<scalar>(thermocPhase_.he())
124  : carriedCloud.noCarrierField<scalar>("he", "enthalpy/energy", true)
125  ),
126  Cpvc
127  (
128  notNull(thermoc_)
129  ? carriedCloud.carrierField<scalar>(thermoc_.Cpv())
130  : carriedCloud.noCarrierField<scalar>("Cpv", "specific heat", false)
131  ),
132  Cpc
133  (
134  isNull(thermoc_) || &thermoc_.Cp() == &thermoc_.Cpv()
135  ? Cpvc
136  : carriedCloud.carrierField<scalar>(thermoc_.Cp())
137  ),
138  Cvc
139  (
140  isNull(thermoc_) || &thermoc_.Cv() == &thermoc_.Cpv()
141  ? Cpvc
142  : carriedCloud.carrierField<scalar>(thermoc_.Cv())
143  ),
144  kappac
145  (
146  notNull(thermoc_)
147  ? carriedCloud.carrierField<scalar>(thermoc_.kappa())
148  : carriedCloud.noCarrierField<scalar>
149  (
150  "kappa",
151  "thermal conductivity",
152  false
153  )
154  ),
155  Prc
156  (
157  c.derivedField<scalar>
158  (
159  [&]
160  (
161  const LagrangianModelRef& model,
162  const LagrangianSubMesh& subMesh
163  )
164  {
165  return
166  Cpc(model, subMesh)
167  *muc(model, subMesh)
168  /kappac(model, subMesh);
169  }
170  )
171  ),
172  iToic(),
173  iToicPhase(),
174  Yc(),
175  YcPhase()
176 {
177  // Create maps from cloud to Eulerian specie indices
178  if (thermalCloud.isThermo<multicomponentLagrangianThermo>())
179  {
181  thermalCloud.thermo<multicomponentLagrangianThermo>();
182 
183  iToic.resize(thermo.species().size(), -1);
184  iToicPhase.resize(thermo.species().size(), -1);
185 
186  if (notNull(multicomponentThermoc_))
187  {
188  forAll(iToic, i)
189  {
190  const word& specieName = thermo.species()[i];
191 
192  iToic[i] =
193  multicomponentThermoc_.containsSpecie(specieName)
194  ? multicomponentThermoc_.species()[specieName]
195  : -1;
196  }
197  }
198  if (notNull(multicomponentThermocPhase_))
199  {
200  forAll(iToicPhase, i)
201  {
202  const word& specieName = thermo.species()[i];
203 
204  iToicPhase[i] =
205  multicomponentThermocPhase_.containsSpecie(specieName)
206  ? multicomponentThermocPhase_.species()[specieName]
207  : -1;
208  }
209  }
210  }
211 
212  // Create carrier fields for the mass fractions
213  if (notNull(multicomponentThermoc_))
214  {
215  const PtrList<volScalarField>& YcVf =
216  multicomponentThermoc_.Y();
217 
218  Yc.resize(YcVf.size());
219 
220  forAll(Yc, ic)
221  {
222  Yc.set
223  (
224  ic,
225  &carriedCloud.carrierField<scalar>(YcVf[ic])
226  );
227  }
228  }
229  if (notNull(multicomponentThermocPhase_))
230  {
231  const PtrList<volScalarField>& YcPhaseVf =
232  multicomponentThermocPhase_.Y();
233 
234  YcPhase.resize(YcPhaseVf.size());
235 
236  forAll(YcPhase, icPhase)
237  {
238  YcPhase.set
239  (
240  icPhase,
241  &carriedCloud.carrierField<scalar>(YcPhaseVf[icPhase])
242  );
243  }
244  }
245 }
246 
247 
248 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
249 
251 {}
252 
253 
254 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
255 
257 {
258  return notNull(thermoc_);
259 }
260 
261 
263 {
264  return notNull(thermocPhase_);
265 }
266 
267 
268 // ************************************************************************* //
scalar Cp(const scalar p, const scalar T) const
Definition: EtoHthermo.H:2
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
Generic GeometricField class.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:99
Simple wrapper to provide an optional reference to a Lagrangian model.
Mesh that relates to a sub-section of a Lagrangian mesh. This is used to construct fields that relate...
Base-class for fluid and solid thermodynamic properties.
Definition: basicThermo.H:78
Base class for clouds. Provides a basic evolution algorithm, models, and a database for caching deriv...
Definition: cloud.H:61
Base class for clouds which are carried by a fluid.
Definition: carried.H:57
Base class for clouds which are coupled to a variable density fluid.
const CloudDerivedField< scalar > & muc
Carrier dynamic viscosity.
Base class for clouds which are coupled to a fluid with a thermodynamic model.
bool hasThermoc() const
Return whether this cloud has a carrier thermo.
const CarrierField< scalar > & kappac
Carrier thermal conductivity.
bool hasThermocPhase() const
Return whether this cloud has a corresponding Eulerian phase thermo.
coupledToThermalFluid(const cloud &c, const carried &, const thermal &)
Construct from a reference to the cloud and its base classes.
const CarrierField< scalar > & Cpc
Carrier heat capacity at constant pressure.
Base class for clouds with thermodynamic modelling.
Definition: thermal.H:56
Base-class for multi-component fluid thermodynamic properties.
Base-class for fluid thermodynamic properties.
Definition: fluidThermo.H:56
Base-class for multicomponent Lagrangian thermodynamic models.
Base-class for multi-component thermodynamic properties.
A base class for physical properties.
Template function which returns the un-mangled name of a given type. Useful for types which do not ha...
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)
defineTypeNameAndDebug(carried, 0)
const dimensionedScalar kappa
Coulomb constant: default SI units: [N.m2/C2].
const dimensionedScalar c
Speed of light in a vacuum.
Namespace for OpenFOAM.
To & refCastNull(From &r)
Reference type cast template function,.
Definition: typeInfo.H:162
bool notNull(const T &t)
Return true if t is not a reference to the nullObject of type T.
Definition: nullObjectI.H:64
const T & NullObjectRef()
Return const reference to the nullObject of type T.
Definition: nullObjectI.H:27
bool isNull(const T &t)
Return true if t is a reference to the nullObject of type T.
Definition: nullObjectI.H:58
void T(GeometricField< Type, GeoMesh, PrimitiveField1 > &gf, const GeometricField< Type, GeoMesh, PrimitiveField2 > &gf1)
volScalarField & p
fluidMulticomponentThermo & thermo
Definition: createFields.H:15