1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
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.
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
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/>.
24 \*---------------------------------------------------------------------------*/
26 #include "ReactingMultiphaseCloud.H"
28 #include "DevolatilisationModel.H"
29 #include "SurfaceReactionModel.H"
31 // * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
33 template<class CloudType>
34 void Foam::ReactingMultiphaseCloud<CloudType>::setModels()
36 devolatilisationModel_.reset
38 DevolatilisationModel<ReactingMultiphaseCloud<CloudType> >::New
40 this->subModelProperties(),
45 surfaceReactionModel_.reset
47 SurfaceReactionModel<ReactingMultiphaseCloud<CloudType> >::New
49 this->subModelProperties(),
56 template<class CloudType>
57 void Foam::ReactingMultiphaseCloud<CloudType>::cloudReset
59 ReactingMultiphaseCloud<CloudType>& c
62 CloudType::cloudReset(c);
64 devolatilisationModel_.reset(c.devolatilisationModel_.ptr());
65 surfaceReactionModel_.reset(c.surfaceReactionModel_.ptr());
67 dMassDevolatilisation_ = c.dMassDevolatilisation_;
68 dMassSurfaceReaction_ = c.dMassSurfaceReaction_;
72 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
74 template<class CloudType>
75 Foam::ReactingMultiphaseCloud<CloudType>::ReactingMultiphaseCloud
77 const word& cloudName,
78 const volScalarField& rho,
79 const volVectorField& U,
80 const dimensionedVector& g,
81 const SLGThermo& thermo,
85 CloudType(cloudName, rho, U, g, thermo, false),
86 reactingMultiphaseCloud(),
88 constProps_(this->particleProperties(), this->solution().active()),
89 devolatilisationModel_(NULL),
90 surfaceReactionModel_(NULL),
91 dMassDevolatilisation_(0.0),
92 dMassSurfaceReaction_(0.0)
94 if (this->solution().active())
100 parcelType::readFields(*this, this->composition());
104 if (this->solution().resetSourcesOnStartup())
111 template<class CloudType>
112 Foam::ReactingMultiphaseCloud<CloudType>::ReactingMultiphaseCloud
114 ReactingMultiphaseCloud<CloudType>& c,
119 reactingMultiphaseCloud(),
121 constProps_(c.constProps_),
122 devolatilisationModel_(c.devolatilisationModel_->clone()),
123 surfaceReactionModel_(c.surfaceReactionModel_->clone()),
124 dMassDevolatilisation_(c.dMassDevolatilisation_),
125 dMassSurfaceReaction_(c.dMassSurfaceReaction_)
129 template<class CloudType>
130 Foam::ReactingMultiphaseCloud<CloudType>::ReactingMultiphaseCloud
134 const ReactingMultiphaseCloud<CloudType>& c
137 CloudType(mesh, name, c),
138 reactingMultiphaseCloud(),
141 devolatilisationModel_(NULL),
142 surfaceReactionModel_(NULL),
143 dMassDevolatilisation_(0.0),
144 dMassSurfaceReaction_(0.0)
148 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
150 template<class CloudType>
151 Foam::ReactingMultiphaseCloud<CloudType>::~ReactingMultiphaseCloud()
155 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
157 template<class CloudType>
158 void Foam::ReactingMultiphaseCloud<CloudType>::setParcelThermoProperties
161 const scalar lagrangianDt
164 CloudType::setParcelThermoProperties(parcel, lagrangianDt);
166 label idGas = this->composition().idGas();
167 label idLiquid = this->composition().idLiquid();
168 label idSolid = this->composition().idSolid();
170 parcel.YGas() = this->composition().Y0(idGas);
171 parcel.YLiquid() = this->composition().Y0(idLiquid);
172 parcel.YSolid() = this->composition().Y0(idSolid);
176 template<class CloudType>
177 void Foam::ReactingMultiphaseCloud<CloudType>::checkParcelProperties
180 const scalar lagrangianDt,
181 const bool fullyDescribed
184 CloudType::checkParcelProperties(parcel, lagrangianDt, fullyDescribed);
188 label idGas = this->composition().idGas();
189 label idLiquid = this->composition().idLiquid();
190 label idSolid = this->composition().idSolid();
192 this->checkSuppliedComposition
195 this->composition().Y0(idGas),
198 this->checkSuppliedComposition
201 this->composition().Y0(idLiquid),
204 this->checkSuppliedComposition
207 this->composition().Y0(idSolid),
214 template<class CloudType>
215 void Foam::ReactingMultiphaseCloud<CloudType>::storeState()
219 static_cast<ReactingMultiphaseCloud<CloudType>*>
221 clone(this->name() + "Copy").ptr()
227 template<class CloudType>
228 void Foam::ReactingMultiphaseCloud<CloudType>::restoreState()
230 cloudReset(cloudCopyPtr_());
231 cloudCopyPtr_.clear();
235 template<class CloudType>
236 void Foam::ReactingMultiphaseCloud<CloudType>::resetSourceTerms()
238 CloudType::resetSourceTerms();
242 template<class CloudType>
243 void Foam::ReactingMultiphaseCloud<CloudType>::evolve()
245 if (this->solution().canEvolve())
247 typename parcelType::template
248 TrackingData<ReactingMultiphaseCloud<CloudType> > td(*this);
255 template<class CloudType>
256 void Foam::ReactingMultiphaseCloud<CloudType>::addToMassDevolatilisation
261 dMassDevolatilisation_ += dMass;
265 template<class CloudType>
266 void Foam::ReactingMultiphaseCloud<CloudType>::addToMassSurfaceReaction
271 dMassSurfaceReaction_ += dMass;
275 template<class CloudType>
276 void Foam::ReactingMultiphaseCloud<CloudType>::info() const
279 Info<< " Mass transfer devolatilisation = "
280 << returnReduce(dMassDevolatilisation_, sumOp<scalar>()) << nl;
281 Info<< " Mass transfer surface reaction = "
282 << returnReduce(dMassSurfaceReaction_, sumOp<scalar>()) << nl;
286 template<class CloudType>
287 void Foam::ReactingMultiphaseCloud<CloudType>::writeFields() const
291 CloudType::particleType::writeFields(*this, this->composition());
296 // ************************************************************************* //