From 8b1900ceeb630eb2fac2949682616d16976972a7 Mon Sep 17 00:00:00 2001 From: Sebastian Proell Date: Fri, 5 Nov 2021 16:52:05 +0100 Subject: [PATCH] N_Vector now returns a pointer to MPI_Comm --- include/deal.II/sundials/n_vector.templates.h | 11 ++++++----- tests/sundials/n_vector.cc | 4 +++- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/include/deal.II/sundials/n_vector.templates.h b/include/deal.II/sundials/n_vector.templates.h index f48798e415..002eb5eb66 100644 --- a/include/deal.II/sundials/n_vector.templates.h +++ b/include/deal.II/sundials/n_vector.templates.h @@ -265,13 +265,13 @@ namespace SUNDIALS template < typename VectorType, typename std::enable_if_t::value, int> = 0> - MPI_Comm + const MPI_Comm & get_communicator(N_Vector v); template < typename VectorType, typename std::enable_if_t::value, int> = 0> - MPI_Comm + const MPI_Comm & get_communicator(N_Vector v); /** @@ -503,7 +503,7 @@ namespace SUNDIALS template ::value, int>> - MPI_Comm + const MPI_Comm & get_communicator(N_Vector v) { return unwrap_nvector_const(v) @@ -515,7 +515,7 @@ namespace SUNDIALS template ::value, int>> - MPI_Comm + const MPI_Comm & get_communicator(N_Vector v) { return unwrap_nvector_const(v)->get_mpi_communicator(); @@ -545,7 +545,8 @@ namespace SUNDIALS (void)v; return nullptr; # else - return get_communicator(v); + // We need to cast away const here, as SUNDIALS demands a pure `void *`. + return &(const_cast(get_communicator(v))); # endif } diff --git a/tests/sundials/n_vector.cc b/tests/sundials/n_vector.cc index ab5d1b4c32..14eb7a5a36 100644 --- a/tests/sundials/n_vector.cc +++ b/tests/sundials/n_vector.cc @@ -329,7 +329,9 @@ test_get_communicator() { auto vector = create_test_vector(); auto n_vector = make_nvector_view(vector); - Assert(N_VGetCommunicator(n_vector) == MPI_COMM_WORLD, NVectorTestError()); + Assert(*static_cast(N_VGetCommunicator(n_vector)) == + MPI_COMM_WORLD, + NVectorTestError()); deallog << "test_get_communicator OK" << std::endl; } -- 2.39.5