8 #ifndef SRC_DECOMPOSITION_DISTRIBUTION_SPACEDISTRIBUTION_HPP_ 
    9 #define SRC_DECOMPOSITION_DISTRIBUTION_SPACEDISTRIBUTION_HPP_ 
   11 #include "util/mathutil.hpp" 
   12 #include "NN/CellList/CellDecomposer.hpp" 
   13 #include "Grid/grid_key_dx_iterator_hilbert.hpp" 
   23 template<
unsigned int dim, 
typename T>
 
   81         for (
size_t i = 0 ; i < dim ; i++)
 
   96                 gp.
vertex(i).template get<nm_v::x>()[2] = 0.0;
 
   99             gp.
vertex(i).template get<nm_v::global_id>() = i;
 
  122         size_t N_best_each = N_tot / Np;
 
  123         size_t N_rest = N_tot % Np;
 
  126         accu.get(0) = N_best_each + ((0 < N_rest)?1:0);
 
  127         for (
size_t i = 1 ; i < Np ; i++)
 
  128             accu.get(i) = accu.get(i-1) + N_best_each + ((i < N_rest)?1:0);
 
  135         for (
size_t i = 0; i < dim ; i++)
 
  142         size_t order = openfpm::math::log2_64(max);
 
  143         if (1ul << order < max)
 
  146         size_t n = 1 << order;
 
  150         CellDecomposer_sm<dim,T> cd_sm;
 
  161         for (
size_t i = 0 ; i < dim ; i++)
 
  162             spacing[i] = (
domain.getHigh(i) - 
domain.getLow(i)) / n;
 
  174             g.template get<0>(
key) = -1;
 
  190           for (
size_t i = 0 ; i < dim ; i++)
 
  191               p.
get(i) = 
key.get(i) * spacing[i] + spacing[i] / 2;
 
  195           if (g.template get<0>(sp) == -1)
 
  197               g.template get<0>(sp) = proc_d;
 
  200               if (ele_d >= accu.get(proc_d))
 
  215             gp.template vertex_p<nm_v::proc_id>(
gr.
LinId(
key)) = g.template get<0>(
key);
 
  230         std::cout << __FILE__ << 
":" << __LINE__ << 
" You are trying to dynamicaly balance a fixed decomposition, this operation has no effect" << std::endl;
 
  252             std::cerr << __FILE__ << 
":" << __LINE__ << 
"Such vertex doesn't exist (id = " << 
id << 
", " << 
"total size = " << 
gp.
getNVertex() << 
")\n";
 
  256         pos[0] = 
gp.
vertex(
id).template get<nm_v::x>()[0];
 
  257         pos[1] = 
gp.
vertex(
id).template get<nm_v::x>()[1];
 
  259             pos[2] = 
gp.
vertex(
id).template get<nm_v::x>()[2];
 
  270         std::cout << __FILE__ << 
":" << __LINE__ << 
" You are trying to set the computation cost on a fixed decomposition, this operation has no effect" << std::endl;
 
  306         size_t N_best_each = N_tot / Np;
 
  307         size_t N_rest = N_tot % Np;
 
  358     void write(
const std::string & file)
 
bool weightsAreUsed()
Checks if weights are used on the vertices. 
 
mem_id LinId(const grid_key_dx< N > &gk, const char sum_id[N]) const 
Linearization of the grid_key_dx with a specified shift. 
 
SpaceDistribution(const ParMetisDistribution< dim, T > &pm)
 
void setComputationCost(size_t id, size_t weight)
Function that set the weight of the vertex. 
 
SpaceDistribution(Vcluster &v_cl)
 
grid_key_dx is the key to access any element in the grid 
 
size_t getProcessUnitID()
Get the process unit id. 
 
size_t size() const 
Return the size of the grid. 
 
Class that distribute sub-sub-domains across processors using an hilbert curve to divide the space...
 
This class implement the point shape in an N-dimensional space. 
 
void write(const std::string &file)
Print the current distribution and save it to VTK file. 
 
Implementation of VCluster class. 
 
This class construct a cartesian graph. 
 
void setMigrationCost(size_t id, size_t migration)
Set migration cost of the vertex id. 
 
Class that distribute sub-sub-domains across processors using ParMetis Library. 
 
size_t getSubSubDomainComputationCost(size_t id)
function that get the weight of the vertex 
 
Graph_CSR< nm_v, nm_e > gp
Global sub-sub-domain graph. 
 
const size_t(& getSize() const)[N]
Return the size of the grid as an array. 
 
Box< dim, T > domain
rectangular domain to decompose 
 
const grid_key_dx< dim > & get() const 
Get the actual key. 
 
SpaceDistribution(SpaceDistribution< dim, T > &&pm)
 
size_t getNSubSubDomains()
Returns total number of sub-sub-domains in the distribution graph. 
 
size_t getProcessorLoad()
Compute the processor load counting the total weights of its vertices. 
 
void setCommunicationCost(size_t v_id, size_t e, size_t communication)
Set communication cost of the edge id. 
 
const T & get(size_t i) const 
Get coordinate. 
 
bool isNext()
Check if there is the next element. 
 
void getSubSubDomainPosition(size_t id, T(&pos)[dim])
function that return the position of the vertex in the space 
 
This class represent an N-dimensional box. 
 
void refine()
Refine current decomposition. 
 
This class is a trick to indicate the compiler a specific specialization pattern. ...
 
auto vertex(size_t id) -> decltype(v.get(id))
Function to access the vertex. 
 
void createCartGraph(grid_sm< dim, void > &grid, Box< dim, T > dom)
Create the Cartesian graph. 
 
size_t getNVertex() const 
Return the number of the vertex. 
 
static const unsigned int id
id property id in boost::fusion::vector 
 
void swap(Graph_CSR< V, E > &g)
swap the memory of g with this graph 
 
grid_sm< dim, void > gr
Structure that store the cartesian grid information. 
 
size_t get_ndec()
It return the decomposition id. 
 
const grid_key_dx< dim > & get()
Get the actual key. 
 
size_t getNChilds(size_t c) const 
Return the number of childs of a vertex. 
 
void decompose()
Create the decomposition. 
 
float getUnbalance()
Compute the unbalance of the processor compared to the optimal balance. 
 
size_t getProcessingUnits()
Get the total number of processors. 
 
bool isNext()
Check if there is the next element. 
 
Graph_CSR< nm_v, nm_e > & getGraph()
Get the current graph (main) 
 
size_t getNSubSubDomainNeighbors(size_t id)
Returns total number of neighbors of the sub-sub-domain id.