Ice Sheet System Model  4.18
Code documentation
Functions
METIS_PartMeshNodalPatch.cpp File Reference
#include <config.h>
#include "../metisincludes.h"
#include "../../../shared/shared.h"

Go to the source code of this file.

Functions

void METIS_PartMeshNodalPatch (int numberofelements, int numberofnodes, int *index, int *vweights, int num_procs, int *epart, int *npart)
 

Function Documentation

◆ METIS_PartMeshNodalPatch()

void METIS_PartMeshNodalPatch ( int  numberofelements,
int  numberofnodes,
int *  index,
int *  vweights,
int  num_procs,
int *  epart,
int *  npart 
)

Definition at line 20 of file METIS_PartMeshNodalPatch.cpp.

20  {
21 
22  #if _METIS_VERSION_ == 4
23  /*Our interface originates in the Metis 4.0 version, hence identical calls*/
24  int edgecut=1;
25  int etype =1; //tria mesh see metis/Programs/Io.c
26  int numflag=0;
27  METIS_PartMeshNodal(&numberofelements,&numberofnodes, index,&etype,&numflag,&num_procs,&edgecut, epart, npart);
28 
29  #elif _METIS_VERSION_ == 5
30 
31  /*Create options*/
32  idx_t options[METIS_NOPTIONS];
33  METIS_SetDefaultOptions(options);
34 
35  options[METIS_OPTION_PTYPE] = METIS_PTYPE_KWAY; /* partitioning method */
36  options[METIS_OPTION_OBJTYPE] = METIS_OBJTYPE_CUT; /* type of objective */
37  options[METIS_OPTION_CTYPE] = METIS_CTYPE_SHEM; /* matching scheme to be used during coarsening.*/
38  options[METIS_OPTION_IPTYPE] = METIS_IPTYPE_METISRB; /* algorithm used during initial partitioning*/
39  options[METIS_OPTION_RTYPE] = METIS_RTYPE_GREEDY; /* algorithm used for refinement*/
40  options[METIS_OPTION_DBGLVL] = 0; /* amount of progress/debugging information will be printed */
41  options[METIS_OPTION_UFACTOR] = 30; /* maximum allowed load imbalance among the partitions*/
42  options[METIS_OPTION_MINCONN] = 0; /* explicitly minimize the maximum connectivity ?*/
43  options[METIS_OPTION_CONTIG] = 0; /* force contiguous partitions?*/
44  options[METIS_OPTION_SEED] = -1; /* seed for the random number generator*/
45  options[METIS_OPTION_NITER] = 10; /* number of iterations for the refinement algorithms*/
46  options[METIS_OPTION_NCUTS] = 1; /* number of different partitionings that it will compute*/
47 
48  /*create eptr*/
49  idx_t k=0;
50  idx_t* eptr=xNew<idx_t>(numberofelements+1);
51  eptr[0]=0;
52  for(int i=0;i<numberofelements;i++){
53  k+=3;
54  eptr[i+1]=k;
55  }
56 
57  /*create tpwgts (Weight per processor)*/
58  real_t* tpwgts=xNew<real_t>(num_procs);
59  for(int i=0;i<num_procs;i++) tpwgts[i]=1.0/(num_procs);
60 
61  /*create vwgt (Weight per node)*/
62  idx_t* vwgts=NULL;
63  if(vweights){
64  vwgts=xNew<idx_t>(numberofnodes);
65  for(int i=0;i<numberofnodes;i++) vwgts[i]=reCast<idx_t>(vweights[i]);
66  }
67 
68  /*Call METIS*/
69  idx_t objval;
70  int output = METIS_PartMeshNodal(&numberofelements,&numberofnodes,eptr,index,vwgts,NULL,&num_procs,tpwgts,options,&objval,epart,npart);
71  if(output!=METIS_OK) _error_("Could not partition mesh");
72 
73  /*clean-up*/
74  xDelete<idx_t>(vwgts);
75  xDelete<idx_t>(eptr);
76  xDelete<real_t>(tpwgts);
77 
78  #else
79  _error_("METIS version not supported yet");
80  #endif
81 }
_error_
#define _error_(StreamArgs)
Definition: exceptions.h:49