]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Simplify distribute_sparsity_pattern in examples
authorMartin Kronbichler <kronbichler@lnm.mw.tum.de>
Sun, 22 Mar 2020 06:48:17 +0000 (07:48 +0100)
committerMartin Kronbichler <kronbichler@lnm.mw.tum.de>
Fri, 10 Apr 2020 14:39:22 +0000 (16:39 +0200)
examples/step-18/step-18.cc
examples/step-40/step-40.cc
examples/step-55/step-55.cc
examples/step-62/step-62.cc

index f78ad03017c7c43fb9d249bc269910769e1ee5fa..b792aaf2f90af8e2c73c634be99b3612b64a4335 100644 (file)
@@ -495,20 +495,10 @@ namespace Step18
 
     ConditionalOStream pcout;
 
-    // Here is a vector where each entry denotes the numbers of degrees of
-    // freedom that are stored on the processor with that particular number:
-    std::vector<types::global_dof_index> local_dofs_per_process;
-
     // We are storing the locally owned and the locally relevant indices:
     IndexSet locally_owned_dofs;
     IndexSet locally_relevant_dofs;
 
-    // In the same direction, also cache how many cells the present processor
-    // owns. Note that the cells that belong to a processor are not
-    // necessarily contiguously numbered (when iterating over them using
-    // <code>active_cell_iterator</code>).
-    unsigned int n_local_cells;
-
     // Finally, we have a static variable that denotes the linear relationship
     // between the stress and strain. Since it is a constant object that does
     // not depend on any input (at least not in this program), we make it a
@@ -720,7 +710,6 @@ namespace Step18
     , n_mpi_processes(Utilities::MPI::n_mpi_processes(mpi_communicator))
     , this_mpi_process(Utilities::MPI::this_mpi_process(mpi_communicator))
     , pcout(std::cout, this_mpi_process == 0)
-    , n_local_cells(numbers::invalid_unsigned_int)
   {}
 
 
@@ -818,15 +807,6 @@ namespace Step18
     locally_owned_dofs = dof_handler.locally_owned_dofs();
     DoFTools::extract_locally_relevant_dofs(dof_handler, locally_relevant_dofs);
 
-    // The next thing is to store some information for later use on how many
-    // cells or degrees of freedom the present processor, or any of the
-    // processors has to work on. First the cells local to this processor...
-    n_local_cells = GridTools::count_cells_with_subdomain_association(
-      triangulation, triangulation.locally_owned_subdomain());
-
-    local_dofs_per_process =
-      dof_handler.compute_n_locally_owned_dofs_per_processor();
-
     // The next step is to set up constraints due to hanging nodes. This has
     // been handled many times before:
     hanging_node_constraints.clear();
@@ -856,7 +836,7 @@ namespace Step18
                                     hanging_node_constraints,
                                     /*keep constrained dofs*/ false);
     SparsityTools::distribute_sparsity_pattern(sparsity_pattern,
-                                               local_dofs_per_process,
+                                               locally_owned_dofs,
                                                mpi_communicator,
                                                locally_relevant_dofs);
     // Note that we have used the <code>DynamicSparsityPattern</code> class
index d650a8b101fbf3bd9d8f1880d78bec90e4b74977..472c28e3136138c63a45dddd64972163c55368af 100644 (file)
@@ -314,11 +314,10 @@ namespace Step40
     DynamicSparsityPattern dsp(locally_relevant_dofs);
 
     DoFTools::make_sparsity_pattern(dof_handler, dsp, constraints, false);
-    SparsityTools::distribute_sparsity_pattern(
-      dsp,
-      dof_handler.compute_n_locally_owned_dofs_per_processor(),
-      mpi_communicator,
-      locally_relevant_dofs);
+    SparsityTools::distribute_sparsity_pattern(dsp,
+                                               dof_handler.locally_owned_dofs(),
+                                               mpi_communicator,
+                                               locally_relevant_dofs);
 
     system_matrix.reinit(locally_owned_dofs,
                          locally_owned_dofs,
index 7ac4be8833356fcc81cada623bf8cf21113e7f8c..419ad7cfd61dae3bf155604401fea917a1baa0b7 100644 (file)
@@ -429,7 +429,7 @@ namespace Step55
 
       SparsityTools::distribute_sparsity_pattern(
         dsp,
-        dof_handler.compute_locally_owned_dofs_per_processor(),
+        dof_handler.locally_owned_dofs(),
         mpi_communicator,
         locally_relevant_dofs);
 
index 91dc9cadfcc792cfc2ed362e93d21e4c7867c814..5d77dca09c33ff5b632f6369a5c8f071f1d02546 100644 (file)
@@ -764,11 +764,10 @@ namespace step62
     DynamicSparsityPattern dsp(locally_relevant_dofs);
 
     DoFTools::make_sparsity_pattern(dof_handler, dsp, constraints, false);
-    SparsityTools::distribute_sparsity_pattern(
-      dsp,
-      dof_handler.compute_n_locally_owned_dofs_per_processor(),
-      mpi_communicator,
-      locally_relevant_dofs);
+    SparsityTools::distribute_sparsity_pattern(dsp,
+                                               locally_owned_dofs,
+                                               mpi_communicator,
+                                               locally_relevant_dofs);
 
     system_matrix.reinit(locally_owned_dofs,
                          locally_owned_dofs,

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.