ReactingMultiphaseCloud.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) 2011-2023 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 
27 
28 #include "DevolatilisationModel.H"
29 #include "SurfaceReactionModel.H"
30 
31 // * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
32 
33 template<class CloudType>
35 {
36  devolatilisationModel_.reset
37  (
39  (
40  this->subModelProperties(),
41  *this
42  ).ptr()
43  );
44 
45  surfaceReactionModel_.reset
46  (
48  (
49  this->subModelProperties(),
50  *this
51  ).ptr()
52  );
53 }
54 
55 
56 template<class CloudType>
58 (
60 )
61 {
62  CloudType::cloudReset(c);
63 
64  devolatilisationModel_.reset(c.devolatilisationModel_.ptr());
65  surfaceReactionModel_.reset(c.surfaceReactionModel_.ptr());
66 
67  dMassDevolatilisation_ = c.dMassDevolatilisation_;
68  dMassSurfaceReaction_ = c.dMassSurfaceReaction_;
69 }
70 
71 
72 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
73 
74 template<class CloudType>
76 (
77  const word& cloudName,
78  const volScalarField& rho,
79  const volVectorField& U,
80  const dimensionedVector& g,
81  const fluidThermo& carrierThermo,
82  const bool readFields
83 )
84 :
85  CloudType(cloudName, rho, U, g, carrierThermo, false),
86  cloudCopyPtr_(nullptr),
87  constProps_(this->particleProperties()),
88  devolatilisationModel_(nullptr),
89  surfaceReactionModel_(nullptr),
90  dMassDevolatilisation_(0.0),
91  dMassSurfaceReaction_(0.0)
92 {
93  setModels();
94 
95  if (readFields)
96  {
97  parcelType::readFields(*this, this->composition());
98  this->deleteLostParticles();
99  }
100 
101  if (this->solution().resetSourcesOnStartup())
102  {
104  }
105 }
106 
107 
108 template<class CloudType>
110 (
112  const word& name
113 )
114 :
115  CloudType(c, name),
116  cloudCopyPtr_(nullptr),
117  constProps_(c.constProps_),
118  devolatilisationModel_(c.devolatilisationModel_->clone()),
119  surfaceReactionModel_(c.surfaceReactionModel_->clone()),
120  dMassDevolatilisation_(c.dMassDevolatilisation_),
121  dMassSurfaceReaction_(c.dMassSurfaceReaction_)
122 {}
123 
124 
125 template<class CloudType>
127 (
128  const fvMesh& mesh,
129  const word& name,
131 )
132 :
133  CloudType(mesh, name, c),
134  cloudCopyPtr_(nullptr),
135  constProps_(),
136  devolatilisationModel_(nullptr),
137  surfaceReactionModel_(nullptr),
138  dMassDevolatilisation_(0.0),
139  dMassSurfaceReaction_(0.0)
140 {}
141 
142 
143 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
144 
145 template<class CloudType>
147 {}
148 
149 
150 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
151 
152 template<class CloudType>
154 (
155  parcelType& parcel
156 )
157 {
158  CloudType::setParcelThermoProperties(parcel);
159 
160  label idGas = this->composition().idGas();
161  label idLiquid = this->composition().idLiquid();
162  label idSolid = this->composition().idSolid();
163 
164  parcel.YGas() = this->composition().Y0(idGas);
165  parcel.YLiquid() = this->composition().Y0(idLiquid);
166  parcel.YSolid() = this->composition().Y0(idSolid);
167 }
168 
169 
170 template<class CloudType>
172 (
173  parcelType& parcel,
174  const label injectori
175 )
176 {
177  CloudType::checkParcelProperties(parcel, injectori);
178 
179  parcel.mass0() = parcel.mass();
180 
181  if (injectori != -1 && this->injectors()[injectori].fullyDescribed())
182  {
183  label idGas = this->composition().idGas();
184  label idLiquid = this->composition().idLiquid();
185  label idSolid = this->composition().idSolid();
186 
187  this->checkSuppliedComposition
188  (
189  parcel.YGas(),
190  this->composition().Y0(idGas),
191  "YGas"
192  );
193  this->checkSuppliedComposition
194  (
195  parcel.YLiquid(),
196  this->composition().Y0(idLiquid),
197  "YLiquid"
198  );
199  this->checkSuppliedComposition
200  (
201  parcel.YSolid(),
202  this->composition().Y0(idSolid),
203  "YSolid"
204  );
205  }
206 }
207 
208 
209 template<class CloudType>
211 {
212  cloudCopyPtr_.reset
213  (
215  (
216  clone(this->name() + "Copy").ptr()
217  )
218  );
219 }
220 
221 
222 template<class CloudType>
224 {
225  cloudReset(cloudCopyPtr_());
226  cloudCopyPtr_.clear();
227 }
228 
229 
230 template<class CloudType>
232 {
233  CloudType::resetSourceTerms();
234 }
235 
236 
237 template<class CloudType>
239 {
240  if (this->solution().canEvolve())
241  {
242  typename parcelType::trackingData td(*this);
243 
244  this->solve(*this, td);
245  }
246 }
247 
248 
249 template<class CloudType>
251 {
252  CloudType::info();
253 
254  this->devolatilisation().info(Info);
255  this->surfaceReaction().info(Info);
256 }
257 
258 
259 template<class CloudType>
261 {
262  if (this->compositionModel_.valid())
263  {
264  CloudType::particleType::writeFields(*this, this->composition());
265  }
266  else
267  {
268  CloudType::particleType::writeFields(*this);
269  }
270 }
271 
272 
273 // ************************************************************************* //
void deleteLostParticles()
Remove lost particles from cloud and delete.
Definition: Cloud.C:233
Templated base class for dsmc cloud.
Definition: DSMCCloud.H:80
ParcelType parcelType
Type of parcel the cloud was instantiated for.
Definition: DSMCCloud.H:225
void info() const
Print cloud information.
Definition: DSMCCloud.C:996
Templated devolatilisation model class.
Generic GeometricField class.
Templated base class for multiphase reacting cloud.
void setModels()
Set cloud sub-models.
void storeState()
Store the current cloud state.
ReactingMultiphaseCloud(const word &cloudName, const volScalarField &rho, const volVectorField &U, const dimensionedVector &g, const fluidThermo &carrierThermo, const bool readFields=true)
Construct given carrier fields and thermo.
virtual void writeFields() const
Write the field data for the cloud.
void info()
Print cloud information.
void restoreState()
Reset the current cloud to the previously stored state.
void cloudReset(ReactingMultiphaseCloud< CloudType > &c)
Reset state of cloud.
void checkParcelProperties(parcelType &parcel, const label injectori)
Check parcel properties.
void resetSourceTerms()
Reset the cloud source terms.
void setParcelThermoProperties(parcelType &parcel)
Set parcel thermo properties.
virtual ~ReactingMultiphaseCloud()
Destructor.
Templated surface reaction model class.
Base-class for fluid thermodynamic properties.
Definition: fluidThermo.H:57
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:99
Selector class for relaxation factors, solver type and solution.
Definition: solution.H:51
A class for handling words, derived from string.
Definition: word.H:62
U
Definition: pEqn.H:72
autoPtr< CompressibleMomentumTransportModel > New(const volScalarField &rho, const volVectorField &U, const surfaceScalarField &phi, const viscosity &viscosity)
const dimensionedScalar c
Speed of light in a vacuum.
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
word name(const bool)
Return a word representation of a bool.
Definition: boolIO.C:39
void readFields(const typename GeoFieldType::Mesh &mesh, const IOobjectList &objects, const HashSet< word > &selectedFields, LIFOStack< regIOobject * > &storedObjects)
Read the selected GeometricFields of the specified type.
Definition: ReadFields.C:244
messageStream Info
T clone(const T &t)
Definition: List.H:55
SolverPerformance< Type > solve(fvMatrix< Type > &, const word &)
Solve returning the solution statistics given convergence tolerance.
const word cloudName(propsDict.lookup("cloudName"))