]> https://gitweb.dealii.org/ - dealii.git/commitdiff
fix sundials compilation 13123/head
authorTimo Heister <timo.heister@gmail.com>
Sat, 25 Dec 2021 17:30:45 +0000 (12:30 -0500)
committerTimo Heister <timo.heister@gmail.com>
Sat, 25 Dec 2021 17:30:45 +0000 (12:30 -0500)
include/deal.II/sundials/n_vector.templates.h

index 2b49e3efc9c5a03d6cb547f0cf96f198448c1c9d..746f63a03b5fcb49d57253f37c7d5fd4d6a3a8cc 100644 (file)
@@ -253,13 +253,13 @@ namespace SUNDIALS
       template <
         typename VectorType,
         typename std::enable_if_t<!IsBlockVector<VectorType>::value, int> = 0>
-      MPI_Comm
+      const MPI_Comm &
       get_communicator(N_Vector v);
 
       template <
         typename VectorType,
         typename std::enable_if_t<IsBlockVector<VectorType>::value, int> = 0>
-      MPI_Comm
+      const MPI_Comm &
       get_communicator(N_Vector v);
 
       /**
@@ -481,7 +481,7 @@ SUNDIALS::internal::NVectorOperations::destroy(N_Vector v)
 
 template <typename VectorType,
           std::enable_if_t<IsBlockVector<VectorType>::value, int>>
-MPI_Comm
+const MPI_Comm &
 SUNDIALS::internal::NVectorOperations::get_communicator(N_Vector v)
 {
   return unwrap_nvector_const<VectorType>(v)->block(0).get_mpi_communicator();
@@ -491,7 +491,7 @@ SUNDIALS::internal::NVectorOperations::get_communicator(N_Vector v)
 
 template <typename VectorType,
           std::enable_if_t<!IsBlockVector<VectorType>::value, int>>
-MPI_Comm
+const MPI_Comm &
 SUNDIALS::internal::NVectorOperations::get_communicator(N_Vector v)
 {
   return unwrap_nvector_const<VectorType>(v)->get_mpi_communicator();
@@ -519,7 +519,8 @@ SUNDIALS::internal::NVectorOperations::get_communicator_as_void_ptr(N_Vector v)
   (void)v;
   return nullptr;
 #  else
-  return get_communicator<VectorType>(v);
+  // We need to cast away const here, as SUNDIALS demands a pure `void *`.
+  return &(const_cast<MPI_Comm &>(get_communicator<VectorType>(v)));
 #  endif
 }
 

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.