regionSplit.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2022 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 
105 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
106 
107 namespace Foam
108 {
109 
110 class polyMesh;
111 
112 /*---------------------------------------------------------------------------*\
113  Class regionSplit Declaration
114 \*---------------------------------------------------------------------------*/
115 
116 class regionSplit
117 :
118  public labelList
119 {
120  // Private Data
121 
122  //- Reference to the polyMesh
123  const polyMesh& mesh_;
124 
125  mutable autoPtr<globalIndex> globalNumberingPtr_;
126 
127 
128  // Private Member Functions
129 
130  //- Calculate region split in non-compact (global) numbering.
131  void calcNonCompactRegionSplit
132  (
133  const globalIndex& globalFaces,
134  const boolList& blockedFace,
135  const List<labelPair>& explicitConnections,
136  labelList& cellRegion
137  ) const;
138 
139  //- Calculate global region split. Return globalIndex.
140  autoPtr<globalIndex> calcRegionSplit
141  (
142  const bool doGlobalRegions,
143  const boolList& blockedFace,
144  const List<labelPair>& explicitConnections,
145  labelList& cellRegion
146  ) const;
147 
148 
149 public:
150 
151  //- Runtime type information
152  ClassName("regionSplit");
153 
154 
155  // Constructors
156 
157  //- Construct from mesh
159  (
160  const polyMesh&,
161  const bool doGlobalRegions = Pstream::parRun()
162  );
163 
164  //- Construct from mesh and whether face is blocked
165  // NOTE: blockedFace has to be consistent across coupled faces!
167  (
168  const polyMesh&,
169  const boolList& blockedFace,
170  const bool doGlobalRegions = Pstream::parRun()
171  );
172 
173  //- Construct from mesh and whether face is blocked. Additional explicit
174  // connections between normal boundary faces.
175  // NOTE: blockedFace has to be consistent across coupled faces!
177  (
178  const polyMesh&,
179  const boolList& blockedFace,
180  const List<labelPair>&,
181  const bool doGlobalRegions = Pstream::parRun()
182  );
183 
184  //- Disallow default bitwise copy construction
185  regionSplit(const regionSplit&) = delete;
186 
187 
188  // Member Functions
189 
190  //- Return reference to the polyMesh
191  const polyMesh& mesh() const
192  {
193  return mesh_;
194  }
195 
196  //- Return global region numbering
197  const globalIndex& globalNumbering() const
198  {
199  return globalNumberingPtr_();
200  }
201 
202  //- Return local number of regions
203  label nLocalRegions() const
204  {
206  }
207 
208  //- Return total number of regions
209  label nRegions() const
210  {
211  return globalNumbering().size();
212  }
213 };
214 
215 
216 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
217 
218 } // End namespace Foam
219 
220 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
221 
222 #endif
223 
224 // ************************************************************************* //
static bool & parRun()
Is this a parallel run?
Definition: UPstream.H:399
static int myProcNo(const label communicator=0)
Number of this process (starting from masterNo() = 0)
Definition: UPstream.H:429
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
Definition: globalIndex.H:64
label localSize() const
My local size.
Definition: globalIndexI.H:60
label size() const
Global sum of localSizes.
Definition: globalIndexI.H:66
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:80
This class separates the mesh into distinct unconnected regions, each of which is then given a label ...
Definition: regionSplit.H:118
ClassName("regionSplit")
Runtime type information.
const globalIndex & globalNumbering() const
Return global region numbering.
Definition: regionSplit.H:196
label nLocalRegions() const
Return local number of regions.
Definition: regionSplit.H:202
regionSplit(const polyMesh &, const bool doGlobalRegions=Pstream::parRun())
Construct from mesh.
Definition: regionSplit.C:395
const polyMesh & mesh() const
Return reference to the polyMesh.
Definition: regionSplit.H:190
label nRegions() const
Return total number of regions.
Definition: regionSplit.H:208
Namespace for OpenFOAM.
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