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