Commit 173b92ab authored by incardon's avatar incardon

Test working

parent 6a195bfe
......@@ -13,6 +13,11 @@
#include <unordered_map>
#include "util/for_each_ref.hpp"
/*! \brief sum functor value
*
* \param v_expr vector expression
*
*/
template<typename v_expr>
struct sum_functor_value
{
......@@ -28,10 +33,10 @@
//! Grid info
const grid_sm<last::dims,void> & gs;
// grid mapping
//! grid mapping
const typename stub_or_real<last,last::dims,typename last::stype,typename last::b_grid::decomposition::extended_type>::type & g_map;
// grid position
//! grid position
grid_dist_key_dx<last::dims> & kmap;
//! coefficent
......@@ -42,13 +47,29 @@
/*! \brief constructor
*
* \param g_map Grid mapping, it convert grid position into vector/Matrix row
* \param kmap grid position
* \param gs grid information
* \param spacing grid spacing
* \param cols unordered map contain the map colum -> value
* \param coeff it contain an additional actual coefficients in front of the values
*
*/
sum_functor_value(const typename stub_or_real<last,last::dims,typename last::stype,typename last::b_grid::decomposition::extended_type>::type & g_map, grid_dist_key_dx<last::dims> & kmap, const grid_sm<last::dims,void> & gs, typename last::stype (& spacing)[last::dims], std::unordered_map<long int,typename last::stype> & cols, typename last::stype coeff)
sum_functor_value(const typename stub_or_real<last,last::dims,typename last::stype,typename last::b_grid::decomposition::extended_type>::type & g_map,
grid_dist_key_dx<last::dims> & kmap,
const grid_sm<last::dims,void> & gs,
typename last::stype (& spacing)[last::dims],
std::unordered_map<long int,typename last::stype> & cols,
typename last::stype coeff)
:cols(cols),gs(gs),g_map(g_map),kmap(kmap),coeff(coeff),spacing(spacing)
{};
//! It call this function for every expression in the sum
/*! \brief It call this function for every expression operand in the sum
*
* \param t expression operand id
*
*/
template<typename T>
void operator()(T& t) const
{
......@@ -70,27 +91,35 @@
template<typename ... expr>
struct sum
{
// Transform from variadic template to boost mpl vector
//! Transform from variadic template to boost mpl vector
typedef boost::mpl::vector<expr... > v_expr;
// size of v_expr
//! size of v_expr
typedef typename boost::mpl::size<v_expr>::type v_sz;
//! struct that specify the syste, of equations
typedef typename boost::mpl::at<v_expr, boost::mpl::int_<v_sz::type::value - 1> >::type Sys_eqs;
/*! \brief Calculate which colums of the Matrix are non zero
*
* \param pos position where the derivative is calculated
* \param gs Grid info
* \param cols non-zero colums calculated by the function
* \param coeff coefficent (constant in front of the derivative)
* \param g_map Grid mapping, it convert grid position into vector/Matrix row
* \param kmap grid position
* \param gs grid information
* \param spacing grid spacing
* \param cols unordered map contain the map colum -> value
* \param coeff it contain an additional actual coefficients in front of the values
*
* ### Example
*
* \snippet FDScheme_unit_tests.hpp sum example
*
*/
inline static void value(const typename stub_or_real<Sys_eqs,Sys_eqs::dims,typename Sys_eqs::stype,typename Sys_eqs::b_grid::decomposition::extended_type>::type & g_map, grid_dist_key_dx<Sys_eqs::dims> & kmap, const grid_sm<Sys_eqs::dims,void> & gs, typename Sys_eqs::stype (& spacing )[Sys_eqs::dims] , std::unordered_map<long int,typename Sys_eqs::stype > & cols, typename Sys_eqs::stype coeff)
inline static void value(const typename stub_or_real<Sys_eqs,Sys_eqs::dims,typename Sys_eqs::stype,typename Sys_eqs::b_grid::decomposition::extended_type>::type & g_map,
grid_dist_key_dx<Sys_eqs::dims> & kmap,
const grid_sm<Sys_eqs::dims,void> & gs,
typename Sys_eqs::stype (& spacing )[Sys_eqs::dims],
std::unordered_map<long int,typename Sys_eqs::stype > & cols,
typename Sys_eqs::stype coeff)
{
// Sum functor
sum_functor_value<v_expr> sm(g_map,kmap,gs,spacing,cols,coeff);
......@@ -99,23 +128,15 @@ struct sum
boost::mpl::for_each_ref< boost::mpl::range_c<int,0,v_sz::type::value - 1> >(sm);
}
/*! \brief Calculate the position in the cell where the sum operator is performed
*
* it is done for the first element, the others are supposed to be in the same position
* it just return the position of the staggered property in the first expression
*
* \param position where we are calculating the derivative
* \param gs Grid info
* \param s_pos staggered position of the properties
*
*/
inline static grid_key_dx<Sys_eqs::dims> position(grid_key_dx<Sys_eqs::dims> & pos, const grid_sm<Sys_eqs::dims,void> & gs, const comb<Sys_eqs::dims> (& s_pos)[Sys_eqs::nvar])
{
return boost::mpl::at<v_expr, boost::mpl::int_<0> >::type::position(pos,gs,s_pos);
}
};
};
/*! \brief It ancapsulate the minus operation
*
* \tparam arg
* \tparam Sys_eqs system of equation
*
*/
template<typename arg, typename Sys_eqs>
struct minus
{
......@@ -123,23 +144,27 @@ struct minus
*
* \tparam ord
*
* \snipper FDScheme_unit_tests.hpp minus example
* \snippet FDScheme_unit_tests.hpp minus example
*
* \param g_map Grid mapping, it convert grid position into vector/Matrix row
* \param kmap grid position
* \param gs grid information
* \param spacing grid spacing
* \param cols unordered map contain the map colum -> value
* \param coeff it contain an additional actual coefficients in front of the values
*
*/
inline static void value(const typename stub_or_real<Sys_eqs,Sys_eqs::dims,typename Sys_eqs::stype,typename Sys_eqs::b_grid::decomposition::extended_type>::type & g_map, grid_dist_key_dx<Sys_eqs::dims> & kmap, const grid_sm<Sys_eqs::dims,void> & gs, typename Sys_eqs::stype (& spacing )[Sys_eqs::dims] , std::unordered_map<long int,typename Sys_eqs::stype > & cols, typename Sys_eqs::stype coeff)
inline static void value(const typename stub_or_real<Sys_eqs,Sys_eqs::dims,typename Sys_eqs::stype,typename Sys_eqs::b_grid::decomposition::extended_type>::type & g_map,
grid_dist_key_dx<Sys_eqs::dims> & kmap,
const grid_sm<Sys_eqs::dims,void> & gs,
typename Sys_eqs::stype (& spacing )[Sys_eqs::dims],
std::unordered_map<long int,typename Sys_eqs::stype > & cols,
typename Sys_eqs::stype coeff)
{
arg::value(g_map,kmap,gs,spacing,cols,-coeff);
}
/*! \brief Calculate the position where the minus is calculated
*
* it just return the position of the staggered property at first expression
*
*/
inline static grid_key_dx<Sys_eqs::dims> position(grid_key_dx<Sys_eqs::dims> & pos, const grid_sm<Sys_eqs::dims,void> & gs, const comb<Sys_eqs::dims> (& s_pos)[Sys_eqs::nvar])
{
std::cerr << "Error " << __FILE__ << ":" << __LINE__ << " only CENTRAL, FORWARD, BACKWARD derivative are defined";
}
};
#endif /* OPENFPM_NUMERICS_SRC_FINITEDIFFERENCE_SUM_HPP_ */
......@@ -875,7 +875,15 @@ public:
*/
void setRelTol(PetscReal rtol_)
{
PetscOptionsSetValue("-ksp_rtol",std::to_string(rtol_).c_str());
PetscReal rtol;
PetscReal abstol;
PetscReal dtol;
PetscInt maxits;
PETSC_SAFE_CALL(KSPGetTolerances(ksp,&rtol,&abstol,&dtol,&maxits));
PETSC_SAFE_CALL(KSPSetTolerances(ksp,rtol_,abstol,dtol,maxits));
// PetscOptionsSetValue("-ksp_rtol",std::to_string(rtol_).c_str());
}
/*! \brief Set the absolute tolerance as stop criteria
......@@ -887,7 +895,15 @@ public:
*/
void setAbsTol(PetscReal abstol_)
{
PetscOptionsSetValue("-ksp_atol",std::to_string(abstol_).c_str());
PetscReal rtol;
PetscReal abstol;
PetscReal dtol;
PetscInt maxits;
PETSC_SAFE_CALL(KSPGetTolerances(ksp,&rtol,&abstol,&dtol,&maxits));
PETSC_SAFE_CALL(KSPSetTolerances(ksp,rtol,abstol_,dtol,maxits));
// PetscOptionsSetValue("-ksp_atol",std::to_string(abstol_).c_str());
}
/*! \brief Set the divergence tolerance
......@@ -899,7 +915,15 @@ public:
*/
void setDivTol(PetscReal dtol_)
{
PetscOptionsSetValue("-ksp_dtol",std::to_string(dtol_).c_str());
PetscReal rtol;
PetscReal abstol;
PetscReal dtol;
PetscInt maxits;
PETSC_SAFE_CALL(KSPGetTolerances(ksp,&rtol,&abstol,&dtol,&maxits));
PETSC_SAFE_CALL(KSPSetTolerances(ksp,rtol,abstol,dtol_,maxits));
// PetscOptionsSetValue("-ksp_dtol",std::to_string(dtol_).c_str());
}
/*! \brief Set the maximum number of iteration for Krylov solvers
......@@ -909,8 +933,16 @@ public:
*/
void setMaxIter(PetscInt n)
{
PetscOptionsSetValue("-ksp_max_it",std::to_string(n).c_str());
maxits = n;
PetscReal rtol;
PetscReal abstol;
PetscReal dtol;
PetscInt maxits;
PETSC_SAFE_CALL(KSPGetTolerances(ksp,&rtol,&abstol,&dtol,&maxits));
PETSC_SAFE_CALL(KSPSetTolerances(ksp,rtol,abstol,dtol,n));
// PetscOptionsSetValue("-ksp_max_it",std::to_string(n).c_str());
this->maxits = n;
}
/*! For the BiCGStab(L) it define the number of search directions
......
......@@ -10,25 +10,61 @@
#include "NN/CellList/MemFast.hpp"
#include "NN/CellList/CellList.hpp"
#include "Grid/grid_dist_key.hpp"
#define INTERPOLATION_ERROR_OBJECT std::runtime_error("Runtime interpolation error");
constexpr int inte_m2p = 0;
constexpr int inte_p2m = 1;
/*! \brief It store the offsets of the interpolation points
*
* \tparam n_ele number of interpolation points
* \tparam T type in general an
*
*/
template<unsigned int n_ele>
struct agg_arr
{
//! offset of the interpolation points
size_t ele[n_ele];
};
/*! \brief multiply the src by coeff for several types T
*
* \tparam type T
*
*/
template<typename T>
struct mul_inte
{
/*! \brief multiply the src by coeff for several types T
*
* \param result the result of the multiplication
* \param coeff coefficent to use for of the multiplication
* \param src source
*
*/
inline static void value(T & result, const T & coeff, const T & src)
{
result += coeff * src;
}
};
/*! \brief multiply the src by coeff for several types T
*
* \tparam type T
*
*/
template<typename T, unsigned int N1>
struct mul_inte<T[N1]>
{
/*! \brief multiply the src by coeff for several types T
*
* \param result the result of the multiplication
* \param coeff coefficent to use for of the multiplication
* \param src source
*
*/
inline static void value(T (& result)[N1], const T & coeff, const T (& src)[N1])
{
for (size_t i = 0 ; i < N1 ; i++)
......@@ -36,9 +72,21 @@ struct mul_inte<T[N1]>
}
};
/*! \brief multiply the src by coeff for several types T
*
* \tparam type T
*
*/
template<typename T, unsigned int N1, unsigned int N2>
struct mul_inte<T[N1][N2]>
{
/*! \brief multiply the src by coeff for several types T
*
* \param result the result of the multiplication
* \param coeff coefficent to use for of the multiplication
* \param src source
*
*/
inline static void value(T (& result)[N1][N2], const T & coeff, const T (& src)[N1][N2])
{
for (size_t i = 0 ; i < N1 ; i++)
......@@ -47,34 +95,193 @@ struct mul_inte<T[N1][N2]>
}
};
template<unsigned int prp_g, unsigned int prp_v,unsigned int m2p_or_p2m>
/*! \brief Class that select the operation to do differently if we are doing Mesh to particle (m2p) or particle to mesh (p2m)
*
* \tparam prp_g property of the grid to interpolate
* \tparam prp_v property of the vector to interpolate
* \param M2P or P2M
*
*/
template<unsigned int np, unsigned int prp_g, unsigned int prp_v,unsigned int m2p_or_p2m>
struct inte_template
{
template<typename grid, typename vector, typename iterator, typename key_type> inline static void value(grid & gd,
/*! \brief Evaluate the interpolation
*
* \tparam np number of kernel points in one direction
* \tparam grid type of grid
* \tparam vector type of vector
* \tparam iterator type of the iterator
*
* \param gd grid for interpolation
* \param vd vector for interpolation
* \param k_dist grid key grid point for interpolation
* \param key_p particle for interpolation
* \param a_int interpolation coefficients pre-calculated
* \param key indicate which pre-calculated coefficient we have to use
*
*/
template<typename grid, typename vector, typename iterator> inline static void value(grid & gd,
vector & vd,
const grid_dist_key_dx<vector::dims> & k_dist,
const grid_dist_lin_dx & k_dist,
iterator & key_p,
const grid_cpu<vector::dims,aggregate<typename vector::stype>> & a_int,
const key_type & key)
typename vector::stype (& a_int)[openfpm::math::pow(vector::dims,np)],
const size_t & key)
{
mul_inte<typename std::remove_reference<decltype(gd.template get<prp_g>(k_dist))>::type>::value(gd.template get<prp_g>(k_dist),a_int.template get<0>(key),vd.template getProp<prp_v>(key_p));
mul_inte<typename std::remove_reference<decltype(gd.template get<prp_g>(k_dist))>::type>::value(gd.template get<prp_g>(k_dist),a_int[key],vd.template getProp<prp_v>(key_p));
}
};
template<unsigned int prp_g, unsigned int prp_v>
struct inte_template<prp_g,prp_v,inte_m2p>
/*! \brief Class that select the operation to do differently if we are doing Mesh to particle (m2p) or particle to mesh (p2m)
*
* \tparam prp_g property of the grid to interpolate
* \tparam prp_v property of the vector to interpolate
* \param M2P or P2M
*
*/
template<unsigned int np, unsigned int prp_g, unsigned int prp_v>
struct inte_template<np,prp_g,prp_v,inte_m2p>
{
template<typename grid, typename vector, typename iterator, typename key_type> inline static void value(grid & gd,
/*! \brief Evaluate the interpolation
*
* \tparam grid type of grid
* \tparam vector type of vector
* \tparam iterator type of the iterator
* \tparam key_type type of the key
*
* \param gd grid for interpolation
* \param vd vector for interpolation
* \param k_dist grid key grid point for interpolation
* \param key_p particle for interpolation
* \param a_int interpolation coefficients pre-calculated
* \param key indicate which pre-calculated coefficient we have to use
*
*/
template<typename grid, typename vector, typename iterator> inline static void value(grid & gd,
vector & vd,
const grid_dist_key_dx<vector::dims> & k_dist,
const grid_dist_lin_dx & k_dist,
iterator & key_p,
const grid_cpu<vector::dims,aggregate<typename vector::stype>> & a_int,
const key_type & key)
typename vector::stype (& a_int)[openfpm::math::pow(vector::dims,np)],
const size_t & key)
{
mul_inte<typename std::remove_reference<decltype(gd.template get<prp_g>(k_dist))>::type>::value(vd.template getProp<prp_v>(key_p),a_int.template get<0>(key),gd.template get<prp_g>(k_dist));
mul_inte<typename std::remove_reference<decltype(gd.template get<prp_g>(k_dist))>::type>::value(vd.template getProp<prp_v>(key_p),a_int[key],gd.template get<prp_g>(k_dist));
}
};
/*! \brief Calculate aint
*
* This class store
*
*/
template<unsigned int dims, typename vector, unsigned int np>
struct calculate_aint
{
/*! \brief Calculate the coefficients of the interpolation a_int for one particles
* having the 1D kernel values
*
* \param sz size of stencil for the interpolation
* \param a_int coefficients on the stencil points
* \param a coefficients of the kernel for each direction, consider
* that for 3 dimensions the kernel is the multiplication
* the 1D kernel on each direction. The "a" array store the
* calculated coefficient of the 1D kernel on each direction
*
*/
static inline void value(size_t (& sz)[vector::dims],
typename vector::stype a_int[openfpm::math::pow(vector::dims,np)],
typename vector::stype (& a)[vector::dims][np])
{
grid_sm<vector::dims,void> gs(sz);
grid_key_dx_iterator<vector::dims> kit(gs);
size_t s = 0;
while (kit.isNext())
{
auto key = kit.get();
a_int[s] = 1;
for (size_t i = 0 ; i < vector::dims ; i++)
a_int[s] *= a[i][key.get(i)];
s++;
++kit;
}
}
};
/*! \brief Calculate aint 2D
*
*
*/
template<typename vector, unsigned int np>
struct calculate_aint<2,vector,np>
{
/*! \brief Calculate the coefficients of the interpolation a_int for one particles
* having the 1D kernel values
*
* \param sz size of stencil for the interpolation
* \param a_int coefficients on the stencil points
* \param a coefficients of the kernel for each direction, consider
* that for 3 dimensions the kernel is the multiplication
* the 1D kernel on each direction. The "a" array store the
* calculated coefficient of the 1D kernel on each direction
*
*/
static inline void value(size_t (& sz)[vector::dims],
typename vector::stype a_int[openfpm::math::pow(vector::dims,np)],
typename vector::stype (& a)[vector::dims][np])
{
size_t s = 0;
for (size_t i = 0 ; i < np ; i++)
{
for (size_t j = 0 ; j < np ; j++)
{
a_int[s] = a[0][j]*a[1][i];
s++;
}
}
}
};
/*! \brief Calculate aint
*
*
*/
template<typename vector, unsigned int np>
struct calculate_aint<3,vector,np>
{
/*! \brief Calculate the coefficients of the interpolation a_int for one particles
* having the 1D kernel values
*
* \param sz size of stencil for the interpolation
* \param a_int coefficients on the stencil points
* \param a coefficients of the kernel for each direction, consider
* that for 3 dimensions the kernel is the multiplication
* the 1D kernel on each direction. The "a" array store the
* calculated coefficient of the 1D kernel on each direction
*
*/
static inline void value(size_t (& sz)[vector::dims],
typename vector::stype a_int[openfpm::math::pow(vector::dims,np)],
typename vector::stype (& a)[vector::dims][np])
{
size_t s = 0;
for (size_t i = 0 ; i < np ; i++)
{
for (size_t j = 0 ; j < np ; j++)
{
for (size_t k = 0 ; k < np ; k++)
{
a_int[s] = a[0][k]*a[1][j]*a[2][i];
s++;
}
}
}
}
};
/*! \brief return the sub-domain where this particle must be interpolated
*
......@@ -85,7 +292,7 @@ struct inte_template<prp_g,prp_v,inte_m2p>
*/
template<typename vector, typename grid>
inline size_t getSub(Point<vector::dims,typename vector::stype> & p,
const CellList<vector::dims,typename vector::stype,Mem_fast<vector::dims,typename vector::stype>,shift<vector::dims,typename vector::stype>> & geo_cell,
const CellList<vector::dims,typename vector::stype,Mem_fast,shift<vector::dims,typename vector::stype>> & geo_cell,
grid & gd)
{
size_t cell = geo_cell.getCell(p);
......@@ -98,121 +305,219 @@ inline size_t getSub(Point<vector::dims,typename vector::stype> & p,
return ns;
}
#ifdef SE_CLASS1
std::cerr << __FILE__ << ":" << __LINE__ << " Error: " << std::endl;
ACTION_ON_ERROR(INTERPOLATION_ERROR_OBJECT)
#endif
return (size_t)-1;
}
// If we end up here it mean that the particle decomposition and the grid decomposition are at machine precision level
// different. To recover we shift the particle of a machine precision correction inside the domain.
typename vector::stype dx[vector::dims];
typename vector::stype best_dx[vector::dims];
typename vector::stype best_tot_dx;
long int best_sub;
template<unsigned int prp_g, unsigned int prp_v, unsigned int m2p_or_p2m, typename kernel, typename iterator, typename vector, typename grid, typename grid_inte>
inline void inte_calc(iterator & it,
vector & vd,
const Box<vector::dims,typename vector::stype> & domain,
int (& ip)[vector::dims][kernel::np],
grid & gd,
const typename vector::stype (& dx)[vector::dims],
typename vector::stype (& xp)[vector::dims],
const grid_inte & a_int,
typename vector::stype (& a)[vector::dims][kernel::np],
typename vector::stype (& x)[vector::dims][kernel::np],
size_t (& sz)[vector::dims],
const CellList<vector::dims,typename vector::stype,Mem_fast<vector::dims,typename vector::stype>,shift<vector::dims,typename vector::stype>> & geo_cell)
{
auto key_p = it.get();
Box<vector::dims,typename vector::stype> sub_dom = gd.getDecomposition().getSubDomain(0);
Point<vector::dims,typename vector::stype> p = vd.getPos(key_p);
for (size_t j = 0 ; j < vector::dims ; j++)
{
if (sub_dom.getLow(j) > p.get(j))
{dx[j] = 2*(sub_dom.getLow(j) - p.get(j));}
else if (sub_dom.getHigh(j) < p.get(j))
{dx[j] = 2*(sub_dom.getHigh(j) - p.get(j));}
else {dx[j] = 0;}
}
// On which sub-domain we interpolate the particle
size_t sub = getSub<vector>(p,geo_cell,gd);
typename vector::stype tot_dx = 0.0;
typename vector::stype x0[vector::dims];
for (size_t j = 0 ; j < vector::dims ; j++)
{tot_dx += fabs(dx[j]);}
// calculate the position of the particle in the grid
// coordinated
for (size_t i = 0 ; i < vector::dims ; i++)
x0[i] = (p.get(i)-domain.getLow(i))*dx[i];
best_tot_dx = tot_dx;
for (size_t j = 0 ; j < vector::dims ; j++)
{best_dx[j] = dx[j];}
best_sub = 0;
// convert into integer
for (size_t i = 0 ; i < vector::dims ; i++)
ip[i][0] = (int)x0[i];
for (size_t i = 1 ; i < gd.getDecomposition().getNSubDomain() ; i++)
{
Box<vector::dims,typename vector::stype> sub_dom = gd.getDecomposition().getSubDomain(i);
// convert the global grid position into local grid position
grid_key_dx<vector::dims> base;
for (size_t j = 0 ; j < vector::dims ; j++)
{
if (sub_dom.getLow(j) > p.get(j))
{dx[j] = 2*(sub_dom.getLow(j) - p.get(j));}
else if (sub_dom.getHigh(j) < p.get(j))
{dx[j] = 2*(sub_dom.getHigh(j) - p.get(j));}
else {dx[j] = 0;}
}
for (size_t i = 0 ; i < vector::dims ; i++)
base.set_d(i,ip[i][0] - gd.getLocalGridsInfo().get(sub).origin.get(i) - (long int)kernel::np/2 + 1);
typename vector::stype tot_dx = 0.0;
// convenient grid of points
for (size_t j = 0 ; j < vector::dims ; j++)
{tot_dx += fabs(dx[j]);}
for (size_t j = 0 ; j < kernel::np-1 ; j++)
{
for (size_t i = 0 ; i < vector::dims ; i++)
ip[i][j+1] = (int)ip[i][j]+1;
if (tot_dx < best_tot_dx)
{
best_tot_dx = tot_dx;
for (size_t j = 0 ; j < vector::dims ; j++)
{best_dx[j] = dx[j];}
best_sub = i;
}
}
for (size_t i = 0 ; i < vector::dims ; i++)
xp[i] = x0[i] - ip[i][0];
// shift xp
for (long int j = 0 ; j < kernel::np ; j++)
for (size_t j = 0 ; j < vector::dims ; j++)
{p.get(j) += best_dx[j];}
return best_sub;
}
/*! \brief calculate the interpolation for one point
*
* \tparam vector of particles
* \kernel type
*
*/
template<typename vector,typename kernel>
struct inte_calc_impl
{
//! Type of the calculations
typedef typename vector::stype arr_type;
/*! \brief M2P or P2M for one particle
*
* \tparam prp_g property to interpolate from(M2P) or to(P2M) for grid
* \tparam prp_v property to interpolate to(M2P) or from(P2M) for vector
* \tparam m2p_or_p2m mesh to particle or mesh to particle interpolation
*
* \param it iterator used to retrieve the particle p for interpolation
* \param vd vector of particles
* \param domain
* \param ip index of the grid on each direction (1D) used for interpolation
* \param gd interpolation grid
* \param dx spacing on each direction
* \param xp Point that store the position of xp
* \param a_int buffer that store the interpolation points
*
*/
template<unsigned int prp_g, unsigned int prp_v, unsigned int m2p_or_p2m, typename iterator, typename grid>
static inline void inte_calc(iterator & it,
vector & vd,
const Box<vector::dims,typename vector::stype> & domain,
int (& ip)[vector::dims][kernel::np],
grid & gd,
const typename vector::stype (& dx)[vector::dims],
typename vector::stype (& xp)[vector::dims],
typename vector::stype (& a_int)[openfpm::math::pow(vector::dims,kernel::np)],
typename vector::stype (& a)[vector::dims][kernel::np],
typename vector::stype (& x)[vector::dims][kernel::np],
size_t (& sz)[vector::dims],
const CellList<vector::dims,typename vector::stype,Mem_fast,shift<vector::dims,typename vector::stype>> & geo_cell,
openfpm::vector<agg_arr<openfpm::math::pow(vector::dims,kernel::np)>> & offsets)
{
auto key_p = it.get();
Point<vector::dims,typename vector::stype> p = vd.getPos(key_p);
// On which sub-domain we interpolate the particle
size_t sub = getSub<vector>(p,geo_cell,gd);
typename vector::stype x0[vector::dims];