function1.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-2024 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 "function1.H"
29 
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
31 
32 namespace Foam
33 {
34 namespace fv
35 {
36 namespace heatTransferCoefficientModels
37 {
41 }
42 }
43 }
44 
45 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
46 
47 void Foam::fv::heatTransferCoefficientModels::function1::readCoeffs
48 (
49  const dictionary& dict
50 )
51 {
52  UName_ = dict.lookupOrDefault<word>("U", "U");
53 
54  htcFunc_.reset
55  (
57  (
58  "htcFunc",
61  dict
62  ).ptr()
63  );
64 }
65 
66 
67 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
68 
70 (
71  const dictionary& dict,
72  const fvMesh& mesh
73 )
74 :
75  heatTransferCoefficientModel(typeName, dict, mesh),
76  UName_(word::null),
77  htcFunc_(nullptr)
78 {
79  readCoeffs(dict);
80 }
81 
82 
84 (
85  const dictionary& dict,
86  const interRegionModel& model
87 )
88 :
89  function1(dict, model.mesh())
90 {}
91 
92 
93 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
94 
96 {}
97 
98 
99 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
100 
103 {
104  const volVectorField& U = mesh_.lookupObject<volVectorField>(UName_);
105 
106  tmp<volScalarField> tHtc =
108  (
109  typedName("htc"),
110  mesh_,
112  zeroGradientFvPatchScalarField::typeName
113  );
114 
115  tHtc->primitiveFieldRef() = htcFunc_->value(mag(U));
116  tHtc->correctBoundaryConditions();
117 
118  return tHtc;
119 }
120 
121 
123 {}
124 
125 
127 (
128  const dictionary& dict
129 )
130 {
132  {
133  readCoeffs(dict);
134  return true;
135  }
136  else
137  {
138  return false;
139  }
140 }
141 
142 
143 // ************************************************************************* //
Macros for easy insertion into run-time selection tables.
static autoPtr< Function1< scalar > > New(const word &name, const Function1s::unitConversions &units, const dictionary &dict)
Select from dictionary.
Definition: Function1New.C:32
Generic GeometricField class.
static tmp< GeometricField< Type, PatchField, GeoMesh > > New(const word &name, const Internal &, const PtrList< PatchField< Type >> &, const HashPtrTable< Source > &=HashPtrTable< Source >())
Return a temporary field constructed from name,.
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:162
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:99
Base class for heat transfer coefficient modelling used in heat transfer fvModels.
virtual bool read(const dictionary &dict)
Read dictionary.
Function1 heat transfer model. The 1D function returns the heat transfer coefficient as a function of...
Definition: function1.H:68
virtual void correct()
Correct the heat transfer coefficient.
Definition: function1.C:122
function1(const dictionary &dict, const fvMesh &mesh)
Construct from dictionary and mesh.
Definition: function1.C:70
virtual bool read(const dictionary &dict)
Read dictionary.
Definition: function1.C:127
virtual tmp< volScalarField > htc() const
Get the heat transfer coefficient.
Definition: function1.C:102
Base class for inter-region exchange.
A class for managing temporary objects.
Definition: tmp.H:55
A class for handling words, derived from string.
Definition: word.H:62
U
Definition: pEqn.H:72
addToRunTimeSelectionTable(heatTransferCoefficientModel, constant, mesh)
Namespace for OpenFOAM.
const dimensionSet dimPower
const dimensionSet dimTemperature
dimensioned< scalar > mag(const dimensioned< Type > &)
word typedName(Name name)
Return the name of the object within the given type.
Definition: typeInfo.H:176
const dimensionSet dimVelocity
const dimensionSet dimArea
labelList fv(nPoints)
dictionary dict