From: Sebastian Proell Date: Fri, 5 Nov 2021 15:52:05 +0000 (+0100) Subject: N_Vector now returns a pointer to MPI_Comm X-Git-Tag: v9.4.0-rc1~859^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F12921%2Fhead;p=dealii.git N_Vector now returns a pointer to MPI_Comm --- 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; }