diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index dbaf666c108fe6d96830c53bdb7c87aa50a912c2..4cff6b232c85518a83c3eef3cd4ff9843c54c86a 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -89,7 +89,11 @@ add_executable (mpi_unit_tests mpi_test_Messenger.cpp ) +add_library(test_Pugs_MeshDataBase + test_MeshDataBase.cpp) + target_link_libraries (unit_tests + test_Pugs_MeshDataBase PugsLanguage PugsLanguageAST PugsLanguageModules @@ -106,6 +110,7 @@ target_link_libraries (unit_tests ) target_link_libraries (mpi_unit_tests + test_Pugs_MeshDataBase PugsUtils PugsAlgebra PugsMesh diff --git a/tests/mpi_test_main.cpp b/tests/mpi_test_main.cpp index f1140b479a5d1810fc56d8cc2eb1ae6f25b2d409..df55a88dc1025fb948add386fb6df41e9873d742 100644 --- a/tests/mpi_test_main.cpp +++ b/tests/mpi_test_main.cpp @@ -3,9 +3,15 @@ #include <Kokkos_Core.hpp> +#include <mesh/DiamondDualConnectivityManager.hpp> +#include <mesh/DiamondDualMeshManager.hpp> +#include <mesh/MeshDataManager.hpp> +#include <mesh/SynchronizerManager.hpp> #include <utils/Messenger.hpp> #include <utils/pugs_config.hpp> +#include <test_MeshDataBase.hpp> + #include <cstdlib> #include <filesystem> @@ -30,9 +36,6 @@ main(int argc, char* argv[]) if (parallel::rank() != 0) { // Disable outputs for ranks != 0 setenv("GCOV_PREFIX", gcov_prefix.string().c_str(), 1); - - std::cout << "putting gcov infos in " << gcov_prefix.string() << '\n'; - parallel_output /= output_base_name + std::to_string(parallel::rank()); Catch::ConfigData data{session.configData()}; @@ -43,7 +46,13 @@ main(int argc, char* argv[]) if (result == 0) { // Disable outputs from tested classes to the standard output std::cout.setstate(std::ios::badbit); - result = session.run(); + + SynchronizerManager::create(); + MeshDataManager::create(); + DiamondDualConnectivityManager::create(); + DiamondDualMeshManager::create(); + + test_MeshDataBase::create(); if (parallel::rank() == 0) { if (parallel::size() > 1) { @@ -59,6 +68,15 @@ main(int argc, char* argv[]) } } } + + result = session.run(); + + test_MeshDataBase::destroy(); + + DiamondDualMeshManager::destroy(); + DiamondDualConnectivityManager::destroy(); + MeshDataManager::destroy(); + SynchronizerManager::destroy(); } Kokkos::finalize(); diff --git a/tests/test_MeshDataBase.cpp b/tests/test_MeshDataBase.cpp new file mode 100644 index 0000000000000000000000000000000000000000..971f5cd5bfc3cc79731b9fad5fcbf37ab591826d --- /dev/null +++ b/tests/test_MeshDataBase.cpp @@ -0,0 +1,33 @@ +#include <test_MeshDataBase.hpp> +#include <utils/PugsAssert.hpp> + +#include <mesh/CartesianMeshBuilder.hpp> + +const test_MeshDataBase* test_MeshDataBase::m_instance = nullptr; + +test_MeshDataBase::test_MeshDataBase() +{ + std::make_shared<CartesianMeshBuilder>(TinyVector<3>{0, 1, 0}, TinyVector<3>{2, -1, 3}, + TinyVector<3, size_t>{6, 7, 3}); +} + +const test_MeshDataBase& +test_MeshDataBase::get() +{ + return *m_instance; +} + +void +test_MeshDataBase::create() +{ + Assert(m_instance == nullptr); + m_instance = new test_MeshDataBase(); +} + +void +test_MeshDataBase::destroy() +{ + Assert(m_instance != nullptr); + delete m_instance; + m_instance = nullptr; +} diff --git a/tests/test_MeshDataBase.hpp b/tests/test_MeshDataBase.hpp new file mode 100644 index 0000000000000000000000000000000000000000..d5e84c8e7bdd08f9abf2ca7fb818bb364d463079 --- /dev/null +++ b/tests/test_MeshDataBase.hpp @@ -0,0 +1,23 @@ +#ifndef TEST_MESH_DATA_BASE_HPP +#define TEST_MESH_DATA_BASE_HPP + +#include <mesh/IMesh.hpp> + +#include <memory> + +class test_MeshDataBase +{ + private: + explicit test_MeshDataBase(); + + static const test_MeshDataBase* m_instance; + + public: + static const test_MeshDataBase& get(); + static void create(); + static void destroy(); + + ~test_MeshDataBase() = default; +}; + +#endif // TEST_MESH_DATA_BASE_HPP diff --git a/tests/test_main.cpp b/tests/test_main.cpp index eba6d05d0ea0cc29b222ec92f4815a3820118c20..2a9b6268f63bcb8bea0a01dfed5e0e52d07929a9 100644 --- a/tests/test_main.cpp +++ b/tests/test_main.cpp @@ -3,9 +3,18 @@ #include <Kokkos_Core.hpp> +#include <mesh/DiamondDualConnectivityManager.hpp> +#include <mesh/DiamondDualMeshManager.hpp> +#include <mesh/MeshDataManager.hpp> +#include <mesh/SynchronizerManager.hpp> +#include <utils/Messenger.hpp> + +#include <test_MeshDataBase.hpp> + int main(int argc, char* argv[]) { + parallel::Messenger::create(argc, argv); Kokkos::initialize({4, -1, -1, true}); Catch::Session session; @@ -14,10 +23,26 @@ main(int argc, char* argv[]) if (result == 0) { // Disable outputs from tested classes to the standard output std::cout.setstate(std::ios::badbit); + + SynchronizerManager::create(); + MeshDataManager::create(); + DiamondDualConnectivityManager::create(); + DiamondDualMeshManager::create(); + + test_MeshDataBase::create(); + result = session.run(); + + test_MeshDataBase::destroy(); + + DiamondDualMeshManager::destroy(); + DiamondDualConnectivityManager::destroy(); + MeshDataManager::destroy(); + SynchronizerManager::destroy(); } Kokkos::finalize(); - + parallel::Messenger::destroy(); + std::cout << "finalizing\n"; return result; }