1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | cfMesh: A library for mesh generation
5 \\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
6 \\/ M anipulation | Copyright (C) Creative Fields, Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of cfMesh.
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.
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
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/>.
28 A cube stores information needed for mesh generation
33 \*---------------------------------------------------------------------------*/
35 #ifndef meshOctreeCube_H
36 #define meshOctreeCube_H
41 #include "meshOctreeCubeBasic.H"
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
53 /*---------------------------------------------------------------------------*\
54 Class meshOctreeCube Declaration
55 \*---------------------------------------------------------------------------*/
58 : public meshOctreeCubeBasic
61 //- pointer the slot containing this cube
62 meshOctreeSlot* activeSlotPtr_;
64 //- pointer to the first child element
65 meshOctreeCube** subCubesPtr_;
67 //- position of the cube in the list of leaves
68 mutable label cubeLabel_;
70 //- label of the row which contains elements contained in the cube
71 label containedElementsLabel_;
73 //- labels of contained surface edges
74 label containedEdgesLabel_;
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];
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];
88 // Private member functions
89 //- find edges contained in the cube
90 void findContainedEdges
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);
100 //- Disallow default bitwise copy construct
101 meshOctreeCube(const meshOctreeCube&);
103 //- Disallow copy construct from meshOctreeCubeBasic
104 meshOctreeCube(const meshOctreeCubeBasic&);
110 //- Default constructor
111 inline meshOctreeCube();
113 //- Construct from coordinates
114 meshOctreeCube(const meshOctreeCubeCoordinates&);
116 //- Construct from coordinates and the number of surface triangles
117 //- this constructor is used for the initial cube, only
120 const meshOctreeCubeCoordinates& cc,
122 meshOctreeSlot* slotPtr
131 //- refine cube in two directions, it is used for generating quadtrees
136 meshOctreeSlot* slotPtr = NULL
139 //- subdivide the octree cube
144 meshOctreeSlot* slotPtr = NULL
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
154 meshOctreeSlot* slotPtr = NULL
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
163 const label elementsRowI = -1,
164 const label edgesRowI = -1,
165 meshOctreeSlot* slotPtr = NULL
168 //- return the pointer to the slot containing the cube
169 inline const meshOctreeSlot* slotPtr() const;
171 //- position of the cube in the list of leaves
172 inline label cubeLabel() const;
174 //- check if the cube is a leaf
175 inline bool isLeaf() const;
177 //- return a pointer to a child cubes at given position
178 inline meshOctreeCube* subCube(const label) const;
180 //- return the pointers to the sons
181 FixedList<meshOctreeCube*, 8> subCubes() const;
183 //- check if this box has some contained triangles
184 bool hasContainedTriangles
188 const VRWGraph& containedElements
191 //- return true if the box contains some triangles
192 inline bool hasContainedElements() const;
194 //- returns the list of contained surface elements
195 //- this list is only allocated for cubes containing elements
196 inline label containedElements() const;
198 //- returns true if the box contains some edges
199 inline bool hasContainedEdges() const;
201 //- returns the list of contained surface edges
202 //- this list is only allocated for cubes containing edges
203 inline label containedEdges() const;
205 // Recursive functions
206 //- leaves contained in the given box
209 const boundBox& rootBox,
210 const boundBox& searchingBox,
211 DynList<const meshOctreeCube*, 256>&
214 //- find leaves for a given cube
217 LongList<meshOctreeCube*>& leaves
220 //- find coordinates of cubes which are located on other processors
221 void findCoordinatesOfMissingCubes
223 LongList<meshOctreeCubeCoordinates>& coordinates
226 //- count number of originating from this cube
227 void countChildCubes(label& nCubes) const;
229 //- delete boxes which are not local to the given processor
230 bool purgeProcessorCubes(const short procNo);
235 inline void operator=(const meshOctreeCube&);
236 friend Ostream& operator<<(Ostream&, const meshOctreeCube&);
240 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
242 } // End namespace Foam
244 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
246 #include "meshOctreeCubeI.H"
248 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
252 // ************************************************************************* //