temperatureCoupledBase.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-2016 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 
84 
86 (
87  const fvPatch& patch,
88  const temperatureCoupledBase& base
89 )
90 :
91  patch_(patch),
92  method_(base.method_),
93  kappaName_(base.kappaName_),
94  alphaAniName_(base.alphaAniName_)
95 {}
96 
97 
98 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
99 
101 (
102  const scalarField& Tp
103 ) const
104 {
105  const fvMesh& mesh = patch_.boundaryMesh().mesh();
106  const label patchi = patch_.index();
107 
108  switch (method_)
109  {
110  case mtFluidThermo:
111  {
113 
115 
116  if
117  (
118  mesh.foundObject<turbulenceModel>(turbName)
119  )
120  {
121  const turbulenceModel& turbModel =
122  mesh.lookupObject<turbulenceModel>(turbName);
123 
124  return turbModel.kappaEff(patchi);
125  }
127  {
128  const fluidThermo& thermo =
130 
131  return thermo.kappa(patchi);
132  }
133  else
134  {
136  << "Kappa defined to employ " << KMethodTypeNames_[method_]
137  << " method, but thermo package not available"
138  << exit(FatalError);
139  }
140 
141  break;
142  }
143 
144  case mtSolidThermo:
145  {
146  const solidThermo& thermo =
148 
149  return thermo.kappa(patchi);
150  break;
151  }
152 
153  case mtDirectionalSolidThermo:
154  {
155  const solidThermo& thermo =
157 
158  const symmTensorField& alphaAni =
159  patch_.lookupPatchField<volSymmTensorField, scalar>
160  (
161  alphaAniName_
162  );
163 
164  const scalarField& pp = thermo.p().boundaryField()[patchi];
165 
166  const symmTensorField kappa(alphaAni*thermo.Cp(pp, Tp, patchi));
167 
168  const vectorField n(patch_.nf());
169 
170  return n & kappa & n;
171  }
172 
173  case mtLookup:
174  {
175  if (mesh.foundObject<volScalarField>(kappaName_))
176  {
177  return patch_.lookupPatchField<volScalarField, scalar>
178  (
179  kappaName_
180  );
181  }
182  else if (mesh.foundObject<volSymmTensorField>(kappaName_))
183  {
184  const symmTensorField& KWall =
185  patch_.lookupPatchField<volSymmTensorField, scalar>
186  (
187  kappaName_
188  );
189 
190  const vectorField n(patch_.nf());
191 
192  return n & KWall & n;
193  }
194  else
195  {
197  << "Did not find field " << kappaName_
198  << " on mesh " << mesh.name() << " patch " << patch_.name()
199  << nl
200  << "Please set 'kappa' to one of "
201  << KMethodTypeNames_.toc()
202  << " and 'kappaName' to the name of the volScalar"
203  << " or volSymmTensor field (if kappa=lookup)"
204  << exit(FatalError);
205  }
206 
207  break;
208  }
209 
210  default:
211  {
213  << "Unimplemented method " << KMethodTypeNames_[method_] << nl
214  << "Please set 'kappa' to one of " << KMethodTypeNames_.toc()
215  << " and 'kappaName' to the name of the volScalar"
216  << " or volSymmTensor field (if kappa=lookup)"
217  << exit(FatalError);
218  }
219  }
220 
221  return scalarField(0);
222 }
223 
224 
226 {
227  os.writeKeyword("kappaMethod") << KMethodTypeNames_[method_]
228  << token::END_STATEMENT << nl;
229  os.writeKeyword("kappa") << kappaName_ << token::END_STATEMENT << nl;
230  os.writeKeyword("alphaAni") << alphaAniName_ << token::END_STATEMENT << nl;
231 }
232 
233 
234 // ************************************************************************* //
GeometricField< symmTensor, fvPatchField, volMesh > volSymmTensorField
Definition: volFieldsFwd.H:58
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 [J/m/s/K].
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
void write(Ostream &) const
Write.
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:137
bool foundObject(const word &name) const
Is the named Type found?
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:319
KMethodType
Type of supplied Kappa.
const word dictName() const
Return the local dictionary name (final part of scoped name)
Definition: dictionary.H:115
ThermalDiffusivity< CompressibleTurbulenceModel< fluidThermo > > turbulenceModel
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:61
Templated wrapper class to provide compressible turbulence models thermal diffusivity based thermal t...
Initialise the NamedEnum HashTable from the static list of names.
Definition: NamedEnum.H:52
const dimensionedScalar kappa
Coulomb constant: default SI units: [N.m2/C2].
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Definition: polyMesh.H:421
virtual volScalarField & p()
Pressure [Pa].
Definition: basicThermo.C:466
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:52
const Type & lookupObject(const word &name) const
Lookup and return the object of the given Type.
dynamicFvMesh & mesh
const Boundary & boundaryField() const
Return const-reference to the boundary field.
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.
Basic thermodynamics type based on the use of fitting functions for cp, h, s obtained from the templa...
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:262
const word alphaAniName_
Name of the non-Isotropic alpha (default: Anialpha)
Fundamental solid thermodynamic properties.
Definition: solidThermo.H:54
Ostream & writeKeyword(const keyType &)
Write the keyword followed by an appropriate indentation.
Definition: Ostream.C:54
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_
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:54
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
tmp< scalarField > kappa(const scalarField &Tp) const
Given patch temperature calculate corresponding K field.
const word & name() const
Return reference to name.
Definition: fvMesh.H:257
Namespace for OpenFOAM.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:451