particle.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 "particle.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 {
45 }
46 namespace functionObjects
47 {
49 }
50 }
51 
52 
53 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
54 
56 (
57  const LagrangianSubMesh& subMesh
58 ) const
59 {
60  const LagrangianSubScalarSubField& m = this->m.ref(subMesh);
61  const LagrangianSubVectorSubField& U = this->U.ref(subMesh);
62 
63  return
67 }
68 
69 
71 {
72  const bool dUdt = tracking == trackingType::parabolic;
73 
74  const LagrangianSubMesh subMesh = this->mesh().subNone();
75 
76  LagrangianSubScalarSubField& m = this->m.ref(subMesh);
77  LagrangianSubScalarSubField& e = this->e.ref(subMesh);
78  LagrangianSubVectorSubField& U = this->U.ref(subMesh);
79 
80  bool result = false;
81 
82  if (LagrangianModels().addsSupToField(m))
83  {
84  result = Lagrangianm::initDdt(dimless, m, dUdt) || result;
85 
86  if (context == cloud::contextType::fvModel)
87  {
88  result = initPsicDdt(m, rhoc) || result;
89  if (hasPhase())
90  {
91  result = initPsicDdt(m, rhocPhase) || result;
92  }
93  }
94  }
95 
96  {
97  result = Lagrangianm::initDdt(dimMass, e, dUdt) || result;
98 
99  if (context == cloud::contextType::fvModel)
100  {
101  if (hasThermoc())
102  {
103  result = initPsicDdt(m, hec) || result;
104  }
105  if (hasThermocPhase() && &hecPhase != &hec)
106  {
107  result = initPsicDdt(m, hecPhase) || result;
108  }
109  }
110  }
111 
112  {
113  result = Lagrangianm::initDdt(dimMass, U, dUdt) || result;
114 
115  if (context == cloud::contextType::fvModel)
116  {
117  result = initPsicDdt(m, Uc) || result;
118  if (hasPhase() && &UcPhase != &Uc)
119  {
120  result = initPsicDdt(m, UcPhase) || result;
121  }
122  }
123  }
124 
125  return result;
126 }
127 
128 
130 (
131  const LagrangianSubScalarField& deltaT,
132  const bool final
133 )
134 {
135  const LagrangianSubMesh& subMesh = deltaT.mesh();
136 
137  LagrangianSubScalarSubField& m = this->m.ref(subMesh);
138  const LagrangianSubScalarSubField& rho = this->rho(subMesh);
139  LagrangianSubScalarSubField& e = this->e.ref(subMesh);
140  LagrangianSubVectorSubField& U = this->U.ref(subMesh);
141 
142  // Update the pressure
143  thermo().correctPressure(subMesh);
144 
145  // Solve the mass equation if a model provides a mass source
146  if (LagrangianModels().addsSupToField(m))
147  {
149  (
150  Lagrangianm::Ddt(deltaT, m)
151  ==
152  LagrangianModels().source(deltaT, m)
153  );
154 
155  mEqn.solve(final);
156 
157  // Correct the diameter for the change in mass, assuming the density
158  // remains constant
160 
161  // Calculate mass exchanges with the carrier
162  if (context == cloud::contextType::fvModel && final)
163  {
164  carrierEqn(rhoc) += psicEqn(deltaT, m, rhoc);
165  if (hasPhase())
166  {
167  carrierEqn(rhocPhase) += psicEqn(deltaT, m, rhocPhase);
168  }
169  }
170  }
171 
172  // Solve the energy equation
173  {
175  (
176  Lagrangianm::Ddt(deltaT, m, e)
177  ==
178  LagrangianModels().source(deltaT, m, e)
179  );
180 
181  eEqn.solve(final);
182 
183  // Update the thermodynamic model
184  thermo().correct(subMesh);
185 
186  // Correct the diameter for changes in density
188 
189  // Calculate energy exchanges with the carrier
190  if (context == cloud::contextType::fvModel && final)
191  {
192  if (hasThermoc())
193  {
194  carrierEqn(hec) += psicEqn(deltaT, m, e, hec);
195  }
196  if (hasThermocPhase() && &hecPhase != &hec)
197  {
198  carrierEqn(hecPhase) += psicEqn(deltaT, m, e, hecPhase);
199  }
200  }
201  }
202 
203  // Solve the momentum equation
204  {
206  (
207  Lagrangianm::Ddt(deltaT, m, U)
208  ==
209  LagrangianModels().source(deltaT, m, U)
210  );
211 
212  UEqn.solve(final);
213 
214  // Calculate momentum exchanges with the carrier
215  if (context == cloud::contextType::fvModel && final)
216  {
217  carrierEqn(Uc) += psicEqn(deltaT, m, U, Uc);
218  if (hasPhase() && &UcPhase != &Uc)
219  {
220  carrierEqn(UcPhase) += psicEqn(deltaT, m, U, UcPhase);
221  }
222  }
223  }
224 }
225 
226 
228 {
231 }
232 
233 
234 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
235 
237 (
239  const contextType context,
240  const dictionary& dict
241 )
242 :
243  cloud(mesh, context),
244  carried(*this, dict),
245  spherical(static_cast<const cloud&>(*this)),
246  thermal(*this, *this, *this),
247  coupledToThermalFluid(*this, *this, *this),
248  sphericalCoupled(*this, *this, *this, *this),
249  massiveCoupledToFluid(*this, *this, *this)
250 {
251  thermo().initialise();
252 
254 }
255 
256 
257 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
258 
260 {}
261 
262 
263 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
264 
265 void Foam::clouds::particle::solve(const bool initial, const bool final)
266 {
267  // Pre-solve operations ...
271 
272  // Solve
273  cloud::solve(initial, final);
274 
275  // Post-solve operations ...
276 }
277 
278 
279 // ************************************************************************* //
Functions for calculating the time derivative for a Lagrangian equation.
Functions for calculating the time derivative for a Lagrangian equation.
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 thermodynamic modelling.
Definition: particle.H:62
virtual void solve(const bool initial, const bool final)
Solve the cloud's evolution over the current time-step.
Definition: particle.C:265
virtual bool reCalculateModified()
Do we need to re-calculate particles that are modified?
Definition: particle.C:70
virtual ~particle()
Destructor.
Definition: particle.C:259
virtual tmp< LagrangianSubVectorField > dUdt(const LagrangianSubMesh &) const
Return the acceleration with which to do second-order tracking.
Definition: particle.C:56
particle(LagrangianMesh &mesh, const contextType context, const dictionary &dict)
Construct from a mesh and context.
Definition: particle.C:237
virtual void partition()
Partition hook.
Definition: particle.C:227
virtual void calculate(const LagrangianSubScalarField &deltaT, const bool final)
Update the cloud properties.
Definition: particle.C:130
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
Base class for clouds with thermodynamic modelling.
Definition: thermal.H:56
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 particle class.
Definition: particle.H:85
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
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
fluidMulticomponentThermo & thermo
Definition: createFields.H:15