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 Automatic octree for mesh generation. This class checks if the current
29 octree resolution is enough to resolve all surface features
32 meshOctreeAddressing.C
34 \*---------------------------------------------------------------------------*/
36 #ifndef meshOctreeAddressing_H
37 #define meshOctreeAddressing_H
41 #include "meshOctreeCubeCoordinates.H"
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
52 // Forward declarations
56 /*---------------------------------------------------------------------------*\
57 Class meshOctreeAddressing Declaration
58 \*---------------------------------------------------------------------------*/
60 class meshOctreeAddressing
63 //- reference to the octree
64 const meshOctree& octree_;
66 //- reference to the dictionary
67 const dictionary& meshDict_;
72 //- number of created octree nodes
73 mutable label nNodes_;
75 //- coordinates of octree nodes
76 mutable pointField* octreePointsPtr_;
79 mutable VRWGraph* nodeLabelsPtr_;
82 mutable FRWGraph<label, 8>* nodeLeavesPtr_;
84 //- identify which boxes should be used as mesh cells
85 mutable List<direction>* boxTypePtr_;
87 //- identify created nodes as OUTERNODE or INNERNODE
88 mutable List<direction>* nodeTypePtr_;
90 // Additional addressing useful for some algorithms
91 //- faces of the octree
92 mutable VRWGraph* octreeFacesPtr_;
93 mutable labelLongList* octreeFacesOwnersPtr_;
94 mutable labelLongList* octreeFacesNeighboursPtr_;
96 //- octree box-faces addressing
97 mutable VRWGraph* leafFacesPtr_;
99 //- node-faces addressing
100 mutable VRWGraph* nodeFacesPtr_;
102 //- leaf-leaves addressing
103 mutable VRWGraph* leafLeavesPtr_;
105 //- edges of the octree
106 mutable LongList<edge>* octreeEdgesPtr_;
108 //- edges-leaves addressing
109 mutable VRWGraph* edgeLeavesPtr_;
111 //- leaf-edges addressing
112 mutable VRWGraph* leafEdgesPtr_;
114 //- node-edges addressing
115 mutable VRWGraph* nodeEdgesPtr_;
117 //- face-edges addressing
118 mutable VRWGraph* faceEdgesPtr_;
120 //- edge-faces addressing
121 mutable VRWGraph* edgeFacesPtr_;
123 //- global octree point label
124 mutable labelLongList* globalPointLabelPtr_;
126 //- global point to local label addressing
127 mutable Map<label>* globalPointToLocalPtr_;
129 //- point-processors addressing
130 mutable VRWGraph* pointProcsPtr_;
132 //- global octree face label
133 mutable labelLongList* globalFaceLabelPtr_;
135 //- global face label to local label addressing
136 mutable Map<label>* globalFaceToLocalPtr_;
138 //- face-processors addressing
139 mutable VRWGraph* faceProcsPtr_;
141 //- global leaf label
142 mutable labelLongList* globalLeafLabelPtr_;
144 //- global leaf label to local label addressing for octree leaves
145 mutable Map<label>* globalLeafToLocalPtr_;
148 mutable VRWGraph* leafAtProcsPtr_;
150 // Private member functions
151 //- calculate octreePointsPtr_
152 void createOctreePoints() const;
154 //- calculate nodeLabelsPtr_
155 void createNodeLabels() const;
157 //- calculate nodeLeavesPtr_
158 void createNodeLeaves() const;
160 //- assemble boxTypePtr_ list
161 void findUsedBoxes() const;
163 //- calculate nodeTypePtr_
164 void calculateNodeType() const;
167 void createOctreeFaces() const;
169 //- calculate leaf-faces addressing
170 void calculateLeafFaces() const;
172 //- calculate node-faces addressing
173 void calculateNodeFaces() const;
175 //- calculate leaf-leaves addressing
176 void calculateLeafLeaves() const;
179 void createOctreeEdges() const;
181 //- calculate leaf-edges
182 void calculateLeafEdges() const;
184 //- calculate edge-leaves addressing
185 void calculateEdgeLeaves() const;
187 //- calculate edge-faces
188 void calculateEdgeFaces() const;
190 //- Clear allocated data
192 void clearBoxTypes();
193 void clearNodeAddressing();
194 void clearOctreeFaces();
195 void clearAddressing();
196 void clearParallelAddressing();
198 //- check if distinct parts are glued together
199 void checkGluedRegions();
201 // Private member functions for parallel runs
203 void calcGlobalPointLabels() const;
204 void calcGlobalFaceLabels() const;
205 void calcGlobalLeafLabels() const;
207 // Private copy constructor
208 //- Disallow default bitwise copy construct
209 meshOctreeAddressing(const meshOctreeAddressing&);
211 //- Disallow default bitwise assignment
212 void operator=(const meshOctreeAddressing&);
218 //- Construct from surface and dictionary
221 const meshOctree& mo,
222 const dictionary& dict,
223 bool useDATABoxes = false
228 ~meshOctreeAddressing();
245 //- check if there exist any non-signly connected edges and vertices
246 //- in the octree mesh. This is primarily needed
247 //- for the cartesian template
248 void checkAndFixIrregularConnections();
250 //- return number of octree nodes
251 inline label numberOfNodes() const;
253 //- return coordinates of octree vertices
254 inline const pointField& octreePoints() const;
256 //- return nodeLabels
257 inline const VRWGraph& nodeLabels() const;
259 //- return nodeLeaves
260 inline const FRWGraph<label, 8>& nodeLeaves() const;
262 //- return which octree boxes are used for mesh creation
263 inline const List<direction>& boxType() const;
265 //- return type of node (INNERNODE,or OUTERNODE)
266 inline const List<direction>& nodeType() const;
269 inline void setBoxType(const label boxI, const direction type);
271 //- return octree faces, created for MESHCELL boxes
272 inline const VRWGraph& octreeFaces() const;
274 //- return owners of octree faces
275 inline const labelLongList& octreeFaceOwner() const;
277 //- return neighbours of octree faces
278 inline const labelLongList& octreeFaceNeighbour() const;
280 //- return octree box-faces addressing
281 inline const VRWGraph& leafFaces() const;
283 //- checks if the face is intersected by the surface
284 bool isIntersectedFace(const label fI) const;
286 //- return leaf-leaves addressing
287 inline const VRWGraph& leafLeaves() const;
289 //- return node-faces addressing
290 inline const VRWGraph& nodeFaces() const;
292 //- return octree edges, created for MESHCELL boxes
293 inline const LongList<edge>& octreeEdges() const;
295 //- return edge-leaves addressing
296 inline const VRWGraph& edgeLeaves() const;
298 //- return leaf-edges addressing
299 inline const VRWGraph& leafEdges() const;
301 //- checks if the edge is intersected by the surface
302 bool isIntersectedEdge(const label eI) const;
303 void edgeIntersections
306 DynList<point>& intersections
309 //- return node-edges addressing
310 inline const VRWGraph& nodeEdges() const;
312 //- return face-edges addressing
313 inline const VRWGraph& faceEdges() const;
315 //- return edge-faces addressing
316 inline const VRWGraph& edgeFaces() const;
318 //- return const reference to meshOctree
319 inline const meshOctree& octree() const;
321 //- find cubes around an edge (cubes must be at the same level)
326 FixedList<label, 4>& edgeCubes
329 //- find edge centre if it exists
330 label findEdgeCentre(const label leafI, const direction eI) const;
332 // Access to data needed for parallel execution
334 //- return global point labels
335 inline const labelLongList& globalPointLabel() const;
337 //- global point label to local label. Only for processors points
338 inline const Map<label>& globalToLocalPointAddressing() const;
340 //- processors which contain an octree point
341 inline const VRWGraph& pointAtProcs() const;
343 //- return global labels of octree faces
344 inline const labelLongList& globalFaceLabel() const;
346 //- return global face label to face label. Only for processor faces
347 inline const Map<label>& globalToLocalFaceAddressing() const;
349 //- return processors which contain each octree face
350 inline const VRWGraph& faceAtProcs() const;
352 //- return global labels of octree leaves
353 inline const labelLongList& globalLeafLabel() const;
355 //- return processors which contain each octree leaf
356 inline const VRWGraph& leafAtProcs() const;
358 //- return global leaf label to local label addressing
359 inline const Map<label>& globalToLocalLeafAddressing() const;
362 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
364 } // End namespace Foam
366 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
368 #include "meshOctreeAddressingI.H"
370 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
374 // ************************************************************************* //