17 auto [it_min, it_max] = std::minmax_element(r.begin(), r.end()) ;
18 double rmax = *it_max ;
19 double ds = 2.1*rmax ;
27 if (lvl==0)
octree[lvl].init_cells(boundaries, ds) ;
28 else octree[lvl].init_subcells(boundaries,
octree[lvl-1].delta,
octree[lvl-1].n_cell) ;
30 smallestdim =
octree[lvl].delta[0] ;
31 for (
int dd=1 ; dd<
d ; dd++)
32 if (
octree[lvl].delta[dd]<smallestdim)
33 smallestdim =
octree[lvl].delta[dd] ;
37 while (
fit_in (r, smallestdim, lvl-1) > 0) ;
44 return octree.back().cum_n_cell.back() ;
47 int fit_in (std::vector<double> &r ,
double smallestdim,
char lvl)
50 for (
size_t i=0 ; i<
lvl_tree.size() ; i++)
52 if (2*r[i]<smallestdim/2.) leftovers ++ ;
53 if (2*r[i]<smallestdim)
lvl_tree[i] = lvl ;
64 for (
size_t i=0 ; i<X.size() ; i++)
78 int contacts(
int ID, std::pair<int,int> bounds,
CLp_it_t<d> & CLp_it,
ContactList<d> & CLnew, std::vector<std::vector<double>>
const & X, std::vector<double>
const &r,
double LE_displacement)
81 for (
char lvl =
max_lvl - 1 ; lvl>=0 ; lvl--)
83 octree[lvl].contacts(ID, bounds, CLp_it, CLnew, X, r, LE_displacement) ;
85 for (
char super_lvl=lvl-1 ; super_lvl>=0 ; super_lvl--)
86 octree[lvl].contacts_external (ID,
octree[super_lvl], lvl-super_lvl, bounds, CLp_it, CLnew, X, r, LE_displacement) ;
88 std::get<0>(bounds)/= pow(2,
d) ;
89 if (lvl>0 && std::get<1>(bounds) ==
octree[lvl].cum_n_cell[
d]) std::get<1>(bounds)=
octree[lvl-1].cum_n_cell[
d] ;
90 else std::get<1>(bounds) /= pow(2,
d) ;
Definition: Boundaries.h:8
All the cells making the space, with related function for creating the cell array,...
Definition: Cells.h:44
void serialize(Archive &ar)
Definition: Octree.h:101
int init_cells(std::vector< Boundary< d >> &boundaries, std::vector< double > &r)
Definition: Octree.h:13
std::vector< char > lvl_tree
Definition: Octree.h:98
int fit_in(std::vector< double > &r, double smallestdim, char lvl)
Definition: Octree.h:47
char max_lvl
Definition: Octree.h:99
int contacts(int ID, std::pair< int, int > bounds, CLp_it_t< d > &CLp_it, ContactList< d > &CLnew, std::vector< std::vector< double >> const &X, std::vector< double > const &r, double LE_displacement)
Definition: Octree.h:78
int cells_to_split()
Definition: Octree.h:42
std::vector< Cells< d > > octree
Definition: Octree.h:97
int allocate_to_cells(std::vector< std::vector< double >> &X)
Definition: Octree.h:58
Simple packing structure for the iterators to the contact list regions per particle.
Definition: Multiproc.h:23