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 
114  word turbName(turbulenceModel::propertiesName);
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  }
126  else if (mesh.foundObject<fluidThermo>(basicThermo::dictName))
127  {
128  const fluidThermo& thermo =
129  mesh.lookupObject<fluidThermo>(basicThermo::dictName);
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 =
147  mesh.lookupObject<solidThermo>(basicThermo::dictName);
148 
149  return thermo.kappa(patchI);
150  break;
151  }
152 
153  case mtDirectionalSolidThermo:
154  {
155  const solidThermo& thermo =
156  mesh.lookupObject<solidThermo>(basicThermo::dictName);
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("kappa") << KMethodTypeNames_[method_]
228  << token::END_STATEMENT << nl;
229  os.writeKeyword("kappaName") << kappaName_ << token::END_STATEMENT << nl;
230 }
231 
232 
233 // ************************************************************************* //
volFields.H
Foam::token::END_STATEMENT
@ END_STATEMENT
Definition: token.H:99
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::temperatureCoupledBase::alphaAniName_
const word alphaAniName_
Name of the non-Isotropic alpha (default: Anialpha)
Definition: temperatureCoupledBase.H:136
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:118
fluidThermo.H
Foam::fluidThermo
Fundamental fluid thermodynamic properties.
Definition: fluidThermo.H:49
Foam::temperatureCoupledBase
Common functions for use in temperature coupled boundaries.
Definition: temperatureCoupledBase.H:104
thermo
Basic thermodynamics type based on the use of fitting functions for cp, h, s obtained from the templa...
Foam::constant::electromagnetic::kappa
const dimensionedScalar kappa
Coulomb constant: default SI units: [N.m2/C2].
Foam::temperatureCoupledBase::temperatureCoupledBase
temperatureCoupledBase(const fvPatch &patch, const word &calculationMethod, const word &kappaName, const word &alphaAniName)
Construct from patch and K name.
Definition: temperatureCoupledBase.C:58
solidThermo.H
dictName
const word dictName("particleTrackDict")
Foam::solidThermo
Fundamental solid thermodynamic properties.
Definition: solidThermo.H:54
n
label n
Definition: TABSMDCalcMethod2.H:31
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::temperatureCoupledBase::method_
const KMethodType method_
How to get K.
Definition: temperatureCoupledBase.H:130
Foam::Field
Pre-declare SubField and related Field type.
Definition: Field.H:57
Foam::volSymmTensorField
GeometricField< symmTensor, fvPatchField, volMesh > volSymmTensorField
Definition: volFieldsFwd.H:58
Foam::compressible::turbulenceModel
ThermalDiffusivity< CompressibleTurbulenceModel< fluidThermo > > turbulenceModel
Definition: turbulentFluidThermoModel.H:60
Foam::temperatureCoupledBase::KMethodType
KMethodType
Type of supplied Kappa.
Definition: temperatureCoupledBase.H:111
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::volScalarField
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:52
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::turbulenceModel
Abstract base class for turbulence models (RAS, LES and laminar).
Definition: turbulenceModel.H:60
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
temperatureCoupledBase.H
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:18
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
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::temperatureCoupledBase::kappaName_
const word kappaName_
Name of thermal conductivity field (if looked up from database)
Definition: temperatureCoupledBase.H:133
Foam::temperatureCoupledBase::KMethodTypeNames_
static const NamedEnum< KMethodType, 4 > KMethodTypeNames_
Definition: temperatureCoupledBase.H:124
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:318
Foam::ThermalDiffusivity
Templated wrapper class to provide compressible turbulence models thermal diffusivity based thermal t...
Definition: ThermalDiffusivity.H:48
scalarField
volScalarField scalarField(fieldObject, mesh)
Foam::temperatureCoupledBase::kappa
tmp< scalarField > kappa(const scalarField &Tp) const
Given patch temperature calculate corresponding K field.
Definition: temperatureCoupledBase.C:101
Foam::Ostream::writeKeyword
Ostream & writeKeyword(const keyType &)
Write the keyword followed by an appropriate indentation.
Definition: Ostream.C:59
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
Foam::temperatureCoupledBase::write
void write(Ostream &) const
Write.
Definition: temperatureCoupledBase.C:225
Foam::GeometricField
Generic GeometricField class.
Definition: surfaceFieldsFwd.H:52
turbulentFluidThermoModel.H
Foam::NamedEnum
Initialise the NamedEnum HashTable from the static list of names.
Definition: NamedEnum.H:52