Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed code for a case that cannot occur #8

Merged
merged 1 commit into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading