mpi_complete_tree/
mpi_complete_tree.rsuse std::time::Instant;
use bempp_octree::{generate_random_points, Octree};
use mpi::traits::Communicator;
use rand::prelude::*;
use rand_chacha::ChaCha8Rng;
pub fn main() {
let universe = mpi::initialize().unwrap();
let comm = universe.world();
let mut rng = ChaCha8Rng::seed_from_u64(comm.rank() as u64);
let npoints = 1000000;
let mut points = generate_random_points(npoints, &mut rng, &comm);
for point in points.iter_mut() {
let len = point.coords()[0] * point.coords()[0]
+ point.coords()[1] * point.coords()[1]
+ point.coords()[2] * point.coords()[2];
let len = len.sqrt();
point.coords_mut()[0] /= len;
point.coords_mut()[1] /= len;
point.coords_mut()[2] /= len;
}
let start = Instant::now();
let octree = Octree::new(&points, 16, 50, &comm);
let duration = start.elapsed();
let global_number_of_points = octree.global_number_of_points();
let global_max_level = octree.global_max_level();
if comm.rank() == 0 {
println!(
"Setup octree with {} points and maximum level {} in {} ms",
global_number_of_points,
global_max_level,
duration.as_millis()
);
}
}