Move Hypre initialization and finalization out to Main

This commit is contained in:
jakobtorben 2024-11-26 14:55:27 +01:00
parent 56897e6d11
commit 6fa9c25ba5
2 changed files with 12 additions and 3 deletions

View File

@ -35,6 +35,10 @@
#include <opm/simulators/utils/DamarisOutputModule.hpp>
#endif
#if HAVE_HYPRE
#include <HYPRE_utilities.h>
#endif
namespace Opm {
Main::Main(int argc, char** argv, bool ownMPI)
@ -88,6 +92,10 @@ Main::~Main()
}
#endif // HAVE_MPI
#if HAVE_HYPRE
HYPRE_Finalize();
#endif
if (ownMPI_) {
FlowGenericVanguard::setCommunication(nullptr);
}
@ -163,6 +171,10 @@ void Main::initMPI()
#endif
#endif // HAVE_MPI
#if HAVE_HYPRE
HYPRE_Initialize();
#endif
}
void Main::handleVersionCmdLine_(int argc, char** argv,

View File

@ -55,8 +55,6 @@ public:
use_gpu_ = prm_.get<bool>("use_gpu", false);
HYPRE_Initialize();
// Set memory location and execution policy
if (use_gpu_) {
HYPRE_SetMemoryLocation(HYPRE_MEMORY_DEVICE);
@ -155,7 +153,6 @@ public:
if (indices_device_) {
hypre_TFree(indices_device_, HYPRE_MEMORY_DEVICE);
}
HYPRE_Finalize();
}
void update() override {