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

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