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 Octree for mesh generation
33 \*---------------------------------------------------------------------------*/
35 #ifndef meshOctreeModifier_H
36 #define meshOctreeModifier_H
38 #include "meshOctree.H"
40 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 /*---------------------------------------------------------------------------*\
46 Class meshOctreeModifier Declaration
47 \*---------------------------------------------------------------------------*/
49 class meshOctreeModifier
52 //- Reference to the octree
55 // Private member functions
56 //- correct refinement such that it produces 1-irregular octree
57 void ensureCorrectRegularity(List<direction>& refineBox);
59 //- add additional refinement with the following rule. If a son
60 //- of a father box is refined, then refine all other sons
61 bool ensureCorrectRegularitySons(List<direction>& refineBox);
63 // Private copy constructor
64 //- Disallow default bitwise copy construct
65 meshOctreeModifier(const meshOctreeModifier&);
67 //- Disallow default bitwise assignment
68 void operator=(const meshOctreeModifier&);
74 //- Construct from octree
75 meshOctreeModifier(meshOctree&);
79 ~meshOctreeModifier();
84 inline const meshOctree& octree() const;
86 //- return neighbour processors
87 inline labelList& neiProcsAccess();
90 inline boundBox& rootBoxAccess();
92 //- return isRootInitialised_
93 inline bool& isRootInitialisedAccess();
95 //- return search range
96 inline scalar& searchRangeAccess();
98 //- return the range of leaves at each processor
99 inline List<Pair<meshOctreeCubeCoordinates> >& neiRangeAccess();
101 //- return initial cube
102 inline meshOctreeCube& initialCubeAccess();
104 //- return octree slots
105 inline List<meshOctreeSlot>& dataSlotsAccess();
107 //- return the pointer to the meshOctreeCube at the given position
108 inline meshOctreeCube* findCubeForPosition
110 const meshOctreeCubeCoordinates&
113 //- find leaves contained in a given boundBox
114 inline void findLeavesContainedInBox
117 DynList<const meshOctreeCube*, 256>&
121 inline LongList<meshOctreeCube*>& leavesAccess();
124 inline void createListOfLeaves();
126 //- mark additional layers around the leaves selected for refinement
127 void markAdditionalLayers
129 List<direction>& refineBox,
130 const direction nLayers = 1
133 //- refine leaves marked for refinement
134 //- hexRefinement is activated when it is required to refine all
135 //- sons of the same father, if a single son gets marked for refinement
136 void refineSelectedBoxes
138 List<direction>& refineBox,
139 const bool hexRefinement = false
142 // functions for parallel runs
143 //- distribute leaves of the initial octree to processors
144 //- each processor creates a list of neighbouring processors
145 void distributeLeavesToProcessors();
147 //- move octree cubes from one processor to another
148 void loadDistribution(const direction usedType = 0);
150 //- refine the tree to add cubes transferred from other processors
151 void refineTreeForCoordinates
153 const meshOctreeCubeCoordinates&,
154 const short procNo = Pstream::myProcNo(),
155 const direction cubeType = meshOctreeCubeBasic::UNKNOWN
158 void refineTreeForCoordinates
160 const meshOctreeCubeCoordinates&,
161 const labelList& containedTriangles,
162 const labelList& containedEdges,
163 const short procNo = Pstream::myProcNo(),
164 const direction cubeType = meshOctreeCubeBasic::UNKNOWN
168 //- update the communication pattern between the processors
169 //- this function is used for load balancing
170 void updateCommunicationPattern();
172 //- add an additional layer of boxes which belongs to the neighbouring
173 //- processors. This simplifies the process of extracting the mesh
174 //- template from the octree in a parallel run
175 void addLayerFromNeighbouringProcessors();
177 //- reduce memory consumption by deleting unnecessary data
178 void reduceMemoryConsumption();
182 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
184 } // End namespace Foam
186 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
188 #include "meshOctreeModifierI.H"
190 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
194 // ************************************************************************* //