regionSplit.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) 2011-2013 OpenFOAM Foundation
9 Copyright (C) 2018-2020 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27Class
28 Foam::regionSplit
29
30Description
31 This class separates the mesh into distinct unconnected regions,
32 each of which is then given a label according to globalNumbering().
33
34
35 Say 6 cells, 3 processors, with single baffle on proc1.
36
37 \verbatim
38 baffle
39 |
40 +---+---+---+---+---+---+
41 | | | | | | |
42 +---+---+---+---+---+---+
43 proc0 | proc1 | proc2
44
45 \endverbatim
46
47
48 \verbatim
49
50 1: determine local regions (uncoupled)
51
52 +---+---+---+---+---+---+
53 | 0 | 0 | 0 | 1 | 0 | 0 |
54 +---+---+---+---+---+---+
55 proc0 | proc1 | proc2
56
57 \endverbatim
58
59
60 2: make global
61
62 \verbatim
63
64 +---+---+---+---+---+---+
65 | 0 | 0 | 1 | 2 | 3 | 3 |
66 +---+---+---+---+---+---+
67 proc0 | proc1 | proc2
68
69 \endverbatim
70
71
72 3: merge connected across procs
73
74 \verbatim
75
76 +---+---+---+---+---+---+
77 | 0 | 0 | 0 | 2 | 2 | 2 |
78 +---+---+---+---+---+---+
79 proc0 | proc1 | proc2
80
81 \endverbatim
82
83
84 4. determine locally owner regions.
85
86 Determine compact numbering for the local regions and send these to
87 all processors that need them:
88
89 - proc0 uses regions:
90 - 0 which is local to it.
91 - proc1 uses regions
92 - 0 which originates from proc0
93 - 2 which is local to it
94 - proc2 uses regions
95 - 2 which originates from proc1
96
97 So proc1 needs to get the compact number for region 0 from proc0 and proc2
98 needs to get the compact number for region 2 from proc1:
99
100 \verbatim
101
102 +---+---+---+---+---+---+
103 | 0 | 0 | 0 | 1 | 1 | 1 |
104 +---+---+---+---+---+---+
105 proc0 | proc1 | proc2
106
107 \endverbatim
108
109 Can optionally keep all regions local to the processor.
110
111Note
112 does not walk across cyclicAMI/cyclicACMI - since these are not
113 \c coupled() at the patch level.
114
115SourceFiles
116 regionSplit.C
117
118\*---------------------------------------------------------------------------*/
119
120#ifndef regionSplit_H
121#define regionSplit_H
122
123#include "globalIndex.H"
124#include "labelPair.H"
125#include "bitSet.H"
126#include "boolList.H"
127#include "MeshObject.H"
128
129// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
130
131namespace Foam
132{
133
134// Forward Declarations
135class polyMesh;
136
137/*---------------------------------------------------------------------------*\
138 Class regionSplit Declaration
139\*---------------------------------------------------------------------------*/
141class regionSplit
142:
143 public MeshObject<polyMesh, TopologicalMeshObject, regionSplit>,
144 public labelList
145{
146 // Private Data
147
148 //- Indexing into the regions
149 globalIndex globalNumbering_;
150
151 //- Temporary list of cells that have changed
152 mutable DynamicList<label> changedCells_;
153
154 //- Temporary list of faces that have changed
155 mutable DynamicList<label> changedFaces_;
156
157
158 // Private Class
159
160
161 //- Simple wrapper for handling test() on bitSet or boolList
162 //- without a templating layer or lambda expresssion.
163 class bitSetOrBoolList
164 {
165 const bitSet& a_;
166 const boolList& b_;
167
168 public:
169
170 explicit bitSetOrBoolList(const bitSet& select)
171 :
172 a_(select),
173 b_(boolList::null())
174 {}
175
176 explicit bitSetOrBoolList(const boolList& select)
177 :
178 a_(bitSet::null()),
179 b_(select)
180 {}
181
182 //- Test function
183 bool test(const label i) const
184 {
185 return a_.test(i) || b_.test(i);
186 }
187 };
188
189
190 // Private Member Functions
191
192 //- Check that boundary faces are synchronised, or Fatal
193 void checkBoundaryFaceSync(const boolList& blockedFace) const;
194
195 //- Update faceRegion data between (non-processor) coupled faces.
196 void updateFacePair
197 (
198 const label face0,
199 const label face1,
200 labelList& faceRegion,
201 DynamicList<label>& facesChanged
202 ) const;
203
204 //- Given a seed cell label, fill cellRegion/faceRegion with markValue
205 //- for contiguous region around it
206 void fillSeedMask
207 (
208 const UList<labelPair>& explicitConnections,
209 const label seedCellID,
210 const label markValue,
211 labelList& cellRegion,
212 labelList& faceRegion
213 ) const;
214
215
216 //- Calculate the local region split.
217 // \return number of processor-local regions,
218 // without consolidation between procesors
219 label localRegionSplit
220 (
221 const UList<labelPair>& explicitConnections,
222 labelList& cellRegion,
223 labelList& faceRegion
224 ) const;
225
226 //- Manually consolidate regions globally by swapping information
227 // between processor domains and reducing the regions accordingly.
228 //
229 // \return globalIndex into the local regions after reduction.
230 globalIndex reduceRegionsImpl
231 (
232 const label numLocalRegions,
233 const bitSetOrBoolList& blockedFace,
234 labelList& cellRegion
235 ) const;
236
237
238public:
239
240 //- Runtime type information
241 ClassName("regionSplit");
242
243
244 // Constructors
245
246 //- Construct from mesh
248 (
249 const polyMesh& mesh,
250 const bool doGlobalRegions = Pstream::parRun()
251 );
252
253 //- Construct from mesh and whether face is blocked, optionally
254 //- with additional explicit connections between
255 //- normal boundary faces.
256 //
257 // \note blockedFace must be consistent across coupled faces!
259 (
260 const polyMesh& mesh,
261 const bitSet& blockedFace,
262 const List<labelPair>& explicitConnections = List<labelPair>(),
263 const bool doGlobalRegions = Pstream::parRun()
264 );
265
266 //- Construct from mesh and whether face is blocked, optionally
267 //- with additional explicit connections between
268 //- normal boundary faces.
269 //
270 // \note blockedFace must be consistent across coupled faces!
272 (
273 const polyMesh& mesh,
274 const boolList& blockedFace,
275 const List<labelPair>& explicitConnections = List<labelPair>(),
276 const bool doGlobalRegions = Pstream::parRun()
277 );
278
279
280 // Member Functions
281
282 //- Return global region numbering
284 {
285 return globalNumbering_;
286 }
287
288 //- Return local number of regions
289 label nLocalRegions() const
290 {
292 }
293
294 //- Return total number of regions
295 label nRegions() const
296 {
297 return globalNumbering().totalSize();
298 }
299
300 //- Manually consolidate regions globally by swapping information
301 // between processor domains and reducing the regions accordingly.
302 //
303 // \return globalIndex into the local regions after reduction.
305 (
306 const label numLocalRegions,
307 const bitSet& blockedFace,
308 labelList& cellRegion
309 ) const;
310};
311
312
313// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
314
315} // End namespace Foam
316
317// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
318
319#endif
320
321// ************************************************************************* //
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Definition: DynamicList.H:72
Templated abstract base-class for optional mesh objects used to automate their allocation to the mesh...
Definition: MeshObject.H:91
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
std::enable_if< std::is_same< bool, TypeT >::value, bool >::type test(const label i) const
Definition: UList.H:518
static bool & parRun() noexcept
Test if this a parallel run.
Definition: UPstream.H:433
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
Definition: bitSet.H:66
bool test(const label pos) const
Test value at specified position, never auto-vivify entries.
Definition: bitSetI.H:521
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
Definition: globalIndex.H:68
label localSize() const
My local size.
Definition: globalIndexI.H:207
label totalSize() const
Global sum of localSizes.
Definition: globalIndexI.H:125
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:81
int myProcNo() const noexcept
Return processor number.
This class separates the mesh into distinct unconnected regions, each of which is then given a label ...
Definition: regionSplit.H:144
ClassName("regionSplit")
Runtime type information.
label nLocalRegions() const
Return local number of regions.
Definition: regionSplit.H:288
globalIndex reduceRegions(const label numLocalRegions, const bitSet &blockedFace, labelList &cellRegion) const
Manually consolidate regions globally by swapping information.
Definition: regionSplit.C:842
const globalIndex & globalNumbering() const noexcept
Return global region numbering.
Definition: regionSplit.H:282
label nRegions() const
Return total number of regions.
Definition: regionSplit.H:294
#define ClassName(TypeNameString)
Add typeName information from argument TypeNameString to a class.
Definition: className.H:67
Namespace for OpenFOAM.
const direction noexcept
Definition: Scalar.H:223