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  dictionary methodDict_;
98 
99  //- Method of decomposition
100  word method_;
101 
102  //- Options to control the operation of the decomposer
103  labelList options_;
104 
105  // Processor weights for each constraint
106  List<real_t> processorWeights_;
107 
108  //- Parameter which describes the ratio of inter-processor
109  // communication time compared to data redistribution time.
110  real_t itr_;
111 
112 
113  // Private Member Functions
114 
116  (
117  const labelList& xadj,
118  const labelList& adjncy,
119  const pointField& cellCentres,
120  const label nWeights,
121  const labelList& cellWeights,
122  const labelList& faceWeights,
123  labelList& finalDecomp
124  );
125 
126 
127 public:
128 
129  //- Runtime type information
130  TypeName("parMetis");
131 
132 
133  // Constructors
134 
135  //- Construct given the decomposition dictionary
136  parMetis
137  (
138  const dictionary& decompositionDict,
139  const dictionary& methodDict
140  );
141 
142  //- Disallow default bitwise copy construction
143  parMetis(const parMetis&) = delete;
144 
145 
146  //- Destructor
147  virtual ~parMetis()
148  {}
149 
150 
151  // Member Functions
152 
153  //- Inherit decompose from decompositionMethod
155 
156  //- Return for every coordinate the wanted processor number. Use the
157  // mesh connectivity (if needed)
158  // Weights get normalised so the minimum value is 1 before truncation
159  // to an integer so the weights should be multiples of the minimum
160  // value. The overall sum of weights might otherwise overflow.
161  virtual labelList decompose
162  (
163  const polyMesh& mesh,
164  const pointField& points,
165  const scalarField& pointWeights
166  );
167 
168  //- Return for every coordinate the wanted processor number. Gets
169  // passed agglomeration map (from fine to coarse cells) and coarse cell
170  // location. Can be overridden by decomposers that provide this
171  // functionality natively.
172  // See note on weights above.
173  virtual labelList decompose
174  (
175  const polyMesh& mesh,
176  const labelList& cellToRegion,
177  const pointField& regionPoints,
178  const scalarField& regionWeights
179  );
180 
181  //- Return for every coordinate the wanted processor number. Explicitly
182  // provided mesh connectivity.
183  // The connectivity is equal to mesh.cellCells() except for
184  // - in parallel the cell numbers are global cell numbers (starting
185  // from 0 at processor0 and then incrementing all through the
186  // processors)
187  // - the connections are across coupled patches
188  // See note on weights above.
189  virtual labelList decompose
190  (
191  const labelListList& globalCellCells,
192  const pointField& cellCentres,
193  const scalarField& cellWeights
194  );
195 
196 
197  // Member Operators
198 
199  //- Disallow default bitwise assignment
200  void operator=(const parMetis&) = delete;
201 };
202 
203 
204 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
205 
206 } // End namespace decompositionMethods
207 } // End namespace Foam
208 
209 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
210 
211 #endif
212 
213 // ************************************************************************* //
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:146
virtual labelList decompose(const pointField &points, const scalarField &pointWeights)
Inherit decompose from decompositionMethod.
parMetis(const dictionary &decompositionDict, const dictionary &methodDict)
Construct given the decomposition dictionary.
Definition: parMetis.C:282
TypeName("parMetis")
Runtime type information.
void operator=(const parMetis &)=delete
Disallow default bitwise assignment.
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
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
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
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