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-2018 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  template<>
41  const char* Foam::NamedEnum
42  <
44  2
45  >::names[] =
46  {
47  "solidRadiation",
48  "lookup"
49  };
50 }
51 
53  Foam::radiationCoupledBase::emissivityMethodTypeNames_;
54 
55 
56 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
57 
59 (
60  const fvPatch& patch,
61  const word& calculationType,
62  const scalarField& emissivity
63 )
64 :
65  patch_(patch),
66  method_(emissivityMethodTypeNames_[calculationType]),
67  emissivity_(emissivity)
68 {}
69 
70 
72 (
73  const fvPatch& patch,
74  const word& calculationType,
75  const scalarField& emissivity,
76  const fvPatchFieldMapper& mapper
77 )
78 :
79  patch_(patch),
80  method_(emissivityMethodTypeNames_[calculationType]),
81  emissivity_(emissivity, mapper)
82 {}
83 
84 
86 (
87  const fvPatch& patch,
88  const dictionary& dict
89 )
90 :
91  patch_(patch),
92  method_(emissivityMethodTypeNames_.read(dict.lookup("emissivityMode")))
93 {
94  switch (method_)
95  {
96  case SOLIDRADIATION:
97  {
98  if (!isA<mappedPatchBase>(patch_.patch()))
99  {
101  (
102  dict
103  ) << "\n patch type '" << patch_.type()
104  << "' not type '" << mappedPatchBase::typeName << "'"
105  << "\n for patch " << patch_.name()
106  << exit(FatalIOError);
107  }
108 
109  emissivity_ = scalarField(patch_.size(), 0.0);
110  }
111  break;
112 
113  case LOOKUP:
114  {
115  if (!dict.found("emissivity"))
116  {
118  (
119  dict
120  ) << "\n emissivity key does not exist for patch "
121  << patch_.name()
122  << exit(FatalIOError);
123  }
124  else
125  {
126  emissivity_ = scalarField("emissivity", dict, patch_.size());
127  }
128  }
129  break;
130  }
131 }
132 
133 
134 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * //
135 
137 {}
138 
139 
140 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
141 
143 {
144  switch (method_)
145  {
146  case SOLIDRADIATION:
147  {
148  // Get the coupling information from the mappedPatchBase
149  const mappedPatchBase& mpp =
150  refCast<const mappedPatchBase>(patch_.patch());
151 
152  const polyMesh& nbrMesh = mpp.sampleMesh();
153 
155  nbrMesh.lookupObject<radiation::opaqueSolid>
156  (
157  "radiationProperties"
158  );
159 
160  const fvMesh& nbrFvMesh = refCast<const fvMesh>(nbrMesh);
161 
162  const fvPatch& nbrPatch =
163  nbrFvMesh.boundary()[mpp.samplePolyPatch().index()];
164 
165  // NOTE: for an opaqueSolid the absorptionEmission model returns the
166  // emissivity of the surface rather than the emission coefficient
167  // and the input specification MUST correspond to this.
168  scalarField emissivity
169  (
170  radiation.absorptionEmission().e()().boundaryField()
171  [
172  nbrPatch.index()
173  ]
174  );
175  mpp.distribute(emissivity);
176 
177  return emissivity;
178 
179  }
180  break;
181 
182  case LOOKUP:
183  {
184  // return local value
185  return emissivity_;
186  }
187 
188  default:
189  {
191  << "Unimplemented method " << method_ << endl
192  << "Please set 'emissivity' to one of "
193  << emissivityMethodTypeNames_.toc()
194  << exit(FatalError);
195  }
196  break;
197  }
198 
199  return scalarField(0);
200 }
201 
202 
204 (
205  const fvPatchFieldMapper& m
206 )
207 {
208  emissivity_.autoMap(m);
209 }
210 
211 
213 (
214  const fvPatchScalarField& ptf,
215  const labelList& addr
216 )
217 {
218  const radiationCoupledBase& mrptf =
219  refCast<const radiationCoupledBase>(ptf);
220 
221  emissivity_.rmap(mrptf.emissivity_, addr);
222 }
223 
224 
226 {
227  os.writeKeyword("emissivityMode") << emissivityMethodTypeNames_[method_]
228  << token::END_STATEMENT << nl;
229  emissivity_.writeEntry("emissivity", os);
230 }
231 
232 
233 // ************************************************************************* //
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
Definition: dictionary.C:431
Radiation for solid opaque solids - does nothing to energy equation source terms (returns zeros) but ...
Definition: opaqueSolid.H:52
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:137
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:319
const polyMesh & sampleMesh() const
Get the region mesh.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:256
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:61
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
scalarField emissivity_
Emissivity.
emissivityMethodType
Type of supplied emissivity.
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:53
static const char nl
Definition: Ostream.H:265
defineTypeNameAndDebug(combustionModel, 0)
virtual void rmap(const fvPatchScalarField &, const labelList &)
Reverse map the given fvPatchField onto this fvPatchField.
Ostream & writeKeyword(const keyType &)
Write the keyword followed by an appropriate indentation.
Definition: Ostream.C:54
const absorptionEmissionModel & absorptionEmission() const
Access to absorptionEmission model.
void distribute(List< Type > &lst) const
Wrapper around map/interpolate data distribution.
virtual tmp< volScalarField > e(const label bandI=0) const
Emission coefficient (net)
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:331
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
label index() const
Return the index of this patch in the boundaryMesh.
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:74
const polyPatch & samplePolyPatch() const
Get the patch on the region.
autoPtr< radiation::radiationModel > radiation(radiation::radiationModel::New(T))
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:576
IOerror FatalIOError