1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
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 "wideBandDiffusiveRadiationMixedFvPatchScalarField.H"
27 #include "addToRunTimeSelectionTable.H"
28 #include "fvPatchFieldMapper.H"
29 #include "volFields.H"
32 #include "wideBandAbsorptionEmission.H"
33 #include "constants.H"
35 using namespace Foam::constant;
36 using namespace Foam::constant::mathematical;
38 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
40 Foam::radiation::wideBandDiffusiveRadiationMixedFvPatchScalarField::
41 wideBandDiffusiveRadiationMixedFvPatchScalarField
44 const DimensionedField<scalar, volMesh>& iF
47 mixedFvPatchScalarField(p, iF),
48 radiationCoupledBase(p, "undefined", scalarField::null()),
53 valueFraction() = 1.0;
57 Foam::radiation::wideBandDiffusiveRadiationMixedFvPatchScalarField::
58 wideBandDiffusiveRadiationMixedFvPatchScalarField
60 const wideBandDiffusiveRadiationMixedFvPatchScalarField& ptf,
62 const DimensionedField<scalar, volMesh>& iF,
63 const fvPatchFieldMapper& mapper
66 mixedFvPatchScalarField(ptf, p, iF, mapper),
70 ptf.emissivityMethod(),
77 Foam::radiation::wideBandDiffusiveRadiationMixedFvPatchScalarField::
78 wideBandDiffusiveRadiationMixedFvPatchScalarField
81 const DimensionedField<scalar, volMesh>& iF,
82 const dictionary& dict
85 mixedFvPatchScalarField(p, iF),
86 radiationCoupledBase(p, dict),
87 TName_(dict.lookup("T"))
89 if (dict.found("value"))
91 fvPatchScalarField::operator=
93 scalarField("value", dict, p.size())
95 refValue() = scalarField("refValue", dict, p.size());
96 refGrad() = scalarField("refGradient", dict, p.size());
97 valueFraction() = scalarField("valueFraction", dict, p.size());
101 const scalarField& Tp =
102 patch().lookupPatchField<volScalarField, scalar>(TName_);
105 4.0*physicoChemical::sigma.value()*pow4(Tp)*emissivity()/pi;
108 fvPatchScalarField::operator=(refValue());
113 Foam::radiation::wideBandDiffusiveRadiationMixedFvPatchScalarField::
114 wideBandDiffusiveRadiationMixedFvPatchScalarField
116 const wideBandDiffusiveRadiationMixedFvPatchScalarField& ptf
119 mixedFvPatchScalarField(ptf),
123 ptf.emissivityMethod(),
130 Foam::radiation::wideBandDiffusiveRadiationMixedFvPatchScalarField::
131 wideBandDiffusiveRadiationMixedFvPatchScalarField
133 const wideBandDiffusiveRadiationMixedFvPatchScalarField& ptf,
134 const DimensionedField<scalar, volMesh>& iF
137 mixedFvPatchScalarField(ptf, iF),
141 ptf.emissivityMethod(),
148 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
150 void Foam::radiation::wideBandDiffusiveRadiationMixedFvPatchScalarField::
158 // Since we're inside initEvaluate/evaluate there might be processor
159 // comms underway. Change the tag we use.
160 int oldTag = UPstream::msgType();
161 UPstream::msgType() = oldTag+1;
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() == 0)
179 "wideBandDiffusiveRadiationMixedFvPatchScalarField::updateCoeffs"
180 ) << " a non-grey boundary condition is used with a 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());
194 dom.blackBody().bLambda(lambdaId).boundaryField()[patchI]
197 scalarField temissivity = emissivity();
202 for (label rayI=0; rayI < dom.nRay(); rayI++)
204 const vector& d = dom.IRay(rayI).d();
206 const scalarField& IFace =
207 dom.IRay(rayI).ILambda(lambdaId).boundaryField()[patchI];
209 if ((-n[faceI] & d) < 0.0) // qin into the wall
211 const vector& dAve = dom.IRay(rayI).dAve();
212 Ir = Ir + IFace[faceI]*mag(n[faceI] & dAve);
216 const vector& d = dom.IRay(rayId).d();
218 if ((-n[faceI] & d) > 0.0)
220 // direction out of the wall
221 refGrad()[faceI] = 0.0;
222 valueFraction()[faceI] = 1.0;
225 Ir*(1.0 - temissivity[faceI])
226 + temissivity[faceI]*Eb[faceI]
231 // direction into the wall
232 valueFraction()[faceI] = 0.0;
233 refGrad()[faceI] = 0.0;
234 refValue()[faceI] = 0.0; //not used
239 UPstream::msgType() = oldTag;
241 mixedFvPatchScalarField::updateCoeffs();
245 void Foam::radiation::wideBandDiffusiveRadiationMixedFvPatchScalarField::write
250 mixedFvPatchScalarField::write(os);
251 radiationCoupledBase::write(os);
252 os.writeKeyword("T") << TName_ << token::END_STATEMENT << nl;
257 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
266 wideBandDiffusiveRadiationMixedFvPatchScalarField
272 // ************************************************************************* //