From 2e6d20113380ca819d04eaf6aa6fc1610528cc96 Mon Sep 17 00:00:00 2001 From: Sebastian Proell Date: Fri, 12 Feb 2021 16:34:27 +0100 Subject: [PATCH] N_Vector get_communicator return nullptr in serial --- include/deal.II/sundials/n_vector.templates.h | 72 ++++++++++--------- tests/sundials/n_vector.cc | 1 + 2 files changed, 39 insertions(+), 34 deletions(-) diff --git a/include/deal.II/sundials/n_vector.templates.h b/include/deal.II/sundials/n_vector.templates.h index 55e08e77d0..c1c10838cd 100644 --- a/include/deal.II/sundials/n_vector.templates.h +++ b/include/deal.II/sundials/n_vector.templates.h @@ -252,22 +252,13 @@ namespace SUNDIALS template < typename VectorType, - typename std::enable_if_t::value, int> = 0> - MPI_Comm get_communicator(N_Vector); - - template < - typename VectorType, - typename std::enable_if_t::value && - !IsBlockVector::value, - int> = 0> + typename std::enable_if_t::value, int> = 0> MPI_Comm get_communicator(N_Vector v); template < typename VectorType, - typename std::enable_if_t::value && - IsBlockVector::value, - int> = 0> + typename std::enable_if_t::value, int> = 0> MPI_Comm get_communicator(N_Vector v); @@ -275,17 +266,17 @@ namespace SUNDIALS * Sundials likes a void* but we want to use the above functions * internally with a safe type. */ - template + template < + typename VectorType, + typename std::enable_if_t::value, int> = 0> inline void * - get_communicator_as_void_ptr(N_Vector v) - { -# ifndef DEAL_II_WITH_MPI - (void)v; - return nullptr; -# else - return get_communicator(v); -# endif - } + get_communicator_as_void_ptr(N_Vector v); + + template ::value, + int> = 0> + inline void * + get_communicator_as_void_ptr(N_Vector v); } // namespace NVectorOperations } // namespace internal @@ -489,34 +480,47 @@ SUNDIALS::internal::NVectorOperations::destroy(N_Vector v) template ::value, int>> -MPI_Comm SUNDIALS::internal::NVectorOperations::get_communicator(N_Vector) + std::enable_if_t::value, int>> +MPI_Comm +SUNDIALS::internal::NVectorOperations::get_communicator(N_Vector v) { - return MPI_COMM_SELF; + return unwrap_nvector_const(v)->block(0).get_mpi_communicator(); } template ::value && - IsBlockVector::value, - int>> + std::enable_if_t::value, int>> MPI_Comm SUNDIALS::internal::NVectorOperations::get_communicator(N_Vector v) { - return unwrap_nvector_const(v)->block(0).get_mpi_communicator(); + return unwrap_nvector_const(v)->get_mpi_communicator(); } template ::value && - !IsBlockVector::value, - int>> -MPI_Comm -SUNDIALS::internal::NVectorOperations::get_communicator(N_Vector v) + typename std::enable_if_t::value, int>> +void * + SUNDIALS::internal::NVectorOperations::get_communicator_as_void_ptr(N_Vector) { - return unwrap_nvector_const(v)->get_mpi_communicator(); + // required by SUNDIALS: MPI-unaware vectors should return the nullptr as comm + return nullptr; +} + + + +template ::value, int>> +void * +SUNDIALS::internal::NVectorOperations::get_communicator_as_void_ptr(N_Vector v) +{ +# ifndef DEAL_II_WITH_MPI + (void)v; + return nullptr; +# else + return get_communicator(v); +# endif } diff --git a/tests/sundials/n_vector.cc b/tests/sundials/n_vector.cc index 89e5414129..80b60017bf 100644 --- a/tests/sundials/n_vector.cc +++ b/tests/sundials/n_vector.cc @@ -314,6 +314,7 @@ test_get_communicator() { auto vector = create_test_vector(); auto n_vector = make_nvector_view(vector); + // required by SUNDIALS: MPI-unaware vectors should return the nullptr Assert(N_VGetCommunicator(n_vector) == nullptr, NVectorTestError()); deallog << "test_get_communicator OK" << std::endl; -- 2.39.5