Loading...
Searching...
No Matches
box.H
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2017-2023 OpenCFD Ltd.
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26Class
27 Foam::processorLODs::box
28
29Description
30 Creates the parallel distribution map by describing the source and target
31 objects using box shapes.
32
33 A single box is created for the source object, which is then split using
34 2x2x2 refinement based on the number of remote target objects that overlap.
35 The refinement is local between communicating processor pairs, where the
36 refinement continues until a threshold number of remote target objects per
37 source box is achieved.
38
39\*---------------------------------------------------------------------------*/
40
41#ifndef Foam_processorLODs_box
42#define Foam_processorLODs_box
43
44#include "processorLOD.H"
45#include "treeBoundBox.H"
46#include "HashSet.H"
47
48// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49
50namespace Foam
51{
53{
54
55/*---------------------------------------------------------------------------*\
56 Class Box Declaration
57\*---------------------------------------------------------------------------*/
58
59class box
60:
61 public processorLOD
62{
63protected:
64
65 // Protected Data
66
67 // Flags to indicate what to do with a box
68
69 //- Drop/discard
70 static const label DROP;
71
72 //- Refine
73 static const label REFINE;
74
75 //- Fixed - do not touch
76 static const label FIXED;
77
78
79 //- Reference to the source points
82 //- Reference to the target points
84
85 //- Per processor, the list of src bound boxes
86 // Note: using treeBoundBox to take advantage of subBbox() method
88
89 //- Maximum number of refinement iterations
90 label nRefineIterMax_;
91
92
93 // Caching controls
94
95 //- Number of iterations before element indices are cached
96 static const label nStartUpIter;
97
98 //- Addressing per proc of new to old bound boxes
100
101 //- Indices of elements in the src boxes
103
104
105 // Private Member Functions
107 //- Helper function to write the boxes in OBJ format
108 void writeBoxes
109 (
110 const List<DynamicList<treeBoundBox>>& fixedBoxes,
111 const label iter
112 ) const;
113
114
115 //- The local boundBox associated with given source object
116 virtual treeBoundBox calcSrcBox(const label srcObji) const = 0;
117
118 //- The local boundBox associated with given target object
119 virtual treeBoundBox calcTgtBox(const label tgtObji) const = 0;
120
121 //- Set the box refinement flags
122 void setRefineFlags
123 (
124 const label refineIter,
125 const label nTgtObjects,
126 List<labelHashSet>& fixedSendElems,
127 List<List<labelList>>& localTgtElems,
128 List<labelList>& refineFlags,
129 labelList& nElems
130 ) const;
131
132 void refineBox
133 (
134 const label boxi,
135 const label refineIter,
136 const label nSrcElem,
137 const treeBoundBox& origBox,
138 DynamicList<treeBoundBox>& procBoxes,
140 DynamicList<label>& procNewToOld
141 ) const;
142
143 void refineBox
144 (
145 const label boxi,
146 const labelList& srcAddr,
147 const treeBoundBox& origBox,
148 DynamicList<treeBoundBox>& procBoxes,
149 DynamicList<labelList>& procBoxElems,
150 DynamicList<label>& procNewToOld
151 ) const;
152
153
154 //- Apply the box refinements
155 // \return true if still refining
156 bool doRefineBoxes
157 (
158 const label refineIter,
159 const label nSrcFaces,
160 const List<labelList>& refineFlags,
162 );
163
164 //- Return the parallel distribution map
165 //- (often linear construct order)
167 (
168 const label nSrcElems,
169 const label nTgtElems,
170 const mapDistributeBase::layoutTypes constructLayout
171 );
172
173
174public:
175
176 //- Runtime type information
177 TypeName("box");
178
179 // Constructors
180
181 //- Construct from list of points for source and target
182 box
183 (
184 const UList<point>& srcPoints,
185 const UList<point>& tgtPoints,
186 const label maxObjectsPerLeaf,
187 const label nObjectsOfType,
188 const label nRefineIterMax = 100
189 );
190
191
192 //- Destructor
193 virtual ~box() = default;
194};
195
196
197// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
198
199} // End namespace processorLODs
200} // End namespace Foam
201
202// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
203
204#endif
205
206// ************************************************************************* //
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Definition DynamicList.H:68
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition List.H:72
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition UList.H:89
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition autoPtr.H:65
layoutTypes
The map layout (eg, of the constructMap).
processorLOD(const label maxObjectsPerLeaf, const label nObjectsOfType) noexcept
Construct from components.
void setRefineFlags(const label refineIter, const label nTgtObjects, List< labelHashSet > &fixedSendElems, List< List< labelList > > &localTgtElems, List< labelList > &refineFlags, labelList &nElems) const
Set the box refinement flags.
Definition box.C:89
label nRefineIterMax_
Maximum number of refinement iterations.
Definition box.H:98
List< labelList > newToOld_
Addressing per proc of new to old bound boxes.
Definition box.H:111
void refineBox(const label boxi, const label refineIter, const label nSrcElem, const treeBoundBox &origBox, DynamicList< treeBoundBox > &procBoxes, DynamicList< labelList > &procBoxElems, DynamicList< label > &procNewToOld) const
Definition box.C:209
virtual treeBoundBox calcSrcBox(const label srcObji) const =0
The local boundBox associated with given source object.
static const label DROP
Drop/discard.
Definition box.H:65
static const label FIXED
Fixed - do not touch.
Definition box.H:75
static const label nStartUpIter
Number of iterations before element indices are cached.
Definition box.H:106
box(const UList< point > &srcPoints, const UList< point > &tgtPoints, const label maxObjectsPerLeaf, const label nObjectsOfType, const label nRefineIterMax=100)
Construct from list of points for source and target.
Definition box.C:533
List< List< treeBoundBox > > boxes_
Per processor, the list of src bound boxes.
Definition box.H:93
void writeBoxes(const List< DynamicList< treeBoundBox > > &fixedBoxes, const label iter) const
Helper function to write the boxes in OBJ format.
Definition box.C:42
bool doRefineBoxes(const label refineIter, const label nSrcFaces, const List< labelList > &refineFlags, List< DynamicList< treeBoundBox > > &fixedBoxes)
Apply the box refinements.
Definition box.C:304
virtual ~box()=default
Destructor.
TypeName("box")
Runtime type information.
autoPtr< mapDistribute > createMap(const label nSrcElems, const label nTgtElems, const mapDistributeBase::layoutTypes constructLayout)
Return the parallel distribution map (often linear construct order).
Definition box.C:409
static const label REFINE
Refine.
Definition box.H:70
const UList< point > & tgtPoints_
Reference to the target points.
Definition box.H:86
virtual treeBoundBox calcTgtBox(const label tgtObji) const =0
The local boundBox associated with given target object.
const UList< point > & srcPoints_
Reference to the source points.
Definition box.H:81
List< List< labelList > > boxSrcElems_
Indices of elements in the src boxes.
Definition box.H:116
Standard boundBox with extra functionality for use in octree.
Namespace for OpenFOAM.
List< label > labelList
A List of labels.
Definition List.H:62
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition typeInfo.H:68