mirror of
https://github.com/OPM/opm-simulators.git
synced 2024-12-22 15:33:29 -06:00
Small fixes for hypre integration (#1)
* use appropriate hypre init function * properly handle hypre without device support * don't add hypre preconditioner to factory if scalar type does not match
This commit is contained in:
parent
6fa9c25ba5
commit
3b67d6dc54
@ -36,6 +36,7 @@
|
||||
#endif
|
||||
|
||||
#if HAVE_HYPRE
|
||||
#include <HYPRE_config.h>
|
||||
#include <HYPRE_utilities.h>
|
||||
#endif
|
||||
|
||||
@ -173,7 +174,11 @@ void Main::initMPI()
|
||||
#endif // HAVE_MPI
|
||||
|
||||
#if HAVE_HYPRE
|
||||
#if HYPRE_RELEASE_NUMBER >= 22900
|
||||
HYPRE_Initialize();
|
||||
#else
|
||||
HYPRE_Init();
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -56,6 +56,7 @@ public:
|
||||
use_gpu_ = prm_.get<bool>("use_gpu", false);
|
||||
|
||||
// Set memory location and execution policy
|
||||
#if HYPRE_USING_CUDA || HYPRE_USING_HIP
|
||||
if (use_gpu_) {
|
||||
HYPRE_SetMemoryLocation(HYPRE_MEMORY_DEVICE);
|
||||
HYPRE_SetExecutionPolicy(HYPRE_EXEC_DEVICE);
|
||||
@ -66,7 +67,9 @@ public:
|
||||
HYPRE_DeviceInitialize();
|
||||
HYPRE_PrintDeviceInfo();
|
||||
}
|
||||
else {
|
||||
else
|
||||
#endif
|
||||
{
|
||||
HYPRE_SetMemoryLocation(HYPRE_MEMORY_HOST);
|
||||
HYPRE_SetExecutionPolicy(HYPRE_EXEC_HOST);
|
||||
}
|
||||
|
@ -549,7 +549,8 @@ struct StandardPreconditioners<Operator, Dune::Amg::SequentialInformation> {
|
||||
});
|
||||
#if HAVE_HYPRE
|
||||
// Only add Hypre for scalar matrices
|
||||
if constexpr (M::block_type::rows == 1 && M::block_type::cols == 1) {
|
||||
if constexpr (M::block_type::rows == 1 && M::block_type::cols == 1 &&
|
||||
std::is_same_v<HYPRE_Real, typename V::field_type>) {
|
||||
F::addCreator("hypre", [](const O& op, const P& prm, const std::function<V()>&, std::size_t) {
|
||||
return std::make_shared<Hypre::HyprePreconditioner<M, V, V>>(op.getmat(), prm);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user