diff --git a/example/ALL_test.cpp b/example/ALL_test.cpp index 9614b51ece2b821c02ac166851ffb64b0cf7f83e..53420877671efd02b0c88ddd0d152da76c45b507 100644 --- a/example/ALL_test.cpp +++ b/example/ALL_test.cpp @@ -1212,9 +1212,8 @@ int main(int argc, char **argv) { int n_transfer[2]; int n_recv[2 * MAX_NEIG]; int offset_neig[2]; - std::vector<int> neighbors; + std::vector<int> neighbors = lb_obj.getNeighbors(); int *nNeighbors; - lb_obj.getNeighbors(neighbors); nNeighbors = neighbors.data(); offset_neig[0] = 0; @@ -1832,10 +1831,8 @@ int main(int argc, char **argv) { case ALL::LB_t::VORONOI: { // get neighbor information int nNeighbors = lb_obj.getNNeighbors(); - std::vector<double> neighbor_vertices; - std::vector<int> neighbors; - lb_obj.getNeighborVertices(neighbor_vertices); - lb_obj.getNeighbors(neighbors); + std::vector<double> neighbor_vertices = lb_obj.getNeighborVertices(); + std::vector<int> neighbors = lb_obj.getNeighbors(); // compute voronoi cells @@ -2278,8 +2275,7 @@ int main(int argc, char **argv) { if (chosen_method == ALL::LB_t::HISTOGRAM) { int *nNeighbors; - std::vector<int> neighbors; - lb_obj.getNeighbors(neighbors); + std::vector<int> neighbors = lb_obj.getNeighbors(); nNeighbors = neighbors.data(); int n_neig = 0; for (int j = 0; j < 3; ++j) { diff --git a/include/ALL.hpp b/include/ALL.hpp index 3934338513fadbb1462bb3631bf7ce40871ebb38..1debe74c25fc50297238d52f2076d13c3e154e94 100644 --- a/include/ALL.hpp +++ b/include/ALL.hpp @@ -431,55 +431,33 @@ public: void getWork(std::vector<W> &result) { result = balancer->getWork(); } /// method to get the work provided to the method - /// @param[out] result to store the work to if only a scalar was used, if an - /// array was used to provide work only the first value will be returned - void getWork(W &result) { result = balancer->getWork().at(0); } + /// @result scalar work or first value of vector work + W getWork() { return balancer->getWork().at(0); } /// method to get the number of neigbors the local domain has /// @result int the number of neighbors the local domain has in total int getNNeighbors() { - std::vector<int> neig; - try { - balancer->getNeighbors(neig); - } catch (CustomException &e) { - std::cout << e.what() << std::endl; - MPI_Abort(MPI_COMM_WORLD, -1); - } - return neig.size(); + return balancer->getNeighbors().size(); } /// method to provide a list of the ranks of the neighbors the local domain /// has in all directions - /// @param[out] neig a reference to a std::vector<int> object, which the - /// neighbors will be stored in - void getNeighbors(std::vector<int> &neig) { - try { - balancer->getNeighbors(neig); - } catch (CustomException &e) { - std::cout << e.what() << std::endl; - MPI_Abort(MPI_COMM_WORLD, -1); - } + /// @result vector if neighboring ranks + std::vector<int> &getNeighbors() { + return balancer->getNeighbors(); } /// method to provide a list of neighboring vertices, e.g. required for /// VORONOI - /// @param[out] nv a reference to a vector object, which the + /// @result vector of neighboring vertices /// neighboring vertices are stored in - void getNeighborVertices(std::vector<T> &nv) { + std::vector<T> &getNeighborVertices() { switch (method) { - case LB_t::TENSOR: - break; - case LB_t::STAGGERED: - break; - case LB_t::UNSTRUCTURED: - break; #ifdef ALL_VORONOI_ACTIVE case LB_t::VORONOI: - ((Voronoi_LB<T, W> *)balancer.get())->getNeighborVertices(nv); + return ((Voronoi_LB<T, W> *)balancer.get())->getNeighborVertices(); break; #endif - case LB_t::HISTOGRAM: - break; default: break; } diff --git a/include/ALL_Histogram.hpp b/include/ALL_Histogram.hpp index 3f26614ecb473baae2d5dfcad894d283147a0a77..f7c93f914f0db9c621821003324c3362775f3389 100644 --- a/include/ALL_Histogram.hpp +++ b/include/ALL_Histogram.hpp @@ -92,7 +92,7 @@ public: // neighbors /// method to provide a list of neighbors by MPI rank /// @param [out] list the std::vector the list of neighbors is stored to - void getNeighbors(std::vector<int> &list) override; + std::vector<int> &getNeighbors() override; /// method to set method specific data /// @param data pointer to an array of integers (int) containing the number of @@ -666,8 +666,8 @@ template <class T, class W> void Histogram_LB<T, W>::find_neighbors() { // provide list of neighbors template <class T, class W> -void Histogram_LB<T, W>::getNeighbors(std::vector<int> &ret) { - ret = neighbors; +std::vector<int> &Histogram_LB<T, W>::getNeighbors() { + return neighbors; } }//namespace ALL diff --git a/include/ALL_LB.hpp b/include/ALL_LB.hpp index 33ac7010e96c875960faa74d28d296ed2bd02ffa..3e2e36354fda0fb6fb57c4c84b82ea36c4daf3bd 100644 --- a/include/ALL_LB.hpp +++ b/include/ALL_LB.hpp @@ -63,9 +63,9 @@ public: virtual void balance(const int step) = 0; /// abstract definition of the method to get the neighbors of the local domain - /// @param[out] list reference to std::vector<int> to store the MPI ranks of - /// the neighbors to - virtual void getNeighbors(std::vector<int> &list) = 0; + /// @result std::vector<int> to store the MPI ranks of the neighbors + /// to + virtual std::vector<int> &getNeighbors() = 0; /// method to update the vertices used for the balancing step, overwrites old /// set of vertices diff --git a/include/ALL_Staggered.hpp b/include/ALL_Staggered.hpp index e1c125e121b1177bbec48615616c508d871e6495..ea364821cf000aa2e4c5c49b6165fb2db77c66ca 100644 --- a/include/ALL_Staggered.hpp +++ b/include/ALL_Staggered.hpp @@ -85,7 +85,7 @@ public: /// method to provide a list of the neighbors of the local domain /// @param[out] list reference to a std::vector of integers where the list of /// neighbors will be assigned to - virtual void getNeighbors(std::vector<int> &list) override; + virtual std::vector<int> &getNeighbors() override; /// method to set specific data structures (unused for staggered grid method) /// @param[in] data pointer to the data structure @@ -619,8 +619,8 @@ template <class T, class W> void Staggered_LB<T, W>::find_neighbors() { // provide list of neighbors template <class T, class W> -void Staggered_LB<T, W>::getNeighbors(std::vector<int> &ret) { - ret = neighbors; +std::vector<int> &Staggered_LB<T, W>::getNeighbors() { + return neighbors; } }//namespace ALL diff --git a/include/ALL_Tensor.hpp b/include/ALL_Tensor.hpp index b4708321fbc4498ed0b4f754e13426f330370e29..c5ca109f2e0195012027787eb2d5f4a00ab8eae2 100644 --- a/include/ALL_Tensor.hpp +++ b/include/ALL_Tensor.hpp @@ -86,7 +86,7 @@ public: /// method to provide a list of the neighbors of the local domain /// @param[out] list reference to a std::vector of integers where the list of /// neighbors will be assigned to - virtual void getNeighbors(std::vector<int> &list) override; + virtual std::vector<int> &getNeighbors() override; /// method to set specific data structures (unused for tensor grid method) /// @param[in] data pointer to the data structure @@ -247,8 +247,8 @@ template <class T, class W> void Tensor_LB<T, W>::balance(int) { // provide list of neighbors template <class T, class W> -void Tensor_LB<T, W>::getNeighbors(std::vector<int> &ret) { - ret = neighbors; +std::vector<int> &Tensor_LB<T, W>::getNeighbors() { + return neighbors; } }//namespace ALL diff --git a/include/ALL_Unstructured.hpp b/include/ALL_Unstructured.hpp index 08dcec5cca02cd0def570770f5ba9ac52a825e70..67f66c41521bf89f91440bcfada4f1f5045d3566 100644 --- a/include/ALL_Unstructured.hpp +++ b/include/ALL_Unstructured.hpp @@ -110,7 +110,7 @@ public: /// method to provide a list of the neighbors of the local domain /// @param[out] list reference to a std::vector of integers where the list of /// neighbors will be assigned to - virtual void getNeighbors(std::vector<int> &list) override; + virtual std::vector<int> &getNeighbors() override; /// method to set specific data structures (unused for tensor grid method) /// @param[in] data pointer to the data structure @@ -149,8 +149,8 @@ template <class T, class W> Unstructured_LB<T, W>::~Unstructured_LB() {} // provide list of neighbors template <class T, class W> -void Unstructured_LB<T, W>::getNeighbors(std::vector<int> &ret) { - ret = neighbors; +std::vector<int> &Unstructured_LB<T, W>::getNeighbors() { + return neighbors; } template <class T, class W> void Unstructured_LB<T, W>::setup() { diff --git a/include/ALL_Voronoi.hpp b/include/ALL_Voronoi.hpp index d9abb94d39f0acc13272669dc777403aefad97f2..3c7ed968ddfa63cc651477f2a18792f7c26e9f50 100644 --- a/include/ALL_Voronoi.hpp +++ b/include/ALL_Voronoi.hpp @@ -94,7 +94,7 @@ public: /// method to provide a list of the neighbors of the local domain /// @param[out] list reference to a std::vector of integers where the list of /// neighbors will be assigned to - virtual void getNeighbors(std::vector<int> &list) override; + virtual std::vector<int> &getNeighbors() override; /// method to set specific data structures (unused for tensor grid method) /// @param[in] data pointer to the data structure @@ -102,7 +102,7 @@ public: /// method to get a list of the vertices of the neighboring domains /// @param[out] ret list of vertices of neighboring domains - void getNeighborVertices(std::vector<T> &ret); + std::vector<T> &getNeighborVertices(); private: // MPI values @@ -552,14 +552,14 @@ void Voronoi_LB<T, W>::balance(int known_unused loadbalancing_step) { // provide list of neighbors template <class T, class W> -void Voronoi_LB<T, W>::getNeighbors(std::vector<int> &ret) { - ret = neighbors; +std::vector<int> &Voronoi_LB<T, W>::getNeighbors() { + return neighbors; } // provide list of neighbor vertices template <class T, class W> -void Voronoi_LB<T, W>::getNeighborVertices(std::vector<T> &ret) { - ret = neighbor_vertices; +std::vector<T> &Voronoi_LB<T, W>::getNeighborVertices() { + return neighbor_vertices; } }//namespace ALL