radiationCoupledBase.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2025 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "radiationCoupledBase.H"
27 #include "volFields.H"
28 #include "fieldMapper.H"
29 #include "mappedFvPatchBaseBase.H"
30 #include "radiationModel.H"
31 #include "opaqueSolid.H"
33 
34 // * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * * * //
35 
36 namespace Foam
37 {
39 }
40 
41 const Foam::NamedEnum
42 <
44  2
46 {
47  "solidRadiation",
48  "lookup"
49 };
50 
51 
52 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
53 
55 (
56  const fvPatch& patch,
57  const word& calculationType,
58  const scalarField& emissivity
59 )
60 :
61  patch_(patch),
62  method_(emissivityMethodTypeNames_[calculationType]),
63  emissivity_(emissivity)
64 {}
65 
66 
68 (
69  const fvPatch& patch,
70  const word& calculationType,
71  const scalarField& emissivity,
72  const fieldMapper& mapper
73 )
74 :
75  patch_(patch),
76  method_(emissivityMethodTypeNames_[calculationType]),
77  emissivity_(mapper(emissivity))
78 {}
79 
80 
82 (
83  const fvPatch& patch,
84  const dictionary& dict
85 )
86 :
87  patch_(patch),
88  method_(emissivityMethodTypeNames_.read(dict.lookup("emissivityMode")))
89 {
90  switch (method_)
91  {
92  case SOLIDRADIATION:
93  {
94  emissivity_ = scalarField(patch_.size(), scalar(0));
95  break;
96  }
97 
98  case LOOKUP:
99  {
100  emissivity_ =
101  scalarField("emissivity", unitFraction, dict, patch_.size());
102  break;
103  }
104  }
105 }
106 
107 
108 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * //
109 
111 {}
112 
113 
114 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
115 
117 {
118  switch (method_)
119  {
120  case SOLIDRADIATION:
121  {
122  // Get the mapper and the neighbouring mesh and patch
123  const mappedFvPatchBaseBase& mapper =
125  const fvMesh& nbrMesh = mapper.nbrMesh();
126  const fvPatch& nbrPatch = mapper.nbrFvPatch();
127 
130  (
131  "radiationProperties"
132  );
133 
134  // NOTE: for an opaqueSolid the absorptionEmission model returns the
135  // emissivity of the surface rather than the emission coefficient
136  // and the input specification MUST correspond to this.
137  return
138  mapper.fromNeighbour
139  (
140  radiation.absorptionEmission().e()().boundaryField()
141  [
142  nbrPatch.index()
143  ]
144  );
145  }
146  break;
147 
148  case LOOKUP:
149  {
150  // Return local value
151  return emissivity_;
152  }
153  break;
154  }
155 
156  return scalarField(0);
157 }
158 
159 
161 (
162  const fvPatchScalarField& ptf,
163  const fieldMapper& mapper
164 )
165 {
166  const radiationCoupledBase& mrptf =
167  refCast<const radiationCoupledBase>(ptf);
168 
169  mapper(emissivity_, mrptf.emissivity_);
170 }
171 
172 
174 (
175  const fvPatchScalarField& ptf
176 )
177 {
178  const radiationCoupledBase& mrptf =
179  refCast<const radiationCoupledBase>(ptf);
180 
181  emissivity_.reset(mrptf.emissivity_);
182 }
183 
184 
186 {
187  writeEntry(os, "emissivityMode", emissivityMethodTypeNames_[method_]);
188  writeEntry(os, "emissivity", emissivity_);
189 }
190 
191 
192 // ************************************************************************* //
Initialise the NamedEnum HashTable from the static list of names.
Definition: NamedEnum.H:55
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
Abstract base class for field mapping.
Definition: fieldMapper.H:48
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:96
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:91
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:64
virtual label size() const
Return size.
Definition: fvPatch.H:138
label index() const
Return the index of this patch in the fvBoundaryMesh.
Definition: fvPatch.H:156
Base class for fv patches that provide mapping between two fv patches.
const fvPatch & nbrFvPatch() const
Get the patch to map from.
static const mappedFvPatchBaseBase & getMap(const fvPatch &patch)
Cast the given fvPatch to a mappedFvPatchBaseBase. Handle errors.
const fvMesh & nbrMesh() const
Get the mesh for the region to map from.
const Type & lookupObject(const word &name) const
Lookup and return the object of the given Type and name.
Common functions to emissivity. It gets supplied from lookup into a dictionary or calculated by the s...
radiationCoupledBase(const fvPatch &patch, const word &calculationMethod, const scalarField &emissivity)
Construct from patch, emissivity mode and emissivity.
void write(Ostream &) const
Write.
virtual void reset(const fvPatchScalarField &)
Reset the fvPatchField to the given fvPatchField.
tmp< scalarField > emissivity() const
Calculate corresponding emissivity field.
virtual void map(const fvPatchScalarField &, const fieldMapper &)
Map the given fvPatchField onto this fvPatchField.
virtual ~radiationCoupledBase()
Destructor.
scalarField emissivity_
Emissivity. Cached locally when looked up.
static const NamedEnum< emissivityMethodType, 2 > emissivityMethodTypeNames_
Names of emissivity methods.
emissivityMethodType
Emissivity methods.
const emissivityMethodType method_
How to get emissivity.
Radiation for solid opaque solids - does nothing to energy equation source terms (returns zeros) but ...
Definition: opaqueSolid.H:55
A class for managing temporary objects.
Definition: tmp.H:55
A class for handling words, derived from string.
Definition: word.H:62
autoPtr< radiationModel > radiation(radiationModel::New(T))
Namespace for OpenFOAM.
bool read(const char *, int32_t &)
Definition: int32IO.C:85
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
Definition: HashTableIO.C:96
defineTypeNameAndDebug(combustionModel, 0)
const unitConversion unitFraction
dictionary dict