variable.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-2021 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 "variable.H"
30 
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
35 namespace fv
36 {
37 namespace heatTransferModels
38 {
39  defineTypeNameAndDebug(variable, 0);
40  addToRunTimeSelectionTable(heatTransferModel, variable, mesh);
41  addToRunTimeSelectionTable(heatTransferModel, variable, model);
42 }
43 }
44 }
45 
46 
47 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
48 
49 void Foam::fv::heatTransferModels::variable::readCoeffs()
50 {
51  UName_ = coeffs().lookupOrDefault<word>("U", "U");
52 
53  a_ = coeffs().lookup<scalar>("a");
54  b_ = coeffs().lookup<scalar>("b");
55  c_ = coeffs().lookup<scalar>("c");
56  L_ = dimensionedScalar("L", dimLength, coeffs());
57  Pr_ = dimensionedScalar("Pr", dimless, coeffs());
58 }
59 
60 
61 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
62 
64 (
65  const dictionary& dict,
66  const fvMesh& mesh
67 )
68 :
69  heatTransferModel(typeName, dict, mesh),
70  UName_(word::null),
71  a_(NaN),
72  b_(NaN),
73  c_(NaN),
74  L_("L", dimLength, NaN),
75  Pr_("Pr", dimless, NaN),
76  htc_
77  (
78  IOobject
79  (
80  type() + ":htc",
81  mesh.time().timeName(),
82  mesh,
85  ),
86  mesh,
88  zeroGradientFvPatchScalarField::typeName
89  )
90 {
91  readCoeffs();
92 }
93 
94 
96 (
97  const dictionary& dict,
98  const interRegionModel& model
99 )
100 :
101  variable(dict, model.mesh())
102 {
103  readCoeffs();
104 }
105 
106 
107 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
108 
110 {}
111 
112 
113 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
114 
116 {
117  const thermophysicalTransportModel& ttm =
118  mesh().lookupObject<thermophysicalTransportModel>
119  (
120  thermophysicalTransportModel::typeName
121  );
123  ttm.momentumTransport();
124 
125  const volVectorField& U =
126  mesh().lookupObject<volVectorField>(UName_);
127 
128  const volScalarField Re(mag(U)*L_/mtm.nuEff());
129  const volScalarField Nu(a_*pow(Re, b_)*pow(Pr_, c_));
130 
131  htc_ = Nu*ttm.kappaEff()/L_;
132  htc_.correctBoundaryConditions();
133 }
134 
135 
137 {
138  if (heatTransferModel::read(dict))
139  {
140  readCoeffs();
141  return true;
142  }
143  else
144  {
145  return false;
146  }
147 }
148 
149 
150 // ************************************************************************* //
const dimensionSet dimArea
const dimensionSet dimPower
U
Definition: pEqn.H:72
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
const compressibleMomentumTransportModel & momentumTransport() const
Base class for heat transfer coefficient modelling used in heat transfer fvModels. Area per unit volume [1/m] (AoV) must be provided as a value in the coefficients dictionary or as a field in constant.
const dimensionSet dimless
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:372
fvMesh & mesh
const fvMesh & mesh() const
Return const access to the mesh database.
Definition: fvModelI.H:34
virtual bool read(const dictionary &dict)
Read dictionary.
Definition: variable.C:136
Macros for easy insertion into run-time selection tables.
const dimensionSet dimLength
Base class for inter-region exchange.
static word timeName(const scalar, const int precision=curPrecision_)
Return time name of given scalar time.
Definition: Time.C:666
labelList fv(nPoints)
static const word null
An empty word.
Definition: word.H:77
defineTypeNameAndDebug(constant, 0)
virtual void correct()
Correct the heat transfer coefficient.
Definition: variable.C:115
virtual ~variable()
Destructor.
Definition: variable.C:109
Abstract base class for thermophysical transport models (RAS, LES and laminar).
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
virtual bool read(const dictionary &dict)
Read dictionary.
virtual tmp< volScalarField > kappaEff() const =0
Effective thermal turbulent diffusivity for temperature.
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
variable(const dictionary &dict, const fvMesh &mesh)
Construct from dictionary and mesh.
Definition: variable.C:64
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:95
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
Definition: POSIX.C:488
addToRunTimeSelectionTable(heatTransferModel, constant, mesh)
Variable heat transfer model depending on local values. The Nusselt number is calculated as: ...
Definition: variable.H:91
dimensioned< scalar > mag(const dimensioned< Type > &)
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:98
scalarField Re(const UList< complex > &cf)
Definition: complexFields.C:97
Base class for single-phase compressible turbulence models.
const dimensionSet dimTemperature
Namespace for OpenFOAM.