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-2023 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 "mappedPatchBase.H"
29 #include "fvPatchFieldMapper.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
56 > Foam::radiationCoupledBase::emissivityMethodTypeNames_;
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 fvPatchFieldMapper& 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_ = scalarField("emissivity", dict, patch_.size());
108  break;
109  }
110  }
111 }
112 
113 
114 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * //
115 
117 {}
118 
119 
120 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
121 
123 {
124  switch (method_)
125  {
126  case SOLIDRADIATION:
127  {
128  // Get the coupling information from the mappedPatchBase
129  const mappedPatchBase& mpp =
130  mappedPatchBase::getMap(patch_.patch());
131 
132  const polyMesh& nbrMesh = mpp.nbrMesh();
133 
136  (
137  "radiationProperties"
138  );
139 
140  const fvMesh& nbrFvMesh = refCast<const fvMesh>(nbrMesh);
141 
142  const fvPatch& nbrPatch =
143  nbrFvMesh.boundary()[mpp.nbrPolyPatch().index()];
144 
145  // NOTE: for an opaqueSolid the absorptionEmission model returns the
146  // emissivity of the surface rather than the emission coefficient
147  // and the input specification MUST correspond to this.
148  return
149  mpp.fromNeighbour
150  (
151  radiation.absorptionEmission().e()().boundaryField()
152  [
153  nbrPatch.index()
154  ]
155  );
156  }
157  break;
158 
159  case LOOKUP:
160  {
161  // Return local value
162  return emissivity_;
163  }
164 
165  default:
166  {
168  << "Unimplemented method " << method_ << endl
169  << "Please set 'emissivity' to one of "
170  << emissivityMethodTypeNames_.toc()
171  << exit(FatalError);
172  }
173  break;
174  }
175 
176  return scalarField(0);
177 }
178 
179 
181 (
182  const fvPatchScalarField& ptf,
183  const fvPatchFieldMapper& mapper
184 )
185 {
186  const radiationCoupledBase& mrptf =
187  refCast<const radiationCoupledBase>(ptf);
188 
189  mapper(emissivity_, mrptf.emissivity_);
190 }
191 
192 
194 (
195  const fvPatchScalarField& ptf
196 )
197 {
198  const radiationCoupledBase& mrptf =
199  refCast<const radiationCoupledBase>(ptf);
200 
201  emissivity_.reset(mrptf.emissivity_);
202 }
203 
204 
206 {
207  writeEntry(os, "emissivityMode", emissivityMethodTypeNames_[method_]);
208  writeEntry(os, "emissivity", emissivity_);
209 }
210 
211 
212 // ************************************************************************* //
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:160
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:101
Foam::fvPatchFieldMapper.
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:87
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:64
virtual label size() const
Return size.
Definition: fvPatch.H:157
label index() const
Return the index of this patch in the fvBoundaryMesh.
Definition: fvPatch.H:175
Engine which provides mapping between two patches.
const polyPatch & nbrPolyPatch() const
Get the patch to map from.
static const mappedPatchBase & getMap(const polyPatch &patch)
Cast the given polyPatch to a mappedPatchBase. Handle errors.
const polyMesh & nbrMesh() const
Get the mesh for the region to map from.
tmp< Field< Type > > fromNeighbour(const Field< Type > &nbrFld) const
Map/interpolate the neighbour patch field to this patch.
const Type & lookupObject(const word &name) const
Lookup and return the object of the given Type and name.
label index() const
Return the index of this patch in the boundaryMesh.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:80
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 fvPatchFieldMapper &)
Map the given fvPatchField onto this fvPatchField.
virtual ~radiationCoupledBase()
Destructor.
scalarField emissivity_
Emissivity.
emissivityMethodType
Type of supplied emissivity.
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:306
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:251
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
dictionary dict