8#ifndef DISTGRAPHFACTORYOLD_HPP_
9#define DISTGRAPHFACTORYOLD_HPP_
11#include "VCluster/VCluster.hpp"
12#include "Vector/map_vector.hpp"
13#include "Graph/map_graph.hpp"
14#include "Grid/grid_sm.hpp"
15#include "Space/Shape/Box.hpp"
16#include "Space/Shape/HyperCube.hpp"
47template<
unsigned int dim,
typename dT,
typename G_v,
typename v,
int impl>
74 typedef typename boost::fusion::result_of::at<v, boost::mpl::int_<T::value>>::type t_val;
76 g_v.template get<t_val::value>() =
gk.
get(T::value) *
szd[T::value];
107template<
unsigned int dim,
typename dT,
typename G_v,
typename v>
151template<
unsigned int dim,
typename dT,
typename G_v,
typename v>
179 typedef typename boost::fusion::result_of::at<v, boost::mpl::int_<0>>::type t_val;
180 typedef typename boost::mpl::at<typename G_v::T_type::type,t_val>::type s_type;
182 for (
size_t i = 0 ; i < std::extent<s_type>::value ; i++)
183 g_v.template get<t_val::value>()[i] = 0.0;
185 for (
size_t i = 0 ; i < dim ; i++)
186 g_v.template get<t_val::value>()[i] =
gk.
get(i) *
static_cast<float>(
szd[i]);
197template<
int i,
typename p,
typename Graph,
int ... pos>
201 typedef typename boost::mpl::at<p, boost::mpl::int_<0>>::type v_element;
202 typedef typename boost::mpl::at<typename Graph::V_type::type, v_element>::type pos_prop_type;
206 value = ((
sizeof...(pos) != 0) * (std::is_array<pos_prop_type>::value + 1))
218template<
typename p,
typename Graph,
int ... pos>
236template<
unsigned int dim,
typename Graph,
int se,
typename T,
unsigned int dim_c,
int ... pos>
248 for (
size_t i = 0; i < dim; i++)
270 size_t mod_v = g.
size() % Np;
271 size_t div_v = g.
size() / Np;
276 for (
int i = 0; i <= Np; i++)
279 vtxdist.get(i) = (div_v + 1) * (i);
281 vtxdist.get(i) = (div_v) * (i) + mod_v;
285 size_t gp_size = vtxdist.get(p_id + 1) - vtxdist.get(p_id);
291 gp.initDistributionVector(vtxdist);
312 if (v_id < vtxdist.get(p_id + 1) && v_id >= vtxdist.get(p_id))
319 auto obj = gp.vertex(local_it);
325 fill_prop_v<dim, T,
decltype(gp.vertex(local_it)),
typename to_boost_vmpl<pos...>::type,
fill_prop_v_by_type<
sizeof...(pos), p, Graph, pos...>::value> flp(obj, szd, key, g);
329 boost::mpl::for_each<boost::mpl::range_c<int, 0,
sizeof...(pos)> >(flp);
333 gp.setGlobalMap(v_id, local_it, v_id);
337 for (
size_t d = dim - 1; d >= dim_c; d--)
345 for (
size_t j = 0; j < c.size(); j++)
353 for (
size_t s = 0; s < dim; s++)
355 ele_sz += szd[s] * abs(c[j][s]);
361 size_t start_v = local_it;
362 size_t end_v = g.template LinId<CheckExistence>(key, c[j].getComb());
365 if (end_v < g.
size())
368 gp.template addEdge<NoCheck>(start_v, end_v).template get<se>() = ele_sz;
390template<
unsigned int dim,
typename Graph,
typename T,
unsigned int dim_c,
int ... pos>
403 for (
size_t i = 0; i < dim; i++)
425 size_t mod_v = g.
size() % Np;
426 size_t div_v = g.
size() / Np;
431 for (
size_t i = 0; i <= Np; i++)
434 vtxdist.get(i) = (div_v + 1) * (i);
436 vtxdist.get(i) = (div_v) * (i) + mod_v;
439 size_t gp_size = vtxdist.get(p_id + 1) - vtxdist.get(p_id);
445 gp.initDistributionVector(vtxdist);
466 if (v_id < (
size_t)vtxdist.get(p_id + 1) && v_id >= (
size_t)vtxdist.get(p_id))
471 auto obj = gp.vertex(local_it);
477 fill_prop_v<dim, T,
decltype(gp.vertex(local_it)),
typename to_boost_vmpl<pos...>::type,
fill_prop_v_by_type<
sizeof...(pos), p, Graph, pos...>::value> flp(obj, szd, key, g);
481 boost::mpl::for_each<boost::mpl::range_c<int, 0,
sizeof...(pos)> >(flp);
485 gp.setGlobalMap(v_id, local_it, v_id);
489 for (
size_t d = dim - 1; d >= dim_c; d--)
497 for (
size_t j = 0; j < c.size(); j++)
505 for (
size_t s = 0; s < dim; s++)
507 ele_sz += szd[s] * abs(c[j][s]);
513 size_t start_v = local_it;
514 size_t end_v = g.template LinId<CheckExistence>(key, c[j].getComb());
517 if (end_v < g.
size())
520 gp.addEdge(start_v, end_v, v_id, end_v);
540template<
unsigned int dim,
typename Graph>
565 template<
int se,
typename T,
unsigned int dim_c,
int ... pos>
This class represent an N-dimensional box.
__device__ __host__ T getLow(int i) const
get the i-coordinate of the low bound interval of the box
__device__ __host__ T getHigh(int i) const
get the high interval of the box
This class construct a cartesian graph.
static Graph construct(const size_t(&sz)[dim], Box< dim, T > dom)
Construct a cartesian graph, with V and E edge properties.
static Graph construct(const size_t(&sz)[dim], Box< dim, T > dom)
Construct Cartesian graph.
Graph constructor function specialization.
static Graph construct(const size_t(&sz)[dim], Box< dim, T > dom)
Construct Cartesian graph.
This class calculate elements of the hyper-cube.
static std::vector< comb< dim > > getCombinations_R(size_t d)
size_t getProcessUnitID()
Get the process unit id.
size_t getProcessingUnits()
Get the total number of processors.
Implementation of VCluster class.
void operator()(T &t) const
It call the function for each property we want to copy.
fill_prop_v(G_v &g_v, const dT(&szd)[dim], grid_key_dx< dim > &gk, const grid_sm< dim, void > &gs)
Fill the object from where to take the properties.
G_v & g_v
Vertex object to fill.
fill_prop_v(G_v &g_v, const dT(&szd)[dim], grid_key_dx< dim > &gk, const grid_sm< dim, void > &gs)
Fill the object from where to take the properties.
const grid_sm< dim, void > & gs
grid info
void operator()(T &t) const
It call the function for each property we want to copy.
grid_key_dx< dim > & gk
grid_key_dx Reference containing the actual position
This class work as a functor.
fill_prop_v(G_v &g_v, const dT(&szd)[dim], grid_key_dx< dim > &gk, const grid_sm< dim, void > &gs)
Fill the object from where to take the properties.
const dT(& szd)[dim]
Reference to an array containing the spacing.
G_v & g_v
Vertex object to fill.
void operator()(T &t) const
It call the function for each property we want to copy.
grid_key_dx< dim > & gk
grid_key_dx Reference containing the actual position
const grid_sm< dim, void > & gs
grid info
const grid_key_dx< dim > & get() const
Get the actual key.
bool isNext()
Check if there is the next element.
grid_key_dx is the key to access any element in the grid
__device__ __host__ index_type get(index_type i) const
Get the i index.
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__ size_t size() const
Return the size of the grid.
Implementation of 1-D std::vector like structure.
Operator for vector and scalar property.
boost::mpl::vector< boost::mpl::int_< id >... > type
construct an mpl vector from the variadic