fixedMultiPhaseHeatFluxFvPatchScalarField.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) 2015-2020 OpenFOAM Foundation
9  Copyright (C) 2020-2021 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
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 
30 #include "fvPatchFieldMapper.H"
32 
33 #include "phaseSystem.H"
37 
38 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
39 
42 (
43  const fvPatch& p,
45 )
46 :
47  fixedValueFvPatchScalarField(p, iF),
48  q_(p.size(), Zero),
49  relax_(1),
50  Tmin_(273)
51 {}
52 
53 
56 (
57  const fvPatch& p,
59  const dictionary& dict
60 )
61 :
62  fixedValueFvPatchScalarField(p, iF, dict),
63  q_("q", dict, p.size()),
64  relax_(dict.getOrDefault<scalar>("relax", 1)),
65  Tmin_(dict.getOrDefault<scalar>("Tmin", 273))
66 {}
67 
68 
71 (
73  const fvPatch& p,
75  const fvPatchFieldMapper& mapper
76 )
77 :
78  fixedValueFvPatchScalarField(psf, p, iF, mapper),
79  q_(psf.q_, mapper),
80  relax_(psf.relax_),
81  Tmin_(psf.Tmin_)
82 {}
83 
84 
87 (
89 )
90 :
91  fixedValueFvPatchScalarField(psf),
92  q_(psf.q_),
93  relax_(psf.relax_),
94  Tmin_(psf.Tmin_)
95 {}
96 
97 
100 (
103 )
104 :
105  fixedValueFvPatchScalarField(psf, iF),
106  q_(psf.q_),
107  relax_(psf.relax_),
108  Tmin_(psf.Tmin_)
109 {}
110 
111 
112 
113 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
114 
116 {
117  if (updated())
118  {
119  return;
120  }
121 
122  // Lookup the fluid model
123  const phaseSystem& fluid =
124  db().lookupObject<phaseSystem>("phaseProperties");
125 
126  const scalarField& Tp = *this;
127 
128  scalarField A(Tp.size(), Zero);
129  scalarField B(Tp.size(), Zero);
130  scalarField Q(Tp.size(), Zero);
131 
132  forAll(fluid.phases(), phasei)
133  {
134  const phaseModel& phase = fluid.phases()[phasei];
135  const fluidThermo& thermo = phase.thermo();
136 
137  const fvPatchScalarField& alpha =
138  phase.boundaryField()[patch().index()];
139 
140  const fvPatchScalarField& T =
141  thermo.T().boundaryField()[patch().index()];
142 
143  const scalarField kappaEff(phase.kappaEff(patch().index()));
144 
145  if (debug)
146  {
147  const scalarField q0(T.snGrad()*alpha*kappaEff);
148  Q += q0;
149 
150  Info<< patch().name() << " " << phase.name()
151  << ": Heat flux " << gMin(q0) << " - " << gMax(q0) << endl;
152  }
153 
154  A += T.patchInternalField()*alpha*kappaEff*patch().deltaCoeffs();
155  B += alpha*kappaEff*patch().deltaCoeffs();
156  }
157 
158  if (debug)
159  {
160  Info<< patch().name() << " " << ": overall heat flux "
161  << gMin(Q) << " - " << gMax(Q) << " W/m2, power: "
162  << gSum(patch().magSf()*Q) << " W" << endl;
163  }
164 
165  operator==((scalar(1) - relax_)*Tp + relax_*max(Tmin_,(q_ + A)/(B)));
166 
167  fixedValueFvPatchScalarField::updateCoeffs();
168 }
169 
170 
172 (
173  const fvPatchFieldMapper& m
174 )
175 {
176  fixedValueFvPatchScalarField::autoMap(m);
177  m(q_);
178 }
179 
180 
182 (
183  const fvPatchScalarField& ptf,
184  const labelList& addr
185 )
186 {
187  fixedValueFvPatchScalarField::rmap(ptf, addr);
188 
190  refCast<const fixedMultiPhaseHeatFluxFvPatchScalarField>(ptf);
191 
192  q_.rmap(mptf.q_, addr);
193 }
194 
195 
197 {
199  os.writeEntry("relax", relax_);
200  q_.writeEntry("q", os);
202 }
203 
204 
205 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
206 
207 namespace Foam
208 {
210  (
212  fixedMultiPhaseHeatFluxFvPatchScalarField
213  );
214 }
215 
216 
217 // ************************************************************************* //
twoPhaseSystem & fluid
dictionary dict
label phasei
Definition: pEqn.H:27
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
Type gMin(const FieldField< Field, Type > &f)
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:40
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:531
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:70
Ostream & writeEntry(const keyType &key, const T &value)
Write a keyword/value entry.
Definition: Ostream.H:321
void writeValueEntry(Ostream &os) const
Write *this field as a "value" entry.
Definition: fvPatchField.H:375
virtual void rmap(const fvPatchScalarField &, const labelList &)
Reverse map the given fvPatchField onto this fvPatchField.
virtual void write(Ostream &) const
Write.
Definition: fvPatchField.C:372
kappaEff
Definition: TEqn.H:10
Macros for easy insertion into run-time selection tables.
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:421
psiReactionThermo & thermo
Definition: createFields.H:28
Type gSum(const FieldField< Field, Type > &f)
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
fixedMultiPhaseHeatFluxFvPatchScalarField(const fvPatch &, const DimensionedField< scalar, volMesh > &)
Construct from patch and internal field.
fvPatchField< scalar > fvPatchScalarField
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
A FieldMapper for finite-volume patch fields.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
int debug
Static debugging option.
Type gMax(const FieldField< Field, Type > &f)
OBJstream os(runTime.globalPath()/outputName)
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
Calculates a wall temperature that produces the specified overall wall heat flux across all the phase...
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: areaFieldsFwd.H:42
const std::string patch
OpenFOAM patch number as a std::string.
messageStream Info
Information stream (stdout output on master, null elsewhere)
volScalarField & p
tmp< faMatrix< Type > > operator==(const faMatrix< Type > &, const faMatrix< Type > &)
const dimensionedScalar alpha
Fine-structure constant: default SI units: [].
static const Foam::dimensionedScalar A("", Foam::dimPressure, 611.21)
makePatchTypeField(fvPatchScalarField, atmBoundaryLayerInletEpsilonFvPatchScalarField)
static const Foam::dimensionedScalar B("", Foam::dimless, 18.678)
Namespace for OpenFOAM.
virtual void autoMap(const fvPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:127