]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Move some operations into a constructor. 17855/head
authorWolfgang Bangerth <bangerth@colostate.edu>
Fri, 8 Nov 2024 15:29:47 +0000 (08:29 -0700)
committerWolfgang Bangerth <bangerth@colostate.edu>
Mon, 11 Nov 2024 16:00:04 +0000 (09:00 -0700)
source/base/mpi.cc

index ffb1502e4d119d97e51790fd9c55002abbcca91e..1b42e2403d56f3ea0fc04f3abd0fbd70f1612550 100644 (file)
@@ -776,6 +776,14 @@ namespace Utilities
            */
           static constexpr unsigned int sparsity_factor = 4;
 
+
+          /**
+           * Set up the dictionary by computing the partitioning from the
+           * global size and sending the rank information on locally owned
+           * ranges to the owner of the dictionary part.
+           */
+          Dictionary(const IndexSet &owned_indices, const MPI_Comm comm);
+
           /**
            * A vector with as many entries as there are dofs in the dictionary
            * of the current process, and each entry containing the rank of the
@@ -831,14 +839,6 @@ namespace Utilities
            */
           unsigned int stride_small_size;
 
-          /**
-           * Set up the dictionary by computing the partitioning from the
-           * global size and sending the rank information on locally owned
-           * ranges to the owner of the dictionary part.
-           */
-          void
-          reinit(const IndexSet &owned_indices, const MPI_Comm comm);
-
           /**
            * Translate a global dof index to the MPI rank in the dictionary
            * using `dofs_per_process`. We multiply by `stride_small_size` to
@@ -938,6 +938,11 @@ namespace Utilities
            */
           std::vector<unsigned int> &owning_ranks;
 
+          /**
+           * The dictionary handling the requests.
+           */
+          Dictionary dict;
+
           /**
            * Keeps track of the origin of the requests. The layout of the data
            * structure is as follows: The outermost vector has as many entries
@@ -953,11 +958,6 @@ namespace Utilities
                                             types::global_dof_index>>>>>
             requesters;
 
-          /**
-           * The dictionary handling the requests.
-           */
-          Dictionary dict;
-
           /**
            * Array to collect the indices to look up (first vector) and their
            * local index among indices (second vector), sorted by the rank in
@@ -1192,8 +1192,8 @@ namespace Utilities
 
 
 
-        void
-        Dictionary::reinit(const IndexSet &owned_indices, const MPI_Comm comm)
+        Dictionary::Dictionary(const IndexSet &owned_indices,
+                               const MPI_Comm  comm)
         {
           // 1) set up the partition
           this->partition(owned_indices, comm);
@@ -1495,10 +1495,9 @@ namespace Utilities
           , n_procs(n_mpi_processes(comm))
           , track_index_requesters(track_index_requesters)
           , owning_ranks(owning_ranks)
-        {
-          dict.reinit(owned_indices, comm);
-          requesters.resize(dict.actually_owning_rank_list.size());
-        }
+          , dict(owned_indices, comm)
+          , requesters(dict.actually_owning_rank_list.size())
+        {}
 
 
 

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.