diff --git a/cpp/dolfinx/fem/DirichletBC.cpp b/cpp/dolfinx/fem/DirichletBC.cpp index 0d53abd9c5a..9c862323bb0 100644 --- a/cpp/dolfinx/fem/DirichletBC.cpp +++ b/cpp/dolfinx/fem/DirichletBC.cpp @@ -266,8 +266,7 @@ std::vector fem::locate_dofs_topological( std::span src = map->src(); std::span dest = map->dest(); std::vector ranks; - std::set_union(src.begin(), src.end(), dest.begin(), dest.end(), - std::back_inserter(ranks)); + std::ranges::set_union(src, dest, std::back_inserter(ranks)); ranks.erase(std::unique(ranks.begin(), ranks.end()), ranks.end()); MPI_Dist_graph_create_adjacent( map->comm(), ranks.size(), ranks.data(), MPI_UNWEIGHTED, ranks.size(), @@ -385,8 +384,7 @@ std::array, 2> fem::locate_dofs_topological( std::span src = map0->src(); std::span dest = map0->dest(); std::vector ranks; - std::set_union(src.begin(), src.end(), dest.begin(), dest.end(), - std::back_inserter(ranks)); + std::ranges::set_union(src, dest, std::back_inserter(ranks)); ranks.erase(std::unique(ranks.begin(), ranks.end()), ranks.end()); MPI_Dist_graph_create_adjacent(map0->comm(), ranks.size(), ranks.data(), MPI_UNWEIGHTED, ranks.size(), ranks.data(), diff --git a/cpp/dolfinx/fem/utils.cpp b/cpp/dolfinx/fem/utils.cpp index 5579f3137e0..91faaa86768 100644 --- a/cpp/dolfinx/fem/utils.cpp +++ b/cpp/dolfinx/fem/utils.cpp @@ -173,8 +173,8 @@ std::vector fem::compute_integration_domains( // Create list of tagged boundary facets const std::vector bfacets = mesh::exterior_facet_indices(topology); std::vector facets; - std::set_intersection(entities.begin(), entities.end(), bfacets.begin(), - bfacets.end(), std::back_inserter(facets)); + std::ranges::set_intersection(entities, bfacets, + std::back_inserter(facets)); for (auto f : facets) { // Get the facet as a pair of (cell, local facet) diff --git a/cpp/dolfinx/mesh/Topology.cpp b/cpp/dolfinx/mesh/Topology.cpp index c2838a7bc69..f0455dd7dff 100644 --- a/cpp/dolfinx/mesh/Topology.cpp +++ b/cpp/dolfinx/mesh/Topology.cpp @@ -324,24 +324,21 @@ std::array, 2> vertex_ownership_groups( // Build difference 1: Vertices attached only to owned cells, and // therefore owned by this rank std::vector owned_vertices; - std::set_difference(local_vertex_set.begin(), local_vertex_set.end(), - boundary_vertices.begin(), boundary_vertices.end(), - std::back_inserter(owned_vertices)); + std::ranges::set_difference(local_vertex_set, boundary_vertices, + std::back_inserter(owned_vertices)); // Build difference 2: Vertices attached only to ghost cells, and // therefore not owned by this rank std::vector unowned_vertices; - std::set_difference(ghost_vertex_set.begin(), ghost_vertex_set.end(), - local_vertex_set.begin(), local_vertex_set.end(), - std::back_inserter(unowned_vertices)); + std::ranges::set_difference(ghost_vertex_set, local_vertex_set, + std::back_inserter(unowned_vertices)); // TODO Check this in debug mode only? // Sanity check // No vertices in unowned should also be in boundary... std::vector unowned_vertices_in_error; - std::set_intersection(unowned_vertices.begin(), unowned_vertices.end(), - boundary_vertices.begin(), boundary_vertices.end(), - std::back_inserter(unowned_vertices_in_error)); + std::ranges::set_intersection(unowned_vertices, boundary_vertices, + std::back_inserter(unowned_vertices_in_error)); if (!unowned_vertices_in_error.empty()) { diff --git a/cpp/dolfinx/mesh/utils.cpp b/cpp/dolfinx/mesh/utils.cpp index 63dca1667c7..40354ed3e04 100644 --- a/cpp/dolfinx/mesh/utils.cpp +++ b/cpp/dolfinx/mesh/utils.cpp @@ -75,12 +75,9 @@ std::vector mesh::exterior_facet_indices(const Topology& topology) } // Remove facets on internal inter-process boundary - const std::vector& interprocess_facets - = topology.interprocess_facets(); std::vector ext_facets; - std::set_difference(facets.begin(), facets.end(), interprocess_facets.begin(), - interprocess_facets.end(), - std::back_inserter(ext_facets)); + std::ranges::set_difference(facets, topology.interprocess_facets(), + std::back_inserter(ext_facets)); return ext_facets; } //------------------------------------------------------------------------------ diff --git a/cpp/dolfinx/refinement/plaza.h b/cpp/dolfinx/refinement/plaza.h index 6618a1a7f94..504e68b75e2 100644 --- a/cpp/dolfinx/refinement/plaza.h +++ b/cpp/dolfinx/refinement/plaza.h @@ -85,21 +85,21 @@ auto compute_parent_facets(std::span simplex_set) { for (int j = 0; j < tdim; ++j) cf[j] = simplex_set[cc * 3 + facet_table_2d[fci][j]]; + std::ranges::sort(cf); - auto it = std::set_intersection(facet_table_2d[fpi].begin(), - facet_table_2d[fpi].end(), cf.begin(), - cf.end(), set_output.begin()); - num_common_vertices = std::distance(set_output.begin(), it); + auto [last1, last2, it_last] = std::ranges::set_intersection( + facet_table_2d[fpi], cf, set_output.begin()); + num_common_vertices = std::distance(set_output.begin(), it_last); } else { for (int j = 0; j < tdim; ++j) cf[j] = simplex_set[cc * 4 + facet_table_3d[fci][j]]; + std::ranges::sort(cf); - auto it = std::set_intersection(facet_table_3d[fpi].begin(), - facet_table_3d[fpi].end(), cf.begin(), - cf.end(), set_output.begin()); - num_common_vertices = std::distance(set_output.begin(), it); + auto [last1, last2, it_last] = std::ranges::set_intersection( + facet_table_3d[fpi], cf, set_output.begin()); + num_common_vertices = std::distance(set_output.begin(), it_last); } if (num_common_vertices == tdim)