Commit bde44d6e authored by incardon's avatar incardon

Fixing vector dist in high dimension

parent a0729db4
......@@ -242,7 +242,7 @@ struct fill_prop_by_type
enum
{
value = ((sizeof...(pos) != 0 && dim <= 3) * (std::is_array<pos_prop_type>::value + 1))
value = ((sizeof...(pos) != 0) * (std::is_array<pos_prop_type>::value + 1))
};
};
......
......@@ -487,7 +487,7 @@ public:
*
*/
template <unsigned int p, typename r_type=decltype(boost::fusion::at_c<p>(data_c))>
inline r_type get()
__device__ __host__ inline r_type get()
{
#ifdef SE_CLASS2
check_valid(&boost::fusion::at_c<p>(data_c),sizeof(typename boost::mpl::at<type,boost::mpl::int_<p>>::type));
......@@ -501,7 +501,7 @@ public:
*
*/
template <unsigned int p, typename r_type=decltype(boost::fusion::at_c<p>(data_c))>
inline const r_type get() const
__device__ __host__ inline const r_type get() const
{
#ifdef SE_CLASS2
check_valid(&boost::fusion::at_c<p>(data_c),sizeof(typename boost::mpl::at<type,boost::mpl::int_<p>>::type));
......@@ -516,7 +516,8 @@ public:
* \param ele value to set
*
*/
template <unsigned int p> inline void set(decltype(boost::fusion::at_c<p>(data_c)) & ele)
template <unsigned int p> inline
__device__ __host__ void set(decltype(boost::fusion::at_c<p>(data_c)) & ele)
{
#ifdef SE_CLASS2
check_valid(&boost::fusion::at_c<p>(data_c),sizeof(typename boost::mpl::at<type,boost::mpl::int_<p>>::type));
......@@ -534,7 +535,8 @@ public:
* \return itself
*
*/
template<unsigned int dim2> inline encapc<dim,T,Mem> & set(const encapc<dim2,T,Mem> & ec)
template<unsigned int dim2>
__device__ __host__ inline encapc<dim,T,Mem> & set(const encapc<dim2,T,Mem> & ec)
{
copy_cpu_encap_encap<encapc<dim2,T,Mem>,encapc<dim,T,Mem>> cp(ec,*this);
......
......@@ -1041,16 +1041,16 @@ public:
* \return An aiterator across the neighborhood particles
*
*/
template<unsigned int impl>
inline CellNNIteratorSymMP<dim,CellList<dim,T,Mem_type,transform,vector_pos_type>,vector_pos_type,(unsigned int)SYM,impl>
getNNIteratorSymMP(size_t cell, size_t p, const vector_pos_type & v_p1, const vector_pos_type & v_p2)
template<unsigned int impl, typename vector_pos_type2>
inline CellNNIteratorSymMP<dim,CellList<dim,T,Mem_type,transform,vector_pos_type>,vector_pos_type2,(unsigned int)SYM,impl>
getNNIteratorSymMP(size_t cell, size_t p, const vector_pos_type2 & v_p1, const vector_pos_type2 & v_p2)
{
#ifdef SE_CLASS1
if (from_cd == false)
std::cerr << __FILE__ << ":" << __LINE__ << " Warning when you try to get a symmetric neighborhood iterator, you must construct the Cell-list in a symmetric way" << std::endl;
#endif
CellNNIteratorSymMP<dim,CellList<dim,T,Mem_type,transform,vector_pos_type>,vector_pos_type,SYM,impl> cln(cell,p,NNc_sym,*this,v_p1,v_p2);
CellNNIteratorSymMP<dim,CellList<dim,T,Mem_type,transform,vector_pos_type>,vector_pos_type2,SYM,impl> cln(cell,p,NNc_sym,*this,v_p1,v_p2);
return cln;
}
......
......@@ -62,11 +62,11 @@ namespace openfpm
typedef int yes_i_am_vector;
//! Type of the encapsulation memory parameter
typedef typename memory_traits_inte<T_>::type layout_type;
typedef typename layout_base<T_>::type layout_type;
//! Object container for T, it is the return type of get_o it return a object type trough
// you can access all the properties of T
typedef typename grid_cpu<1,T_,CudaMemory,typename memory_traits_inte<T_>::type>::container container;
typedef typename grid_cpu<1,T_,CudaMemory,typename layout_base<T_>::type>::container container;
//! Type of the value the vector is storing
typedef T_ value_type;
......
......@@ -685,6 +685,24 @@ struct meta_copy_op
}
};
//! Partial specialization for N=1 1D-Array
template<template<typename,typename> class op, typename T, typename vmpl>
struct meta_copy_op<op,openfpm::detail::multi_array::sub_array_openfpm<T,1,vmpl>>
{
/*! \brief Meta-copy applying an operation
*
* \param src source object
* \param dst destination object
*
*/
static inline void meta_copy_op_(const openfpm::detail::multi_array::sub_array_openfpm<T,1,vmpl> src, openfpm::detail::multi_array::sub_array_openfpm<T,1,vmpl> dst)
{
for (size_t i1 = 0 ; i1 < boost::mpl::at<vmpl,boost::mpl::int_<0>>::type::value ; i1++)
{
copy_general_op<op,T>(src[i1],dst[i1]);
}
}
};
//! Partial specialization for N=1 1D-Array
template<template<typename,typename> class op, typename T,size_t N1>
......@@ -705,6 +723,28 @@ struct meta_copy_op<op,T[N1]>
}
};
//! Partial specialization for N=2 2D-Array
template<template<typename,typename> class op, typename T, typename vmpl>
struct meta_copy_op<op,openfpm::detail::multi_array::sub_array_openfpm<T,2,vmpl>>
{
/*! \brief Meta-copy applying an operation
*
* \param src source object
* \param dst destination object
*
*/
static inline void meta_copy_op_(const openfpm::detail::multi_array::sub_array_openfpm<T,2,vmpl> src, openfpm::detail::multi_array::sub_array_openfpm<T,2,vmpl> dst)
{
for (size_t i1 = 0 ; i1 < boost::mpl::at<vmpl,boost::mpl::int_<0>>::type::value ; i1++)
{
for (size_t i2 = 0 ; i2 < boost::mpl::at<vmpl,boost::mpl::int_<1>>::type::value ; i2++)
{
copy_general_op<op,T>(src[i1][i2],dst[i1][i2]);
}
}
}
};
//! Partial specialization for N=2 2D-Array
template<template<typename,typename> class op, typename T,size_t N1,size_t N2>
struct meta_copy_op<op,T[N1][N2]>
......@@ -818,6 +858,25 @@ struct meta_copy_op_d<op,Tsrc,Tdst[N1]>
}
};
//! Partial specialization for N=2 2D-Array
template<template<typename,typename> class op, typename Tsrc, typename Tdst, typename vmpl>
struct meta_copy_op_d<op,openfpm::detail::multi_array::sub_array_openfpm<Tsrc,1,vmpl>,openfpm::detail::multi_array::sub_array_openfpm<Tdst,1,vmpl>>
{
/*! \brief copy and object from src to dst
*
* \param src source object to copy
* \param dst destination object
*
*/
static inline void meta_copy_op_d_(const openfpm::detail::multi_array::sub_array_openfpm<Tsrc,1,vmpl> src, openfpm::detail::multi_array::sub_array_openfpm<Tdst,1,vmpl> dst)
{
for (size_t i1 = 0 ; i1 < boost::mpl::at<vmpl,boost::mpl::int_<0>>::type::value ; i1++)
{
copy_general_op<op,Tdst>(src[i1],dst[i1]);
}
}
};
//! Partial specialization for N=1 1D-Array
template<template<typename,typename> class op, typename Tsrc, typename Tdst, size_t N1>
struct meta_copy_op_d<op,Tsrc[N1],Tdst[N1]>
......@@ -859,4 +918,26 @@ struct meta_copy_op_d<op,Tsrc[N1][N2],Tdst[N1][N2]>
}
};
//! Partial specialization for N=2 2D-Array
template<template<typename,typename> class op, typename Tsrc, typename Tdst, typename vmpl>
struct meta_copy_op_d<op,openfpm::detail::multi_array::sub_array_openfpm<Tsrc,2,vmpl>,openfpm::detail::multi_array::sub_array_openfpm<Tdst,2,vmpl>>
{
/*! \brief copy and object from src to dst
*
* \param src source object to copy
* \param dst destination object
*
*/
static inline void meta_copy_op_d_(const openfpm::detail::multi_array::sub_array_openfpm<Tsrc,2,vmpl> src, openfpm::detail::multi_array::sub_array_openfpm<Tdst,2,vmpl> dst)
{
for (size_t i1 = 0 ; i1 < boost::mpl::at<vmpl,boost::mpl::int_<0>>::type::value ; i1++)
{
for (size_t i2 = 0 ; i2 < boost::mpl::at<vmpl,boost::mpl::int_<1>>::type::value ; i2++)
{
copy_general_op<op,Tdst>(src[i1][i2],dst[i1][i2]);
}
}
}
};
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment