initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / lagrangian / intermediate / clouds / Templates / ReactingCloud / ReactingCloud.C
blob1e58d2876cc52a74661e11277a2b933524e1d475
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 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 the
13     Free Software Foundation; either version 2 of the License, or (at your
14     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, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "ReactingCloud.H"
29 #include "CompositionModel.H"
30 #include "PhaseChangeModel.H"
32 // * * * * * * * * * * * Protected Member Functions  * * * * * * * * * * * * //
34 template<class ParcelType>
35 void Foam::ReactingCloud<ParcelType>::checkSuppliedComposition
37     const scalarField& YSupplied,
38     const scalarField& Y,
39     const word& YName
42     if (YSupplied.size() != Y.size())
43     {
44         FatalErrorIn
45         (
46             "ReactingCloud<ParcelType>::checkSuppliedComposition"
47             "("
48                 "const scalarField&, "
49                 "const scalarField&, "
50                 "const word&"
51             ")"
52         )   << YName << " supplied, but size is not compatible with "
53             << "parcel composition: " << nl << "    "
54             << YName << "(" << YSupplied.size() << ") vs required composition "
55             << YName << "(" << Y.size() << ")" << nl
56             << abort(FatalError);
57     }
61 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
63 template<class ParcelType>
64 Foam::ReactingCloud<ParcelType>::ReactingCloud
66     const word& cloudName,
67     const volScalarField& rho,
68     const volVectorField& U,
69     const dimensionedVector& g,
70     basicThermo& thermo
73     ThermoCloud<ParcelType>(cloudName, rho, U, g, thermo),
74     reactingCloud(),
75     constProps_(this->particleProperties()),
76     mcCarrierThermo_
77     (
78         dynamic_cast<multiComponentMixture<thermoType>&>(thermo)
79     ),
80     compositionModel_
81     (
82         CompositionModel<ReactingCloud<ParcelType> >::New
83         (
84             this->particleProperties(),
85             *this
86         )
87     ),
88     phaseChangeModel_
89     (
90         PhaseChangeModel<ReactingCloud<ParcelType> >::New
91         (
92             this->particleProperties(),
93             *this
94         )
95     ),
96     rhoTrans_(mcCarrierThermo_.species().size()),
97     dMassPhaseChange_(0.0)
99     // Set storage for mass source fields and initialise to zero
100     forAll(rhoTrans_, i)
101     {
102         rhoTrans_.set
103         (
104             i,
105             new DimensionedField<scalar, volMesh>
106             (
107                 IOobject
108                 (
109                     this->name() + "rhoTrans_" + mcCarrierThermo_.species()[i],
110                     this->db().time().timeName(),
111                     this->db(),
112                     IOobject::NO_READ,
113                     IOobject::NO_WRITE,
114                     false
115                 ),
116                 this->mesh(),
117                 dimensionedScalar("zero", dimMass, 0.0)
118             )
119         );
120     }
124 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
126 template<class ParcelType>
127 Foam::ReactingCloud<ParcelType>::~ReactingCloud()
131 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
133 template<class ParcelType>
134 void Foam::ReactingCloud<ParcelType>::checkParcelProperties
136     ParcelType& parcel,
137     const scalar lagrangianDt,
138     const bool fullyDescribed
141     ThermoCloud<ParcelType>::checkParcelProperties
142     (
143         parcel,
144         lagrangianDt,
145         fullyDescribed
146     );
148     if (!fullyDescribed)
149     {
150         parcel.Y() = composition().YMixture0();
151     }
152     else
153     {
154         checkSuppliedComposition
155         (
156             parcel.Y(),
157             composition().YMixture0(),
158             "YMixture"
159         );
160     }
162     // derived information - store initial mass
163     parcel.mass0() = parcel.mass();
167 template<class ParcelType>
168 void Foam::ReactingCloud<ParcelType>::resetSourceTerms()
170     ThermoCloud<ParcelType>::resetSourceTerms();
171     forAll(rhoTrans_, i)
172     {
173         rhoTrans_[i].field() = 0.0;
174     }
178 template<class ParcelType>
179 void Foam::ReactingCloud<ParcelType>::preEvolve()
181     ThermoCloud<ParcelType>::preEvolve();
185 template<class ParcelType>
186 void Foam::ReactingCloud<ParcelType>::postEvolve()
188     ThermoCloud<ParcelType>::postEvolve();
192 template<class ParcelType>
193 void Foam::ReactingCloud<ParcelType>::evolve()
195     preEvolve();
197     const volScalarField& T = this->carrierThermo().T();
198     const volScalarField cp = this->carrierThermo().Cp();
199     const volScalarField& p = this->carrierThermo().p();
201     autoPtr<interpolation<scalar> > rhoInterp = interpolation<scalar>::New
202     (
203         this->interpolationSchemes(),
204         this->rho()
205     );
207     autoPtr<interpolation<vector> > UInterp = interpolation<vector>::New
208     (
209         this->interpolationSchemes(),
210         this->U()
211     );
213     autoPtr<interpolation<scalar> > muInterp = interpolation<scalar>::New
214     (
215         this->interpolationSchemes(),
216         this->mu()
217     );
219     autoPtr<interpolation<scalar> > TInterp = interpolation<scalar>::New
220     (
221         this->interpolationSchemes(),
222         T
223     );
225     autoPtr<interpolation<scalar> > cpInterp = interpolation<scalar>::New
226     (
227         this->interpolationSchemes(),
228         cp
229     );
231     autoPtr<interpolation<scalar> > pInterp = interpolation<scalar>::New
232     (
233         this->interpolationSchemes(),
234         p
235     );
237     typename ParcelType::trackData td
238     (
239         *this,
240         constProps_,
241         rhoInterp(),
242         UInterp(),
243         muInterp(),
244         TInterp(),
245         cpInterp(),
246         pInterp(),
247         this->g().value()
248     );
250     this->injection().inject(td);
252     if (this->coupled())
253     {
254         resetSourceTerms();
255     }
257     Cloud<ParcelType>::move(td);
259     postEvolve();
263 template<class ParcelType>
264 void Foam::ReactingCloud<ParcelType>::info() const
266     ThermoCloud<ParcelType>::info();
268     Info<< "    Mass transfer phase change      = "
269         << returnReduce(dMassPhaseChange_, sumOp<scalar>()) << nl;
273 template<class ParcelType>
274 void Foam::ReactingCloud<ParcelType>::addToMassPhaseChange(const scalar dMass)
276     dMassPhaseChange_ += dMass;
280 // ************************************************************************* //