8#ifndef SRC_DECOMPOSITION_DISTRIBUTION_SPACEDISTRIBUTIONWEIGHT_HPP_
9#define SRC_DECOMPOSITION_DISTRIBUTION_SPACEDISTRIBUTIONWEIGHT_HPP_
13#include "util/mathutil.hpp"
14#include "NN/CellList/CellDecomposer.hpp"
24template<
unsigned int dim,
typename T>
25class SpaceDistributionWeight
49 SpaceDistributionWeight(
Vcluster & v_cl)
59 SpaceDistributionWeight(SpaceDistributionWeight<dim,T> && pm)
73 for (
size_t i = 0 ; i < dim ; i++)
82 gp = g_factory_part.template construct<NO_EDGE,
nm_v::id, T, dim - 1, 0>(gr.
getSize(), domain, bc);
88 gp.
vertex(i).template get<nm_v::x>()[2] = 0.0;
91 gp.
vertex(i).template get<nm_v::global_id>() = i;
111 v_cl.SGather(id_w,0);
117 tot /= v_cl.getProcessingUnits();
120 if (v_cl.getProcessUnitID() == 0)
122 for (
size_t i = 0 ; i < id_w.
size() ; i++)
123 gp.template vertex_p<nm_v::computation>(id_w.get(i).id) = id_w.get(i).w;
130 for (
size_t i = 0; i < dim ; i++)
132 if (max < gr.
size(i))
137 size_t order = openfpm::math::log2_64(max);
138 if (1ul << order < max)
141 size_t n = 1 << order;
145 CellDecomposer_sm<dim,T> cd_sm;
146 cd_sm.setDimensions(domain, gr.
getSize(), 0);
156 for (
size_t i = 0 ; i < dim ; i++)
157 spacing[i] = (domain.getHigh(i) - domain.getLow(i)) / n;
169 g.template get<0>(key) = -1;
177 while (h_it.isNext())
179 auto key = h_it.get();
184 for (
size_t i = 0 ; i < dim ; i++)
185 p.
get(i) = key.get(i) * spacing[i] + spacing[i] / 2;
189 if (g.template get<0>(sp) == -1)
191 g.template get<0>(sp) = proc_d;
207 auto key = it2.get();
209 gp.template vertex_p<nm_v::proc_id>(gr.
LinId(key)) = g.template get<0>(key);
211 id_w.get(g.template get<1>(key)) = g.template get<1>(key);
243 return gr.
size() % v_cl.getProcessingUnits();
252 void getSubSubDomainPosition(
size_t id, T (&pos)[dim])
256 std::cerr << __FILE__ <<
":" << __LINE__ <<
"Such vertex doesn't exist (id = " <<
id <<
", " <<
"total size = " << gp.
getNVertex() <<
")\n";
260 pos[0] = gp.
vertex(
id).template get<nm_v::x>()[0];
261 pos[1] = gp.
vertex(
id).template get<nm_v::x>()[1];
263 pos[2] = gp.
vertex(
id).template get<nm_v::x>()[2];
272 inline void setComputationCost(
size_t id,
size_t weight)
274 std::cout << __FILE__ <<
":" << __LINE__ <<
" You are trying to set the computation cost on a fixed decomposition, this operation has no effect" << std::endl;
281 bool weightsAreUsed()
291 size_t getSubSubDomainComputationCost(
size_t id)
300 size_t getProcessorLoad()
303 size_t Np = v_cl.getProcessingUnits();
307 size_t N_tot = gr.
size();
308 size_t N_best_each = N_tot / Np;
309 size_t N_rest = N_tot % Np;
311 if (v_cl.getProcessUnitID() < N_rest)
322 void setMigrationCost(
size_t id,
size_t migration)
332 void setCommunicationCost(
size_t v_id,
size_t e,
size_t communication)
339 size_t getNSubSubDomains()
348 size_t getNSubSubDomainNeighbors(
size_t id)
358 void write(
const std::string & file)
361 gv2.write(std::to_string(v_cl.getProcessUnitID()) +
"_" + file +
".vtk");
367 domain = dist.domain;
377 domain = dist.domain;
This class represent an N-dimensional box.
This class construct a cartesian graph.
Structure that store a graph in CSR format or basically in compressed adjacency matrix format.
auto vertex(size_t id) -> decltype(v.get(id))
Function to access the vertex.
size_t getNChilds(size_t c) const
Return the number of childs of a vertex.
void swap(Graph_CSR< V, E > &g)
swap the memory of g with this graph
size_t getNVertex() const
Return the number of the vertex.
This class implement the point shape in an N-dimensional space.
__device__ __host__ const T & get(unsigned int i) const
Get coordinate.
Class that distribute sub-sub-domains across processors using an hilbert curve to divide the space.
Implementation of VCluster class.
grid_key_dx is the key to access any element in the grid
mem_id LinId(const grid_key_dx< N, ids_type > &gk, const signed char sum_id[N]) const
Linearization of the grid_key_dx with a specified shift.
__device__ __host__ const size_t(& getSize() const)[N]
Return the size of the grid as an array.
__device__ __host__ size_t size() const
Return the size of the grid.
Implementation of 1-D std::vector like structure.
static const unsigned int id
id property id in boost::fusion::vector