Skip to content

Commit

Permalink
Removed code for a case that cannot occur
Browse files Browse the repository at this point in the history
  • Loading branch information
tbetcke committed Oct 30, 2024
1 parent c5357f6 commit 200ec18
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 18 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ battleship = []

[package]
name = "bempp-octree"
version = "0.1.1"
version = "0.1.1-dev"
edition = "2021"
authors = [
"Srinath Kailasa <[email protected]>, Timo Betcke <[email protected]>",
Expand Down
23 changes: 6 additions & 17 deletions src/octree/implementation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -954,7 +954,7 @@ pub fn compute_neighbours(
continue;
}

// For leaf keys we need to check if the neighbours exist on the same level, above or below.
// For leaf keys we need to check if the neighbours exist on the same level or above.

if *key_type == KeyType::LocalLeaf {
for neighbour in key
Expand All @@ -966,26 +966,15 @@ pub fn compute_neighbours(
if all_keys.contains_key(&neighbour) {
// The easy case. Just add the neighbour.
neighbours.entry(*key).or_default().push(neighbour);
} else if all_keys.contains_key(&neighbour.parent()) {
} else {
// The neighbour is on the next level closer to root.
// Note, we cannot mistakenly add the parent of a sibling since the tree is complete.
debug_assert!(all_keys.contains_key(&neighbour.parent())); // Neighbour parent must be in `all_keys`.
neighbours.entry(*key).or_default().push(neighbour.parent());
} else {
// We take children of the neighbour and take each child that is neighbour to a child
// of the current key.
for neighbour_child in neighbour.children() {
for neighbour_child_neighbour in neighbour_child
.neighbours()
.iter()
.filter(|key| key.is_valid())
{
if neighbour_child_neighbour.parent() == *key {
debug_assert!(all_keys.contains_key(&neighbour_child));
neighbours.entry(*key).or_default().push(neighbour_child);
}
}
}
}
// Note that the case cannot happen that neither the neighbor nor its parent exists. In a 2:1 tree
// the only other case could be that the neighbours children are in the tree. But in that case the
// neighbour itself is also in the tree as its children are.
}
continue;
}
Expand Down

0 comments on commit 200ec18

Please sign in to comment.