dynamicParcel.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 "dynamicParcel.H"
27 #include "cloud_fvModel.H"
28 #include "cloud_functionObject.H"
29 #include "LagrangiancDdt.H"
30 #include "LagrangianmDdt.H"
31 #include "oneOrTmp.H"
33 
34 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
35 
36 namespace Foam
37 {
38 namespace clouds
39 {
42 }
43 namespace fv
44 {
45  makeCloudFvModel(dynamicParcel);
46 }
47 namespace functionObjects
48 {
49  makeCloudFunctionObject(dynamicParcel);
50 }
51 }
52 
53 
54 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
55 
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& number = this->number.ref(subMesh);
78  LagrangianSubScalarSubField& m = this->m.ref(subMesh);
79  LagrangianSubVectorSubField& U = this->U.ref(subMesh);
80 
81  bool result = false;
82 
83  if (LagrangianModels().addsSupToField(word::null))
84  {
85  result = Lagrangianm::initDdt(dimless, number) || result;
86  }
87 
88  if (LagrangianModels().addsSupToField(m))
89  {
90  result = Lagrangianm::initDdt(dimless, m, dUdt) || result;
91 
92  if (context == cloud::contextType::fvModel)
93  {
94  result = initPsicDdt(m, rhoc) || result;
95  if (hasPhase())
96  {
97  result = initPsicDdt(m, rhocPhase) || result;
98  }
99  }
100  }
101 
102  {
103  result = Lagrangianm::initDdt(dimMass, U, dUdt) || result;
104 
105  if (context == cloud::contextType::fvModel)
106  {
107  result = initPsicDdt(m, Uc) || result;
108  if (hasPhase() && &UcPhase != &Uc)
109  {
110  result = initPsicDdt(m, UcPhase) || result;
111  }
112  }
113  }
114 
115  return result;
116 }
117 
118 
120 (
121  const LagrangianSubScalarField& deltaT,
122  const bool final
123 )
124 {
125  const LagrangianSubMesh& subMesh = deltaT.mesh();
126 
127  LagrangianSubScalarSubField& number = this->number.ref(subMesh);
128  LagrangianSubScalarSubField& m = this->m.ref(subMesh);
129  const LagrangianSubScalarSubField& rho = this->rho(subMesh);
130  LagrangianSubVectorSubField& U = this->U.ref(subMesh);
131 
132  // Evaluate the fractional source
133  LagrangianEqn<scalar> oneEqn(LagrangianModels().source(deltaT));
134 
135  // Initialise a unity fractional change in number (i.e., no change)
136  oneOrTmp<LagrangianSubScalarField> numberByNumber0;
137 
138  // Solve the number equation if a model provides a fractional source
139  if (oneEqn.valid())
140  {
141  LagrangianEqn<scalar> numberEqn
142  (
143  Lagrangianm::Ddt(deltaT, number)
144  ==
145  oneEqn
146  );
147 
148  numberEqn.solve(final);
149 
150  // Set the fractional change in number
151  numberByNumber0 = number/number.oldTime();
152 
153  // Correct the fractional source
154  oneEqn *= numberByNumber0();
155  }
156 
157  // Solve the mass equation if a model provides a mass source
158  if (oneEqn.valid() || LagrangianModels().addsSupToField(m))
159  {
161  (
162  Lagrangianm::Ddt(deltaT, m)
163  + oneEqn
164  ==
165  numberByNumber0()*LagrangianModels().source(deltaT, m)
166  );
167 
168  mEqn.solve(final);
169 
170  // Correct the diameter, assuming the density remains constant
172 
173  // Calculate mass exchanges with the carrier
174  if (context == cloud::contextType::fvModel && final)
175  {
176  carrierEqn(rhoc) += number*psicEqn(deltaT, m, rhoc);
177  if (hasPhase())
178  {
179  carrierEqn(rhocPhase) += number*psicEqn(deltaT, m, rhocPhase);
180  }
181  }
182  }
183 
184  // Solve the velocity equation
185  {
187  (
188  Lagrangianm::Ddt(deltaT, m, U)
189  + m*oneEqn
190  ==
191  numberByNumber0*LagrangianModels().source(deltaT, m, U)
192  );
193 
194  UEqn.solve(final);
195 
196  // Calculate momentum exchanges with the carrier
197  if (context == cloud::contextType::fvModel && final)
198  {
199  carrierEqn(Uc) += number*psicEqn(deltaT, m, U, Uc);
200  if (hasPhase() && &UcPhase != &Uc)
201  {
202  carrierEqn(UcPhase) += number*psicEqn(deltaT, m, U, UcPhase);
203  }
204  }
205  }
206 }
207 
208 
210 {
213 }
214 
215 
216 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
217 
219 (
221  const contextType context,
222  const dictionary& dict
223 )
224 :
225  cloud(mesh, context),
226  carried(*this, dict),
227  grouped(static_cast<const cloud&>(*this)),
228  spherical(*this, *this),
229  dense(*this, *this),
230  coupledToFluid(*this, *this),
231  sphericalCoupled(*this, *this, *this, *this),
232  massiveCoupledToFluid(*this, *this, *this)
233 {
235 }
236 
237 
238 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
239 
241 {}
242 
243 
244 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
245 
246 void Foam::clouds::dynamicParcel::solve(const bool initial, const bool final)
247 {
248  // Pre-solve operations ...
252 
253  // Solve
254  cloud::solve(initial, final);
255 
256  // Post-solve operations ...
257 }
258 
259 
260 // ************************************************************************* //
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.
bool valid() const
Determine whether this matrix has any valid coefficients.
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...
const Field0Type & oldTime() const
Return the old-time field.
Definition: OldTimeField.C:322
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
Base class for clouds which are coupled to a variable density fluid.
void updateCarrier()
Update the cached carrier fields.
void clearCarrierEqns()
Clear the carrier equations.
Definition: coupled.C:110
Base class for clouds with a user-specified density field.
Definition: dense.H:76
Basic cloud with spherical, variable density, particles, grouped into parcels.
Definition: dynamicParcel.H:74
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?
Definition: dynamicParcel.C:71
dynamicParcel(LagrangianMesh &mesh, const contextType context, const dictionary &dict)
Construct from a mesh and context.
virtual tmp< LagrangianSubVectorField > dUdt(const LagrangianSubMesh &) const
Return the acceleration with which to do second-order tracking.
Definition: dynamicParcel.C:57
virtual ~dynamicParcel()
Destructor.
virtual void partition()
Partition hook.
virtual void calculate(const LagrangianSubScalarField &deltaT, const bool final)
Update the cloud properties.
Base class for clouds in which particles are grouped into parcels.
Definition: grouped.H:51
Base class for clouds of massive particles which are coupled to a fluid.
const CloudDerivedField< scalar > & m
Mass.
Definition: massive.H:78
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
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
Variant type that either contains and behaves as tmp object or represents a value of one....
Definition: oneOrTmp.H:53
A class for managing temporary objects.
Definition: tmp.H:55
static const word null
An empty word.
Definition: word.H:78
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 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