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

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