23 #include "rheolef/config.h"
24 #ifdef _RHEOLEF_HAVE_MPI
25 #include "rheolef/geo_element.h"
26 #include "rheolef/hack_array.h"
28 #if defined(_RHEOLEF_HAVE_SCOTCH)
30 #elif defined(_RHEOLEF_HAVE_PARMETIS)
32 typedef idx_t idxtype;
41 const distributor& ios_ownership,
48 communicator comm = ios_ownership.comm();
52 disarray<size_type> partition (ios_ownership);
54 if (partition.dis_size() <= nproc || dis_nv <= nproc) {
56 for (
size_type ie = 0, nie = ios_ownership.size(); ie < nie; ie++) {
57 partition [ie] = my_proc;
62 disarray<idxtype> part (ios_ownership);
63 std::vector<idxtype> elmdist (nproc+1);
65 ios_ownership.begin(),
68 std::vector<idxtype> eptr (ios_ownership.dis_size()+1);
74 for (const_iterator_by_variant iter = ios_geo_element [
variant].begin(), last = ios_geo_element [
variant].end();
75 iter != last; iter++, ie++) {
76 const geo_element& K = *iter;
77 eptr [ie+1] = eptr[ie] + K.size();
81 std::vector<idxtype> eind (eptr [ios_ownership.size()]);
82 std::vector<idxtype>::iterator iter_eind = eind.begin();
86 for (const_iterator_by_variant iter = ios_geo_element [
variant].begin(), last = ios_geo_element [
variant].end();
87 iter != last; iter++) {
88 const geo_element& K = *iter;
89 for (
size_type iloc = 0; iloc < K.size(); iloc++, iter_eind++) {
100 std::vector<float> tpwgts (nparts*ncon);
101 std::fill (tpwgts.begin(), tpwgts.end(), 1./nparts);
103 std::fill (ubvec, ubvec+ncon, 1.05);
106 const int pvm3_option_dbglvl = 1;
107 const int pvm3_option_seed = 2;
108 options[pvm3_option_dbglvl] = 0;
109 options[pvm3_option_seed] = 0;
111 MPI_Comm raw_comm = comm;
113 #if defined(_RHEOLEF_HAVE_SCOTCH)
115 elmdist.begin().operator->(),
116 eptr.begin().operator->(),
122 tpwgts.begin().operator->(),
125 part.begin().operator->(),
127 #elif defined(_RHEOLEF_HAVE_PARMETIS)
128 ParMETIS_V3_PartMeshKway(
129 elmdist.begin().operator->(),
130 eptr.begin().operator->(),
131 eind.begin().operator->(),
138 tpwgts.begin().operator->(),
142 part.begin().operator->(),
145 # error either parmetis nor scotch partitioner founded
149 std::copy (part.begin(), part.end(), partition.begin());
field::size_type size_type
rep::base::size_type size_type
std::vector< T, A >::const_iterator const_iterator
static const variant_type max_variant
static variant_type last_variant_by_dimension(size_type dim)
static variant_type first_variant_by_dimension(size_type dim)
This file is part of Rheolef.
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)