allVariablesCoupledBase.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 
35 
36 
37 
38 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
39 
41 (
42  const fvPatch& patch,
43  const word& calculationType,
44  const word& TName
45 )
46 :
47  patch_(patch),
48  TName_(TName),
49 {}
50 
51 
53 (
54  const fvPatch& patch,
55  const dictionary& dict
56 )
57 :
58  patch_(patch),
59  kappaName_(dict.lookup("kappaName")),
60 {}
61 
62 
64 (
65  const fvPatch& patch,
66  const temperatureCoupledBase& base
67 )
68 :
69  patch_(patch),
70  TName_(base.TName_),
71 {}
72 
73 
74 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
75 
77 (
78  const scalarField& Tp
79 ) const
80 {
81  const fvMesh& mesh = patch_.boundaryMesh().mesh();
82  const label patchI = patch_.index();
83 
84  switch (method_)
85  {
86  case mtFluidThermo:
87  {
89 
90  word turbName(turbulenceModel::propertiesName);
91 
92  if
93  (
94  mesh.foundObject<turbulenceModel>(turbName)
95  )
96  {
97  const turbulenceModel& turbModel =
98  mesh.lookupObject<turbulenceModel>(turbName);
99 
100  return turbModel.kappaEff(patchI);
101  }
102  else if (mesh.foundObject<fluidThermo>(basicThermo::dictName))
103  {
104  const fluidThermo& thermo =
105  mesh.lookupObject<fluidThermo>(basicThermo::dictName);
106 
107  return thermo.kappa(patchI);
108  }
109  else
110  {
112  << "Kappa defined to employ " << KMethodTypeNames_[method_]
113  << " method, but thermo package not available"
114  << exit(FatalError);
115  }
116 
117  break;
118  }
119 
120  case mtSolidThermo:
121  {
122  const solidThermo& thermo =
123  mesh.lookupObject<solidThermo>(basicThermo::dictName);
124 
125  return thermo.kappa(patchI);
126  break;
127  }
128 
130  {
131  const solidThermo& thermo =
132  mesh.lookupObject<solidThermo>(basicThermo::dictName);
133 
134  const symmTensorField& alphaAni =
136  (
138  );
139 
140  const scalarField& pp = thermo.p().boundaryField()[patchI];
141 
142  const symmTensorField kappa(alphaAni*thermo.Cp(pp, Tp, patchI));
143 
144  const vectorField n(patch_.nf());
145 
146  return n & kappa & n;
147  }
148 
149  case mtLookup:
150  {
151  if (mesh.foundObject<volScalarField>(kappaName_))
152  {
153  return patch_.lookupPatchField<volScalarField, scalar>
154  (
155  kappaName_
156  );
157  }
158  else if (mesh.foundObject<volSymmTensorField>(kappaName_))
159  {
160  const symmTensorField& KWall =
162  (
163  kappaName_
164  );
165 
166  const vectorField n(patch_.nf());
167 
168  return n & KWall & n;
169  }
170  else
171  {
173  << "Did not find field " << kappaName_
174  << " on mesh " << mesh.name() << " patch " << patch_.name()
175  << nl
176  << "Please set 'kappa' to one of "
178  << " and 'kappaName' to the name of the volScalar"
179  << " or volSymmTensor field (if kappa=lookup)"
180  << exit(FatalError);
181  }
182 
183  break;
184  }
185 
186  default:
187  {
189  << "Unimplemented method " << KMethodTypeNames_[method_] << nl
190  << "Please set 'kappa' to one of " << KMethodTypeNames_.toc()
191  << " and 'kappaName' to the name of the volScalar"
192  << " or volSymmTensor field (if kappa=lookup)"
193  << exit(FatalError);
194  }
195  }
196 
197  return scalarField(0);
198 }
199 
200 
201 void Foam::temperatureCoupledBase::write(Ostream& os) const
202 {
203  os.writeKeyword("kappa") << KMethodTypeNames_[method_]
204  << token::END_STATEMENT << nl;
205  os.writeKeyword("kappaName") << kappaName_ << token::END_STATEMENT << nl;
206 }
207 
208 
209 // ************************************************************************* //
volFields.H
Foam::temperatureCoupledBase::mtDirectionalSolidThermo
@ mtDirectionalSolidThermo
Definition: temperatureCoupledBase.H:115
Foam::scalarField
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Definition: primitiveFieldsFwd.H:48
Foam::token::END_STATEMENT
@ END_STATEMENT
Definition: token.H:99
Foam::temperatureCoupledBase::alphaAniName_
const word alphaAniName_
Name of the non-Isotropic alpha (default: Anialpha)
Definition: temperatureCoupledBase.H:136
Foam::HashTable::toc
List< Key > toc() const
Return the table of contents.
Definition: HashTable.C:201
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:118
fluidThermo.H
Foam::basicThermo::dictName
static const word dictName
Definition: basicThermo.H:176
Foam::turbulenceModel::propertiesName
static const word propertiesName
Default name of the turbulence properties dictionary.
Definition: turbulenceModel.H:97
thermo
Basic thermodynamics type based on the use of fitting functions for cp, h, s obtained from the templa...
Foam::fvBoundaryMesh::mesh
const fvMesh & mesh() const
Return the mesh reference.
Definition: fvBoundaryMesh.H:99
Foam::temperatureCoupledBase::mtSolidThermo
@ mtSolidThermo
Definition: temperatureCoupledBase.H:114
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
Foam::temperatureCoupledBase::mtLookup
@ mtLookup
Definition: temperatureCoupledBase.H:116
solidThermo.H
Foam::symmTensorField
Field< symmTensor > symmTensorField
Specialisation of Field<T> for symmTensor.
Definition: primitiveFieldsFwd.H:51
Foam::vectorField
Field< vector > vectorField
Specialisation of Field<T> for vector.
Definition: primitiveFieldsFwd.H:49
Foam::fvPatch::boundaryMesh
const fvBoundaryMesh & boundaryMesh() const
Return boundaryMesh reference.
Definition: fvPatch.H:185
Foam::fvPatch::name
const word & name() const
Return name.
Definition: fvPatch.H:149
n
label n
Definition: TABSMDCalcMethod2.H:31
Foam::fvPatch::nf
tmp< vectorField > nf() const
Return face normals.
Definition: fvPatch.C:124
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::volSymmTensorField
GeometricField< symmTensor, fvPatchField, volMesh > volSymmTensorField
Definition: volFieldsFwd.H:58
Foam::compressible::turbulenceModel
ThermalDiffusivity< CompressibleTurbulenceModel< fluidThermo > > turbulenceModel
Definition: turbulentFluidThermoModel.H:60
Foam::nl
static const char nl
Definition: Ostream.H:260
Foam::temperatureCoupledBase::patch_
const fvPatch & patch_
Underlying patch.
Definition: temperatureCoupledBase.H:127
Foam::temperatureCoupledBase::mtFluidThermo
@ mtFluidThermo
Definition: temperatureCoupledBase.H:113
Foam::volScalarField
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:52
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::FatalError
error FatalError
Foam::fvPatch::index
label index() const
Return the index of this patch in the fvBoundaryMesh.
Definition: fvPatch.H:179
temperatureCoupledBase.H
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:18
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
T
const volScalarField & T
Definition: createFields.H:25
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::fvPatch::lookupPatchField
const GeometricField::PatchFieldType & lookupPatchField(const word &name, const GeometricField *=NULL, const Type *=NULL) const
Lookup and return the patchField of the named field from the.
Definition: fvPatchFvMeshTemplates.C:32
Foam::temperatureCoupledBase::write
void write(Ostream &) const
Write.
Definition: temperatureCoupledBase.C:225
turbulentFluidThermoModel.H
lookup
stressControl lookup("compactNormalStress") >> compactNormalStress