faMeshDecomposition.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) 2016-2017 Wikki Ltd
9  Copyright (C) 2021-2026 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::faMeshDecomposition
29 
30 Description
31  Automatic faMesh decomposition class. The decomposition of finite-area
32  follows the faceProcAddressing, pointProcAddressing from an existing
33  finite-volume decomposition.
34 
35 Author
36  Zeljko Tukovic, FSB Zagreb
37  Hrvoje Jasak, Wikki Ltd.
38 
39 SourceFiles
40  faMeshDecomposition.cxx
41 
42 \*---------------------------------------------------------------------------*/
43 
44 #ifndef Foam_faMeshDecomposition_H
45 #define Foam_faMeshDecomposition_H
46 
47 #include "faMesh.H"
48 
49 namespace Foam
50 {
51 
52 /*---------------------------------------------------------------------------*\
53  Class faMeshDecomposition Declaration
54 \*---------------------------------------------------------------------------*/
55 
57 :
58  public faMesh
59 {
60  // Private Data
61 
62  //- The area-region name
63  const word areaName_;
64 
65  //- Number of processors in decomposition
66  const label nProcs_;
67 
68  //- Is the decomposition data to be distributed for each processor
69  bool distributed_;
70 
71  //- Are globalFaceZones being used (specific to foam-extend)
72  bool hasGlobalFaceZones_;
73 
74  //- Are there cyclic-parallel edges (not really used...)
75  bool cyclicParallel_;
76 
77  //- Emit edgeProcAddressing without turning index (2512 and earlier)
78  bool noEdgeEncoding_;
79 
80  //- The target processor for each face
81  labelList faceToProc_;
82 
83  //- (per-processor) The mesh faceLabels
84  labelListList procFaceLabels_;
85 
86  //- (per-processor) Mapping of serial edgeId to local edgeLabel
87  List<Map<label>> procMeshEdgesMap_;
88 
89  //- (per-processor) The number of internal edges
90  labelList procNInternalEdges_;
91 
92  //- (per-processor) The edgeLabels for the boundary patches
93  List<labelListList> procPatchEdgeLabels_;
94 
95  //- (per-processor) Lookup of edgeLabel to serial edgeId
96  labelListList procPatchEdgeLookup_;
97 
98  //- Labels of points for each processor
99  labelListList procPointAddressing_;
100 
101  //- Labels of edges for each processor. Includes directional
102  //- encoding: (-edge-1) = flipped; (edge+1) = not flipped.
103  labelListList procEdgeAddressing_;
104 
105  //- Labels of faces for each processor.
106  //- No directional encoding
107  labelListList procFaceAddressing_;
108 
109  //- Original patch index for every processor patch.
110  //- An identity map for global boudaries, -1 otherwise.
111  labelListList procBoundaryAddressing_;
112 
113  //- (per-processor) start/size for regular boundaries
114  List<List<labelRange>> procPatchRange_;
115 
116  //- (per-processor) start/size for processor boundaries
117  List<List<labelRange>> procProcessorPatchRange_;
118 
119  //- (per-processor) the neighbProcNo for processor boundaries
120  labelListList procNeighbourProcessors_;
121 
122  //- List of globally shared point labels
123  labelList globallySharedPoints_;
124 
125 
126  // Private Static Data
127 
128  //- Disable use of edgeProcAddressing turning index
129  static bool disallowEdgeEncoding_;
130 
131 
132  // Private Member Functions
133 
134  //- Calculate distribution of the finite-area faces.
135  // Uses faMesh::faceLabels() and the finite-volume faceProcAddressing.
136  void distributeFaces();
137 
138  //- Write the addressing information
139  static void writeProcAddressing
140  (
141  const faMesh& procMesh,
142  const labelUList& faceProcAddr,
143  const labelUList& edgeProcAddr,
144  const labelUList& pointProcAddr,
145  const labelUList& boundaryProcAddr,
146  bool withoutEdgeEncoding
147  );
148 
149 
150 public:
151 
152  // Tuning switches
153 
154  //- The enable/disable state for allowing encoding of
155  //- edgeProcAddressing edge flips (default: true)
156  static bool allowEdgeEncoding() noexcept
157  {
158  return (!disallowEdgeEncoding_);
159  }
160 
161  //- Set enable/disable state for allowing edge flip encoding
162  static bool allowEdgeEncoding(bool on) noexcept
163  {
164  bool old(!disallowEdgeEncoding_);
165  disallowEdgeEncoding_ = (!on);
166  return old;
167  }
168 
169 
170  // Generated Methods
171 
172  //- No copy construct
173  faMeshDecomposition(const faMeshDecomposition&) = delete;
174 
175  //- No copy assignment
176  void operator=(const faMeshDecomposition&) = delete;
177 
178 
179  // Constructors
180 
181  //- Construct from components.
182  //- Values will come from the volume decomposition
184  (
186  const word& areaName,
188  const polyMesh& mesh,
190  const label nProcessors,
192  const dictionary& params = dictionary::null
193  );
194 
195  //- Construct from components (default area region).
196  //- Values will come from the volume decomposition
198  (
200  const polyMesh& mesh,
202  const label nProcessors,
204  const dictionary& params = dictionary::null
205  );
206 
207 
208  //- Destructor
209  ~faMeshDecomposition() = default;
210 
211 
212  // Member Functions
213 
214  // Settings
215 
216  //- The area-region name
217  const word& name() const noexcept { return areaName_; }
218 
219  //- Number of processor in decomposition
220  label nProcs() const noexcept { return nProcs_; }
221 
222  //- Is decomposition data to be distributed for each processor
223  bool distributed() const noexcept { return distributed_; }
224 
225  //- Change distributed flag
226  bool distributed(bool on) noexcept
227  {
228  bool old(distributed_);
229  distributed_ = on;
230  return old;
231  }
232 
233  //- Is edge encoding disabled
234  bool noEdgeEncoding() const noexcept { return noEdgeEncoding_; }
235 
236  //- Change the edge encoding flag
237  bool noEdgeEncoding(bool on) noexcept
238  {
239  bool old(noEdgeEncoding_);
240  noEdgeEncoding_ = on;
241  return old;
242  }
243 
244  //- Are global face zones used
245  bool useGlobalFaceZones() const noexcept
246  {
247  return hasGlobalFaceZones_;
248  }
249 
250  //- Change global face zones flag
251  bool useGlobalFaceZones(bool on) noexcept
252  {
253  bool old(hasGlobalFaceZones_);
254  hasGlobalFaceZones_ = on;
255  return old;
256  }
257 
258  //- Update flags based on the decomposition model settings
259  // Sets "distributed", detects presence of "globalFaceZones"
260  void updateParameters(const dictionary& params);
261 
262 
263  // Mappings
264 
265  //- Face-processor decomposition labels
266  const labelUList& faceToProc() const noexcept
267  {
268  return faceToProc_;
269  }
270 
271 
272  // Decompose
273 
274  //- Decompose mesh
276 
277  //- Write decomposition
278  bool writeDecomposition() const;
279 };
281 
282 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
283 
284 } // End namespace Foam
286 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
287 
288 #endif
289 
290 // ************************************************************************* //
Finite area mesh (used for 2-D non-Euclidian finite area method) defined using a patch of faces on a ...
Definition: faMesh.H:133
faMeshDecomposition(const faMeshDecomposition &)=delete
No copy construct.
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:130
const labelUList & faceToProc() const noexcept
Face-processor decomposition labels.
bool noEdgeEncoding() const noexcept
Is edge encoding disabled.
bool useGlobalFaceZones() const noexcept
Are global face zones used.
label nProcs() const noexcept
Number of processor in decomposition.
void updateParameters(const dictionary &params)
Update flags based on the decomposition model settings.
UList< label > labelUList
A UList of labels.
Definition: UList.H:76
dictionary()
Default construct, a top-level empty dictionary.
Definition: dictionary.C:68
A class for handling words, derived from Foam::string.
Definition: word.H:63
static const dictionary null
An empty dictionary, which is also the parent for all dictionaries.
Definition: dictionary.H:487
const direction noexcept
Definition: scalarImpl.H:265
bool writeDecomposition() const
Write decomposition.
const polyMesh & mesh() const
Return access to polyMesh.
Definition: faMesh.C:1016
~faMeshDecomposition()=default
Destructor.
const word & name() const noexcept
The area-region name.
bool distributed() const noexcept
Is decomposition data to be distributed for each processor.
void decomposeMesh()
Decompose mesh.
Automatic faMesh decomposition class. The decomposition of finite-area follows the faceProcAddressing...
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:76
void operator=(const faMeshDecomposition &)=delete
No copy assignment.
Namespace for OpenFOAM.
static bool allowEdgeEncoding() noexcept
The enable/disable state for allowing encoding of edgeProcAddressing edge flips (default: true) ...