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

greyMeanAbsorptionEmission.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 "greyMeanAbsorptionEmission.H"
00028 #include "addToRunTimeSelectionTable.H"
00029 
00030 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
00031 
00032 namespace Foam
00033 {
00034     namespace radiation
00035     {
00036         defineTypeNameAndDebug(greyMeanAbsorptionEmission, 0);
00037 
00038         addToRunTimeSelectionTable
00039         (
00040             absorptionEmissionModel,
00041             greyMeanAbsorptionEmission,
00042             dictionary
00043         );
00044     }
00045 }
00046 
00047 
00048 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00049 
00050 Foam::radiation::greyMeanAbsorptionEmission::greyMeanAbsorptionEmission
00051 (
00052     const dictionary& dict,
00053     const fvMesh& mesh
00054 )
00055 :
00056     absorptionEmissionModel(dict, mesh),
00057     coeffsDict_((dict.subDict(typeName + "Coeffs"))),
00058     speciesNames_(0),
00059     specieIndex_(0),
00060     lookUpTable_
00061     (
00062         fileName(coeffsDict_.lookup("lookUpTableFileName")),
00063         mesh.time().constant(),
00064         mesh
00065     ),
00066     thermo_(mesh.lookupObject<basicThermo>("thermophysicalProperties")),
00067     EhrrCoeff_(readScalar(coeffsDict_.lookup("EhrrCoeff"))),
00068     Yj_(nSpecies_)
00069 {
00070     label nFunc = 0;
00071     const dictionary& functionDicts = dict.subDict(typeName + "Coeffs");
00072 
00073     forAllConstIter(dictionary, functionDicts, iter)
00074     {
00075         // safety:
00076         if (!iter().isDict())
00077         {
00078             continue;
00079         }
00080         const word& key = iter().keyword();
00081         speciesNames_.insert(key, nFunc);
00082         const dictionary& dict = iter().dict();
00083         coeffs_[nFunc].initialise(dict);
00084         nFunc++;
00085     }
00086 
00087     // Check that all the species on the dictionary are present in the
00088     // look-up table and save the corresponding indices of the look-up table
00089 
00090     label j = 0;
00091     forAllConstIter(HashTable<label>, speciesNames_, iter)
00092     {
00093         if (mesh.foundObject<volScalarField>("ft"))
00094         {
00095             if (lookUpTable_.found(iter.key()))
00096             {
00097                 label index = lookUpTable_.findFieldIndex(iter.key());
00098 
00099                 Info<< "specie: " << iter.key() << " found on look-up table "
00100                     << " with index: " << index << endl;
00101 
00102                 specieIndex_[iter()] = index;
00103             }
00104             else if (mesh.foundObject<volScalarField>(iter.key()))
00105             {
00106                 volScalarField& Y =
00107                     const_cast<volScalarField&>
00108                     (
00109                         mesh.lookupObject<volScalarField>(iter.key())
00110                     );
00111                 Yj_.set(j, &Y);
00112                 specieIndex_[iter()] = 0;
00113                 j++;
00114                 Info<< "specie: " << iter.key() << " is being solved" << endl;
00115             }
00116             else
00117             {
00118                 FatalErrorIn
00119                 (
00120                     "Foam::radiation::greyMeanAbsorptionEmission(const"
00121                     "dictionary& dict, const fvMesh& mesh)"
00122                 )   << "specie: " << iter.key()
00123                     << " is neither in look-up table: "
00124                     << lookUpTable_.tableName()
00125                     << " nor is being solved" << nl
00126                     << exit(FatalError);
00127             }
00128         }
00129         else
00130         {
00131             FatalErrorIn
00132             (
00133                 "Foam::radiation::greyMeanAbsorptionEmission(const"
00134                 "dictionary& dict, const fvMesh& mesh)"
00135             )   << "specie ft is not present " << nl
00136                 << exit(FatalError);
00137 
00138         }
00139     }
00140 }
00141 
00142 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
00143 
00144 Foam::radiation::greyMeanAbsorptionEmission::~greyMeanAbsorptionEmission()
00145 {}
00146 
00147 
00148 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00149 
00150 Foam::tmp<Foam::volScalarField>
00151 Foam::radiation::greyMeanAbsorptionEmission::aCont(const label bandI) const
00152 {
00153     const volScalarField& T = thermo_.T();
00154     const volScalarField& p = thermo_.p();
00155     const volScalarField& ft = mesh_.lookupObject<volScalarField>("ft");
00156 
00157     label nSpecies = speciesNames_.size();
00158 
00159     tmp<volScalarField> ta
00160     (
00161         new volScalarField
00162         (
00163             IOobject
00164             (
00165                 "a",
00166                 mesh().time().timeName(),
00167                 mesh(),
00168                 IOobject::NO_READ,
00169                 IOobject::NO_WRITE
00170             ),
00171             mesh(),
00172             dimensionedScalar("a", dimless/dimLength, 0.0)
00173         )
00174     );
00175 
00176     scalarField& a = ta().internalField();
00177 
00178     forAll(a, i)
00179     {
00180         const List<scalar>& species = lookUpTable_.lookUp(ft[i]);
00181 
00182         for (label n=0; n<nSpecies; n++)
00183         {
00184             label l = 0;
00185             scalar Yipi = 0;
00186             if (specieIndex_[n] != 0)
00187             {
00188                 //moles x pressure [atm]
00189                 Yipi = species[specieIndex_[n]]*p[i]*9.869231e-6;
00190             }
00191             else
00192             {
00193                 // mass fraction
00194                 Yipi = Yj_[l][i];
00195                 l++;
00196             }
00197 
00198             const absorptionCoeffs::coeffArray& b = coeffs_[n].coeffs(T[i]);
00199 
00200             scalar Ti = T[i];
00201             // negative temperature exponents
00202             if (coeffs_[n].invTemp())
00203             {
00204                 Ti = 1./T[i];
00205             }
00206             a[i] +=
00207                 Yipi
00208                *(
00209                     ((((b[5]*Ti + b[4])*Ti + b[3])*Ti + b[2])*Ti + b[1])*Ti
00210                   + b[0]
00211                 );
00212         }
00213     }
00214     return ta;
00215 }
00216 
00217 
00218 Foam::tmp<Foam::volScalarField>
00219 Foam::radiation::greyMeanAbsorptionEmission::eCont(const label bandI) const
00220 {
00221     tmp<volScalarField> e
00222     (
00223         new volScalarField
00224         (
00225             IOobject
00226             (
00227                 "e",
00228                 mesh().time().timeName(),
00229                 mesh(),
00230                 IOobject::NO_READ,
00231                 IOobject::NO_WRITE
00232             ),
00233             mesh(),
00234             dimensionedScalar("e", dimless/dimLength, 0.0)
00235         )
00236     );
00237 
00238     return e;
00239 }
00240 
00241 
00242 Foam::tmp<Foam::volScalarField>
00243 Foam::radiation::greyMeanAbsorptionEmission::ECont(const label bandI) const
00244 {
00245     tmp<volScalarField> E
00246     (
00247         new volScalarField
00248         (
00249             IOobject
00250             (
00251                 "E",
00252                 mesh_.time().timeName(),
00253                 mesh_,
00254                 IOobject::NO_READ,
00255                 IOobject::NO_WRITE
00256             ),
00257             mesh_,
00258             dimensionedScalar("E", dimMass/dimLength/pow3(dimTime), 0.0)
00259         )
00260     );
00261 
00262     if (mesh_.foundObject<volScalarField>("hrr"))
00263     {
00264         const volScalarField& hrr = mesh_.lookupObject<volScalarField>("hrr");
00265         E().internalField() = EhrrCoeff_*hrr.internalField();
00266     }
00267 
00268     return E;
00269 }
00270 
00271 
00272 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd