1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2008-2011 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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "greyDiffusiveRadiationMixedFvPatchScalarField.H"
27 #include "addToRunTimeSelectionTable.H"
28 #include "fvPatchFieldMapper.H"
29 #include "volFields.H"
32 #include "constants.H"
34 using namespace Foam::constant;
35 using namespace Foam::constant::mathematical;
37 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
39 Foam::radiation::greyDiffusiveRadiationMixedFvPatchScalarField::
40 greyDiffusiveRadiationMixedFvPatchScalarField
43 const DimensionedField<scalar, volMesh>& iF
46 mixedFvPatchScalarField(p, iF),
47 radiationCoupledBase(p, "undefined", scalarField::null()),
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),
69 ptf.emissivityMethod(),
76 Foam::radiation::greyDiffusiveRadiationMixedFvPatchScalarField::
77 greyDiffusiveRadiationMixedFvPatchScalarField
80 const DimensionedField<scalar, volMesh>& iF,
81 const dictionary& dict
84 mixedFvPatchScalarField(p, iF),
85 radiationCoupledBase(p, dict),
86 TName_(dict.lookup("T"))
88 if (dict.found("refValue"))
90 fvPatchScalarField::operator=
92 scalarField("value", dict, p.size())
94 refValue() = scalarField("refValue", dict, p.size());
95 refGrad() = scalarField("refGradient", dict, p.size());
96 valueFraction() = scalarField("valueFraction", dict, p.size());
100 // No value given. Restart as fixedValue b.c.
102 const scalarField& Tp =
103 patch().lookupPatchField<volScalarField, scalar>(TName_);
106 4.0*physicoChemical::sigma.value()*pow4(Tp)*emissivity()/pi;
108 valueFraction() = 1.0;
110 fvPatchScalarField::operator=(refValue());
115 Foam::radiation::greyDiffusiveRadiationMixedFvPatchScalarField::
116 greyDiffusiveRadiationMixedFvPatchScalarField
118 const greyDiffusiveRadiationMixedFvPatchScalarField& ptf
121 mixedFvPatchScalarField(ptf),
125 ptf.emissivityMethod(),
132 Foam::radiation::greyDiffusiveRadiationMixedFvPatchScalarField::
133 greyDiffusiveRadiationMixedFvPatchScalarField
135 const greyDiffusiveRadiationMixedFvPatchScalarField& ptf,
136 const DimensionedField<scalar, volMesh>& iF
139 mixedFvPatchScalarField(ptf, iF),
143 ptf.emissivityMethod(),
150 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
152 void Foam::radiation::greyDiffusiveRadiationMixedFvPatchScalarField::
160 const scalarField& Tp =
161 patch().lookupPatchField<volScalarField, scalar>(TName_);
163 const radiationModel& radiation =
164 db().lookupObject<radiationModel>("radiationProperties");
166 const fvDOM& dom(refCast<const fvDOM>(radiation));
170 dom.setRayIdLambdaId(dimensionedInternalField().name(), rayId, lambdaId);
172 const label patchI = patch().index();
174 if (dom.nLambda() != 1)
179 "greyDiffusiveRadiationMixedFvPatchScalarField::updateCoeffs"
180 ) << " a grey boundary condition is used with a non-grey "
181 << "absorption model" << nl << exit(FatalError);
184 scalarField& Iw = *this;
185 const vectorField n(patch().Sf()/patch().magSf());
187 radiativeIntensityRay& ray =
188 const_cast<radiativeIntensityRay&>(dom.IRay(rayId));
190 ray.Qr().boundaryField()[patchI] += Iw*(n & ray.dAve());
192 scalarList temissivity = emissivity();
198 for (label rayI=0; rayI < dom.nRay(); rayI++)
200 const vector& d = dom.IRay(rayI).d();
202 const scalarField& IFace =
203 dom.IRay(rayI).ILambda(lambdaId).boundaryField()[patchI];
205 if ((-n[faceI] & d) < 0.0)
208 const vector& dAve = dom.IRay(rayI).dAve();
209 Ir += IFace[faceI]*mag(n[faceI] & dAve);
213 const vector& d = dom.IRay(rayId).d();
215 if ((-n[faceI] & d) > 0.0)
217 // direction out of the wall
218 refGrad()[faceI] = 0.0;
219 valueFraction()[faceI] = 1.0;
222 Ir*(scalar(1.0) - temissivity[faceI])
223 + temissivity[faceI]*physicoChemical::sigma.value()
227 // Emmited heat flux from this ray direction
228 ray.Qem().boundaryField()[patchI][faceI] =
229 refValue()[faceI]*(n[faceI] & ray.dAve());
233 // direction into the wall
234 valueFraction()[faceI] = 0.0;
235 refGrad()[faceI] = 0.0;
236 refValue()[faceI] = 0.0; //not used
238 // Incident heat flux on this ray direction
239 ray.Qin().boundaryField()[patchI][faceI] =
240 Iw[faceI]*(n[faceI] & ray.dAve());
243 mixedFvPatchScalarField::updateCoeffs();
247 void Foam::radiation::greyDiffusiveRadiationMixedFvPatchScalarField::write
252 mixedFvPatchScalarField::write(os);
253 radiationCoupledBase::write(os);
254 os.writeKeyword("T") << TName_ << token::END_STATEMENT << nl;
258 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
267 greyDiffusiveRadiationMixedFvPatchScalarField
273 // ************************************************************************* //