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-2020 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
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 
28 #include "externalHeatFluxSource.H"
33 
35 
36 // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
37 
38 namespace Foam
39 {
40 namespace fa
41 {
42  defineTypeNameAndDebug(externalHeatFluxSource, 0);
43  addToRunTimeSelectionTable(option, externalHeatFluxSource, dictionary);
44 }
45 }
46 
47 
48 const Foam::Enum
49 <
51 >
53 ({
54  { operationMode::fixedPower, "power" },
55  { operationMode::fixedHeatFlux, "flux" },
56  { operationMode::fixedHeatTransferCoeff, "coefficient" },
57 });
58 
59 
60 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
61 
63 (
64  const word& sourceName,
65  const word& modelType,
66  const dictionary& dict,
67  const fvPatch& patch
68 )
69 :
70  faceSetOption(sourceName, modelType, dict, patch),
71  mode_(operationModeNames.get("mode", dict)),
72  TName_(dict.getOrDefault<word>("T", "T")),
73  Q_(0),
74  q_(0),
75  h_(0),
76  Ta_(),
77  emissivity_(dict.getOrDefault<scalar>("emissivity", 0))
78 {
79  fieldNames_.setSize(1, TName_);
80 
81  applied_.setSize(fieldNames_.size(), false);
82 
83  read(dict);
84 }
85 
86 
87 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
88 
90 (
91  const areaScalarField& h,
92  const areaScalarField& rho,
93  faMatrix<scalar>& eqn,
94  const label fieldi
95 )
96 {
97  if (isActive())
98  {
99  DebugInfo<< name() << ": applying source to "
100  << eqn.psi().name() << endl;
101 
102  IOobject io
103  (
104  "Q",
105  mesh_.time().timeName(),
106  mesh_,
107  IOobject::NO_READ,
108  IOobject::NO_WRITE,
109  false
110  );
111 
112  auto tQ = new areaScalarField
113  (
114  io,
115  regionMesh(),
117  zeroGradientFaPatchScalarField::typeName
118  );
119  areaScalarField& Q = *tQ;
120 
121  switch (mode_)
122  {
123  case fixedPower:
124  {
125  Q.primitiveFieldRef() = Q_/regionMesh().S().field();
126  eqn += Q;
127 
128  break;
129  }
130  case fixedHeatFlux:
131  {
132  Q.primitiveFieldRef() = q_;
133  eqn += Q;
134  break;
135  }
136  case fixedHeatTransferCoeff:
137  {
138  const dimensionedScalar Ta
139  (
140  "Ta",
142  Ta_->value(mesh_.time().timeOutputValue())
143  );
144 
145  areaScalarField hp
146  (
147  io,
148  regionMesh(),
150  (
151  "h",
153  h_
154  )
155  );
156 
157  const areaScalarField hpTa(hp*Ta);
158 
159  if (emissivity_ > 0)
160  {
161  hp -= emissivity_*sigma.value()*pow3(eqn.psi());
162  }
163 
164  eqn -= fam::SuSp(hp, eqn.psi()) - hpTa;
165 
166  }
167  }
168  }
169 }
170 
171 
173 {
174  if (option::read(dict))
175  {
176  dict.readIfPresent("T", TName_);
177  dict.readIfPresent("emissivity", emissivity_);
178 
179  mode_ = operationModeNames.get("mode", dict);
180 
181  switch (mode_)
182  {
183  case fixedPower:
184  {
185  dict.readEntry("Q", Q_);
186  break;
187  }
188  case fixedHeatFlux:
189  {
190  dict.readEntry("q", q_);
191  break;
192  }
194  {
195  dict.readEntry("h", h_);
196  Ta_ = Function1<scalar>::New("Ta", dict);
197  break;
198  }
199  }
200 
201  return true;
202  }
203 
204  return false;
205 }
206 
207 
208 // ************************************************************************* //
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:104
Foam::Enum
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
Definition: IOstreamOption.H:57
Foam::faMatrix
A special matrix type and solver, designed for finite area solutions of scalar equations....
Definition: faMatrix.H:59
Foam::fa::externalHeatFluxSource::operationMode
operationMode
Options for the heat transfer condition mode.
Definition: externalHeatFluxSource.H:217
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::fa::externalHeatFluxSource::fixedHeatTransferCoeff
Fixed heat transfer coefficient.
Definition: externalHeatFluxSource.H:221
Foam::dimLength
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:53
Foam::fa::externalHeatFluxSource::fixedHeatFlux
Fixed heat flux [W/m2].
Definition: externalHeatFluxSource.H:220
Foam::fa::faceSetOption
Intermediate abstract class for handling face-set options for the derived faOptions.
Definition: faceSetOption.H:134
Foam::fa::addToRunTimeSelectionTable
addToRunTimeSelectionTable(option, contactHeatFluxSource, dictionary)
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:350
Foam::dimensioned::value
const Type & value() const
Return const reference to value.
Definition: dimensionedType.C:434
Foam::Enum::get
EnumType get(const word &enumName) const
The enumeration corresponding to the given name.
Definition: Enum.C:75
rho
rho
Definition: readInitialConditions.H:88
Foam::fa::externalHeatFluxSource::addSup
virtual void addSup(const areaScalarField &h, const areaScalarField &rho, faMatrix< scalar > &eqn, const label fieldi)
Add explicit contribution to compressible momentum equation.
Definition: externalHeatFluxSource.C:90
Foam::Function1
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
Definition: Function1.H:86
Foam::fam::SuSp
tmp< faMatrix< Type > > SuSp(const areaScalarField &sp, const GeometricField< Type, faPatchField, areaMesh > &vf)
Definition: famSup.C:151
Foam::pow3
dimensionedScalar pow3(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:89
Foam::constant::universal::h
const dimensionedScalar h
Planck constant.
Definition: setRegionSolidFields.H:33
Foam::name
word name(const complex &c)
Return string representation of complex.
Definition: complex.C:76
Foam::fa::externalHeatFluxSource::operationModeNames
static const Enum< operationMode > operationModeNames
Names for operationMode.
Definition: externalHeatFluxSource.H:225
Foam::fvPatch
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:65
Foam::dictionary::readEntry
bool readEntry(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX, bool mandatory=true) const
Definition: dictionaryTemplates.C:314
Foam::dimensionedScalar
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
Definition: dimensionedScalarFwd.H:43
Foam::blockMeshTools::read
void read(Istream &, label &, const dictionary &)
In-place read with dictionary lookup.
Definition: blockMeshTools.C:33
Foam::dimPower
const dimensionSet dimPower
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam::dimensioned< scalar >
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::areaScalarField
GeometricField< scalar, faPatchField, areaMesh > areaScalarField
Definition: areaFieldsFwd.H:53
Foam::fa::option::read
virtual bool read(const dictionary &dict)
Read source dictionary.
Definition: faOptionIO.C:54
Foam::GeometricField::primitiveFieldRef
Internal::FieldType & primitiveFieldRef(const bool updateAccessTime=true)
Return a reference to the internal field.
Definition: GeometricField.C:766
zeroGradientFaPatchFields.H
Foam::fa::externalHeatFluxSource::read
virtual bool read(const dictionary &dict)
Read source dictionary.
Definition: externalHeatFluxSource.C:172
Foam::sqr
dimensionedSymmTensor sqr(const dimensionedVector &dv)
Definition: dimensionedSymmTensor.C:51
DebugInfo
#define DebugInfo
Report an information message using Foam::Info.
Definition: messageStream.H:359
Foam::foamVersion::patch
const std::string patch
OpenFOAM patch number as a std::string.
physicoChemicalConstants.H
Foam::faMatrix::psi
const GeometricField< Type, faPatchField, areaMesh > & psi() const
Definition: faMatrix.H:239
Foam::fa::defineTypeNameAndDebug
defineTypeNameAndDebug(faceSetOption, 0)
Foam::fa::externalHeatFluxSource::fixedPower
Fixed heat power [W].
Definition: externalHeatFluxSource.H:219
Foam::constant::physicoChemical::sigma
const dimensionedScalar sigma
Stefan-Boltzmann constant: default SI units: [W/m2/K4].
Foam::dimTemperature
const dimensionSet dimTemperature(0, 0, 0, 1, 0, 0, 0)
Definition: dimensionSets.H:55
sigma
dimensionedScalar sigma("sigma", dimMass/sqr(dimTime), transportProperties)
Foam::dictionary::getOrDefault
T getOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
Definition: dictionaryTemplates.C:122
Foam::GeometricField< scalar, faPatchField, areaMesh >
externalHeatFluxSource.H
Foam::fa::externalHeatFluxSource::externalHeatFluxSource
externalHeatFluxSource(const word &sourceName, const word &modelType, const dictionary &dict, const fvPatch &patch)
Construct from explicit source name and mesh.
Definition: externalHeatFluxSource.C:63
Foam::dictionary::readIfPresent
bool readIfPresent(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX) const
Definition: dictionaryTemplates.C:417