~ubuntu-branches/ubuntu/trusty/scotch/trusty-proposed

« back to all changes in this revision

Viewing changes to src/libscotch/library_mesh_order.c

  • Committer: Bazaar Package Importer
  • Author(s): "Adam C. Powell, IV", Christophe Trophime, Adam C. Powell, IV
  • Date: 2010-12-29 13:07:19 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20101229130719-jwalolw5d6av6wqx
Tags: 5.1.11.dfsg-1
[Christophe Trophime]
* New upstream release
* Forward-ported patches to version 5.1.10b.
* Install scotch headers properly.
* Fix chrpath commands in debian/rules.
* Fix (pt)scotch library install paths.
* Fix lintian errors and warnings.

[Adam C. Powell, IV]
* Forward-ported patches to version 5.1.11.

Show diffs side-by-side

added added

removed removed

Lines of Context:
48
48
/**                # Version 5.0  : from : 04 aug 2007     **/
49
49
/**                                 to     31 may 2008     **/
50
50
/**                # Version 5.1  : from : 29 mar 2010     **/
51
 
/**                                 to     29 mar 2010     **/
 
51
/**                                 to     14 aug 2010     **/
52
52
/**                                                        **/
53
53
/************************************************************/
54
54
 
76
76
/*                                  */
77
77
/************************************/
78
78
 
79
 
/*+ This routine parses the given
80
 
*** mesh ordering strategy.
81
 
*** It returns:
82
 
*** - 0   : if string successfully scanned.
83
 
*** - !0  : on error.
84
 
+*/
85
 
 
86
 
int
87
 
SCOTCH_stratMeshOrder (
88
 
SCOTCH_Strat * const        stratptr,
89
 
const char * const          string)
90
 
{
91
 
  if (*((Strat **) stratptr) != NULL)
92
 
    stratExit (*((Strat **) stratptr));
93
 
 
94
 
  if ((*((Strat **) stratptr) = stratInit (&hmeshorderststratab, string)) == NULL) {
95
 
    errorPrint ("SCOTCH_stratMeshOrder: error in ordering strategy");
96
 
    return     (1);
97
 
  }
98
 
 
99
 
  return (0);
100
 
}
101
 
 
102
79
/*+ This routine initializes an API ordering
103
80
*** with respect to the given source graph
104
81
*** and the locations of output parameters.
211
188
 
212
189
int
213
190
SCOTCH_meshOrderCompute (
214
 
const SCOTCH_Mesh * const   meshptr,              /*+ Mesh to order       +*/
 
191
SCOTCH_Mesh * const         meshptr,              /*+ Mesh to order       +*/
215
192
SCOTCH_Ordering * const     ordeptr,              /*+ Ordering to compute +*/
216
193
SCOTCH_Strat * const        stratptr)             /*+ Ordering strategy   +*/
217
194
{
229
206
 
230
207
int
231
208
SCOTCH_meshOrderComputeList (
232
 
const SCOTCH_Mesh * const   meshptr,              /*+ Mesh to order                   +*/
 
209
SCOTCH_Mesh * const         meshptr,              /*+ Mesh to order                   +*/
233
210
SCOTCH_Ordering * const     ordeptr,              /*+ Ordering to compute             +*/
234
211
const SCOTCH_Num            listnbr,              /*+ Number of vertices in list      +*/
235
212
const SCOTCH_Num * const    listtab,              /*+ List of vertex indices to order +*/
242
219
  VertList *          srclistptr;                 /* Pointer to subgraph vertex list */
243
220
  const Strat *       ordstratptr;                /* Pointer to ordering strategy    */
244
221
 
 
222
  srcmeshptr = (Mesh *) meshptr;
 
223
 
 
224
#ifdef SCOTCH_DEBUG_MESH2
 
225
  if (meshCheck (srcmeshptr) != 0) {
 
226
    errorPrint ("SCOTCH_meshOrderComputeList: invalid input mesh");
 
227
    return     (1);
 
228
  }
 
229
#endif /* SCOTCH_DEBUG_MESH2 */
 
230
 
245
231
  if (*((Strat **) stratptr) == NULL)             /* Set default ordering strategy if necessary */
246
 
    *((Strat **) stratptr) = stratInit (&hmeshorderststratab, "c{rat=0.7,cpr=n{sep=/(vnod>120)?m{vnod=100,low=h{pass=10},asc=f{bal=0.1}}:;,ole=v{strat=d{cmin=0,cmax=10000000,frat=0}},ose=g},unc=n{sep=/(vnod>120)?m{vnod=100,low=h{pass=10},asc=f{bal=0.1}}:;,ole=v{strat=d{cmin=0,cmax=10000000,frat=0}},ose=g}}");
 
232
    SCOTCH_stratMeshOrderBuild (stratptr, SCOTCH_STRATQUALITY, 0.1);
 
233
 
247
234
  ordstratptr = *((Strat **) stratptr);
248
235
  if (ordstratptr->tabl != &hmeshorderststratab) {
249
236
    errorPrint ("SCOTCH_meshOrderComputeList: not a mesh ordering strategy");
250
237
    return     (1);
251
238
  }
252
239
 
253
 
  srcmeshptr = (Mesh *) meshptr;
254
240
  memCpy (&srcmeshdat.m, srcmeshptr, sizeof (Mesh)); /* Copy non-halo mesh data  */
255
241
  srcmeshdat.m.flagval &= ~MESHFREETABS;          /* Do not allow to free arrays */
256
242
  srcmeshdat.vehdtax    = srcmeshdat.m.vendtax;   /* End of non-halo vertices    */
302
288
 
303
289
int
304
290
SCOTCH_meshOrder (
305
 
const SCOTCH_Mesh * const   meshptr,              /*+ Mesh to order                      +*/
 
291
SCOTCH_Mesh * const         meshptr,              /*+ Mesh to order                      +*/
306
292
SCOTCH_Strat * const        stratptr,             /*+ Ordering strategy                  +*/
307
293
SCOTCH_Num * const          permtab,              /*+ Ordering permutation               +*/
308
294
SCOTCH_Num * const          peritab,              /*+ Inverse permutation array          +*/
332
318
 
333
319
int
334
320
SCOTCH_meshOrderList (
335
 
const SCOTCH_Mesh * const   meshptr,              /*+ Mesh to order                      +*/
 
321
SCOTCH_Mesh * const         meshptr,              /*+ Mesh to order                      +*/
336
322
const SCOTCH_Num            listnbr,              /*+ Number of vertices in list         +*/
337
323
const SCOTCH_Num * const    listtab,              /*+ List of vertex indices to order    +*/
338
324
SCOTCH_Strat * const        stratptr,             /*+ Ordering strategy                  +*/
366
352
{
367
353
  return (orderCheck (&((LibOrder *) ordeptr)->o));
368
354
}
 
355
 
 
356
/*+ This routine parses the given
 
357
*** mesh ordering strategy.
 
358
*** It returns:
 
359
*** - 0   : if string successfully scanned.
 
360
*** - !0  : on error.
 
361
+*/
 
362
 
 
363
int
 
364
SCOTCH_stratMeshOrder (
 
365
SCOTCH_Strat * const        stratptr,
 
366
const char * const          string)
 
367
{
 
368
  if (*((Strat **) stratptr) != NULL)
 
369
    stratExit (*((Strat **) stratptr));
 
370
 
 
371
  if ((*((Strat **) stratptr) = stratInit (&hmeshorderststratab, string)) == NULL) {
 
372
    errorPrint ("SCOTCH_stratMeshOrder: error in ordering strategy");
 
373
    return     (1);
 
374
  }
 
375
 
 
376
  return (0);
 
377
}
 
378
 
 
379
/*+ This routine provides predefined
 
380
*** ordering strategies.
 
381
*** It returns:
 
382
*** - 0   : if string successfully initialized.
 
383
*** - !0  : on error.
 
384
+*/
 
385
 
 
386
int
 
387
SCOTCH_stratMeshOrderBuild (
 
388
SCOTCH_Strat * const        stratptr,             /*+ Strategy to create      +*/
 
389
const SCOTCH_Num            flagval,              /*+ Desired characteristics +*/
 
390
const double                balrat)               /*+ Desired imbalance ratio +*/
 
391
{
 
392
  char                bufftab[8192];              /* Should be enough */
 
393
  char                bbaltab[32];
 
394
 
 
395
  strcpy (bufftab, "c{rat=0.7,cpr=n{sep=/(vnod>120)?m{vnod=100,low=h{pass=10},asc=f{bal=<BBAL>}}:;,ole=v{strat=d{cmin=0,cmax=10000000,frat=0}},ose=g},unc=n{sep=/(vnod>120)?m{vnod=100,low=h{pass=10},asc=f{bal=<BBAL>}}:;,ole=v{strat=d{cmin=0,cmax=10000000,frat=0}},ose=g}}");
 
396
 
 
397
  sprintf (bbaltab, "%lf", balrat);
 
398
  stringSubst (bufftab, "<BBAL>", bbaltab);
 
399
 
 
400
  if (SCOTCH_stratMeshOrder (stratptr, bufftab) != 0) {
 
401
    errorPrint ("SCOTCH_stratMeshOrderBuild: error in sequential ordering strategy");
 
402
    return     (1);
 
403
  }
 
404
 
 
405
  return (0);
 
406
}