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

ThermoLookupTableInjection.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 "ThermoLookupTableInjection.H"
00028 #include "scalarIOList.H"
00029 
00030 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
00031 
00032 template<class CloudType>
00033 Foam::label Foam::ThermoLookupTableInjection<CloudType>::INPUT_FILE_COLS = 11;
00034 
00035 // * * * * * * * * * * * * Protected Member Functions  * * * * * * * * * * * //
00036 
00037 template<class CloudType>
00038 Foam::label Foam::ThermoLookupTableInjection<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::ThermoLookupTableInjection<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::ThermoLookupTableInjection<CloudType>::ThermoLookupTableInjection
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     injectorCells_(0)
00099 {
00100     scalarListIOList injectorData
00101     (
00102         IOobject
00103         (
00104             inputFileName_,
00105             owner.db().time().constant(),
00106             owner.db(),
00107             IOobject::MUST_READ,
00108             IOobject::NO_WRITE
00109         )
00110     );
00111 
00112     x_.setSize(injectorData.size());
00113     U_.setSize(injectorData.size());
00114     d_.setSize(injectorData.size());
00115     rho_.setSize(injectorData.size());
00116     mDot_.setSize(injectorData.size());
00117     T_.setSize(injectorData.size());
00118     cp_.setSize(injectorData.size());
00119 
00120     // Populate lists
00121     forAll(injectorData, injectorI)
00122     {
00123         if (injectorData[injectorI].size() != INPUT_FILE_COLS)
00124         {
00125             FatalErrorIn
00126             (
00127                 "ThermoLookupTableInjection"
00128                 "("
00129                     "const dictionary&,"
00130                     "CloudType& owner"
00131                 ")"
00132             )   << "Incorrect number of entries in injector specification "
00133                 << "- found " << injectorData[injectorI].size()
00134                 << ", expected " << INPUT_FILE_COLS << ":" << nl
00135                 << "    x0 x1 x2 u0 u1 u2 d rho mDot T cp"
00136                 << nl << exit(FatalError);
00137         }
00138         x_[injectorI].component(0) = injectorData[injectorI][0];
00139         x_[injectorI].component(1) = injectorData[injectorI][1];
00140         x_[injectorI].component(2) = injectorData[injectorI][2];
00141         U_[injectorI].component(0) = injectorData[injectorI][3];
00142         U_[injectorI].component(1) = injectorData[injectorI][4];
00143         U_[injectorI].component(2) = injectorData[injectorI][5];
00144         d_[injectorI] = injectorData[injectorI][6];
00145         rho_[injectorI] = injectorData[injectorI][7];
00146         mDot_[injectorI] = injectorData[injectorI][8];
00147         T_[injectorI] = injectorData[injectorI][9];
00148         cp_[injectorI] = injectorData[injectorI][10];
00149    }
00150 
00151     // Set/cache the injector cells
00152     injectorCells_.setSize(injectorData.size());
00153     forAll(x_, injectorI)
00154     {
00155         this->findCellAtPosition(injectorCells_[injectorI], x_[injectorI]);
00156     }
00157 
00158     // Determine volume of particles to inject
00159     this->volumeTotal_ = 0.0;
00160     forAll(mDot_, injectorI)
00161     {
00162         this->volumeTotal_ += mDot_[injectorI]/rho_[injectorI];
00163     }
00164     this->volumeTotal_ *= duration_;
00165 }
00166 
00167 
00168 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
00169 
00170 template<class CloudType>
00171 Foam::ThermoLookupTableInjection<CloudType>::~ThermoLookupTableInjection()
00172 {}
00173 
00174 
00175 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00176 
00177 template<class CloudType>
00178 bool Foam::ThermoLookupTableInjection<CloudType>::active() const
00179 {
00180     return true;
00181 }
00182 
00183 
00184 template<class CloudType>
00185 Foam::scalar Foam::ThermoLookupTableInjection<CloudType>::timeEnd() const
00186 {
00187     return this->SOI_ + duration_;
00188 }
00189 
00190 
00191 template<class CloudType>
00192 void Foam::ThermoLookupTableInjection<CloudType>::setPositionAndCell
00193 (
00194     const label parcelI,
00195     const label nParcels,
00196     const scalar time,
00197     vector& position,
00198     label& cellOwner
00199 )
00200 {
00201     label injectorI = parcelI*injectorCells_.size()/nParcels;
00202 
00203     position = x_[injectorI];
00204     cellOwner = injectorCells_[injectorI];
00205 }
00206 
00207 
00208 template<class CloudType>
00209 void Foam::ThermoLookupTableInjection<CloudType>::setProperties
00210 (
00211     const label parcelI,
00212     const label nParcels,
00213     const scalar,
00214     typename CloudType::parcelType* pPtr
00215 )
00216 {
00217     label injectorI = parcelI*injectorCells_.size()/nParcels;
00218 
00219     // set particle velocity
00220     parcel.U() = U_[injectorI];
00221 
00222     // set particle diameter
00223     parcel.d() = d_[injectorI];
00224 
00225     // set particle density
00226     parcel.rho() = rho_[injectorI];
00227 
00228     // set particle temperature
00229     parcel.T() = T_[injectorI];
00230 
00231     // set particle specific heat capacity
00232     parcel.cp() = cp_[injectorI];
00233 }
00234 
00235 
00236 template<class CloudType>
00237 bool Foam::ThermoLookupTableInjection<CloudType>::fullyDescribed() const
00238 {
00239     return true;
00240 }
00241 
00242 
00243 template<class CloudType>
00244 bool Foam::ThermoLookupTableInjection<CloudType>::validInjection(const label)
00245 {
00246     return true;
00247 }
00248 
00249 
00250 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd