dynamicParticle.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 "dynamicParticle.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(dynamicParticle);
45 }
46 namespace functionObjects
47 {
48  makeCloudFunctionObject(dynamicParticle);
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  LagrangianSubVectorSubField& U = this->U.ref(subMesh);
78 
79  bool result = false;
80 
81  if (LagrangianModels().addsSupToField(m))
82  {
83  result = Lagrangianm::initDdt(dimless, m, dUdt) || result;
84 
85  if (context == cloud::contextType::fvModel)
86  {
87  result = initPsicDdt(m, rhoc) || result;
88  if (hasPhase())
89  {
90  result = initPsicDdt(m, rhocPhase) || result;
91  }
92  }
93  }
94 
95  {
96  result = Lagrangianm::initDdt(dimMass, U, dUdt) || result;
97 
98  if (context == cloud::contextType::fvModel)
99  {
100  result = initPsicDdt(m, Uc) || result;
101  if (hasPhase() && &UcPhase != &Uc)
102  {
103  result = initPsicDdt(m, UcPhase) || result;
104  }
105  }
106  }
107 
108  return result;
109 }
110 
111 
113 (
114  const LagrangianSubScalarField& deltaT,
115  const bool final
116 )
117 {
118  const LagrangianSubMesh& subMesh = deltaT.mesh();
119 
120  LagrangianSubScalarSubField& m = this->m.ref(subMesh);
121  const LagrangianSubScalarSubField& rho = this->rho(subMesh);
122  LagrangianSubVectorSubField& U = this->U.ref(subMesh);
123 
124  // Solve the mass equation if a model provides a mass source
125  if (LagrangianModels().addsSupToField(m))
126  {
128  (
129  Lagrangianm::Ddt(deltaT, m)
130  ==
131  LagrangianModels().source(deltaT, m)
132  );
133 
134  mEqn.solve(final);
135 
136  // Correct the diameter, assuming the density remains constant
138 
139  // Calculate mass exchanges with the carrier
140  if (context == cloud::contextType::fvModel && final)
141  {
142  carrierEqn(rhoc) += psicEqn(deltaT, m, rhoc);
143  if (hasPhase())
144  {
145  carrierEqn(rhocPhase) += psicEqn(deltaT, m, rhocPhase);
146  }
147  }
148  }
149 
150  // Solve the momentum equation
151  {
153  (
154  Lagrangianm::Ddt(deltaT, m, U)
155  ==
156  LagrangianModels().source(deltaT, m, U)
157  );
158 
159  UEqn.solve(final);
160 
161  // Calculate momentum exchanges with the carrier
162  if (context == cloud::contextType::fvModel && final)
163  {
164  carrierEqn(Uc) += psicEqn(deltaT, m, U, Uc);
165  if (hasPhase() && &UcPhase != &Uc)
166  {
167  carrierEqn(UcPhase) += psicEqn(deltaT, m, U, UcPhase);
168  }
169  }
170  }
171 }
172 
173 
175 {
178 }
179 
180 
181 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
182 
184 (
186  const contextType context,
187  const dictionary& dict
188 )
189 :
190  cloud(mesh, context),
191  carried(*this, dict),
192  spherical(static_cast<const cloud&>(*this)),
193  dense(*this, *this),
194  coupledToFluid(*this, *this),
195  sphericalCoupled(*this, *this, *this, *this),
196  massiveCoupledToFluid(*this, *this, *this)
197 {
199 }
200 
201 
202 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
203 
205 {}
206 
207 
208 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
209 
210 void Foam::clouds::dynamicParticle::solve(const bool initial, const bool final)
211 {
212  // Pre-solve operations ...
216 
217  // Solve
218  cloud::solve(initial, final);
219 
220  // Post-solve operations ...
221 }
222 
223 
224 // ************************************************************************* //
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
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
Cloud with spherical, variable density, particles.
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.
dynamicParticle(LagrangianMesh &mesh, const contextType context, const dictionary &dict)
Construct from a mesh and context.
virtual ~dynamicParticle()
Destructor.
virtual void partition()
Partition hook.
virtual void calculate(const LagrangianSubScalarField &deltaT, const bool final)
Update the cloud properties.
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
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 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