Initial commit for version 2.0.x patch release
[OpenFOAM-2.0.x.git] / src / lagrangian / intermediate / clouds / Templates / ReactingMultiphaseCloud / ReactingMultiphaseCloud.C
blob9813318ba1d9671513155d55ed00bd04e6010379
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2008-2011 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
19     for more details.
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
37     (
38         DevolatilisationModel<ReactingMultiphaseCloud<CloudType> >::New
39         (
40             this->subModelProperties(),
41             *this
42         ).ptr()
43     );
45     surfaceReactionModel_.reset
46     (
47         SurfaceReactionModel<ReactingMultiphaseCloud<CloudType> >::New
48         (
49             this->subModelProperties(),
50             *this
51         ).ptr()
52     );
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,
82     bool readFields
85     CloudType(cloudName, rho, U, g, thermo, false),
86     reactingMultiphaseCloud(),
87     cloudCopyPtr_(NULL),
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())
95     {
96         setModels();
98         if (readFields)
99         {
100             parcelType::readFields(*this, this->composition());
101         }
102     }
104     if (this->solution().resetSourcesOnStartup())
105     {
106         resetSourceTerms();
107     }
111 template<class CloudType>
112 Foam::ReactingMultiphaseCloud<CloudType>::ReactingMultiphaseCloud
114     ReactingMultiphaseCloud<CloudType>& c,
115     const word& name
118     CloudType(c, name),
119     reactingMultiphaseCloud(),
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_)
129 template<class CloudType>
130 Foam::ReactingMultiphaseCloud<CloudType>::ReactingMultiphaseCloud
132     const fvMesh& mesh,
133     const word& name,
134     const ReactingMultiphaseCloud<CloudType>& c
137     CloudType(mesh, name, c),
138     reactingMultiphaseCloud(),
139     cloudCopyPtr_(NULL),
140     constProps_(),
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
160     parcelType& parcel,
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
179     parcelType& parcel,
180     const scalar lagrangianDt,
181     const bool fullyDescribed
184     CloudType::checkParcelProperties(parcel, lagrangianDt, fullyDescribed);
186     if (fullyDescribed)
187     {
188         label idGas = this->composition().idGas();
189         label idLiquid = this->composition().idLiquid();
190         label idSolid = this->composition().idSolid();
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     }
214 template<class CloudType>
215 void Foam::ReactingMultiphaseCloud<CloudType>::storeState()
217     cloudCopyPtr_.reset
218     (
219         static_cast<ReactingMultiphaseCloud<CloudType>*>
220         (
221             clone(this->name() + "Copy").ptr()
222         )
223     );
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())
246     {
247         typename parcelType::template
248             TrackingData<ReactingMultiphaseCloud<CloudType> > td(*this);
250         this->solve(td);
251     }
255 template<class CloudType>
256 void Foam::ReactingMultiphaseCloud<CloudType>::addToMassDevolatilisation
258     const scalar dMass
261     dMassDevolatilisation_ += dMass;
265 template<class CloudType>
266 void Foam::ReactingMultiphaseCloud<CloudType>::addToMassSurfaceReaction
268     const scalar dMass
271     dMassSurfaceReaction_ += dMass;
275 template<class CloudType>
276 void Foam::ReactingMultiphaseCloud<CloudType>::info() const
278     CloudType::info();
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
289     if (this->size())
290     {
291         CloudType::particleType::writeFields(*this, this->composition());
292     }
296 // ************************************************************************* //