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;
33 #endif // _RHEOLEF_HAVE_PARMETIS
48 communicator comm = ios_ownership.
comm();
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;
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++) {
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++) {
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->(),
144 #else // _RHEOLEF_HAVE_PARMETIS
145 # error either parmetis nor scotch partitioner founded
146 #endif // _RHEOLEF_HAVE_PARMETIS
149 std::copy (part.begin(), part.end(), partition.begin());
154 #endif // _RHEOLEF_HAVE_MPI