faceShading.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2015 OpenFOAM Foundation
9  Copyright (C) 2017-2022 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::faceShading
29 
30 Description
31  Helper class to calculate visible faces for global, sun-like illumination.
32 
33  faceShading uses the transmissivity value in the boundaryRadiationProperties
34  in order to evaluate which faces are "hit" by the "direction" vector.
35  NOTE: Only transmissivity values of zero are considered for opaque walls.
36 
37 SourceFiles
38  faceShading.C
39 
40 \*---------------------------------------------------------------------------*/
41 
42 #ifndef faceShading_H
43 #define faceShading_H
44 
46 #include "DynamicField.H"
47 #include "triSurface.H"
48 
49 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50 
51 namespace Foam
52 {
53 
54 // Forward Declarations
55 class fvMesh;
56 class polyMesh;
57 
58 /*---------------------------------------------------------------------------*\
59  Class faceShading Declaration
60 \*---------------------------------------------------------------------------*/
61 
62 class faceShading
63 {
64  // Private Data
65 
66  //- Reference to mesh
67  const fvMesh& mesh_;
68 
69  //- Patches to check for visibility
70  const labelList patchIDs_;
71 
72  //- FaceZones to check for visibility
73  const labelList zoneIDs_;
74 
75  //- Direction
76  vector direction_;
77 
78  //- Faces directly hit by vector direction
79  labelList rayStartFaces_;
80 
81 
82  // Private Member Functions
83 
84  //- Calculate ray start faces
85  void calculate();
86 
87  //- Construct a triSurface from selected faces on patches or faceZones.
88  // Resulting surface has regioning with mesh patches first, faceZones
89  // second.
90  triSurface triangulate
91  (
92  const labelUList& faceIDs,
93  const bitSet& flipMap
94  ) const;
95 
96  //- Find opaque faces by looking at the radiation properties.
97  bitSet selectOpaqueFaces
98  (
99  const radiation::boundaryRadiationProperties& boundaryRadiation,
100  const labelUList& patchIDs,
101  const labelUList& zoneIDs
102  ) const;
103 
104  //- Pick up candidate faces that might be blocking visibility for
105  // other faces:
106  // - if transmissivity is 0
107  // - (optional) if pointing wrong way
108  void selectFaces
109  (
110  const bool useNormal,
111  const bitSet& isCandidateFace,
112  const labelUList& patchIDs,
113  const labelUList& zoneIDs,
114 
115  labelList& faceIDs,
116  bitSet& flipMap
117  ) const;
118 
119  //- Write rays
120  void writeRays
121  (
122  const fileName& fName,
123  const DynamicField<point>& endCf,
124  const pointField& myFc
125  );
126 
127  //- No copy construct
128  faceShading(const faceShading&) = delete;
129 
130  //- No copy assignment
131  void operator=(const faceShading&) = delete;
132 
133 
134 public:
135 
136  // Declare name of the class and its debug switch
137  ClassName("faceShading");
138 
139 
140  // Constructors
141 
142  //- Helper: return all uncoupled patches
143  static labelList nonCoupledPatches(const polyMesh& mesh);
144 
145  //- Construct from mesh and vector to 'sun'. All uncoupled patches
146  // are checked for visibility. faceZones are ignored.
148  (
149  const fvMesh& mesh,
150  const vector& dir
151  );
152 
153  //- Construct from mesh and vector to 'sun' and selected patches
154  // and faceZones.
156  (
157  const fvMesh& mesh,
158  const labelList& patchIDs,
159  const labelList& zoneIDs,
160  const vector& dir
161  );
162 
163 
164  //- Destructor
165  ~faceShading() = default;
166 
167 
168  // Member Functions
169 
170  // Access
171 
172  //- Const access to direction
173  const vector direction() const
174  {
175  return direction_;
176  }
177 
178  //- Non-const access to direction
179  vector& direction()
180  {
181  return direction_;
182  }
183 
184  //- Const access to rayStartFaces
185  const labelList& rayStartFaces() const
186  {
187  return rayStartFaces_;
188  }
189 
190 
191  //- Recalculate rayStartFaces using direction vector
192  void correct();
193 };
194 
195 
196 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
197 
198 } // End namespace Foam
199 
200 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
201 
202 #endif
203 
204 // ************************************************************************* //
const labelList patchIDs(pbm.indices(polyPatchNames, true))
const labelIOList & zoneIDs
Definition: correctPhi.H:59
A class for handling file names.
Definition: fileName.H:72
void correct()
Recalculate rayStartFaces using direction vector.
Definition: faceShading.C:562
~faceShading()=default
Destructor.
dynamicFvMesh & mesh
Dynamically sized Field.
Definition: DynamicField.H:45
Helper class to calculate visible faces for global, sun-like illumination.
Definition: faceShading.H:57
static labelList nonCoupledPatches(const polyMesh &mesh)
Helper: return all uncoupled patches.
Definition: faceShading.C:545
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
ClassName("faceShading")
const labelList & rayStartFaces() const
Const access to rayStartFaces.
Definition: faceShading.H:222
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
Definition: bitSet.H:59
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
Triangulated surface description with patch information.
Definition: triSurface.H:71
const vector direction() const
Const access to direction.
Definition: faceShading.H:206
Namespace for OpenFOAM.