radiationCoupledBase.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2011-2015 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"
32 
33 // * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * * * //
34 
35 namespace Foam
36 {
37  defineTypeNameAndDebug(radiationCoupledBase, 0);
38 }
39 
40 
41 namespace Foam
42 {
43  template<>
44  const char* Foam::NamedEnum
45  <
47  2
48  >::names[] =
49  {
50  "solidRadiation",
51  "lookup"
52  };
53 }
54 
55 
57  Foam::radiationCoupledBase::emissivityMethodTypeNames_;
58 
59 
60 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
61 
63 (
64  const fvPatch& patch,
65  const word& calculationType,
66  const scalarField& emissivity
67 )
68 :
69  patch_(patch),
70  method_(emissivityMethodTypeNames_[calculationType]),
71  emissivity_(emissivity)
72 {}
73 
74 
76 (
77  const fvPatch& patch,
78  const word& calculationType,
79  const scalarField& emissivity,
80  const fvPatchFieldMapper& mapper
81 )
82 :
83  patch_(patch),
84  method_(emissivityMethodTypeNames_[calculationType]),
85  emissivity_(emissivity, mapper)
86 {}
87 
88 
90 (
91  const fvPatch& patch,
92  const dictionary& dict
93 )
94 :
95  patch_(patch),
96  method_(emissivityMethodTypeNames_.read(dict.lookup("emissivityMode")))
97 {
98  switch (method_)
99  {
100  case SOLIDRADIATION:
101  {
102  if (!isA<mappedPatchBase>(patch_.patch()))
103  {
105  (
106  dict
107  ) << "\n patch type '" << patch_.type()
108  << "' not type '" << mappedPatchBase::typeName << "'"
109  << "\n for patch " << patch_.name()
110  << exit(FatalIOError);
111  }
112 
113  emissivity_ = scalarField(patch_.size(), 0.0);
114  }
115  break;
116 
117  case LOOKUP:
118  {
119  if (!dict.found("emissivity"))
120  {
122  (
123  dict
124  ) << "\n emissivity key does not exist for patch "
125  << patch_.name()
126  << exit(FatalIOError);
127  }
128  else
129  {
130  emissivity_ = scalarField("emissivity", dict, patch_.size());
131  }
132  }
133  break;
134  }
135 }
136 
137 
138 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * //
139 
141 {}
142 
143 
144 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
145 
147 {
148  switch (method_)
149  {
150  case SOLIDRADIATION:
151  {
152  // Get the coupling information from the mappedPatchBase
153  const mappedPatchBase& mpp =
154  refCast<const mappedPatchBase>(patch_.patch());
155 
156  const polyMesh& nbrMesh = mpp.sampleMesh();
157 
159  nbrMesh.lookupObject<radiation::radiationModel>
160  (
161  "radiationProperties"
162  );
163 
164 
165  const fvMesh& nbrFvMesh = refCast<const fvMesh>(nbrMesh);
166 
167  const fvPatch& nbrPatch =
168  nbrFvMesh.boundary()[mpp.samplePolyPatch().index()];
169 
170 
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  }
183  break;
184 
185  case LOOKUP:
186  {
187  // return local value
188  return emissivity_;
189  }
190 
191  default:
192  {
194  << "Unimplemented method " << method_ << endl
195  << "Please set 'emissivity' to one of "
196  << emissivityMethodTypeNames_.toc()
197  << exit(FatalError);
198  }
199  break;
200  }
201 
202  return scalarField(0);
203 }
204 
205 
207 (
208  const fvPatchFieldMapper& m
209 )
210 {
211  emissivity_.autoMap(m);
212 }
213 
214 
216 (
217  const fvPatchScalarField& ptf,
218  const labelList& addr
219 )
220 {
221  const radiationCoupledBase& mrptf =
222  refCast<const radiationCoupledBase>(ptf);
223 
224  emissivity_.rmap(mrptf.emissivity_, addr);
225 }
226 
227 
229 {
230  os.writeKeyword("emissivityMode") << emissivityMethodTypeNames_[method_]
231  << token::END_STATEMENT << nl;
232  emissivity_.writeEntry("emissivity", os);
233 }
234 
235 
236 // ************************************************************************* //
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
Definition: dictionary.C:431
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:253
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:52
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 ...
Top level model for radiation modelling.
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:262
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