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-2019 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  Note: does not walk across cyclicAMI/cyclicACMI - since not 'coupled()'
93  at the patch level.
94 
95 
96 SourceFiles
97  regionSplit.C
98 
99 \*---------------------------------------------------------------------------*/
100 
101 #ifndef regionSplit_H
102 #define regionSplit_H
103 
104 #include "globalIndex.H"
105 #include "labelPair.H"
106 #include "boolList.H"
107 #include "MeshObject.H"
108 
109 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
110 
111 namespace Foam
112 {
113 
114 class polyMesh;
115 
116 /*---------------------------------------------------------------------------*\
117  Class regionSplit Declaration
118 \*---------------------------------------------------------------------------*/
120 class regionSplit
121 :
122  public MeshObject<polyMesh, TopologicalMeshObject, regionSplit>,
123  public labelList
124 {
125  // Private Data
126 
127  mutable autoPtr<globalIndex> globalNumberingPtr_;
128 
129 
130  // Private Member Functions
131 
132  //- Calculate region split in non-compact (global) numbering.
133  void calcNonCompactRegionSplit
134  (
135  const globalIndex& globalFaces,
136  const boolList& blockedFace,
137  const List<labelPair>& explicitConnections,
138  labelList& cellRegion
139  ) const;
140 
141  //- Calculate global region split. Return globalIndex.
142  autoPtr<globalIndex> calcRegionSplit
143  (
144  const bool doGlobalRegions,
145  const boolList& blockedFace,
146  const List<labelPair>& explicitConnections,
147  labelList& cellRegion
148  ) const;
149 
150 
151 public:
152 
153  //- Runtime type information
154  ClassName("regionSplit");
155 
156 
157  // Constructors
158 
159  //- Construct from mesh
161  (
162  const polyMesh&,
163  const bool doGlobalRegions = Pstream::parRun()
164  );
165 
166  //- Construct from mesh and whether face is blocked
167  // NOTE: blockedFace has to be consistent across coupled faces!
169  (
170  const polyMesh&,
171  const boolList& blockedFace,
172  const bool doGlobalRegions = Pstream::parRun()
173  );
174 
175  //- Construct from mesh and whether face is blocked. Additional explicit
176  // connections between normal boundary faces.
177  // NOTE: blockedFace has to be consistent across coupled faces!
179  (
180  const polyMesh&,
181  const boolList& blockedFace,
182  const List<labelPair>&,
183  const bool doGlobalRegions = Pstream::parRun()
184  );
185 
186 
187  // Member Functions
188 
189  //- Return global region numbering
190  const globalIndex& globalNumbering() const
191  {
192  return globalNumberingPtr_();
193  }
194 
195  //- Return local number of regions
196  label nLocalRegions() const
197  {
199  }
200 
201  //- Return total number of regions
202  label nRegions() const
203  {
204  return globalNumbering().size();
205  }
206 };
207 
208 
209 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
210 
211 } // End namespace Foam
212 
213 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
214 
215 #endif
216 
217 // ************************************************************************* //
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:119
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
label nLocalRegions() const
Return local number of regions.
Definition: regionSplit.H:195
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:85
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:189
static bool & parRun()
Is this a parallel run?
Definition: UPstream.H:399
label nRegions() const
Return total number of regions.
Definition: regionSplit.H:201
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:74
Namespace for OpenFOAM.
label localSize() const
My local size.
Definition: globalIndexI.H:60