From f5b433bd14904cfe30ffb2bcffb738b76919f137 Mon Sep 17 00:00:00 2001 From: Thomas Steinreiter Date: Thu, 17 Nov 2016 13:45:25 +0100 Subject: [PATCH] followed clang-tidy messages * removed unused headers * removed unused dtors * use nullptr * removed unused vars --- bhtree_mpi/CMakeLists.txt | 3 ++- bhtree_mpi/src/datastructures/BarnesHutTree.cpp | 6 +----- bhtree_mpi/src/datastructures/BarnesHutTree.hpp | 1 - bhtree_mpi/src/datastructures/Body.cpp | 4 ---- bhtree_mpi/src/datastructures/Node.cpp | 15 +++++---------- bhtree_mpi/src/datastructures/Node.hpp | 1 - bhtree_mpi/src/datastructures/Tree.cpp | 3 +-- bhtree_mpi/src/mpimain.cpp | 1 - bhtree_mpi/src/simulation/MpiSimulation.cpp | 2 +- bhtree_mpi/src/simulation/Simulation.cpp | 5 +---- bhtree_mpi/src/simulation/Simulation.hpp | 1 - 11 files changed, 11 insertions(+), 31 deletions(-) diff --git a/bhtree_mpi/CMakeLists.txt b/bhtree_mpi/CMakeLists.txt index b92d5ef..368e028 100644 --- a/bhtree_mpi/CMakeLists.txt +++ b/bhtree_mpi/CMakeLists.txt @@ -25,7 +25,8 @@ include(CheckCXXCompilerFlag) CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11) set(CXX11 ${COMPILER_SUPPORTS_CXX11}) set(CXX11_FLAGS -std=c++11) -set(CMAKE_CXX_FLAGS "-std=c++11") +set(CMAKE_CXX_FLAGS "-std=c++11 -Wall") +set(CMAKE_BUILD_TYPE RelWithDebInfo) find_package(MPI REQUIRED) diff --git a/bhtree_mpi/src/datastructures/BarnesHutTree.cpp b/bhtree_mpi/src/datastructures/BarnesHutTree.cpp index e652a69..6bdd1cb 100644 --- a/bhtree_mpi/src/datastructures/BarnesHutTree.cpp +++ b/bhtree_mpi/src/datastructures/BarnesHutTree.cpp @@ -8,8 +8,6 @@ namespace nbody { BarnesHutTree::BarnesHutTree(int parallelId) : Tree(parallelId) { } - BarnesHutTree::~BarnesHutTree() { - } //determine octree subboxes std::vector BarnesHutTree::splitBB(const Node* node) { @@ -143,9 +141,7 @@ namespace nbody { while (child != nullptr && !contained(child->getBB(), it->position)) { child = child->nextSibling; } - if (child != nullptr) { - current = child; - } + //TODO(pheinzlr): check for child == nullptr? current = child; } current->bodies.push_back(*it); diff --git a/bhtree_mpi/src/datastructures/BarnesHutTree.hpp b/bhtree_mpi/src/datastructures/BarnesHutTree.hpp index 9772f46..ff5a4e6 100644 --- a/bhtree_mpi/src/datastructures/BarnesHutTree.hpp +++ b/bhtree_mpi/src/datastructures/BarnesHutTree.hpp @@ -16,7 +16,6 @@ namespace nbody { static void split(Node* current); public: BarnesHutTree(int parallelId); - virtual ~BarnesHutTree(); virtual void build(const std::vector& bodies); virtual void build(const std::vector& bodies, const Box& domain); virtual void mergeLET(const std::vector& bodies); diff --git a/bhtree_mpi/src/datastructures/Body.cpp b/bhtree_mpi/src/datastructures/Body.cpp index 27dc9e0..a924c99 100644 --- a/bhtree_mpi/src/datastructures/Body.cpp +++ b/bhtree_mpi/src/datastructures/Body.cpp @@ -1,12 +1,8 @@ #include "Body.hpp" -#include #include #include #include -#include #include -#include -#include #include #include diff --git a/bhtree_mpi/src/datastructures/Node.cpp b/bhtree_mpi/src/datastructures/Node.cpp index be93dab..8ce3a48 100644 --- a/bhtree_mpi/src/datastructures/Node.cpp +++ b/bhtree_mpi/src/datastructures/Node.cpp @@ -1,4 +1,3 @@ -#include #include #include #include @@ -18,10 +17,6 @@ namespace nbody { this->parent = nullptr; } - Node::~Node() { - } - - Box Node::getBB() const { return this->bb; } @@ -75,7 +70,7 @@ namespace nbody { } bool Node::isCorrect() const { - if (this->afterSubtree == NULL) { + if (this->afterSubtree == nullptr) { std::cerr << "after subtree null\n"; return false; } @@ -97,11 +92,11 @@ namespace nbody { Node* current = this->next; int children = 0; - while (current != NULL && current != this->afterSubtree) { + while (current != nullptr && current != this->afterSubtree) { current = current->afterSubtree; children++; } - if (current == NULL) { + if (current == nullptr) { std::cerr << "afterSubtree null\n"; return false; } @@ -122,7 +117,7 @@ namespace nbody { std::cerr << "non-empty inner node\n"; return false; } - if (this->leaf && this->nextSibling != NULL && this->next != this->nextSibling) { + if (this->leaf && this->nextSibling != nullptr && this->next != this->nextSibling) { std::cerr << "wrong next sibling\n"; return false; } @@ -142,7 +137,7 @@ namespace nbody { } } } else { - for (Node* node = this->next; node != NULL; node = node->nextSibling) { + for (Node* node = this->next; node != nullptr; node = node->nextSibling) { mass += node->representative.mass; } } diff --git a/bhtree_mpi/src/datastructures/Node.hpp b/bhtree_mpi/src/datastructures/Node.hpp index 83c4c81..9633290 100644 --- a/bhtree_mpi/src/datastructures/Node.hpp +++ b/bhtree_mpi/src/datastructures/Node.hpp @@ -27,7 +27,6 @@ namespace nbody { Body representative; public: Node(Tree* tree); - virtual ~Node(); virtual bool isSplitable() const; virtual void extendBBforBodies(); virtual void extendBBtoCube(); diff --git a/bhtree_mpi/src/datastructures/Tree.cpp b/bhtree_mpi/src/datastructures/Tree.cpp index ba111fb..5f5c061 100644 --- a/bhtree_mpi/src/datastructures/Tree.cpp +++ b/bhtree_mpi/src/datastructures/Tree.cpp @@ -13,7 +13,7 @@ namespace nbody { this->nodes = new Node(this); this->maxLeafBodies = 16; this->parallelId = parallelId; - this->simulation = NULL; + this->simulation = nullptr; } Tree::~Tree() { @@ -162,7 +162,6 @@ namespace nbody { if (n->leaf) { for (auto& b : n->bodies) { if (!b.refinement) { - double pos[3] = {b.position[0], b.position[1], b.position[2]}; integrate(b); extend(bb, b); } diff --git a/bhtree_mpi/src/mpimain.cpp b/bhtree_mpi/src/mpimain.cpp index 686355e..bd058f9 100644 --- a/bhtree_mpi/src/mpimain.cpp +++ b/bhtree_mpi/src/mpimain.cpp @@ -2,7 +2,6 @@ #include #include #include -#include #include using namespace nbody; diff --git a/bhtree_mpi/src/simulation/MpiSimulation.cpp b/bhtree_mpi/src/simulation/MpiSimulation.cpp index 9643f72..b7de8e5 100644 --- a/bhtree_mpi/src/simulation/MpiSimulation.cpp +++ b/bhtree_mpi/src/simulation/MpiSimulation.cpp @@ -95,7 +95,7 @@ namespace nbody { } //mpi send wrapper - void MpiSimulation::send(std::vector bodies, int target) { + void MpiSimulation::send(std::vector bodies, int target) { //TODO(steinret): MPI_BSend, remove SendStore int bodySize = bodies.size(); SendStore* store = this->availableSendStore(bodySize); diff --git a/bhtree_mpi/src/simulation/Simulation.cpp b/bhtree_mpi/src/simulation/Simulation.cpp index 9c127c5..c855183 100644 --- a/bhtree_mpi/src/simulation/Simulation.cpp +++ b/bhtree_mpi/src/simulation/Simulation.cpp @@ -7,10 +7,7 @@ namespace nbody { this->parallelRank = -1; this->parallelSize = -1; this->correctState = 0; - this->tree = NULL; - } - - Simulation::~Simulation() { + this->tree = nullptr; } void Simulation::clearBodies() { diff --git a/bhtree_mpi/src/simulation/Simulation.hpp b/bhtree_mpi/src/simulation/Simulation.hpp index 723ac21..7bb0f66 100644 --- a/bhtree_mpi/src/simulation/Simulation.hpp +++ b/bhtree_mpi/src/simulation/Simulation.hpp @@ -16,7 +16,6 @@ namespace nbody { BarnesHutTree* tree; public: Simulation(); - virtual ~Simulation(); virtual void initialize(const std::string& inputFile) = 0; virtual void cleanup() = 0; virtual void clearBodies(); -- GitLab