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-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 
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("kappa"))),
80  kappaName_(dict.lookup("kappaName")),
81  alphaAniName_(dict.lookupOrDefault<word>("alphaAniName","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  (
137  "temperatureCoupledBase::kappa(const scalarField&) const"
138  )
139  << "Kappa defined to employ " << KMethodTypeNames_[method_]
140  << " method, but thermo package not available"
141  << exit(FatalError);
142  }
143 
144  break;
145  }
146 
147  case mtSolidThermo:
148  {
149  const solidThermo& thermo =
151 
152  return thermo.kappa(patchI);
153  break;
154  }
155 
156  case mtDirectionalSolidThermo:
157  {
158  const solidThermo& thermo =
160 
161  const symmTensorField& alphaAni =
162  patch_.lookupPatchField<volSymmTensorField, scalar>
163  (
164  alphaAniName_
165  );
166 
167  const scalarField& pp = thermo.p().boundaryField()[patchI];
168 
169  const symmTensorField kappa(alphaAni*thermo.Cp(pp, Tp, patchI));
170 
171  const vectorField n(patch_.nf());
172 
173  return n & kappa & n;
174  }
175 
176  case mtLookup:
177  {
178  if (mesh.foundObject<volScalarField>(kappaName_))
179  {
180  return patch_.lookupPatchField<volScalarField, scalar>
181  (
182  kappaName_
183  );
184  }
185  else if (mesh.foundObject<volSymmTensorField>(kappaName_))
186  {
187  const symmTensorField& KWall =
188  patch_.lookupPatchField<volSymmTensorField, scalar>
189  (
190  kappaName_
191  );
192 
193  const vectorField n(patch_.nf());
194 
195  return n & KWall & n;
196  }
197  else
198  {
200  (
201  "temperatureCoupledBase::kappa(const scalarField&) const"
202  )
203  << "Did not find field " << kappaName_
204  << " on mesh " << mesh.name() << " patch " << patch_.name()
205  << nl
206  << "Please set 'kappa' to one of "
207  << KMethodTypeNames_.toc()
208  << " and 'kappaName' to the name of the volScalar"
209  << " or volSymmTensor field (if kappa=lookup)"
210  << exit(FatalError);
211  }
212 
213  break;
214  }
215 
216  default:
217  {
219  (
220  "temperatureCoupledBase::kappa(const scalarField&) const"
221  )
222  << "Unimplemented method " << KMethodTypeNames_[method_] << nl
223  << "Please set 'kappa' to one of " << KMethodTypeNames_.toc()
224  << " and 'kappaName' to the name of the volScalar"
225  << " or volSymmTensor field (if kappa=lookup)"
226  << exit(FatalError);
227  }
228  }
229 
230  return scalarField(0);
231 }
232 
233 
235 {
236  os.writeKeyword("kappa") << KMethodTypeNames_[method_]
237  << token::END_STATEMENT << nl;
238  os.writeKeyword("kappaName") << kappaName_ << token::END_STATEMENT << nl;
239 }
240 
241 
242 // ************************************************************************* //
static const NamedEnum< KMethodType, 4 > KMethodTypeNames_
const word kappaName_
Name of thermal conductivity field (if looked up from database)
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
const word & name() const
Return reference to name.
Definition: fvMesh.H:257
GeometricBoundaryField & boundaryField()
Return reference to GeometricBoundaryField.
bool foundObject(const word &name) const
Is the named Type found?
virtual tmp< volScalarField > kappa() const =0
Thermal diffusivity for temperature of mixture [J/m/s/K].
A class for handling words, derived from string.
Definition: word.H:59
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
void write(Ostream &) const
Write.
virtual volScalarField & p()
Pressure [Pa].
Definition: basicThermo.C:466
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
const KMethodType method_
How to get K.
dynamicFvMesh & mesh
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
virtual tmp< volScalarField > Cp() const =0
Heat capacity at constant pressure [J/kg/K].
Namespace for OpenFOAM.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
ThermalDiffusivity< CompressibleTurbulenceModel< fluidThermo > > turbulenceModel
label n
static const char nl
Definition: Ostream.H:260
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:52
Fundamental solid thermodynamic properties.
Definition: solidThermo.H:54
const Type & lookupObject(const word &name) const
Lookup and return the object of the given Type.
GeometricField< symmTensor, fvPatchField, volMesh > volSymmTensorField
Definition: volFieldsFwd.H:58
Fundamental fluid thermodynamic properties.
Definition: fluidThermo.H:49
Ostream & writeKeyword(const keyType &)
Write the keyword followed by an appropriate indentation.
Definition: Ostream.C:59
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Definition: polyMesh.H:421
Initialise the NamedEnum HashTable from the static list of names.
Definition: NamedEnum.H:52
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
Definition: error.H:314
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:452
error FatalError
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
temperatureCoupledBase(const fvPatch &patch, const word &calculationMethod, const word &kappaName, const word &alphaAniName)
Construct from patch and K name.
const polyMesh & mesh() const
Return the mesh reference.
KMethodType
Type of supplied Kappa.
tmp< scalarField > kappa(const scalarField &Tp) const
Given patch temperature calculate corresponding K field.
Common functions for use in temperature coupled boundaries.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
static const word propertiesName
Default name of the turbulence properties dictionary.
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:61
const word dictName() const
Return the local dictionary name (final part of scoped name)
Definition: dictionary.H:115
Basic thermodynamics type based on the use of fitting functions for cp, h, s obtained from the templa...
const dimensionedScalar kappa
Coulomb constant: default SI units: [N.m2/C2].
Templated wrapper class to provide compressible turbulence models thermal diffusivity based thermal t...
A class for managing temporary objects.
Definition: PtrList.H:118
const word alphaAniName_
Name of the non-Isotropic alpha (default: Anialpha)