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>
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 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.template getNNIterator<NO_CHECK>(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 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.template getNNIterator<NO_CHECK>(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 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.template getNNIterator<NO_CHECK>(cl.getCell(p));
234 rtype prp_q = v_exp.value(nnp_k);
236 pse += lker.value(key.
getKey(),nnp,prp_p,prp_q,vd);
254 template <
typename exp1,
typename vector_type>
258 typedef typename boost::mpl::at<vector_type,boost::mpl::int_<0>>::type
NN;
260 typedef typename boost::mpl::at<vector_type,boost::mpl::int_<1>>::type
Kernel;
262 typedef typename boost::mpl::at<vector_type,boost::mpl::int_<2>>::type
vector_orig;
300 :o1(o1),cl(cl),ker(ker),vd(vd)
322 template <
typename exp1,
typename vector_type>
326 typedef typename boost::mpl::at<vector_type,boost::mpl::int_<0>>::type
NN;
328 typedef typename boost::mpl::at<vector_type,boost::mpl::int_<1>>::type
Kernel;
330 typedef typename boost::mpl::at<vector_type,boost::mpl::int_<2>>::type
vector_orig;
362 :cl(cl),ker(ker),vd(vd)
385 template <
typename exp1,
typename vector_type>
389 typedef typename boost::mpl::at<vector_type,boost::mpl::int_<0>>::type
NN;
391 typedef typename boost::mpl::at<vector_type,boost::mpl::int_<1>>::type
Kernel;
394 typedef typename boost::mpl::at<vector_type,boost::mpl::int_<2>>::type
vector_orig;
432 :o1(o1),cl(cl),ker(ker),vd(vd)
460 template<
typename exp1,
typename exp2,
unsigned int op1,
typename NN,
typename Kernel,
typename vector_type>
464 vector_dist_expression_op<vector_dist_expression_op<exp1,exp2,op1>,boost::mpl::vector<NN,Kernel,vector_type>,VECT_APPLYKER_IN> exp_sum(va,cl,ker,vd);
478 template<
typename exp1,
typename exp2,
unsigned int op1,
typename NN,
typename Kernel,
typename vector_type>
479 inline vector_dist_expression_op<vector_dist_expression_op<exp1,exp2,op1>,boost::mpl::vector<NN,Kernel,vector_type>,VECT_APPLYKER_IN_GEN>
482 vector_dist_expression_op<vector_dist_expression_op<exp1,exp2,op1>,boost::mpl::vector<NN,Kernel,vector_type>,VECT_APPLYKER_IN_GEN> exp_sum(va,cl,ker,vd);
498 template<
unsigned int prp,
typename NN,
typename Kernel,
typename vector_type>
502 vector_dist_expression_op<vector_dist_expression<prp,vector_type>,boost::mpl::vector<NN,Kernel,vector_type>,VECT_APPLYKER_IN> exp_sum(va,cl,ker,vd);
516 template<
unsigned int prp,
typename NN,
typename Kernel,
typename vector_type>
517 inline vector_dist_expression_op<vector_dist_expression<prp,vector_type>,boost::mpl::vector<NN,Kernel,vector_type>,VECT_APPLYKER_IN_GEN>
520 vector_dist_expression_op<vector_dist_expression<prp,vector_type>,boost::mpl::vector<NN,Kernel,vector_type>,VECT_APPLYKER_IN_GEN> exp_sum(va,cl,ker,vd);
534 template<
typename NN,
typename Kernel,
typename vector_type>
536 applyKernel_in_sim(
vector_type & vd, NN & cl, Kernel & ker)
static 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.
std::remove_reference< rtype >::type value(const vect_dist_key_dx &key) const
Evaluate the expression.
boost::mpl::at< vector_type, boost::mpl::int_< 2 > >::type vector_orig
Get the type of the vector containing the set of particles.
void init() const
This function must be called before value.
boost::mpl::at< vector_type, boost::mpl::int_< 2 > >::type vector_orig
Return the vector containing the position of the particles.
static rtype create()
return 0
static 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.
void init() const
This function must be called before value.
exp rtype
indicate the return type of the expression exp
apply_kernel_rtype< decltype(o1.value(vect_dist_key_dx()))>::rtype rtype
Get the return type of applying the kernel to a particle.
vector_dist_expression_op(const exp1 &o1, NN &cl, Kernel &ker, const vector_orig &vd)
Constructor.
Meta-function to return a compatible zero-element.
apply_kernel_rtype< decltype(o1.value(vect_dist_key_dx()))>::rtype rtype
Return type of the expression.
This class implement the point shape in an N-dimensional space.
Grid key for a distributed grid.
T & value(size_t i)
Return the reference to the value at coordinate i.
const vector_orig & vd
Vector containing the particles.
vector_dist_expression_op(const exp1 &o1, NN &cl, Kernel &ker, const vector_orig &vd)
Constructor.
boost::mpl::at< vector_type, boost::mpl::int_< 1 > >::type Kernel
Get the type of the kernel.
Unknown operation specialization.
vector_dist_expression_op(NN &cl, Kernel &ker, const vector_orig &vd)
Constructor.
boost::mpl::at< vector_type, boost::mpl::int_< 0 > >::type NN
Get the type of the Cell-list.
std::remove_reference< rtype >::type value(const vect_dist_key_dx &key) const
Evaluate the expression.
Main class that encapsulate a vector properties operand to be used for expressions construction...
const vector_orig & vd
The vector that contain the particles.
static 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.
const T & get(size_t i) const
Get coordinate.
static Point< dim, T > create()
return a point with all the coordinates set to zero
boost::mpl::at< vector_type, boost::mpl::int_< 2 > >::type vector_orig
Get the type that contain the particle positions.
Apply the kernel to particle differently that is a number or is an expression.
size_t getKey() const
Get the key.
This class is a trick to indicate the compiler a specific specialization pattern. ...
void setKey(size_t key)
set the key
apply_kernel_rtype< decltype(std::declval< Kernel >).value(Point< vector_orig::dims, typename vector_orig::stype >0.0), Point< vector_orig::dims, typename vector_orig::stype >0.0)))>::rtype rtype
Get the return type of the expression.
std::remove_reference< rtype >::type value(const vect_dist_key_dx &key) const
Evaluate the expression.
exp::return_type rtype
indicate the return type of the expression exp
void zero()
Set to zero the point coordinate.
It give the return type of the expression if applicable.
Apply the kernel to particle differently that is a number or is an expression.
void init() const
This function must be called before value.
boost::mpl::at< vector_type, boost::mpl::int_< 1 > >::type Kernel
Return the type of the kernel.
const vector_orig & vd
vector with the particle positions
Apply the kernel to particle differently that is a number or is an expression.
boost::mpl::at< vector_type, boost::mpl::int_< 1 > >::type Kernel
Get the type of the kernel.
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_< 0 > >::type NN
Return the type of the Cell-list.
is_expression check if a type is simple a type or is just an encapsulation of an expression ...