]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Make ConsensusAlgorithms work in serial 11105/head
authorPeter Munch <peterrmuench@gmail.com>
Sun, 25 Oct 2020 19:03:56 +0000 (20:03 +0100)
committerPeter Munch <peterrmuench@gmail.com>
Mon, 26 Oct 2020 08:17:18 +0000 (09:17 +0100)
include/deal.II/base/mpi_consensus_algorithms.templates.h

index ad878a53dbc36f1660157cbb5d249c886edc3a67..010f0697851a3f2a4ec374f7a88645a66bcfd0e4 100644 (file)
@@ -83,8 +83,10 @@ namespace Utilities
                                    const MPI_Comm & comm)
         : process(process)
         , comm(comm)
-        , my_rank(this_mpi_process(comm))
-        , n_procs(n_mpi_processes(comm))
+        , my_rank(Utilities::MPI::job_supports_mpi() ? this_mpi_process(comm) :
+                                                       0)
+        , n_procs(Utilities::MPI::job_supports_mpi() ? n_mpi_processes(comm) :
+                                                       1)
       {}
 
 
@@ -558,20 +560,22 @@ namespace Utilities
         : Interface<T1, T2>(process, comm)
       {
         // Depending on the number of processes we switch between
-        // implementations. We reduce the threshold for debug mode to be able to
-        // test also the non-blocking implementation. This feature is tested by:
+        // implementations. We reduce the threshold for debug mode to be
+        // able to test also the non-blocking implementation. This feature
+        // is tested by:
         // tests/multigrid/transfer_matrix_free_06.with_mpi=true.with_p4est=true.with_trilinos=true.mpirun=15.output
 #ifdef DEAL_II_WITH_MPI
 #  if DEAL_II_MPI_VERSION_GTE(3, 0)
 #    ifdef DEBUG
-        if (Utilities::MPI::n_mpi_processes(comm) > 14)
+        if (this->n_procs > 14)
 #    else
-        if (Utilities::MPI::n_mpi_processes(comm) > 99)
+        if (this->n_procs > 99)
 #    endif
           consensus_algo.reset(new NBX<T1, T2>(process, comm));
         else
 #  endif
 #endif
+          if (this->n_procs > 1)
           consensus_algo.reset(new PEX<T1, T2>(process, comm));
       }
 
@@ -581,7 +585,8 @@ namespace Utilities
       void
       Selector<T1, T2>::run()
       {
-        consensus_algo->run();
+        if (consensus_algo)
+          consensus_algo->run();
       }
 
 

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.