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-2021 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
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
27Class
28 Foam::scotchDecomp
29
30Description
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
204Note
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
214SourceFiles
215 scotchDecomp.C
216
217\*---------------------------------------------------------------------------*/
218
219#ifndef scotchDecomp_H
220#define scotchDecomp_H
221
222#include "metisLikeDecomp.H"
223
224namespace Foam
225{
226
227/*---------------------------------------------------------------------------*\
228 Class scotchDecomp Declaration
229\*---------------------------------------------------------------------------*/
231class 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
241protected:
242
243 // Protected Member Functions
244
245 //- Decompose non-parallel
246 virtual label decomposeSerial
247 (
248 const labelList& adjncy,
249 const labelList& xadj,
250 const List<scalar>& cWeights,
251 labelList& decomp
252 ) const;
253
254
255 //- No copy construct
256 scotchDecomp(const scotchDecomp&) = delete;
257
258 //- No copy assignment
259 void operator=(const scotchDecomp&) = delete;
260
261
262public:
263
264 //- Runtime type information
265 TypeName("scotch");
266
267
268 // Constructors
269
270 //- Construct given decomposition dictionary and optional region name
271 explicit scotchDecomp
272 (
273 const dictionary& decompDict,
274 const word& regionName = ""
275 );
276
277
278 //- Destructor
279 virtual ~scotchDecomp() = default;
280
281
282 // Member Functions
283
284 //- Knows about coupled boundaries
285 virtual bool parallelAware() const
286 {
287 return true;
288 }
289
290 //- Inherit all decompose methods
292
293 //- Return for every coordinate the wanted processor number.
294 virtual labelList decompose
295 (
296 const polyMesh& mesh,
297 const pointField& points,
298 const scalarField& pointWeights
299 ) const;
300
301 //- Return for every coordinate the wanted processor number.
302 virtual labelList decompose
303 (
304 const polyMesh& mesh,
305 const labelList& agglom,
306 const pointField& regionPoints,
307 const scalarField& regionWeights
308 ) const;
309
310 //- Return for every coordinate the wanted processor number.
311 virtual labelList decompose
312 (
313 const labelListList& globalCellCells,
314 const pointField& cc,
315 const scalarField& cWeights
316 ) const;
317};
318
319
320// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
321
322} // End namespace Foam
323
324// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
325
326#endif
327
328// ************************************************************************* //
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
A class for handling file names.
Definition: fileName.H:76
Domain decomposition using METIS-like data structures.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:81
Scotch domain decomposition.
Definition: scotchDecomp.H:233
void operator=(const scotchDecomp &)=delete
No copy assignment.
virtual label decomposeSerial(const labelList &adjncy, const labelList &xadj, const List< scalar > &cWeights, labelList &decomp) const
Decompose non-parallel.
virtual bool parallelAware() const
Knows about coupled boundaries.
Definition: scotchDecomp.H:284
virtual ~scotchDecomp()=default
Destructor.
virtual labelList decompose(const polyMesh &mesh, const pointField &points, const scalarField &pointWeights) const
Return for every coordinate the wanted processor number.
scotchDecomp(const scotchDecomp &)=delete
No copy construct.
TypeName("scotch")
Runtime type information.
bool decompose() const noexcept
Query the decompose flag (normally off)
A class for handling words, derived from Foam::string.
Definition: word.H:68
dynamicFvMesh & mesh
Foam::word regionName(Foam::polyMesh::defaultRegion)
const pointField & points
Namespace for OpenFOAM.
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73