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-2022 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 {
38  defineTypeNameAndDebug(radiationCoupledBase, 0);
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  if (!isA<mappedPatchBase>(patch_.patch()))
102  {
104  (
105  dict
106  ) << "\n patch type '" << patch_.type()
107  << "' not type '" << mappedPatchBase::typeName << "'"
108  << "\n for patch " << patch_.name()
109  << exit(FatalIOError);
110  }
111 
112  emissivity_ = scalarField(patch_.size(), 0.0);
113  }
114  break;
115 
116  case LOOKUP:
117  {
118  if (!dict.found("emissivity"))
119  {
121  (
122  dict
123  ) << "\n emissivity key does not exist for patch "
124  << patch_.name()
125  << exit(FatalIOError);
126  }
127  else
128  {
129  emissivity_ = scalarField("emissivity", dict, patch_.size());
130  }
131  }
132  break;
133  }
134 }
135 
136 
137 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * //
138 
140 {}
141 
142 
143 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
144 
146 {
147  switch (method_)
148  {
149  case SOLIDRADIATION:
150  {
151  // Get the coupling information from the mappedPatchBase
152  const mappedPatchBase& mpp =
153  refCast<const mappedPatchBase>(patch_.patch());
154 
155  const polyMesh& nbrMesh = mpp.sampleMesh();
156 
158  nbrMesh.lookupObject<radiationModels::opaqueSolid>
159  (
160  "radiationProperties"
161  );
162 
163  const fvMesh& nbrFvMesh = refCast<const fvMesh>(nbrMesh);
164 
165  const fvPatch& nbrPatch =
166  nbrFvMesh.boundary()[mpp.samplePolyPatch().index()];
167 
168  // NOTE: for an opaqueSolid the absorptionEmission model returns the
169  // emissivity of the surface rather than the emission coefficient
170  // and the input specification MUST correspond to this.
171  scalarField emissivity
172  (
173  radiation.absorptionEmission().e()().boundaryField()
174  [
175  nbrPatch.index()
176  ]
177  );
178  mpp.distribute(emissivity);
179 
180  return emissivity;
181  }
182  break;
183 
184  case LOOKUP:
185  {
186  // Return local value
187  return emissivity_;
188  }
189 
190  default:
191  {
193  << "Unimplemented method " << method_ << endl
194  << "Please set 'emissivity' to one of "
195  << emissivityMethodTypeNames_.toc()
196  << exit(FatalError);
197  }
198  break;
199  }
200 
201  return scalarField(0);
202 }
203 
204 
206 {
207  m(emissivity_, emissivity_);
208 }
209 
210 
212 (
213  const fvPatchScalarField& ptf,
214  const labelList& addr
215 )
216 {
217  const radiationCoupledBase& mrptf =
218  refCast<const radiationCoupledBase>(ptf);
219 
220  emissivity_.rmap(mrptf.emissivity_, addr);
221 }
222 
223 
225 (
226  const fvPatchScalarField& ptf
227 )
228 {
229  const radiationCoupledBase& mrptf =
230  refCast<const radiationCoupledBase>(ptf);
231 
232  emissivity_.reset(mrptf.emissivity_);
233 }
234 
235 
237 {
238  writeEntry(os, "emissivityMode", emissivityMethodTypeNames_[method_]);
239  writeEntry(os, "emissivity", emissivity_);
240 }
241 
242 
243 // ************************************************************************* //
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
Definition: dictionary.C:663
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
error FatalError
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:306
const polyMesh & sampleMesh() const
Get the region mesh.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:63
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:66
scalarField emissivity() const
Calculate corresponding emissivity field.
Initialise the NamedEnum HashTable from the static list of names.
Definition: NamedEnum.H:51
virtual tmp< volScalarField > e(const label bandI=0) const
Emission coefficient (net)
Radiation for solid opaque solids - does nothing to energy equation source terms (returns zeros) but ...
Definition: opaqueSolid.H:52
scalarField emissivity_
Emissivity.
emissivityMethodType
Type of supplied emissivity.
const radiationModels::absorptionEmissionModel & absorptionEmission() const
Access to absorptionEmission model.
A class for handling words, derived from string.
Definition: word.H:59
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
void write(Ostream &) const
Write.
Foam::fvPatchFieldMapper.
Determines a mapping between patch face centres and mesh cell or face centres and processors they&#39;re ...
Common functions to emissivity. It gets supplied from lookup into a dictionary or calculated by the s...
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
defineTypeNameAndDebug(combustionModel, 0)
virtual void rmap(const fvPatchScalarField &, const labelList &)
Reverse map the given fvPatchField onto this fvPatchField.
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
Definition: HashTableIO.C:96
void distribute(List< Type > &lst) const
Wrapper around map/interpolate data distribution.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:318
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:95
label index() const
Return the index of this patch in the boundaryMesh.
autoPtr< radiationModel > radiation(radiationModel::New(T))
virtual ~radiationCoupledBase()
Destructor.
virtual void autoMap(const fvPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:76
const polyPatch & samplePolyPatch() const
Get the patch on the region.
virtual void reset(const fvPatchScalarField &)
Reset the fvPatchField to the given fvPatchField.
Namespace for OpenFOAM.
radiationCoupledBase(const fvPatch &patch, const word &calculationMethod, const scalarField &emissivity)
Construct from patch, emissivity mode and emissivity.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:864
IOerror FatalIOError