multiphaseInterHtcModel.C
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2022 OpenCFD Ltd.
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26\*---------------------------------------------------------------------------*/
27
31#include "dictionary.H"
32
33// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
34
35namespace Foam
36{
37namespace functionObjects
38{
41 (
45 );
46}
47}
48
49
50// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
51
54{
55 const fvMesh& mesh = htcModelPtr_->mesh();
56
57 const auto& T = mesh.lookupObject<volScalarField>(htcModelPtr_->TName());
58
60
61 auto tq = tmp<FieldField<Field, scalar>>::New(Tbf.size());
62 auto& q = tq.ref();
63
64 forAll(q, patchi)
65 {
66 q.set(patchi, new Field<scalar>(Tbf[patchi].size(), Zero));
67 }
68
69 const auto* fluidPtr =
70 mesh.cfindObject<multiphaseInterSystem>("phaseProperties");
71
72 if (!fluidPtr)
73 {
75 << "Unable to find a valid phaseSystem to evaluate q" << nl
76 << exit(FatalError);
77 }
78
80
81 for (const label patchi : htcModelPtr_->patchSet())
82 {
83 q[patchi] += fluid.kappaEff(patchi)()*Tbf[patchi].snGrad();
84 }
85
86 // Add radiative heat flux contribution if present
87
88 const auto* qrPtr =
89 mesh.cfindObject<volScalarField>(htcModelPtr_->qrName());
90
91 if (qrPtr)
92 {
93 const volScalarField::Boundary& qrbf = qrPtr->boundaryField();
94
95 for (const label patchi : htcModelPtr_->patchSet())
96 {
97 q[patchi] += qrbf[patchi];
98 }
99 }
100
101 return tq;
102}
103
104
105// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
106
108{
109 auto& htc =
110 htcModelPtr_->mesh().lookupObjectRef<volScalarField>(resultName_);
111
112 htcModelPtr_->calc(htc, q());
113
114 return true;
115}
116
117
118// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
119
121(
122 const word& name,
123 const Time& runTime,
124 const dictionary& dict
125)
126:
128 htcModelPtr_(nullptr)
129{
130 read(dict);
131
132 setResultName(typeName, "htc:" + htcModelPtr_->type());
133
134 auto* htcPtr =
136 (
138 (
140 mesh_.time().timeName(),
141 mesh_,
144 ),
145 mesh_,
147 );
148
149 mesh_.objectRegistry::store(htcPtr);
150}
151
152
153// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
154
156(
157 const dictionary& dict
158)
159{
161 {
162 return false;
163 }
164
165 htcModelPtr_ = heatTransferCoeffModel::New(dict, mesh_, fieldName_);
166
167 htcModelPtr_->read(dict);
168
169 return true;
170}
171
172
173// ************************************************************************* //
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
twoPhaseSystem & fluid
Generic templated field type.
Definition: Field.H:82
const Boundary & boundaryField() const
Return const-reference to the boundary field.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:170
virtual bool read()
Re-read model coefficients if they have changed.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:80
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
Definition: Time.C:717
static word timeName(const scalar t, const int precision=precision_)
Definition: Time.C:780
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
Abstract base-class for Time/database function objects.
Intermediate class for handling field expression function objects (e.g. blendingFactor etc....
word resultName_
Name of result field.
void setResultName(const word &typeName, const word &defaultArg)
Set the name of result field.
const fvMesh & mesh_
Reference to the fvMesh.
A heat transfer coefficient for multiphase inter solvers (i.e. icoReactingMultiphaseFoam).
virtual bool calc()
Calculate the heat transfer coefficient field.
virtual bool read(const dictionary &dict)
Read the heatTransferCoeff data.
tmp< FieldField< Field, scalar > > q() const
Calculate heat flux.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:91
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:290
const Type * cfindObject(const word &name, const bool recursive=false) const
Return const pointer to the object of the given Type.
const Type & lookupObject(const word &name, const bool recursive=false) const
A class for managing temporary objects.
Definition: tmp.H:65
A class for handling words, derived from Foam::string.
Definition: word.H:68
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition: className.H:121
const volScalarField & T
dynamicFvMesh & mesh
engineTime & runTime
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
Namespace for OpenFOAM.
const dimensionSet dimPower
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:82
const dimensionSet dimArea(sqr(dimLength))
Definition: dimensionSets.H:59
const dimensionSet dimTemperature(0, 0, 0, 1, 0, 0, 0)
Definition: dimensionSets.H:54
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh > > &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
error FatalError
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
constexpr char nl
The newline '\n' character (0x0a)
Definition: Ostream.H:53
dictionary dict
Info<< "Reading field p_rgh\n"<< endl;volScalarField p_rgh(IOobject("p_rgh", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE), mesh);Info<< "Reading field U\n"<< endl;volVectorField U(IOobject("U", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE), mesh);Info<< "Reading field T\n"<< endl;volScalarField T(IOobject("T", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE), mesh);Info<< "Calculating field g.h\n"<< endl;volScalarField p(IOobject("p", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE), p_rgh);Info<< "Creating multiphaseSystem\n"<< endl;autoPtr< multiphaseInter::multiphaseSystem > fluidPtr
Definition: createFields.H:66
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333