temperatureCoupledBase.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2019 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 
26 #include "temperatureCoupledBase.H"
27 #include "volFields.H"
28 #include "fluidThermo.H"
29 #include "solidThermo.H"
31 
32 // * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36  template<>
37  const char* Foam::NamedEnum
38  <
40  4
41  >::names[] =
42  {
43  "fluidThermo",
44  "solidThermo",
45  "directionalSolidThermo",
46  "lookup"
47  };
48 }
49 
50 
53 
54 
55 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
56 
58 (
59  const fvPatch& patch,
60  const word& calculationType,
61  const word& kappaName,
62  const word& alphaAniName
63 )
64 :
65  patch_(patch),
66  method_(KMethodTypeNames_[calculationType]),
67  kappaName_(kappaName),
68  alphaAniName_(alphaAniName)
69 {}
70 
71 
73 (
74  const fvPatch& patch,
75  const dictionary& dict
76 )
77 :
78  patch_(patch),
79  method_(KMethodTypeNames_.read(dict.lookup("kappaMethod"))),
80  kappaName_(dict.lookupOrDefault<word>("kappa", "none")),
81  alphaAniName_(dict.lookupOrDefault<word>("alphaAni","Anialpha"))
82 {
83  switch (method_)
84  {
85  case mtDirectionalSolidThermo:
86  {
87  if (!dict.found("alphaAni"))
88  {
90  << "Did not find entry 'alphaAni'"
91  " required for 'kappaMethod' "
92  << KMethodTypeNames_[method_]
93  << exit(FatalIOError);
94  }
95 
96  break;
97  }
98 
99  case mtLookup:
100  {
101  if (!dict.found("kappa"))
102  {
104  << "Did not find entry 'kappa'"
105  " required for 'kappaMethod' "
106  << KMethodTypeNames_[method_] << nl
107  << " Please set 'kappa' to the name of a volScalarField"
108  " or volSymmTensorField"
109  << exit(FatalIOError);
110  }
111 
112  break;
113  }
114 
115  default:
116  break;
117  }
118 }
119 
120 
122 (
123  const fvPatch& patch,
124  const temperatureCoupledBase& base
125 )
126 :
127  patch_(patch),
128  method_(base.method_),
129  kappaName_(base.kappaName_),
130  alphaAniName_(base.alphaAniName_)
131 {}
132 
133 
134 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
135 
137 (
138  const scalarField& Tp
139 ) const
140 {
141  const fvMesh& mesh = patch_.boundaryMesh().mesh();
142  const label patchi = patch_.index();
143 
144  switch (method_)
145  {
146  case mtFluidThermo:
147  {
149 
151 
152  if
153  (
154  mesh.foundObject<turbulenceModel>(turbName)
155  )
156  {
157  const turbulenceModel& turbModel =
158  mesh.lookupObject<turbulenceModel>(turbName);
159 
160  return turbModel.kappaEff(patchi);
161  }
163  {
164  const fluidThermo& thermo =
166 
167  return thermo.kappa(patchi);
168  }
169  else
170  {
172  << "kappaMethod defined to employ "
173  << KMethodTypeNames_[method_]
174  << " method, but thermo package not available"
175  << exit(FatalError);
176  }
177 
178  break;
179  }
180 
181  case mtSolidThermo:
182  {
183  const solidThermo& thermo =
185 
186  return thermo.kappa(patchi);
187  break;
188  }
189 
190  case mtDirectionalSolidThermo:
191  {
192  const solidThermo& thermo =
194 
195  const symmTensorField& alphaAni =
196  patch_.lookupPatchField<volSymmTensorField, scalar>
197  (
198  alphaAniName_
199  );
200 
201  const scalarField& pp = thermo.p().boundaryField()[patchi];
202 
203  const symmTensorField kappa(alphaAni*thermo.Cp(pp, Tp, patchi));
204 
205  const vectorField n(patch_.nf());
206 
207  return n & kappa & n;
208  }
209 
210  case mtLookup:
211  {
212  if (mesh.foundObject<volScalarField>(kappaName_))
213  {
214  return patch_.lookupPatchField<volScalarField, scalar>
215  (
216  kappaName_
217  );
218  }
219  else if (mesh.foundObject<volSymmTensorField>(kappaName_))
220  {
221  const symmTensorField& KWall =
222  patch_.lookupPatchField<volSymmTensorField, scalar>
223  (
224  kappaName_
225  );
226 
227  const vectorField n(patch_.nf());
228 
229  return n & KWall & n;
230  }
231  else
232  {
234  << "Did not find field " << kappaName_
235  << " on mesh " << mesh.name() << " patch " << patch_.name()
236  << nl
237  << " Please set 'kappa' to the name of a volScalarField"
238  " or volSymmTensorField."
239  << exit(FatalError);
240  }
241 
242  break;
243  }
244 
245  default:
246  {
248  << "Unimplemented method " << KMethodTypeNames_[method_] << nl
249  << " Please set 'kappaMethod' to one of "
250  << KMethodTypeNames_.toc()
251  << " and 'kappa' to the name of the volScalar"
252  << " or volSymmTensor field (if kappa=lookup)"
253  << exit(FatalError);
254  }
255  }
256 
257  return scalarField(0);
258 }
259 
260 
262 {
263  writeEntry(os, "kappaMethod", KMethodTypeNames_[method_]);
264  writeEntry(os, "kappa", kappaName_);
265  writeEntry(os, "alphaAni", alphaAniName_);
266 }
267 
268 
269 // ************************************************************************* //
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Definition: polyMesh.H:434
GeometricField< symmTensor, fvPatchField, volMesh > volSymmTensorField
Definition: volFieldsFwd.H:58
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
Definition: dictionary.C:438
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
virtual tmp< volScalarField > kappa() const =0
Thermal diffusivity for temperature of mixture [W/m/K].
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
const word kappaName_
Name of thermal conductivity field (if looked up from database)
error FatalError
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:158
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:319
const Boundary & boundaryField() const
Return const-reference to the boundary field.
KMethodType
Type of supplied Kappa.
tmp< scalarField > kappa(const scalarField &Tp) const
Given patch temperature calculate corresponding K field.
ThermalDiffusivity< CompressibleTurbulenceModel< fluidThermo > > turbulenceModel
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:61
bool foundObject(const word &name) const
Is the named Type found?
Templated wrapper class to provide compressible turbulence models thermal diffusivity based thermal t...
rhoReactionThermo & thermo
Definition: createFields.H:28
const Type & lookupObject(const word &name) const
Lookup and return the object of the given Type.
Initialise the NamedEnum HashTable from the static list of names.
Definition: NamedEnum.H:51
const dimensionedScalar kappa
Coulomb constant: default SI units: [N.m2/C2].
const word dictName() const
Return the local dictionary name (final part of scoped name)
Definition: dictionary.H:123
virtual volScalarField & p()
Pressure [Pa].
Definition: basicThermo.C:477
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:52
dynamicFvMesh & mesh
static const word propertiesName
Default name of the turbulence properties dictionary.
A class for handling words, derived from string.
Definition: word.H:59
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Fundamental fluid thermodynamic properties.
Definition: fluidThermo.H:49
const polyMesh & mesh() const
Return the mesh reference.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
static const char nl
Definition: Ostream.H:265
const word alphaAniName_
Name of the non-Isotropic alpha (default: Anialpha)
Fundamental solid thermodynamic properties.
Definition: solidThermo.H:48
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
Definition: HashTableIO.C:96
virtual tmp< volScalarField > Cp() const =0
Heat capacity at constant pressure [J/kg/K].
const KMethodType method_
How to get K.
Common functions used in temperature coupled boundaries.
label patchi
static const NamedEnum< KMethodType, 4 > KMethodTypeNames_
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
const word & name() const
Return reference to name.
Definition: fvMesh.H:253
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:331
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
label n
temperatureCoupledBase(const fvPatch &patch, const word &calculationMethod, const word &kappaName, const word &alphaAniName)
Construct from patch and K name.
A class for managing temporary objects.
Definition: PtrList.H:53
void write(Ostream &) const
Write.
Namespace for OpenFOAM.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:583
IOerror FatalIOError