Loading...
Searching...
No Matches
atmTurbulentHeatFluxTemperatureFvPatchScalarField.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) 2020 ENERCON GmbH
9 Copyright (C) 2020-2022 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27\*---------------------------------------------------------------------------*/
28
31#include "fvPatchFieldMapper.H"
32#include "volFields.H"
33#include "turbulenceModel.H"
34
35// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
36
37const Foam::Enum
38<
39 Foam::atmTurbulentHeatFluxTemperatureFvPatchScalarField::heatSourceType
40>
41Foam::atmTurbulentHeatFluxTemperatureFvPatchScalarField::heatSourceTypeNames
42({
43 { heatSourceType::POWER , "power" },
44 { heatSourceType::FLUX , "flux" }
45});
46
47
48// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49
50namespace Foam
51{
52
53// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
54
57(
58 const fvPatch& p,
60)
61:
62 fixedGradientFvPatchScalarField(p, iF),
63 heatSource_(heatSourceType::POWER),
64 alphaEffName_("undefinedAlphaEff"),
65 Cp0_(nullptr),
66 q_(nullptr)
67{}
68
69
72(
74 const fvPatch& p,
76 const fvPatchFieldMapper& mapper
77)
78:
79 fixedGradientFvPatchScalarField(ptf, p, iF, mapper),
80 heatSource_(ptf.heatSource_),
81 alphaEffName_(ptf.alphaEffName_),
82 Cp0_(ptf.Cp0_.clone()),
83 q_(ptf.q_.clone(p.patch()))
84{}
85
86
89(
90 const fvPatch& p,
92 const dictionary& dict
93)
94:
95 fixedGradientFvPatchScalarField(p, iF), // Bypass dictionary constructor
96 heatSource_
97 (
98 heatSourceTypeNames.getOrDefault
99 (
100 "heatSource",
101 dict,
102 heatSourceType::POWER
103 )
104 ),
105 alphaEffName_(dict.get<word>("alphaEff")),
106 Cp0_(Function1<scalar>::New("Cp0", dict, &db())),
107 q_(PatchFunction1<scalar>::New(p.patch(), "q", dict))
108{
109 if (!this->readGradientEntry(dict) || !this->readValueEntry(dict))
111 extrapolateInternal();
112 gradient() = Zero;
113 }
114}
115
116
119(
120 const atmTurbulentHeatFluxTemperatureFvPatchScalarField& atmpsf
121)
122:
123 fixedGradientFvPatchScalarField(atmpsf),
124 heatSource_(atmpsf.heatSource_),
125 alphaEffName_(atmpsf.alphaEffName_),
126 Cp0_(atmpsf.Cp0_.clone()),
127 q_(atmpsf.q_.clone(this->patch().patch()))
128{}
129
130
133(
136)
137:
138 fixedGradientFvPatchScalarField(atmpsf, iF),
139 heatSource_(atmpsf.heatSource_),
140 alphaEffName_(atmpsf.alphaEffName_),
141 Cp0_(atmpsf.Cp0_.clone()),
142 q_(atmpsf.q_.clone(this->patch().patch()))
143{}
144
145
146// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
147
149(
150 const fvPatchFieldMapper& m
152{
154 q_->autoMap(m);
155}
156
157
159(
160 const fvPatchScalarField& ptf,
161 const labelList& addr
162)
163{
164 fixedGradientFvPatchScalarField::rmap(ptf, addr);
165
168
169 q_->rmap(atmptf.q_(), addr);
170}
171
172
174{
175 if (updated())
176 {
177 return;
178 }
179
180 const scalarField& alphaEffp =
181 patch().lookupPatchField<volScalarField>(alphaEffName_);
182
183 const scalar t = db().time().timeOutputValue();
184 const scalar Cp0 = Cp0_->value(t);
185
186 if (Cp0 < SMALL)
187 {
189 << "Cp0 = " << Cp0 << " must be positive."
190 << exit(FatalError);
191 }
192
193 const scalarField q(q_->value(t));
194
195 switch (heatSource_)
196 {
197 case heatSourceType::POWER:
198 {
199 const scalar Ap = gSum(patch().magSf());
200 gradient() = q/(Ap*Cp0*alphaEffp + SMALL);
201 break;
202 }
203
204 case heatSourceType::FLUX:
205 {
206 gradient() = q/(Cp0*alphaEffp + SMALL);
207 break;
208 }
209
210 default:
211 {
213 << "Unknown heat source type. Valid types are: "
214 << heatSourceTypeNames << nl
215 << exit(FatalError);
217 }
218
219 fixedGradientFvPatchScalarField::updateCoeffs();
220}
221
222
224{
226 os.writeEntry("heatSource", heatSourceTypeNames[heatSource_]);
227 os.writeEntry("alphaEff", alphaEffName_);
228 Cp0_->writeData(os);
229 q_->writeData(os);
231}
232
233
234// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
235
237(
239 atmTurbulentHeatFluxTemperatureFvPatchScalarField
240);
241
242
243// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
244
245} // End namespace Foam
246
247// ************************************************************************* //
Macros for easy insertion into run-time selection tables.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
Definition Enum.H:57
void autoMap(const FieldMapper &map, const bool applyFlip=true)
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
Definition Function1.H:92
const Time & time() const noexcept
Return Time associated with the objectRegistry.
Definition IOobject.C:456
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
scalar timeOutputValue() const
Return the current user-time value. (ie, after applying any timeToUserTime() conversion).
Definition TimeStateI.H:24
This boundary condition provides a fixed heat constraint on temperature (i.e. T) to specify temperatu...
virtual void autoMap(const fvPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
atmTurbulentHeatFluxTemperatureFvPatchScalarField(const fvPatch &, const DimensionedField< scalar, volMesh > &)
Construct from patch and internal field.
virtual void rmap(const fvPatchScalarField &, const labelList &)
Reverse map the given fvPatchField onto this fvPatchField.
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
virtual void write(Ostream &) const
Write.
A FieldMapper for finite-volume patch fields.
void writeValueEntry(Ostream &os) const
Write *this field as a "value" entry.
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:66
volScalarField & p
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition error.H:600
OBJstream os(runTime.globalPath()/outputName)
#define makePatchTypeField(PatchTypeField, typePatchTypeField)
Define a concrete fvPatchField type and add to run-time tables Example, (fvPatchScalarField,...
const std::string patch
OpenFOAM patch number as a std::string.
Namespace for OpenFOAM.
Type & refCast(U &obj)
A dynamic_cast (for references) to Type reference.
Definition typeInfo.H:172
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh > > &tf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
Type gSum(const FieldField< Field, Type > &f)
List< label > labelList
A List of labels.
Definition List.H:62
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
static constexpr const zero Zero
Global zero (0).
Definition zero.H:127
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition errorManip.H:125
fvPatchField< scalar > fvPatchScalarField
constexpr char nl
The newline '\n' character (0x0a).
Definition Ostream.H:50
dictionary dict