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 -------------------------------------------------------------------------------
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"
29 #include "fam.H"
30 #include "faScalarMatrix.H"
34 
36 
37 // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
38 
39 namespace Foam
40 {
41 namespace fa
42 {
43  defineTypeNameAndDebug(externalHeatFluxSource, 0);
44  addToRunTimeSelectionTable(option, externalHeatFluxSource, dictionary);
45 }
46 }
47 
48 
49 const 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 
82  fa::option::resetApplied();
83 
84  read(dict);
85 }
86 
87 
88 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
89 
91 (
92  const areaScalarField& h,
93  const areaScalarField& rho,
94  faMatrix<scalar>& eqn,
95  const label fieldi
96 )
97 {
98  if (isActive())
99  {
100  DebugInfo<< name() << ": applying source to "
101  << eqn.psi().name() << endl;
102 
103  IOobject io
104  (
105  "Q",
106  mesh_.time().timeName(),
107  mesh_,
108  IOobject::NO_READ,
109  IOobject::NO_WRITE,
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 
146  areaScalarField hp
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 {
175  if (fa::option::read(dict))
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  }
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 // ************************************************************************* //
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:169
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: faMatricesFwd.H:43
Foam::fa::externalHeatFluxSource::operationMode
operationMode
Options for the heat transfer condition mode.
Definition: externalHeatFluxSource.H:216
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::fa::externalHeatFluxSource::fixedHeatTransferCoeff
Fixed heat transfer coefficient.
Definition: externalHeatFluxSource.H:220
Foam::dimLength
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:52
Foam::fa::externalHeatFluxSource::fixedHeatFlux
Fixed heat flux [W/m2].
Definition: externalHeatFluxSource.H:219
fam.H
Namespace of functions to calculate implicit derivatives returning a matrix. Time derivatives are cal...
Foam::fa::faceSetOption
Intermediate abstract class for handling face-set options for the derived faOptions.
Definition: faceSetOption.H:134
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:369
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:91
Foam::Function1
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
Definition: propellerInfo.H:291
Foam::fa::defineTypeNameAndDebug
defineTypeNameAndDebug(limitVelocity, 0)
Foam::fam::SuSp
tmp< faMatrix< Type > > SuSp(const areaScalarField &sp, const GeometricField< Type, faPatchField, areaMesh > &vf)
Definition: famSup.C:151
Foam::fa::option::mesh_
const fvMesh & mesh_
Reference to the mesh database.
Definition: faOption.H:152
Foam::blockMeshTools::read
void read(Istream &, label &val, const dictionary &)
In-place read with dictionary lookup.
Definition: blockMeshTools.C:57
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::fa::externalHeatFluxSource::operationModeNames
static const Enum< operationMode > operationModeNames
Names for operationMode.
Definition: externalHeatFluxSource.H:224
Foam::fvPatch
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:65
Foam::dimensionedScalar
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
Definition: dimensionedScalarFwd.H:42
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:123
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:173
Foam::sqr
dimensionedSymmTensor sqr(const dimensionedVector &dv)
Definition: dimensionedSymmTensor.C:51
DebugInfo
#define DebugInfo
Report an information message using Foam::Info.
Definition: messageStream.H:382
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:255
Foam::fa::externalHeatFluxSource::fixedPower
Fixed heat power [W].
Definition: externalHeatFluxSource.H:218
faScalarMatrix.H
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:54
Foam::name
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
Foam::fa::addToRunTimeSelectionTable
addToRunTimeSelectionTable(option, limitVelocity, dictionary)
sigma
dimensionedScalar sigma("sigma", dimMass/sqr(dimTime), transportProperties)
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:64