FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

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-2010 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
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your 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, see <http://www.gnu.org/licenses/>.
00023 
00024 \*---------------------------------------------------------------------------*/
00025 
00026 #include "wideBandDiffusiveRadiationMixedFvPatchScalarField.H"
00027 #include <OpenFOAM/addToRunTimeSelectionTable.H>
00028 #include <finiteVolume/fvPatchFieldMapper.H>
00029 #include <finiteVolume/volFields.H>
00030 
00031 #include <radiation/fvDOM.H>
00032 #include <radiation/wideBandAbsorptionEmission.H>
00033 #include <radiation/radiationConstants.H>
00034 #include <OpenFOAM/mathematicalConstants.H>
00035 
00036 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00037 
00038 Foam::radiation::wideBandDiffusiveRadiationMixedFvPatchScalarField::
00039 wideBandDiffusiveRadiationMixedFvPatchScalarField
00040 (
00041     const fvPatch& p,
00042     const DimensionedField<scalar, volMesh>& iF
00043 )
00044 :
00045     mixedFvPatchScalarField(p, iF),
00046     TName_("undefinedT"),
00047     emissivity_(0.0)
00048 {
00049     refValue() = 0.0;
00050     refGrad() = 0.0;
00051     valueFraction() = 1.0;
00052 }
00053 
00054 
00055 Foam::radiation::wideBandDiffusiveRadiationMixedFvPatchScalarField::
00056 wideBandDiffusiveRadiationMixedFvPatchScalarField
00057 (
00058     const wideBandDiffusiveRadiationMixedFvPatchScalarField& ptf,
00059     const fvPatch& p,
00060     const DimensionedField<scalar, volMesh>& iF,
00061     const fvPatchFieldMapper& mapper
00062 )
00063 :
00064     mixedFvPatchScalarField(ptf, p, iF, mapper),
00065     TName_(ptf.TName_),
00066     emissivity_(ptf.emissivity_)
00067 {}
00068 
00069 
00070 Foam::radiation::wideBandDiffusiveRadiationMixedFvPatchScalarField::
00071 wideBandDiffusiveRadiationMixedFvPatchScalarField
00072 (
00073     const fvPatch& p,
00074     const DimensionedField<scalar, volMesh>& iF,
00075     const dictionary& dict
00076 )
00077 :
00078     mixedFvPatchScalarField(p, iF),
00079     TName_(dict.lookup("T")),
00080     emissivity_(readScalar(dict.lookup("emissivity")))
00081 {
00082     const scalarField& Tp =
00083         patch().lookupPatchField<volScalarField, scalar>(TName_);
00084 
00085     refValue() =
00086         emissivity_*4.0*radiation::sigmaSB.value()*pow4(Tp)
00087        /Foam::mathematicalConstant::pi;
00088     refGrad() = 0.0;
00089 
00090     if (dict.found("value"))
00091     {
00092         fvPatchScalarField::operator=
00093         (
00094             scalarField("value", dict, p.size())
00095         );
00096     }
00097     else
00098     {
00099         fvPatchScalarField::operator=(refValue());
00100     }
00101 }
00102 
00103 
00104 Foam::radiation::wideBandDiffusiveRadiationMixedFvPatchScalarField::
00105 wideBandDiffusiveRadiationMixedFvPatchScalarField
00106 (
00107     const wideBandDiffusiveRadiationMixedFvPatchScalarField& ptf
00108 )
00109 :
00110     mixedFvPatchScalarField(ptf),
00111     TName_(ptf.TName_),
00112     emissivity_(ptf.emissivity_)
00113 {}
00114 
00115 
00116 Foam::radiation::wideBandDiffusiveRadiationMixedFvPatchScalarField::
00117 wideBandDiffusiveRadiationMixedFvPatchScalarField
00118 (
00119     const wideBandDiffusiveRadiationMixedFvPatchScalarField& ptf,
00120     const DimensionedField<scalar, volMesh>& iF
00121 )
00122 :
00123     mixedFvPatchScalarField(ptf, iF),
00124     TName_(ptf.TName_),
00125     emissivity_(ptf.emissivity_)
00126 {}
00127 
00128 
00129 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00130 
00131 void Foam::radiation::wideBandDiffusiveRadiationMixedFvPatchScalarField::
00132 updateCoeffs()
00133 {
00134     if (this->updated())
00135     {
00136         return;
00137     }
00138 
00139     const radiationModel& radiation =
00140         db().lookupObject<radiationModel>("radiationProperties");
00141 
00142     const fvDOM& dom(refCast<const fvDOM>(radiation));
00143 
00144     label rayId = -1;
00145     label lambdaId = -1;
00146     dom.setRayIdLambdaId(dimensionedInternalField().name(), rayId, lambdaId);
00147 
00148     const label patchI = patch().index();
00149 
00150     if (dom.nLambda() == 0)
00151     {
00152         FatalErrorIn
00153         (
00154             "Foam::radiation::"
00155             "wideBandDiffusiveRadiationMixedFvPatchScalarField::updateCoeffs"
00156         )   << " a non-grey boundary condition is used with a grey "
00157             << "absorption model" << nl << exit(FatalError);
00158     }
00159 
00160     scalarField& Iw = *this;
00161     vectorField n = patch().Sf()/patch().magSf();
00162 
00163     radiativeIntensityRay& ray =
00164         const_cast<radiativeIntensityRay&>(dom.IRay(rayId));
00165 
00166     ray.Qr().boundaryField()[patchI] += Iw*(n & ray.dAve());
00167 
00168     const scalarField Eb =
00169         dom.blackBody().bLambda(lambdaId).boundaryField()[patchI];
00170 
00171     forAll(Iw, faceI)
00172     {
00173         scalar Ir = 0.0;
00174         for (label rayI=0; rayI < dom.nRay(); rayI++)
00175         {
00176             const vector& d = dom.IRay(rayI).d();
00177 
00178             const scalarField& IFace =
00179                 dom.IRay(rayI).ILambda(lambdaId).boundaryField()[patchI];
00180 
00181             if ((-n[faceI] & d) < 0.0) // qin into the wall
00182             {
00183                 const vector& dAve = dom.IRay(rayI).dAve();
00184                 Ir = Ir + IFace[faceI]*mag(n[faceI] & dAve);
00185             }
00186         }
00187 
00188         const vector& d = dom.IRay(rayId).d();
00189 
00190         if ((-n[faceI] & d) > 0.0)
00191         {
00192             // direction out of the wall
00193             refGrad()[faceI] = 0.0;
00194             valueFraction()[faceI] = 1.0;
00195             refValue()[faceI] =
00196                 (
00197                     Ir*(1.0 - emissivity_)
00198                   + emissivity_*Eb[faceI]
00199                 )
00200                /mathematicalConstant::pi;
00201         }
00202         else
00203         {
00204             // direction into the wall
00205             valueFraction()[faceI] = 0.0;
00206             refGrad()[faceI] = 0.0;
00207             refValue()[faceI] = 0.0; //not used
00208         }
00209     }
00210 
00211     mixedFvPatchScalarField::updateCoeffs();
00212 }
00213 
00214 
00215 void Foam::radiation::wideBandDiffusiveRadiationMixedFvPatchScalarField::write
00216 (
00217     Ostream& os
00218 ) const
00219 {
00220     fvPatchScalarField::write(os);
00221     os.writeKeyword("T") << TName_ << token::END_STATEMENT << nl;
00222     os.writeKeyword("emissivity") << emissivity_ << token::END_STATEMENT << nl;
00223     writeEntry("value", os);
00224 }
00225 
00226 
00227 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00228 
00229 namespace Foam
00230 {
00231 namespace radiation
00232 {
00233     makePatchTypeField
00234     (
00235         fvPatchScalarField,
00236         wideBandDiffusiveRadiationMixedFvPatchScalarField
00237     );
00238 }
00239 }
00240 
00241 
00242 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines