Skip to content

Commit

Permalink
Fixed debug check of redistribution of keys
Browse files Browse the repository at this point in the history
  • Loading branch information
tbetcke committed Oct 26, 2024
1 parent 7eac37b commit ea6c09d
Showing 1 changed file with 18 additions and 32 deletions.
50 changes: 18 additions & 32 deletions src/octree/implementation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ use crate::{
geometry::{PhysicalBox, Point},
morton::MortonKey,
parsort::parsort,
tools::{communicate_back, gather_to_all, global_inclusive_cumsum, redistribute, sort_to_bins},
tools::{
communicate_back, gather_to_all, global_inclusive_cumsum, is_sorted_array, redistribute,
sort_to_bins,
},
};

use mpi::traits::{Equivalence, Root};
Expand Down Expand Up @@ -215,39 +218,22 @@ pub fn redistribute_with_respect_to_coarse_tree<C: CommunicatorCollectives>(

#[cfg(debug_assertions)]
{
// Check through that the first and last key of result are descendents
// of the first and last coarse bloack.
let coarse_first = coarse_tree.first().unwrap();
let coarse_last = coarse_tree.last().unwrap();
let result_first = result.first().unwrap();
let result_last = result.last().unwrap();

if !coarse_first.is_ancestor(*result_first) {
println!(
"First key is not a descendent of the first coarse key. Rank: {}, First key: {}, First coarse key: {}",
comm.rank(),
result_first,
coarse_first
);
}
// Check through that the first and last key of result are contained
// in the intervals given by the coarse tree.

if !coarse_last.is_ancestor(*result_last) {
println!(
"Last key is not a descendent of the last coarse key. Rank: {}, Last key: {}, Last coarse key: {}",
comm.rank(),
result_last,
coarse_last
);
}
// Check that the result array is sorted.
debug_assert!(is_sorted_array(&result, comm));

// Check that the first and last result key are within the bounds.

debug_assert!(coarse_tree
.first()
.unwrap()
.is_ancestor(*result.first().unwrap()));
debug_assert!(coarse_tree
.last()
.unwrap()
.is_ancestor(*result.last().unwrap()));
debug_assert!(coarse_tree.first().unwrap() <= result.first().unwrap());
debug_assert!(
result.last().unwrap() < coarse_tree.last().unwrap()
|| coarse_tree
.last()
.unwrap()
.is_ancestor(*result.last().unwrap())
);
}

result
Expand Down

0 comments on commit ea6c09d

Please sign in to comment.