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-2021 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 processorLODs_box
42#define processorLODs_box
43
44#include "processorLOD.H"
45#include "treeBoundBox.H"
46#include "HashSet.H"
47
48// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49
50namespace Foam
51{
52
53namespace processorLODs
54{
55
56/*---------------------------------------------------------------------------*\
57 Class Box Declaration
58\*---------------------------------------------------------------------------*/
60class box
61:
62 public processorLOD
63{
64protected:
65
66 // Protected data
67
68 // Flags to indicate what to do with a box
69
70 //- Drop/discard
71 static const label DROP;
72
73 //- Refine
74 static const label REFINE;
75
76 //- Fixed - do not touch
77 static const label FIXED;
78
79
80 //- Reference to the source points
82
83 //- Reference to the target points
85
86 //- Per processor, the list of src bound boxes
87 // Note: using treeBoundBox to take advantage of subBbox() method
89
90 //- Maximum number of refinement iterations
91 label nRefineIterMax_;
92
93
94 // Caching controls
95
96 //- Number of iterations before element indices are cached
97 static const label nStartUpIter;
98
99 //- Addressing per proc of new to old bound boxes
101
102 //- Indices of elements in the src boxes
104
105
106 // Private Member Functions
107
108 //- Helper function to write the boxes in OBJ format
109 void writeBoxes
110 (
111 const List<DynamicList<treeBoundBox>>& fixedBoxes,
112 const label iter
113 ) const;
114
116 virtual boundBox calcSrcBox(const label srcObji) const = 0;
117 virtual boundBox calcTgtBox(const label tgtObji) const = 0;
118
119 //- Set the box refinement flags
120 void setRefineFlags
121 (
122 const label refineIter,
123 const label nTgtObjects,
124 List<labelHashSet>& fixedSendElems,
125 List<List<labelList>>& localTgtElems,
126 List<labelList>& refineFlags,
127 labelList& nElems
128 ) const;
129
130 void refineBox
131 (
132 const label boxi,
133 const label refineIter,
134 const label nSrcElem,
135 const treeBoundBox& origBox,
136 DynamicList<treeBoundBox>& procBoxes,
137 DynamicList<labelList>& procBoxElems,
138 DynamicList<label>& procNewToOld
139 ) const;
140
141 void refineBox
142 (
143 const label boxi,
144 const labelList& srcAddr,
145 const treeBoundBox& origBox,
146 DynamicList<treeBoundBox>& procBoxes,
147 DynamicList<labelList>& procBoxElems,
148 DynamicList<label>& procNewToOld
149 ) const;
150
151
152 //- Apply the box refinements
153 // \return true if still refining
154 bool doRefineBoxes
155 (
156 const label refineIter,
157 const label nSrcFaces,
158 const List<labelList>& refineFlags,
160 );
161
163 (
164 const label nSrcElems,
165 const label nTgtElems
166 );
167
168 //- Use the current list of send elements to create the mapDistribute
170 (
171 List<labelList>& sendElems
172 ) const;
173
174
175public:
176
177 //- Runtime type information
178 TypeName("box");
179
180 //- Construct from list of points
181 box
182 (
183 const UList<point>& srcPoints,
184 const UList<point>& tgtPoints,
185 const label maxObjectsPerLeaf,
186 const label nObjectsOfType,
187 const label nRefineIterMax = 100
188 );
189
190 //- Destructor
191 virtual ~box() = default;
192};
193
194
195// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
196
197} // End namespace processorLODs
198
199// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
200
201} // End namespace Foam
202
203// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
204
205#endif
206
207// ************************************************************************* //
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Definition: DynamicList.H:72
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: List.H:77
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:94
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
A bounding box defined in terms of min/max extrema points.
Definition: boundBox.H:64
Base class to generate a parallel distribution map for sending sufficient target objects to cover a d...
Definition: processorLOD.H:53
Creates the parallel distribution map by describing the source and target objects using box shapes.
Definition: box.H:62
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:102
label nRefineIterMax_
Maximum number of refinement iterations.
Definition: box.H:90
virtual boundBox calcSrcBox(const label srcObji) const =0
List< labelList > newToOld_
Addressing per proc of new to old bound boxes.
Definition: box.H:99
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:224
static const label DROP
Drop/discard.
Definition: box.H:70
static const label FIXED
Fixed - do not touch.
Definition: box.H:76
autoPtr< mapDistribute > createMap(const label nSrcElems, const label nTgtElems)
Definition: box.C:424
static const label nStartUpIter
Number of iterations before element indices are cached.
Definition: box.H:96
List< List< treeBoundBox > > boxes_
Per processor, the list of src bound boxes.
Definition: box.H:87
void writeBoxes(const List< DynamicList< treeBoundBox > > &fixedBoxes, const label iter) const
Helper function to write the boxes in OBJ format.
Definition: box.C:49
bool doRefineBoxes(const label refineIter, const label nSrcFaces, const List< labelList > &refineFlags, List< DynamicList< treeBoundBox > > &fixedBoxes)
Apply the box refinements.
Definition: box.C:319
virtual ~box()=default
Destructor.
virtual boundBox calcTgtBox(const label tgtObji) const =0
TypeName("box")
Runtime type information.
static const label REFINE
Refine.
Definition: box.H:73
const UList< point > & tgtPoints_
Reference to the target points.
Definition: box.H:83
const UList< point > & srcPoints_
Reference to the source points.
Definition: box.H:80
List< List< labelList > > boxSrcElems_
Indices of elements in the src boxes.
Definition: box.H:102
autoPtr< mapDistribute > createLODMap(List< labelList > &sendElems) const
Use the current list of send elements to create the mapDistribute.
Definition: box.C:541
Standard boundBox with extra functionality for use in octree.
Definition: treeBoundBox.H:89
Namespace for OpenFOAM.
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73