From: Martin Kronbichler Date: Sun, 22 Mar 2020 06:48:17 +0000 (+0100) Subject: Simplify distribute_sparsity_pattern in examples X-Git-Tag: v9.2.0-rc1~239^2~2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6699977f4b61aeb2860ad77eb4e424709254a67c;p=dealii.git Simplify distribute_sparsity_pattern in examples --- diff --git a/examples/step-18/step-18.cc b/examples/step-18/step-18.cc index f78ad03017..b792aaf2f9 100644 --- a/examples/step-18/step-18.cc +++ b/examples/step-18/step-18.cc @@ -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 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 - // active_cell_iterator). - 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 DynamicSparsityPattern class diff --git a/examples/step-40/step-40.cc b/examples/step-40/step-40.cc index d650a8b101..472c28e313 100644 --- a/examples/step-40/step-40.cc +++ b/examples/step-40/step-40.cc @@ -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, diff --git a/examples/step-55/step-55.cc b/examples/step-55/step-55.cc index 7ac4be8833..419ad7cfd6 100644 --- a/examples/step-55/step-55.cc +++ b/examples/step-55/step-55.cc @@ -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); diff --git a/examples/step-62/step-62.cc b/examples/step-62/step-62.cc index 91dc9cadfc..5d77dca09c 100644 --- a/examples/step-62/step-62.cc +++ b/examples/step-62/step-62.cc @@ -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,