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-2018 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 SLGThermo& thermo,
82  bool readFields
83 )
84 :
85  CloudType(cloudName, rho, U, g, thermo, false),
87  cloudCopyPtr_(nullptr),
88  constProps_(this->particleProperties()),
89  devolatilisationModel_(nullptr),
90  surfaceReactionModel_(nullptr),
91  dMassDevolatilisation_(0.0),
92  dMassSurfaceReaction_(0.0)
93 {
94  if (this->solution().active())
95  {
96  setModels();
97 
98  if (readFields)
99  {
100  parcelType::readFields(*this, this->composition());
101  this->deleteLostParticles();
102  }
103  }
104 
105  if (this->solution().resetSourcesOnStartup())
106  {
107  resetSourceTerms();
108  }
109 }
110 
111 
112 template<class CloudType>
114 (
116  const word& name
117 )
118 :
119  CloudType(c, name),
121  cloudCopyPtr_(nullptr),
122  constProps_(c.constProps_),
123  devolatilisationModel_(c.devolatilisationModel_->clone()),
124  surfaceReactionModel_(c.surfaceReactionModel_->clone()),
125  dMassDevolatilisation_(c.dMassDevolatilisation_),
126  dMassSurfaceReaction_(c.dMassSurfaceReaction_)
127 {}
128 
129 
130 template<class CloudType>
132 (
133  const fvMesh& mesh,
134  const word& name,
136 )
137 :
138  CloudType(mesh, name, c),
140  cloudCopyPtr_(nullptr),
141  constProps_(),
142  devolatilisationModel_(nullptr),
143  surfaceReactionModel_(nullptr),
144  dMassDevolatilisation_(0.0),
145  dMassSurfaceReaction_(0.0)
146 {}
147 
148 
149 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
150 
151 template<class CloudType>
153 {}
154 
155 
156 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
157 
158 template<class CloudType>
160 (
161  parcelType& parcel,
162  const scalar lagrangianDt
163 )
164 {
165  CloudType::setParcelThermoProperties(parcel, lagrangianDt);
166 
167  label idGas = this->composition().idGas();
168  label idLiquid = this->composition().idLiquid();
169  label idSolid = this->composition().idSolid();
170 
171  parcel.YGas() = this->composition().Y0(idGas);
172  parcel.YLiquid() = this->composition().Y0(idLiquid);
173  parcel.YSolid() = this->composition().Y0(idSolid);
174 }
175 
176 
177 template<class CloudType>
179 (
180  parcelType& parcel,
181  const scalar lagrangianDt,
182  const bool fullyDescribed
183 )
184 {
185  CloudType::checkParcelProperties(parcel, lagrangianDt, fullyDescribed);
186 
187  if (fullyDescribed)
188  {
189  label idGas = this->composition().idGas();
190  label idLiquid = this->composition().idLiquid();
191  label idSolid = this->composition().idSolid();
192 
193  this->checkSuppliedComposition
194  (
195  parcel.YGas(),
196  this->composition().Y0(idGas),
197  "YGas"
198  );
199  this->checkSuppliedComposition
200  (
201  parcel.YLiquid(),
202  this->composition().Y0(idLiquid),
203  "YLiquid"
204  );
205  this->checkSuppliedComposition
206  (
207  parcel.YSolid(),
208  this->composition().Y0(idSolid),
209  "YSolid"
210  );
211  }
212 }
213 
214 
215 template<class CloudType>
217 {
218  cloudCopyPtr_.reset
219  (
221  (
222  clone(this->name() + "Copy").ptr()
223  )
224  );
225 }
226 
227 
228 template<class CloudType>
230 {
231  cloudReset(cloudCopyPtr_());
232  cloudCopyPtr_.clear();
233 }
234 
235 
236 template<class CloudType>
238 {
239  CloudType::resetSourceTerms();
240 }
241 
242 
243 template<class CloudType>
245 {
246  if (this->solution().canEvolve())
247  {
248  typename parcelType::trackingData td(*this);
249 
250  this->solve(*this, td);
251  }
252 }
253 
254 
255 template<class CloudType>
257 (
258  const mapPolyMesh& mapper
259 )
260 {
262 
263  this->updateMesh();
264 }
265 
266 
267 template<class CloudType>
269 {
270  CloudType::info();
271 
272  this->devolatilisation().info(Info);
273  this->surfaceReaction().info(Info);
274 }
275 
276 
277 template<class CloudType>
279 {
280  if (this->compositionModel_.valid())
281  {
282  CloudType::particleType::writeFields(*this, this->composition());
283  }
284 }
285 
286 
287 // ************************************************************************* //
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
DSMCCloud< dsmcParcel > CloudType
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
void setModels()
Set cloud sub-models.
basicSpecieMixture & composition
parcelType::constantProperties constProps_
Parcel constant properties.
autoPtr< SurfaceReactionModel< ReactingMultiphaseCloud< CloudType > > > surfaceReactionModel_
Surface reaction model.
Templated base class for multiphase reacting cloud.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:158
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
void cloudReset(ReactingMultiphaseCloud< CloudType > &c)
Reset state of cloud.
void restoreState()
Reset the current cloud to the previously stored state.
virtual void autoMap(const mapPolyMesh &)
Remap the cells of particles corresponding to the.
A class for handling words, derived from string.
Definition: word.H:59
rhoEqn solve()
void resetSourceTerms()
Reset the cloud source terms.
Thermo package for (S)olids (L)iquids and (G)ases Takes reference to thermo package, and provides:
Definition: SLGThermo.H:62
Base cloud calls templated on particle type.
Definition: Cloud.H:52
ParcelType parcelType
Type of parcel the cloud was instantiated for.
Definition: DSMCCloud.H:218
void storeState()
Store the current cloud state.
Virtual abstract base class for templated reactingMultiphaseCloud.
virtual ~ReactingMultiphaseCloud()
Destructor.
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
autoPtr< DevolatilisationModel< ReactingMultiphaseCloud< CloudType > > > devolatilisationModel_
Devolatilisation model.
void setParcelThermoProperties(parcelType &parcel, const scalar lagrangianDt)
Set parcel thermo properties.
virtual void writeFields() const
Write the field data for the cloud.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
scalar dMassDevolatilisation_
Total mass transferred to continuous phase via devolatilisation.
void checkParcelProperties(parcelType &parcel, const scalar lagrangianDt, const bool fullyDescribed)
Check parcel properties.
messageStream Info
Templated devolatilisation model class.
Selector class for relaxation factors, solver type and solution.
Definition: solution.H:48
void info()
Print cloud information.
scalar dMassSurfaceReaction_
Total mass transferred to continuous phase via surface.
Templated surface reaction model class.