]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Fix sundials test 14601/head
authorStefano Zampini <stefano.zampini@gmail.com>
Sun, 22 Jan 2023 12:40:41 +0000 (15:40 +0300)
committerStefano Zampini <stefano.zampini@gmail.com>
Sun, 22 Jan 2023 12:40:41 +0000 (15:40 +0300)
tests/sundials/n_vector.cc

index a23fbcba81b8f80a9bd6554c5341e6f9e7587426..2c1891114523cbf74c1571973c243b4d73245f4e 100644 (file)
 #include "../../include/deal.II/sundials/n_vector.templates.h"
 #include <deal.II/sundials/n_vector.h>
 
+#ifdef DEAL_II_WITH_MPI
+#  include <mpi.h>
+#endif
+
 #include "../tests.h"
 
 using namespace SUNDIALS::internal;
@@ -371,9 +375,16 @@ test_get_communicator()
                                     global_nvector_context
 #endif
   );
-  Assert(*static_cast<MPI_Comm *>(N_VGetCommunicator(n_vector)) ==
-           MPI_COMM_WORLD,
-         NVectorTestError());
+  // PETSc duplicates the user communicator. It does not make sense to
+  // compare MPI_Comm using "==", which is equivalent to MPI_IDENT.
+  // MPI_CONGRUENT indicates same group but different context (e.g. tags,
+  // keyvals, etc.)
+#ifdef DEAL_II_WITH_MPI
+  int  result;
+  auto comm = static_cast<MPI_Comm *>(N_VGetCommunicator(n_vector));
+  MPI_Comm_compare(*comm, MPI_COMM_WORLD, &result);
+  Assert(result == MPI_IDENT || result == MPI_CONGRUENT, NVectorTestError());
+#endif
 
   deallog << "test_get_communicator OK" << std::endl;
 }

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.