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  dictionary methodDict_;
231 
232 
233  // Private Member Functions
234 
235  //- Check and print error message
236  static void check(const int, const char*);
237 
239  (
240  const fileName& meshPath,
241  const labelList& adjncy,
242  const labelList& xadj,
243  const scalarField& cellWeights,
244  labelList& decomp
245  );
246 
247  //- Decompose non-parallel
248  label decomposeOneProc
249  (
250  const fileName& meshPath,
251  const labelList& adjncy,
252  const labelList& xadj,
253  const scalarField& cellWeights,
254  labelList& decomp
255  );
256 
257 
258 public:
259 
260  //- Runtime type information
261  TypeName("scotch");
262 
263 
264  // Constructors
265 
266  //- Construct given the decomposition dictionary and mesh
267  scotch
268  (
269  const dictionary& decompositionDict,
270  const dictionary& methodDict
271  );
272 
273  //- Disallow default bitwise copy construction
274  scotch(const scotch&) = delete;
275 
276 
277  //- Destructor
278  virtual ~scotch()
279  {}
280 
281 
282  // Member Functions
283 
284  //- Inherit decompose from decompositionMethod
286 
287  //- Return for every coordinate the wanted processor number. Use the
288  // mesh connectivity (if needed)
289  // Weights get normalised with minimum weight and truncated to
290  // convert into integer so e.g. 3.5 is seen as 3. The overall sum
291  // of weights might otherwise overflow.
292  virtual labelList decompose
293  (
294  const polyMesh& mesh,
295  const pointField& points,
296  const scalarField& pointWeights
297  );
298 
299  //- Return for every coordinate the wanted processor number. Gets
300  // passed agglomeration map (from fine to coarse cells) and coarse cell
301  // location. Can be overridden by decomposers that provide this
302  // functionality natively.
303  // See note on weights above.
304  virtual labelList decompose
305  (
306  const polyMesh& mesh,
307  const labelList& agglom,
308  const pointField& regionPoints,
309  const scalarField& regionWeights
310  );
311 
312  //- Return for every coordinate the wanted processor number. Explicitly
313  // provided mesh connectivity.
314  // The connectivity is equal to mesh.cellCells() except for
315  // - in parallel the cell numbers are global cell numbers (starting
316  // from 0 at processor0 and then incrementing all through the
317  // processors)
318  // - the connections are across coupled patches
319  // See note on weights above.
320  virtual labelList decompose
321  (
322  const labelListList& globalCellCells,
323  const pointField& cellCentres,
324  const scalarField& cellWeights
325  );
326 
327 
328  // Member Operators
329 
330  //- Disallow default bitwise assignment
331  void operator=(const scotch&) = delete;
332 };
333 
334 
335 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
336 
337 } // End namespace decompositionMethods
338 } // End namespace Foam
339 
340 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
341 
342 #endif
343 
344 // ************************************************************************* //
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:277
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, const dictionary &methodDict)
Construct given the decomposition dictionary and mesh.
Definition: dummyScotch.C:95
TypeName("scotch")
Runtime type information.
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
A class for handling file names.
Definition: fileName.H:82
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:80
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
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
word meshPath
Definition: setMeshPath.H:1