scotch.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-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::scotch
26 
27 Description
28  Scotch domain decomposition.
29  When run in parallel will collect the whole graph on to the master,
30  decompose and send back. Use ptscotch for proper distributed
31  decomposition.
32 
33  Quoting from the Scotch forum, on the 2008-08-22 10:09, Francois
34  PELLEGRINI posted the following details:
35  \verbatim
36  RE: Graph mapping 'strategy' string
37 
38  Strategy handling in Scotch is a bit tricky. In order
39  not to be confused, you must have a clear view of how they are built.
40  Here are some rules:
41 
42  1- Strategies are made up of "methods" which are combined by means of
43  "operators".
44 
45  2- A method is of the form "m{param=value,param=value,...}", where "m"
46  is a single character (this is your first error: "f" is a method name,
47  not a parameter name).
48 
49  3- There exist different sort of strategies : bipartitioning strategies,
50  mapping strategies, ordering strategies, which cannot be mixed. For
51  instance, you cannot build a bipartitioning strategy and feed it to a
52  mapping method (this is your second error).
53 
54  To use the "mapCompute" routine, you must create a mapping strategy, not
55  a bipartitioning one, and so use stratGraphMap() and not
56  stratGraphBipart(). Your mapping strategy should however be based on the
57  "recursive bipartitioning" method ("b"). For instance, a simple (and
58  hence not very efficient) mapping strategy can be :
59 
60  "b{sep=f}"
61 
62  which computes mappings with the recursive bipartitioning method "b",
63  this latter using the Fiduccia-Mattheyses method "f" to compute its
64  separators.
65 
66  If you want an exact partition (see your previous post), try
67  "b{sep=fx}".
68 
69  However, these strategies are not the most efficient, as they do not
70  make use of the multi-level framework.
71 
72  To use the multi-level framework, try for instance:
73 
74  "b{sep=m{vert=100,low=h,asc=f}x}"
75 
76  The current default mapping strategy in Scotch can be seen by using the
77  "-vs" option of program gmap. It is, to date:
78 
79  r
80  {
81  job=t,
82  map=t,
83  poli=S,
84  sep=
85  (
86  m
87  {
88  asc=b
89  {
90  bnd=
91  (
92  d{pass=40,dif=1,rem=1}
93  |
94  )
95  f{move=80,pass=-1,bal=0.002491},
96  org=f{move=80,pass=-1,bal=0.002491},
97  width=3
98  },
99  low=h{pass=10}
100  f{move=80,pass=-1,bal=0.002491},
101  type=h,
102  vert=80,
103  rat=0.8
104  }
105  | m
106  {
107  asc=b
108  {
109  bnd=
110  (
111  d{pass=40,dif=1,rem=1}
112  |
113  )
114  f{move=80,pass=-1,bal=0.002491},
115  org=f{move=80,pass=-1,bal=0.002491},
116  width=3
117  },
118  low=h{pass=10}
119  f{move=80,pass=-1,bal=0.002491},
120  type=h,
121  vert=80,
122  rat=0.8
123  }
124  )
125  }
126  \endverbatim
127 
128  Given that this information was written in 2008, this example strategy will
129  unlikely work as-is with the more recent Scotch versions. Therefore, the
130  steps for getting the current default strategy from within Scotch, is to do
131  the following steps:
132 
133  <ol>
134  <li> Edit the file <tt>system/decomposeParDict</tt> and use the following
135  settings:
136 
137  \verbatim
138  method scotch;
139 
140  scotchCoeffs
141  {
142  writeGraph true;
143  }
144  \endverbatim
145  </li>
146 
147  <li> Run \c decomposePar. For example, it will write a file named
148  <tt>region0.grf</tt>.
149  </li>
150 
151  <li> Now, instead of using \c gmap, run \c gpart with the following
152  command structure to get the default strategy:
153 
154  \verbatim
155  gpart <nProcs> -vs <grfFile>
156  \endverbatim
157 
158  where:
159 
160  <ul>
161  <li> <grfFile> is the file that was obtained with the option
162  <tt>writeGraph=true</tt>, namely <tt>region0.grf</tt>.
163  </li>
164  <li> <nProcs> is the \c numberOfSubdomains defined in the dictionary
165  file.
166  </li>
167  </ul>
168  </li>
169 
170  <li> At the end of the execution will be shown a long string, similar to
171  the following example (complete line was cropped at <tt>[...]</tt>):
172 
173  \verbatim
174  S Strat=m{asc=b{width=3,bnd=d{pass=40,dif=1,rem=0}[...],type=h}
175  \endverbatim
176  </li>
177 
178  <li> Edit the file <tt>system/decomposeParDict</tt> once again and add
179  the \c strategy entry as exemplified:
180 
181  \verbatim
182  method scotch;
183 
184  scotchCoeffs
185  {
186  // writeGraph true;
187  strategy "m{asc=b{width=3,bnd=d{pass=40,dif=1,rem=0}[...],type=h}";
188  }
189  \endverbatim
190  </li>
191 
192  <li> Finally, run \c decomposePar once again, to at least test if it
193  works as intended.
194  </li>
195 
196  </ol>
197 
198  Note:
199  \c gpart can be found in the current search path by adding the
200  respective \c bin folder from the Scotch installation, namely by running
201  the following commands:
202  \verbatim
203  source $(foamEtcFile config.sh/scotch)
204  export PATH=$PATH:$SCOTCH_ARCH_PATH/bin
205  \endverbatim
206 
207 SourceFiles
208  scotch.C
209 
210 \*---------------------------------------------------------------------------*/
211 
212 #ifndef scotch_H
213 #define scotch_H
214 
215 #include "decompositionMethod.H"
216 
217 namespace Foam
218 {
219 namespace decompositionMethods
220 {
221 
222 /*---------------------------------------------------------------------------*\
223  Class scotch Declaration
224 \*---------------------------------------------------------------------------*/
225 
226 class scotch
227 :
228  public decompositionMethod
229 {
230  // Private Member Functions
231 
232  //- Check and print error message
233  static void check(const int, const char*);
234 
236  (
237  const fileName& meshPath,
238  const labelList& adjncy,
239  const labelList& xadj,
240  const scalarField& cellWeights,
241  labelList& decomp
242  );
243 
244  //- Decompose non-parallel
245  label decomposeOneProc
246  (
247  const fileName& meshPath,
248  const labelList& adjncy,
249  const labelList& xadj,
250  const scalarField& cellWeights,
251  labelList& decomp
252  );
253 
254 
255 public:
256 
257  //- Runtime type information
258  TypeName("scotch");
259 
260 
261  // Constructors
262 
263  //- Construct given the decomposition dictionary and mesh
264  scotch(const dictionary& decompositionDict);
265 
266  //- Disallow default bitwise copy construction
267  scotch(const scotch&) = delete;
268 
269 
270  //- Destructor
271  virtual ~scotch()
272  {}
273 
274 
275  // Member Functions
276 
277  //- Inherit decompose from decompositionMethod
279 
280  //- Return for every coordinate the wanted processor number. Use the
281  // mesh connectivity (if needed)
282  // Weights get normalised with minimum weight and truncated to
283  // convert into integer so e.g. 3.5 is seen as 3. The overall sum
284  // of weights might otherwise overflow.
285  virtual labelList decompose
286  (
287  const polyMesh& mesh,
288  const pointField& points,
289  const scalarField& pointWeights
290  );
291 
292  //- Return for every coordinate the wanted processor number. Gets
293  // passed agglomeration map (from fine to coarse cells) and coarse cell
294  // location. Can be overridden by decomposers that provide this
295  // functionality natively.
296  // See note on weights above.
297  virtual labelList decompose
298  (
299  const polyMesh& mesh,
300  const labelList& agglom,
301  const pointField& regionPoints,
302  const scalarField& regionWeights
303  );
304 
305  //- Return for every coordinate the wanted processor number. Explicitly
306  // provided mesh connectivity.
307  // The connectivity is equal to mesh.cellCells() except for
308  // - in parallel the cell numbers are global cell numbers (starting
309  // from 0 at processor0 and then incrementing all through the
310  // processors)
311  // - the connections are across coupled patches
312  // See note on weights above.
313  virtual labelList decompose
314  (
315  const labelListList& globalCellCells,
316  const pointField& cellCentres,
317  const scalarField& cellWeights
318  );
319 
320 
321  // Member Operators
322 
323  //- Disallow default bitwise assignment
324  void operator=(const scotch&) = delete;
325 };
326 
327 
328 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
329 
330 } // End namespace decompositionMethods
331 } // End namespace Foam
332 
333 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
334 
335 #endif
336 
337 // ************************************************************************* //
Abstract base class for decomposition.
virtual labelList decompose(const pointField &points, const scalarField &pointWeights)
Return for every coordinate the wanted processor number.
Scotch domain decomposition. When run in parallel will collect the whole graph on to the master,...
Definition: scotch.H:228
virtual ~scotch()
Destructor.
Definition: scotch.H:270
void operator=(const scotch &)=delete
Disallow default bitwise assignment.
virtual labelList decompose(const pointField &points, const scalarField &pointWeights)
Inherit decompose from decompositionMethod.
scotch(const dictionary &decompositionDict)
Construct given the decomposition dictionary and mesh.
Definition: dummyScotch.C:95
TypeName("scotch")
Runtime type information.
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:162
A class for handling file names.
Definition: fileName.H:82
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:80
const pointField & points
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