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 | Copyright (C) 2011-2016 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::regionSplit
26 
27 Description
28  This class separates the mesh into distinct unconnected regions,
29  each of which is then given a label according to globalNumbering().
30 
31 
32  Say 6 cells, 3 processors, with single baffle on proc1.
33 
34  baffle
35  |
36  +---+---+---+---+---+---+
37  | | | | | | |
38  +---+---+---+---+---+---+
39  proc0 | proc1 | proc2
40 
41 
42 
43  1: determine local regions (uncoupled)
44 
45  +---+---+---+---+---+---+
46  | 0 | 0 | 0 | 1 | 0 | 0 |
47  +---+---+---+---+---+---+
48  proc0 | proc1 | proc2
49 
50 
51 
52  2: make global
53 
54  +---+---+---+---+---+---+
55  | 0 | 0 | 1 | 2 | 3 | 3 |
56  +---+---+---+---+---+---+
57  proc0 | proc1 | proc2
58 
59 
60 
61  3: merge connected across procs
62 
63  +---+---+---+---+---+---+
64  | 0 | 0 | 0 | 2 | 2 | 2 |
65  +---+---+---+---+---+---+
66  proc0 | proc1 | proc2
67 
68 
69 
70  4. determine locally owner regions. determine compact numbering for the
71  local regions and send these to all processors that need them:
72 
73  proc0 uses regions:
74  - 0 which is local to it.
75  proc1 uses regions
76  - 0 which originates from proc0
77  - 2 which is local to it
78  proc2 uses regions
79  - 2 which originates from proc1
80 
81  So proc1 needs to get the compact number for region 0 from proc0 and proc2
82  needs to get the compact number for region 2 from proc1:
83 
84  +---+---+---+---+---+---+
85  | 0 | 0 | 0 | 1 | 1 | 1 |
86  +---+---+---+---+---+---+
87  proc0 | proc1 | proc2
88 
89 
90  Can optionally keep all regions local to the processor.
91 
92 
93 SourceFiles
94  regionSplit.C
95 
96 \*---------------------------------------------------------------------------*/
97 
98 #ifndef regionSplit_H
99 #define regionSplit_H
100 
101 #include "globalIndex.H"
102 #include "labelPair.H"
103 #include "boolList.H"
104 #include "MeshObject.H"
105 
106 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
107 
108 namespace Foam
109 {
110 
111 class polyMesh;
112 
113 /*---------------------------------------------------------------------------*\
114  Class regionSplit Declaration
115 \*---------------------------------------------------------------------------*/
117 class regionSplit
118 :
119  public MeshObject<polyMesh, TopologicalMeshObject, regionSplit>,
120  public labelList
121 {
122  // Private data
123 
124  mutable autoPtr<globalIndex> globalNumberingPtr_;
125 
126 
127  // Private Member Functions
128 
129  //- Transfer faceRegion data from one face to the other (or vice versa)
130  void transferCoupledFaceRegion
131  (
132  const label facei,
133  const label otherFacei,
134 
135  labelList& faceRegion,
136  DynamicList<label>& newChangedFaces
137  ) const;
138 
139  //- Given a seed cell label, fill cellRegion/faceRegion with markValue
140  // for contiguous region around it
141  void fillSeedMask
142  (
143  const List<labelPair>& explicitConnections,
144  labelList& cellRegion,
145  labelList& faceRegion,
146  const label seedCellID,
147  const label markValue
148  ) const;
149 
150  //- Calculate local region split. Return number of regions.
151  label calcLocalRegionSplit
152  (
153  const boolList& blockedFace,
154  const List<labelPair>& explicitConnections,
155  labelList& cellRegion
156  ) const;
157 
158  //- Calculate global region split. Return globalIndex.
159  autoPtr<globalIndex> calcRegionSplit
160  (
161  const bool doGlobalRegions,
162  const boolList& blockedFace,
163  const List<labelPair>& explicitConnections,
164  labelList& cellRegion
165  ) const;
166 
167 
168 public:
169 
170  //- Runtime type information
171  ClassName("regionSplit");
172 
173 
174  // Constructors
175 
176  //- Construct from mesh
178  (
179  const polyMesh&,
180  const bool doGlobalRegions = Pstream::parRun()
181  );
182 
183  //- Construct from mesh and whether face is blocked
184  // NOTE: blockedFace has to be consistent across coupled faces!
186  (
187  const polyMesh&,
188  const boolList& blockedFace,
189  const bool doGlobalRegions = Pstream::parRun()
190  );
191 
192  //- Construct from mesh and whether face is blocked. Additional explicit
193  // connections between normal boundary faces.
194  // NOTE: blockedFace has to be consistent across coupled faces!
196  (
197  const polyMesh&,
198  const boolList& blockedFace,
199  const List<labelPair>&,
200  const bool doGlobalRegions = Pstream::parRun()
201  );
202 
203 
204  // Member Functions
205 
206  //- Return global region numbering
207  const globalIndex& globalNumbering() const
208  {
209  return globalNumberingPtr_();
210  }
211 
212  //- Return local number of regions
213  label nLocalRegions() const
214  {
216  }
217 
218  //- Return total number of regions
219  label nRegions() const
220  {
221  return globalNumbering().size();
222  }
223 };
224 
225 
226 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
227 
228 } // End namespace Foam
229 
230 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
231 
232 #endif
233 
234 // ************************************************************************* //
ClassName("regionSplit")
Runtime type information.
This class separates the mesh into distinct unconnected regions, each of which is then given a label ...
Definition: regionSplit.H:116
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
static int myProcNo(const label communicator=0)
Number of this process (starting from masterNo() = 0)
Definition: UPstream.H:417
label size() const
Global sum of localSizes.
Definition: globalIndexI.H:66
label nRegions() const
Return total number of regions.
Definition: regionSplit.H:218
Templated abstract base-class for optional mesh objects used to automate their allocation to the mesh...
Definition: MeshObject.H:85
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
Definition: globalIndex.H:63
regionSplit(const polyMesh &, const bool doGlobalRegions=Pstream::parRun())
Construct from mesh.
Definition: regionSplit.C:677
static bool & parRun()
Is this a parallel run?
Definition: UPstream.H:393
label localSize() const
My local size.
Definition: globalIndexI.H:60
label nLocalRegions() const
Return local number of regions.
Definition: regionSplit.H:212
const globalIndex & globalNumbering() const
Return global region numbering.
Definition: regionSplit.H:206
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:53
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
Namespace for OpenFOAM.