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-2024 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 template<>
42 const char* Foam::NamedEnum
43 <
45  2
46 >::names[] =
47 {
48  "solidRadiation",
49  "lookup"
50 };
51 
52 const Foam::NamedEnum
53 <
55  2
57 
58 
59 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
60 
62 (
63  const fvPatch& patch,
64  const word& calculationType,
65  const scalarField& emissivity
66 )
67 :
68  patch_(patch),
69  method_(emissivityMethodTypeNames_[calculationType]),
70  emissivity_(emissivity)
71 {}
72 
73 
75 (
76  const fvPatch& patch,
77  const word& calculationType,
78  const scalarField& emissivity,
79  const fieldMapper& mapper
80 )
81 :
82  patch_(patch),
83  method_(emissivityMethodTypeNames_[calculationType]),
84  emissivity_(mapper(emissivity))
85 {}
86 
87 
89 (
90  const fvPatch& patch,
91  const dictionary& dict
92 )
93 :
94  patch_(patch),
95  method_(emissivityMethodTypeNames_.read(dict.lookup("emissivityMode")))
96 {
97  switch (method_)
98  {
99  case SOLIDRADIATION:
100  {
101  emissivity_ = scalarField(patch_.size(), scalar(0));
102  break;
103  }
104 
105  case LOOKUP:
106  {
107  emissivity_ =
108  scalarField("emissivity", unitFraction, dict, patch_.size());
109  break;
110  }
111  }
112 }
113 
114 
115 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * //
116 
118 {}
119 
120 
121 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
122 
124 {
125  switch (method_)
126  {
127  case SOLIDRADIATION:
128  {
129  // Get the mapper and the neighbouring mesh and patch
130  const mappedFvPatchBaseBase& mapper =
132  const fvMesh& nbrMesh = mapper.nbrMesh();
133  const fvPatch& nbrPatch = mapper.nbrFvPatch();
134 
137  (
138  "radiationProperties"
139  );
140 
141  // NOTE: for an opaqueSolid the absorptionEmission model returns the
142  // emissivity of the surface rather than the emission coefficient
143  // and the input specification MUST correspond to this.
144  return
145  mapper.fromNeighbour
146  (
147  radiation.absorptionEmission().e()().boundaryField()
148  [
149  nbrPatch.index()
150  ]
151  );
152  }
153  break;
154 
155  case LOOKUP:
156  {
157  // Return local value
158  return emissivity_;
159  }
160 
161  default:
162  {
164  << "Unimplemented method " << method_ << endl
165  << "Please set 'emissivity' to one of "
166  << emissivityMethodTypeNames_.toc()
167  << exit(FatalError);
168  }
169  break;
170  }
171 
172  return scalarField(0);
173 }
174 
175 
177 (
178  const fvPatchScalarField& ptf,
179  const fieldMapper& mapper
180 )
181 {
182  const radiationCoupledBase& mrptf =
183  refCast<const radiationCoupledBase>(ptf);
184 
185  mapper(emissivity_, mrptf.emissivity_);
186 }
187 
188 
190 (
191  const fvPatchScalarField& ptf
192 )
193 {
194  const radiationCoupledBase& mrptf =
195  refCast<const radiationCoupledBase>(ptf);
196 
197  emissivity_.reset(mrptf.emissivity_);
198 }
199 
200 
202 {
203  writeEntry(os, "emissivityMode", emissivityMethodTypeNames_[method_]);
204  writeEntry(os, "emissivity", emissivity_);
205 }
206 
207 
208 // ************************************************************************* //
Initialise the NamedEnum HashTable from the static list of names.
Definition: NamedEnum.H:54
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
A list of keyword definitions, which are a keyword followed by any number of values (e....
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:99
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:88
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))
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:334
Namespace for OpenFOAM.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
bool read(const char *, int32_t &)
Definition: int32IO.C:85
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:257
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)
error FatalError
const unitConversion unitFraction
dictionary dict