1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2008-2009 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software; you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "greyDiffusiveRadiationMixedFvPatchScalarField.H"
28 #include "addToRunTimeSelectionTable.H"
29 #include "fvPatchFieldMapper.H"
30 #include "volFields.H"
33 #include "radiationConstants.H"
34 #include "mathematicalConstants.H"
37 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
39 Foam::radiation::greyDiffusiveRadiationMixedFvPatchScalarField::
40 greyDiffusiveRadiationMixedFvPatchScalarField
43 const DimensionedField<scalar, volMesh>& iF
46 mixedFvPatchScalarField(p, iF),
52 valueFraction() = 1.0;
56 Foam::radiation::greyDiffusiveRadiationMixedFvPatchScalarField::
57 greyDiffusiveRadiationMixedFvPatchScalarField
59 const greyDiffusiveRadiationMixedFvPatchScalarField& ptf,
61 const DimensionedField<scalar, volMesh>& iF,
62 const fvPatchFieldMapper& mapper
65 mixedFvPatchScalarField(ptf, p, iF, mapper),
67 emissivity_(ptf.emissivity_)
71 Foam::radiation::greyDiffusiveRadiationMixedFvPatchScalarField::
72 greyDiffusiveRadiationMixedFvPatchScalarField
75 const DimensionedField<scalar, volMesh>& iF,
76 const dictionary& dict
79 mixedFvPatchScalarField(p, iF),
80 TName_(dict.lookup("T")),
81 emissivity_(readScalar(dict.lookup("emissivity")))
83 const scalarField& Tp =
84 patch().lookupPatchField<volScalarField, scalar>(TName_);
87 emissivity_*4.0*radiation::sigmaSB.value()*pow4(Tp)
88 /Foam::mathematicalConstant::pi;
92 if (dict.found("value"))
94 fvPatchScalarField::operator=
96 scalarField("value", dict, p.size())
101 fvPatchScalarField::operator=(refValue());
106 Foam::radiation::greyDiffusiveRadiationMixedFvPatchScalarField::
107 greyDiffusiveRadiationMixedFvPatchScalarField
109 const greyDiffusiveRadiationMixedFvPatchScalarField& ptf
112 mixedFvPatchScalarField(ptf),
114 emissivity_(ptf.emissivity_)
118 Foam::radiation::greyDiffusiveRadiationMixedFvPatchScalarField::
119 greyDiffusiveRadiationMixedFvPatchScalarField
121 const greyDiffusiveRadiationMixedFvPatchScalarField& ptf,
122 const DimensionedField<scalar, volMesh>& iF
125 mixedFvPatchScalarField(ptf, iF),
127 emissivity_(ptf.emissivity_)
131 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
133 void Foam::radiation::greyDiffusiveRadiationMixedFvPatchScalarField::
141 const scalarField& Tp =
142 patch().lookupPatchField<volScalarField, scalar>(TName_);
144 const radiationModel& radiation =
145 db().lookupObject<radiationModel>("radiationProperties");
147 const fvDOM& dom(refCast<const fvDOM>(radiation));
151 dom.setRayIdLambdaId(dimensionedInternalField().name(), rayId, lambdaId);
153 const label patchI = patch().index();
155 if (dom.nLambda() != 1)
160 "greyDiffusiveRadiationMixedFvPatchScalarField::updateCoeffs"
161 ) << " a grey boundary condition is used with a non-grey "
162 << "absorption model" << nl << exit(FatalError);
165 scalarField& Iw = *this;
166 vectorField n = patch().Sf()/patch().magSf();
168 radiativeIntensityRay& ray =
169 const_cast<radiativeIntensityRay&>(dom.IRay(rayId));
171 ray.Qr().boundaryField()[patchI] += Iw*(-n & ray.dAve());
177 for (label rayI=0; rayI < dom.nRay(); rayI++)
179 const vector& d = dom.IRay(rayI).d();
181 const scalarField& IFace =
182 dom.IRay(rayI).ILambda(lambdaId).boundaryField()[patchI];
184 if ((-n[faceI] & d) < 0.0)
187 const vector& dAve = dom.IRay(rayI).dAve();
188 Ir += IFace[faceI]*mag(n[faceI] & dAve);
192 const vector& d = dom.IRay(rayId).d();
194 if ((-n[faceI] & d) > 0.0)
196 // direction out of the wall
197 refGrad()[faceI] = 0.0;
198 valueFraction()[faceI] = 1.0;
201 Ir*(1.0 - emissivity_)
202 + emissivity_*radiation::sigmaSB.value()*pow4(Tp[faceI])
204 /mathematicalConstant::pi;
209 // direction into the wall
210 valueFraction()[faceI] = 0.0;
211 refGrad()[faceI] = 0.0;
212 refValue()[faceI] = 0.0; //not used
216 mixedFvPatchScalarField::updateCoeffs();
220 void Foam::radiation::greyDiffusiveRadiationMixedFvPatchScalarField::write
225 fvPatchScalarField::write(os);
226 os.writeKeyword("T") << TName_ << token::END_STATEMENT << nl;
227 os.writeKeyword("emissivity") << emissivity_ << token::END_STATEMENT << nl;
228 writeEntry("value", os);
232 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
241 greyDiffusiveRadiationMixedFvPatchScalarField
247 // ************************************************************************* //