boundaryRadiationProperties.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) 2015 OpenCFD Ltd
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 
28 #include "fvPatchField.H"
29 
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
31 
32 namespace Foam
33 {
34  namespace radiation
35  {
37  }
38 }
39 
40 
41 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
42 
44 (
45  const fvMesh& mesh, const word name
46 ) const
47 {
48  IOobject io
49  (
50  name,
51  mesh.time().constant(),
52  mesh,
53  IOobject::MUST_READ,
54  IOobject::NO_WRITE
55  );
56 
57  if (io.headerOk())
58  {
59  io.readOpt() = IOobject::MUST_READ_IF_MODIFIED;
60  return io;
61  }
62  else
63  {
64  io.readOpt() = IOobject::NO_READ;
65  return io;
66  }
67 }
68 
69 
70 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
71 
73 (
74  const fvMesh& mesh
75 )
76 :
78  <
79  fvMesh,
82  >(mesh),
83  radBoundaryProperties_()
84 {
85  const IOobject boundaryIO
86  (
87  createIOobject(mesh, boundaryRadiationProperties::typeName)
88  );
89 
90  if (boundaryIO.readOpt() == IOobject::MUST_READ_IF_MODIFIED)
91  {
92  radBoundaryProperties_.set
93  (
94  new volScalarField(boundaryIO, mesh)
95  );
96  }
97 }
98 
99 
100 // * * * * * * * * * * * * * * * Member fucntions * * * * * * * * * * * * * //
101 
104 {
105  return radBoundaryProperties_();
106 }
107 
108 
110 emissivity(const label index, const label bandI) const
111 {
112  if (!radBoundaryProperties_.empty())
113  {
114  return refCast<const boundaryRadiationPropertiesFvPatchField>
115  (
116  radBoundaryProperties_->boundaryField()[index]
117  ).emissivity(bandI);
118  }
119  else
120  {
122  << "Field 'boundaryRadiationProperties'"
123  << "is not found in the constant directory."
124  << "Please add it "
125  << exit(FatalError);
126 
127  return tmp<scalarField>(new scalarField());
128  }
129 }
130 
131 
133 absorptivity(const label index, const label bandI) const
134 {
135  if (!radBoundaryProperties_.empty())
136  {
137  return refCast<const boundaryRadiationPropertiesFvPatchField>
138  (
139  radBoundaryProperties_->boundaryField()[index]
140  ).absorptivity(bandI);
141  }
142  else
143  {
145  << "Field 'boundaryRadiationProperties'"
146  << "is not found in the constant directory."
147  << "Please add it "
148  << exit(FatalError);
149 
150  return tmp<scalarField>(new scalarField());
151  }
152 }
153 
154 
156 transmissivity(const label index, const label bandI) const
157 {
158  if (!radBoundaryProperties_.empty())
159  {
160  return refCast<const boundaryRadiationPropertiesFvPatchField>
161  (
162  radBoundaryProperties_->boundaryField()[index]
163  ).transmissivity(bandI);
164  }
165  else
166  {
168  << "Field 'boundaryRadiationProperties'"
169  << "is not found in the constant directory."
170  << "Please add it "
171  << exit(FatalError);
172 
173  return tmp<scalarField>(new scalarField());
174  }
175 }
176 
177 
179 reflectivity(const label index, const label bandI) const
180 {
181  if (!radBoundaryProperties_.empty())
182  {
183  return refCast<const boundaryRadiationPropertiesFvPatchField>
184  (
185  radBoundaryProperties_->boundaryField()[index]
186  ).reflectivity(bandI);
187  }
188  else
189  {
191  << "Field 'boundaryRadiationProperties'"
192  << "is not found in the constant directory."
193  << "Please add it "
194  << exit(FatalError);
195 
196  return tmp<scalarField>(new scalarField());
197  }
198 }
199 
200 
201 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
202 
204 {}
205 
206 
207 // ************************************************************************* //
boundaryRadiationPropertiesFvPatchField.H
Foam::radiation::boundaryRadiationProperties::emissivity
tmp< scalarField > emissivity(const label patchId, const label bandI=0) const
Access boundary emissivity on patch.
Definition: boundaryRadiationProperties.C:110
Foam::scalarField
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Definition: primitiveFieldsFwd.H:48
Foam::IOobject
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:91
Foam::radiation::boundaryRadiationProperties::absorptivity
tmp< scalarField > absorptivity(const label patchId, const label bandI=0) const
Access boundary absorptivity on patch.
Definition: boundaryRadiationProperties.C:133
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::radiation::boundaryRadiationProperties::createIOobject
IOobject createIOobject(const fvMesh &mesh, const word) const
Create IO object if dictionary is present.
Definition: boundaryRadiationProperties.C:44
Foam::radiation::boundaryRadiationProperties::radBoundaryProperties_
autoPtr< volScalarField > radBoundaryProperties_
AutoPtr to volSacalarField properties.
Definition: boundaryRadiationProperties.H:69
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:118
Foam::radiation::boundaryRadiationProperties::radBoundaryProperties
const volScalarField & radBoundaryProperties() const
Access to radBoundaryProperties.
Definition: boundaryRadiationProperties.C:103
Foam::GeometricMeshObject
Definition: MeshObject.H:220
Foam::radiation::boundaryRadiationProperties::boundaryRadiationProperties
boundaryRadiationProperties(const fvMesh &)
Construct given fvMesh and IOobject.
Definition: boundaryRadiationProperties.C:73
Foam::IOobject::headerOk
bool headerOk()
Read and check header info.
Definition: IOobject.C:439
Foam::radiation::boundaryRadiationProperties::transmissivity
tmp< scalarField > transmissivity(const label patchId, const label bandI=0) const
Access boundary transmissivity on patch.
Definition: boundaryRadiationProperties.C:156
Foam::radiation::boundaryRadiationProperties::reflectivity
tmp< scalarField > reflectivity(const label patchId, const label bandI=0) const
Access boundary reflectivity on patch.
Definition: boundaryRadiationProperties.C:179
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
Foam::IOobject::readOpt
readOption readOpt() const
Definition: IOobject.H:317
Foam::volScalarField
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:52
radiation
autoPtr< radiation::radiationModel > radiation(radiation::radiationModel::New(T))
Foam::radiation::boundaryRadiationProperties
Definition: boundaryRadiationProperties.H:56
Foam::FatalError
error FatalError
Foam::radiation::boundaryRadiationProperties::~boundaryRadiationProperties
virtual ~boundaryRadiationProperties()
Destructor.
Definition: boundaryRadiationProperties.C:203
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:18
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::radiation::defineTypeNameAndDebug
defineTypeNameAndDebug(cloudAbsorptionEmission, 0)
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:318
boundaryRadiationProperties
Boundary radiation properties holder.
Foam::MeshObject
Templated abstract base-class for optional mesh objects used to automate their allocation to the mesh...
Definition: MeshObject.H:81
Foam::GeometricField
Generic GeometricField class.
Definition: surfaceFieldsFwd.H:52
Foam::name
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
boundaryRadiationProperties.H
fvPatchField.H