]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Do not store some things in the CA::Interface base class. 13262/head
authorWolfgang Bangerth <bangerth@colostate.edu>
Tue, 18 Jan 2022 15:44:11 +0000 (08:44 -0700)
committerWolfgang Bangerth <bangerth@colostate.edu>
Tue, 18 Jan 2022 20:54:51 +0000 (13:54 -0700)
The base class currently stores a number of things about the communicator that are either
unused in any of the implementations, or only used in one place in the Selector::run()
function. Remove these member variables and just query what we need in the one place
where it's used.

include/deal.II/base/mpi_consensus_algorithms.h
include/deal.II/base/mpi_consensus_algorithms.templates.h

index 3c34b591b422b91527416325717cc09bbf52cb9d..4319fe0b754b0b0945ce52beeef972d259b644ae 100644 (file)
@@ -244,21 +244,6 @@ namespace Utilities
          * MPI communicator.
          */
         const MPI_Comm &comm;
-
-        /**
-         * Cache if job supports MPI.
-         */
-        const bool job_supports_mpi;
-
-        /**
-         * Rank of this process.
-         */
-        const unsigned int my_rank;
-
-        /**
-         * Number of processes in the communicator.
-         */
-        const unsigned int n_procs;
       };
 
 
index b0c2993bed49d03a791568be64c37f5e36949090..e2c7090a2c3553928ed6ab427b87e3ddf2e90ef8 100644 (file)
@@ -116,9 +116,6 @@ namespace Utilities
                                    const MPI_Comm & comm)
         : process(process)
         , comm(comm)
-        , job_supports_mpi(Utilities::MPI::job_supports_mpi())
-        , my_rank(job_supports_mpi ? this_mpi_process(comm) : 0)
-        , n_procs(job_supports_mpi ? n_mpi_processes(comm) : 1)
       {}
 
 
@@ -692,18 +689,22 @@ namespace Utilities
         // 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=10.output
+
+        const unsigned int n_procs = (Utilities::MPI::job_supports_mpi() ?
+                                        Utilities::MPI::n_mpi_processes(comm) :
+                                        1);
 #ifdef DEAL_II_WITH_MPI
 #  if DEAL_II_MPI_VERSION_GTE(3, 0)
 #    ifdef DEBUG
-        if (this->n_procs > 10)
+        if (n_procs > 10)
 #    else
-        if (this->n_procs > 99)
+        if (n_procs > 99)
 #    endif
           consensus_algo.reset(new NBX<T1, T2>(process, comm));
         else
 #  endif
 #endif
-          if (this->n_procs > 1)
+          if (n_procs > 1)
           consensus_algo.reset(new PEX<T1, T2>(process, comm));
         else
           consensus_algo.reset(new Serial<T1, T2>(process, comm));

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.