parMetis.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) 2024 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::decompositionMethods::parMetis
26 
27 Description
28  ParMetis redistribution in parallel
29 
30  Note: parMetis methods do not support serial operation.
31 
32  Parameters
33  - Method of decomposition
34  - kWay: multilevel k-way
35  - geomKway: combined coordinate-based and multi-level k-way
36  - adaptiveRepart: balances the work load of a graph
37 
38  - Options
39  - options[0]: The specified options are used if options[0] = 1
40 
41  - options[1]: Specifies the level of information to be returned during
42  the execution of the algorithm. Timing information can be obtained by
43  setting this to 1. Additional options for this parameter can be obtained
44  by looking at parmetis.h. Default: 0.
45 
46  - options[2]: Random number seed for the routine
47 
48  - options[3]: Specifies whether the sub-domains and processors are coupled
49  or un-coupled. If the number of sub-domains desired (i.e., nparts) and
50  the number of processors that are being used is not the same, then these
51  must be un-coupled. However, if nparts equals the number of processors,
52  these can either be coupled or de-coupled. If sub-domains and processors
53  are coupled, then the initial partitioning will be obtained implicitly
54  from the graph distribution. However, if sub-domains are un-coupled from
55  processors, then the initial partitioning needs to be obtained from the
56  initial values assigned to the part array.
57 
58  - itr: Parameter which describes the ratio of inter-processor communication
59  time compared to data redistribution time. Should be set between 0.000001
60  and 1000000.0. If set high, a repartitioning with a low edge-cut will be
61  computed. If it is set low, a repartitioning that requires little data
62  redistribution will be computed. Good values for this parameter can be
63  obtained by dividing inter-processor communication time by data
64  redistribution time. Otherwise, a value of 1000.0 is recommended.
65  Default: 1000.
66 
67 SourceFiles
68  parMetis.C
69 
70 \*---------------------------------------------------------------------------*/
71 
72 #ifndef parMetis_H
73 #define parMetis_H
74 
75 #include "decompositionMethod.H"
76 
77 extern "C"
78 {
79  #include "parmetis.h"
80 }
81 
82 namespace Foam
83 {
84 namespace decompositionMethods
85 {
86 
87 /*---------------------------------------------------------------------------*\
88  Class parMetis Declaration
89 \*---------------------------------------------------------------------------*/
90 
91 class parMetis
92 :
93  public decompositionMethod
94 {
95  // Private Member Data
96 
97  //- Method of decomposition
98  word method_;
99 
100  //- Options to control the operation of the decomposer
101  labelList options_;
102 
103  // Processor weights for each constraint
104  List<real_t> processorWeights_;
105 
106  //- Parameter which describes the ratio of inter-processor
107  // communication time compared to data redistribution time.
108  real_t itr_;
109 
110 
111  // Private Member Functions
112 
114  (
115  const labelList& xadj,
116  const labelList& adjncy,
117  const pointField& cellCentres,
118  const label nWeights,
119  const labelList& cellWeights,
120  const labelList& faceWeights,
121  labelList& finalDecomp
122  );
123 
124 
125 public:
126 
127  //- Runtime type information
128  TypeName("parMetis");
129 
130 
131  // Constructors
132 
133  //- Construct given the decomposition dictionary
134  parMetis(const dictionary& decompositionDict);
135 
136  //- Disallow default bitwise copy construction
137  parMetis(const parMetis&) = delete;
138 
139 
140  //- Destructor
141  virtual ~parMetis()
142  {}
143 
144 
145  // Member Functions
146 
147  //- Inherit decompose from decompositionMethod
149 
150  //- Return for every coordinate the wanted processor number. Use the
151  // mesh connectivity (if needed)
152  // Weights get normalised so the minimum value is 1 before truncation
153  // to an integer so the weights should be multiples of the minimum
154  // value. The overall sum of weights might otherwise overflow.
155  virtual labelList decompose
156  (
157  const polyMesh& mesh,
158  const pointField& points,
159  const scalarField& pointWeights
160  );
161 
162  //- Return for every coordinate the wanted processor number. Gets
163  // passed agglomeration map (from fine to coarse cells) and coarse cell
164  // location. Can be overridden by decomposers that provide this
165  // functionality natively.
166  // See note on weights above.
167  virtual labelList decompose
168  (
169  const polyMesh& mesh,
170  const labelList& cellToRegion,
171  const pointField& regionPoints,
172  const scalarField& regionWeights
173  );
174 
175  //- Return for every coordinate the wanted processor number. Explicitly
176  // provided mesh connectivity.
177  // The connectivity is equal to mesh.cellCells() except for
178  // - in parallel the cell numbers are global cell numbers (starting
179  // from 0 at processor0 and then incrementing all through the
180  // processors)
181  // - the connections are across coupled patches
182  // See note on weights above.
183  virtual labelList decompose
184  (
185  const labelListList& globalCellCells,
186  const pointField& cellCentres,
187  const scalarField& cellWeights
188  );
189 
190 
191  // Member Operators
192 
193  //- Disallow default bitwise assignment
194  void operator=(const parMetis&) = delete;
195 };
196 
197 
198 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
199 
200 } // End namespace decompositionMethods
201 } // End namespace Foam
202 
203 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
204 
205 #endif
206 
207 // ************************************************************************* //
Abstract base class for decomposition.
label nWeights(const pointField &points, const scalarField &pointWeights) const
Return the number of weights per point.
virtual labelList decompose(const pointField &points, const scalarField &pointWeights)
Return for every coordinate the wanted processor number.
ParMetis redistribution in parallel.
Definition: parMetis.H:93
virtual ~parMetis()
Destructor.
Definition: parMetis.H:140
virtual labelList decompose(const pointField &points, const scalarField &pointWeights)
Inherit decompose from decompositionMethod.
TypeName("parMetis")
Runtime type information.
parMetis(const dictionary &decompositionDict)
Construct given the decomposition dictionary.
Definition: parMetis.C:282
void operator=(const parMetis &)=delete
Disallow default bitwise assignment.
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:162
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:80
A class for handling words, derived from string.
Definition: word.H:62
const pointField & points
tmp< scalarField > faceWeights(const polyMesh &mesh, const vectorField &fCtrs, const vectorField &fAreas, const vectorField &cellCtrs)
Generate interpolation factors field.
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