From: Wolfgang Bangerth Date: Wed, 21 Jun 2023 15:40:39 +0000 (-0600) Subject: Do not remove duplicates before inserting index set elements. X-Git-Tag: relicensing~846^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6aba85e8bde2d89c48544b3a95ab3ef28eff5a38;p=dealii.git Do not remove duplicates before inserting index set elements. --- diff --git a/include/deal.II/lac/affine_constraints.templates.h b/include/deal.II/lac/affine_constraints.templates.h index ec2674885e..12fdc5564d 100644 --- a/include/deal.II/lac/affine_constraints.templates.h +++ b/include/deal.II/lac/affine_constraints.templates.h @@ -2613,10 +2613,6 @@ AffineConstraints::distribute(VectorType &vec) const if (!vec_owned_elements.is_element(entry.first)) additional_elements.emplace_back(entry.first); std::sort(additional_elements.begin(), additional_elements.end()); - additional_elements.erase(std::unique(additional_elements.begin(), - additional_elements.end()), - additional_elements.end()); - needed_elements.add_indices(additional_elements.begin(), additional_elements.end()); diff --git a/include/deal.II/lac/sparse_matrix_tools.h b/include/deal.II/lac/sparse_matrix_tools.h index 5e30faff48..9f2c240fe7 100644 --- a/include/deal.II/lac/sparse_matrix_tools.h +++ b/include/deal.II/lac/sparse_matrix_tools.h @@ -499,10 +499,6 @@ namespace SparseMatrixTools i.end()); std::sort(ghost_indices_vector.begin(), ghost_indices_vector.end()); - ghost_indices_vector.erase(std::unique(ghost_indices_vector.begin(), - ghost_indices_vector.end()), - ghost_indices_vector.end()); - IndexSet locally_active_dofs(std::get<1>(prefix_sum)); locally_active_dofs.add_indices(ghost_indices_vector.begin(), diff --git a/include/deal.II/multigrid/mg_transfer_global_coarsening.templates.h b/include/deal.II/multigrid/mg_transfer_global_coarsening.templates.h index c2084e1341..b936273c7d 100644 --- a/include/deal.II/multigrid/mg_transfer_global_coarsening.templates.h +++ b/include/deal.II/multigrid/mg_transfer_global_coarsening.templates.h @@ -773,9 +773,6 @@ namespace internal } std::sort(ghost_indices.begin(), ghost_indices.end()); - ghost_indices.erase(std::unique(ghost_indices.begin(), - ghost_indices.end()), - ghost_indices.end()); this->is_extended_ghosts = IndexSet(mg_level_fine == numbers::invalid_unsigned_int ? @@ -1078,12 +1075,6 @@ namespace internal std::sort(locally_relevant_dofs_temp.begin(), locally_relevant_dofs_temp.end()); - - locally_relevant_dofs_temp.erase( - std::unique(locally_relevant_dofs_temp.begin(), - locally_relevant_dofs_temp.end()), - locally_relevant_dofs_temp.end()); - locally_relevant_dofs.add_indices(locally_relevant_dofs_temp.begin(), locally_relevant_dofs_temp.end()); diff --git a/source/dofs/dof_tools.cc b/source/dofs/dof_tools.cc index d91d716257..d460e6cd4f 100644 --- a/source/dofs/dof_tools.cc +++ b/source/dofs/dof_tools.cc @@ -1159,11 +1159,9 @@ namespace DoFTools dofs_on_ghosts.push_back(dof_index); } - // sort, compress out duplicates, fill into index set + // sort and put into an index set std::sort(dofs_on_ghosts.begin(), dofs_on_ghosts.end()); - dof_set.add_indices(dofs_on_ghosts.begin(), - std::unique(dofs_on_ghosts.begin(), - dofs_on_ghosts.end())); + dof_set.add_indices(dofs_on_ghosts.begin(), dofs_on_ghosts.end()); dof_set.compress(); return dof_set; @@ -1217,12 +1215,9 @@ namespace DoFTools dofs_on_ghosts.push_back(dof_index); } - // sort, compress out duplicates, fill into index set + // sort and fill into an index set std::sort(dofs_on_ghosts.begin(), dofs_on_ghosts.end()); - dof_set.add_indices(dofs_on_ghosts.begin(), - std::unique(dofs_on_ghosts.begin(), - dofs_on_ghosts.end())); - + dof_set.add_indices(dofs_on_ghosts.begin(), dofs_on_ghosts.end()); dof_set.compress(); return dof_set; @@ -1690,13 +1685,8 @@ namespace DoFTools local_dof_indices.begin(), local_dof_indices.end()); } - // sort indices and remove duplicates + // sort indices and put into an index set: std::sort(subdomain_indices.begin(), subdomain_indices.end()); - subdomain_indices.erase(std::unique(subdomain_indices.begin(), - subdomain_indices.end()), - subdomain_indices.end()); - - // insert into IndexSet index_set.add_indices(subdomain_indices.begin(), subdomain_indices.end()); index_set.compress(); diff --git a/source/matrix_free/dof_info.cc b/source/matrix_free/dof_info.cc index d6f12cd6fb..fd86229c5e 100644 --- a/source/matrix_free/dof_info.cc +++ b/source/matrix_free/dof_info.cc @@ -930,9 +930,6 @@ namespace internal part.local_to_global(plain_dof_indices[i])); } std::sort(ghost_indices.begin(), ghost_indices.end()); - ghost_indices.erase(std::unique(ghost_indices.begin(), - ghost_indices.end()), - ghost_indices.end()); IndexSet compressed_set(part.size()); compressed_set.add_indices(ghost_indices.begin(), ghost_indices.end()); compressed_set.subtract_set(part.locally_owned_range()); @@ -1084,9 +1081,6 @@ namespace internal part.get_mpi_communicator()) != 0; std::sort(ghost_indices.begin(), ghost_indices.end()); - ghost_indices.erase(std::unique(ghost_indices.begin(), - ghost_indices.end()), - ghost_indices.end()); IndexSet compressed_set(part.size()); compressed_set.add_indices(ghost_indices.begin(), ghost_indices.end()); @@ -1161,9 +1155,6 @@ namespace internal } }); std::sort(ghost_indices.begin(), ghost_indices.end()); - ghost_indices.erase(std::unique(ghost_indices.begin(), - ghost_indices.end()), - ghost_indices.end()); IndexSet compressed_set(part.size()); compressed_set.add_indices(ghost_indices.begin(), ghost_indices.end()); diff --git a/source/multigrid/mg_tools.cc b/source/multigrid/mg_tools.cc index ae4d802c05..011a9cb9bb 100644 --- a/source/multigrid/mg_tools.cc +++ b/source/multigrid/mg_tools.cc @@ -1432,10 +1432,8 @@ namespace MGTools ++level) { std::sort(dofs_by_level[level].begin(), dofs_by_level[level].end()); - boundary_indices[level].add_indices( - dofs_by_level[level].begin(), - std::unique(dofs_by_level[level].begin(), - dofs_by_level[level].end())); + boundary_indices[level].add_indices(dofs_by_level[level].begin(), + dofs_by_level[level].end()); } } @@ -1521,8 +1519,7 @@ namespace MGTools interface_dofs[l].clear(); std::sort(tmp_interface_dofs[l].begin(), tmp_interface_dofs[l].end()); interface_dofs[l].add_indices(tmp_interface_dofs[l].begin(), - std::unique(tmp_interface_dofs[l].begin(), - tmp_interface_dofs[l].end())); + tmp_interface_dofs[l].end()); interface_dofs[l].compress(); } } diff --git a/source/multigrid/mg_transfer_internal.cc b/source/multigrid/mg_transfer_internal.cc index 8bcced916a..7d4be4e020 100644 --- a/source/multigrid/mg_transfer_internal.cc +++ b/source/multigrid/mg_transfer_internal.cc @@ -407,8 +407,7 @@ namespace internal std::sort(ghosted_level_dofs.begin(), ghosted_level_dofs.end()); IndexSet ghosted_dofs(locally_owned.size()); ghosted_dofs.add_indices(ghosted_level_dofs.begin(), - std::unique(ghosted_level_dofs.begin(), - ghosted_level_dofs.end())); + ghosted_level_dofs.end()); ghosted_dofs.compress(); // Add possible ghosts from the previous content in the vector