MarshakRadiationFixedTemperatureFvPatchScalarField.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) 2011-2015 OpenFOAM Foundation
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 
28 #include "fvPatchFieldMapper.H"
29 #include "volFields.H"
30 #include "radiationModel.H"
32 
33 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
34 
37 (
38  const fvPatch& p,
40 )
41 :
42  mixedFvPatchScalarField(p, iF),
43  radiationCoupledBase(p, "undefined", scalarField::null()),
44  Trad_(p.size())
45 {
46  refValue() = 0.0;
47  refGrad() = 0.0;
48  valueFraction() = 0.0;
49 }
50 
51 
54 (
56  const fvPatch& p,
58  const fvPatchFieldMapper& mapper
59 )
60 :
61  mixedFvPatchScalarField(ptf, p, iF, mapper),
63  (
64  p,
65  ptf.emissivityMethod(),
66  ptf.emissivity_,
67  mapper
68  ),
69  Trad_(ptf.Trad_, mapper)
70 {}
71 
72 
75 (
76  const fvPatch& p,
78  const dictionary& dict
79 )
80 :
81  mixedFvPatchScalarField(p, iF),
82  radiationCoupledBase(p, dict),
83  Trad_("Trad", dict, p.size())
84 {
85  // refValue updated on each call to updateCoeffs()
86  refValue() = 4.0*constant::physicoChemical::sigma.value()*pow4(Trad_);
87 
88  // zero gradient
89  refGrad() = 0.0;
90 
91  valueFraction() = 1.0;
92 
93  fvPatchScalarField::operator=(refValue());
94 }
95 
96 
99 (
101 )
102 :
103  mixedFvPatchScalarField(ptf),
105  (
106  ptf.patch(),
107  ptf.emissivityMethod(),
108  ptf.emissivity_
109  ),
110  Trad_(ptf.Trad_)
111 {}
112 
113 
116 (
119 )
120 :
121  mixedFvPatchScalarField(ptf, iF),
123  (
124  ptf.patch(),
125  ptf.emissivityMethod(),
126  ptf.emissivity_
127  ),
128  Trad_(ptf.Trad_)
129 {}
130 
131 
132 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
133 
135 (
136  const fvPatchFieldMapper& m
137 )
138 {
139  mixedFvPatchScalarField::autoMap(m);
140  radiationCoupledBase::autoMap(m);
141  Trad_.autoMap(m);
142 }
143 
144 
146 (
147  const fvPatchScalarField& ptf,
148  const labelList& addr
149 )
150 {
151  mixedFvPatchScalarField::rmap(ptf, addr);
152  radiationCoupledBase::rmap(ptf, addr);
154  refCast<const MarshakRadiationFixedTemperatureFvPatchScalarField>(ptf);
155 
156  Trad_.rmap(mrptf.Trad_, addr);
157 }
158 
159 
161 {
162  if (this->updated())
163  {
164  return;
165  }
166 
167  // Since we're inside initEvaluate/evaluate there might be processor
168  // comms underway. Change the tag we use.
169  int oldTag = UPstream::msgType();
170  UPstream::msgType() = oldTag+1;
171 
172  // Re-calc reference value
173  refValue() = 4.0*constant::physicoChemical::sigma.value()*pow4(Trad_);
174 
175  // Diffusion coefficient - created by radiation model's ::updateCoeffs()
176  const scalarField& gamma =
177  patch().lookupPatchField<volScalarField, scalar>("gammaRad");
178 
179  const scalarField temissivity = emissivity();
180 
181  const scalarField Ep(temissivity/(2.0*(scalar(2.0) - temissivity)));
182 
183  // Set value fraction
184  valueFraction() = 1.0/(1.0 + gamma*patch().deltaCoeffs()/Ep);
185 
186  // Restore tag
187  UPstream::msgType() = oldTag;
188 
189  mixedFvPatchScalarField::updateCoeffs();
190 }
191 
192 
194 (
195  Ostream& os
196 ) const
197 {
200  Trad_.writeEntry("Trad", os);
201 }
202 
203 
204 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
205 
206 namespace Foam
207 {
209  (
212  );
213 }
214 
215 
216 // ************************************************************************* //
virtual void rmap(const fvPatchScalarField &, const labelList &)
Reverse map the given fvPatchField onto this fvPatchField.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:61
const dimensionedScalar sigma
Stefan-Boltzmann constant: default SI units: [W/m2/K4].
void writeEntry(const word &keyword, Ostream &os) const
Write the field as a dictionary entry.
Definition: Field.C:719
scalarField emissivity() const
Calculate corresponding emissivity field.
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:65
const Type & value() const
Return const reference to value.
static int & msgType()
Message tag of standard messages.
Definition: UPstream.H:464
scalarField emissivity_
Emissivity.
Macros for easy insertion into run-time selection tables.
void write(Ostream &) const
Write.
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:52
makePatchTypeField(fvPatchVectorField, SRFFreestreamVelocityFvPatchVectorField)
MarshakRadiationFixedTemperatureFvPatchScalarField(const fvPatch &, const DimensionedField< scalar, volMesh > &)
Construct from patch and internal field.
word emissivityMethod() const
Method to obtain emissivity.
Foam::fvPatchFieldMapper.
virtual label size() const
Return size.
Definition: fvPatch.H:161
A &#39;mixed&#39; boundary condition that implements a Marshak condition for the incident radiation field (us...
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Common functions to emissivity. It gets supplied from lookup into a dictionary or calculated by the s...
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
dimensionedScalar pow4(const dimensionedScalar &ds)
virtual void autoMap(const fvPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
runTime write()
Namespace for OpenFOAM.