externalHeatFluxSource.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) 2019-2021 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
29#include "fam.H"
30#include "faScalarMatrix.H"
34
36
37// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
38
39namespace Foam
40{
41namespace fa
42{
45}
46}
47
48
49const Foam::Enum
50<
52>
54({
55 { operationMode::fixedPower, "power" },
56 { operationMode::fixedHeatFlux, "flux" },
57 { operationMode::fixedHeatTransferCoeff, "coefficient" },
58});
59
60
61// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
62
64(
65 const word& sourceName,
66 const word& modelType,
67 const dictionary& dict,
68 const fvPatch& patch
69)
70:
71 fa::faceSetOption(sourceName, modelType, dict, patch),
72 mode_(operationModeNames.get("mode", dict)),
73 TName_(dict.getOrDefault<word>("T", "T")),
74 Q_(0),
75 q_(0),
76 h_(0),
77 Ta_(nullptr),
78 emissivity_(dict.getOrDefault<scalar>("emissivity", 0))
79{
80 fieldNames_.resize(1, TName_);
81
83
84 read(dict);
85}
86
87
88// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
89
91(
92 const areaScalarField& h,
93 const areaScalarField& rho,
95 const label fieldi
96)
97{
98 if (isActive())
99 {
100 DebugInfo<< name() << ": applying source to "
101 << eqn.psi().name() << endl;
102
104 (
105 "Q",
106 mesh_.time().timeName(),
107 mesh_,
110 false
111 );
112
113 auto tQ = new areaScalarField
114 (
115 io,
116 regionMesh(),
118 zeroGradientFaPatchScalarField::typeName
119 );
120 areaScalarField& Q = *tQ;
121
122 switch (mode_)
123 {
124 case fixedPower:
125 {
126 Q.primitiveFieldRef() = Q_/regionMesh().S().field();
127 eqn += Q;
128
129 break;
130 }
131 case fixedHeatFlux:
132 {
133 Q.primitiveFieldRef() = q_;
134 eqn += Q;
135 break;
136 }
137 case fixedHeatTransferCoeff:
138 {
139 const dimensionedScalar Ta
140 (
141 "Ta",
143 Ta_->value(mesh_.time().timeOutputValue())
144 );
145
147 (
148 io,
149 regionMesh(),
151 (
152 "h",
154 h_
155 )
156 );
157
158 const areaScalarField hpTa(hp*Ta);
159
160 if (emissivity_ > 0)
161 {
162 hp -= emissivity_*sigma.value()*pow3(eqn.psi());
163 }
164
165 eqn -= fam::SuSp(hp, eqn.psi()) - hpTa;
166
167 }
168 }
169 }
170}
171
172
174{
176 {
177 dict.readIfPresent("T", TName_);
178 dict.readIfPresent("emissivity", emissivity_);
179
180 mode_ = operationModeNames.get("mode", dict);
181
182 switch (mode_)
183 {
184 case fixedPower:
185 {
186 dict.readEntry("Q", Q_);
187 break;
188 }
189 case fixedHeatFlux:
190 {
191 dict.readEntry("q", q_);
192 break;
193 }
194 case fixedHeatTransferCoeff:
195 {
196 dict.readEntry("h", h_);
197 Ta_ = Function1<scalar>::New("Ta", dict, &mesh_);
198 break;
199 }
200 }
201
202 return true;
203 }
204
205 return false;
206}
207
208
209// ************************************************************************* //
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
Definition: Enum.H:61
Internal::FieldType & primitiveFieldRef(const bool updateAccessTime=true)
Return a reference to the internal field.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:170
void resize(const label len)
Adjust allocated size of list.
Definition: ListI.H:139
virtual bool read()
Re-read model coefficients if they have changed.
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
Definition: Time.C:717
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
const Type & value() const
Return const reference to value.
A special matrix type and solver, designed for finite area solutions of scalar equations....
Definition: faMatrix.H:76
const GeometricField< Type, faPatchField, areaMesh > & psi() const
Definition: faMatrix.H:270
Applies a heat flux condition for a specified faMesh region to temperature on an external wall for co...
static const Enum< operationMode > operationModeNames
Names for operationMode.
virtual void addSup(const areaScalarField &h, const areaScalarField &rho, faMatrix< scalar > &eqn, const label fieldi)
Add explicit contribution to compressible momentum equation.
virtual bool read(const dictionary &dict)
Read source dictionary.
operationMode
Options for the heat transfer condition mode.
Intermediate abstract class for handling face-set options for the derived faOptions.
Base abstract class for handling finite area options (i.e. faOption).
Definition: faOption.H:134
wordList fieldNames_
Field names to apply source to - populated by derived models.
Definition: faOption.H:164
void resetApplied()
Resize/reset applied flag list for all fieldNames_ entries.
Definition: faOption.C:45
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:71
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
Namespace of functions to calculate implicit derivatives returning a matrix. Time derivatives are cal...
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, false)
#define DebugInfo
Report an information message using Foam::Info.
const dimensionedScalar sigma
Stefan-Boltzmann constant: default SI units: [W/m2/K4].
zeroField SuSp(const Foam::zero, const GeometricField< Type, faPatchField, areaMesh > &)
A no-op source.
Namespace for OpenFOAM.
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
const dimensionSet dimPower
dimensionedSymmTensor sqr(const dimensionedVector &dv)
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:52
dimensionedScalar pow3(const dimensionedScalar &ds)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:372
const dimensionSet dimTemperature(0, 0, 0, 1, 0, 0, 0)
Definition: dimensionSets.H:54
GeometricField< scalar, faPatchField, areaMesh > areaScalarField
Definition: areaFieldsFwd.H:78
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
dictionary dict
volScalarField & h