Skip to content

Commit

Permalink
Apply formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
skailasa committed Sep 29, 2023
1 parent 32f3fbb commit 5fc6669
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 18 deletions.
17 changes: 12 additions & 5 deletions tree/examples/test_let.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ use mpi::{environment::Universe, traits::*};

use rlst::common::traits::accessors::RawAccess;

use bempp_tree::types::multi_node::MultiNodeTree;
use bempp_tree::implementations::helpers::points_fixture;

use bempp_tree::types::multi_node::MultiNodeTree;

/// Test that the near field boxes are contained either locally, or in the received boxes
/// from the locally essential tree.
Expand All @@ -20,11 +19,11 @@ fn test_near_field(tree: &MultiNodeTree) {
// Test that the tree contains all the data it requires for the near field evaluations
for key in tree.get_all_leaves_set() {
let near_field = key.neighbors();

for n in near_field.iter() {
assert!(tree.leaves_set.contains(n) || locally_essential_tree.leaves_set.contains(n));
}
}
}
}

fn main() {
Expand All @@ -44,7 +43,15 @@ fn main() {
let points = points_fixture(n_points, None, None);
let global_idxs = (0..n_points).collect_vec();

let uniform_tree = MultiNodeTree::new(&comm, points.data(), adaptive, n_crit, depth, k, &global_idxs);
let uniform_tree = MultiNodeTree::new(
&comm,
points.data(),
adaptive,
n_crit,
depth,
k,
&global_idxs,
);

test_near_field(&uniform_tree);
if world.rank() == 0 {
Expand Down
34 changes: 21 additions & 13 deletions tree/src/implementations/impl_multi_node.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use itertools::Itertools;
use std::collections::{HashMap, HashSet};

use mpi::{topology::UserCommunicator, traits::*, Rank, collective::SystemOperation};
use mpi::{collective::SystemOperation, topology::UserCommunicator, traits::*, Rank};

use hyksort::hyksort;

Expand All @@ -11,7 +11,7 @@ use crate::{
constants::{DEEPEST_LEVEL, DEFAULT_LEVEL, NCRIT, ROOT},
implementations::{
impl_morton::{complete_region, encode_anchor},
mpi_helpers::all_to_allv_sparse
mpi_helpers::all_to_allv_sparse,
},
types::{
domain::Domain,
Expand Down Expand Up @@ -567,11 +567,9 @@ impl Tree for MultiNodeTree {
}
}


impl MultiNodeTree {

/// Create a locally essential tree (LET) for use in Fast Multipole Methods (FMMs).
///
///
/// The idea is to communicate the required point and octant data across the distributed tree prior
/// to the running of the upward pass so that multipole expansions can be constructed independently
/// on each processor at the leaf level, and for the final potential evaluation each process already
Expand All @@ -585,7 +583,7 @@ impl MultiNodeTree {

self.world.all_gather_into(&self.range, &mut ranges);

// Calculate users for each key in local tree
// Calculate users for each key in local tree
let mut users: Vec<Vec<Rank>> = Vec::new();
let mut key_packet_destinations = vec![0 as Rank; size as usize];
let mut leaf_packet_destinations = vec![0 as Rank; size as usize];
Expand Down Expand Up @@ -640,7 +638,8 @@ impl MultiNodeTree {
key_packet_destinations[rank as usize] = 1
}

if leaf_packet_destinations[rank as usize] == 0 && self.leaves_set.contains(key)
if leaf_packet_destinations[rank as usize] == 0
&& self.leaves_set.contains(key)
{
leaf_packet_destinations[rank as usize] = 1;
}
Expand Down Expand Up @@ -693,7 +692,8 @@ impl MultiNodeTree {

// Form packets for each send
for &rank in key_packet_destinations.iter() {
let key_packet: Vec<MortonKey> = self.keys_set
let key_packet: Vec<MortonKey> = self
.keys_set
.iter()
.zip(users.iter())
.filter(|(_, user)| user.contains(&rank))
Expand All @@ -711,7 +711,7 @@ impl MultiNodeTree {
.intersection(&self.leaves_set)
.cloned()
.collect();

let point_packet: Vec<Point> = leaf_packet
.iter()
.map(|leaf| self.get_points(leaf).unwrap().to_vec())
Expand Down Expand Up @@ -773,12 +773,20 @@ impl MultiNodeTree {
levels_to_keys: HashMap::default(),
leaves_set: received_leaves.iter().cloned().collect(),
keys_set: received_keys.iter().cloned().collect(),
points: Points{ points: received_points, index: 0},
leaves: MortonKeys { keys: received_leaves, index: 0 },
keys: MortonKeys { keys: received_keys, index: 0 },
points: Points {
points: received_points,
index: 0,
},
leaves: MortonKeys {
keys: received_leaves,
index: 0,
},
keys: MortonKeys {
keys: received_keys,
index: 0,
},
};


locally_essential_tree
}
}

0 comments on commit 5fc6669

Please sign in to comment.