FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

ReactingMultiphaseLookupTableInjection.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-2010 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
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your 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, see <http://www.gnu.org/licenses/>.
00023 
00024 \*---------------------------------------------------------------------------*/
00025 
00026 #include "ReactingMultiphaseLookupTableInjection.H"
00027 
00028 // * * * * * * * * * * * * Protected Member Functions  * * * * * * * * * * * //
00029 
00030 template<class CloudType>
00031 Foam::label
00032 Foam::ReactingMultiphaseLookupTableInjection<CloudType>::parcelsToInject
00033 (
00034     const scalar time0,
00035     const scalar time1
00036 ) const
00037 {
00038     if ((time0 >= 0.0) && (time0 < duration_))
00039     {
00040         return round(injectorCells_.size()*(time1 - time0)*nParcelsPerSecond_);
00041     }
00042     else
00043     {
00044         return 0;
00045     }
00046 }
00047 
00048 
00049 template<class CloudType>
00050 Foam::scalar
00051 Foam::ReactingMultiphaseLookupTableInjection<CloudType>::volumeToInject
00052 (
00053     const scalar time0,
00054     const scalar time1
00055 ) const
00056 {
00057     scalar volume = 0.0;
00058     if ((time0 >= 0.0) && (time0 < duration_))
00059     {
00060         forAll(injectors_, i)
00061         {
00062             volume += injectors_[i].mDot()/injectors_[i].rho()*(time1 - time0);
00063         }
00064     }
00065 
00066     return volume;
00067 }
00068 
00069 
00070 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00071 
00072 template<class CloudType>
00073 Foam::ReactingMultiphaseLookupTableInjection<CloudType>::
00074 ReactingMultiphaseLookupTableInjection
00075 (
00076     const dictionary& dict,
00077     CloudType& owner
00078 )
00079 :
00080     InjectionModel<CloudType>(dict, owner, typeName),
00081     inputFileName_(this->coeffDict().lookup("inputFile")),
00082     duration_(readScalar(this->coeffDict().lookup("duration"))),
00083     nParcelsPerSecond_
00084     (
00085         readScalar(this->coeffDict().lookup("parcelsPerSecond"))
00086     ),
00087     injectors_
00088     (
00089         IOobject
00090         (
00091             inputFileName_,
00092             owner.db().time().constant(),
00093             owner.db(),
00094             IOobject::MUST_READ,
00095             IOobject::NO_WRITE
00096         )
00097     ),
00098     injectorCells_(0)
00099 {
00100     // Set/cache the injector cells
00101     injectorCells_.setSize(injectors_.size());
00102     forAll(injectors_, i)
00103     {
00104         this->findCellAtPosition(injectorCells_[i], injectors_[i].x());
00105     }
00106 
00107     // Determine volume of particles to inject
00108     this->volumeTotal_ = 0.0;
00109     forAll(injectors_, i)
00110     {
00111         this->volumeTotal_ += injectors_[i].mDot()/injectors_[i].rho();
00112     }
00113     this->volumeTotal_ *= duration_;
00114 }
00115 
00116 
00117 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
00118 
00119 template<class CloudType>
00120 Foam::ReactingMultiphaseLookupTableInjection<CloudType>::
00121 ~ReactingMultiphaseLookupTableInjection()
00122 {}
00123 
00124 
00125 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00126 
00127 template<class CloudType>
00128 bool Foam::ReactingMultiphaseLookupTableInjection<CloudType>::active() const
00129 {
00130     return true;
00131 }
00132 
00133 
00134 template<class CloudType>
00135 Foam::scalar
00136 Foam::ReactingMultiphaseLookupTableInjection<CloudType>::timeEnd() const
00137 {
00138     return this->SOI_ + duration_;
00139 }
00140 
00141 
00142 template<class CloudType>
00143 void Foam::ReactingMultiphaseLookupTableInjection<CloudType>::setPositionAndCell
00144 (
00145     const label parcelI,
00146     const label nParcels,
00147     const scalar time,
00148     vector& position,
00149     label& cellOwner
00150 )
00151 {
00152     label injectorI = parcelI*injectorCells_.size()/nParcels;
00153 
00154     position = injectors_[injectorI].x();
00155     cellOwner = injectorCells_[injectorI];
00156 }
00157 
00158 
00159 template<class CloudType>
00160 void Foam::ReactingMultiphaseLookupTableInjection<CloudType>::setProperties
00161 (
00162     const label parcelI,
00163     const label nParcels,
00164     const scalar,
00165     typename CloudType::parcelType& parcel
00166 )
00167 {
00168     label injectorI = parcelI*injectorCells_.size()/nParcels;
00169 
00170     // set particle velocity
00171     parcel.U() = injectors_[injectorI].U();
00172 
00173     // set particle diameter
00174     parcel.d() = injectors_[injectorI].d();
00175 
00176     // set particle density
00177     parcel.rho() = injectors_[injectorI].rho();
00178 
00179     // set particle temperature
00180     parcel.T() = injectors_[injectorI].T();
00181 
00182     // set particle specific heat capacity
00183     parcel.cp() = injectors_[injectorI].cp();
00184 
00185     // set particle component mass fractions
00186     parcel.Y() = injectors_[injectorI].Y();
00187 
00188     // set particle gaseous component mass fractions
00189     parcel.YGas() = injectors_[injectorI].YGas();
00190 
00191     // set particle liquid component mass fractions
00192     parcel.YLiquid() = injectors_[injectorI].YLiquid();
00193 
00194     // set particle solid component mass fractions
00195     parcel.YSolid() = injectors_[injectorI].YSolid();
00196 }
00197 
00198 
00199 template<class CloudType>
00200 bool
00201 Foam::ReactingMultiphaseLookupTableInjection<CloudType>::fullyDescribed() const
00202 {
00203     return true;
00204 }
00205 
00206 
00207 template<class CloudType>
00208 bool Foam::ReactingMultiphaseLookupTableInjection<CloudType>::validInjection
00209 (
00210     const label
00211 )
00212 {
00213     return true;
00214 }
00215 
00216 
00217 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines