Commit 66ef3bb3 authored by Quentin Khan's avatar Quentin Khan

Deprecate FNode::getDepth in favor of FNode::getLevel

Better consistency with rest of code.
parent b198b960
......@@ -407,10 +407,10 @@ public:
* ancestor at the highest one's level is used.
*/
int compute_box_offset_index(node_t* node, node_t* other_node, const std::size_t n) {
while(node->getDepth() > other_node->getDepth()) {
while(node->getLevel() > other_node->getLevel()) {
node = node->getParent();
}
while(node->getDepth() < other_node->getDepth()) {
while(node->getLevel() < other_node->getLevel()) {
other_node = other_node->getParent();
}
......
......@@ -1139,10 +1139,10 @@ public:
* ancestor at the highest one's level is used.
*/
int compute_box_offset_index(node_t* node, node_t* other_node, const std::size_t n) {
while(node->getDepth() > other_node->getDepth()) {
while(node->getLevel() > other_node->getLevel()) {
node = node->getParent();
}
while(node->getDepth() < other_node->getDepth()) {
while(node->getLevel() < other_node->getLevel()) {
other_node = other_node->getParent();
}
......
......@@ -221,6 +221,13 @@ public:
static_assert(models_symbolic_data<symbolic_data_t>::value,
"The symbolic_data_t type does not model the required symbolic data interface.");
using level_t = typename std::remove_reference<
decltype(std::declval<symbolic_data_t>().getLevel())>::type;
using morton_index_t = typename std::remove_reference<
decltype(std::declval<symbolic_data_t>().getMortonIndex())>::type;
private:
friend struct scalfmm::tests::test_Node;
......@@ -272,7 +279,7 @@ public:
_parent(&parent),
_box (parent.getBox().center(), parent.getBox().corner(child_index) ),
_tree (parent._tree ),
_symbolic_data{static_cast<int>(parent.getDepth()+1), (parent.getIndex() << Dim) + child_index}
_symbolic_data{static_cast<int>(parent.getLevel()+1), (parent.getIndex() << Dim) + child_index}
{
if (child_index >= child_count) {
throw std::invalid_argument(std::string("Wrong child index in node contructor: got ")
......@@ -390,8 +397,13 @@ public:
}
/// Depth accessor
std::size_t getDepth() const noexcept {
return _symbolic_data.depth;
[[gnu::deprecated("Use getLevel for interface consistency.")]]
level_t getDepth() const noexcept {
return _symbolic_data.getLevel();
}
/// Level accessor
level_t getLevel() const noexcept {
return _symbolic_data.getLevel();
}
/// Morton index accessor
......@@ -677,7 +689,7 @@ public:
*/
bool operator==(const FNode& other) const {
return other.getParent() == getParent()
&& other.getDepth() == getDepth()
&& other.getLevel() == getLevel()
&& other.getIndex() == getIndex();
}
......@@ -703,7 +715,7 @@ private:
data->setMortonIndex(node->getIndex());
FTreeCoordinate coord(node->getIndex());
data->setCoordinate(coord);
data->setLevel(node->getDepth());
data->setLevel(node->getLevel());
}
/**
......@@ -739,8 +751,8 @@ private:
*/
void update_tree_height() {
assert(is_leaf() == true);
if(getDepth()+1 > getTree().height())
getTree().set_height(getDepth() + 1);
if(getLevel()+1 > getTree().height())
getTree().set_height(getLevel() + 1);
}
/**
......@@ -766,7 +778,7 @@ private:
// Remove this node from tree leaf list
getTree().leaves().erase(this);
// Create the children, add them to tree leaf list
FNode* tmp = this->getTree().node_memory_manager.provide(this->getDepth()+1, child_count);
FNode* tmp = this->getTree().node_memory_manager.provide(this->getLevel()+1, child_count);
for(FNode*& child : getChildren()) {
child = new(tmp+idx) FNode(*this, idx);
getTree().leaves().insert(child);
......@@ -805,7 +817,7 @@ private:
void split() {
assert(this->is_leaf());
if(getDepth()+1 > getTree().max_height()) {
if(getLevel()+1 > getTree().max_height()) {
// TODO: log that there were too many particles
return;
}
......@@ -823,13 +835,13 @@ private:
// Adjacent to child
child->U.insert(u_item);
u_item->U.insert(child);
} else if(u_item->getDepth() < child->getDepth()) {
} else if(u_item->getLevel() < child->getLevel()) {
// Adjacent to parent (this) but not to child
child->X.insert(u_item);
u_item->W.insert(child);
} else { // u_item->getDepth() >= child->getDepth()
} else { // u_item->getLevel() >= child->getLevel()
// Find ancestor of u_item that is adjacent to child
while(u_item->getDepth() > child->getDepth()) {
while(u_item->getLevel() > child->getLevel()) {
if(child->is_adjacent(u_item->getParent())) {
// Parent is adjacent -> W list
child->W.insert(u_item);
......@@ -839,7 +851,7 @@ private:
u_item = u_item->getParent();
}
}
if(u_item->getDepth() == child->getDepth()) {
if(u_item->getLevel() == child->getLevel()) {
// No adjacent ancestor -> add a neighbour
child->V.insert(u_item);
u_item->V.insert(child);
......@@ -851,12 +863,12 @@ private:
for(FNode* w_item : this->W) {
// Find first ancestor of w_item that is adjacent to child
// not needed, done in U list treatment, only check parent
if(child->getDepth() < w_item->getDepth()) {
if(child->getLevel() < w_item->getLevel()) {
if(child->is_adjacent(w_item->getParent())) {
child->W.insert(w_item);
w_item->X.insert(child);
}
} else if(child->getDepth() == w_item->getDepth()) {
} else if(child->getLevel() == w_item->getLevel()) {
// No adjacent ancestor -> add a neighbour
child->V.insert(w_item);
w_item->V.insert(child);
......@@ -995,7 +1007,7 @@ private:
// Node data and recurrence
auto index_width =
std::setw(static_cast<int>(
std::log10(1 << (Dim * (this->getDepth()+1)))));
std::log10(1 << (Dim * (this->getLevel()+1)))));
if(! this->is_leaf()) { // Internal node
os << "node " << index_width << this->getIndex() << ":\n";
......
......@@ -32,7 +32,7 @@
template<typename node_t>
std::size_t expected_P2P(node_t* node) {
std::size_t index = node->getIndex();
std::size_t depth = node->getDepth();
std::size_t depth = node->getLevel();
int min = 0;
int max = (int)std::pow(2,depth);
......@@ -68,7 +68,7 @@ std::size_t expected_M2M(node_t* node) {
template<typename node_t>
std::size_t expected_M2L(node_t* node, bool v = false) {
std::size_t index = node->getIndex();
std::size_t depth = node->getDepth();
std::size_t depth = node->getLevel();
int min = 0;
int max = (int)std::pow(2,depth);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment