interRegionHeatTransfer.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-2025 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 
27 #include "basicThermo.H"
28 #include "fvmSup.H"
30 #include "fvcVolumeIntegrate.H"
32 
33 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
34 
35 namespace Foam
36 {
37 namespace fv
38 {
41  (
42  fvModel,
45  );
46 }
47 }
48 
49 
50 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
51 
52 void Foam::fv::interRegionHeatTransfer::readCoeffs(const dictionary& dict)
53 {
54  semiImplicit_ = dict.lookup<bool>("semiImplicit");
55 
56  TName_ = dict.lookupOrDefault<word>("T", "T");
57  TNbrName_ = dict.lookupOrDefault<word>("TNbr", "T");
58 
59  if (master())
60  {
61  heatTransferAv_.reset(new heatTransferAv(dict, mesh()));
62 
63  heatTransferCoefficientModel_ =
65  }
66 }
67 
68 
70 Foam::fv::interRegionHeatTransfer::nbrHeatTransfer() const
71 {
72  return refCast<const interRegionHeatTransfer>(nbrModel());
73 }
74 
75 
76 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
77 
79 (
80  const word& name,
81  const word& modelType,
82  const fvMesh& mesh,
83  const dictionary& dict
84 )
85 :
86  interRegionModel(name, modelType, mesh, dict),
87  semiImplicit_(false),
88  TName_(word::null),
89  TNbrName_(word::null),
90  heatTransferAv_(nullptr),
91  heatTransferCoefficientModel_(nullptr)
92 {
93  readCoeffs(coeffs(dict));
94 }
95 
96 
97 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
98 
100 {}
101 
102 
103 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
104 
106 {
107  const basicThermo& thermo =
109 
110  return wordList(1, thermo.he().name());
111 }
112 
113 
115 (
116  const volScalarField& he,
117  fvMatrix<scalar>& eqn
118 ) const
119 {
120  const volScalarField& T =
121  mesh().lookupObject<volScalarField>(TName_);
122 
123  tmp<volScalarField> tTnbr = volScalarField::New(TNbrName_, T);
125  (
126  nbrMesh().lookupObject<volScalarField>(TNbrName_),
127  tTnbr->primitiveFieldRef()
128  );
129  const volScalarField& Tnbr = tTnbr();
130 
131  // Get the heat transfer coefficient field
132  tmp<volScalarField> tHtcAv;
133  if (master())
134  {
135  tmp<volScalarField> mask =
137  (
138  "mask",
139  mesh(),
141  );
142  tmp<volScalarField> oneNbr =
144  (
145  "one",
146  nbrMesh(),
148  );
149  interpolate(oneNbr(), mask.ref().primitiveFieldRef());
150  tHtcAv =
151  mask
152  *heatTransferCoefficientModel_->htc()
153  *heatTransferAv_->Av();
154  }
155  else
156  {
157  tmp<volScalarField> tHtcNbr =
158  nbrHeatTransfer().heatTransferCoefficientModel_->htc()
159  *nbrHeatTransfer().heatTransferAv_->Av();
160  tHtcAv =
162  (
163  tHtcNbr().name(),
164  mesh(),
165  dimensionedScalar(tHtcNbr().dimensions(), 0)
166  );
167  interpolate(tHtcNbr(), tHtcAv.ref().primitiveFieldRef());
168  }
169  const volScalarField& htcAv = tHtcAv();
170 
171  if (semiImplicit_)
172  {
173  if (he.dimensions() == dimEnergy/dimMass)
174  {
175  const basicThermo& thermo =
177 
178  const volScalarField htcAvByCpv(htcAv/thermo.Cpv());
179 
180  eqn +=
181  htcAv*(Tnbr - T)
182  + htcAvByCpv*he - fvm::Sp(htcAvByCpv, he);
183  }
184  else if (he.dimensions() == dimTemperature)
185  {
186  eqn += htcAv*Tnbr - fvm::Sp(htcAv, he);
187  }
188  }
189  else
190  {
191  eqn += htcAv*(Tnbr - T);
192  }
193 }
194 
195 
197 (
198  const volScalarField& rho,
199  const volScalarField& he,
200  fvMatrix<scalar>& eqn
201 ) const
202 {
203  addSup(he, eqn);
204 }
205 
206 
208 {
209  if (master())
210  {
211  heatTransferCoefficientModel_->correct();
212  }
213 }
214 
215 
217 {
219  return true;
220 }
221 
222 
224 {
226 }
227 
228 
230 {
232 }
233 
234 
236 (
237  const polyDistributionMap&
238 )
239 {
241 }
242 
243 
245 {
247  {
248  readCoeffs(coeffs(dict));
249  return true;
250  }
251  else
252  {
253  return false;
254  }
255 }
256 
257 
258 // ************************************************************************* //
Macros for easy insertion into run-time selection tables.
const dimensionSet & dimensions() const
Return dimensions.
Generic GeometricField class.
static tmp< GeometricField< Type, GeoMesh, PrimitiveField > > New(const word &name, const Internal &, const PtrList< Patch > &, const HashPtrTable< Source > &=HashPtrTable< Source >())
Return a temporary field constructed from name,.
Base-class for fluid and solid thermodynamic properties.
Definition: basicThermo.H:78
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
A special matrix type and solver, designed for finite volume solutions of scalar equations....
Definition: fvMatrix.H:118
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:98
Finite volume model abstract base class.
Definition: fvModel.H:60
static const dictionary & coeffs(const word &modelType, const dictionary &)
Return the coefficients sub-dictionary for a given model type.
Definition: fvModelI.H:31
const fvMesh & mesh() const
Return const access to the mesh database.
Definition: fvModelI.H:69
static autoPtr< heatTransferCoefficientModel > New(const dictionary &dict, const fvMesh &mesh)
Select from dictionary and mesh.
Model for inter-region heat exchange. Requires specification of a model for the heat transfer coeffic...
virtual bool movePoints()
Update for mesh motion.
virtual wordList addSupFields() const
Return the list of fields for which the fvModel adds source term.
interRegionHeatTransfer(const word &name, const word &modelType, const fvMesh &mesh, const dictionary &dict)
Construct from dictionary.
virtual void correct()
Correct the model.
virtual void addSup(const volScalarField &he, fvMatrix< scalar > &eqn) const
Source term to energy equation.
virtual void topoChange(const polyTopoChangeMap &)
Update topology using the given map.
virtual void distribute(const polyDistributionMap &)
Redistribute or update using the given distribution map.
virtual bool read(const dictionary &dict)
Read dictionary.
virtual void mapMesh(const polyMeshMap &)
Update from another mesh using the given map.
Base class for inter-region exchange.
bool master() const
Return whether the master region.
virtual bool read(const dictionary &dict)
Read dictionary.
const Type & lookupObject(const word &name) const
Lookup and return the object of the given Type and name.
Class containing mesh-to-mesh mapping information after a mesh distribution where we send parts of me...
Class containing mesh-to-mesh mapping information.
Definition: polyMeshMap.H:51
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
A class for managing temporary objects.
Definition: tmp.H:55
T & ref() const
Return non-const reference or generate a fatal error.
Definition: tmpI.H:197
A class for handling words, derived from string.
Definition: word.H:63
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:381
Volume integrate volField creating a volField.
Calculate the matrix for implicit and explicit sources.
rho
Definition: pEqn.H:1
addToRunTimeSelectionTable(fvConstraint, bound, dictionary)
defineTypeNameAndDebug(bound, 0)
static tmp< SurfaceField< Type > > interpolate(const VolField< Type > &tvf, const surfaceScalarField &faceFlux, Istream &schemeData)
Interpolate field onto faces using scheme given by Istream.
tmp< fvMatrix< Type > > Sp(const volScalarField::Internal &, const VolField< Type > &)
Namespace for OpenFOAM.
List< word > wordList
A List of words.
Definition: fileName.H:54
const dimensionSet & dimless
Definition: dimensions.C:138
const dimensionSet & dimMass
Definition: dimensions.C:140
String typeName(const std::type_info &info)
Return the un-mangled name given the standard type info.
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
const dimensionSet & dimEnergy
Definition: dimensions.C:160
void T(GeometricField< Type, GeoMesh, PrimitiveField1 > &gf, const GeometricField< Type, GeoMesh, PrimitiveField2 > &gf1)
const dimensionSet & dimTemperature
Definition: dimensions.C:143
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
labelList fv(nPoints)
dictionary dict
fluidMulticomponentThermo & thermo
Definition: createFields.H:15