function2.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 "function2.H"
29 
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
31 
32 namespace Foam
33 {
34 namespace fv
35 {
36 namespace heatTransferCoefficientModels
37 {
40 }
41 }
42 }
43 
44 
45 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
46 
47 void Foam::fv::heatTransferCoefficientModels::function2::readCoeffs
48 (
49  const dictionary& dict
50 )
51 {
52  UName_ = dict.lookupOrDefault<word>("U", "U");
53  UNbrName_ = dict.lookupOrDefault<word>("UNbr", "U");
54 
55  htcFunc_.reset
56  (
58  (
59  "htcFunc",
63  dict
64  ).ptr()
65  );
66 }
67 
68 
69 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
70 
72 (
73  const dictionary& dict,
74  const interRegionModel& model
75 )
76 :
77  heatTransferCoefficientModel(typeName, dict, model),
78  model_(model),
79  UName_(word::null),
80  UNbrName_(word::null),
81  htcFunc_(),
82  htc_
83  (
84  IOobject
85  (
86  typedName("htc"),
87  model.mesh().time().name(),
88  model.mesh(),
89  IOobject::NO_READ,
90  IOobject::NO_WRITE
91  ),
92  model.mesh(),
94  zeroGradientFvPatchScalarField::typeName
95  )
96 {
97  readCoeffs(dict);
98 }
99 
100 
101 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
102 
104 {}
105 
106 
107 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
108 
110 {
111  const scalarField UMag
112  (
113  mag
114  (
115  model_.mesh()
116  .lookupObject<volVectorField>(UName_)
117  .primitiveField()
118  )
119  );
120  const scalarField UMagNbr
121  (
122  model_.interpolate
123  (
124  mag
125  (
126  model_.nbrMesh()
127  .lookupObject<volVectorField>(UNbrName_)
128  .primitiveField()
129  )()
130  )
131  );
132 
133  htc_.primitiveFieldRef() = htcFunc_->value(UMag, UMagNbr);
134  htc_.correctBoundaryConditions();
135 }
136 
137 
139 (
140  const dictionary& dict
141 )
142 {
144  {
145  readCoeffs(dict);
146  return true;
147  }
148  else
149  {
150  return false;
151  }
152 }
153 
154 
155 // ************************************************************************* //
Macros for easy insertion into run-time selection tables.
static autoPtr< Function2< Type > > New(const word &name, const Function2s::unitConversions &units, const dictionary &dict)
Select from dictionary.
Definition: Function2New.C:32
Generic GeometricField class.
const Internal::FieldType & primitiveField() const
Return a const-reference to the primitive field.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:99
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:162
Base class for heat transfer coefficient modelling used in heat transfer fvModels.
virtual bool read(const dictionary &dict)
Read dictionary.
Function2 heat transfer model. The 2D function returns the heat transfer coefficient as a function of...
Definition: function2.H:69
virtual void correct()
Correct the heat transfer coefficient.
Definition: function2.C:109
virtual bool read(const dictionary &dict)
Read dictionary.
Definition: function2.C:139
function2(const dictionary &dict, const interRegionModel &model)
Construct from dictionary and model.
Definition: function2.C:72
Base class for inter-region exchange.
A class for handling words, derived from string.
Definition: word.H:62
addToRunTimeSelectionTable(heatTransferCoefficientModel, constant, mesh)
Namespace for OpenFOAM.
word name(const bool)
Return a word representation of a bool.
Definition: boolIO.C:39
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