diff --git a/src/thermophysicalModels/radiation/Make/files b/src/thermophysicalModels/radiation/Make/files index 9b385e8a56..4e7fb1b11c 100644 --- a/src/thermophysicalModels/radiation/Make/files +++ b/src/thermophysicalModels/radiation/Make/files @@ -1,13 +1,15 @@ /* Radiation constants */ radiationConstants/radiationConstants.C - /* Radiation model */ radiationModel/radiationModel/radiationModel.C radiationModel/radiationModel/newRadiationModel.C radiationModel/noRadiation/noRadiation.C radiationModel/P1/P1.C - +radiationModel/fvDOM/fvDOM/fvDOM.C +radiationModel/fvDOM/radiativeIntensityRay/radiativeIntensityRay.C +radiationModel/fvDOM/blackBodyEmission/blackBodyEmission.C +radiationModel/fvDOM/absorptionCoeffs/absorptionCoeffs.C /* Scatter model */ submodels/scatterModel/scatterModel/scatterModel.C @@ -21,11 +23,14 @@ submodels/absorptionEmissionModel/absorptionEmissionModel/newAbsorptionEmissionM submodels/absorptionEmissionModel/noAbsorptionEmission/noAbsorptionEmission.C submodels/absorptionEmissionModel/constantAbsorptionEmission/constantAbsorptionEmission.C submodels/absorptionEmissionModel/binaryAbsorptionEmission/binaryAbsorptionEmission.C +submodels/absorptionEmissionModel/greyMeanAbsorptionEmission/greyMeanAbsorptionEmission.C +submodels/absorptionEmissionModel/wideBandAbsorptionEmission/wideBandAbsorptionEmission.C /* Boundary conditions */ derivedFvPatchFields/MarshakRadiation/MarshakRadiationMixedFvPatchScalarField.C derivedFvPatchFields/MarshakRadiationFixedT/MarshakRadiationFixedTMixedFvPatchScalarField.C - +derivedFvPatchFields/greyDiffusiveRadiation/greyDiffusiveRadiationMixedFvPatchScalarField.C +derivedFvPatchFields/wideBandDiffusiveRadiation/wideBandDiffusiveRadiationMixedFvPatchScalarField.C LIB = $(FOAM_LIBBIN)/libradiation diff --git a/src/thermophysicalModels/radiation/Make/options b/src/thermophysicalModels/radiation/Make/options index 31643f8150..98956f2b6d 100644 --- a/src/thermophysicalModels/radiation/Make/options +++ b/src/thermophysicalModels/radiation/Make/options @@ -1,6 +1,9 @@ EXE_INC = \ -I$(LIB_SRC)/finiteVolume/lnInclude \ - -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude + -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/combustion/lnInclude \ + -I$(LIB_SRC)/OpenFOAM/lnInclude \ + -I radiationModel/fvDOM/interpolationLookUpTable LIB_LIBS = \ -lfiniteVolume diff --git a/src/thermophysicalModels/radiation/derivedFvPatchFields/greyDiffusiveRadiation/greyDiffusiveRadiationMixedFvPatchScalarField.C b/src/thermophysicalModels/radiation/derivedFvPatchFields/greyDiffusiveRadiation/greyDiffusiveRadiationMixedFvPatchScalarField.C new file mode 100644 index 0000000000..e7daa58aaf --- /dev/null +++ b/src/thermophysicalModels/radiation/derivedFvPatchFields/greyDiffusiveRadiation/greyDiffusiveRadiationMixedFvPatchScalarField.C @@ -0,0 +1,273 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "greyDiffusiveRadiationMixedFvPatchScalarField.H" +#include "addToRunTimeSelectionTable.H" +#include "fvPatchFieldMapper.H" +#include "volFields.H" + +#include "fvDOM.H" +#include "radiationConstants.H" +#include "mathematicalConstants.H" + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::radiation::greyDiffusiveRadiationMixedFvPatchScalarField:: +greyDiffusiveRadiationMixedFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF +) +: + mixedFvPatchScalarField(p, iF), + TName_("undefinedT"), + emissivity_(0.0), + rayId_(0), + lambdaId_(0) +{ + refValue() = 0.0; + refGrad() = 0.0; + valueFraction() = 1.0; +} + + +Foam::radiation::greyDiffusiveRadiationMixedFvPatchScalarField:: +greyDiffusiveRadiationMixedFvPatchScalarField +( + const greyDiffusiveRadiationMixedFvPatchScalarField& ptf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + mixedFvPatchScalarField(ptf, p, iF, mapper), + TName_(ptf.TName_), + emissivity_(ptf.emissivity_), + rayId_(ptf.rayId_), + lambdaId_(ptf.lambdaId_) +{} + + +Foam::radiation::greyDiffusiveRadiationMixedFvPatchScalarField:: +greyDiffusiveRadiationMixedFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + mixedFvPatchScalarField(p, iF), + TName_(dict.lookup("T")), + emissivity_(readScalar(dict.lookup("emissivity"))), + rayId_(-1), + lambdaId_(-1) +{ + const scalarField& Tp = + patch().lookupPatchField(TName_); + + refValue() = + emissivity_*4.0*radiation::sigmaSB.value()*pow4(Tp) + /Foam::mathematicalConstant::pi; + + refGrad() = 0.0; + + if (dict.found("value")) + { + fvPatchScalarField::operator= + ( + scalarField("value", dict, p.size()) + ); + } + else + { + fvPatchScalarField::operator=(refValue()); + } +} + + +Foam::radiation::greyDiffusiveRadiationMixedFvPatchScalarField:: +greyDiffusiveRadiationMixedFvPatchScalarField +( + const greyDiffusiveRadiationMixedFvPatchScalarField& ptf +) +: + mixedFvPatchScalarField(ptf), + TName_(ptf.TName_), + emissivity_(ptf.emissivity_), + rayId_(ptf.rayId_), + lambdaId_(ptf.lambdaId_) +{} + + +Foam::radiation::greyDiffusiveRadiationMixedFvPatchScalarField:: +greyDiffusiveRadiationMixedFvPatchScalarField +( + const greyDiffusiveRadiationMixedFvPatchScalarField& ptf, + const DimensionedField& iF +) +: + mixedFvPatchScalarField(ptf, iF), + TName_(ptf.TName_), + emissivity_(ptf.emissivity_), + rayId_(ptf.rayId_), + lambdaId_(ptf.lambdaId_) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::radiation::greyDiffusiveRadiationMixedFvPatchScalarField:: +updateCoeffs() +{ + if (this->updated()) + { + return; + } + + const scalarField& Tp = + patch().lookupPatchField(TName_); + + const fvDOM& dom = db().lookupObject("radiationProperties"); + + const label patchI = patch().index(); + + if (dom.nLambda() == 1) + { + if (rayId_ == -1) + { + for (label rayI=0; rayI < dom.nRay(); rayI++) + { + for (label lambdaI=0; lambdaI < dom.nLambda(); lambdaI++) + { + const volScalarField& radiationField = + dom.IRayLambda(rayI, lambdaI); + if + ( + &(radiationField.internalField()) + == &dimensionedInternalField() + ) + { + rayId_ = rayI; + lambdaId_ = lambdaI; + break; + } + } + } + } + } + else + { + FatalErrorIn + ( + "Foam::radiation::" + "greyDiffusiveRadiationMixedFvPatchScalarField::" + "updateCoeffs" + ) << " a grey boundary condition is used with a non-grey" + << "absorption model" + << exit(FatalError); + } + + scalarField& Iw = *this; + vectorField n = patch().Sf()/patch().magSf(); + + radiativeIntensityRay& ray = + const_cast(dom.IRay(rayId_)); + + ray.Qr().boundaryField()[patchI] += Iw*(-n & ray.dAve()); + + forAll(Iw, faceI) + { + scalar Ir = 0.0; + + for (label rayI=0; rayI < dom.nRay(); rayI++) + { + const vector& d = dom.IRay(rayI).d(); + + const scalarField& Iface = + dom.IRay(rayI).ILambda(lambdaId_).boundaryField()[patchI]; + + if ((-n[faceI] & d) < 0.0) // qin into the wall + { + const vector& dAve = dom.IRay(rayI).dAve(); + Ir += Iface[faceI]*mag(n[faceI] & dAve); + } + } + + const vector& d = dom.IRay(rayId_).d(); + + if ((-n[faceI] & d) > 0.) //direction out of the wall + { + refGrad()[faceI] = 0.0; + valueFraction()[faceI] = 1.0; + refValue()[faceI] = + ( + Ir*(1.0 - emissivity_) + + emissivity_*radiation::sigmaSB.value()*pow4(Tp[faceI]) + ) + /mathematicalConstant::pi; + + } + else //direction into the wall + { + valueFraction()[faceI] = 0.0; + refGrad()[faceI] = 0.0; + refValue()[faceI] = 0.0; //not used + } + } + + mixedFvPatchScalarField::updateCoeffs(); +} + + +void Foam::radiation::greyDiffusiveRadiationMixedFvPatchScalarField::write +( + Ostream& os +) const +{ + fvPatchScalarField::write(os); + os.writeKeyword("T") << TName_ << token::END_STATEMENT << nl; + os.writeKeyword("emissivity") << emissivity_ << token::END_STATEMENT << nl; + writeEntry("value", os); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace radiation +{ + makePatchTypeField + ( + fvPatchScalarField, + greyDiffusiveRadiationMixedFvPatchScalarField + ); +} +} + + +// ************************************************************************* // diff --git a/src/thermophysicalModels/radiation/derivedFvPatchFields/greyDiffusiveRadiation/greyDiffusiveRadiationMixedFvPatchScalarField.H b/src/thermophysicalModels/radiation/derivedFvPatchFields/greyDiffusiveRadiation/greyDiffusiveRadiationMixedFvPatchScalarField.H new file mode 100644 index 0000000000..f236f8be15 --- /dev/null +++ b/src/thermophysicalModels/radiation/derivedFvPatchFields/greyDiffusiveRadiation/greyDiffusiveRadiationMixedFvPatchScalarField.H @@ -0,0 +1,190 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::greyDiffusiveRadiationMixedFvPatchScalarField + +Description + Radiation temperature specified + +SourceFiles + greyDiffusiveRadiationMixedFvPatchScalarField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef greyDiffusiveRadiationMixedFvPatchScalarField_H +#define greyDiffusiveRadiationMixedFvPatchScalarField_H + +#include "mixedFvPatchFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace radiation +{ +/*---------------------------------------------------------------------------*\ + Class greyDiffusiveRadiationMixedFvPatchScalarField Declaration +\*---------------------------------------------------------------------------*/ + +class greyDiffusiveRadiationMixedFvPatchScalarField +: + public mixedFvPatchScalarField +{ + // Private data + + //- Name of temperature field + word TName_; + + //- Emissivity + scalar emissivity_; + + //- Ray index + label rayId_; + + //- Wavelength index + label lambdaId_; + + +public: + + //- Runtime type information + TypeName("greyDiffusiveRadiation"); + + + // Constructors + + //- Construct from patch and internal field + greyDiffusiveRadiationMixedFvPatchScalarField + ( + const fvPatch&, + const DimensionedField& + ); + + //- Construct from patch, internal field and dictionary + greyDiffusiveRadiationMixedFvPatchScalarField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given a + // greyDiffusiveRadiationMixedFvPatchScalarField onto a new patch + greyDiffusiveRadiationMixedFvPatchScalarField + ( + const greyDiffusiveRadiationMixedFvPatchScalarField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + greyDiffusiveRadiationMixedFvPatchScalarField + ( + const greyDiffusiveRadiationMixedFvPatchScalarField& + ); + + //- Construct and return a clone + virtual tmp clone() const + { + return tmp + ( + new greyDiffusiveRadiationMixedFvPatchScalarField(*this) + ); + } + + //- Construct as copy setting internal field reference + greyDiffusiveRadiationMixedFvPatchScalarField + ( + const greyDiffusiveRadiationMixedFvPatchScalarField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp clone + ( + const DimensionedField& iF + ) const + { + return tmp + ( + new greyDiffusiveRadiationMixedFvPatchScalarField(*this, iF) + ); + } + + + // Member functions + + // Access + + //- Return the temperature field name + const word& TName() const + { + return TName_; + } + + //- Return reference to the temperature field name to allow + // adjustment + word& TName() + { + return TName_; + } + + //- Return the emissivity + const scalar& emissivity() const + { + return emissivity_; + } + + //- Return reference to the emissivity to allow adjustment + scalar& emissivity() + { + return emissivity_; + } + + + // Evaluation functions + + //- Update the coefficients associated with the patch field + virtual void updateCoeffs(); + + + // I-O + + //- Write + virtual void write(Ostream&) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/thermophysicalModels/radiation/derivedFvPatchFields/wideBandDiffusiveRadiation/wideBandDiffusiveRadiationMixedFvPatchScalarField.C b/src/thermophysicalModels/radiation/derivedFvPatchFields/wideBandDiffusiveRadiation/wideBandDiffusiveRadiationMixedFvPatchScalarField.C new file mode 100644 index 0000000000..eb65337aca --- /dev/null +++ b/src/thermophysicalModels/radiation/derivedFvPatchFields/wideBandDiffusiveRadiation/wideBandDiffusiveRadiationMixedFvPatchScalarField.C @@ -0,0 +1,269 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "wideBandDiffusiveRadiationMixedFvPatchScalarField.H" +#include "addToRunTimeSelectionTable.H" +#include "fvPatchFieldMapper.H" +#include "volFields.H" + +#include "fvDOM.H" +#include "wideBandAbsorptionEmission.H" +#include "radiationConstants.H" +#include "mathematicalConstants.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::radiation::wideBandDiffusiveRadiationMixedFvPatchScalarField:: +wideBandDiffusiveRadiationMixedFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF +) +: + mixedFvPatchScalarField(p, iF), + TName_("undefinedT"), + emissivity_(0.0), + rayId_(0), + lambdaId_(0) +{ + refValue() = 0.0; + refGrad() = 0.0; + valueFraction() = 1.0; +} + + +Foam::radiation::wideBandDiffusiveRadiationMixedFvPatchScalarField:: +wideBandDiffusiveRadiationMixedFvPatchScalarField +( + const wideBandDiffusiveRadiationMixedFvPatchScalarField& ptf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + mixedFvPatchScalarField(ptf, p, iF, mapper), + TName_(ptf.TName_), + emissivity_(ptf.emissivity_), + rayId_(ptf.rayId_), + lambdaId_(ptf.lambdaId_) +{} + + +Foam::radiation::wideBandDiffusiveRadiationMixedFvPatchScalarField:: +wideBandDiffusiveRadiationMixedFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + mixedFvPatchScalarField(p, iF), + TName_(dict.lookup("T")), + emissivity_(readScalar(dict.lookup("emissivity"))), + rayId_(0), + lambdaId_(0) +{ + const scalarField& Tp = + patch().lookupPatchField(TName_); + + refValue() = + emissivity_*4.0*radiation::sigmaSB.value()*pow4(Tp) + /Foam::mathematicalConstant::pi; + refGrad() = 0.0; + + if (dict.found("value")) + { + fvPatchScalarField::operator= + ( + scalarField("value", dict, p.size()) + ); + } + else + { + fvPatchScalarField::operator=(refValue()); + } +} + + +Foam::radiation::wideBandDiffusiveRadiationMixedFvPatchScalarField:: +wideBandDiffusiveRadiationMixedFvPatchScalarField +( + const wideBandDiffusiveRadiationMixedFvPatchScalarField& ptf +) +: + mixedFvPatchScalarField(ptf), + TName_(ptf.TName_), + emissivity_(ptf.emissivity_), + rayId_(ptf.rayId_), + lambdaId_(ptf.lambdaId_) +{} + + +Foam::radiation::wideBandDiffusiveRadiationMixedFvPatchScalarField:: +wideBandDiffusiveRadiationMixedFvPatchScalarField +( + const wideBandDiffusiveRadiationMixedFvPatchScalarField& ptf, + const DimensionedField& iF +) +: + mixedFvPatchScalarField(ptf, iF), + TName_(ptf.TName_), + emissivity_(ptf.emissivity_), + rayId_(ptf.rayId_), + lambdaId_(ptf.lambdaId_) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::radiation::wideBandDiffusiveRadiationMixedFvPatchScalarField:: +updateCoeffs() +{ + if (this->updated()) + { + return; + } + + const fvDOM& dom = db().lookupObject("radiationProperties"); + + const label patchI = patch().index(); + + if (dom.nLambda() > 1) + { + if (rayId_ == -1) + { + for (label rayI=0; rayI < dom.nRay(); rayI++) + { + for (label lambdaI=0; lambdaI < dom.nLambda(); lambdaI++) + { + const volScalarField& radiationField = + dom.IRayLambda(rayI, lambdaI); + if + ( + &(radiationField.internalField()) + ==&dimensionedInternalField() + ) + { + rayId_ = rayI; + lambdaId_ = lambdaI; + break; + } + } + } + } + } + else + { + FatalErrorIn + ( + "Foam::radiation::" + "wideBandDiffusiveRadiationMixedFvPatchScalarField::" + "updateCoeffs" + ) << " a Non-grey boundary condition is used with a grey" + << "absorption model" << nl << exit(FatalError); + } + + scalarField& Iw = *this; + vectorField n = patch().Sf()/patch().magSf(); + + radiativeIntensityRay& ray = + const_cast(dom.IRay(rayId_)); + + ray.Qr().boundaryField()[patchI] += Iw*(-n & ray.dAve()); + + const scalarField Eb = + dom.blackBody().bLambda(lambdaId_).boundaryField()[patchI]; + + forAll(Iw, faceI) + { + scalar Ir = 0.0; + for (label rayI=0; rayI < dom.nRay(); rayI++) + { + const vector& d = dom.IRay(rayI).d(); + + const scalarField& Iface = + dom.IRay(rayI).ILambda(lambdaId_).boundaryField()[patchI]; + + if ((-n[faceI] & d) < 0.0) // qin into the wall + { + const vector& dAve = dom.IRay(rayI).dAve(); + Ir = Ir + Iface[faceI]*mag(n[faceI] & dAve); + } + } + + const vector& d = dom.IRay(rayId_).d(); + + if ((-n[faceI] & d) > 0.0) //direction out of the wall + { + refGrad()[faceI] = 0.0; + valueFraction()[faceI] = 1.0; + refValue()[faceI] = + ( + Ir*(1.0 - emissivity_) + + emissivity_*Eb[faceI] + ) + /mathematicalConstant::pi; + } + else //direction into the wall + { + valueFraction()[faceI] = 0.0; + refGrad()[faceI] = 0.0; + refValue()[faceI] = 0.0; //not used + } + } + + mixedFvPatchScalarField::updateCoeffs(); +} + + +void Foam::radiation::wideBandDiffusiveRadiationMixedFvPatchScalarField::write +( + Ostream& os +) const +{ + fvPatchScalarField::write(os); + os.writeKeyword("T") << TName_ << token::END_STATEMENT << nl; + os.writeKeyword("emissivity") << emissivity_ << token::END_STATEMENT << nl; + writeEntry("value", os); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace radiation +{ + makePatchTypeField + ( + fvPatchScalarField, + wideBandDiffusiveRadiationMixedFvPatchScalarField + ); +} +} + + +// ************************************************************************* // diff --git a/src/thermophysicalModels/radiation/derivedFvPatchFields/wideBandDiffusiveRadiation/wideBandDiffusiveRadiationMixedFvPatchScalarField.H b/src/thermophysicalModels/radiation/derivedFvPatchFields/wideBandDiffusiveRadiation/wideBandDiffusiveRadiationMixedFvPatchScalarField.H new file mode 100644 index 0000000000..3ff3990786 --- /dev/null +++ b/src/thermophysicalModels/radiation/derivedFvPatchFields/wideBandDiffusiveRadiation/wideBandDiffusiveRadiationMixedFvPatchScalarField.H @@ -0,0 +1,193 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::wideBandDiffusiveRadiationMixedFvPatchScalarField + +Description + Radiation temperature specified + +SourceFiles + wideBandDiffusiveRadiationMixedFvPatchScalarField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef wideBandDiffusiveRadiationMixedFvPatchScalarField_H +#define wideBandDiffusiveRadiationMixedFvPatchScalarField_H + +#include "mixedFvPatchFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace radiation +{ +/*---------------------------------------------------------------------------*\ + Class wideBandDiffusiveRadiationMixedFvPatchScalarField Declaration +\*---------------------------------------------------------------------------*/ + +class wideBandDiffusiveRadiationMixedFvPatchScalarField +: + public mixedFvPatchScalarField +{ + // Private data + + //- Name of temperature field + word TName_; + + //- Emissivity + scalar emissivity_; + + //- Ray index + label rayId_; + + //- Wavelength index + label lambdaId_; + + //- Radiative heat flux on walls. + scalarField qr_; + + +public: + + //- Runtime type information + TypeName("wideBandDiffusiveRadiation"); + + + // Constructors + + //- Construct from patch and internal field + wideBandDiffusiveRadiationMixedFvPatchScalarField + ( + const fvPatch&, + const DimensionedField& + ); + + //- Construct from patch, internal field and dictionary + wideBandDiffusiveRadiationMixedFvPatchScalarField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given GreyDiffusiveRadiationMixedFvPatchField + // onto a new patch + wideBandDiffusiveRadiationMixedFvPatchScalarField + ( + const wideBandDiffusiveRadiationMixedFvPatchScalarField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + wideBandDiffusiveRadiationMixedFvPatchScalarField + ( + const wideBandDiffusiveRadiationMixedFvPatchScalarField& + ); + + //- Construct and return a clone + virtual tmp clone() const + { + return tmp + ( + new wideBandDiffusiveRadiationMixedFvPatchScalarField(*this) + ); + } + + //- Construct as copy setting internal field reference + wideBandDiffusiveRadiationMixedFvPatchScalarField + ( + const wideBandDiffusiveRadiationMixedFvPatchScalarField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp clone + ( + const DimensionedField& iF + ) const + { + return tmp + ( + new wideBandDiffusiveRadiationMixedFvPatchScalarField(*this, iF) + ); + } + + + // Member functions + + // Access + + //- Return the temperature field name + const word& TName() const + { + return TName_; + } + + //- Return reference to the temperature field name to allow + // adjustment + word& TName() + { + return TName_; + } + + //- Return the emissivity + const scalar& emissivity() const + { + return emissivity_; + } + + //- Return reference to the emissivity to allow adjustment + scalar& emissivity() + { + return emissivity_; + } + + + // Evaluation functions + + //- Update the coefficients associated with the patch field + virtual void updateCoeffs(); + + + // I-O + + //- Write + virtual void write(Ostream&) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/thermophysicalModels/radiation/radiationModel/P1/P1.C b/src/thermophysicalModels/radiation/radiationModel/P1/P1.C index 8679ac2861..dee9629292 100644 --- a/src/thermophysicalModels/radiation/radiationModel/P1/P1.C +++ b/src/thermophysicalModels/radiation/radiationModel/P1/P1.C @@ -50,9 +50,9 @@ namespace Foam } } + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -// Construct from components Foam::radiation::P1::P1(const volScalarField& T) : radiationModel(typeName, T), @@ -133,12 +133,8 @@ bool Foam::radiation::P1::read() } -void Foam::radiation::P1::correct() +void Foam::radiation::P1::calculate() { - if (!radiation_) - { - return; - } a_ = absorptionEmission_->a(); e_ = absorptionEmission_->e(); E_ = absorptionEmission_->E(); diff --git a/src/thermophysicalModels/radiation/radiationModel/P1/P1.H b/src/thermophysicalModels/radiation/radiationModel/P1/P1.H index 7215664cf7..c0249e28db 100644 --- a/src/thermophysicalModels/radiation/radiationModel/P1/P1.H +++ b/src/thermophysicalModels/radiation/radiationModel/P1/P1.H @@ -59,7 +59,6 @@ class P1 : public radiationModel { - // Private data //- Incident radiation / [W/m2] @@ -97,18 +96,17 @@ public: // Destructor - - ~P1(); + virtual ~P1(); // Member functions // Edit - //- Update radiationSource varible - void correct(); + //- Solve radiation equation(s) + void calculate(); - //- Read radiationProperties dictionary + //- Read radiation properties dictionary bool read(); diff --git a/src/thermophysicalModels/radiation/radiationModel/fvDOM/absorptionCoeffs/absorptionCoeffs.C b/src/thermophysicalModels/radiation/radiationModel/fvDOM/absorptionCoeffs/absorptionCoeffs.C new file mode 100644 index 0000000000..3452797b3e --- /dev/null +++ b/src/thermophysicalModels/radiation/radiationModel/fvDOM/absorptionCoeffs/absorptionCoeffs.C @@ -0,0 +1,110 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "absorptionCoeffs.H" +#include "IOstreams.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::radiation::absorptionCoeffs::absorptionCoeffs(Istream& is) +: + Tcommon_(readScalar(is)), + Tlow_(readScalar(is)), + Thigh_(readScalar(is)), + invTemp_(readBool(is)) +{ + for (label coefLabel=0; absorptionCoeffs::nCoeffs_; coefLabel++) + { + is >> highACoeffs_[coefLabel]; + } + + for (label coefLabel=0; absorptionCoeffs::nCoeffs_; coefLabel++) + { + is >> lowACoeffs_[coefLabel]; + } +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * // + +Foam::radiation::absorptionCoeffs::~absorptionCoeffs() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::radiation::absorptionCoeffs::checkT(const scalar T) const +{ + if (T < Tlow_ || T > Thigh_) + { + FatalErrorIn + ( + "absorptionCoeffs::checkT(const scalar T) const" + ) << "attempt to use absCoeff out of temperature range:" << nl + << " " << Tlow_ << " -> " << Thigh_ << "; T = " << T + << nl << abort(FatalError); + } +} + + +const Foam::radiation::absorptionCoeffs::coeffArray& +Foam::radiation::absorptionCoeffs::coeffs +( + const scalar T +) const +{ + checkT(T); + + if (T < Tcommon_) + { + return lowACoeffs_; + } + else + { + return highACoeffs_; + } +} + + +void Foam::radiation::absorptionCoeffs::initialise(Istream&) +{ + absorptionCoeffs(Istream); +} + + +void Foam::radiation::absorptionCoeffs::initialise(const dictionary& dict) +{ + dict.lookup("Tcommon") >> Tcommon_; + dict.lookup("Tlow") >> Tlow_; + dict.lookup("Tlow") >> Thigh_; + dict.lookup("invTemp") >> invTemp_; + + dict.lookup("loTcoeffs") >> lowACoeffs_; + dict.lookup("hiTcoeffs") >> highACoeffs_; +} + + +// ************************************************************************* // diff --git a/src/thermophysicalModels/radiation/radiationModel/fvDOM/absorptionCoeffs/absorptionCoeffs.H b/src/thermophysicalModels/radiation/radiationModel/fvDOM/absorptionCoeffs/absorptionCoeffs.H new file mode 100644 index 0000000000..1a79e310b9 --- /dev/null +++ b/src/thermophysicalModels/radiation/radiationModel/fvDOM/absorptionCoeffs/absorptionCoeffs.H @@ -0,0 +1,146 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::janafThermo + +Description + Absorption coefficients class used in greyMeanAbsorptionEmission and + wideBandAbsorptionEmission + +SourceFiles + absorptionCoeffs.C + +\*---------------------------------------------------------------------------*/ + +#ifndef absorptionCoeffs_H +#define absorptionCoeffs_H + +#include "List.H" +#include "IOstreams.H" +#include "IOdictionary.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +namespace Foam +{ +namespace radiation +{ + +/*---------------------------------------------------------------------------*\ + Class absorptionCoeffs Declaration +\*---------------------------------------------------------------------------*/ + +class absorptionCoeffs +{ +public: + + // Public data members + + static const int nCoeffs_ = 6; + typedef FixedList coeffArray; + + +private: + + // Private data + + // Temperature limits of applicability for functions + + scalar Tcommon_; + + scalar Tlow_; + + scalar Thigh_; + + + // Polynomial using inverse temperatures + bool invTemp_; + + coeffArray highACoeffs_; + coeffArray lowACoeffs_; + + + // Private member functions + + //- Check given temperature is within the range of the fitted coeffs + void checkT(const scalar T) const; + + +public: + + // Constructors + + //- Construct from Istream + absorptionCoeffs(Istream&); + + // Null constructor + absorptionCoeffs() + {} + + + // Destructor + ~absorptionCoeffs(); + + + // Member functions + + //- Return the coefficients corresponding to the given temperature + const coeffArray& coeffs(const scalar T) const; + + // Initialise from a dictionary + void initialise(const dictionary&); + + // Initialise from an Istream + void initialise(Istream&); + + + // Access Functions + + inline bool invTemp() const; + + inline scalar Tcommon() const; + + inline scalar Tlow() const; + + inline scalar Thigh() const; + + inline const coeffArray& highACoeffs() const; + + inline const coeffArray& lowACoeffs() const; +}; + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam +} // End namespace radiation + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "absorptionCoeffsI.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/thermophysicalModels/radiation/radiationModel/fvDOM/absorptionCoeffs/absorptionCoeffsI.H b/src/thermophysicalModels/radiation/radiationModel/fvDOM/absorptionCoeffs/absorptionCoeffsI.H new file mode 100644 index 0000000000..c7759db477 --- /dev/null +++ b/src/thermophysicalModels/radiation/radiationModel/fvDOM/absorptionCoeffs/absorptionCoeffsI.H @@ -0,0 +1,65 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +inline bool Foam::radiation::absorptionCoeffs::invTemp() const +{ + return invTemp_; +} + + +inline Foam::scalar Foam::radiation::absorptionCoeffs::Tcommon() const +{ + return Tcommon_; +} + + +inline Foam::scalar Foam::radiation::absorptionCoeffs::Tlow() const +{ + return Tlow_; +} + + +inline Foam::scalar Foam::radiation::absorptionCoeffs::Thigh() const +{ + return Thigh_; +} + + +inline const Foam::radiation::absorptionCoeffs::coeffArray& +Foam::radiation::absorptionCoeffs::highACoeffs() const +{ + return highACoeffs_; +} + + +inline const Foam::radiation::absorptionCoeffs::coeffArray& +Foam::radiation::absorptionCoeffs::lowACoeffs() const +{ + return lowACoeffs_; +} + + +// ************************************************************************* // diff --git a/src/thermophysicalModels/radiation/radiationModel/fvDOM/blackBodyEmission/blackBodyEmission.C b/src/thermophysicalModels/radiation/radiationModel/fvDOM/blackBodyEmission/blackBodyEmission.C new file mode 100644 index 0000000000..39d02831bb --- /dev/null +++ b/src/thermophysicalModels/radiation/radiationModel/fvDOM/blackBodyEmission/blackBodyEmission.C @@ -0,0 +1,143 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "blackBodyEmission.H" +#include "dimensionedConstants.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::radiation::blackBodyEmission::blackBodyEmission +( + const fileName& name, + const word& instance, + const label nLambda, + const volScalarField& T +) +: + blackBodyEmissiveTable_(name, instance, T.mesh()), + C1_("C1",dimensionSet(1, 4, 3, 0, 0, 0, 0), 3.7419e-16), + C2_("C2",dimensionSet(0, 1, 0, 1, 0, 0, 0), 14.388e-6), + bLambda_(nLambda), + T_(T) +{ + forAll(bLambda_, lambdaI) + { + bLambda_.set + ( + lambdaI, + new volScalarField + ( + IOobject + ( + "bLambda_" + Foam::name(lambdaI) , + T.mesh().time().timeName(), + T.mesh(), + IOobject::NO_READ, + IOobject::NO_WRITE + ), + radiation::sigmaSB*pow4(T) + ) + ); + + } +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::radiation::blackBodyEmission::~blackBodyEmission() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +Foam::scalar Foam::radiation::blackBodyEmission::fLambdaT +( + const scalar lambdaT +) const +{ + return blackBodyEmissiveTable_.lookUp(lambdaT*1.0e6)[1]; +} + + +Foam::tmp +Foam::radiation::blackBodyEmission::EbDeltaLambdaT +( + const volScalarField& T, + const Vector2D& band +) const +{ + tmp Eb + ( + new volScalarField + ( + IOobject + ( + "Eb", + T.mesh().time().timeName(), + T.mesh(), + IOobject::NO_READ, + IOobject::NO_WRITE + ), + radiation::sigmaSB*pow4(T) + ) + ); + + + if (band == Vector2D::one) + { + return Eb; + } + else + { + forAll(T, i) + { + scalar T1 = fLambdaT(band[1]*T[i]); + scalar T2 = fLambdaT(band[0]*T[i]); + dimensionedScalar fLambdaDelta + ( + "fLambdaDelta", + dimless, + T1 - T2 + ); + Eb()[i] = Eb()[i]*fLambdaDelta.value(); + } + return Eb; + } +} + + +void Foam::radiation::blackBodyEmission::correct +( + const label lambdaI, + const Vector2D& band +) +{ + bLambda_[lambdaI] = EbDeltaLambdaT(T_, band); +} + + +// ************************************************************************* // diff --git a/src/thermophysicalModels/radiation/radiationModel/fvDOM/blackBodyEmission/blackBodyEmission.H b/src/thermophysicalModels/radiation/radiationModel/fvDOM/blackBodyEmission/blackBodyEmission.H new file mode 100644 index 0000000000..d21582938f --- /dev/null +++ b/src/thermophysicalModels/radiation/radiationModel/fvDOM/blackBodyEmission/blackBodyEmission.H @@ -0,0 +1,143 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::radiation::blackBodyEmission + +Description + Class black body emission + +SourceFiles + blackBodyEmission.C + +\*---------------------------------------------------------------------------*/ + +#ifndef blackModyEmission_H +#define blackModyEmission_H + +#include "volFields.H" +#include "dimensionedScalar.H" +#include "mathematicalConstants.H" +#include "radiationConstants.H" +#include "interpolationLookUpTable.H" +#include "Vector2D.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace radiation +{ + +/*---------------------------------------------------------------------------*\ + Class blackBodyEmission Declaration +\*---------------------------------------------------------------------------*/ + +class blackBodyEmission +{ + // Private data + + mutable interpolationLookUpTable blackBodyEmissiveTable_; + + //- Constant C1 + const dimensionedScalar C1_; + + //- Constant C2 + const dimensionedScalar C2_; + + // Ptr List for black body emission energy field for each wavelength + PtrList bLambda_; + + // Reference to the temperature field + const volScalarField& T_; + + + // Private member functions + + scalar fLambdaT(const scalar lambdaT) const; + + +public: + + // Constructors + + //- Construct from components + blackBodyEmission + ( + const fileName& name, + const word& instance, + const label nLambda, + const volScalarField& T + ); + + + // Destructor + ~blackBodyEmission(); + + + // Member functions + + // Access + + //- Black body spectrum + inline const volScalarField& bLambda(const label lambdaI) const + { + return bLambda_[lambdaI]; + } + + //- Spectral emission for the black body at T and lambda + inline dimensionedScalar EblambdaT + ( + const dimensionedScalar& T, + const scalar lambda + ) const + { + return (C1_/(pow5(lambda)*(exp(C2_/(lambda*T)) - 1.0))); + } + + //- Integral energy at T from lambda1 to lambda2 + tmp EbDeltaLambdaT + ( + const volScalarField& T, + const Vector2D& band + ) const; + + + // Edit + + // Update black body emission + void correct(const label lambdaI, const Vector2D& band); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam +} // End namespace radiation + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/thermophysicalModels/radiation/radiationModel/fvDOM/blackBodyEmission/blackBodyEmissivePower b/src/thermophysicalModels/radiation/radiationModel/fvDOM/blackBodyEmission/blackBodyEmissivePower new file mode 100644 index 0000000000..c0151b436a --- /dev/null +++ b/src/thermophysicalModels/radiation/radiationModel/fvDOM/blackBodyEmission/blackBodyEmissivePower @@ -0,0 +1,174 @@ +171 +( +1000 0.00032 +1100 0.00091 +1200 0.00213 +1300 0.00432 +1400 0.00779 +1500 0.01285 +1600 0.01972 +1700 0.02853 +1800 0.03934 +1900 0.05210 +2000 0.06672 +2100 0.08305 +2200 0.10088 +2300 0.12002 +2400 0.14025 +2500 0.16135 +2600 0.18311 +2700 0.20535 +2800 0.22788 +2900 0.25055 +3000 0.27322 +3100 0.29576 +3200 0.31809 +3300 0.34009 +3400 0.36172 +3500 0.38290 +3600 0.40359 +3700 0.42375 +3800 0.44336 +3900 0.46240 +4000 0.48085 +4100 0.49872 +4200 0.51599 +4300 0.53267 +4400 0.54877 +4500 0.56429 +4600 0.57925 +4700 0.59366 +4800 0.60753 +4900 0.62088 +5000 0.63372 +5100 0.64606 +5200 0.65794 +5300 0.66935 +5400 0.68033 +5500 0.69087 +5600 0.70101 +5700 0.71076 +5800 0.72012 +5900 0.72913 +6000 0.73778 +6100 0.74610 +6200 0.75410 +6300 0.76180 +6400 0.76920 +6500 0.77631 +6600 0.78316 +6700 0.78975 +6800 0.79609 +6900 0.80219 +7000 0.80807 +7100 0.81373 +7200 0.81918 +7300 0.82443 +7400 0.82949 +7500 0.83436 +7600 0.83906 +7700 0.84359 +7800 0.84796 +7900 0.85218 +8000 0.85625 +8100 0.86017 +8200 0.86396 +8300 0.86762 +8400 0.87115 +8500 0.87456 +8600 0.87786 +8700 0.88105 +8800 0.88413 +8900 0.88711 +9000 0.88999 +9100 0.89277 +9200 0.89547 +9300 0.89807 +9400 0.90060 +9500 0.90304 +9600 0.90541 +9700 0.90770 +9800 0.90992 +9900 0.91207 +10000 0.91415 +10200 0.91813 +10400 0.92188 +10600 0.92540 +10800 0.92872 +11000 0.93184 +11200 0.93479 +11400 0.93758 +11600 0.94021 +11800 0.94270 +12000 0.94505 +12200 0.94728 +12400 0.94939 +12600 0.95139 +12800 0.95329 +13000 0.95509 +13200 0.95680 +13400 0.95843 +13600 0.95998 +13800 0.96145 +14000 0.96285 +14200 0.96418 +14400 0.96546 +14600 0.96667 +14800 0.96783 +15000 0.96893 +15200 0.96999 +15400 0.97100 +15600 0.97196 +15800 0.97288 +16000 0.97377 +16200 0.97461 +16400 0.97542 +16600 0.97620 +16800 0.97694 +17000 0.97765 +17200 0.97834 +17400 0.97899 +17600 0.97962 +17800 0.98023 +18000 0.98080 +18200 0.98137 +18400 0.98191 +18600 0.98243 +18900 0.98293 +19000 0.98340 +19200 0.98387 +19400 0.98431 +19600 0.98474 +19800 0.98515 +20000 0.98555 +21000 0.98735 +22000 0.98886 +23000 0.99014 +24000 0.99123 +25000 0.99217 +26000 0.99297 +27000 0.99367 +28000 0.99429 +29000 0.99482 +30000 0.99529 +31000 0.99571 +32000 0.99607 +33000 0.99640 +34000 0.99669 +35000 0.99695 +35000 0.99719 +36000 0.99740 +37000 0.99759 +38000 0.99776 +39000 0.99792 +40000 0.99806 +41000 0.99819 +42000 0.99831 +43000 0.99842 +44000 0.99851 +45000 0.99861 +46000 0.99869 +47000 0.99877 +48000 0.99884 +49000 0.99890 +) \ No newline at end of file diff --git a/src/thermophysicalModels/radiation/radiationModel/fvDOM/fvDOM/fvDOM.C b/src/thermophysicalModels/radiation/radiationModel/fvDOM/fvDOM/fvDOM.C new file mode 100644 index 0000000000..af3b14ebb0 --- /dev/null +++ b/src/thermophysicalModels/radiation/radiationModel/fvDOM/fvDOM/fvDOM.C @@ -0,0 +1,372 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "fvDOM.H" +#include "addToRunTimeSelectionTable.H" +#include "fvm.H" + +#include "absorptionEmissionModel.H" +#include "scatterModel.H" +#include "mathematicalConstants.H" +#include "radiationConstants.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + namespace radiation + { + defineTypeNameAndDebug(fvDOM, 0); + + addToRunTimeSelectionTable + ( + radiationModel, + fvDOM, + dictionary + ); + } +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::radiation::fvDOM::fvDOM(const volScalarField& T) +: + radiationModel(typeName, T), + G_ + ( + IOobject + ( + "G", + mesh_.time().timeName(), + mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh_, + dimensionedScalar("G", dimMass/pow3(dimTime), 0.0) + ), + Qr_ + ( + IOobject + ( + "Qr", + mesh_.time().timeName(), + mesh_, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + mesh_, + dimensionedScalar("Qr", dimMass/pow3(dimTime), 0.0) + ), + a_ + ( + IOobject + ( + "a", + mesh_.time().timeName(), + mesh_, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + mesh_, + dimensionedScalar("a", dimless/dimLength, 0.0) + ), + e_ + ( + IOobject + ( + "e", + mesh_.time().timeName(), + mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh_, + dimensionedScalar("a", dimless/dimLength, 0.0) + ), + E_ + ( + IOobject + ( + "E", + mesh_.time().timeName(), + mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh_, + dimensionedScalar("E", dimMass/dimLength/pow3(dimTime), 0.0) + ), + nTheta_(readLabel(coeffs_.lookup("nTheta"))), + nPhi_(readLabel(coeffs_.lookup("nPhi"))), + nRay_(0), + nLambda_(absorptionEmission_->nBands()), + aLambda_(nLambda_), + blackBody_ + ( + fileName("blackBodyEmissivePower"), + mesh_.time().constant(), + nLambda_, + T + ), + IRay_(0), + convergence_(coeffs_.lookupOrDefault("convergence", 0.0)) +{ + if (mesh_.nSolutionD() == 3) //3D + { + IRay_.setSize(4*nPhi_*nTheta_); + nRay_ = 4*nPhi_*nTheta_; + scalar deltaPhi = mathematicalConstant::pi/(2.0*nPhi_); + scalar deltaTheta = mathematicalConstant::pi/nTheta_; + label i = 0; + for (label n = 1; n <= nTheta_; n++) + { + for (label m = 1; m <= 4*nPhi_; m++) + { + scalar thetai = (2.0*n - 1.0)*deltaTheta/2.0; + scalar phii = (2.0*m - 1.0)*deltaPhi/2.0; + IRay_.set + ( + i, + new radiativeIntensityRay + ( + *this, + mesh_, + phii, + thetai, + deltaPhi, + deltaTheta, + nLambda_, + absorptionEmission_, + blackBody_ + ) + ); + i++; + } + } + } + else + { + if (mesh_.nSolutionD() == 2) //2D (X & Y) + { + scalar thetai = mathematicalConstant::pi/2.0; + scalar deltaTheta = mathematicalConstant::pi; + IRay_.setSize(4*nPhi_); + nRay_ = 4*nPhi_; + scalar deltaPhi = mathematicalConstant::pi/(2.0*nPhi_); + label i = 0; + for (label m = 1; m <= 4*nPhi_; m++) + { + scalar phii = (2.0*m - 1.0)*deltaPhi/2.0; + IRay_.set + ( + i, + new radiativeIntensityRay + ( + *this, + mesh_, + phii, + thetai, + deltaPhi, + deltaTheta, + nLambda_, + absorptionEmission_, + blackBody_ + ) + ); + i++; + } + } + else //1D (X) + { + scalar thetai = mathematicalConstant::pi/2.0; + scalar deltaTheta = mathematicalConstant::pi; + IRay_.setSize(2); + nRay_ = 2; + scalar deltaPhi = mathematicalConstant::pi; + label i = 0; + for (label m = 1; m <= 2; m++) + { + scalar phii = (2.0*m - 1.0)*deltaPhi/2.0; + IRay_.set + ( + i, + new radiativeIntensityRay + ( + *this, + mesh_, + phii, + thetai, + deltaPhi, + deltaTheta, + nLambda_, + absorptionEmission_, + blackBody_ + ) + ); + i++; + } + + } + } + + + // Construct absorption field for each wavelength + forAll(aLambda_, lambdaI) + { + aLambda_.set + ( + lambdaI, + new volScalarField + ( + IOobject + ( + "aLambda_" + Foam::name(lambdaI) , + mesh_.time().timeName(), + mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + a_ + ) + ); + } +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::radiation::fvDOM::~fvDOM() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +bool Foam::radiation::fvDOM::read() +{ + if (radiationModel::read()) + { + // nothing to read + +// coeffs_.lookup("nTheta") >> nTheta_; +// coeffs_.lookup("nPhi") >> nPhi_; + + return true; + } + else + { + return false; + } +} + + +void Foam::radiation::fvDOM::calculate() +{ + absorptionEmission_->correct(a_, aLambda_); + + updateBlackBodyEmission(); + + scalar maxResidual = 0.0; + label radIter = 0; + do + { + radIter++; + forAll(IRay_, rayI) + { + maxResidual = 0.0; + scalar maxBandResidual = IRay_[rayI].correct(); + maxResidual = max(maxBandResidual, maxResidual); + } + + Info << "Radiation solver iter: " << radIter << endl; + + } while(maxResidual > convergence_); + + updateG(); +} + + +Foam::tmp Foam::radiation::fvDOM::Rp() const +{ + return tmp + ( + new volScalarField + ( + IOobject + ( + "Rp", + mesh_.time().timeName(), + mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE, + false + ), + 4.0*a_*radiation::sigmaSB //absorptionEmission_->a() + ) + ); +} + + +Foam::tmp > +Foam::radiation::fvDOM::Ru() const +{ + + const DimensionedField& G = + G_.dimensionedInternalField(); + const DimensionedField E = + absorptionEmission_->ECont()().dimensionedInternalField(); + const DimensionedField a = + a_.dimensionedInternalField(); //absorptionEmission_->aCont()() + + return a*G - 4.0*E; +} + + +void Foam::radiation::fvDOM::updateBlackBodyEmission() +{ + for (label j=0; j < nLambda_; j++) + { + blackBody_.correct(j, absorptionEmission_->bands(j)); + } +} + + +void Foam::radiation::fvDOM::updateG() +{ + G_ = dimensionedScalar("zero",dimMass/pow3(dimTime), 0.0); + Qr_ = dimensionedScalar("zero",dimMass/pow3(dimTime), 0.0); + + forAll(IRay_, rayI) + { + IRay_[rayI].addIntensity(); + G_ += IRay_[rayI].I()*IRay_[rayI].omega(); + Qr_ += IRay_[rayI].Qr(); + } +} + + +// ************************************************************************* // diff --git a/src/thermophysicalModels/radiation/radiationModel/fvDOM/fvDOM/fvDOM.H b/src/thermophysicalModels/radiation/radiationModel/fvDOM/fvDOM/fvDOM.H new file mode 100644 index 0000000000..3cbd921406 --- /dev/null +++ b/src/thermophysicalModels/radiation/radiationModel/fvDOM/fvDOM/fvDOM.H @@ -0,0 +1,227 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::radiation::fvDOM + +Description + + Finite Volume Discrete Ordinary Method. Solves the RTE equation for n + directions in a participating media, not including scatter. + + Available absorption models: + greyMeanAbsoprtionEmission + wideBandAbsorptionEmission + + i.e. dictionary + fvDOMCoeffs + { + Nphi 1; // azimuthal angles in PI/2 on X-Y.(from Y to X) + Ntheta 2; // polar angles in P1 (from Z to X-Y plane) + convergence 1e-4; // convergence criteria for radiation iteration + } + + nFlowIterPerRadIter 1; // Number of flow iterations per radiation + iteration + + The total number of solid angles is 4*Nphi*Ntheta. + + In 1D the direction of the rays is X (Nphi and Ntheta are ignored) + In 2D the direction of the rays is on X-Y plane (only Nphi is considered) + In 3D (Nphi and Ntheta are considered) + +SourceFiles + fvDOM.C + +\*---------------------------------------------------------------------------*/ + +#ifndef radiationModelfvDOM_H +#define radiationModelfvDOM_H + +#include "radiativeIntensityRay.H" +#include "radiationModel.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace radiation +{ + +/*---------------------------------------------------------------------------*\ + Class fvDOM Declaration +\*---------------------------------------------------------------------------*/ + +class fvDOM +: + public radiationModel +{ + // Private data + + //- Incident radiation [W/m2] + volScalarField G_; + + //- Total radiative heat flux [W/m2] + volScalarField Qr_; + + //- Total absorption coefficient [1/m] + volScalarField a_; + + //- Total emission coefficient [1/m] + volScalarField e_; + + //- Emission contribution [Kg/m/s^3] + volScalarField E_; + + //- Number of solid angles in theta + label nTheta_; + + //- Number of solid angles in phi + label nPhi_ ; + + //- Total number of rays (1 per direction) + label nRay_; + + //- Number of wavelength bands + label nLambda_; + + //- Wavelength total absorption coefficient [1/m] + PtrList aLambda_; + + //- Black body + blackBodyEmission blackBody_; + + //- List of pointers to radiative intensity rays + PtrList IRay_; + + //- Convergence criterion + scalar convergence_; + + + // Private member functions + + //- Disallow default bitwise copy construct + fvDOM(const fvDOM&); + + //- Disallow default bitwise assignment + void operator=(const fvDOM&); + + //- Update Absorption Coefficients +// void updateAbsorptionCoeffs(void); + + //- Update nlack body emission + void updateBlackBodyEmission(); + + +public: + + //- Runtime type information + TypeName("fvDOM"); + + + // Constructors + + //- Construct from components + fvDOM(const volScalarField& T); + + + //- Destructor + virtual ~fvDOM(); + + + // Member functions + + // Edit + + //- Solve radiation equation(s) + void calculate(); + + //- Read radiation properties dictionary + bool read(); + + //- Update G and calculate total heat flux on boundary + void updateG(); + + //- Source term component (for power of T^4) + virtual tmp Rp() const; + + //- Source term component (constant) + virtual tmp > Ru() const; + + + // Access + + //- Ray intensity for rayI + inline const radiativeIntensityRay& IRay(const label rayI) const; + + //- Ray intensity for rayI and lambda bandwidth + inline const volScalarField& IRayLambda + ( + const label rayI, + const label lambdaI + ) const; + + //- Number of angles in theta + inline label nTheta() const; + + //- Number of angles in phi + inline label nPhi() const; + + //- Number of rays + inline label nRay() const; + + //- Number of wavelengths + inline label nLambda() const; + + // Const access to total absorption coefficient + inline const volScalarField& a() const; + + // Const access to wavelength total absorption coefficient + inline const volScalarField& aLambda(const label lambdaI) const; + + // Const access to incident radiation field + inline const volScalarField& G() const; + + // Const access to total radiative heat flux field + inline const volScalarField& Qr() const; + + // Const access to black body + inline const blackBodyEmission& blackBody() const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "fvDOMI.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace radiation +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/thermophysicalModels/radiation/radiationModel/fvDOM/fvDOM/fvDOMI.H b/src/thermophysicalModels/radiation/radiationModel/fvDOM/fvDOM/fvDOMI.H new file mode 100644 index 0000000000..594b5bee0a --- /dev/null +++ b/src/thermophysicalModels/radiation/radiationModel/fvDOM/fvDOM/fvDOMI.H @@ -0,0 +1,103 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +inline const Foam::radiation::radiativeIntensityRay& +Foam::radiation::fvDOM::IRay(const label rayI) const +{ + return IRay_[rayI]; +} + + +inline const Foam::volScalarField& +Foam::radiation::fvDOM::IRayLambda +( + const label rayI, + const label lambdaI +) const +{ + return IRay_[rayI].ILambda(lambdaI); +} + + +inline Foam::label Foam::radiation::fvDOM::nTheta() const +{ + return nTheta_; +} + + +inline Foam::label Foam::radiation::fvDOM::nPhi() const +{ + return nPhi_; +} + + +inline Foam::label Foam::radiation::fvDOM::nRay() const +{ + return nRay_; +} + + +inline Foam::label Foam::radiation::fvDOM::nLambda() const +{ + return nLambda_; +} + + +inline const Foam::volScalarField& Foam::radiation::fvDOM::a() const +{ + return a_; +} + + +inline const Foam::volScalarField& Foam::radiation::fvDOM::aLambda +( + const label lambdaI +) const +{ + return aLambda_[lambdaI]; +} + + +inline const Foam::volScalarField& Foam::radiation::fvDOM::G() const +{ + return G_; +} + + +inline const Foam::volScalarField& Foam::radiation::fvDOM::Qr() const +{ + return Qr_; +} + + +inline const Foam::radiation::blackBodyEmission& +Foam::radiation::fvDOM::blackBody() const +{ + return blackBody_; +} + + +// ************************************************************************* // diff --git a/src/thermophysicalModels/radiation/radiationModel/fvDOM/interpolationLookUpTable/interpolationLookUpTable.C b/src/thermophysicalModels/radiation/radiationModel/fvDOM/interpolationLookUpTable/interpolationLookUpTable.C new file mode 100755 index 0000000000..e9e28658c4 --- /dev/null +++ b/src/thermophysicalModels/radiation/radiationModel/fvDOM/interpolationLookUpTable/interpolationLookUpTable.C @@ -0,0 +1,521 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "IFstream.H" + +// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // + +template +Foam::label Foam::interpolationLookUpTable ::index +( + const List& indices, + const bool lastDim +) const +{ + label totalindex = 0; + + for (int i = 0; i < dim_.size() - 1; i++) + { + label dim = 1; + for (int j = i + 1; j < dim_.size(); j++) + { + dim *=(dim_[j]+1); + } + + totalindex += + dim + *min + ( + max(label((indices[i] - min_[i])/delta_[i]), 0), + dim_[i] + ); + } + + if (lastDim) + { + label iLastdim = dim_.size() - 1; + totalindex += Foam::min + ( + max + ( + label((indices[iLastdim] - min_[iLastdim])/delta_[iLastdim]), + 0 + ), + dim_[iLastdim] + ); + } + + return totalindex; +} + + +template +Foam::label Foam::interpolationLookUpTable ::index +( + const scalar indice +) const +{ + label i = 0; + label totalIndex = + Foam::min + ( + Foam::max + ( + label((indice - min_[i])/delta_[i]), + 0 + ), + dim_[i] + ); + + return totalIndex; +} + + +template +bool Foam::interpolationLookUpTable::checkRange +( + const scalar lookUpValue, + const label interfield +) const +{ + if (lookUpValue >= min_[interfield] && lookUpValue <= max_[interfield]) + { + return true; + } + else + { + return false; + } +} + + +template +Foam::scalar Foam::interpolationLookUpTable::interpolate +( + const label lo, + const label hi, + const scalar lookUpValue, + const label ofield, + const label interfield +) const +{ + if + ( + List::operator[](interfield).operator[](hi) + != List::operator[](interfield).operator[](lo) + ) + { + scalar output + ( + List::operator[](ofield).operator[](lo) + + ( + List::operator[](ofield).operator[](hi) + - List::operator[](ofield).operator[](lo) + ) + *( + lookUpValue + - List::operator[](interfield).operator[](lo) + ) + /( + List::operator[](interfield).operator[](hi) + - List::operator[](interfield).operator[](lo) + ) + ); + return output; + } + else + { + return List::operator[](ofield).operator[](lo); + } +} + + +template +void Foam::interpolationLookUpTable::dimensionTable() +{ + min_.setSize(entries_.size()); + dim_.setSize(entries_.size()); + delta_.setSize(entries_.size()); + max_.setSize(entries_.size()); + entryIndices_.setSize(entries_.size()); + outputIndices_.setSize(output_.size()); + label index = 0; + label tableDim = 1; + + forAll(entries_,i) + { + dim_[i] = readLabel(entries_[i].lookup("N")); + max_[i] = readScalar(entries_[i].lookup("max")); + min_[i] = readScalar(entries_[i].lookup("min")); + delta_[i] = (max_[i] - min_[i])/dim_[i]; + tableDim *= (dim_[i] + 1); + fieldIndices_.insert(entries_[i].lookup("name"),index); + entryIndices_[i] = index; + index++; + } + + forAll(output_,i) + { + fieldIndices_.insert(output_[i].lookup("name"),index); + outputIndices_[i] = index; + index++; + } + + List& internal = *this; + + internal.setSize(entries_.size() + output_.size()); + + interpOutput_.setSize(entries_.size() + output_.size()); + + forAll(internal, i) + { + internal[i].setSize(tableDim); + } +} + + +template +void Foam::interpolationLookUpTable::readTable +( + const word& instance, + const fvMesh& mesh +) +{ + IOdictionary control + ( + IOobject + ( + fileName_, + instance, + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE + ) + ); + + control.lookup("fields") >> entries_; + control.lookup("output") >> output_; + control.lookup("values") >> *this; + + dimensionTable(); + + check(); + + if (this->size() == 0) + { + FatalErrorIn + ( + "Foam::interpolationLookUpTable::readTable()" + ) << "table is empty" << nl + << exit(FatalError); + } +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template +Foam::interpolationLookUpTable::interpolationLookUpTable() +: + List(), + fileName_("fileNameIsUndefined") +{} + + +template +Foam::interpolationLookUpTable::interpolationLookUpTable +( + const fileName& fn, const word& instance, const fvMesh& mesh +) +: + List(), + fileName_(fn), + dim_(0), + min_(0), + delta_(0.0), + max_(0.0), + entries_(0), + output_(0), + entryIndices_(0), + outputIndices_(0), + interpOutput_(0) +{ + readTable(instance, mesh); +} + + +template +Foam::interpolationLookUpTable::interpolationLookUpTable +( + const interpolationLookUpTable& interpTable +) +: + List(interpTable), + fileName_(interpTable.fileName_), + entryIndices_(interpTable.entryIndices_), + outputIndices_(interpTable.outputIndices_), + dim_(interpTable.dim_), + min_(interpTable.min_), + delta_(interpTable.delta_), + max_(interpTable.max_), + entries_(0), + output_(0), + interpOutput_(interpTable.interpOutput_) +{} + + +template +Foam::interpolationLookUpTable::interpolationLookUpTable +( + const dictionary& dict +) +: + List(), + fileName_(fileName(dict.lookup("fileName")).expand()), + dim_(0), + min_(0.0), + delta_(0.0), + max_(0.0), + entries_(dict.lookup("fields")), + output_(dict.lookup("output")), + entryIndices_(0), + outputIndices_(0), + fieldIndices_(0), + interpOutput_(0) +{ + dimensionTable(); +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template +void Foam::interpolationLookUpTable::check() const +{ +// check order in the first dimension. + + scalar prevValue = List::operator[](0).operator[](0); + label dim = 1 ; + for (int j = 1; j < dim_.size(); j++) + { + dim *=(dim_[j]+1); + } + + for (label i = 1; i < dim_[0]; i++) + { + label index = i*dim; + const scalar currValue = + List::operator[](0).operator[](index); + + // avoid duplicate values (divide-by-zero error) + if (currValue <= prevValue) + { + FatalErrorIn + ( + "Foam::interpolationLookUpTable::checkOrder() const" + ) << "out-of-order value: " + << currValue << " at index " << index << nl + << exit(FatalError); + } + prevValue = currValue; + } +} + + +template +void Foam::interpolationLookUpTable::write +( + Ostream& os, + const fileName& fn, + const word& instance, + const fvMesh& mesh +) const +{ + IOdictionary control + ( + IOobject + ( + fn, + instance, + mesh, + IOobject::NO_READ, + IOobject::NO_WRITE + ) + ); + + control.writeHeader(os); + + os.writeKeyword("fields"); + os << entries_ << token::END_STATEMENT << nl; + + os.writeKeyword("output"); + os << output_ << token::END_STATEMENT << nl; + + if (this->size() == 0) + { + FatalErrorIn + ( + "Foam::interpolationTable::write()" + ) << "table is empty" << nl + << exit(FatalError); + } + os.writeKeyword("values"); + os << *this << token::END_STATEMENT << nl; +} + + +// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // + +template +Foam::scalarField& +Foam::interpolationLookUpTable::operator[](const label i) +{ + label ii = i; + label n = this->size(); + + if (n <= 1) + { + FatalErrorIn + ( + "Foam::interpolationLookUpTable::operator[]" + "(const label) const" + ) << "table has (" << n << ") columns" << nl + << exit(FatalError); + } + else if (ii < 0) + { + FatalErrorIn + ( + "Foam::interpolationLookUpTable::operator[]" + "(const label) const" + ) << "index (" << ii << ") underflow" << nl + << exit(FatalError); + } + else if (ii > n) + { + FatalErrorIn + ( + "Foam::interpolationLookUpTable::operator[]" + "(const label) const" + ) << "index (" << ii << ") overflow" << nl + << exit(FatalError); + } + + return List::operator[](ii); +} + + +template +const Foam::scalarField& +Foam::interpolationLookUpTable::operator[](const label i) const +{ + label ii = i; + label n = this->size(); + + if (n <= 1) + { + FatalErrorIn + ( + "Foam::interpolationLookUpTable::operator[]" + "(const label) const" + ) << "table has (" << n << ") columns" << nl + << exit(FatalError); + } + else if (ii < 0) + { + FatalErrorIn + ( + "Foam::interpolationLookUpTable::operator[]" + "(const label) const" + ) << "index (" << ii << ") underflow" << nl + << exit(FatalError); + } + + else if (ii > n) + { + FatalErrorIn + ( + "Foam::interpolationLookUpTable::operator[]" + "(const label) const" + ) << "index (" << ii << ") overflow" << nl + << exit(FatalError); + } + + return List::operator[](ii); +} + + +template +bool Foam::interpolationLookUpTable::found(const word& fieldName) const +{ + return fieldIndices_.found(fieldName); +} + + +template +const Foam::scalarList& +Foam::interpolationLookUpTable::lookUp(const scalar retvals) +{ + const label lo = index(retvals); + findHi(lo, retvals); + return interpOutput_; +} + + +template +void Foam::interpolationLookUpTable::findHi +( + const label lo, + const scalar retvals +) +{ + forAll(outputIndices_,j) + { + scalar tmp = 0; + label ofield = outputIndices_[j]; + scalar baseValue = List::operator[](ofield).operator[](lo); + + forAll(entryIndices_,i) + { + if (checkRange(retvals,entryIndices_[i])) + { + label dim = 1; + + label hi = Foam::min(lo + dim, (*this)[0].size() - 1); + + tmp += interpolate(lo, hi, retvals, ofield, entryIndices_[i]) + - baseValue; + } + interpOutput_[entryIndices_[i]] = retvals; + } + + tmp += baseValue; + interpOutput_[outputIndices_[j]] = tmp; + } +} + + +// ************************************************************************* // diff --git a/src/thermophysicalModels/radiation/radiationModel/fvDOM/interpolationLookUpTable/interpolationLookUpTable.H b/src/thermophysicalModels/radiation/radiationModel/fvDOM/interpolationLookUpTable/interpolationLookUpTable.H new file mode 100755 index 0000000000..d2518d4e02 --- /dev/null +++ b/src/thermophysicalModels/radiation/radiationModel/fvDOM/interpolationLookUpTable/interpolationLookUpTable.H @@ -0,0 +1,234 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::interpolationLookUpTable + +Description + A list of lists. Interpolates based on the first dimension. + The values must be positive and monotonically increasing in each dimension + +Note + - Accessing an empty list results in an error. + - Accessing a list with a single element always returns the same value. + +SourceFiles + interpolationLookUpTable.C + +\*---------------------------------------------------------------------------*/ + +#ifndef interpolationLookUpTable_H +#define interpolationLookUpTable_H + +#include "List.H" +#include "ListOps.H" +#include "scalarField.H" +#include "HashTable.H" +#include "IOdictionary.H" +#include "fvCFD.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class interpolationLookUpTable Declaration +\*---------------------------------------------------------------------------*/ + +template +class interpolationLookUpTable +: + public List +{ +private: + + // Private data + + //- File name + fileName fileName_; + + //- Table dimensions + List