8#ifndef CARTESIANGRAPHFACTORY_HPP_
9#define CARTESIANGRAPHFACTORY_HPP_
11#include "Vector/map_vector.hpp"
12#include "Graph/map_graph.hpp"
13#include "Grid/grid_sm.hpp"
14#include "Space/Shape/Box.hpp"
15#include "Space/Shape/HyperCube.hpp"
17#define NO_VERTEX_ID -1
25template<
unsigned int dim,
typename G_v,
int prp>
31 g_v.template get<prp>() = gs.
LinId(gk);
39template<
unsigned int dim,
typename G_v>
76template<
unsigned int dim,
int lin_
id,
typename dT,
typename G_v,
typename v,
int impl>
106 typedef typename boost::fusion::result_of::at<v, boost::mpl::int_<T::value>>::type t_val;
139template<
unsigned int dim,
int lin_
id,
typename dT,
typename G_v,
typename v>
183template<
unsigned int dim,
int lin_
id,
typename dT,
typename G_v,
typename v>
213 typedef typename boost::fusion::result_of::at<v, boost::mpl::int_<0>>::type t_val;
214 typedef typename boost::mpl::at<typename G_v::T_type::type,t_val>::type s_type;
216 for (
size_t i = 0 ; i < std::extent<s_type>::value ; i++)
217 g_v.template get<t_val::value>()[i] = 0.0;
219 for (
size_t i = 0 ; i < dim ; i++)
233template<
unsigned int dim,
int i,
typename p,
typename Graph,
int ... pos>
238 typedef typename boost::mpl::at<p, boost::mpl::int_<0>>::type
v_element;
241 typedef typename boost::mpl::at<typename Graph::V_type::type, v_element>::type
pos_prop_type;
245 value = ((
sizeof...(pos) != 0) * (std::is_array<pos_prop_type>::value + 1))
257template<
unsigned int dim,
typename p,
typename Graph,
int ... pos>
275template<
unsigned int dim,
int lin_id,
typename Graph,
int se,
typename T,
unsigned int dim_c,
int ... pos>
294 for (
size_t i = 0; i < dim; i++)
332 auto obj = gp.vertex(g.
LinId(key));
338 fill_prop<dim, lin_id, T,
decltype(gp.vertex(g.
LinId(key))),
typename to_boost_vmpl<pos...>::type,
fill_prop_by_type<dim,
sizeof...(pos), p, Graph, pos...>::value> flp(obj, szd, key, g, dom);
342 boost::mpl::for_each<boost::mpl::range_c<int, 0,
sizeof...(pos)> >(flp);
346 for (
long int d = dim-1 ; d >= dim_c ; d--)
354 for (
size_t j = 0; j < c.size(); j++)
363 for (
size_t s = 0 ; s < dim ; s++)
364 ele_sz += szd[s] * abs(c[j][s]);
369 size_t start_v = g.
LinId(key);
371 size_t end_v = g.template LinId<CheckExistence>(key,c[j].getComb(),bc);
374 gp.template addEdge<CheckExistence>(start_v, end_v).template get<se>() = ele_sz;
396template<
unsigned int dim,
int lin_id,
typename Graph,
typename T,
unsigned int dim_c,
int ... pos>
416 for (
size_t i = 0; i < dim; i++)
453 auto obj = gp.vertex(g.
LinId(key));
459 fill_prop<dim, lin_id, T,
decltype(gp.vertex(g.
LinId(key))),
typename to_boost_vmpl<pos...>::type,
fill_prop_by_type<dim,
sizeof...(pos), p, Graph, pos...>::value> flp(obj, szd, key, g, dom);
463 boost::mpl::for_each_ref<boost::mpl::range_c<int, 0,
sizeof...(pos)> >(flp);
467 for (
long int d = dim-1 ; d >= dim_c ; d--)
475 for (
size_t j = 0; j < c.size(); j++)
480 size_t start_v = g.
LinId(key);
482 size_t end_v = g.template LinId<CheckExistence>(key,c[j].getComb(),bc);
485 gp.template addEdge<CheckExistence>(start_v, end_v);
506template<
unsigned int dim,
typename Graph>
539 template<
int se,
int id_prp,
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, const size_t(&bc)[dim])
Construct a cartesian graph, with V and E edge properties.
static Graph construct(const size_t(&sz)[dim], Box< dim, T > &dom, const size_t(&bc)[dim])
Construct a cartesian graph.
Graph constructor function specialization.
static Graph construct(const size_t(&sz)[dim], Box< dim, T > &dom, const size_t(&bc)[dim])
Construct a cartesian graph.
This class calculate elements of the hyper-cube.
static std::vector< comb< dim > > getCombinations_R(size_t d)
void operator()(T &t) const
It call the function for each property we want to copy.
fill_prop(G_v &g_v, const dT(&szd)[dim], grid_key_dx< dim > &gk, const grid_sm< dim, void > &gs, const Box< dim, dT > &domain)
Fill the object from where to take the properties.
fill_prop(G_v &g_v, const dT(&szd)[dim], grid_key_dx< dim > &gk, const grid_sm< dim, void > &gs, const Box< dim, dT > &domain)
Fill the object from where to take the properties.
const Box< dim, dT > & domain
Domain.
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
G_v & g_v
Vertex object to fill.
This class work as a functor.
void operator()(T &t) const
It call the function for each property we want to copy.
fill_prop(G_v &g_v, const dT(&szd)[dim], grid_key_dx< dim > &gk, const grid_sm< dim, void > &gs, const Box< dim, dT > &domain)
Fill the object from where to take the properties.
G_v & g_v
Vertex object to fill.
const Box< dim, dT > & domain
Domain.
grid_key_dx< dim > & gk
grid_key_dx Reference containing the actual position
const dT(& szd)[dim]
Reference to an array containing the spacing.
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.
static void fill(G_v &g_v, const grid_key_dx< dim > &gk, const grid_sm< dim, void > &gs)
function that fill with linearization indexes
Operator to fill the property 'prp' with the linearization of indexes.
static void fill(G_v &g_v, const grid_key_dx< dim > &gk, const grid_sm< dim, void > &gs)
function that fill with linearization indexes
Operator for vector and scalar property.
boost::mpl::at< typenameGraph::V_type::type, v_element >::type pos_prop_type
Get the property v_element (v_element is a number)
boost::mpl::at< p, boost::mpl::int_< 0 > >::type v_element
Get the element 0.
boost::mpl::vector< boost::mpl::int_< id >... > type
construct an mpl vector from the variadic