kinematicParcel.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 "kinematicParcel.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(kinematicParcel);
46 }
47 namespace functionObjects
48 {
49  makeCloudFunctionObject(kinematicParcel);
50 }
51 }
52 
53 
54 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
55 
58 (
59  const LagrangianSubMesh& subMesh
60 ) const
61 {
62  const LagrangianSubScalarSubField& v = this->v.ref(subMesh);
63  const LagrangianSubVectorSubField& U = this->U.ref(subMesh);
64 
65  return
69 }
70 
71 
73 {
74  const bool dUdt = tracking == trackingType::parabolic;
75 
76  const LagrangianSubMesh subMesh = this->mesh().subNone();
77 
78  LagrangianSubScalarSubField& number = this->number.ref(subMesh);
79  LagrangianSubScalarSubField& v = this->v.ref(subMesh);
80  LagrangianSubVectorSubField& U = this->U.ref(subMesh);
81 
82  bool result = false;
83 
84  if (LagrangianModels().addsSupToField(word::null))
85  {
86  result = Lagrangianm::initDdt(dimless, number) || result;
87  }
88 
89  if (LagrangianModels().addsSupToField(v))
90  {
91  result = Lagrangianm::initDdt(dimless, v, dUdt) || result;
92 
93  if (context == cloud::contextType::fvModel)
94  {
95  result = initPsicDdt(v, onec) || result;
96  if (hasPhase())
97  {
98  result = initPsicDdt(v, onecPhase) || result;
99  }
100  }
101  }
102 
103  {
104  result = Lagrangianm::initDdt(dimVolume, U, dUdt) || result;
105 
106  if (context == cloud::contextType::fvModel)
107  {
108  result = initPsicDdt(v, Uc) || result;
109  if (hasPhase() && &UcPhase != &Uc)
110  {
111  result = initPsicDdt(v, UcPhase) || result;
112  }
113  }
114  }
115 
116  return result;
117 }
118 
119 
121 (
122  const LagrangianSubScalarField& deltaT,
123  const bool final
124 )
125 {
126  const LagrangianSubMesh& subMesh = deltaT.mesh();
127 
128  LagrangianSubScalarSubField& number = this->number.ref(subMesh);
129  LagrangianSubScalarSubField& v = this->v.ref(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 volume equation if a model provides a volume source
158  if (oneEqn.valid() || LagrangianModels().addsSupToField(v))
159  {
161  (
162  Lagrangianm::Ddt(deltaT, v)
163  + oneEqn
164  ==
165  numberByNumber0()*LagrangianModels().source(deltaT, v)
166  );
167 
168  vEqn.solve(final);
169 
170  // Correct the diameter
172 
173  // Calculate volume exchanges with the carrier
174  if (context == cloud::contextType::fvModel && final)
175  {
176  carrierEqn(onec) += number*psicEqn(deltaT, v, onec);
177  if (hasPhase())
178  {
179  carrierEqn(onecPhase) += number*psicEqn(deltaT, v, onecPhase);
180  }
181  }
182  }
183 
184  // Solve the velocity equation
185  {
187  (
188  Lagrangianm::Ddt(deltaT, v, U)
189  + v*oneEqn
190  ==
191  numberByNumber0*LagrangianModels().source(deltaT, v, 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, v, U, Uc);
200  if (hasPhase() && &UcPhase != &Uc)
201  {
202  carrierEqn(UcPhase) += number*psicEqn(deltaT, v, 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  coupledToConstantDensityFluid(*this, *this),
230  sphericalCoupled(*this, *this, *this, *this)
231 {
233 }
234 
235 
236 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
237 
239 {}
240 
241 
242 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
243 
245 (
246  const bool initial,
247  const bool final
248 )
249 {
250  // Pre-solve operations ...
254 
255  // Solve
256  cloud::solve(initial, final);
257 
258  // Post-solve operations ...
259 }
260 
261 
262 // ************************************************************************* //
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 constant density fluid.
void clearCarrierEqns()
Clear the carrier equations.
Definition: coupled.C:110
void updateCarrier()
Update the cached carrier fields.
Definition: coupled.C:101
Base class for clouds in which particles are grouped into parcels.
Definition: grouped.H:51
Basic cloud with spherical, constant density, particles, grouped into parcels.
virtual void solve(const bool initial, const bool final)
Solve the cloud's evolution over the current time-step.
virtual ~kinematicParcel()
Destructor.
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.
kinematicParcel(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.
const CloudDerivedField< scalar > & v
Volume.
Definition: shaped.H:90
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
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 & dimVolume
Definition: dimensions.C:150
labelList fv(nPoints)
dictionary dict