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-2023 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(Function2<scalar>::New("htcFunc", dict).ptr());
56 }
57 
58 
59 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
60 
62 (
63  const dictionary& dict,
64  const interRegionModel& model
65 )
66 :
67  heatTransferCoefficientModel(typeName, dict, model),
68  model_(model),
69  UName_(word::null),
70  UNbrName_(word::null),
71  htcFunc_(),
72  htc_
73  (
74  IOobject
75  (
76  typedName("htc"),
77  model.mesh().time().name(),
78  model.mesh(),
79  IOobject::NO_READ,
80  IOobject::NO_WRITE
81  ),
82  model.mesh(),
84  zeroGradientFvPatchScalarField::typeName
85  )
86 {
87  readCoeffs(dict);
88 }
89 
90 
91 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
92 
94 {}
95 
96 
97 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
98 
100 {
101  const scalarField UMag
102  (
103  mag
104  (
105  model_.mesh()
106  .lookupObject<volVectorField>(UName_)
107  .primitiveField()
108  )
109  );
110  const scalarField UMagNbr
111  (
112  model_.interpolate
113  (
114  mag
115  (
116  model_.nbrMesh()
117  .lookupObject<volVectorField>(UNbrName_)
118  .primitiveField()
119  )()
120  )
121  );
122 
123  htc_.primitiveFieldRef() = htcFunc_->value(UMag, UMagNbr);
124  htc_.correctBoundaryConditions();
125 }
126 
127 
129 (
130  const dictionary& dict
131 )
132 {
134  {
135  readCoeffs(dict);
136  return true;
137  }
138  else
139  {
140  return false;
141  }
142 }
143 
144 
145 // ************************************************************************* //
Macros for easy insertion into run-time selection tables.
static autoPtr< Function2< Type > > New(const word &name, const dictionary &dict)
Selector.
Definition: Function2New.C:32
Generic GeometricField class.
const Internal::FieldType & primitiveField() const
Return a const-reference to the internal 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:160
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:99
virtual bool read(const dictionary &dict)
Read dictionary.
Definition: function2.C:129
function2(const dictionary &dict, const interRegionModel &model)
Construct from dictionary and model.
Definition: function2.C:62
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.
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:149
const dimensionSet dimArea
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
labelList fv(nPoints)
dictionary dict