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 if (dict.found("refValue"))
85 fvPatchScalarField::operator=
87 scalarField("value", dict, p.size())
89 refValue() = scalarField("refValue", dict, p.size());
90 refGrad() = scalarField("refGradient", dict, p.size());
91 valueFraction() = scalarField("valueFraction", dict, p.size());
95 // No value given. Restart as fixedValue b.c.
97 const scalarField& Tp =
98 patch().lookupPatchField<volScalarField, scalar>(TName_);
101 emissivity_*4.0*radiation::sigmaSB.value()*pow4(Tp)
102 /Foam::mathematicalConstant::pi;
105 valueFraction() = 1.0;
107 fvPatchScalarField::operator=(refValue());
112 Foam::radiation::greyDiffusiveRadiationMixedFvPatchScalarField::
113 greyDiffusiveRadiationMixedFvPatchScalarField
115 const greyDiffusiveRadiationMixedFvPatchScalarField& ptf
118 mixedFvPatchScalarField(ptf),
120 emissivity_(ptf.emissivity_)
124 Foam::radiation::greyDiffusiveRadiationMixedFvPatchScalarField::
125 greyDiffusiveRadiationMixedFvPatchScalarField
127 const greyDiffusiveRadiationMixedFvPatchScalarField& ptf,
128 const DimensionedField<scalar, volMesh>& iF
131 mixedFvPatchScalarField(ptf, iF),
133 emissivity_(ptf.emissivity_)
137 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
139 void Foam::radiation::greyDiffusiveRadiationMixedFvPatchScalarField::
147 const scalarField& Tp =
148 patch().lookupPatchField<volScalarField, scalar>(TName_);
150 const radiationModel& radiation =
151 db().lookupObject<radiationModel>("radiationProperties");
153 const fvDOM& dom(refCast<const fvDOM>(radiation));
157 dom.setRayIdLambdaId(dimensionedInternalField().name(), rayId, lambdaId);
159 const label patchI = patch().index();
161 if (dom.nLambda() != 1)
166 "greyDiffusiveRadiationMixedFvPatchScalarField::updateCoeffs"
167 ) << " a grey boundary condition is used with a non-grey "
168 << "absorption model" << nl << exit(FatalError);
171 scalarField& Iw = *this;
172 vectorField n = patch().Sf()/patch().magSf();
174 radiativeIntensityRay& ray =
175 const_cast<radiativeIntensityRay&>(dom.IRay(rayId));
177 ray.Qr().boundaryField()[patchI] += Iw*(n & ray.dAve());
183 for (label rayI=0; rayI < dom.nRay(); rayI++)
185 const vector& d = dom.IRay(rayI).d();
187 const scalarField& IFace =
188 dom.IRay(rayI).ILambda(lambdaId).boundaryField()[patchI];
190 if ((-n[faceI] & d) < 0.0)
193 const vector& dAve = dom.IRay(rayI).dAve();
194 Ir += IFace[faceI]*mag(n[faceI] & dAve);
198 const vector& d = dom.IRay(rayId).d();
200 if ((-n[faceI] & d) > 0.0)
202 // direction out of the wall
203 refGrad()[faceI] = 0.0;
204 valueFraction()[faceI] = 1.0;
207 Ir*(1.0 - emissivity_)
208 + emissivity_*radiation::sigmaSB.value()*pow4(Tp[faceI])
210 /mathematicalConstant::pi;
215 // direction into the wall
216 valueFraction()[faceI] = 0.0;
217 refGrad()[faceI] = 0.0;
218 refValue()[faceI] = 0.0; //not used
222 mixedFvPatchScalarField::updateCoeffs();
226 void Foam::radiation::greyDiffusiveRadiationMixedFvPatchScalarField::write
231 mixedFvPatchScalarField::write(os);
232 os.writeKeyword("T") << TName_ << token::END_STATEMENT << nl;
233 os.writeKeyword("emissivity") << emissivity_ << token::END_STATEMENT << nl;
237 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
246 greyDiffusiveRadiationMixedFvPatchScalarField
252 // ************************************************************************* //