27 #ifndef _SF_PARTITIONING_H 28 #define _SF_PARTITIONING_H 43 template<
class T,
class S>
57 template<
class T,
class S>
67 parmetis_partitioner() : _unbalance(1.01f), _ncommon(2)
70 parmetis_partitioner(
float ub,
short nc) : _unbalance(ub), _ncommon(nc)
82 MPI_Comm comm = mesh.
comm;
85 MPI_Comm_size(comm, &size); MPI_Comm_rank(comm, &rank);
97 MPI_Allgather(&numelem,
sizeof(idx_t), MPI_BYTE, elemdist_cnt.data(),
sizeof(idx_t), MPI_BYTE, comm);
101 int ncommonnod = _ncommon;
104 idx_t* elemwgt = NULL;
108 for(
size_t i=0; i<tpwgts.
size(); i++) tpwgts[i] = (
float)1. / (float)(nparts*ncon);
111 for (
int i = 0; i < ncon; i++ ) ubvec[i] = _unbalance;
120 for(
size_t i=0; i<mesh.
con.size(); i++) eind[i] = rnod[mesh.
con[i]];
125 ParMETIS_V3_PartMeshKway(elemdist_dsp.
data(),
148 template<
class T,
class S>
154 int size; MPI_Comm_size(mesh.
comm, &size);
167 T elemsize = mesh.
dsp[i+1] - dsp;
169 for(T j=0; j<elemsize; j++) {
170 T v = mesh.
con[dsp+j];
171 avrg.
x += mesh.
xyz[v*3+0];
172 avrg.
y += mesh.
xyz[v*3+1];
173 avrg.
z += mesh.
xyz[v*3+2];
175 avrg.
x /= S(elemsize);
176 avrg.
y /= S(elemsize);
177 avrg.
z /= S(elemsize);
186 partitioner(mesh.
comm, ctr, size, part);
188 part_vec.
assign(part.begin(), part.end());
The mesh storage class. It contains both element and vertex data.
The vector class and related algorithms.
vector< T > & get_numbering(SF_nbr nbr_type)
Get the vector defining a certain numbering.
MPI_Comm comm
the parallel mesh is defined on a MPI world
vector< T > dsp
connectivity starting index of each element
minimalistic internal point struct
kdtree based partitioning classes.
The nodal numbering of the reference mesh (the one stored on HD).
vector< S > xyz
node cooridnates
T * data()
Pointer to the vector's start.
size_t size() const
The current size of the vector.
virtual void operator()(const meshdata< T, S > &mesh, vector< T > &part)=0
A vector storing arbitrary data.
size_t l_numelem
local number of elements
Abstract base class for a mesh partitioner.
void assign(InputIterator s, InputIterator e)
Assign a memory range.
void vec_assign(S *lhs, const V *rhs, size_t size)
Assign the values in rhs to lhs. The data-type of rhs is cast to the type of lhs. ...
void resize(size_t n)
Resize a vector.
void dsp_from_cnt(const vector< T > &cnt, vector< T > &dsp)
Compute displacements from counts.