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