diff --git a/README_new.md b/README_new.md index b894b71143be6a8d2fe5a14df3a8f3ae71259270..89cc34cba214f06688765650d077b67ee6e1d93f 100644 --- a/README_new.md +++ b/README_new.md @@ -142,7 +142,7 @@ The ALL object can be constructed with Where the type of the boundaries is given by `T` and the type of the work as `W`, which are usually float or double. The load balancing method must be one of `ALL::LB_t::TENSOR`, `...STAGGERED`, -`...UNSTRUCTURED`, `...VORONOI`, `...HISTOGRAM`. Where the Voronoi +`...FORCEBASED`, `...VORONOI`, `...HISTOGRAM`. Where the Voronoi method must be enabled at compile time. There is also a second form where the initial domain vertices are given: diff --git a/example/ALL_test.cpp b/example/ALL_test.cpp index b7fe2741aafa66fc8975bd2c78f327c386b2c82a..5827b7df32e17cd763300179e6f0ea636870d77f 100644 --- a/example/ALL_test.cpp +++ b/example/ALL_test.cpp @@ -222,7 +222,7 @@ void print_points(std::vector<ALL::Point<double>> plist, int step, #ifdef ALL_VORONOI_ACTIVE method == ALL::LB_t::VORONOI || #endif - method == ALL::LB_t::UNSTRUCTURED) { + method == ALL::LB_t::FORCEBASED) { if (!vtk_init) { controller = vtkMPIController::New(); controller->Initialize(); @@ -423,8 +423,8 @@ int main(int argc, char **argv) { case ALL::LB_t::STAGGERED: std::cout << "chosen method: STAGGERED" << std::endl; break; - case ALL::LB_t::UNSTRUCTURED: - std::cout << "chosen method: UNSTRUCTURED" << std::endl; + case ALL::LB_t::FORCEBASED: + std::cout << "chosen method: FORCEBASED" << std::endl; break; #ifdef ALL_VORONOI_ACTIVE case ALL::LB_t::VORONOI: @@ -463,7 +463,7 @@ int main(int argc, char **argv) { case ALL::LB_t::STAGGERED: nvertices = 2; break; - case ALL::LB_t::UNSTRUCTURED: + case ALL::LB_t::FORCEBASED: nvertices = 8; break; #ifdef ALL_VORONOI_ACTIVE @@ -496,7 +496,7 @@ int main(int argc, char **argv) { vertices.at(0) = lp; vertices.at(1) = up; break; - case ALL::LB_t::UNSTRUCTURED: + case ALL::LB_t::FORCEBASED: for (int i = 0; i < nvertices; ++i) vertices.at(0) = lp; for (int z = 0; z < 2; ++z) @@ -1423,7 +1423,7 @@ int main(int argc, char **argv) { offset_neig[1] = offset_neig[0] + nNeighbors[2 * (i + 1)]; } } break; - case ALL::LB_t::UNSTRUCTURED: { + case ALL::LB_t::FORCEBASED: { // array of all vertices of all neighbors (and self) double comm_vertices[27 * 8 * 3]; @@ -1522,7 +1522,7 @@ int main(int argc, char **argv) { #ifdef ALL_VTK_FORCE_SORT // creating an unstructured grid for local domain and neighbors auto vtkpoints = vtkSmartPointer<vtkPoints>::New(); - auto unstructuredGrid = vtkSmartPointer<vtkUnstructuredGrid>::New(); + auto unstructuredGrid = vtkSmartPointer<vtkForceBasedGrid>::New(); for (int i = 0; i < 27; ++i) { for (int v = 0; v < 8; ++v) { vtkpoints->InsertNextPoint(comm_vertices[i * 24 + v * 3], @@ -1585,7 +1585,7 @@ int main(int argc, char **argv) { /* if (localRank == 26) { - auto writer = vtkSmartPointer<vtkXMLUnstructuredGridWriter>::New(); + auto writer = vtkSmartPointer<vtkXMLForceBasedGridWriter>::New(); writer->SetInputData(unstructuredGrid); writer->SetFileName("test.vtu"); writer->SetDataModeToAscii(); @@ -1822,7 +1822,7 @@ int main(int argc, char **argv) { #else if (localRank == 0) - std::cout << "Currently no UNSTRUCTURED test without VTK!" + std::cout << "Currently no FORCEBASED test without VTK!" << std::endl; MPI_Abort(MPI_COMM_WORLD, -1); #endif @@ -2182,11 +2182,11 @@ int main(int argc, char **argv) { #ifdef ALL_VTK_OUTPUT // if (localRank == 0) // std::cout << "creating vtk outlines output" << std::endl; - if (chosen_method != ALL::LB_t::UNSTRUCTURED) + if (chosen_method != ALL::LB_t::FORCEBASED) lb_obj.printVTKoutlines(output_step); // if (localRank == 0) // std::cout << "creating vtk vertices output" << std::endl; - if (chosen_method == ALL::LB_t::UNSTRUCTURED) + if (chosen_method == ALL::LB_t::FORCEBASED) lb_obj.printVTKvertices(output_step); // if (localRank == 0) // std::cout << "creating points output" << std::endl; @@ -2320,7 +2320,7 @@ int main(int argc, char **argv) { if (chosen_method != ALL::LB_t::VORONOI) { #endif #ifdef ALL_VTK_OUTPUT - if (chosen_method != ALL::LB_t::UNSTRUCTURED) { + if (chosen_method != ALL::LB_t::FORCEBASED) { lb_obj.printVTKoutlines(output_step); double width[3]; double volume = 1.0; @@ -2346,7 +2346,7 @@ int main(int argc, char **argv) { MPI_Barrier(cart_comm); } } - if (chosen_method == ALL::LB_t::UNSTRUCTURED) + if (chosen_method == ALL::LB_t::FORCEBASED) lb_obj.printVTKvertices(output_step); #endif output_step++; diff --git a/example/jube/ALL_benchmark.xml b/example/jube/ALL_benchmark.xml index 7464a6a11b4b865e61b215f4e5c895c488a5848d..b8296417a0e5e642c29173dca8c2123371b7dc69 100644 --- a/example/jube/ALL_benchmark.xml +++ b/example/jube/ALL_benchmark.xml @@ -12,7 +12,7 @@ <parameter name="weight" type="int">0,1</parameter> <parameter name="gamma" type="float">4.0,8.0,16.0,32.0</parameter><--> <parameter name="method" type="int">0,1,4</parameter> - <parameter name="method_name" mode="python">["STAGGERED","TENSOR","UNSTRUCTURED","VORONOI","HISTOGRAM"][${method}]</parameter> + <parameter name="method_name" mode="python">["STAGGERED","TENSOR","FORCEBASED","VORONOI","HISTOGRAM"][${method}]</parameter> <parameter name="max_iter" mode="python" type="int">[500,500,-1,-1,3][${method}]</parameter> <parameter name="weight" type="int">0,1</parameter> <parameter name="gamma" type="float">4.0,8.0,16.0</parameter> diff --git a/include/ALL.hpp b/include/ALL.hpp index 903b5b9a8905c7996d2a361683afabef0ae0ef8d..2308e0a689838e7220b9090d5955e5cec15fcdeb 100644 --- a/include/ALL.hpp +++ b/include/ALL.hpp @@ -40,7 +40,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #endif #include "ALL_Histogram.hpp" #include "ALL_Staggered.hpp" -#include "ALL_Unstructured.hpp" +#include "ALL_ForceBased.hpp" #include <algorithm> #include <iomanip> #include <memory> @@ -79,7 +79,7 @@ enum LB_t : int { /// tensor based load balancing TENSOR = 1, /// unstructured-mesh load balancing - UNSTRUCTURED = 2, + FORCEBASED = 2, #ifdef ALL_VORONOI_ACTIVE /// voronoi cell based load balancing VORONOI = 3, @@ -142,8 +142,8 @@ public: case LB_t::STAGGERED: balancer.reset(new Staggered_LB<T, W>(d, (W)0, g)); break; - case LB_t::UNSTRUCTURED: - balancer.reset(new Unstructured_LB<T, W>(d, (W)0, g)); + case LB_t::FORCEBASED: + balancer.reset(new ForceBased_LB<T, W>(d, (W)0, g)); break; #ifdef ALL_VORONOI_ACTIVE case LB_t::VORONOI: @@ -371,7 +371,7 @@ public: */ balancer->balance(loadbalancing_step); break; - case LB_t::UNSTRUCTURED: + case LB_t::FORCEBASED: balancer->balance(loadbalancing_step); break; #ifdef ALL_VORONOI_ACTIVE @@ -436,15 +436,7 @@ public: /// @result vector of neighboring vertices /// neighboring vertices are stored in std::vector<T> &getNeighborVertices() { - switch (method) { -#ifdef ALL_VORONOI_ACTIVE - case LB_t::VORONOI: - return ((Voronoi_LB<T, W> *)balancer.get())->getNeighborVertices(); - break; -#endif - default: - break; - } + return balancer->getNeighborVertices(); } /// method to set the size of the system, e.g. required for the HISTOGRAM diff --git a/include/ALL_Unstructured.hpp b/include/ALL_ForceBased.hpp similarity index 97% rename from include/ALL_Unstructured.hpp rename to include/ALL_ForceBased.hpp index 67f66c41521bf89f91440bcfada4f1f5045d3566..6ebbc3bea69a610b739f9ad0d81a8d4cceba667a 100644 --- a/include/ALL_Unstructured.hpp +++ b/include/ALL_ForceBased.hpp @@ -28,14 +28,14 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef ALL_UNSTRUCTURED_HEADER_INCLUDED -#define ALL_UNSTRUCTURED_HEADER_INCLUDED +#ifndef ALL_FORCEBASED_HEADER_INCLUDED +#define ALL_FORCEBASED_HEADER_INCLUDED #define ALL_FORCE_OLD /* - Unstructured load-balancing scheme: + ForceBased load-balancing scheme: Requirements: a) cartesian communicator @@ -82,20 +82,20 @@ namespace ALL { /// conserved throughout the load-balancing process. /// @tparam T data for vertices and related data /// @tparam W data for work and related data -template <class T, class W> class Unstructured_LB : public LB<T, W> { +template <class T, class W> class ForceBased_LB : public LB<T, W> { public: /// default constructor - Unstructured_LB() {} + ForceBased_LB() {} /// constructor initializing basic parameters /// @param[in] d the dimension of the used vertices /// @param[in] w the scalar work assigned to the local domain /// @param[in] g the correction factor gamma - Unstructured_LB(int d, W w, T g) : LB<T, W>(d, g) { + ForceBased_LB(int d, W w, T g) : LB<T, W>(d, g) { this->setWork(w); } /// default destructor - ~Unstructured_LB() override; + ~ForceBased_LB() override; /// setup internal data structures and parameters void setup() override; @@ -145,15 +145,15 @@ private: int sec_dim[2]; }; -template <class T, class W> Unstructured_LB<T, W>::~Unstructured_LB() {} +template <class T, class W> ForceBased_LB<T, W>::~ForceBased_LB() {} // provide list of neighbors template <class T, class W> -std::vector<int> &Unstructured_LB<T, W>::getNeighbors() { +std::vector<int> &ForceBased_LB<T, W>::getNeighbors() { return neighbors; } -template <class T, class W> void Unstructured_LB<T, W>::setup() { +template <class T, class W> void ForceBased_LB<T, W>::setup() { n_vertices = this->vertices.size(); vertex_neighbors.resize(n_vertices * 8); @@ -277,7 +277,7 @@ template <class T, class W> void Unstructured_LB<T, W>::setup() { #ifdef ALL_DEBUG_ENABLED MPI_Barrier(this->globalComm); if (this->localRank == 0) - std::cout << "ALL::Unstructured_LB<T,W>::setup() preparing communicators..." + std::cout << "ALL::ForceBased_LB<T,W>::setup() preparing communicators..." << std::endl; #endif std::vector<int> dim_vert(this->global_dims); @@ -288,7 +288,7 @@ template <class T, class W> void Unstructured_LB<T, W>::setup() { #ifdef ALL_DEBUG_ENABLED MPI_Barrier(this->globalComm); if (this->localRank == 0) - std::cout << "ALL::Unstructured_LB<T,W>::setup() computing communicators..." + std::cout << "ALL::ForceBased_LB<T,W>::setup() computing communicators..." << std::endl; std::cout << "DEBUG: " << " rank: " << this->localRank << " dim_vert: " << dim_vert.at(0) @@ -370,7 +370,7 @@ template <class T, class W> void Unstructured_LB<T, W>::setup() { #ifdef ALL_DEBUG_ENABLED MPI_Barrier(this->globalComm); if (this->localRank == 0) - std::cout << "ALL::Unstructured_LB<T,W>::setup() finished computing " + std::cout << "ALL::ForceBased_LB<T,W>::setup() finished computing " "communicators..." << std::endl; #endif @@ -381,7 +381,7 @@ template <class T, class W> void Unstructured_LB<T, W>::setup() { // for now: do not change the vertices along the edge of the system template <class T, class W> -void Unstructured_LB<T, W>::balance(int /*step*/) { +void ForceBased_LB<T, W>::balance(int /*step*/) { this->prevVertices = this->vertices; diff --git a/include/ALL_LB.hpp b/include/ALL_LB.hpp index 3e2e36354fda0fb6fb57c4c84b82ea36c4daf3bd..b2b36c8ee0fda555e3992028f94605712b511198 100644 --- a/include/ALL_LB.hpp +++ b/include/ALL_LB.hpp @@ -51,6 +51,7 @@ public: periodicity.resize(dim); local_coords.resize(dim); global_dims.resize(dim); + neighborVertices.resize(0); } /// destructor @@ -162,6 +163,12 @@ public: /// @param[in] data the data be passed to the balancing method virtual void setAdditionalData(const void *data) = 0; + /// method to provide a list of vertices describing the neighboring domains + /// currently only implemented for VORONOI, as a means to get the anchor points + /// of the surrounding domains + std::vector<T> &getNeighborVertices() { + return neighborVertices; } + protected: /// correction factor T gamma; @@ -188,9 +195,12 @@ protected: std::vector<int> local_coords; /// periodicity of the MPI communicator / system std::vector<int> periodicity; + /// vertices describing neighboring domains + std::vector<T> neighborVertices; /// method the resize the vertex list /// @param [in] new_size the new size of the vertex list void resizeVertices(const int newSize) { vertices.resize(newSize); } + }; }//namespace ALL diff --git a/include/ALL_Voronoi.hpp b/include/ALL_Voronoi.hpp index 3c7ed968ddfa63cc651477f2a18792f7c26e9f50..8cc2bdc4020b50e84394d5a140fadcb2838e4657 100644 --- a/include/ALL_Voronoi.hpp +++ b/include/ALL_Voronoi.hpp @@ -115,9 +115,6 @@ private: std::vector<int> neighbors; int nNeighbors[1]; - // generator points of the neighbor cells - std::vector<T> neighbor_vertices; - // collection of generator points std::vector<T> generator_points; @@ -540,13 +537,13 @@ void Voronoi_LB<T, W>::balance(int known_unused loadbalancing_step) { nNeighbors[0] = neighbors.size(); // clear old neighbor vertices - neighbor_vertices.clear(); + this->neighborVertices.clear(); // find vertices of neighbors for (auto n : neighbors) { for (int i = 0; i < dimension; ++i) - neighbor_vertices.push_back(generator_points.at(info_length * n + i)); + this->neighborVertices.push_back(generator_points.at(info_length * n + i)); } } @@ -556,11 +553,6 @@ std::vector<int> &Voronoi_LB<T, W>::getNeighbors() { return neighbors; } -// provide list of neighbor vertices -template <class T, class W> -std::vector<T> &Voronoi_LB<T, W>::getNeighborVertices() { - return neighbor_vertices; -} }//namespace ALL diff --git a/src/ALL_module.F90 b/src/ALL_module.F90 index d76af38fc8a0c19dee71b0ae77e65e465e883bbf..ad9dcfd14937b5065ece390acbc6b176960de49f 100644 --- a/src/ALL_module.F90 +++ b/src/ALL_module.F90 @@ -42,7 +42,7 @@ module ALL_module ! The different loadbalancing methods. Must be kept in sync with C side. integer(c_int), public, parameter :: ALL_STAGGERED = 0 integer(c_int), public, parameter :: ALL_TENSOR = 1 - integer(c_int), public, parameter :: ALL_UNSTRUCTURED = 2 + integer(c_int), public, parameter :: ALL_FORCEBASED = 2 #ifdef ALL_VORONOI_ACTIVE integer(c_int), public, parameter :: ALL_VORONOI = 3 #endif diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6214431aa7ea5161adaea8aee5b680e9767d971e..283e2ceda34219ea46a2329e62030ce9215a6b0a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -5,7 +5,7 @@ set(ALL_HEADER_FILES ${ALL_INCLUDE_DIR}/ALL.hpp ${ALL_INCLUDE_DIR}/ALL_Histogram.hpp ${ALL_INCLUDE_DIR}/ALL_Staggered.hpp ${ALL_INCLUDE_DIR}/ALL_Tensor.hpp - ${ALL_INCLUDE_DIR}/ALL_Unstructured.hpp + ${ALL_INCLUDE_DIR}/ALL_ForceBased.hpp ${ALL_INCLUDE_DIR}/ALL_Voronoi.hpp ${ALL_INCLUDE_DIR}/ALL_Point.hpp ${ALL_INCLUDE_DIR}/ALL_CustomExceptions.hpp)