multicomponentParticle.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 "multicomponentParticle.H"
27 #include "cloud_fvModel.H"
28 #include "cloud_functionObject.H"
29 #include "LagrangiancDdt.H"
30 #include "LagrangianmDdt.H"
32 
33 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
34 
35 namespace Foam
36 {
37 namespace clouds
38 {
41 }
42 namespace fv
43 {
44  makeCloudFvModel(multicomponentParticle);
45 }
46 namespace functionObjects
47 {
48  makeCloudFunctionObject(multicomponentParticle);
49 }
50 }
51 
52 
53 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
54 
57 (
58  const LagrangianSubMesh& subMesh
59 ) const
60 {
61  const LagrangianSubScalarSubField& m = this->m.ref(subMesh);
62  const LagrangianSubVectorSubField& U = this->U.ref(subMesh);
63 
64  return
68 }
69 
70 
72 {
73  const bool dUdt = tracking == trackingType::parabolic;
74 
75  const LagrangianSubMesh subMesh = this->mesh().subNone();
76 
77  LagrangianSubScalarSubField& m = this->m.ref(subMesh);
78  LagrangianSubScalarSubField& e = this->e.ref(subMesh);
79  LagrangianSubVectorSubField& U = this->U.ref(subMesh);
80 
81  bool result = false;
82 
83  if (LagrangianModels().addsSupToField(m))
84  {
85  result = Lagrangianm::initDdt(dimless, m, dUdt) || result;
86 
87  if (context == cloud::contextType::fvModel)
88  {
89  result = initPsicDdt(m, rhoc) || result;
90  if (hasPhase())
91  {
92  result = initPsicDdt(m, rhocPhase) || result;
93  }
94  }
95  }
96 
97  {
98  forAll(this->Y, i)
99  {
100  LagrangianSubScalarSubField& Yi = this->Y[i].ref(subMesh);
101 
102  result = Lagrangianm::initDdt(dimMass, Yi, dUdt) || result;
103  }
104 
105  if (context == cloud::contextType::fvModel)
106  {
107  forAll(this->Y, i)
108  {
109  const label ic = iToic[i];
110  if (ic != -1)
111  {
112  result = initPsicDdt(m, Yc[ic]) || result;
113  }
114  if (hasPhase())
115  {
116  const label icPhase = iToicPhase[i];
117  if (icPhase != -1 && &YcPhase[icPhase] != &Yc[ic])
118  {
119  result = initPsicDdt(m, YcPhase[icPhase]) || result;
120  }
121  }
122  }
123  }
124  }
125 
126  {
127  result = Lagrangianm::initDdt(dimMass, e, dUdt) || result;
128 
129  if (context == cloud::contextType::fvModel)
130  {
131  if (hasThermoc())
132  {
133  result = initPsicDdt(m, hec) || result;
134  }
135  if (hasThermocPhase() && &hecPhase != &hec)
136  {
137  result = initPsicDdt(m, hecPhase) || result;
138  }
139  }
140  }
141 
142  {
143  result = Lagrangianm::initDdt(dimMass, U, dUdt) || result;
144 
145  if (context == cloud::contextType::fvModel)
146  {
147  result = initPsicDdt(m, Uc) || result;
148  if (hasPhase() && &UcPhase != &Uc)
149  {
150  result = initPsicDdt(m, UcPhase) || result;
151  }
152  }
153  }
154 
155  return result;
156 }
157 
158 
160 (
161  const LagrangianSubScalarField& deltaT,
162  const bool final
163 )
164 {
165  const LagrangianSubMesh& subMesh = deltaT.mesh();
166 
167  LagrangianSubScalarSubField& m = this->m.ref(subMesh);
168  const LagrangianSubScalarSubField& rho = this->rho(subMesh);
169  LagrangianSubScalarSubField& e = this->e.ref(subMesh);
170  LagrangianSubVectorSubField& U = this->U.ref(subMesh);
171 
172  // Update the pressure
173  thermo().correctPressure(subMesh);
174 
175  // Solve the mass equation if a model provides a mass source
176  if (LagrangianModels().addsSupToField(m))
177  {
179  (
180  Lagrangianm::Ddt(deltaT, m)
181  ==
182  LagrangianModels().source(deltaT, m)
183  );
184 
185  mEqn.solve(final);
186 
187  // Correct the diameter for the change in mass, assuming the density
188  // remains constant
190 
191  // Calculate mass exchanges with the carrier
192  if (context == cloud::contextType::fvModel && final)
193  {
194  carrierEqn(rhoc) += psicEqn(deltaT, m, rhoc);
195  if (hasPhase())
196  {
197  carrierEqn(rhocPhase) += psicEqn(deltaT, m, rhocPhase);
198  }
199  }
200  }
201 
202  // Solve the species fraction equations
203  {
205  this->thermo<multicomponentLagrangianThermo>();
206 
207  forAll(this->Y, i)
208  {
209  if (i == thermo.defaultSpecie()) continue;
210 
211  LagrangianSubScalarSubField& Yi = this->Y[i].ref(subMesh);
212 
214  (
215  Lagrangianm::Ddt(deltaT, m, Yi)
216  ==
217  LagrangianModels().source(deltaT, m, Yi)
218  );
219 
220  YiEqn.solve(final);
221  }
222 
223  // Ensure the species fractions sum to one
224  thermo.normaliseY(subMesh);
225 
226  // Calculate specie exchanges with the carrier
227  if (context == cloud::contextType::fvModel && final)
228  {
229  forAll(this->Y, i)
230  {
231  const label ic = iToic[i];
232  if (ic != -1)
233  {
234  carrierEqn(Yc[ic]) +=
235  psicEqn(deltaT, m, e, Yc[ic]);
236  }
237  if (hasPhase())
238  {
239  const label icPhase = iToicPhase[i];
240  if (icPhase != -1 && &YcPhase[icPhase] != &Yc[ic])
241  {
242  carrierEqn(YcPhase[icPhase]) +=
243  psicEqn(deltaT, m, e, YcPhase[icPhase]);
244  }
245  }
246  }
247  }
248  }
249 
250  // Solve the energy equation
251  {
253  (
254  Lagrangianm::Ddt(deltaT, m, e)
255  ==
256  LagrangianModels().source(deltaT, m, e)
257  );
258 
259  eEqn.solve(final);
260 
261  // Update the thermodynamic model
262  thermo().correct(subMesh);
263 
264  // Correct the diameter for changes in density
266 
267  // Calculate energy exchanges with the carrier
268  if (context == cloud::contextType::fvModel && final)
269  {
270  if (hasThermoc())
271  {
272  carrierEqn(hec) += psicEqn(deltaT, m, e, hec);
273  }
274  if (hasThermocPhase() && &hecPhase != &hec)
275  {
276  carrierEqn(hecPhase) += psicEqn(deltaT, m, e, hecPhase);
277  }
278  }
279  }
280 
281  // Solve the momentum equation
282  {
284  (
285  Lagrangianm::Ddt(deltaT, m, U)
286  ==
287  LagrangianModels().source(deltaT, m, U)
288  );
289 
290  UEqn.solve(final);
291 
292  // Calculate momentum exchanges with the carrier
293  if (context == cloud::contextType::fvModel && final)
294  {
295  carrierEqn(Uc) += psicEqn(deltaT, m, U, Uc);
296  if (hasPhase() && &UcPhase != &Uc)
297  {
298  carrierEqn(UcPhase) += psicEqn(deltaT, m, U, UcPhase);
299  }
300  }
301  }
302 }
303 
304 
306 {
309 }
310 
311 
312 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
313 
315 (
317  const contextType context,
318  const dictionary& dict
319 )
320 :
321  cloud(mesh, context),
322  carried(*this, dict),
323  spherical(static_cast<const cloud&>(*this)),
324  multicomponentThermal(*this, *this, *this),
325  coupledToThermalFluid(*this, *this, *this),
326  sphericalCoupled(*this, *this, *this, *this),
327  massiveCoupledToFluid(*this, *this, *this)
328 {
329  thermo().initialise();
330 
332 }
333 
334 
335 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
336 
338 {}
339 
340 
341 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
342 
344 (
345  const bool initial,
346  const bool final
347 )
348 {
349  // Pre-solve operations ...
353 
354  // Solve
355  cloud::solve(initial, final);
356 
357  // Post-solve operations ...
358 }
359 
360 
361 // ************************************************************************* //
Functions for calculating the time derivative for a Lagrangian equation.
Functions for calculating the time derivative for a Lagrangian equation.
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:449
Macros for easy insertion into run-time selection tables.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
const GeoMesh & mesh() const
Return mesh.
This class stores the coefficients of a Lagrangian equation, and facilitates solving that equation an...
Definition: LagrangianEqn.H:56
void solve(const bool final)
Solve.
Class containing Lagrangian geometry and topology.
List of Lagrangian models, constructed as a (Lagrangian) mesh object. Provides similar functions to t...
bool addsSupToField(const word &fieldName) const
Return true if the LagrangianModels adds a source term to the.
Mesh that relates to a sub-section of a Lagrangian mesh. This is used to construct fields that relate...
Base class for clouds. Provides a basic evolution algorithm, models, and a database for caching deriv...
Definition: cloud.H:61
contextType
Context in which this cloud is used.
Definition: cloud.H:203
virtual void solve(const bool initial, const bool final)
Solve the cloud's evolution over the current time-step.
Definition: cloud.C:608
Foam::LagrangianModels & LagrangianModels() const
Access the models.
Definition: cloud.C:597
virtual void partition()
Partition hook.
Definition: cloud.C:450
CloudStateField< vector > U
Velocity.
Definition: cloud.H:209
Base class for clouds which are carried by a fluid.
Definition: carried.H:57
void clearCarrierFields()
Clear the carrier fields.
Definition: carried.C:115
void resetCarrierFields(const bool initial)
Reset the carrier fields.
Definition: carried.C:132
void updateCarrier()
Update the cached carrier fields.
Base class for clouds which are coupled to a fluid with a thermodynamic model.
void clearCarrierEqns()
Clear the carrier equations.
Definition: coupled.C:110
Base class for clouds of massive particles which are coupled to a fluid.
const CloudDerivedField< scalar > & m
Mass.
Definition: massive.H:78
Cloud with spherical particles with multicomponent thermodynamic modelling.
virtual void solve(const bool initial, const bool final)
Solve the cloud's evolution over the current time-step.
virtual bool reCalculateModified()
Do we need to re-calculate particles that are modified?
virtual tmp< LagrangianSubVectorField > dUdt(const LagrangianSubMesh &) const
Return the acceleration with which to do second-order tracking.
multicomponentParticle(LagrangianMesh &mesh, const contextType context, const dictionary &dict)
Construct from a mesh and context.
virtual void partition()
Partition hook.
virtual void calculate(const LagrangianSubScalarField &deltaT, const bool final)
Update the cloud properties.
Base class for clouds with multicomponent thermodynamic modelling.
Base class for clouds of spherical particles which are coupled to a carrier.
Base class for clouds with spherical particles.
Definition: spherical.H:53
void correct(const LagrangianSubScalarSubField &v)
Correct the shape to match the given volume.
Definition: spherical.C:90
const Thermo & thermo(const Args &... args) const
Get a reference to the thermodynamic model of a given type.
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
Base-class for multicomponent Lagrangian thermodynamic models.
A class for managing temporary objects.
Definition: tmp.H:55
fvVectorMatrix & UEqn
Definition: UEqn.H:11
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
U
Definition: pEqn.H:72
rho
Definition: pEqn.H:1
tmp< LagrangianSubField< Type > > Ddt(const LagrangianSubSubField< Type > &psi)
Return the instantaneous time-derivative.
tmp< LagrangianEqn< Type > > Ddt(const LagrangianSubScalarField &deltaT, LagrangianSubSubField< Type > &psi)
Return the time-derivative matrix.
bool initDdt(const dimensionSet &mDims, const LagrangianSubSubField< Type > &psi, const bool instantaneousDdt=false)
Initialise time-derivative information. Registers fields used to.
addToRunTimeSelectionTable(cloud, dynamicParcel, LagrangianMesh)
defineTypeNameAndDebug(carried, 0)
makeCloudFunctionObject(dynamicParcel)
makeCloudFvModel(dynamicParcel)
Namespace for OpenFOAM.
const doubleScalar e
Definition: doubleScalar.H:106
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
tmp< DimensionedField< Type, GeoMesh, SubField > > toSubField(const DimensionedField< Type, GeoMesh, Field > &)
Return a temporary sub-field from a reference to a field.
labelList fv(nPoints)
dictionary dict
PtrList< volScalarField > & Y
fluidMulticomponentThermo & thermo
Definition: createFields.H:15