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 "ReactingCloud.H"
28 #include "CompositionModel.H"
29 #include "PhaseChangeModel.H"
31 // * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * * //
33 template<class CloudType>
34 void Foam::ReactingCloud<CloudType>::setModels()
36 compositionModel_.reset
38 CompositionModel<ReactingCloud<CloudType> >::New
40 this->subModelProperties(),
45 phaseChangeModel_.reset
47 PhaseChangeModel<ReactingCloud<CloudType> >::New
49 this->subModelProperties(),
56 template<class CloudType>
57 void Foam::ReactingCloud<CloudType>::checkSuppliedComposition
59 const scalarField& YSupplied,
64 if (YSupplied.size() != Y.size())
68 "ReactingCloud<CloudType>::checkSuppliedComposition"
70 "const scalarField&, "
71 "const scalarField&, "
74 ) << YName << " supplied, but size is not compatible with "
75 << "parcel composition: " << nl << " "
76 << YName << "(" << YSupplied.size() << ") vs required composition "
77 << YName << "(" << Y.size() << ")" << nl
83 template<class CloudType>
84 void Foam::ReactingCloud<CloudType>::cloudReset(ReactingCloud<CloudType>& c)
86 CloudType::cloudReset(c);
88 compositionModel_.reset(c.compositionModel_.ptr());
89 phaseChangeModel_.reset(c.phaseChangeModel_.ptr());
91 dMassPhaseChange_ = c.dMassPhaseChange_;
95 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
97 template<class CloudType>
98 Foam::ReactingCloud<CloudType>::ReactingCloud
100 const word& cloudName,
101 const volScalarField& rho,
102 const volVectorField& U,
103 const dimensionedVector& g,
104 const SLGThermo& thermo,
108 CloudType(cloudName, rho, U, g, thermo, false),
111 constProps_(this->particleProperties(), this->solution().active()),
112 compositionModel_(NULL),
113 phaseChangeModel_(NULL),
114 rhoTrans_(thermo.carrier().species().size()),
115 dMassPhaseChange_(0.0)
117 if (this->solution().active())
123 parcelType::readFields(*this, this->composition());
127 // Set storage for mass source fields and initialise to zero
130 const word& specieName = thermo.carrier().species()[i];
134 new DimensionedField<scalar, volMesh>
138 this->name() + "rhoTrans_" + specieName,
139 this->db().time().timeName(),
141 IOobject::READ_IF_PRESENT,
145 dimensionedScalar("zero", dimMass, 0.0)
150 if (this->solution().resetSourcesOnStartup())
157 template<class CloudType>
158 Foam::ReactingCloud<CloudType>::ReactingCloud
160 ReactingCloud<CloudType>& c,
167 constProps_(c.constProps_),
168 compositionModel_(c.compositionModel_->clone()),
169 phaseChangeModel_(c.phaseChangeModel_->clone()),
170 rhoTrans_(c.rhoTrans_.size()),
171 dMassPhaseChange_(c.dMassPhaseChange_)
173 forAll(c.rhoTrans_, i)
175 const word& specieName = this->thermo().carrier().species()[i];
179 new DimensionedField<scalar, volMesh>
183 this->name() + "rhoTrans_" + specieName,
184 this->db().time().timeName(),
197 template<class CloudType>
198 Foam::ReactingCloud<CloudType>::ReactingCloud
202 const ReactingCloud<CloudType>& c
205 CloudType(mesh, name, c),
209 compositionModel_(c.compositionModel_->clone()),
210 // compositionModel_(NULL),
211 phaseChangeModel_(NULL),
213 dMassPhaseChange_(0.0)
217 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
219 template<class CloudType>
220 Foam::ReactingCloud<CloudType>::~ReactingCloud()
224 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
226 template<class CloudType>
227 void Foam::ReactingCloud<CloudType>::setParcelThermoProperties
230 const scalar lagrangianDt
233 CloudType::setParcelThermoProperties(parcel, lagrangianDt);
235 parcel.pc() = this->thermo().thermo().p()[parcel.cell()];
236 parcel.Y() = composition().YMixture0();
240 template<class CloudType>
241 void Foam::ReactingCloud<CloudType>::checkParcelProperties
244 const scalar lagrangianDt,
245 const bool fullyDescribed
248 CloudType::checkParcelProperties(parcel, lagrangianDt, fullyDescribed);
252 checkSuppliedComposition
255 composition().YMixture0(),
260 // derived information - store initial mass
261 parcel.mass0() = parcel.mass();
265 template<class CloudType>
266 void Foam::ReactingCloud<CloudType>::storeState()
270 static_cast<ReactingCloud<CloudType>*>
272 clone(this->name() + "Copy").ptr()
278 template<class CloudType>
279 void Foam::ReactingCloud<CloudType>::restoreState()
281 cloudReset(cloudCopyPtr_());
282 cloudCopyPtr_.clear();
286 template<class CloudType>
287 void Foam::ReactingCloud<CloudType>::resetSourceTerms()
289 CloudType::resetSourceTerms();
292 rhoTrans_[i].field() = 0.0;
297 template<class CloudType>
298 void Foam::ReactingCloud<CloudType>::relaxSources
300 const ReactingCloud<CloudType>& cloudOldTime
303 CloudType::relaxSources(cloudOldTime);
305 typedef DimensionedField<scalar, volMesh> dsfType;
307 forAll(rhoTrans_, fieldI)
309 dsfType& rhoT = rhoTrans_[fieldI];
310 const dsfType& rhoT0 = cloudOldTime.rhoTrans()[fieldI];
311 this->relax(rhoT, rhoT0, "rho");
316 template<class CloudType>
317 void Foam::ReactingCloud<CloudType>::scaleSources()
319 CloudType::scaleSources();
321 typedef DimensionedField<scalar, volMesh> dsfType;
323 forAll(rhoTrans_, fieldI)
325 dsfType& rhoT = rhoTrans_[fieldI];
326 this->scale(rhoT, "rho");
331 template<class CloudType>
332 void Foam::ReactingCloud<CloudType>::evolve()
334 if (this->solution().canEvolve())
336 typename parcelType::template
337 TrackingData<ReactingCloud<CloudType> > td(*this);
344 template<class CloudType>
345 void Foam::ReactingCloud<CloudType>::addToMassPhaseChange(const scalar dMass)
347 dMassPhaseChange_ += dMass;
351 template<class CloudType>
352 void Foam::ReactingCloud<CloudType>::info() const
356 Info<< " Mass transfer phase change = "
357 << returnReduce(dMassPhaseChange_, sumOp<scalar>()) << nl;
361 template<class CloudType>
362 void Foam::ReactingCloud<CloudType>::writeFields() const
366 CloudType::particleType::writeFields(*this, this->composition());
371 // ************************************************************************* //