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

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