8 #ifndef OPENFPM_NUMERICS_SRC_OPERATORS_VECTOR_VECTOR_DIST_OPERATORS_APPLY_KERNEL_HPP_
9 #define OPENFPM_NUMERICS_SRC_OPERATORS_VECTOR_VECTOR_DIST_OPERATORS_APPLY_KERNEL_HPP_
13 #define DEFINE_INTERACTION_3D(name) struct name \
16 Point<3,double> value(const Point<3,double> & xp, const Point<3,double> xq)\
19 #define END_INTERACTION }\
28 template<
typename ObjType,
typename Sfinae =
void>
31 template<
typename ObjType>
36 template<typename exp, bool is_exp = is_expression<exp>::value>
40 typedef typename exp::return_type
rtype;
44 template<
typename exp>
56 template<
typename rtype>
60 __device__ __host__
static rtype
create()
67 template<
unsigned int dim,
typename T>
84 template<typename T, typename vector, typename exp,typename NN_type, typename Kernel, typename rtype, bool is_exp=is_expression<T>::value>
98 inline __host__ __device__
static typename std::remove_reference<rtype>::type
apply(
const vector & vd, NN_type & cl,
const exp & v_exp,
const vect_dist_key_dx & key, Kernel & lker)
107 rtype prp_p = v_exp.value(key);
110 auto NN = cl.getNNIteratorBox(cl.getCell(p));
123 rtype prp_q = v_exp.value(nnp_k);
128 pse += lker.
value(p,q,prp_p,prp_q);
144 template<
typename vector,
typename exp,
typename NN_type,
typename Kernel,
typename rtype>
157 __device__ __host__
inline static typename std::remove_reference<rtype>::type
apply(
const vector & vd, NN_type & cl,
const vect_dist_key_dx & key, Kernel & lker)
166 auto NN = cl.getNNIteratorBox(cl.getCell(p));
178 pse += lker.
value(p,q);
195 template<typename T, typename vector, typename exp,typename NN_type, typename Kernel, typename rtype, bool is_exp=is_expression<T>::value>
209 __device__ __host__
inline static typename std::remove_reference<rtype>::type
apply(
const vector & vd, NN_type & cl,
const exp & v_exp,
const vect_dist_key_dx & key, Kernel & lker)
215 rtype prp_p = v_exp.value(key);
221 auto NN = cl.getNNIteratorBox(cl.getCell(p));
234 rtype prp_q = v_exp.value(nnp_k);
236 pse += lker.value(key.
getKey(),nnp,prp_p,prp_q,vd);
247 template<
typename T,
bool mm>
267 template<typename T, bool is_reference = std::is_reference<T>::value>
270 typedef const T type;
276 typedef typename std::remove_reference<T>::type
const & type;
285 template <
typename exp1,
typename vector_type>
289 typedef typename boost::mpl::at<vector_type,boost::mpl::int_<0>>::type
NN;
291 typedef typename boost::mpl::at<vector_type,boost::mpl::int_<1>>::type
Kernel;
293 typedef typename boost::mpl::at<vector_type,boost::mpl::int_<2>>::type
vector_orig;
296 typedef typename std::remove_reference<NN>::type
NN_nr;
298 typedef typename std::remove_reference<Kernel>::type
Kernel_nr;
368 :o1(o1),cl(cl),ker(ker),vd(vd)
385 rtype>::apply(vd,cl.obj,o1,key,ker.obj);
395 template <
typename exp1,
typename vector_type>
399 typedef typename boost::mpl::at<vector_type,boost::mpl::int_<0>>::type
NN;
401 typedef typename boost::mpl::at<vector_type,boost::mpl::int_<1>>::type
Kernel;
403 typedef typename boost::mpl::at<vector_type,boost::mpl::int_<2>>::type
vector_orig;
406 typedef typename std::remove_reference<NN>::type
NN_nr;
408 typedef typename std::remove_reference<Kernel>::type
Kernel_nr;
473 :cl(cl),ker(ker),vd(vd)
489 rtype>::apply(vd,cl.obj,key,ker.obj);
499 template <
typename exp1,
typename vector_type>
503 typedef typename boost::mpl::at<vector_type,boost::mpl::int_<0>>::type
NN;
505 typedef typename boost::mpl::at<vector_type,boost::mpl::int_<1>>::type
Kernel;
508 typedef typename boost::mpl::at<vector_type,boost::mpl::int_<2>>::type
vector_orig;
511 typedef typename std::remove_reference<NN>::type
NN_nr;
513 typedef typename std::remove_reference<Kernel>::type
Kernel_nr;
582 :o1(o1),cl(cl),ker(ker),vd(vd)
595 decltype(o1.value(key)),
601 >::apply(vd,cl.obj,o1,key,ker.obj);
608 typedef cl_type& ctype;
610 static ctype & get(cl_type & cl)
616 template<
typename cl_type>
619 typedef decltype(std::declval<cl_type>().toKernel()) ctype;
621 static ctype get(cl_type & cl)
623 return cl.toKernel();
627 template<
typename cl_type>
630 typedef cl_type ctype;
632 static ctype & get(cl_type & cl)
641 typedef kl_type& ktype;
644 template<
typename kl_type,
typename cl_type>
647 typedef kl_type ktype;
650 template<
typename kl_type,
typename cl_type>
653 typedef kl_type ktype;
656 template<
bool uwk,
typename T>
661 static T & get(T & v)
670 typedef decltype(std::declval<T>().toKernel()) type;
672 static type get(T & v)
681 typedef vl_type& vtype;
683 static vtype & get(vl_type & v)
689 template<
typename vl_type,
typename cl_type>
692 typedef decltype(std::declval<vl_type>().toKernel()) vtype;
694 static vtype get(vl_type & v)
700 template<
typename vl_type,
typename cl_type>
705 static vtype get(vl_type & v)
723 template<
typename exp1,
typename exp2,
unsigned int op1,
typename NN,
typename Kernel,
typename vector_type>
725 boost::mpl::vector<typename cl_selector_impl<NN>::ctype,
726 typename kl_selector_impl<Kernel,NN>::ktype,
733 boost::mpl::vector<typename cl_selector_impl<NN>::ctype,
734 typename kl_selector_impl<Kernel,NN>::ktype,
757 template<
typename exp1,
typename exp2,
unsigned int op1,
typename NN,
typename Kernel,
typename vector_type>
759 boost::mpl::vector<typename cl_selector_impl<NN>::ctype,
760 typename kl_selector_impl<Kernel,NN>::ktype,
762 VECT_APPLYKER_IN_GEN>
767 boost::mpl::vector<typename cl_selector_impl<NN>::ctype,
768 typename kl_selector_impl<Kernel,NN>::ktype,
790 template<
unsigned int prp,
typename NN,
typename Kernel,
typename vector_type,
typename vector_type_ker>
792 boost::mpl::vector<typename cl_selector_impl<NN>::ctype,
793 typename kl_selector_impl<Kernel,NN>::ktype,
800 boost::mpl::vector<typename cl_selector_impl<NN>::ctype,
801 typename kl_selector_impl<Kernel,NN>::ktype,
821 template<
unsigned int prp,
typename NN,
typename Kernel,
typename vector_type,
typename vector_type_ker>
823 boost::mpl::vector<typename cl_selector_impl<NN>::ctype,
824 typename kl_selector_impl<Kernel,NN>::ktype,
826 VECT_APPLYKER_IN_GEN>
831 boost::mpl::vector<typename cl_selector_impl<NN>::ctype,
832 typename kl_selector_impl<Kernel,NN>::ktype,
852 template<
typename NN,
typename Kernel,
typename vector_type>
854 boost::mpl::vector<typename cl_selector_impl<NN>::ctype,
855 typename kl_selector_impl<Kernel,NN>::ktype,
857 VECT_APPLYKER_IN_SIM>
858 applyKernel_in_sim(
vector_type & vd, NN & cl, Kernel & ker)
862 boost::mpl::vector<typename cl_selector_impl<NN>::ctype,
863 typename kl_selector_impl<Kernel,NN>::ktype,
This class implement the point shape in an N-dimensional space.
__device__ __host__ T & value(size_t i)
Return the reference to the value at coordinate i.
__device__ __host__ void zero()
Set to zero the point coordinate.
Grid key for a distributed grid.
__device__ __host__ size_t getKey() const
Get the key.
__device__ __host__ void setKey(size_t key)
set the key
std::remove_reference< vector_orig >::type vector_orig_nr
Return the vector containing the position of the particles.
boost::mpl::at< vector_type, boost::mpl::int_< 0 > >::type NN
Get the type of the Cell-list.
boost::mpl::at< vector_type, boost::mpl::int_< 2 > >::type vector_orig
Get the type that contain the particle positions.
has_vector_kernel< vector_orig_nr >::type is_ker
indicate if this expression operate on kernel expression
const vtype & getVector() const
get the vector
vector_dist_expression_op(const exp1 &o1, const NN &cl, Kernel &ker, const vector_orig_nr &vd)
Constructor.
boost::mpl::at< vector_type, boost::mpl::int_< 1 > >::type Kernel
Get the type of the kernel.
NN_nr * getNN() const
get the NN object
add_const_reference< vector_orig >::type vd
The vector that contain the particles.
mutable_or_not< Kernel, is_gpu_celllist< NN >::type::value||is_gpu_ker_celllist< NN >::type::value > ker
kernel
__device__ __host__ std::remove_reference< rtype >::type value(const vect_dist_key_dx &key) const
Evaluate the expression.
apply_kernel_rtype< decltype(o1.value(vect_dist_key_dx()))>::rtype rtype
Get the return type of applying the kernel to a particle.
mutable_or_not< NN, is_gpu_celllist< NN >::type::value||is_gpu_ker_celllist< NN >::type::value > cl
Cell-list.
std::remove_reference< Kernel >::type Kernel_nr
Return the type of the kernel.
NN_nr NN_type
type of NN structure
vector_orig_nr vtype
vector type on which this expression work
void init() const
This function must be called before value.
std::remove_reference< NN >::type NN_nr
Return the type of the Cell-list.
vector_orig_nr vtype
vector type on which this expression work
const vtype & getVector() const
get the vector
mutable_or_not< NN, is_gpu_celllist< NN >::type::value||is_gpu_ker_celllist< NN >::type::value > cl
Cell-list.
boost::mpl::at< vector_type, boost::mpl::int_< 2 > >::type vector_orig
Get the type of the vector containing the set of particles.
std::remove_reference< vector_orig >::type vector_orig_nr
Return the vector containing the position of the particles.
NN_nr NN_type
type of NN structure
boost::mpl::at< vector_type, boost::mpl::int_< 1 > >::type Kernel
Get the type of the kernel.
const vector_orig vd
Vector containing the particles.
std::remove_reference< NN >::type NN_nr
Return the type of the Cell-list.
boost::mpl::at< vector_type, boost::mpl::int_< 0 > >::type NN
Get the type of the Cell-list.
__device__ __host__ std::remove_reference< rtype >::type value(const vect_dist_key_dx &key) const
Evaluate the expression.
NN_nr * getNN() const
get the NN object
vector_dist_expression_op(const exp1 &o1, const NN &cl, Kernel &ker, const vector_orig &vd)
Constructor.
has_vector_kernel< vector_orig_nr >::type is_ker
indicate if this expression operate on kernel expression
std::remove_reference< Kernel >::type Kernel_nr
Return the type of the kernel.
apply_kernel_rtype< decltype(o1.value(vect_dist_key_dx()))>::rtype rtype
Return type of the expression.
void init() const
This function must be called before value.
mutable_or_not< Kernel, is_gpu_celllist< NN >::type::value||is_gpu_ker_celllist< NN >::type::value > ker
kernel
apply_kernel_rtype< decltype(std::declval< Kernel_nr >).value(Point< vector_orig_nr::dims, typename vector_orig_nr::stype >0.0), Point< vector_orig_nr::dims, typename vector_orig_nr::stype >0.0)))>::rtype rtype
Get the return type of the expression.
vector_dist_expression_op(const NN &cl, Kernel &ker, const vector_orig &vd)
Constructor.
has_vector_kernel< vector_orig_nr >::type is_ker
indicate if this expression operate on kernel expression
void init() const
This function must be called before value.
vector_orig_nr vtype
vector type on which this expression work
__device__ __host__ std::remove_reference< rtype >::type value(const vect_dist_key_dx &key) const
Evaluate the expression.
const vector_orig vd
vector with the particle positions
boost::mpl::at< vector_type, boost::mpl::int_< 0 > >::type NN
Return the type of the Cell-list.
std::remove_reference< Kernel >::type Kernel_nr
Return the type of the kernel.
boost::mpl::at< vector_type, boost::mpl::int_< 2 > >::type vector_orig
Return the vector containing the position of the particles.
std::remove_reference< vector_orig >::type vector_orig_nr
Return the vector containing the position of the particles.
boost::mpl::at< vector_type, boost::mpl::int_< 1 > >::type Kernel
Return the type of the kernel.
std::remove_reference< NN >::type NN_nr
Return the type of the Cell-list.
mutable_or_not< Kernel, is_gpu_celllist< NN >::type::value||is_gpu_ker_celllist< NN >::type::value > ker
kernel
mutable_or_not< NN, is_gpu_celllist< NN >::type::value||is_gpu_ker_celllist< NN >::type::value > cl
Cell-list.
NN_nr NN_type
type of NN structure
NN_nr * getNN() const
get the NN object
const vtype & getVector() const
get the vector
Unknown operation specialization.
Main class that encapsulate a vector properties operand to be used for expressions construction.
Apply the kernel to particle differently that is a number or is an expression.
__device__ static __host__ std::remove_reference< rtype >::type apply(const vector &vd, NN_type &cl, const exp &v_exp, const vect_dist_key_dx &key, Kernel &lker)
Apply the kernel expression to a particle.
Apply the kernel to particle differently that is a number or is an expression.
__device__ static __host__ std::remove_reference< rtype >::type apply(const vector &vd, NN_type &cl, const vect_dist_key_dx &key, Kernel &lker)
Apply the kernel expression to a particle.
Apply the kernel to particle differently that is a number or is an expression.
__host__ static __device__ std::remove_reference< rtype >::type apply(const vector &vd, NN_type &cl, const exp &v_exp, const vect_dist_key_dx &key, Kernel &lker)
Apply the kernel expression to a particle.
exp rtype
indicate the return type of the expression exp
It give the return type of the expression if applicable.
exp::return_type rtype
indicate the return type of the expression exp
is_expression check if a type is simple a type or is just an encapsulation of an expression
Check this is a gpu or cpu type cell-list.
__device__ static __host__ Point< dim, T > create()
return a point with all the coordinates set to zero
Meta-function to return a compatible zero-element.
__device__ static __host__ rtype create()
return 0