FreeFOAM The Cross-Platform CFD Toolkit
wideBandDiffusiveRadiationMixedFvPatchScalarField.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2008-2010 OpenCFD Ltd.
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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.
15 
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
19  for more details.
20 
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/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
29 #include <finiteVolume/volFields.H>
30 
31 #include <radiation/fvDOM.H>
35 
36 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
37 
40 (
41  const fvPatch& p,
43 )
44 :
45  mixedFvPatchScalarField(p, iF),
46  TName_("undefinedT"),
47  emissivity_(0.0)
48 {
49  refValue() = 0.0;
50  refGrad() = 0.0;
51  valueFraction() = 1.0;
52 }
53 
54 
57 (
59  const fvPatch& p,
61  const fvPatchFieldMapper& mapper
62 )
63 :
64  mixedFvPatchScalarField(ptf, p, iF, mapper),
65  TName_(ptf.TName_),
66  emissivity_(ptf.emissivity_)
67 {}
68 
69 
72 (
73  const fvPatch& p,
75  const dictionary& dict
76 )
77 :
78  mixedFvPatchScalarField(p, iF),
79  TName_(dict.lookup("T")),
80  emissivity_(readScalar(dict.lookup("emissivity")))
81 {
82  const scalarField& Tp =
83  patch().lookupPatchField<volScalarField, scalar>(TName_);
84 
85  refValue() =
86  emissivity_*4.0*radiation::sigmaSB.value()*pow4(Tp)
88  refGrad() = 0.0;
89 
90  if (dict.found("value"))
91  {
92  fvPatchScalarField::operator=
93  (
94  scalarField("value", dict, p.size())
95  );
96  }
97  else
98  {
99  fvPatchScalarField::operator=(refValue());
100  }
101 }
102 
103 
106 (
108 )
109 :
110  mixedFvPatchScalarField(ptf),
111  TName_(ptf.TName_),
112  emissivity_(ptf.emissivity_)
113 {}
114 
115 
118 (
121 )
122 :
123  mixedFvPatchScalarField(ptf, iF),
124  TName_(ptf.TName_),
125  emissivity_(ptf.emissivity_)
126 {}
127 
128 
129 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
130 
133 {
134  if (this->updated())
135  {
136  return;
137  }
138 
139  const radiationModel& radiation =
140  db().lookupObject<radiationModel>("radiationProperties");
141 
142  const fvDOM& dom(refCast<const fvDOM>(radiation));
143 
144  label rayId = -1;
145  label lambdaId = -1;
146  dom.setRayIdLambdaId(dimensionedInternalField().name(), rayId, lambdaId);
147 
148  const label patchI = patch().index();
149 
150  if (dom.nLambda() == 0)
151  {
153  (
154  "Foam::radiation::"
155  "wideBandDiffusiveRadiationMixedFvPatchScalarField::updateCoeffs"
156  ) << " a non-grey boundary condition is used with a grey "
157  << "absorption model" << nl << exit(FatalError);
158  }
159 
160  scalarField& Iw = *this;
161  vectorField n = patch().Sf()/patch().magSf();
162 
163  radiativeIntensityRay& ray =
164  const_cast<radiativeIntensityRay&>(dom.IRay(rayId));
165 
166  ray.Qr().boundaryField()[patchI] += Iw*(n & ray.dAve());
167 
168  const scalarField Eb =
169  dom.blackBody().bLambda(lambdaId).boundaryField()[patchI];
170 
171  forAll(Iw, faceI)
172  {
173  scalar Ir = 0.0;
174  for (label rayI=0; rayI < dom.nRay(); rayI++)
175  {
176  const vector& d = dom.IRay(rayI).d();
177 
178  const scalarField& IFace =
179  dom.IRay(rayI).ILambda(lambdaId).boundaryField()[patchI];
180 
181  if ((-n[faceI] & d) < 0.0) // qin into the wall
182  {
183  const vector& dAve = dom.IRay(rayI).dAve();
184  Ir = Ir + IFace[faceI]*mag(n[faceI] & dAve);
185  }
186  }
187 
188  const vector& d = dom.IRay(rayId).d();
189 
190  if ((-n[faceI] & d) > 0.0)
191  {
192  // direction out of the wall
193  refGrad()[faceI] = 0.0;
194  valueFraction()[faceI] = 1.0;
195  refValue()[faceI] =
196  (
197  Ir*(1.0 - emissivity_)
198  + emissivity_*Eb[faceI]
199  )
201  }
202  else
203  {
204  // direction into the wall
205  valueFraction()[faceI] = 0.0;
206  refGrad()[faceI] = 0.0;
207  refValue()[faceI] = 0.0; //not used
208  }
209  }
210 
212 }
213 
214 
216 (
217  Ostream& os
218 ) const
219 {
221  os.writeKeyword("T") << TName_ << token::END_STATEMENT << nl;
222  os.writeKeyword("emissivity") << emissivity_ << token::END_STATEMENT << nl;
223  writeEntry("value", os);
224 }
225 
226 
227 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
228 
229 namespace Foam
230 {
231 namespace radiation
232 {
234  (
237  );
238 }
239 }
240 
241 
242 // ************************ vim: set sw=4 sts=4 et: ************************ //