From e89f73e88c448508d5b6b2c3597213352370d40d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Del=20Pino?= <stephane.delpino44@gmail.com> Date: Thu, 24 Jun 2021 16:08:02 +0200 Subject: [PATCH] Add SLEPc initialization and finalization calls --- src/utils/CMakeLists.txt | 9 ++++++++- src/utils/PugsUtils.cpp | 3 +++ src/utils/SLEPcWrapper.cpp | 26 ++++++++++++++++++++++++++ src/utils/SLEPcWrapper.hpp | 10 ++++++++++ 4 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 src/utils/SLEPcWrapper.cpp create mode 100644 src/utils/SLEPcWrapper.hpp diff --git a/src/utils/CMakeLists.txt b/src/utils/CMakeLists.txt index 3e2e1c15b..7639963d4 100644 --- a/src/utils/CMakeLists.txt +++ b/src/utils/CMakeLists.txt @@ -13,7 +13,14 @@ add_library( PETScWrapper.cpp PugsUtils.cpp RevisionInfo.cpp - SignalManager.cpp) + SignalManager.cpp + SLEPcWrapper.cpp) + +target_link_libraries( + PugsUtils + ${PETSC_LIBRARIES} + ${SLEPC_LIBRARIES} +) # --------------- get git revision info --------------- diff --git a/src/utils/PugsUtils.cpp b/src/utils/PugsUtils.cpp index fbf2b04e3..d35fa95f4 100644 --- a/src/utils/PugsUtils.cpp +++ b/src/utils/PugsUtils.cpp @@ -6,6 +6,7 @@ #include <utils/Messenger.hpp> #include <utils/PETScWrapper.hpp> #include <utils/RevisionInfo.hpp> +#include <utils/SLEPcWrapper.hpp> #include <utils/SignalManager.hpp> #include <utils/pugs_build_info.hpp> @@ -124,6 +125,7 @@ initialize(int& argc, char* argv[]) } PETScWrapper::initialize(argc, argv); + SLEPcWrapper::initialize(argc, argv); setDefaultOMPEnvironment(); Kokkos::initialize(argc, argv); @@ -153,6 +155,7 @@ void finalize() { Kokkos::finalize(); + SLEPcWrapper::finalize(); PETScWrapper::finalize(); parallel::Messenger::destroy(); } diff --git a/src/utils/SLEPcWrapper.cpp b/src/utils/SLEPcWrapper.cpp new file mode 100644 index 000000000..2c7076d54 --- /dev/null +++ b/src/utils/SLEPcWrapper.cpp @@ -0,0 +1,26 @@ +#include <utils/SLEPcWrapper.hpp> + +#include <utils/pugs_config.hpp> + +#ifdef PUGS_HAS_SLEPC +#include <slepc.h> +#endif // PUGS_HAS_SLEPC + +namespace SLEPcWrapper +{ +void +initialize([[maybe_unused]] int& argc, [[maybe_unused]] char* argv[]) +{ +#ifdef PUGS_HAS_SLEPC + SlepcInitialize(&argc, &argv, 0, 0); +#endif // PUGS_HAS_SLEPC +} + +void +finalize() +{ +#ifdef PUGS_HAS_SLEPC + SlepcFinalize(); +#endif // PUGS_HAS_SLEPC +} +} // namespace SLEPcWrapper diff --git a/src/utils/SLEPcWrapper.hpp b/src/utils/SLEPcWrapper.hpp new file mode 100644 index 000000000..8b6480233 --- /dev/null +++ b/src/utils/SLEPcWrapper.hpp @@ -0,0 +1,10 @@ +#ifndef SLEPC_WRAPPER_HPP +#define SLEPC_WRAPPER_HPP + +namespace SLEPcWrapper +{ +void initialize(int& argc, char* argv[]); +void finalize(); +} // namespace SLEPcWrapper + +#endif // SLEPC_WRAPPER_HPP -- GitLab