geo_partition_scotch.h
Go to the documentation of this file.
#ifndef _RHEOLEF_PARMETIS_TOOLS_H
#define _RHEOLEF_PARMETIS_TOOLS_H
#include "rheolef/distributor.h"
namespace rheolef {
typedef int my_idxtype;
#define IDX_DATATYPE MPI_INT
typedef my_idxtype idxtype;
// main call
extern void geo_partition_scotch (
my_idxtype *elmdist,
my_idxtype *eptr,
std::vector<my_idxtype>& eind,
my_idxtype *elmwgt,
int *ncon,
int *ncommonnodes,
int *nparts,
float *tpwgts,
float *ubvec,
int *edgecut,
my_idxtype *part,
const mpi::communicator& comm);
// internal materials:
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <stdarg.h>
#include <limits.h>
#include <time.h>
#include <assert.h>
#define UNBALANCE_FRACTION 1.05
#define DBG_INFO 2 /* Perform timing analysis */
#define PMV3_OPTION_DBGLVL 1
#define PMV3_OPTION_SEED 2
#define MAXNCON 12
#define MAXLINE 8192
struct MeshType {
rheolef::distributor ownership;
std::vector<my_idxtype> elements;
int etype;
int gnelms, gnns;
int nelms, nns;
int ncon;
int esize, gminnode;
my_idxtype *elmwgt;
MeshType();
private:
MeshType(const MeshType& x);
MeshType& operator= (const MeshType& x);
};
inline
MeshType::MeshType()
: ownership(),
elements(),
etype(0),
gnelms(0),
gnns(0),
nelms(0),
nns(0),
ncon(0),
esize(0),
gminnode(0),
elmwgt(0)
{
}
#ifdef TODO
inline
MeshType::MeshType(const MeshType& x)
: ownership(x.ownership),
elements(x.elements),
etype(x.etype),
gnelms(x.gnelms),
gnns(x.gnns),
nelms(x.nelms),
nns(x.nns),
ncon(x.ncon),
esize(x.esize),
gminnode(x.gminnode),
elmwgt(ARGGG)
{
}
#endif // TODO
/*************************************************************************
* The following data structure stores key-value pair
**************************************************************************/
struct KeyValueType {
my_idxtype key;
my_idxtype val;
};
typedef struct KeyValueType KeyValueType;
#define amax(a, b) ((a) >= (b) ? (a) : (b))
#define icopy(n, a, b) memcpy((b), (a), sizeof(int)*(n))
#define idxcopy(n, a, b) memcpy((b), (a), sizeof(my_idxtype)*(n))
#define SHIFTCSR(i, n, a) \
do { \
for (i=n; i>0; i--) a[i] = a[i-1]; \
a[0] = 0; \
} while(0)
template <class Size, class RandomIOIterator>
static inline void init_csr_ptr (Size n, const RandomIOIterator& aptr) {
for (Size i=1; i<n; i++) aptr[i] += aptr[i-1];
for (Size i=n; i>0; i--) aptr[i] = aptr[i-1];
aptr[0] = 0;
}
template <class Size, class RandomIOIterator>
static inline void shift_csr_ptr (Size n, const RandomIOIterator& aptr) {
for (long int i = n; i > 0; i--) aptr[i] = aptr[i-1];
aptr[0] = 0;
}
/*************************************************************************
* These functions return the index of the minimum element in a vector
**************************************************************************/
inline
int
idxamin(int n, const std::vector<my_idxtype>& x) {
int min=0;
for (int i=1; i<n; i++) min = (x[i] < x[min] ? i : min);
return min;
}
/*************************************************************************
* These functions return the index of the maximum element in a vector
**************************************************************************/
inline
int
idxamax(int n, const std::vector<my_idxtype>& x) {
int max=0;
for (int i=1; i<n; i++) max = (x[i] > x[max] ? i : max);
return max;
}
} // namespace rheolef
#endif // _RHEOLEF_PARMETIS_TOOLS_H
rheolef::idxamin
int idxamin(int n, const std::vector< my_idxtype > &x)
Definition: geo_partition_scotch.h:150
rheolef::KeyValueType::key
my_idxtype key
Definition: geo_partition_scotch.h:121
rheolef::idxtype
my_idxtype idxtype
Definition: geo_partition_scotch.h:30
rheolef::KeyValueType
Definition: geo_partition_scotch.h:118
rheolef::MeshType::gminnode
int gminnode
Definition: geo_partition_scotch.h:74
rheolef::distributor
see the distributor page for the full documentation
Definition: distributor.h:62
rheolef::KeyValueType::val
my_idxtype val
Definition: geo_partition_scotch.h:122
rheolef::MeshType::nelms
int nelms
Definition: geo_partition_scotch.h:72
rheolef::MeshType::ownership
rheolef::distributor ownership
Definition: geo_partition_scotch.h:68
rheolef::MeshType::etype
int etype
Definition: geo_partition_scotch.h:70
rheolef::my_idxtype
int my_idxtype
Definition: geo_partition_scotch.h:28
rheolef::MeshType
Definition: geo_partition_scotch.h:67
rheolef::MeshType::esize
int esize
Definition: geo_partition_scotch.h:74
rheolef::MeshType::MeshType
MeshType()
Definition: geo_partition_scotch.h:82
rheolef
This file is part of Rheolef.
Definition: compiler_eigen.h:37
rheolef::MeshType::elmwgt
my_idxtype * elmwgt
Definition: geo_partition_scotch.h:75
rheolef::MeshType::gnns
int gnns
Definition: geo_partition_scotch.h:71
rheolef::MeshType::gnelms
int gnelms
Definition: geo_partition_scotch.h:71
rheolef::geo_partition_scotch
void geo_partition_scotch(my_idxtype *elmdist, my_idxtype *eptr, vector< my_idxtype > &eind, my_idxtype *elmwgt, int *ncon, int *ncommonnodes, int *nparts, float *tpwgts, float *ubvec, int *edgecut, my_idxtype *part, const mpi::communicator &comm)
Definition: geo_mpi_partition_scotch.cc:48
mkgeo_ball.n
n
Definition: mkgeo_ball.sh:150
rheolef::idxamax
int idxamax(int n, const std::vector< my_idxtype > &x)
Definition: geo_partition_scotch.h:160
rheolef::MeshType::nns
int nns
Definition: geo_partition_scotch.h:72
rheolef::MeshType::ncon
int ncon
Definition: geo_partition_scotch.h:73
rheolef::MeshType::elements
std::vector< my_idxtype > elements
Definition: geo_partition_scotch.h:69