ReactingMultiphaseCloud.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2011-2016 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_(NULL),
88  constProps_(this->particleProperties()),
89  devolatilisationModel_(NULL),
90  surfaceReactionModel_(NULL),
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  }
102  }
103 
104  if (this->solution().resetSourcesOnStartup())
105  {
106  resetSourceTerms();
107  }
108 }
109 
110 
111 template<class CloudType>
113 (
115  const word& name
116 )
117 :
118  CloudType(c, name),
120  cloudCopyPtr_(NULL),
121  constProps_(c.constProps_),
122  devolatilisationModel_(c.devolatilisationModel_->clone()),
123  surfaceReactionModel_(c.surfaceReactionModel_->clone()),
124  dMassDevolatilisation_(c.dMassDevolatilisation_),
125  dMassSurfaceReaction_(c.dMassSurfaceReaction_)
126 {}
127 
128 
129 template<class CloudType>
131 (
132  const fvMesh& mesh,
133  const word& name,
135 )
136 :
137  CloudType(mesh, name, c),
139  cloudCopyPtr_(NULL),
140  constProps_(),
141  devolatilisationModel_(NULL),
142  surfaceReactionModel_(NULL),
143  dMassDevolatilisation_(0.0),
144  dMassSurfaceReaction_(0.0)
145 {}
146 
147 
148 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
149 
150 template<class CloudType>
152 {}
153 
154 
155 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
156 
157 template<class CloudType>
159 (
160  parcelType& parcel,
161  const scalar lagrangianDt
162 )
163 {
164  CloudType::setParcelThermoProperties(parcel, lagrangianDt);
165 
166  label idGas = this->composition().idGas();
167  label idLiquid = this->composition().idLiquid();
168  label idSolid = this->composition().idSolid();
169 
170  parcel.YGas() = this->composition().Y0(idGas);
171  parcel.YLiquid() = this->composition().Y0(idLiquid);
172  parcel.YSolid() = this->composition().Y0(idSolid);
173 }
174 
175 
176 template<class CloudType>
178 (
179  parcelType& parcel,
180  const scalar lagrangianDt,
181  const bool fullyDescribed
182 )
183 {
184  CloudType::checkParcelProperties(parcel, lagrangianDt, fullyDescribed);
185 
186  if (fullyDescribed)
187  {
188  label idGas = this->composition().idGas();
189  label idLiquid = this->composition().idLiquid();
190  label idSolid = this->composition().idSolid();
191 
192  this->checkSuppliedComposition
193  (
194  parcel.YGas(),
195  this->composition().Y0(idGas),
196  "YGas"
197  );
198  this->checkSuppliedComposition
199  (
200  parcel.YLiquid(),
201  this->composition().Y0(idLiquid),
202  "YLiquid"
203  );
204  this->checkSuppliedComposition
205  (
206  parcel.YSolid(),
207  this->composition().Y0(idSolid),
208  "YSolid"
209  );
210  }
211 }
212 
213 
214 template<class CloudType>
216 {
217  cloudCopyPtr_.reset
218  (
220  (
221  clone(this->name() + "Copy").ptr()
222  )
223  );
224 }
225 
226 
227 template<class CloudType>
229 {
230  cloudReset(cloudCopyPtr_());
231  cloudCopyPtr_.clear();
232 }
233 
234 
235 template<class CloudType>
237 {
238  CloudType::resetSourceTerms();
239 }
240 
241 
242 template<class CloudType>
244 {
245  if (this->solution().canEvolve())
246  {
247  typename parcelType::template
248  TrackingData<ReactingMultiphaseCloud<CloudType>> td(*this);
249 
250  this->solve(td);
251  }
252 }
253 
254 
255 template<class CloudType>
257 (
258  const mapPolyMesh& mapper
259 )
260 {
262  tdType;
263 
264  tdType td(*this);
265 
266  Cloud<parcelType>::template autoMap<tdType>(td, mapper);
267 
268  this->updateMesh();
269 }
270 
271 
272 template<class CloudType>
274 {
275  CloudType::info();
276 
277  this->devolatilisation().info(Info);
278  this->surfaceReaction().info(Info);
279 }
280 
281 
282 template<class CloudType>
284 {
285  if (this->size())
286  {
287  CloudType::particleType::writeFields(*this, this->composition());
288  }
289 }
290 
291 
292 // ************************************************************************* //
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 setModels()
Set cloud sub-models.
basicMultiComponentMixture & 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
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
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
virtual void writeFields() const
Write the field data for the cloud.
Base cloud calls templated on particle type.
Definition: Cloud.H:52
ParcelType parcelType
Type of parcel the cloud was instantiated for.
Definition: DSMCCloud.H:217
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.
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.