8 #ifndef SRC_VECTOR_SE_CLASS3_VECTOR_HPP_ 
    9 #define SRC_VECTOR_SE_CLASS3_VECTOR_HPP_ 
   12 #include <Space/Shape/Point.hpp> 
   13 #include <Vector/map_vector.hpp> 
   14 #include <Vector/vector_dist_comm.hpp> 
   46     static const int init = UNINITIALIZED;
 
   54     static const int init = CLEAN;
 
   71 template<
unsigned int Np, 
typename vector>
 
   97         typedef typename boost::mpl::at<vector,boost::mpl::int_<T::value>>::type tc;
 
  104 template<
typename tcheck, 
bool foundamental>
 
  114     static bool isNan(
const tcheck & data)
 
  126     static bool isInf(
const tcheck & data)
 
  133 template<
typename tcheck>
 
  143     static bool isNan(
const tcheck & data)
 
  145         return std::isnan(data);
 
  155     static bool isInf(
const tcheck & data)
 
  157         return std::isinf(data);
 
  162 template<
typename tcheck, 
bool foundamental, 
unsigned int N1>
 
  172     static bool isNan(tcheck (& data)[N1])
 
  176         for (
size_t i = 0 ; i < N1; i++)
 
  178             if (std::isnan(data[i]))
 
  192     static bool isInf(tcheck (& data)[N1])
 
  196         for (
size_t i = 0 ; i < N1; i++)
 
  198             if (std::isinf(data[i]))
 
  207 template<
typename tcheck, 
bool foundamental, 
unsigned int N1, 
unsigned int N2>
 
  217     static bool isNan(tcheck (& data)[N1][N2])
 
  221         for (
size_t i = 0 ; i < N1; i++)
 
  223             for (
size_t j = 0 ; j < N2; j++)
 
  225                 if (std::isnan(data[i][j]))
 
  240     static bool isInf(tcheck (& data)[N1][N2])
 
  244         for (
size_t i = 0 ; i < N1; i++)
 
  246             for (
size_t j = 0 ; j < N2; j++)
 
  248                 if (std::isinf(data[i][j]))
 
  265 template<
typename vector>
 
  293         typedef typename boost::mpl::at<typename vector::value_type::type,typename boost::mpl::int_<T::value> >::type type_to_check;
 
  299             std::cerr << __FILE__ << 
":" << __LINE__ << 
" error detected NAN in property " << T::value  << std::endl;
 
  301             ACTION_ON_ERROR(VECTOR_DIST_ERROR_OBJECT);
 
  315 template<
typename vector>
 
  344         typedef typename boost::mpl::at<typename vector::value_type::type,boost::mpl::int_<T::value> >::type type_to_check;
 
  350             std::cerr << __FILE__ << 
":" << __LINE__ << 
" error detected INF in property " << T::value << std::endl;
 
  351             ACTION_ON_ERROR(VECTOR_DIST_ERROR_OBJECT);
 
  361 static inline std::string getParticleTypeString(
size_t type)
 
  364         return std::string(
"INSIDE");
 
  365     else if (type == HALO)
 
  366         return std::string(
"HALO");
 
  367     else if (type == GHOST)
 
  368         return std::string(
"GHOST");
 
  370     return std::string();
 
  373 template<
unsigned int prp, 
unsigned int Np, 
typename vector>  
void check_for_pos_nan_inf(
const vector & vd, 
size_t p)
 
  375 #ifdef CHECKFOR_POSINF 
  377             if ( std::isinf(vd.getPosNC(p)[0]) || std::isinf(vd.getPosNC(p)[1]) || std::isinf(vd.getPosNC(p)[2]) )
 
  379                 std::cerr << __FILE__ << 
":" << __LINE__ << 
" error detected INF in position for particle p=" << p << 
" of type=" << getParticleTypeString(vd.template getPropNC<Np+SE3_TYPE>(p)) << std::endl;
 
  380                 ACTION_ON_ERROR(VECTOR_DIST_ERROR_OBJECT);
 
  385 #ifdef CHECKFOR_POSNAN 
  387             if ( std::isnan(vd.getPosNC(p)[0]) || std::isnan(vd.getPosNC(p)[1]) || std::isnan(vd.getPosNC(p)[2]) )
 
  389                 std::cerr << __FILE__ << 
":" << __LINE__ << 
" error detected NAN in position for particle p=" << p << 
" of type=" << getParticleTypeString(vd.template getPropNC<Np+SE3_TYPE>(p)) << std::endl;
 
  390                 ACTION_ON_ERROR(VECTOR_DIST_ERROR_OBJECT);
 
  396 template<
unsigned int prp, 
unsigned int Np_real, 
typename vector>  
void check_for_prop_nan_inf(
const vector & vd, 
size_t p)
 
  398 #ifdef CHECKFOR_PROPINF 
  403                 boost::mpl::for_each_ref< boost::mpl::range_c<int,0, Np_real > > (checker);
 
  408 #ifdef CHECKFOR_PROPNAN 
  413                 boost::mpl::for_each_ref< boost::mpl::range_c<int,0, Np_real > >(checker);
 
  426 template<
unsigned int Np, 
unsigned int dim, 
typename T, 
typename Decomposition, 
typename vector>
 
  456             for (
size_t i = 0; i < 
dec.getNLocalSub(); i++)
 
  458                 size_t Nl = 
dec.getLocalNIGhost(i);
 
  460                 for (
size_t j = 0; j < Nl; j++)
 
  489             if (
id > vd.size_local())
 
  497                 if (vp_id.
size() != 0)
 
  518         template<
unsigned int ... prp>
 
  523             for (
size_t i = 0 ; i < 
Np_real ; i++)
 
  526                 for (
size_t j = 0 ; j < 
sizeof...(prp) ; j++)
 
  551                 return std::string(
"POSITION");
 
  553             return std::to_string(i);
 
  565         :dec(dec),vd(vd),
l_wrt(-1)
 
  576             return sync[GHOST][prp];
 
  584             auto it = vd.getDomainIterator_no_se3();
 
  592                 boost::mpl::for_each_ref< boost::mpl::range_c<int,0,Np_real+1> >(np_r);
 
  594                 vd.template getPropNC<Np+SE3_TYPE>(p) = INSIDE;
 
  599             for (
size_t i = 0 ; i < 
Np_real ; i++)
 
  601                 sync[GHOST][i] = NOTSYNC;
 
  602                 sync[HALO][i] = SYNC;
 
  606         template <
unsigned int ... prp> 
void ghost_get_pre(
size_t opt)
 
  608             const size_t gg[
sizeof...(prp)+1]  = {prp...};
 
  615             auto it = vd.getGhostIterator_no_se3();
 
  621                 for (
size_t i = 0 ; i < 
sizeof...(prp) ; i++)
 
  623                     if (vd.template getPropNC<Np+SE3_STATUS>(p)[gg[i]] == DIRTY)
 
  625                         std::cerr << __FILE__ << 
":" << __LINE__ << 
" Error the ghost has been written and ghost_get will overwrite your changes" << std::endl;
 
  626                         ACTION_ON_ERROR(VECTOR_DIST_ERROR_OBJECT);
 
  630                 if (!(opt & KEEP_PROPERTIES))
 
  634                         if (vd.template getPropNC<Np+SE3_STATUS>(p)[
non_NP.get(i)] == DIRTY)
 
  636                             std::cerr << __FILE__ << 
":" << __LINE__ << 
" Error the it seem that the property=" << 
getPrpName(
non_NP.get(i)) << 
" has been written and ghost_get will destroy such changes" << std::endl;
 
  637                             ACTION_ON_ERROR(VECTOR_DIST_ERROR_OBJECT);
 
  646         template <
unsigned int ... prp> 
void ghost_get_post(
size_t opt)
 
  648             const size_t gg[
sizeof...(prp)+1]  = {prp...};
 
  652             auto it2 = vd.getGhostIterator_no_se3();
 
  658                 for (
size_t i = 0 ; i < 
sizeof...(prp) ; i++)
 
  660                     if (vd.template getPropNC<Np+SE3_STATUS>(p)[gg[i]] == DIRTY)
 
  661                     {vd.template getPropNC<Np+SE3_STATUS>(p)[gg[i]] = CLEAN;}
 
  664                 if (vd.template getPropNC<Np+SE3_STATUS>(p)[
Np_real] == DIRTY)
 
  665                 {vd.template getPropNC<Np+SE3_STATUS>(p)[
Np_real] = CLEAN;}
 
  667                 vd.template getPropNC<Np+SE3_TYPE>(p) = GHOST;
 
  672             if (!(opt & KEEP_PROPERTIES))
 
  675                     sync[GHOST][
non_NP.get(i)] = NOTSYNC;
 
  677                 auto it = vd.getGhostIterator_no_se3();
 
  679                 while (it.isNext() == 
true)
 
  684                         vd.template getPropNC<Np+SE3_STATUS>(p)[
non_NP.get(i)] = UNINITIALIZED;
 
  692             for (
size_t i = 0 ; i < 
sizeof...(prp) ; i++)
 
  693                 sync[GHOST][gg[i]] = SYNC;
 
  695             if (!(opt & NO_POSITION))
 
  700             if (!(opt & KEEP_PROPERTIES))
 
  703                     sync[GHOST][
non_NP.get(i)] = NOTSYNC;
 
  707         template <
unsigned int ... prp> 
void ghost_put()
 
  709             const size_t gg[
sizeof...(prp)]  = {prp...};
 
  711             auto it = vd.getDomainIterator_no_se3();
 
  717                 if (vd.template getProp<Np+SE3_TYPE>(p) == INSIDE)
 
  723                 for (
size_t i = 0 ; i < 
sizeof...(prp) ; i++)
 
  725                     if (vd.template getProp<Np+SE3_STATUS>(p)[gg[i]] == UNINITIALIZED)
 
  727                         std::cerr << __FILE__ << 
":" << __LINE__ << 
" error it seem that you are sending at least in part uninitialized data with ghost put " << std::endl;
 
  728                         ACTION_ON_ERROR(VECTOR_DIST_ERROR_OBJECT);
 
  735             for (
size_t i = 0 ; i < 
sizeof...(prp) ; i++)
 
  737                 sync[HALO][gg[i]] = SYNC;
 
  738                 sync[HALO][gg[i]] = CLEAN;
 
  742             auto it2 = vd.getGhostIterator_no_se3();
 
  748                 for (
size_t i = 0 ; i < 
sizeof...(prp) ; i++)
 
  749                     vd.template getProp<Np+SE3_STATUS>(p)[gg[i]] = CLEAN;
 
  755         void getIterator()
 const 
  757             auto it = vd.getDomainIterator_no_se3();
 
  763                 for (
size_t j = 0 ; j < 
Np_real + 1 ; j++)
 
  765                     if (vd.template getPropNC<Np+SE3_STATUS>(p)[j] == DIRTY)
 
  766                         vd.template getPropNC<Np+SE3_STATUS>(p)[j] = CLEAN;
 
  775             auto it = vd.getGhostIterator_no_se3();
 
  777             while (it.isNext() == 
true)
 
  781                 for (
size_t j = 0 ; j < 
Np_real + 1 ; j++)
 
  783                     if (vd.template getPropNC<Np+SE3_STATUS>(p)[j] == DIRTY)
 
  785                         std::cerr << __FILE__ << 
":" << __LINE__ << 
" error it seem that ghost has been filled with information that we are going to destroy with the map call " << std::endl;
 
  799             for (
size_t j = 0 ; j < 
Np_real + 1 ; j++)
 
  802                 sync[GHOST][j] = NOTSYNC;
 
  805             auto it = vd.getDomainIterator_no_se3();
 
  807             while (it.isNext() == 
true)
 
  819         template<
unsigned int prp> 
void read(
const vector & vd, 
size_t p)
 const 
  821             if (vd.template getPropNC<Np+SE3_STATUS>(p)[prp] == UNINITIALIZED)
 
  823                 std::stringstream str;
 
  824                 std::string type_str = getParticleTypeString(vd.template getPropNC<Np+SE3_TYPE>(p));
 
  827                     str << __FILE__ << 
":" << __LINE__ << 
" Error you are reading the particle " << p << 
" of type " << type_str << 
" the position. But it result to be uninitialized" << std::endl;
 
  829                     str << __FILE__ << 
":" << __LINE__ << 
" Error you are reading from the particle " << p << 
" of type " << type_str << 
" the property=" << 
getPrpName(prp) << 
". But it result to be uninitialized" << std::endl;
 
  832                 std::cerr << str.str() << std::endl;
 
  833                 ACTION_ON_ERROR(VECTOR_DIST_ERROR_OBJECT);
 
  836             if (vd.template getPropNC<Np+SE3_STATUS>(p)[prp] == DIRTY && p != 
l_wrt)
 
  838                 std::cerr << __FILE__ << 
":" << __LINE__ << 
" Warning you are reading from a particle that has been changed already in the same cycle" << std::endl;
 
  839                 ACTION_ON_ERROR(VECTOR_DIST_ERROR_OBJECT);
 
  842             if (vd.template getPropNC<Np+SE3_TYPE>(p) == GHOST)
 
  847                 if (sync[vd.template getPropNC<Np+SE3_TYPE>(p)][prp] != SYNC)
 
  849                     std::cerr << __FILE__ << 
":" << __LINE__ << 
" Error it seem that you are reading from a ghost the property=" << 
getPrpName(prp) << 
" but it seem it is changed from the last ghost_get. It seems that is missing a ghost_get" << std::endl;
 
  850                     ACTION_ON_ERROR(VECTOR_DIST_ERROR_OBJECT);
 
  854             check_for_pos_nan_inf<prp>(
vd,p);
 
  855             check_for_prop_nan_inf<prp,Np_real>(
vd,p);
 
  858         template<
unsigned int prp> 
void write(vector & vd, 
size_t p)
 
  860             vd.template getPropNC<Np+SE3_STATUS>(p)[prp] = DIRTY;
 
  861             if (p >= vd.size_local())
 
  862                 vd.get_se_class3().template setHaloOutSync<prp>();
 
  865                 if (vd.template getPropNC<Np+SE3_TYPE>(p) == HALO)
 
  866                     vd.get_se_class3().template setGhostOutSync<prp>();
 
  875             for (
size_t i = 0 ; i < 
Np_real + 1 ; i++)
 
  877                 sync[0][i] = se3.
sync[0][i];
 
  878                 sync[1][i] = se3.
sync[1][i];
 
  884         template<
unsigned int prp> 
void setHaloOutSync()
 
  886             sync[HALO][prp] = NOTSYNC;
 
  889         template<
unsigned int prp> 
void setGhostOutSync()
 
  891             sync[GHOST][prp] = NOTSYNC;
 
  896             if (sync[GHOST][
Np_real] == NOTSYNC)
 
  898                 std::cerr << __FILE__ << 
":" << __LINE__ << 
" Error you are trying to get a Cell-list or Verlet-list without having the ghost synchronized in position please use ghost_get before" << std::endl;
 
  899                 ACTION_ON_ERROR(VECTOR_DIST_ERROR_OBJECT);
 
std::string getPrpName(size_t i) const 
Get property name. 
 
static bool isInf(tcheck(&data)[N1])
It check if the type is Infinity, data type to check. 
 
int sync[2][Np]
status of the properties 
 
static bool isNan(tcheck(&data)[N1])
It check if the type is Nan, data type to check. 
 
this class is a functor for "for_each" algorithm 
 
this class is a functor for "for_each" algorithm 
 
Decomposition & dec
Domain decomposition object. 
 
void operator()(T &t) const 
It call the copy function for each property. 
 
openfpm::vector< size_t > non_NP
temporal buffer 
 
void operator()(T &t) const 
It call the copy function for each property. 
 
bool isInside(const Point< dim, T > &p) const 
Check if the point is inside the box. 
 
init_prop(size_t(&prp_init)[Np])
constructor 
 
Type check in case of unknown type. 
 
static const int init
it indicate the property is not initialized 
 
this class is a functor for "for_each" algorithm 
 
static bool isInf(tcheck(&data)[N1][N2])
It check if the type is Infinity, data type to check. 
 
vector & vd
Reference to the distributed object. 
 
size_t isGhostSync()
return the status of the ghosts 
 
const vector & data
Data to check. 
 
This class implement the point shape in an N-dimensional space. 
 
propCheckNAN(const vector &data, size_t id)
constructor 
 
const vector & data
Data to check. 
 
void map_post()
Operation to do after map. 
 
This class define the domain decomposition interface. 
 
se_class3_vector< Np, dim, T, Decomposition, vector > & operator=(const se_class3_vector< Np, dim, T, Decomposition, vector > &se3)
Copy operator. 
 
static bool isInf(const tcheck &data)
It check if the type is Infinity, data type to check. 
 
static bool isNan(const tcheck &data)
It check if the type is Nan, data type to check. 
 
propCheckINF(const vector &data, size_t id)
constructor 
 
static bool isInf(const tcheck &data)
It check if the type is Infinity, data type to check. 
 
void Initialize()
Initialize the se_class2 structure. 
 
bool isLocalHalo(const Point< dim, T > &p)
It check if the particle is in the internal ghost area. 
 
static const size_t Np_real
number of real properties + POSITION 
 
size_t id
Element to check. 
 
This class check for inconsistency access. 
 
static bool isNan(const tcheck &data)
It check if the type is Nan, data type to check. 
 
size_t(& prp_init)[Np]
vector for prop initialization 
 
This class represent an N-dimensional box. 
 
static bool isNan(tcheck(&data)[N1][N2])
It check if the type is Nan, data type to check. 
 
void create_NNP(const size_t(&gg)[sizeof...(prp)+1])
Fill non_NP with the properties that are not synchronized. 
 
size_t getParticleType(const Point< dim, T > &p, const size_t &id, vector &vd)
Given the position it return the particle type. 
 
se_class3_vector(Decomposition &dec, vector &vd)
 
void operator()(T &t) const 
It call the copy function for each property.