meshOctreeCube.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | cfMesh: A library for mesh generation
4  \\ / O peration |
5  \\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
6  \\/ M anipulation | Copyright (C) Creative Fields, Ltd.
7 -------------------------------------------------------------------------------
8 License
9  This file is part of cfMesh.
10 
11  cfMesh is free software; you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by the
13  Free Software Foundation; either version 3 of the License, or (at your
14  option) any later version.
15 
16  cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  meshOctreeCube
26 
27 Description
28  A cube stores information needed for mesh generation
29 
30 SourceFiles
31  meshOctreeCube.C
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef meshOctreeCube_H
36 #define meshOctreeCube_H
37 
38 #include "DynList.H"
39 #include "LongList.H"
40 #include "boolList.H"
41 #include "meshOctreeCubeBasic.H"
42 
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 
45 namespace Foam
46 {
47 
48 class Ostream;
49 class triSurf;
50 class VRWGraph;
51 class meshOctreeSlot;
52 
53 /*---------------------------------------------------------------------------*\
54  Class meshOctreeCube Declaration
55 \*---------------------------------------------------------------------------*/
56 
57 class meshOctreeCube
58 : public meshOctreeCubeBasic
59 {
60  // Private data
61  //- pointer the slot containing this cube
63 
64  //- pointer to the first child element
66 
67  //- position of the cube in the list of leaves
68  mutable label cubeLabel_;
69 
70  //- label of the row which contains elements contained in the cube
72 
73  //- labels of contained surface edges
75 
76  // Static data
77  //- this data is needed to map the the current refinement pattern
78  //- to the Hilbert space-filling curve in order to reduce the bandwidth
79  //- in the list of leaves. The procedure is performed using the table
80  //- published in (Campbell etal: Dynamic Octree Load Balancing Using
81  //- Space-Filling Curves) which is adjusted to the current ref pattern
82  static const label hOrder_[24][8];
83 
84  //- orientation of the Hilbert curve in the refined cubes of a cube
85  //- with the ordering in the above table
86  static const label hOrient_[24][8];
87 
88  // Private member functions
89  //- find edges contained in the cube
91  (
92  const triSurf&,
93  const boundBox&
94  );
95 
96  //- store data which is contained in the child cube
97  //- this is needed for parallel coarsening of the octree
98  //inline void reclaimDataFromChild(const label scI);
99 
100  //- Disallow copy construct from meshOctreeCubeBasic
102 
103 public:
104 
105  // Constructors
106 
107  //- Default constructor
108  inline meshOctreeCube();
109 
110  //- Copy construct
111  inline meshOctreeCube(const meshOctreeCube&);
112 
113  //- Construct from coordinates
115 
116  //- Construct from coordinates and the number of surface triangles
117  //- this constructor is used for the initial cube, only
119  (
120  const meshOctreeCubeCoordinates& cc,
121  const label nElmts,
123  );
124 
125  // Destructor
126 
127  ~meshOctreeCube();
128 
129  // Member Functions
130 
131  //- refine cube in two directions, it is used for generating quadtrees
132  void refineCube2D
133  (
134  const triSurf&,
135  const boundBox&,
136  meshOctreeSlot* slotPtr = NULL
137  );
138 
139  //- subdivide the octree cube
140  void refineCube
141  (
142  const triSurf&,
143  const boundBox&,
144  meshOctreeSlot* slotPtr = NULL
145  );
146 
147  //- create missing child cubes and refine them until the required
148  //- cube is reached (this function is used for parallel octree creation)
149  void refineMissingCube
150  (
151  const triSurf&,
152  const boundBox&,
153  const label scI,
154  meshOctreeSlot* slotPtr = NULL
155  );
156 
157  //- create missing child cubes and refine them until the required
158  //- cube is reached (this function is used for parallel octree creation)
159  //- contained elements and edges are provided as argument
160  void refineMissingCube
161  (
162  const label scI,
163  const label elementsRowI = -1,
164  const label edgesRowI = -1,
165  meshOctreeSlot* slotPtr = NULL
166  );
167 
168  //- return the pointer to the slot containing the cube
169  inline const meshOctreeSlot* slotPtr() const;
170 
171  //- position of the cube in the list of leaves
172  inline label cubeLabel() const;
173 
174  //- check if the cube is a leaf
175  inline bool isLeaf() const;
176 
177  //- return a pointer to a child cubes at given position
178  inline meshOctreeCube* subCube(const label) const;
179 
180  //- return the pointers to the sons
182 
183  //- check if this box has some contained triangles
185  (
186  const triSurf&,
187  const boundBox&,
189  ) const;
190 
191  //- return true if the box contains some triangles
192  inline bool hasContainedElements() const;
193 
194  //- returns the list of contained surface elements
195  //- this list is only allocated for cubes containing elements
196  inline label containedElements() const;
197 
198  //- returns true if the box contains some edges
199  inline bool hasContainedEdges() const;
200 
201  //- returns the list of contained surface edges
202  //- this list is only allocated for cubes containing edges
203  inline label containedEdges() const;
204 
205  // Recursive functions
206  //- leaves contained in the given box
207  void leavesInBox
208  (
209  const boundBox& rootBox,
210  const boundBox& searchingBox,
212  ) const;
213 
214  //- find leaves within a sphere
215  void leavesInSphere
216  (
217  const boundBox& rootBox,
218  const point&,
219  const scalar,
221  ) const;
222 
223  //- mark leaves within a sphere
224  void markLeavesInSphere
225  (
226  const boundBox& rootBox,
227  const point&,
228  const scalar,
229  labelList&,
230  bool&
231  ) const;
232 
233  //- find leaves for a given cube
234  void findLeaves
235  (
237  ) const;
238 
239  //- find coordinates of cubes which are located on other processors
241  (
243  ) const;
244 
245  //- count number of originating from this cube
246  void countChildCubes(label& nCubes) const;
247 
248  //- delete boxes which are not local to the given processor
249  bool purgeProcessorCubes(const short procNo);
250 
251  // Member operators
252 
253  //- assignment
254  inline void operator=(const meshOctreeCube&);
255  friend Ostream& operator<<(Ostream&, const meshOctreeCube&);
256 };
257 
258 
259 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
260 
261 } // End namespace Foam
262 
263 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
264 
265 #include "meshOctreeCubeI.H"
266 
267 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
268 
269 #endif
270 
271 // ************************************************************************* //
LongList.H
meshOctreeSlot
A class holding information about octree data generated by a single thread.
boolList.H
Foam::meshOctreeCubeCoordinates
Definition: meshOctreeCubeCoordinates.H:55
Foam::meshOctreeCube::containedEdges
label containedEdges() const
Definition: meshOctreeCubeI.H:102
Foam::meshOctreeCube::refineCube
void refineCube(const triSurf &, const boundBox &, meshOctreeSlot *slotPtr=NULL)
subdivide the octree cube
Definition: meshOctreeCubeRefine.C:223
Foam::meshOctreeCube::findCoordinatesOfMissingCubes
void findCoordinatesOfMissingCubes(LongList< meshOctreeCubeCoordinates > &coordinates) const
find coordinates of cubes which are located on other processors
Definition: meshOctreeCubeRecursiveFunctions.C:207
Foam::meshOctreeCube::operator<<
friend Ostream & operator<<(Ostream &, const meshOctreeCube &)
Definition: meshOctreeCube.C:161
Foam::meshOctreeCube::cubeLabel
label cubeLabel() const
position of the cube in the list of leaves
Definition: meshOctreeCubeI.H:76
Foam::meshOctreeCube::hasContainedElements
bool hasContainedElements() const
return true if the box contains some triangles
Definition: meshOctreeCubeI.H:81
Foam::meshOctreeCube::subCube
meshOctreeCube * subCube(const label) const
return a pointer to a child cubes at given position
Definition: meshOctreeCubeI.H:71
Foam::meshOctreeCube::containedElementsLabel_
label containedElementsLabel_
label of the row which contains elements contained in the cube
Definition: meshOctreeCube.H:70
Foam::meshOctreeCube::leavesInSphere
void leavesInSphere(const boundBox &rootBox, const point &, const scalar, DynList< label > &) const
find leaves within a sphere
Definition: meshOctreeCubeRecursiveFunctions.C:89
Foam::meshOctreeCube::~meshOctreeCube
~meshOctreeCube()
Definition: meshOctreeCube.C:139
Foam::meshOctreeCubeBasic::coordinates
const meshOctreeCubeCoordinates & coordinates() const
return coordinates in the octree
Definition: meshOctreeCubeBasicI.H:90
Foam::meshOctreeCube::countChildCubes
void countChildCubes(label &nCubes) const
count number of originating from this cube
Definition: meshOctreeCubeRecursiveFunctions.C:229
Foam::meshOctreeCube::hasContainedEdges
bool hasContainedEdges() const
returns true if the box contains some edges
Definition: meshOctreeCubeI.H:94
Foam::meshOctreeSlot
Definition: meshOctreeSlot.H:50
Foam::LongList
Definition: LongList.H:55
meshOctreeCubeBasic.H
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
meshOctreeCubeI.H
Foam::meshOctreeCube::cubeLabel_
label cubeLabel_
position of the cube in the list of leaves
Definition: meshOctreeCube.H:67
Foam::meshOctreeCube::subCubesPtr_
meshOctreeCube ** subCubesPtr_
pointer to the first child element
Definition: meshOctreeCube.H:64
Foam::meshOctreeCube::subCubes
FixedList< meshOctreeCube *, 8 > subCubes() const
return the pointers to the sons
Definition: meshOctreeCube.C:144
Foam::meshOctreeCube::isLeaf
bool isLeaf() const
check if the cube is a leaf
Definition: meshOctreeCubeI.H:63
Foam::meshOctreeCube::findContainedEdges
void findContainedEdges(const triSurf &, const boundBox &)
find edges contained in the cube
Definition: meshOctreeCubeRefine.C:46
Foam::meshOctreeCube::operator=
void operator=(const meshOctreeCube &)
assignment
Definition: meshOctreeCubeI.H:107
Foam::meshOctreeCube::refineMissingCube
void refineMissingCube(const triSurf &, const boundBox &, const label scI, meshOctreeSlot *slotPtr=NULL)
Definition: meshOctreeCubeRefine.C:340
Foam::meshOctreeCube::leavesInBox
void leavesInBox(const boundBox &rootBox, const boundBox &searchingBox, DynList< const meshOctreeCube *, 256 > &) const
leaves contained in the given box
Definition: meshOctreeCubeRecursiveFunctions.C:43
Foam::meshOctreeCube::slotPtr
const meshOctreeSlot * slotPtr() const
return the pointer to the slot containing the cube
Definition: meshOctreeCubeI.H:58
Foam::meshOctreeCube::hOrient_
static const label hOrient_[24][8]
Definition: meshOctreeCube.H:85
Foam::meshOctreeCube::markLeavesInSphere
void markLeavesInSphere(const boundBox &rootBox, const point &, const scalar, labelList &, bool &) const
mark leaves within a sphere
Definition: meshOctreeCubeRecursiveFunctions.C:135
Foam::meshOctreeCube::purgeProcessorCubes
bool purgeProcessorCubes(const short procNo)
delete boxes which are not local to the given processor
Definition: meshOctreeCubeRecursiveFunctions.C:247
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::meshOctreeCube::containedEdgesLabel_
label containedEdgesLabel_
labels of contained surface edges
Definition: meshOctreeCube.H:73
Foam::DynList
Definition: DynList.H:53
Foam::meshOctreeCube::meshOctreeCube
meshOctreeCube()
Default constructor.
Definition: meshOctreeCubeI.H:38
Foam::meshOctreeCube::hOrder_
static const label hOrder_[24][8]
Definition: meshOctreeCube.H:81
Foam::meshOctreeCube::activeSlotPtr_
meshOctreeSlot * activeSlotPtr_
pointer the slot containing this cube
Definition: meshOctreeCube.H:61
Foam::Vector< scalar >
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
VRWGraph
This class is an implementation of a graph with variable column width. The imoplementation is memory ...
triSurf
A class for triangulated surface used in the meshing process. It is derived from points and facets wi...
Foam::FixedList
A 1D vector of objects of type <T> with a fixed size <Size>.
Definition: FixedList.H:53
Foam::meshOctreeCube
Definition: meshOctreeCube.H:56
Foam::meshOctreeCubeBasic::procNo
short procNo() const
return processor number
Definition: meshOctreeCubeBasicI.H:80
Foam::boundBox
A bounding box defined in terms of the points at its extremities.
Definition: boundBox.H:55
Foam::meshOctreeCube::refineCube2D
void refineCube2D(const triSurf &, const boundBox &, meshOctreeSlot *slotPtr=NULL)
refine cube in two directions, it is used for generating quadtrees
Definition: meshOctreeCubeRefine.C:102
Foam::meshOctreeCube::containedElements
label containedElements() const
Definition: meshOctreeCubeI.H:89
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
Foam::VRWGraph
Definition: VRWGraph.H:101
Foam::triSurf
Definition: triSurf.H:59
Foam::meshOctreeCube::findLeaves
void findLeaves(LongList< meshOctreeCube * > &leaves) const
find leaves for a given cube
Definition: meshOctreeCubeRecursiveFunctions.C:184
DynList.H
Foam::meshOctreeCubeBasic
Definition: meshOctreeCubeBasic.H:49
Foam::meshOctreeCube::hasContainedTriangles
bool hasContainedTriangles(const triSurf &, const boundBox &, const VRWGraph &containedElements) const
check if this box has some contained triangles
Definition: meshOctreeCubeIntersections.C:43