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

wideBandDiffusiveRadiationMixedFvPatchScalarField.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 2008-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 \*---------------------------------------------------------------------------*/
00026 
00027 #include "wideBandDiffusiveRadiationMixedFvPatchScalarField.H"
00028 #include "addToRunTimeSelectionTable.H"
00029 #include "fvPatchFieldMapper.H"
00030 #include "volFields.H"
00031 
00032 #include "fvDOM.H"
00033 #include "wideBandAbsorptionEmission.H"
00034 #include "radiationConstants.H"
00035 #include "mathematicalConstants.H"
00036 
00037 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00038 
00039 Foam::radiation::wideBandDiffusiveRadiationMixedFvPatchScalarField::
00040 wideBandDiffusiveRadiationMixedFvPatchScalarField
00041 (
00042     const fvPatch& p,
00043     const DimensionedField<scalar, volMesh>& iF
00044 )
00045 :
00046     mixedFvPatchScalarField(p, iF),
00047     TName_("undefinedT"),
00048     emissivity_(0.0)
00049 {
00050     refValue() = 0.0;
00051     refGrad() = 0.0;
00052     valueFraction() = 1.0;
00053 }
00054 
00055 
00056 Foam::radiation::wideBandDiffusiveRadiationMixedFvPatchScalarField::
00057 wideBandDiffusiveRadiationMixedFvPatchScalarField
00058 (
00059     const wideBandDiffusiveRadiationMixedFvPatchScalarField& ptf,
00060     const fvPatch& p,
00061     const DimensionedField<scalar, volMesh>& iF,
00062     const fvPatchFieldMapper& mapper
00063 )
00064 :
00065     mixedFvPatchScalarField(ptf, p, iF, mapper),
00066     TName_(ptf.TName_),
00067     emissivity_(ptf.emissivity_)
00068 {}
00069 
00070 
00071 Foam::radiation::wideBandDiffusiveRadiationMixedFvPatchScalarField::
00072 wideBandDiffusiveRadiationMixedFvPatchScalarField
00073 (
00074     const fvPatch& p,
00075     const DimensionedField<scalar, volMesh>& iF,
00076     const dictionary& dict
00077 )
00078 :
00079     mixedFvPatchScalarField(p, iF),
00080     TName_(dict.lookup("T")),
00081     emissivity_(readScalar(dict.lookup("emissivity")))
00082 {
00083     const scalarField& Tp =
00084         patch().lookupPatchField<volScalarField, scalar>(TName_);
00085 
00086     refValue() =
00087         emissivity_*4.0*radiation::sigmaSB.value()*pow4(Tp)
00088        /Foam::mathematicalConstant::pi;
00089     refGrad() = 0.0;
00090 
00091     if (dict.found("value"))
00092     {
00093         fvPatchScalarField::operator=
00094         (
00095             scalarField("value", dict, p.size())
00096         );
00097     }
00098     else
00099     {
00100         fvPatchScalarField::operator=(refValue());
00101     }
00102 }
00103 
00104 
00105 Foam::radiation::wideBandDiffusiveRadiationMixedFvPatchScalarField::
00106 wideBandDiffusiveRadiationMixedFvPatchScalarField
00107 (
00108     const wideBandDiffusiveRadiationMixedFvPatchScalarField& ptf
00109 )
00110 :
00111     mixedFvPatchScalarField(ptf),
00112     TName_(ptf.TName_),
00113     emissivity_(ptf.emissivity_)
00114 {}
00115 
00116 
00117 Foam::radiation::wideBandDiffusiveRadiationMixedFvPatchScalarField::
00118 wideBandDiffusiveRadiationMixedFvPatchScalarField
00119 (
00120     const wideBandDiffusiveRadiationMixedFvPatchScalarField& ptf,
00121     const DimensionedField<scalar, volMesh>& iF
00122 )
00123 :
00124     mixedFvPatchScalarField(ptf, iF),
00125     TName_(ptf.TName_),
00126     emissivity_(ptf.emissivity_)
00127 {}
00128 
00129 
00130 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00131 
00132 void Foam::radiation::wideBandDiffusiveRadiationMixedFvPatchScalarField::
00133 updateCoeffs()
00134 {
00135     if (this->updated())
00136     {
00137         return;
00138     }
00139 
00140     const radiationModel& radiation =
00141         db().lookupObject<radiationModel>("radiationProperties");
00142 
00143     const fvDOM& dom(refCast<const fvDOM>(radiation));
00144 
00145     label rayId = -1;
00146     label lambdaId = -1;
00147     dom.setRayIdLambdaId(dimensionedInternalField().name(), rayId, lambdaId);
00148 
00149     const label patchI = patch().index();
00150 
00151     if (dom.nLambda() == 0)
00152     {
00153         FatalErrorIn
00154         (
00155             "Foam::radiation::"
00156             "wideBandDiffusiveRadiationMixedFvPatchScalarField::updateCoeffs"
00157         )   << " a non-grey boundary condition is used with a grey "
00158             << "absorption model" << nl << exit(FatalError);
00159     }
00160 
00161     scalarField& Iw = *this;
00162     vectorField n = patch().Sf()/patch().magSf();
00163 
00164     radiativeIntensityRay& ray =
00165         const_cast<radiativeIntensityRay&>(dom.IRay(rayId));
00166 
00167     ray.Qr().boundaryField()[patchI] += Iw*(-n & ray.dAve());
00168 
00169     const scalarField Eb =
00170         dom.blackBody().bLambda(lambdaId).boundaryField()[patchI];
00171 
00172     forAll(Iw, faceI)
00173     {
00174         scalar Ir = 0.0;
00175         for (label rayI=0; rayI < dom.nRay(); rayI++)
00176         {
00177             const vector& d = dom.IRay(rayI).d();
00178 
00179             const scalarField& IFace =
00180                 dom.IRay(rayI).ILambda(lambdaId).boundaryField()[patchI];
00181 
00182             if ((-n[faceI] & d) < 0.0) // qin into the wall
00183             {
00184                 const vector& dAve = dom.IRay(rayI).dAve();
00185                 Ir = Ir + IFace[faceI]*mag(n[faceI] & dAve);
00186             }
00187         }
00188 
00189         const vector& d = dom.IRay(rayId).d();
00190 
00191         if ((-n[faceI] & d) > 0.0)
00192         {
00193             // direction out of the wall
00194             refGrad()[faceI] = 0.0;
00195             valueFraction()[faceI] = 1.0;
00196             refValue()[faceI] =
00197                 (
00198                     Ir*(1.0 - emissivity_)
00199                   + emissivity_*Eb[faceI]
00200                 )
00201                /mathematicalConstant::pi;
00202         }
00203         else
00204         {
00205             // direction into the wall
00206             valueFraction()[faceI] = 0.0;
00207             refGrad()[faceI] = 0.0;
00208             refValue()[faceI] = 0.0; //not used
00209         }
00210     }
00211 
00212     mixedFvPatchScalarField::updateCoeffs();
00213 }
00214 
00215 
00216 void Foam::radiation::wideBandDiffusiveRadiationMixedFvPatchScalarField::write
00217 (
00218     Ostream& os
00219 ) const
00220 {
00221     fvPatchScalarField::write(os);
00222     os.writeKeyword("T") << TName_ << token::END_STATEMENT << nl;
00223     os.writeKeyword("emissivity") << emissivity_ << token::END_STATEMENT << nl;
00224     writeEntry("value", os);
00225 }
00226 
00227 
00228 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00229 
00230 namespace Foam
00231 {
00232 namespace radiation
00233 {
00234     makePatchTypeField
00235     (
00236         fvPatchScalarField,
00237         wideBandDiffusiveRadiationMixedFvPatchScalarField
00238     );
00239 }
00240 }
00241 
00242 
00243 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd