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 #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  //- Calculate region split in non-compact (global) numbering.
130  void calcNonCompactRegionSplit
131  (
132  const globalIndex& globalFaces,
133  const boolList& blockedFace,
134  const List<labelPair>& explicitConnections,
135  labelList& cellRegion
136  ) const;
137 
138  //- Calculate global region split. Return globalIndex.
139  autoPtr<globalIndex> calcRegionSplit
140  (
141  const bool doGlobalRegions,
142  const boolList& blockedFace,
143  const List<labelPair>& explicitConnections,
144  labelList& cellRegion
145  ) const;
146 
147 
148 public:
149 
150  //- Runtime type information
151  ClassName("regionSplit");
152 
153 
154  // Constructors
155 
156  //- Construct from mesh
158  (
159  const polyMesh&,
160  const bool doGlobalRegions = Pstream::parRun()
161  );
162 
163  //- Construct from mesh and whether face is blocked
164  // NOTE: blockedFace has to be consistent across coupled faces!
166  (
167  const polyMesh&,
168  const boolList& blockedFace,
169  const bool doGlobalRegions = Pstream::parRun()
170  );
171 
172  //- Construct from mesh and whether face is blocked. Additional explicit
173  // connections between normal boundary faces.
174  // NOTE: blockedFace has to be consistent across coupled faces!
176  (
177  const polyMesh&,
178  const boolList& blockedFace,
179  const List<labelPair>&,
180  const bool doGlobalRegions = Pstream::parRun()
181  );
182 
183 
184  // Member Functions
185 
186  //- Return global region numbering
187  const globalIndex& globalNumbering() const
188  {
189  return globalNumberingPtr_();
190  }
191 
192  //- Return local number of regions
193  label nLocalRegions() const
194  {
196  }
197 
198  //- Return total number of regions
199  label nRegions() const
200  {
201  return globalNumbering().size();
202  }
203 };
204 
205 
206 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
207 
208 } // End namespace Foam
209 
210 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
211 
212 #endif
213 
214 // ************************************************************************* //
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
label nLocalRegions() const
Return local number of regions.
Definition: regionSplit.H:192
static int myProcNo(const label communicator=0)
Number of this process (starting from masterNo() = 0)
Definition: UPstream.H:429
Templated abstract base-class for optional mesh objects used to automate their allocation to the mesh...
Definition: MeshObject.H:87
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
Definition: globalIndex.H:63
label size() const
Global sum of localSizes.
Definition: globalIndexI.H:66
regionSplit(const polyMesh &, const bool doGlobalRegions=Pstream::parRun())
Construct from mesh.
Definition: regionSplit.C:396
const globalIndex & globalNumbering() const
Return global region numbering.
Definition: regionSplit.H:186
static bool & parRun()
Is this a parallel run?
Definition: UPstream.H:399
label nRegions() const
Return total number of regions.
Definition: regionSplit.H:198
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:76
Namespace for OpenFOAM.
label localSize() const
My local size.
Definition: globalIndexI.H:60