1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2008 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 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
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"
28 #include "CompositionModel.H"
29 #include "MassTransferModel.H"
30 #include "SurfaceReactionModel.H"
32 #include "interpolationCellPoint.H"
34 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
36 template<class ParcelType>
37 Foam::ReactingCloud<ParcelType>::ReactingCloud
39 const word& cloudType,
40 const volPointInterpolation& vpi,
41 const volScalarField& rho,
42 const volVectorField& U,
43 const dimensionedVector& g,
44 hCombustionThermo& thermo,
45 PtrList<specieReactingProperties>& gases
48 ThermoCloud<ParcelType>(cloudType, vpi, rho, U, g, thermo),
50 constProps_(this->particleProperties()),
51 carrierThermo_(thermo),
55 CompositionModel<ReactingCloud<ParcelType> >::New
57 this->particleProperties(),
63 MassTransferModel<ReactingCloud<ParcelType> >::New
65 this->particleProperties(),
71 SurfaceReactionModel<ReactingCloud<ParcelType> >::New
73 this->particleProperties(),
77 rhoTrans_(thermo.composition().Y().size())
79 // Set storage for mass source fields and initialise to zero
85 new DimensionedField<scalar, volMesh>
89 this->name() + "rhoTrans" + Foam::name(i),
90 this->db().time().timeName(),
97 dimensionedScalar("zero", dimMass, 0.0)
104 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
106 template<class ParcelType>
107 Foam::ReactingCloud<ParcelType>::~ReactingCloud()
111 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
113 template<class ParcelType>
114 void Foam::ReactingCloud<ParcelType>::resetSourceTerms()
116 ThermoCloud<ParcelType>::resetSourceTerms();
119 rhoTrans_[i].field() = 0.0;
124 template<class ParcelType>
125 void Foam::ReactingCloud<ParcelType>::evolve()
127 const volScalarField& T = carrierThermo_.T();
128 const volScalarField cp = carrierThermo_.Cp();
129 const volScalarField& p = carrierThermo_.p();
131 autoPtr<interpolation<scalar> > rhoInterpolator = interpolation<scalar>::New
133 this->interpolationSchemes(),
138 autoPtr<interpolation<vector> > UInterpolator = interpolation<vector>::New
140 this->interpolationSchemes(),
145 autoPtr<interpolation<scalar> > muInterpolator = interpolation<scalar>::New
147 this->interpolationSchemes(),
152 autoPtr<interpolation<scalar> > TInterpolator = interpolation<scalar>::New
154 this->interpolationSchemes(),
159 autoPtr<interpolation<scalar> > cpInterpolator = interpolation<scalar>::New
161 this->interpolationSchemes(),
166 autoPtr<interpolation<scalar> > pInterpolator = interpolation<scalar>::New
168 this->interpolationSchemes(),
173 typename ParcelType::trackData td
193 Cloud<ParcelType>::move(td);
197 template<class ParcelType>
198 template<class TrackingData>
199 void Foam::ReactingCloud<ParcelType>::inject
204 scalar time = this->db().time().value();
206 scalar pRho = td.constProps().rho0();
208 this->injection().prepareForNextTimeStep(this->time0(), time);
210 // Number of parcels to introduce during this timestep
211 const label nParcels = this->injection().nParcels();
213 // Return if no parcels are required
216 this->postInjectCheck();
220 // Volume of particles to introduce during this timestep
221 scalar pVolume = this->injection().volume();
223 // Volume fraction to introduce during this timestep
224 scalar pVolumeFraction = this->injection().volumeFraction();
226 // Duration of injection period during this timestep
229 this->db().time().deltaT().value(),
232 time - this->injection().timeStart(),
233 this->injection().timeEnd() - this->time0()
237 // Pad injection time if injection starts during this timestep
241 this->injection().timeStart() - this->time0()
244 // Introduce new parcels linearly with time
245 for (label iParcel=0; iParcel<nParcels; iParcel++)
247 // Calculate the pseudo time of injection for parcel 'iParcel'
248 scalar timeInj = this->time0() + padTime + deltaT*iParcel/nParcels;
250 // Determine injected parcel properties
251 vector pPosition = this->injection().position
258 // Diameter of parcels
259 scalar pDiameter = this->injection().d0(iParcel, timeInj);
261 // Number of particles per parcel
262 scalar pNumberOfParticles = this->setNumberOfParticles
271 // Velocity of parcels
272 vector pU = this->injection().velocity
279 // Determine the injection cell
281 this->setInjectorCellAndPosition(pCell, pPosition);
285 // construct the parcel that is to be injected
286 ParcelType* pPtr = new ParcelType
289 this->parcelTypeId(),
295 composition().YGas0(),
296 composition().YLiquid0(),
297 composition().YSolid0(),
298 composition().YMixture0(),
302 scalar dt = time - timeInj;
304 pPtr->stepFraction() = (this->db().time().deltaT().value() - dt)
305 /this->db().time().deltaT().value();
307 this->injectParcel(td, pPtr);
311 this->postInjectCheck();
315 this->dumpParticlePositions();
320 // ************************************************************************* //