OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

ReactingLookupTableInjection.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 2008-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 \*---------------------------------------------------------------------------*/
00026 
00027 #include "ReactingLookupTableInjection.H"
00028 #include "scalarIOList.H"
00029 
00030 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
00031 
00032 template<class CloudType>
00033 Foam::label Foam::ReactingLookupTableInjection<CloudType>::INPUT_FILE_COLS = 12;
00034 
00035 // * * * * * * * * * * * * Protected Member Functions  * * * * * * * * * * * //
00036 
00037 template<class CloudType>
00038 Foam::label Foam::ReactingLookupTableInjection<CloudType>::parcelsToInject
00039 (
00040     const scalar time0,
00041     const scalar time1
00042 ) const
00043 {
00044     if ((time0 >= 0.0) && (time0 < duration_))
00045     {
00046         return round(injectorCells_.size()*(time1 - time0)*nParcelsPerSecond_);
00047     }
00048     else
00049     {
00050         return 0;
00051     }
00052 }
00053 
00054 
00055 template<class CloudType>
00056 Foam::scalar Foam::ReactingLookupTableInjection<CloudType>::volumeToInject
00057 (
00058     const scalar time0,
00059     const scalar time1
00060 ) const
00061 {
00062     scalar volume = 0.0;
00063     if ((time0 >= 0.0) && (time0 < duration_))
00064     {
00065         forAll(mDot_, injectorI)
00066         {
00067             volume += mDot_[injectorI]/rho_[injectorI]*(time1 - time0);
00068         }
00069     }
00070 
00071     return volume;
00072 }
00073 
00074 
00075 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00076 
00077 template<class CloudType>
00078 Foam::ReactingLookupTableInjection<CloudType>::ReactingLookupTableInjection
00079 (
00080     const dictionary& dict,
00081     CloudType& owner
00082 )
00083 :
00084     InjectionModel<CloudType>(dict, owner, typeName),
00085     inputFileName_(this->coeffDict().lookup("inputFile")),
00086     duration_(readScalar(this->coeffDict().lookup("duration"))),
00087     nParcelsPerSecond_
00088     (
00089         readScalar(this->coeffDict().lookup("parcelsPerSecond"))
00090     ),
00091     x_(0),
00092     U_(0),
00093     d_(0),
00094     rho_(0),
00095     mDot_(0),
00096     T_(0),
00097     cp_(0),
00098     Y_(0),
00099     injectorCells_(0)
00100 {
00101     scalarListIOList injectorData
00102     (
00103         IOobject
00104         (
00105             inputFileName_,
00106             owner.db().time().constant(),
00107             owner.db(),
00108             IOobject::MUST_READ,
00109             IOobject::NO_WRITE
00110         )
00111     );
00112 
00113     x_.setSize(injectorData.size());
00114     U_.setSize(injectorData.size());
00115     d_.setSize(injectorData.size());
00116     rho_.setSize(injectorData.size());
00117     mDot_.setSize(injectorData.size());
00118     T_.setSize(injectorData.size());
00119     cp_.setSize(injectorData.size());
00120     Y_.setSize(injectorData.size());
00121 
00122     // Populate lists
00123     forAll(injectorData, injectorI)
00124     {
00125         if (injectorData[injectorI].size() != INPUT_FILE_COLS)
00126         {
00127             FatalErrorIn
00128             (
00129                 "ReactingLookupTableInjection"
00130                 "("
00131                     "const dictionary&,"
00132                     "CloudType& owner"
00133                 ")"
00134             )   << "Incorrect number of entries in injector specification "
00135                 << "- found " << injectorData[injectorI].size()
00136                 << ", expected a minimum of " << INPUT_FILE_COLS << ":" << nl
00137                 << "    x0 x1 x2 u0 u1 u2 d rho mDot T cp Y0..YN"
00138                 << nl << exit(FatalError);
00139         }
00140         x_[injectorI].component(0) = injectorData[injectorI][0];
00141         x_[injectorI].component(1) = injectorData[injectorI][1];
00142         x_[injectorI].component(2) = injectorData[injectorI][2];
00143         U_[injectorI].component(0) = injectorData[injectorI][3];
00144         U_[injectorI].component(1) = injectorData[injectorI][4];
00145         U_[injectorI].component(2) = injectorData[injectorI][5];
00146         d_[injectorI] = injectorData[injectorI][6];
00147         rho_[injectorI] = injectorData[injectorI][7];
00148         mDot_[injectorI] = injectorData[injectorI][8];
00149         T_[injectorI] = injectorData[injectorI][9];
00150         cp_[injectorI] = injectorData[injectorI][10];
00151 
00152         Y_[injectorI].setSize
00153         (
00154             injectorData[injectorI].size() - INPUT_FILE_COLS + 1
00155         );
00156         label Yi = 0;
00157         for
00158         (
00159             label i = INPUT_FILE_COLS-1;
00160             i < injectorData[injectorI].size();
00161             i++
00162         )
00163         {
00164             Y_[injectorI][Yi++] = injectorData[injectorI][i];
00165         }
00166    }
00167 
00168     // Set/cache the injector cells
00169     injectorCells_.setSize(injectorData.size());
00170     forAll(x_, injectorI)
00171     {
00172         this->findCellAtPosition(injectorCells_[injectorI], x_[injectorI]);
00173     }
00174 
00175     // Determine volume of particles to inject
00176     this->volumeTotal_ = 0.0;
00177     forAll(mDot_, injectorI)
00178     {
00179         this->volumeTotal_ += mDot_[injectorI]/rho_[injectorI];
00180     }
00181     this->volumeTotal_ *= duration_;
00182 }
00183 
00184 
00185 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
00186 
00187 template<class CloudType>
00188 Foam::ReactingLookupTableInjection<CloudType>::~ReactingLookupTableInjection()
00189 {}
00190 
00191 
00192 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00193 
00194 template<class CloudType>
00195 bool Foam::ReactingLookupTableInjection<CloudType>::active() const
00196 {
00197     return true;
00198 }
00199 
00200 
00201 template<class CloudType>
00202 Foam::scalar Foam::ReactingLookupTableInjection<CloudType>::timeEnd() const
00203 {
00204     return this->SOI_ + duration_;
00205 }
00206 
00207 
00208 template<class CloudType>
00209 void Foam::ReactingLookupTableInjection<CloudType>::setPositionAndCell
00210 (
00211     const label parcelI,
00212     const label nParcels,
00213     const scalar time,
00214     vector& position,
00215     label& cellOwner
00216 )
00217 {
00218     label injectorI = parcelI*injectorCells_.size()/nParcels;
00219 
00220     position = x_[injectorI];
00221     cellOwner = injectorCells_[injectorI];
00222 }
00223 
00224 
00225 template<class CloudType>
00226 void Foam::ReactingLookupTableInjection<CloudType>::setProperties
00227 (
00228     const label parcelI,
00229     const label nParcels,
00230     const scalar,
00231     typename CloudType::parcelType& parcel
00232 )
00233 {
00234     label injectorI = parcelI*injectorCells_.size()/nParcels;
00235 
00236     // set particle velocity
00237     parcel.U() = U_[injectorI];
00238 
00239     // set particle diameter
00240     parcel.d() = d_[injectorI];
00241 
00242     // set particle density
00243     parcel.rho() = rho_[injectorI];
00244 
00245     // set particle temperature
00246     parcel.T() = T_[injectorI];
00247 
00248     // set particle specific heat capacity
00249     parcel.cp() = cp_[injectorI];
00250 
00251     // set particle component mass fractions
00252     parcel.Y() = Y_[injectorI];
00253 }
00254 
00255 
00256 template<class CloudType>
00257 bool Foam::ReactingLookupTableInjection<CloudType>::fullyDescribed() const
00258 {
00259     return true;
00260 }
00261 
00262 
00263 template<class CloudType>
00264 bool Foam::ReactingLookupTableInjection<CloudType>::validInjection(const label)
00265 {
00266     return true;
00267 }
00268 
00269 
00270 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd