meshOctreeModifier.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  meshOctreeModifier
26 
27 Description
28  Octree for mesh generation
29 
30 SourceFiles
31  meshOctreeModifier.C
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef meshOctreeModifier_H
36 #define meshOctreeModifier_H
37 
38 #include "meshOctree.H"
39 
40 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
41 
42 namespace Foam
43 {
44 
45 /*---------------------------------------------------------------------------*\
46  Class meshOctreeModifier Declaration
47 \*---------------------------------------------------------------------------*/
48 
50 {
51  // Private data
52  //- Reference to the octree
54 
55  // Private member functions
56  //- correct refinement such that it produces 1-irregular octree
57  void ensureCorrectRegularity(labelList& refineBox);
58 
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(labelList& refineBox);
62 
63  // Private copy constructor
64  //- Disallow default bitwise copy construct
66 
67  //- Disallow default bitwise assignment
68  void operator=(const meshOctreeModifier&);
69 
70 public:
71 
72  // Constructors
73 
74  //- Construct from octree
76 
77  // Destructor
78 
80 
81 
82  // Member Functions
83  //- return octree
84  inline const meshOctree& octree() const;
85 
86  //- return neighbour processors
87  inline labelList& neiProcsAccess();
88 
89  //- return rootBox
90  inline boundBox& rootBoxAccess();
91 
92  //- return isRootInitialised_
93  inline bool& isRootInitialisedAccess();
94 
95  //- return search range
96  inline scalar& searchRangeAccess();
97 
98  //- return the range of leaves at each processor
100 
101  //- return initial cube
103 
104  //- return octree slots
106 
107  //- return the pointer to the meshOctreeCube at the given position
109  (
111  ) const;
112 
113  //- find leaves contained in a given boundBox
114  inline void findLeavesContainedInBox
115  (
116  const boundBox&,
118  ) const;
119 
120  //- return leaves
122 
123  //- create leaves
124  inline void createListOfLeaves();
125 
126  //- mark additional layers around the leaves selected for refinement
128  (
129  labelList& refineBox,
130  const label nLayers = 1
131  ) const;
132 
133  //- mark additional layers around the leaves selected for refinement
135  (
136  labelList& refineBox,
137  const label nLayers = 1
138  ) const;
139 
140  //- mark additional layers around the leaves selected for refinement
141  //- given on a box-by-box basis
142  //- returns the number of boxes selected for refinement
144  (
145  labelList& refineBox,
146  labelList& nLayers,
147  List<direction>& targetRefLevel
148  ) const;
149 
150  //- refine leaves marked for refinement
151  //- hexRefinement is activated when it is required to refine all
152  //- sons of the same father, if a single son gets marked for refinement
154  (
155  labelList& refineBox,
156  const bool hexRefinement = false
157  );
158 
159  //- refine selected boxes and the boxes within the given range
161  (
162  labelList& refineBox,
163  const scalarList& refThickness
164  );
165 
166  // functions for parallel runs
167  //- distribute leaves of the initial octree to processors
168  //- each processor creates a list of neighbouring processors
170 
171  //- move octree cubes from one processor to another
172  void loadDistribution(const direction usedType = 0);
173 
174  //- refine the tree to add cubes transferred from other processors
176  (
178  const short procNo = Pstream::myProcNo(),
179  const direction cubeType = meshOctreeCubeBasic::UNKNOWN
180  );
181 
183  (
185  const labelList& containedTriangles,
186  const labelList& containedEdges,
187  const short procNo = Pstream::myProcNo(),
188  const direction cubeType = meshOctreeCubeBasic::UNKNOWN
189 
190  );
191 
192  //- update the communication pattern between the processors
193  //- this function is used for load balancing
195 
196  //- add an additional layer of boxes which belongs to the neighbouring
197  //- processors. This simplifies the process of extracting the mesh
198  //- template from the octree in a parallel run
200 
201  //- reduce memory consumption by deleting unnecessary data
203 };
204 
205 
206 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
207 
208 } // End namespace Foam
209 
210 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
211 
212 #include "meshOctreeModifierI.H"
213 
214 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
215 
216 #endif
217 
218 // ************************************************************************* //
Foam::meshOctreeModifier::findCubeForPosition
meshOctreeCube * findCubeForPosition(const meshOctreeCubeCoordinates &) const
return the pointer to the meshOctreeCube at the given position
Definition: meshOctreeModifierI.H:78
Foam::meshOctreeModifier::searchRangeAccess
scalar & searchRangeAccess()
return search range
Definition: meshOctreeModifierI.H:56
Foam::meshOctreeModifier::refineSelectedBoxesAndAdditionalLayers
void refineSelectedBoxesAndAdditionalLayers(labelList &refineBox, const scalarList &refThickness)
refine selected boxes and the boxes within the given range
Definition: meshOctreeModifierRefineSelectedBoxes.C:500
Foam::meshOctreeModifier::refineTreeForCoordinates
void refineTreeForCoordinates(const meshOctreeCubeCoordinates &, const short procNo=Pstream::myProcNo(), const direction cubeType=meshOctreeCubeBasic::UNKNOWN)
refine the tree to add cubes transferred from other processors
Definition: meshOctreeModifierParallelRefinement.C:44
Foam::meshOctreeCubeCoordinates
Definition: meshOctreeCubeCoordinates.H:55
Foam::meshOctreeModifier::addLayerFromNeighbouringProcessors
void addLayerFromNeighbouringProcessors()
Definition: meshOctreeModifierParallelRefinement.C:200
Foam::meshOctreeModifier::rootBoxAccess
boundBox & rootBoxAccess()
return rootBox
Definition: meshOctreeModifierI.H:46
Foam::meshOctreeModifier::distributeLeavesToProcessors
void distributeLeavesToProcessors()
Definition: meshOctreeModifierDistributeLeavesToProcessors.C:39
Foam::meshOctreeModifier::dataSlotsAccess
List< meshOctreeSlot > & dataSlotsAccess()
return octree slots
Definition: meshOctreeModifierI.H:72
Foam::meshOctreeCubeBasic::UNKNOWN
@ UNKNOWN
Definition: meshOctreeCubeBasic.H:88
Foam::meshOctreeModifier::reduceMemoryConsumption
void reduceMemoryConsumption()
reduce memory consumption by deleting unnecessary data
Definition: meshOctreeModifierReduceMemoryConsumption.C:41
meshOctree.H
Foam::meshOctreeModifier
Definition: meshOctreeModifier.H:48
Foam::meshOctreeModifier::refineSelectedBoxes
void refineSelectedBoxes(labelList &refineBox, const bool hexRefinement=false)
Definition: meshOctreeModifierRefineSelectedBoxes.C:428
Foam::LongList
Definition: LongList.H:55
Foam::meshOctreeModifier::findLeavesContainedInBox
void findLeavesContainedInBox(const boundBox &, DynList< const meshOctreeCube *, 256 > &) const
find leaves contained in a given boundBox
Definition: meshOctreeModifierI.H:86
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
Foam::meshOctreeModifier::loadDistribution
void loadDistribution(const direction usedType=0)
move octree cubes from one processor to another
Definition: meshOctreeModifierLoadDistribution.C:51
Foam::meshOctreeModifier::neiProcsAccess
labelList & neiProcsAccess()
return neighbour processors
Definition: meshOctreeModifierI.H:41
Foam::meshOctreeModifier::meshOctreeModifier
meshOctreeModifier(const meshOctreeModifier &)
Disallow default bitwise copy construct.
Foam::meshOctreeModifier::isRootInitialisedAccess
bool & isRootInitialisedAccess()
return isRootInitialised_
Definition: meshOctreeModifierI.H:51
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::DynList
Definition: DynList.H:53
Foam::meshOctreeModifier::updateCommunicationPattern
void updateCommunicationPattern()
Definition: meshOctreeModifierUpdateCommunicationPattern.C:45
Foam::UPstream::myProcNo
static int myProcNo(const label communicator=0)
Number of this process (starting from masterNo() = 0)
Definition: UPstream.H:405
Foam::meshOctreeModifier::octree
const meshOctree & octree() const
return octree
Definition: meshOctreeModifierI.H:36
Foam::meshOctreeModifier::initialCubeAccess
meshOctreeCube & initialCubeAccess()
return initial cube
Definition: meshOctreeModifierI.H:67
meshOctreeModifierI.H
Foam::meshOctreeModifier::ensureCorrectRegularity
void ensureCorrectRegularity(labelList &refineBox)
correct refinement such that it produces 1-irregular octree
Definition: meshOctreeModifierEnsureCorrectRegularity.C:44
Foam::meshOctreeModifier::markAdditionalLayersOfFaceNeighbours
void markAdditionalLayersOfFaceNeighbours(labelList &refineBox, const label nLayers=1) const
mark additional layers around the leaves selected for refinement
Definition: meshOctreeModifierRefineSelectedBoxes.C:148
Foam::meshOctreeModifier::markAdditionalLayers
void markAdditionalLayers(labelList &refineBox, const label nLayers=1) const
mark additional layers around the leaves selected for refinement
Definition: meshOctreeModifierRefineSelectedBoxes.C:53
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
Foam::meshOctreeModifier::ensureCorrectRegularitySons
bool ensureCorrectRegularitySons(labelList &refineBox)
Definition: meshOctreeModifierEnsureCorrectRegularity.C:197
Foam::meshOctree
Definition: meshOctree.H:55
Foam::meshOctreeCube
Definition: meshOctreeCube.H:56
Foam::direction
unsigned char direction
Definition: direction.H:43
Foam::boundBox
A bounding box defined in terms of the points at its extremities.
Definition: boundBox.H:55
Foam::meshOctreeModifier::neiRangeAccess
List< Pair< meshOctreeCubeCoordinates > > & neiRangeAccess()
return the range of leaves at each processor
Definition: meshOctreeModifierI.H:62
Foam::meshOctreeModifier::~meshOctreeModifier
~meshOctreeModifier()
Definition: meshOctreeModifier.C:52
Foam::meshOctreeModifier::operator=
void operator=(const meshOctreeModifier &)
Disallow default bitwise assignment.
Foam::meshOctreeModifier::createListOfLeaves
void createListOfLeaves()
create leaves
Definition: meshOctreeModifierI.H:100
Foam::meshOctreeModifier::leavesAccess
LongList< meshOctreeCube * > & leavesAccess()
return leaves
Definition: meshOctreeModifierI.H:95
Foam::meshOctreeModifier::octree_
meshOctree & octree_
Reference to the octree.
Definition: meshOctreeModifier.H:52