turbulentHeatFluxTemperatureFvPatchScalarField.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 "fvCFD.H"
29 #include "fvPatchFieldMapper.H"
32 
33 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
34 
35 namespace Foam
36 {
37  // declare specialization within 'Foam' namespace
38  template<>
39  const char* NamedEnum
40  <
43  2
44  >::names[] =
45  {
46  "power",
47  "flux"
48  };
49 }
50 
51 
52 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
53 
54 
55 namespace Foam
56 {
57 
58 namespace incompressible
59 {
60 
61 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
62 
63 const NamedEnum
64 <
66  2
68 
69 
70 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
71 
74 (
75  const fvPatch& p,
77 )
78 :
79  fixedGradientFvPatchScalarField(p, iF),
80  heatSource_(hsPower),
81  q_(p.size(), 0.0),
82  QrName_("undefinedQr")
83 {}
84 
85 
88 (
90  const fvPatch& p,
92  const fvPatchFieldMapper& mapper
93 )
94 :
95  fixedGradientFvPatchScalarField(ptf, p, iF, mapper),
96  heatSource_(ptf.heatSource_),
97  q_(ptf.q_, mapper),
98  QrName_(ptf.QrName_)
99 {}
100 
101 
104 (
105  const fvPatch& p,
107  const dictionary& dict
108 )
109 :
110  fixedGradientFvPatchScalarField(p, iF),
111  heatSource_(heatSourceTypeNames_.read(dict.lookup("heatSource"))),
112  q_("q", dict, p.size()),
113  QrName_(dict.lookupOrDefault<word>("Qr", "none"))
114 {
115  if (dict.found("value") && dict.found("gradient"))
116  {
118  gradient() = Field<scalar>("gradient", dict, p.size());
119  }
120  else
121  {
122  fvPatchField<scalar>::operator=(patchInternalField());
123  gradient() = 0.0;
124  }
125 }
126 
127 
130 (
132 )
133 :
134  fixedGradientFvPatchScalarField(thftpsf),
135  heatSource_(thftpsf.heatSource_),
136  q_(thftpsf.q_),
137  QrName_(thftpsf.QrName_)
138 {}
139 
140 
143 (
146 )
147 :
148  fixedGradientFvPatchScalarField(thftpsf, iF),
149  heatSource_(thftpsf.heatSource_),
150  q_(thftpsf.q_),
151  QrName_(thftpsf.QrName_)
152 {}
153 
154 
155 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
156 
158 (
159  const fvPatchFieldMapper& m
160 )
161 {
162  fixedGradientFvPatchScalarField::autoMap(m);
163  q_.autoMap(m);
164 }
165 
166 
168 (
169  const fvPatchScalarField& ptf,
170  const labelList& addr
171 )
172 {
173  fixedGradientFvPatchScalarField::rmap(ptf, addr);
174 
176  refCast<const turbulentHeatFluxTemperatureFvPatchScalarField>
177  (
178  ptf
179  );
180 
181  q_.rmap(thftptf.q_, addr);
182 }
183 
184 
186 {
187  if (updated())
188  {
189  return;
190  }
191 
192  const scalarField& alphat =
193  patch().lookupPatchField<volScalarField, scalar>("alphat");
194 
195  typedef incompressible::turbulenceModel iTModel;
196  const iTModel& tModel =
197  db().lookupObject<iTModel>
198  (
200  (
203  )
204  );
205 
206  // need kappaEff = kappa(laminar) + kappat, where kappal = nu/Pr
207  // See applications/solvers/heatTransfer/buoyantBoussinesqSimpleFoam/TEqn.H
208  const label patchI = patch().index();
209  const scalarField& nu = tModel.nu()->boundaryField()[patchI];
210  const singlePhaseTransportModel & transport =
211  static_cast<const singlePhaseTransportModel &>(tModel.transport());
212  const scalar
213  Pr(dimensionedScalar(transport.lookup("Pr")).value());
214  const scalar Cp0(dimensionedScalar(transport.lookup("Cp")).value());
215  const scalar rho(dimensionedScalar(transport.lookup("rho")).value());
216 
217  scalarField qr(this->size(), 0.0);
218 
219  //- Qr is negative going into the domain
220  if (QrName_ != "none")
221  {
222  qr = patch().lookupPatchField<volScalarField, scalar>(QrName_);
223  }
224 
225  const scalarField kappaEff(rho * Cp0 * (nu/Pr + alphat));
226 
227  switch (heatSource_)
228  {
229  case hsPower:
230  {
231  const scalar Ap = gSum(patch().magSf());
232  gradient() = (q_/Ap + qr) / kappaEff;
233  break;
234  }
235  case hsFlux:
236  {
237  gradient() = (q_ + qr) / kappaEff;
238  break;
239  }
240  default:
241  {
243  << "Unknown heat source type. Valid types are: "
245  }
246  }
247 
248  fixedGradientFvPatchScalarField::updateCoeffs();
249 }
250 
251 
253 {
255  os.writeKeyword("heatSource") << heatSourceTypeNames_[heatSource_]
256  << token::END_STATEMENT << nl;
257  q_.writeEntry("q", os);
258  os.writeKeyword("Qr")<< QrName_ << token::END_STATEMENT << nl;
259  writeEntry("value", os);
260 }
261 
262 
263 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
264 
266 (
269 );
270 
271 
272 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
273 
274 } // End namespace incompressible
275 } // End namespace Foam
276 
277 // ************************************************************************* //
Foam::fvPatchField
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:65
Foam::fvPatchField::operator=
virtual void operator=(const UList< Type > &)
Foam::token::END_STATEMENT
@ END_STATEMENT
Definition: token.H:99
Foam::IOobject::groupName
static word groupName(Name name, const word &group)
turbulentHeatFluxTemperatureFvPatchScalarField.H
p
p
Definition: pEqn.H:62
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
singlePhaseTransportModel.H
dimensionedInternalField
rDeltaT dimensionedInternalField()
alphat
alphat
Definition: TEqn.H:2
Foam::incompressible::turbulentHeatFluxTemperatureFvPatchScalarField::heatSource_
heatSourceType heatSource_
Heat source type.
Definition: turbulentHeatFluxTemperatureFvPatchScalarField.H:138
turbulentTransportModel.H
Foam::dictionary::lookup
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:449
Foam::turbulenceModel::propertiesName
static const word propertiesName
Default name of the turbulence properties dictionary.
Definition: turbulenceModel.H:97
Foam::incompressible::turbulentHeatFluxTemperatureFvPatchScalarField::updateCoeffs
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Definition: turbulentHeatFluxTemperatureFvPatchScalarField.C:185
Foam::dictionary::lookupOrDefault
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
Definition: dictionaryTemplates.C:33
Foam::GeometricField::boundaryField
GeometricBoundaryField & boundaryField()
Return reference to GeometricBoundaryField.
Definition: GeometricField.C:735
Foam::constant::atomic::group
const char *const group
Group name for atomic constants.
Definition: atomicConstants.C:40
fvPatchFieldMapper.H
Foam::dimensioned::value
const Type & value() const
Return const reference to value.
Definition: dimensionedType.C:261
Foam::gSum
Type gSum(const FieldField< Field, Type > &f)
Definition: FieldFieldFunctions.C:564
Foam::singlePhaseTransportModel
A simple single-phase transport model based on viscosityModel.
Definition: singlePhaseTransportModel.H:55
nu
volScalarField & nu
Definition: readMechanicalProperties.H:179
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
Foam::dictionary::found
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
Definition: dictionary.C:304
Foam::Field< scalar >
Foam::incompressible::turbulentHeatFluxTemperatureFvPatchScalarField::QrName_
word QrName_
Name of radiative in flux field.
Definition: turbulentHeatFluxTemperatureFvPatchScalarField.H:144
Foam::nl
static const char nl
Definition: Ostream.H:260
Foam::fvPatch
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:61
Foam::dimensionedScalar
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
Definition: dimensionedScalarFwd.H:41
Foam::volScalarField
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:52
Pr
dimensionedScalar Pr("Pr", dimless, laminarTransport)
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::FatalError
error FatalError
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
Foam::incompressible::turbulentHeatFluxTemperatureFvPatchScalarField::q_
scalarField q_
Heat power [W] or flux [W/m2].
Definition: turbulentHeatFluxTemperatureFvPatchScalarField.H:141
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam::incompressible::turbulentHeatFluxTemperatureFvPatchScalarField::turbulentHeatFluxTemperatureFvPatchScalarField
turbulentHeatFluxTemperatureFvPatchScalarField(const fvPatch &, const DimensionedField< scalar, volMesh > &)
Construct from patch and internal field.
Definition: turbulentHeatFluxTemperatureFvPatchScalarField.C:74
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
Foam::incompressible::turbulentHeatFluxTemperatureFvPatchScalarField::heatSourceType
heatSourceType
Enumeration listing the possible hest source input modes.
Definition: turbulentHeatFluxTemperatureFvPatchScalarField.H:123
Foam::Field::writeEntry
void writeEntry(const word &keyword, Ostream &os) const
Write the field as a dictionary entry.
Definition: Field.C:700
rho
rho
Definition: pEqn.H:3
Foam::incompressible::turbulentHeatFluxTemperatureFvPatchScalarField::heatSourceTypeNames_
static const NamedEnum< heatSourceType, 2 > heatSourceTypeNames_
Heat source type names.
Definition: turbulentHeatFluxTemperatureFvPatchScalarField.H:135
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:318
Foam::incompressible::turbulentHeatFluxTemperatureFvPatchScalarField::write
virtual void write(Ostream &) const
Write.
Definition: turbulentHeatFluxTemperatureFvPatchScalarField.C:252
Foam::incompressible::turbulentHeatFluxTemperatureFvPatchScalarField::rmap
virtual void rmap(const fvPatchScalarField &, const labelList &)
Reverse map the given fvPatchField onto this fvPatchField.
Definition: turbulentHeatFluxTemperatureFvPatchScalarField.C:168
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
Foam::incompressible::turbulentHeatFluxTemperatureFvPatchScalarField::autoMap
virtual void autoMap(const fvPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
Definition: turbulentHeatFluxTemperatureFvPatchScalarField.C:158
Foam::incompressible::turbulentHeatFluxTemperatureFvPatchScalarField::hsPower
@ hsPower
Definition: turbulentHeatFluxTemperatureFvPatchScalarField.H:125
Foam::Ostream::writeKeyword
Ostream & writeKeyword(const keyType &)
Write the keyword followed by an appropriate indentation.
Definition: Ostream.C:59
Foam::incompressible::turbulentHeatFluxTemperatureFvPatchScalarField
Fixed heat boundary condition to specify temperature gradient. Input heat source either specified in ...
Definition: turbulentHeatFluxTemperatureFvPatchScalarField.H:114
fvCFD.H
Foam::IncompressibleTurbulenceModel
Templated abstract base class for single-phase incompressible turbulence models.
Definition: IncompressibleTurbulenceModel.H:52
Foam::fvPatchFieldMapper
Foam::fvPatchFieldMapper.
Definition: fvPatchFieldMapper.H:45
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
Foam::incompressible::turbulentHeatFluxTemperatureFvPatchScalarField::hsFlux
@ hsFlux
Definition: turbulentHeatFluxTemperatureFvPatchScalarField.H:126
write
Tcoeff write()
Foam::NamedEnum
Initialise the NamedEnum HashTable from the static list of names.
Definition: NamedEnum.H:52
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:51
Foam::incompressible::makePatchTypeField
makePatchTypeField(fvPatchScalarField, turbulentBoundaryCoupledFvPatchScalarField)