FreeFOAM The Cross-Platform CFD Toolkit
greyDiffusiveRadiationMixedFvPatchScalarField.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>
34 
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  if (dict.found("refValue"))
83  {
84  fvPatchScalarField::operator=
85  (
86  scalarField("value", dict, p.size())
87  );
88  refValue() = scalarField("refValue", dict, p.size());
89  refGrad() = scalarField("refGradient", dict, p.size());
90  valueFraction() = scalarField("valueFraction", dict, p.size());
91  }
92  else
93  {
94  // No value given. Restart as fixedValue b.c.
95 
96  const scalarField& Tp =
97  patch().lookupPatchField<volScalarField, scalar>(TName_);
98 
99  refValue() =
100  emissivity_*4.0*radiation::sigmaSB.value()*pow4(Tp)
102 
103  refGrad() = 0.0;
104  valueFraction() = 1.0;
105 
106  fvPatchScalarField::operator=(refValue());
107  }
108 }
109 
110 
113 (
115 )
116 :
117  mixedFvPatchScalarField(ptf),
118  TName_(ptf.TName_),
119  emissivity_(ptf.emissivity_)
120 {}
121 
122 
125 (
128 )
129 :
130  mixedFvPatchScalarField(ptf, iF),
131  TName_(ptf.TName_),
132  emissivity_(ptf.emissivity_)
133 {}
134 
135 
136 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
137 
140 {
141  if (this->updated())
142  {
143  return;
144  }
145 
146  const scalarField& Tp =
147  patch().lookupPatchField<volScalarField, scalar>(TName_);
148 
149  const radiationModel& radiation =
150  db().lookupObject<radiationModel>("radiationProperties");
151 
152  const fvDOM& dom(refCast<const fvDOM>(radiation));
153 
154  label rayId = -1;
155  label lambdaId = -1;
156  dom.setRayIdLambdaId(dimensionedInternalField().name(), rayId, lambdaId);
157 
158  const label patchI = patch().index();
159 
160  if (dom.nLambda() != 1)
161  {
163  (
164  "Foam::radiation::"
165  "greyDiffusiveRadiationMixedFvPatchScalarField::updateCoeffs"
166  ) << " a grey boundary condition is used with a non-grey "
167  << "absorption model" << nl << exit(FatalError);
168  }
169 
170  scalarField& Iw = *this;
171  vectorField n = patch().Sf()/patch().magSf();
172 
173  radiativeIntensityRay& ray =
174  const_cast<radiativeIntensityRay&>(dom.IRay(rayId));
175 
176  ray.Qr().boundaryField()[patchI] += Iw*(n & ray.dAve());
177 
178  forAll(Iw, faceI)
179  {
180  scalar Ir = 0.0;
181 
182  for (label rayI=0; rayI < dom.nRay(); rayI++)
183  {
184  const vector& d = dom.IRay(rayI).d();
185 
186  const scalarField& IFace =
187  dom.IRay(rayI).ILambda(lambdaId).boundaryField()[patchI];
188 
189  if ((-n[faceI] & d) < 0.0)
190  {
191  // q into the wall
192  const vector& dAve = dom.IRay(rayI).dAve();
193  Ir += IFace[faceI]*mag(n[faceI] & dAve);
194  }
195  }
196 
197  const vector& d = dom.IRay(rayId).d();
198 
199  if ((-n[faceI] & d) > 0.0)
200  {
201  // direction out of the wall
202  refGrad()[faceI] = 0.0;
203  valueFraction()[faceI] = 1.0;
204  refValue()[faceI] =
205  (
206  Ir*(1.0 - emissivity_)
207  + emissivity_*radiation::sigmaSB.value()*pow4(Tp[faceI])
208  )
210 
211  // Emmited heat flux from this ray direction
212  ray.Qem().boundaryField()[patchI][faceI] =
213  refValue()[faceI]*(n[faceI] & ray.dAve());
214 
215  }
216  else
217  {
218  // direction into the wall
219  valueFraction()[faceI] = 0.0;
220  refGrad()[faceI] = 0.0;
221  refValue()[faceI] = 0.0; //not used
222 
223  // Incident heat flux on this ray direction
224  ray.Qin().boundaryField()[patchI][faceI] =
225  Iw[faceI]*(n[faceI] & ray.dAve());
226  }
227  }
228 
230 }
231 
232 
234 (
235  Ostream& os
236 ) const
237 {
238  mixedFvPatchScalarField::write(os);
239  os.writeKeyword("T") << TName_ << token::END_STATEMENT << nl;
240  os.writeKeyword("emissivity") << emissivity_ << token::END_STATEMENT << nl;
241 }
242 
243 
244 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
245 
246 namespace Foam
247 {
248 namespace radiation
249 {
251  (
254  );
255 }
256 }
257 
258 
259 // ************************ vim: set sw=4 sts=4 et: ************************ //