From 97de9529af1dc89524d7536f449ab874cb249bed Mon Sep 17 00:00:00 2001 From: andy Date: Fri, 20 Mar 2009 11:07:53 +0000 Subject: [PATCH 01/16] initial commit of sergio's fvDOM model --- src/thermophysicalModels/radiation/Make/files | 13 +- .../radiation/Make/options | 5 +- ...iffusiveRadiationMixedFvPatchScalarField.C | 312 ++++++++++ ...iffusiveRadiationMixedFvPatchScalarField.H | 218 +++++++ ...iffusiveRadiationMixedFvPatchScalarField.C | 314 ++++++++++ ...iffusiveRadiationMixedFvPatchScalarField.H | 218 +++++++ .../radiation/radiationModel/P1/P1.C | 9 +- .../radiation/radiationModel/P1/P1.H | 4 + .../fvDOM/absorptionCoeffs/absorptionCoeffs.C | 112 ++++ .../fvDOM/absorptionCoeffs/absorptionCoeffs.H | 153 +++++ .../blackBodyEmission/blackBodyEmission.C | 143 +++++ .../blackBodyEmission/blackBodyEmission.H | 124 ++++ .../blackBodyEmission/blackBodyEmissivePower | 174 ++++++ .../radiationModel/fvDOM/fvDOM/fvDOM.C | 353 ++++++++++++ .../radiationModel/fvDOM/fvDOM/fvDOM.H | 257 +++++++++ .../interpolationLookUpTable.C | 540 ++++++++++++++++++ .../interpolationLookUpTable.H | 247 ++++++++ .../radiativeIntensityRay.C | 250 ++++++++ .../radiativeIntensityRay.H | 214 +++++++ .../radiationModel/newRadiationModel.C | 6 +- .../radiationModel/radiationModel.C | 5 +- .../radiationModel/radiationModel.H | 8 + .../absorptionEmissionModel.C | 60 +- .../absorptionEmissionModel.H | 51 +- .../constantAbsorptionEmission.C | 6 +- .../constantAbsorptionEmission.H | 13 +- .../greyMeanAbsorptionEmission.C | 273 +++++++++ .../greyMeanAbsorptionEmission.H | 207 +++++++ .../wideBandAbsorptionEmission.C | 318 +++++++++++ .../wideBandAbsorptionEmission.H | 264 +++++++++ 30 files changed, 4833 insertions(+), 38 deletions(-) create mode 100644 src/thermophysicalModels/radiation/derivedFvPatchFields/GreyDiffusiveRadiation/GreyDiffusiveRadiationMixedFvPatchScalarField.C create mode 100644 src/thermophysicalModels/radiation/derivedFvPatchFields/GreyDiffusiveRadiation/GreyDiffusiveRadiationMixedFvPatchScalarField.H create mode 100644 src/thermophysicalModels/radiation/derivedFvPatchFields/WideBandDiffusiveRadiation/WideBandDiffusiveRadiationMixedFvPatchScalarField.C create mode 100644 src/thermophysicalModels/radiation/derivedFvPatchFields/WideBandDiffusiveRadiation/WideBandDiffusiveRadiationMixedFvPatchScalarField.H create mode 100644 src/thermophysicalModels/radiation/radiationModel/fvDOM/absorptionCoeffs/absorptionCoeffs.C create mode 100644 src/thermophysicalModels/radiation/radiationModel/fvDOM/absorptionCoeffs/absorptionCoeffs.H create mode 100644 src/thermophysicalModels/radiation/radiationModel/fvDOM/blackBodyEmission/blackBodyEmission.C create mode 100644 src/thermophysicalModels/radiation/radiationModel/fvDOM/blackBodyEmission/blackBodyEmission.H create mode 100644 src/thermophysicalModels/radiation/radiationModel/fvDOM/blackBodyEmission/blackBodyEmissivePower create mode 100644 src/thermophysicalModels/radiation/radiationModel/fvDOM/fvDOM/fvDOM.C create mode 100644 src/thermophysicalModels/radiation/radiationModel/fvDOM/fvDOM/fvDOM.H create mode 100755 src/thermophysicalModels/radiation/radiationModel/fvDOM/interpolationLookUpTable/interpolationLookUpTable.C create mode 100755 src/thermophysicalModels/radiation/radiationModel/fvDOM/interpolationLookUpTable/interpolationLookUpTable.H create mode 100644 src/thermophysicalModels/radiation/radiationModel/fvDOM/radiativeIntensityRay/radiativeIntensityRay.C create mode 100644 src/thermophysicalModels/radiation/radiationModel/fvDOM/radiativeIntensityRay/radiativeIntensityRay.H create mode 100644 src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/greyMeanAbsorptionEmission/greyMeanAbsorptionEmission.C create mode 100644 src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/greyMeanAbsorptionEmission/greyMeanAbsorptionEmission.H create mode 100644 src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/wideBandAbsorptionEmission/wideBandAbsorptionEmission.C create mode 100644 src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/wideBandAbsorptionEmission/wideBandAbsorptionEmission.H diff --git a/src/thermophysicalModels/radiation/Make/files b/src/thermophysicalModels/radiation/Make/files index 9b385e8a56..cfce312410 100644 --- a/src/thermophysicalModels/radiation/Make/files +++ b/src/thermophysicalModels/radiation/Make/files @@ -1,13 +1,16 @@ + /* 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 +24,13 @@ 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..818b874d1d --- /dev/null +++ b/src/thermophysicalModels/radiation/derivedFvPatchFields/GreyDiffusiveRadiation/GreyDiffusiveRadiationMixedFvPatchScalarField.C @@ -0,0 +1,312 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 "radiationModel.H" +#include "fvDOM.H" +#include "radiationConstants.H" +#include "mathematicalConstants.H" + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::radiation::GreyDiffusiveRadiationMixedFvPatchField:: +GreyDiffusiveRadiationMixedFvPatchField +( + const fvPatch& p, + const DimensionedField& iF +) +: + mixedFvPatchScalarField(p, iF), + TName_("undefined"), + emissivity_(0.0), + myRayIndex_(0), + myWaveLengthIndex_(0), + myRayIsInit_(-1), + qr_(0) +{ + refValue() = 0.0; + refGrad() = 0.0; + valueFraction() = 1.0; + qr_.setSize(p.size()); +} + + +Foam::radiation::GreyDiffusiveRadiationMixedFvPatchField:: +GreyDiffusiveRadiationMixedFvPatchField +( + const GreyDiffusiveRadiationMixedFvPatchField& ptf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + mixedFvPatchScalarField(ptf, p, iF, mapper), + TName_(ptf.TName_), + emissivity_(ptf.emissivity_), + myRayIndex_(ptf.myRayIndex_), + myWaveLengthIndex_(ptf.myWaveLengthIndex_), + myRayIsInit_(ptf.myRayIsInit_), + qr_(ptf.qr_) +{} + + +Foam::radiation::GreyDiffusiveRadiationMixedFvPatchField:: +GreyDiffusiveRadiationMixedFvPatchField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + mixedFvPatchScalarField(p, iF), + TName_(dict.lookup("T")), + emissivity_(readScalar(dict.lookup("emissivity"))), + myRayIndex_(0), + myWaveLengthIndex_(0), + myRayIsInit_(-1), + qr_(0) +{ + const scalarField& Tp = + patch().lookupPatchField(TName_); + + refValue() = emissivity_*4.0*radiation::sigmaSB.value()*pow4(Tp) / + Foam::mathematicalConstant::pi; + refGrad() = 0.0; + + qr_.setSize(p.size()); + + if (dict.found("value")) + { + fvPatchScalarField::operator= + ( + scalarField("value", dict, p.size()) + ); + } + else + { + fvPatchScalarField::operator=(refValue()); + } +} + + +Foam::radiation::GreyDiffusiveRadiationMixedFvPatchField:: +GreyDiffusiveRadiationMixedFvPatchField +( + const GreyDiffusiveRadiationMixedFvPatchField& ptf +) +: + mixedFvPatchScalarField(ptf), + TName_(ptf.TName_), + emissivity_(ptf.emissivity_), + myRayIndex_(ptf.myRayIndex_), + myWaveLengthIndex_(ptf.myWaveLengthIndex_), + myRayIsInit_(ptf.myRayIsInit_), + qr_(ptf.qr_) +{} + + +Foam::radiation::GreyDiffusiveRadiationMixedFvPatchField:: +GreyDiffusiveRadiationMixedFvPatchField +( + const GreyDiffusiveRadiationMixedFvPatchField& ptf, + const DimensionedField& iF +) +: + mixedFvPatchScalarField(ptf, iF), + TName_(ptf.TName_), + emissivity_(ptf.emissivity_), + myRayIndex_(ptf.myRayIndex_), + myWaveLengthIndex_(ptf.myWaveLengthIndex_), + myRayIsInit_(ptf.myRayIsInit_), + qr_(ptf.qr_) + +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::radiation::GreyDiffusiveRadiationMixedFvPatchField::autoMap +( + const fvPatchFieldMapper& m +) +{ + scalarField::autoMap(m); + +} + + +void Foam::radiation::GreyDiffusiveRadiationMixedFvPatchField::rmap +( + const fvPatchScalarField& ptf, + const labelList& addr +) +{ + mixedFvPatchScalarField::rmap(ptf, addr); + +// const GreyDiffusiveRadiationMixedFvPatchField& mrptf = + refCast(ptf); +} + + +void Foam::radiation::GreyDiffusiveRadiationMixedFvPatchField::updateCoeffs() +{ + if (this->updated()) + { + return; + } + + const scalarField& Tp = + patch().lookupPatchField(TName_); + + const radiationModel& rad = + db().lookupObject("radiationProperties"); + + const fvDOM& Dom(refCast(rad)); + + const label patchi = patch().index(); + + if(Dom.lambdaj() == 1) + { + if (myRayIsInit_ == -1) + { + for(label i=0; i < Dom.Ni() ; i++) + { + for(label j=0; j < Dom.lambdaj() ; j++) + { + const volScalarField& radiationField = + Dom.RadIntRayiLambdaj(i,j); + if (&(radiationField.internalField()) == + &dimensionedInternalField()) + { + myRayIndex_ = i; + myWaveLengthIndex_ = j; + myRayIsInit_ = 0.; + break; + } + } + } + } + } + else + { + FatalErrorIn + ( + "Foam::radiation::" + "GreyDiffusiveRadiationMixedFvPatchField::" + "updateCoeffs" + ) << " a grey boundary condition is used with a non-grey" + << "absorption model" + << exit(FatalError); + } + + vectorField n = patch().Sf()/patch().magSf(); + + scalarField& Iw = *(this); + + qr_ = Iw *(-n & Dom.RadIntRay(myRayIndex_).Di()); + + Dom.RadIntRay(myRayIndex_).add(qr_,patchi); + + forAll(Iw, faceI) + { + + scalar Ir = 0.0; + + for(label i=0; i < Dom.Ni() ; i++) // + { + const vector& si = Dom.RadIntRay(i).Si(); + + const scalarField& Iface = Dom.RadIntRay(i).Ilambdaj + ( + myWaveLengthIndex_ + ).boundaryField()[patch().index()]; + + scalar InOut = -n[faceI] & si; + + if (InOut < 0.) // qin into the wall + { + const vector& di = Dom.RadIntRay(i).Di(); + Ir += Iface[faceI]*mag(n[faceI] & di); + } + } + + const vector& mySi = Dom.RadIntRay(myRayIndex_).Si(); + + scalar InOut = -n[faceI] & mySi; + + if (InOut > 0.) //direction out of the wall + { + refGrad()[faceI] = 0.0; + valueFraction()[faceI] = 1.0; + refValue()[faceI] = ((1. - emissivity_) * Ir + + emissivity_*radiation::sigmaSB.value()*pow4(Tp[faceI])) / + Foam::mathematicalConstant::pi; + + } + else if (InOut < 0.) //direction into the wall + { + valueFraction()[faceI] = 0.0; + refGrad()[faceI] = 0.0; + refValue()[faceI] = 0.0; //not used + } + } + + mixedFvPatchScalarField::updateCoeffs(); +} + + +void Foam::radiation::GreyDiffusiveRadiationMixedFvPatchField::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, + GreyDiffusiveRadiationMixedFvPatchField + ); +} +} + + +// ************************************************************************* // diff --git a/src/thermophysicalModels/radiation/derivedFvPatchFields/GreyDiffusiveRadiation/GreyDiffusiveRadiationMixedFvPatchScalarField.H b/src/thermophysicalModels/radiation/derivedFvPatchFields/GreyDiffusiveRadiation/GreyDiffusiveRadiationMixedFvPatchScalarField.H new file mode 100644 index 0000000000..cc0cd34129 --- /dev/null +++ b/src/thermophysicalModels/radiation/derivedFvPatchFields/GreyDiffusiveRadiation/GreyDiffusiveRadiationMixedFvPatchScalarField.H @@ -0,0 +1,218 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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::GreyDiffusiveRadiationMixedFvPatchField + +Description + Radiation temperature specified + +SourceFiles + GreyDiffusiveRadiationMixedFvPatchField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef GreyDiffusiveRadiationMixedFvPatchField_H +#define GreyDiffusiveRadiationMixedFvPatchField_H + +#include "mixedFvPatchFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace radiation +{ +/*---------------------------------------------------------------------------*\ + Class GreyDiffusiveRadiationMixedFvPatchField Declaration +\*---------------------------------------------------------------------------*/ + +class GreyDiffusiveRadiationMixedFvPatchField +: + public mixedFvPatchScalarField +{ + + // Private data + + //- Name of temperature field + word TName_; + + //- Emissivity + scalar emissivity_; + + //- Direction index + label myRayIndex_; + + //- Direction index + label myWaveLengthIndex_; + + //- Init ray flag + label myRayIsInit_; + + //- Radiative heat flux on walls. + scalarField qr_; + +public: + + //- Runtime type information + TypeName("GreyDiffusiveRadiation"); + + + // Constructors + + //- Construct from patch and internal field + GreyDiffusiveRadiationMixedFvPatchField + ( + const fvPatch&, + const DimensionedField& + ); + + //- Construct from patch, internal field and dictionary + GreyDiffusiveRadiationMixedFvPatchField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given GreyDiffusiveRadiationMixedFvPatchField + // onto a new patch + GreyDiffusiveRadiationMixedFvPatchField + ( + const GreyDiffusiveRadiationMixedFvPatchField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + GreyDiffusiveRadiationMixedFvPatchField + ( + const GreyDiffusiveRadiationMixedFvPatchField& + ); + + //- Construct and return a clone + virtual tmp clone() const + { + return tmp + ( + new GreyDiffusiveRadiationMixedFvPatchField(*this) + ); + } + + //- Construct as copy setting internal field reference + GreyDiffusiveRadiationMixedFvPatchField + ( + const GreyDiffusiveRadiationMixedFvPatchField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp clone + ( + const DimensionedField& iF + ) const + { + return tmp + ( + new GreyDiffusiveRadiationMixedFvPatchField(*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_; + } + + + //- Return heat flux on the boundary + const scalarField& qr() const + { + return qr_; + } + + // Mapping functions + + //- Map (and resize as needed) from self given a mapping object + virtual void autoMap + ( + const fvPatchFieldMapper& + ); + + //- Reverse map the given fvPatchField onto this fvPatchField + virtual void rmap + ( + const fvPatchScalarField&, + const labelList& + ); + + + // 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..ef795c5f52 --- /dev/null +++ b/src/thermophysicalModels/radiation/derivedFvPatchFields/WideBandDiffusiveRadiation/WideBandDiffusiveRadiationMixedFvPatchScalarField.C @@ -0,0 +1,314 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 "radiationModel.H" +#include "fvDOM.H" +#include "wideBandAbsorptionEmission.H" +#include "radiationConstants.H" +#include "mathematicalConstants.H" + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::radiation::WideBandDiffusiveRadiationMixedFvPatchField:: +WideBandDiffusiveRadiationMixedFvPatchField +( + const fvPatch& p, + const DimensionedField& iF +) +: + mixedFvPatchScalarField(p, iF), + TName_("undefined"), + emissivity_(0.0), + myRayIndex_(0), + myWaveLengthIndex_(0), + myRayIsInit_(-1), + qr_(0) +{ + refValue() = 0.0; + refGrad() = 0.0; + valueFraction() = 1.0; + qr_.setSize(p.size()); +} + + +Foam::radiation::WideBandDiffusiveRadiationMixedFvPatchField:: +WideBandDiffusiveRadiationMixedFvPatchField +( + const WideBandDiffusiveRadiationMixedFvPatchField& ptf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + mixedFvPatchScalarField(ptf, p, iF, mapper), + TName_(ptf.TName_), + emissivity_(ptf.emissivity_), + myRayIndex_(ptf.myRayIndex_), + myWaveLengthIndex_(ptf.myWaveLengthIndex_), + myRayIsInit_(ptf.myRayIsInit_), + qr_(ptf.qr_) +{} + + +Foam::radiation::WideBandDiffusiveRadiationMixedFvPatchField:: +WideBandDiffusiveRadiationMixedFvPatchField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + mixedFvPatchScalarField(p, iF), + TName_(dict.lookup("T")), + emissivity_(readScalar(dict.lookup("emissivity"))), + myRayIndex_(0), + myWaveLengthIndex_(0), + myRayIsInit_(-1), + qr_(0) +{ + const scalarField& Tp = + patch().lookupPatchField(TName_); + + refValue() = emissivity_*4.0*radiation::sigmaSB.value()*pow4(Tp) / + Foam::mathematicalConstant::pi; + refGrad() = 0.0; + + qr_.setSize(p.size()); + + if (dict.found("value")) + { + fvPatchScalarField::operator= + ( + scalarField("value", dict, p.size()) + ); + } + else + { + fvPatchScalarField::operator=(refValue()); + } +} + + +Foam::radiation::WideBandDiffusiveRadiationMixedFvPatchField:: +WideBandDiffusiveRadiationMixedFvPatchField +( + const WideBandDiffusiveRadiationMixedFvPatchField& ptf +) +: + mixedFvPatchScalarField(ptf), + TName_(ptf.TName_), + emissivity_(ptf.emissivity_), + myRayIndex_(ptf.myRayIndex_), + myWaveLengthIndex_(ptf.myWaveLengthIndex_), + myRayIsInit_(ptf.myRayIsInit_), + qr_(ptf.qr_) +{} + + +Foam::radiation::WideBandDiffusiveRadiationMixedFvPatchField:: +WideBandDiffusiveRadiationMixedFvPatchField +( + const WideBandDiffusiveRadiationMixedFvPatchField& ptf, + const DimensionedField& iF +) +: + mixedFvPatchScalarField(ptf, iF), + TName_(ptf.TName_), + emissivity_(ptf.emissivity_), + myRayIndex_(ptf.myRayIndex_), + myWaveLengthIndex_(ptf.myWaveLengthIndex_), + myRayIsInit_(ptf.myRayIsInit_), + qr_(ptf.qr_) + +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::radiation::WideBandDiffusiveRadiationMixedFvPatchField::autoMap +( + const fvPatchFieldMapper& m +) +{ + scalarField::autoMap(m); + +} + + +void Foam::radiation::WideBandDiffusiveRadiationMixedFvPatchField::rmap +( + const fvPatchScalarField& ptf, + const labelList& addr +) +{ + mixedFvPatchScalarField::rmap(ptf, addr); + +// const GreyDiffusiveRadiationMixedFvPatchField& mrptf = + refCast(ptf); +} + + +void +Foam::radiation::WideBandDiffusiveRadiationMixedFvPatchField::updateCoeffs +() +{ + if (this->updated()) + { + return; + } + + const radiationModel& rad = + db().lookupObject("radiationProperties"); + + const fvDOM& Dom(refCast(rad)); + + const label patchi = patch().index(); + + if(Dom.lambdaj() > 1) + { + if (myRayIsInit_ == -1) + { + for(label i=0; i < Dom.Ni() ; i++) + { + for(label j=0; j < Dom.lambdaj() ; j++) + { + const volScalarField& radiationField = + Dom.RadIntRayiLambdaj(i,j); + if (&(radiationField.internalField()) == + &dimensionedInternalField()) + { + myRayIndex_ = i; + myWaveLengthIndex_ = j; + myRayIsInit_ = 0.; + break; + } + } + } + } + } + else + { + FatalErrorIn + ( + "Foam::radiation::" + "WideBandDiffusiveRadiationMixedFvPatchScalarField::" + "updateCoeffs" + ) << " a Non-grey boundary condition is used with a grey" + << "absorption model" + << exit(FatalError); + } + + vectorField n = patch().Sf()/patch().magSf(); + + scalarField& Iw = *(this); + + qr_ = Iw *(-n & Dom.RadIntRay(myRayIndex_).Di()); + + Dom.RadIntRay(myRayIndex_).add(qr_,patchi); + + const scalarField Eb = + Dom.blackBody().bj(myWaveLengthIndex_).boundaryField()[patchi]; + + forAll(Iw, faceI) + { + + scalar Ir = 0.0; + for(label i=0; i < Dom.Ni() ; i++) // + { + const vector& si = Dom.RadIntRay(i).Si(); + + const scalarField& Iface = Dom.RadIntRay(i).Ilambdaj + ( + myWaveLengthIndex_ + ).boundaryField()[patch().index()]; + + scalar InOut = -n[faceI] & si; + + if (InOut < 0.) // qin into the wall + { + const vector& di = Dom.RadIntRay(i).Di(); + Ir = Ir + Iface[faceI]*mag(n[faceI] & di); + } + } + + + const vector& mySi = Dom.RadIntRay(myRayIndex_).Si(); + + scalar InOut = -n[faceI] & mySi; + + if (InOut > 0.) //direction out of the wall + { + refGrad()[faceI] = 0.0; + valueFraction()[faceI] = 1.0; + refValue()[faceI] = ((1. - emissivity_) * Ir + + emissivity_* Eb[faceI]) / Foam::mathematicalConstant::pi; + } + else if (InOut < 0.) //direction into the wall + { + valueFraction()[faceI] = 0.0; + refGrad()[faceI] = 0.0; + refValue()[faceI] = 0.0; //not used + } + } + + mixedFvPatchScalarField::updateCoeffs(); +} + + +void Foam::radiation::WideBandDiffusiveRadiationMixedFvPatchField::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, + WideBandDiffusiveRadiationMixedFvPatchField + ); +} +} + + +// ************************************************************************* // diff --git a/src/thermophysicalModels/radiation/derivedFvPatchFields/WideBandDiffusiveRadiation/WideBandDiffusiveRadiationMixedFvPatchScalarField.H b/src/thermophysicalModels/radiation/derivedFvPatchFields/WideBandDiffusiveRadiation/WideBandDiffusiveRadiationMixedFvPatchScalarField.H new file mode 100644 index 0000000000..765579c3ac --- /dev/null +++ b/src/thermophysicalModels/radiation/derivedFvPatchFields/WideBandDiffusiveRadiation/WideBandDiffusiveRadiationMixedFvPatchScalarField.H @@ -0,0 +1,218 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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::WideBandDiffusiveRadiationMixedFvPatchField + +Description + Radiation temperature specified + +SourceFiles + WideBandDiffusiveRadiationMixedFvPatchField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef WideBandDiffusiveRadiationMixedFvPatchField_H +#define WideBandDiffusiveRadiationMixedFvPatchField_H + +#include "mixedFvPatchFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace radiation +{ +/*---------------------------------------------------------------------------*\ + Class WideBandDiffusiveRadiationMixedFvPatchField Declaration +\*---------------------------------------------------------------------------*/ + +class WideBandDiffusiveRadiationMixedFvPatchField +: + public mixedFvPatchScalarField +{ + + // Private data + + //- Name of temperature field + word TName_; + + //- Emissivity + scalar emissivity_; + + //- Direction index + label myRayIndex_; + + //- Direction index + label myWaveLengthIndex_; + + //- Init ray flag + label myRayIsInit_; + + //- Radiative heat flux on walls. + scalarField qr_; + +public: + + //- Runtime type information + TypeName("WideBandDiffusiveRadiation"); + + + // Constructors + + //- Construct from patch and internal field + WideBandDiffusiveRadiationMixedFvPatchField + ( + const fvPatch&, + const DimensionedField& + ); + + //- Construct from patch, internal field and dictionary + WideBandDiffusiveRadiationMixedFvPatchField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given GreyDiffusiveRadiationMixedFvPatchField + // onto a new patch + WideBandDiffusiveRadiationMixedFvPatchField + ( + const WideBandDiffusiveRadiationMixedFvPatchField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + WideBandDiffusiveRadiationMixedFvPatchField + ( + const WideBandDiffusiveRadiationMixedFvPatchField& + ); + + //- Construct and return a clone + virtual tmp clone() const + { + return tmp + ( + new WideBandDiffusiveRadiationMixedFvPatchField(*this) + ); + } + + //- Construct as copy setting internal field reference + WideBandDiffusiveRadiationMixedFvPatchField + ( + const WideBandDiffusiveRadiationMixedFvPatchField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp clone + ( + const DimensionedField& iF + ) const + { + return tmp + ( + new WideBandDiffusiveRadiationMixedFvPatchField(*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_; + } + + + //- Return heat flux on the boundary + const scalarField& qr() const + { + return qr_; + } + + // Mapping functions + + //- Map (and resize as needed) from self given a mapping object + virtual void autoMap + ( + const fvPatchFieldMapper& + ); + + //- Reverse map the given fvPatchField onto this fvPatchField + virtual void rmap + ( + const fvPatchScalarField&, + const labelList& + ); + + + // 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..5a7e598278 100644 --- a/src/thermophysicalModels/radiation/radiationModel/P1/P1.C +++ b/src/thermophysicalModels/radiation/radiationModel/P1/P1.C @@ -50,6 +50,9 @@ namespace Foam } } +// Radiation solver iteration +Foam::label Foam::radiation::P1::iterRadId = pTraits