11#include "util/mathutil.hpp"
21template<
unsigned int dim,
typename ORB>
37 orb.template bisect<T::value>();
53template<
unsigned int dim,
unsigned int i,
typename ORB,
class Enable=
void>
61template<
unsigned int dim,
unsigned int i,
typename ORB>
64 static void bisect_loop(
bisect_unroll<dim,ORB> & bu,
typename boost::enable_if< boost::mpl::bool_<(i < dim)> >::type* dummy = 0)
66 boost::mpl::for_each< boost::mpl::range_c<int,0,i> >(bu);
83 static const unsigned int CM = 0;
97template<
unsigned int dim,
typename T,
typename loc_wg=openfpm::vector<
float>,
typename loc_pos=openfpm::vector<Po
int<dim,T>> ,
typename Box=Box<dim,T>,
template<
typename,
typename>
class Tree=
Graph_CSR_s>
128 template<
unsigned int dir>
void local_cm(
size_t start)
137 auto it = lp.getIterator();
144 size_t lbl = lp_lbl.get(key) - start;
147 cm.get(lbl) += lp.template get<s::x>(key)[dir];
169 const size_t dir_cm = (dir == 0)?(dim-1):(dir-1);
172 if (grp.getNVertex() == 1)
173 {lp_lbl.resize(lp.size());lp_lbl.fill(0);
return;}
177 auto p_it = lp.getIterator();
181 auto key = p_it.get();
184 size_t lbl = lp_lbl.get(key);
188 size_t n1 = grp.getChild(lbl,0);
189 size_t n2 = grp.getChild(lbl,1);
192 T cm = grp.template vertex_p<ORB_node<T>::CM>(lbl);
197 if (lp.template get<s::x>(key)[dir_cm] < cm)
198 {lp_lbl.get(key) = n1;}
200 {lp_lbl.get(key) = n2;}
212 template<
unsigned int dir>
size_t bisect()
215 size_t start = grp.getNVertex();
221 size_t n_node = (start + 1) / 2;
224 local_cm<dir>(start - n_node);
233 for (
size_t i = 0 ; i < n_node ; i++)
235 grp.template vertex_p<ORB_node<T>::CM>(start-n_node+i) = cm.get(i) / cm_cnt.get(i);
240 for (
size_t i = start - n_node, s = 0 ; i < start ; i++, s++)
245 grp.template addEdge(i,start+2*s);
246 grp.template addEdge(i,start+2*s+1);
266 :v_cl(create_vcluster()),lp(lp)
272 n_sub = openfpm::math::round_big_2(n_sub);
273 size_t nsub = log2(n_sub);
276 cm.resize(2 << nsub);
277 cm_cnt.resize(2 << nsub);
280 size_t dim_cycle = nsub / dim;
287 for (
size_t i = 0 ; i < dim_cycle ; i++)
289 boost::mpl::for_each< boost::mpl::range_c<int,0,dim> >(bu);
294 switch(nsub - dim_cycle * dim)
320 std::cerr <<
"Error: " << __FILE__ <<
":" << __LINE__ <<
" ORB is not working for dimension bigger than 8";
This class represent an N-dimensional box.
Simplified implementation of Graph_CSR.
This class implement orthogonal recursive bisection.
size_t bisect()
Bisect the domains along one direction.
void local_cm(size_t start)
Calculate the local center of mass on direction dir.
ORB(Box dom, size_t n_sub, loc_pos &lp)
constructor
void local_label()
It label the particles.
This class implement the point shape in an N-dimensional space.
void execute()
Execute all the requests.
void sum(T &num)
Sum the numbers across all processors and get the result.
Implementation of VCluster class.
Implementation of 1-D std::vector like structure.
aggregate of properties, from a list of object if create a struct that follow the OPENFPM native stru...
this class is a functor for "for_each" algorithm
bisect_unroll(ORB &orb)
constructor
void operator()(T &t)
It call the copy function for each property.
This structure use SFINAE to avoid instantiation of invalid code.