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 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
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 
27 Class
28  Foam::regionSplit
29 
30 Description
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 
111 Note
112  does not walk across cyclicAMI/cyclicACMI - since these are not
113  \c coupled() at the patch level.
114 
115 SourceFiles
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 "boolList.H"
126 #include "MeshObject.H"
127 
128 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
129 
130 namespace Foam
131 {
132 
133 // Forward declarations
134 
135 class polyMesh;
136 
137 /*---------------------------------------------------------------------------*\
138  Class regionSplit Declaration
139 \*---------------------------------------------------------------------------*/
140 
141 class regionSplit
142 :
143  public MeshObject<polyMesh, TopologicalMeshObject, regionSplit>,
144  public labelList
145 {
146  // Private data
147 
148  autoPtr<globalIndex> globalNumberingPtr_;
149 
150  //- Temporary list of cells that have changed
151  mutable DynamicList<label> changedCells_;
152 
153  //- Temporary list of faces that have changed
154  mutable DynamicList<label> changedFaces_;
155 
156 
157  // Private Member Functions
158 
159  //- Update faceRegion data between (non-processor) coupled faces.
160  void updateFacePair
161  (
162  const label face0,
163  const label face1,
164  labelList& faceRegion,
165  DynamicList<label>& facesChanged
166  ) const;
167 
168  //- Given a seed cell label, fill cellRegion/faceRegion with markValue
169  //- for contiguous region around it
170  void fillSeedMask
171  (
172  const List<labelPair>& explicitConnections,
173  const label seedCellID,
174  const label markValue,
175  labelList& cellRegion,
176  labelList& faceRegion
177  ) const;
178 
179 
180  //- Calculate the local region split.
181  // \return number of processor-local regions,
182  // without consolidation between procesors
183  label calcLocalRegionSplit
184  (
185  const boolList& blockedFace,
186  const List<labelPair>& explicitConnections,
187  labelList& cellRegion
188  ) const;
189 
190 
191  //- Calculate the local region split.
192  // \return number of processor-local regions,
193  // without consolidation between procesors
194  autoPtr<globalIndex> calcRegionSplit
195  (
196  const bool doGlobalRegions,
197  const boolList& blockedFace,
198  const List<labelPair>& explicitConnections,
199  labelList& cellRegion
200  ) const;
201 
202 
203 public:
204 
205  //- Runtime type information
206  ClassName("regionSplit");
207 
208 
209  // Constructors
210 
211  //- Construct from mesh
213  (
214  const polyMesh& mesh,
215  const bool doGlobalRegions = Pstream::parRun()
216  );
217 
218  //- Construct from mesh and whether face is blocked
219  // \note blockedFace must be consistent across coupled faces!
221  (
222  const polyMesh& mesh,
223  const boolList& blockedFace,
224  const bool doGlobalRegions = Pstream::parRun()
225  );
226 
227  //- Construct from mesh and whether face is blocked, with additional
228  //- explicit connections between normal boundary faces.
229  // \note blockedFace must be consistent across coupled faces!
231  (
232  const polyMesh& mesh,
233  const boolList& blockedFace,
234  const List<labelPair>& explicitConnections,
235  const bool doGlobalRegions = Pstream::parRun()
236  );
237 
238 
239  // Member Functions
240 
241  //- Return global region numbering
242  const globalIndex& globalNumbering() const
243  {
244  return *globalNumberingPtr_;
245  }
246 
247  //- Return local number of regions
248  label nLocalRegions() const
249  {
251  }
252 
253  //- Return total number of regions
254  label nRegions() const
255  {
256  return globalNumbering().size();
257  }
258 
259 
260  //- Manually consolidate the regions globally by swapping information
261  // between processor domains and reducing the regions accordingly.
262  //
263  // \return number of local regions after reduction.
265  (
266  const label numLocalRegions,
267  const boolList& blockedFace,
268  labelList& cellRegion
269  ) const;
270 
271 };
272 
273 
274 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
275 
276 } // End namespace Foam
277 
278 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
279 
280 #endif
281 
282 // ************************************************************************* //
boolList.H
Foam::DynamicList< label >
globalIndex.H
Foam::UPstream::parRun
static bool & parRun()
Is this a parallel run?
Definition: UPstream.H:415
Foam::globalIndex::localSize
label localSize() const
My local size.
Definition: globalIndexI.H:124
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
Foam::regionSplit::regionSplit
regionSplit(const polyMesh &mesh, const bool doGlobalRegions=Pstream::parRun())
Construct from mesh.
Definition: regionSplit.C:402
Foam::regionSplit::globalNumbering
const globalIndex & globalNumbering() const
Return global region numbering.
Definition: regionSplit.H:241
Foam::MeshObject< polyMesh, TopologicalMeshObject, regionSplit >::mesh
const polyMesh & mesh() const
Definition: MeshObject.H:122
Foam::regionSplit
This class separates the mesh into distinct unconnected regions, each of which is then given a label ...
Definition: regionSplit.H:140
Foam::regionSplit::nRegions
label nRegions() const
Return total number of regions.
Definition: regionSplit.H:253
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::globalIndex
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
Definition: globalIndex.H:68
Foam::UPstream::myProcNo
static int myProcNo(const label communicator=0)
Number of this process (starting from masterNo() = 0)
Definition: UPstream.H:445
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::globalIndex::size
label size() const
Global sum of localSizes.
Definition: globalIndexI.H:88
Foam::List< label >
MeshObject.H
Foam::MeshObject
Templated abstract base-class for optional mesh objects used to automate their allocation to the mesh...
Definition: MeshObject.H:88
Foam::regionSplit::reduceRegions
autoPtr< globalIndex > reduceRegions(const label numLocalRegions, const boolList &blockedFace, labelList &cellRegion) const
Manually consolidate the regions globally by swapping information.
Definition: regionSplit.C:464
Foam::regionSplit::ClassName
ClassName("regionSplit")
Runtime type information.
Foam::regionSplit::nLocalRegions
label nLocalRegions() const
Return local number of regions.
Definition: regionSplit.H:247
labelPair.H