From 44bfc6e8667a9506dd6dca16c648cb868a6a6297 Mon Sep 17 00:00:00 2001 From: "Garth N. Wells" Date: Wed, 13 Nov 2019 16:01:01 +0000 Subject: [PATCH 01/12] Require C++17 in CMake file. --- cpp/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 880907ec9ca..d10169b7f28 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -26,8 +26,8 @@ if (POLICY CMP0075) endif() #------------------------------------------------------------------------------ -# Use C++14 -set(CMAKE_CXX_STANDARD 14) +# Use C++17 +set(CMAKE_CXX_STANDARD 17) # Require C++14 set(CMAKE_CXX_STANDARD_REQUIRED ON) From 67aca5a9f15fa22b3198dfde40b5d8406eeb646b Mon Sep 17 00:00:00 2001 From: "Garth N. Wells" Date: Wed, 13 Nov 2019 16:31:30 +0000 Subject: [PATCH 02/12] Compress some code. --- cpp/dolfin/fem/DofMapBuilder.cpp | 11 +++-------- cpp/dolfin/function/Function.cpp | 4 +--- cpp/dolfin/graph/GraphBuilder.cpp | 10 ++-------- cpp/dolfin/io/HDF5File.cpp | 9 +-------- cpp/dolfin/io/HDF5Utility.cpp | 4 +--- 5 files changed, 8 insertions(+), 30 deletions(-) diff --git a/cpp/dolfin/fem/DofMapBuilder.cpp b/cpp/dolfin/fem/DofMapBuilder.cpp index 1930165df28..d3bd610c4a5 100644 --- a/cpp/dolfin/fem/DofMapBuilder.cpp +++ b/cpp/dolfin/fem/DofMapBuilder.cpp @@ -761,14 +761,9 @@ DofMapBuilder::build(const mesh::Mesh& mesh, // Compute node ownership: // (a) Number of owned nodes; // (b) owned and shared nodes (and owned and un-owned): - // -1: unowned, 0: owned and shared, 1: owned and not shared; - // (c) map from shared node to sharing processes; and - std::int32_t num_owned_nodes; - std::vector node_ownership0; - std::unordered_map> - shared_node_to_processes0; - std::set neighbouring_procs; - std::tie(num_owned_nodes, node_ownership0, shared_node_to_processes0) + // -1: unowned, 0: owned and shared, 1: owned and not shared; and + // (c) map from shared node to sharing processes. + auto [num_owned_nodes, node_ownership0, shared_node_to_processes0] = compute_ownership(node_graph0, shared_nodes, mesh, global_dimension); // Build re-ordering map for data locality. Owned dofs are re-ordred diff --git a/cpp/dolfin/function/Function.cpp b/cpp/dolfin/function/Function.cpp index e987f03646d..519f3450649 100644 --- a/cpp/dolfin/function/Function.cpp +++ b/cpp/dolfin/function/Function.cpp @@ -100,9 +100,7 @@ Function Function::sub(int i) const Function Function::collapse() const { // Create new collapsed FunctionSpace - std::shared_ptr function_space_new; - std::vector collapsed_map; - std::tie(function_space_new, collapsed_map) = _function_space->collapse(); + auto [function_space_new, collapsed_map] = _function_space->collapse(); // Create new vector assert(function_space_new); diff --git a/cpp/dolfin/graph/GraphBuilder.cpp b/cpp/dolfin/graph/GraphBuilder.cpp index 33e6b261244..17d1b2fb110 100644 --- a/cpp/dolfin/graph/GraphBuilder.cpp +++ b/cpp/dolfin/graph/GraphBuilder.cpp @@ -429,19 +429,13 @@ graph::GraphBuilder::compute_dual_graph( { LOG(INFO) << "Build mesh dual graph"; - std::vector> local_graph; - std::int32_t num_ghost_nodes; - // Compute local part of dual graph - graph::GraphBuilder::FacetCellMap facet_cell_map; - std::int32_t num_local_edges; - std::tie(local_graph, facet_cell_map, num_local_edges) + auto [local_graph, facet_cell_map, num_local_edges] = graph::GraphBuilder::compute_local_dual_graph(mpi_comm, cell_vertices, cell_type); // Compute nonlocal part - std::int32_t num_nonlocal_edges; - std::tie(num_ghost_nodes, num_nonlocal_edges) = compute_nonlocal_dual_graph( + auto [num_ghost_nodes, num_nonlocal_edges] = compute_nonlocal_dual_graph( mpi_comm, cell_vertices, cell_type, facet_cell_map, local_graph); // Shrink to fit diff --git a/cpp/dolfin/io/HDF5File.cpp b/cpp/dolfin/io/HDF5File.cpp index f03630d9ba7..f203a522e52 100644 --- a/cpp/dolfin/io/HDF5File.cpp +++ b/cpp/dolfin/io/HDF5File.cpp @@ -1326,15 +1326,8 @@ mesh::Mesh HDF5File::read_mesh(const std::string data_path, bool use_partition_from_file, const mesh::GhostMode ghost_mode) const { - mesh::CellType cell_type; - Eigen::Array points; - Eigen::Array - cells; - std::vector global_cell_indices; - std::vector cell_distribution; - // Read local mesh data - std::tie(cell_type, points, cells, global_cell_indices, cell_distribution) + auto [cell_type, points, cells, global_cell_indices, cell_distribution] = read_mesh_data(data_path); if (use_partition_from_file) diff --git a/cpp/dolfin/io/HDF5Utility.cpp b/cpp/dolfin/io/HDF5Utility.cpp index d8d35265ef1..305d9e10779 100644 --- a/cpp/dolfin/io/HDF5Utility.cpp +++ b/cpp/dolfin/io/HDF5Utility.cpp @@ -289,9 +289,7 @@ void HDF5Utility::set_local_vector_values( // Calculate one (global cell, local_dof_index) to associate with // each item in the vector on this process - std::vector global_cells; - std::vector remote_local_dofi; - std::tie(global_cells, remote_local_dofi) = HDF5Utility::map_gdof_to_cell( + auto [global_cells, remote_local_dofi] = HDF5Utility::map_gdof_to_cell( mpi_comm, cells, cell_dofs, x_cell_dofs, input_vector_range); // At this point, each process has a set of data, and for each From 1107440fdaeb4b0b4f0ea5f1a3c2eb2034efb27d Mon Sep 17 00:00:00 2001 From: "Garth N. Wells" Date: Wed, 13 Nov 2019 16:35:08 +0000 Subject: [PATCH 03/12] More cleaning up. --- cpp/dolfin/io/XDMFFile.cpp | 9 +-------- cpp/dolfin/mesh/Mesh.cpp | 9 ++------- cpp/dolfin/mesh/Partitioning.cpp | 8 ++------ cpp/dolfin/refinement/PlazaRefinementND.cpp | 8 ++------ 4 files changed, 7 insertions(+), 27 deletions(-) diff --git a/cpp/dolfin/io/XDMFFile.cpp b/cpp/dolfin/io/XDMFFile.cpp index 5a7b0c8845c..0402fee1215 100644 --- a/cpp/dolfin/io/XDMFFile.cpp +++ b/cpp/dolfin/io/XDMFFile.cpp @@ -1458,15 +1458,8 @@ XDMFFile::read_mesh_data(MPI_Comm comm) const //---------------------------------------------------------------------------- mesh::Mesh XDMFFile::read_mesh(const mesh::GhostMode ghost_mode) const { - - mesh::CellType cell_type; - Eigen::Array points; - Eigen::Array - cells; - std::vector global_cell_indices; - // Read local mesh data - std::tie(cell_type, points, cells, global_cell_indices) + auto [cell_type, points, cells, global_cell_indices] = read_mesh_data(_mpi_comm.comm()); // Permute cells to DOLFIN ordering diff --git a/cpp/dolfin/mesh/Mesh.cpp b/cpp/dolfin/mesh/Mesh.cpp index d7ed42b8e39..e8b54d61d45 100644 --- a/cpp/dolfin/mesh/Mesh.cpp +++ b/cpp/dolfin/mesh/Mesh.cpp @@ -170,16 +170,11 @@ compute_point_distribution( // Distribute points to processes that need them, and calculate // shared points. Points are returned in same order as in global_index_set. // Sharing information is (global_index -> [remote sharing processes]). - std::map> shared_points_global; - Eigen::Array - recv_points; - std::tie(shared_points_global, recv_points) + auto [shared_points_global, recv_points] = Partitioning::distribute_points(mpi_comm, points, global_index_set); // Get local to global mapping for points - std::vector local_to_global; - std::array num_vertices_local; - std::tie(local_to_global, num_vertices_local) + auto [local_to_global, num_vertices_local] = compute_local_to_global_point_map(mpi_comm, num_vertices_per_cell, shared_points_global, cell_nodes, type); diff --git a/cpp/dolfin/mesh/Partitioning.cpp b/cpp/dolfin/mesh/Partitioning.cpp index 9de26ae0fc1..9d61cd2e1a8 100644 --- a/cpp/dolfin/mesh/Partitioning.cpp +++ b/cpp/dolfin/mesh/Partitioning.cpp @@ -552,9 +552,7 @@ PartitionData Partitioning::partition_cells( if (mpi_comm != MPI_COMM_NULL) { // Compute dual graph (for this partition) - std::vector> local_graph; - std::tuple graph_info; - std::tie(local_graph, graph_info) = graph::GraphBuilder::compute_dual_graph( + auto [local_graph, graph_info] = graph::GraphBuilder::compute_dual_graph( mpi_comm, cell_vertices, cell_type); const std::size_t global_graph_size @@ -809,9 +807,7 @@ std::map> Partitioning::compute_halo_cells( cell_vertices) { // Compute dual graph (for this partition) - std::vector> local_graph; - std::tuple graph_info; - std::tie(local_graph, graph_info) = graph::GraphBuilder::compute_dual_graph( + auto [local_graph, graph_info] = graph::GraphBuilder::compute_dual_graph( mpi_comm, cell_vertices, cell_type); graph::CSRGraph csr_graph(mpi_comm, local_graph); diff --git a/cpp/dolfin/refinement/PlazaRefinementND.cpp b/cpp/dolfin/refinement/PlazaRefinementND.cpp index bbd14a2519f..73072150037 100644 --- a/cpp/dolfin/refinement/PlazaRefinementND.cpp +++ b/cpp/dolfin/refinement/PlazaRefinementND.cpp @@ -379,9 +379,7 @@ mesh::Mesh PlazaRefinementND::refine(const mesh::Mesh& mesh, bool redistribute) } common::Timer t0("PLAZA: refine"); - std::vector long_edge; - std::vector edge_ratio_ok; - std::tie(long_edge, edge_ratio_ok) = face_long_edge(mesh); + auto [long_edge, edge_ratio_ok] = face_long_edge(mesh); ParallelRefinement p_ref(mesh); p_ref.mark_all(); @@ -402,9 +400,7 @@ PlazaRefinementND::refine(const mesh::Mesh& mesh, } common::Timer t0("PLAZA: refine"); - std::vector long_edge; - std::vector edge_ratio_ok; - std::tie(long_edge, edge_ratio_ok) = face_long_edge(mesh); + auto [long_edge, edge_ratio_ok] = face_long_edge(mesh); ParallelRefinement p_ref(mesh); p_ref.mark(refinement_marker); From 38d08fa95780a7bea558f5af21d9bc405e8445e1 Mon Sep 17 00:00:00 2001 From: "Garth N. Wells" Date: Wed, 13 Nov 2019 20:41:35 +0000 Subject: [PATCH 04/12] More C++17. --- cpp/dolfin/mesh/DistributedMeshTools.cpp | 8 +------- cpp/dolfin/mesh/Mesh.cpp | 12 ++---------- cpp/dolfin/mesh/Partitioning.cpp | 3 ++- cpp/test/unit/mesh/DistributedMesh.cpp | 8 +------- 4 files changed, 6 insertions(+), 25 deletions(-) diff --git a/cpp/dolfin/mesh/DistributedMeshTools.cpp b/cpp/dolfin/mesh/DistributedMeshTools.cpp index f5f380fc0fb..466d1b272f7 100644 --- a/cpp/dolfin/mesh/DistributedMeshTools.cpp +++ b/cpp/dolfin/mesh/DistributedMeshTools.cpp @@ -402,14 +402,8 @@ void DistributedMeshTools::number_entities(const Mesh& mesh, int d) return; } - // Get shared entities map - std::map>& shared_entities - = _mesh.topology().shared_entities(d); - // Number entities - std::vector global_entity_indices; - std::size_t num_global_entities; - std::tie(global_entity_indices, shared_entities, num_global_entities) + auto [global_entity_indices, shared_entities, num_global_entities] = compute_entity_numbering(mesh, d); // Set global entity numbers in mesh diff --git a/cpp/dolfin/mesh/Mesh.cpp b/cpp/dolfin/mesh/Mesh.cpp index e8b54d61d45..6727f854de4 100644 --- a/cpp/dolfin/mesh/Mesh.cpp +++ b/cpp/dolfin/mesh/Mesh.cpp @@ -254,16 +254,8 @@ Mesh::Mesh( // Compute node local-to-global map from global indices, and compute // cell topology using new local indices - std::array num_vertices_local; - std::vector node_indices_global; - Eigen::Array - coordinate_nodes; - std::map> nodes_shared; - Eigen::Array - points_received; - - std::tie(node_indices_global, nodes_shared, coordinate_nodes, points_received, - num_vertices_local) + auto [node_indices_global, nodes_shared, coordinate_nodes, points_received, + num_vertices_local] = compute_point_distribution(comm, num_vertices_per_cell, cells, points, type); diff --git a/cpp/dolfin/mesh/Partitioning.cpp b/cpp/dolfin/mesh/Partitioning.cpp index 9d61cd2e1a8..637f8bc2934 100644 --- a/cpp/dolfin/mesh/Partitioning.cpp +++ b/cpp/dolfin/mesh/Partitioning.cpp @@ -807,7 +807,8 @@ std::map> Partitioning::compute_halo_cells( cell_vertices) { // Compute dual graph (for this partition) - auto [local_graph, graph_info] = graph::GraphBuilder::compute_dual_graph( + std::vector> local_graph; + std::tie(local_graph, std::ignore) = graph::GraphBuilder::compute_dual_graph( mpi_comm, cell_vertices, cell_type); graph::CSRGraph csr_graph(mpi_comm, local_graph); diff --git a/cpp/test/unit/mesh/DistributedMesh.cpp b/cpp/test/unit/mesh/DistributedMesh.cpp index 87ee121c48d..4be132fc9f8 100644 --- a/cpp/test/unit/mesh/DistributedMesh.cpp +++ b/cpp/test/unit/mesh/DistributedMesh.cpp @@ -39,15 +39,9 @@ void test_distributed_mesh() io::XDMFFile file(MPI_COMM_WORLD, "mesh.xdmf"); file.write(*mesh); - mesh::CellType cell_type; - Eigen::Array points; - Eigen::Array - cells; - std::vector global_cell_indices; - // Read in mesh in mesh data from XDMF file io::XDMFFile infile(MPI_COMM_WORLD, "mesh.xdmf"); - std::tie(cell_type, points, cells, global_cell_indices) + auto [cell_type, points, cells, global_cell_indices] = infile.read_mesh_data(subset_comm); // Partition mesh into nparts using local mesh data and subset of From f2538f883f5c3929fd987fa6a8402dedc833ac09 Mon Sep 17 00:00:00 2001 From: "Garth N. Wells" Date: Wed, 13 Nov 2019 21:03:51 +0000 Subject: [PATCH 05/12] Fix tuple return. --- cpp/dolfin/mesh/DistributedMeshTools.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cpp/dolfin/mesh/DistributedMeshTools.cpp b/cpp/dolfin/mesh/DistributedMeshTools.cpp index 466d1b272f7..f5f380fc0fb 100644 --- a/cpp/dolfin/mesh/DistributedMeshTools.cpp +++ b/cpp/dolfin/mesh/DistributedMeshTools.cpp @@ -402,8 +402,14 @@ void DistributedMeshTools::number_entities(const Mesh& mesh, int d) return; } + // Get shared entities map + std::map>& shared_entities + = _mesh.topology().shared_entities(d); + // Number entities - auto [global_entity_indices, shared_entities, num_global_entities] + std::vector global_entity_indices; + std::size_t num_global_entities; + std::tie(global_entity_indices, shared_entities, num_global_entities) = compute_entity_numbering(mesh, d); // Set global entity numbers in mesh From 91457466c477a167d4489d7bcedd5c65486082eb Mon Sep 17 00:00:00 2001 From: "Garth N. Wells" Date: Wed, 13 Nov 2019 21:21:44 +0000 Subject: [PATCH 06/12] Undo some changes. --- cpp/test/unit/mesh/DistributedMesh.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cpp/test/unit/mesh/DistributedMesh.cpp b/cpp/test/unit/mesh/DistributedMesh.cpp index 4be132fc9f8..87ee121c48d 100644 --- a/cpp/test/unit/mesh/DistributedMesh.cpp +++ b/cpp/test/unit/mesh/DistributedMesh.cpp @@ -39,9 +39,15 @@ void test_distributed_mesh() io::XDMFFile file(MPI_COMM_WORLD, "mesh.xdmf"); file.write(*mesh); + mesh::CellType cell_type; + Eigen::Array points; + Eigen::Array + cells; + std::vector global_cell_indices; + // Read in mesh in mesh data from XDMF file io::XDMFFile infile(MPI_COMM_WORLD, "mesh.xdmf"); - auto [cell_type, points, cells, global_cell_indices] + std::tie(cell_type, points, cells, global_cell_indices) = infile.read_mesh_data(subset_comm); // Partition mesh into nparts using local mesh data and subset of From c3fc9fdb2f83d499fa237f9904cd98b839a9cdb8 Mon Sep 17 00:00:00 2001 From: "Garth N. Wells" Date: Thu, 14 Nov 2019 21:05:31 +0000 Subject: [PATCH 07/12] More std::tie updates. --- cpp/dolfin/mesh/DistributedMeshTools.cpp | 8 +------- cpp/test/unit/mesh/DistributedMesh.cpp | 8 +------- 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/cpp/dolfin/mesh/DistributedMeshTools.cpp b/cpp/dolfin/mesh/DistributedMeshTools.cpp index f5f380fc0fb..466d1b272f7 100644 --- a/cpp/dolfin/mesh/DistributedMeshTools.cpp +++ b/cpp/dolfin/mesh/DistributedMeshTools.cpp @@ -402,14 +402,8 @@ void DistributedMeshTools::number_entities(const Mesh& mesh, int d) return; } - // Get shared entities map - std::map>& shared_entities - = _mesh.topology().shared_entities(d); - // Number entities - std::vector global_entity_indices; - std::size_t num_global_entities; - std::tie(global_entity_indices, shared_entities, num_global_entities) + auto [global_entity_indices, shared_entities, num_global_entities] = compute_entity_numbering(mesh, d); // Set global entity numbers in mesh diff --git a/cpp/test/unit/mesh/DistributedMesh.cpp b/cpp/test/unit/mesh/DistributedMesh.cpp index 87ee121c48d..4be132fc9f8 100644 --- a/cpp/test/unit/mesh/DistributedMesh.cpp +++ b/cpp/test/unit/mesh/DistributedMesh.cpp @@ -39,15 +39,9 @@ void test_distributed_mesh() io::XDMFFile file(MPI_COMM_WORLD, "mesh.xdmf"); file.write(*mesh); - mesh::CellType cell_type; - Eigen::Array points; - Eigen::Array - cells; - std::vector global_cell_indices; - // Read in mesh in mesh data from XDMF file io::XDMFFile infile(MPI_COMM_WORLD, "mesh.xdmf"); - std::tie(cell_type, points, cells, global_cell_indices) + auto [cell_type, points, cells, global_cell_indices] = infile.read_mesh_data(subset_comm); // Partition mesh into nparts using local mesh data and subset of From 0fcf9fc44d7b948b972486e46bf803001fe8d265 Mon Sep 17 00:00:00 2001 From: "Garth N. Wells" Date: Thu, 14 Nov 2019 21:17:33 +0000 Subject: [PATCH 08/12] Fix for unused variable. --- cpp/dolfin/mesh/DistributedMeshTools.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cpp/dolfin/mesh/DistributedMeshTools.cpp b/cpp/dolfin/mesh/DistributedMeshTools.cpp index 466d1b272f7..4e0610b9d97 100644 --- a/cpp/dolfin/mesh/DistributedMeshTools.cpp +++ b/cpp/dolfin/mesh/DistributedMeshTools.cpp @@ -403,7 +403,9 @@ void DistributedMeshTools::number_entities(const Mesh& mesh, int d) } // Number entities - auto [global_entity_indices, shared_entities, num_global_entities] + std::vector global_entity_indices; + std::size_t num_global_entities; + std::tie(global_entity_indices, std::ignore, num_global_entities) = compute_entity_numbering(mesh, d); // Set global entity numbers in mesh From 8421bcf0155ffc937ec5dff0efe58d7dd2937ca3 Mon Sep 17 00:00:00 2001 From: "Garth N. Wells" Date: Thu, 14 Nov 2019 21:46:01 +0000 Subject: [PATCH 09/12] Fix cpp version for unit tests. --- cpp/CMakeLists.txt | 2 +- cpp/test/unit/CMakeLists.txt | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index d10169b7f28..e2608cf0990 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -29,7 +29,7 @@ endif() # Use C++17 set(CMAKE_CXX_STANDARD 17) -# Require C++14 +# Require C++17 set(CMAKE_CXX_STANDARD_REQUIRED ON) # Do not enable compler-specific extensions diff --git a/cpp/test/unit/CMakeLists.txt b/cpp/test/unit/CMakeLists.txt index 3fbb9f92d14..fd9289de8f6 100644 --- a/cpp/test/unit/CMakeLists.txt +++ b/cpp/test/unit/CMakeLists.txt @@ -4,6 +4,9 @@ project(dolfin-tests) find_package(DOLFIN REQUIRED) include(${DOLFIN_USE_FILE}) +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + # Prepare "Catch" library for other executables set(CATCH_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/catch) From 06a548fde28f526a6684314bcf49fc2dbabde61f Mon Sep 17 00:00:00 2001 From: "Garth N. Wells" Date: Fri, 15 Nov 2019 06:48:53 +0000 Subject: [PATCH 10/12] Revert a file. --- cpp/dolfin/mesh/DistributedMeshTools.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cpp/dolfin/mesh/DistributedMeshTools.cpp b/cpp/dolfin/mesh/DistributedMeshTools.cpp index 4e0610b9d97..f5f380fc0fb 100644 --- a/cpp/dolfin/mesh/DistributedMeshTools.cpp +++ b/cpp/dolfin/mesh/DistributedMeshTools.cpp @@ -402,10 +402,14 @@ void DistributedMeshTools::number_entities(const Mesh& mesh, int d) return; } + // Get shared entities map + std::map>& shared_entities + = _mesh.topology().shared_entities(d); + // Number entities std::vector global_entity_indices; std::size_t num_global_entities; - std::tie(global_entity_indices, std::ignore, num_global_entities) + std::tie(global_entity_indices, shared_entities, num_global_entities) = compute_entity_numbering(mesh, d); // Set global entity numbers in mesh From ea22854b13ebce98aeed6c7f5f3ae04c395480f7 Mon Sep 17 00:00:00 2001 From: "Garth N. Wells" Date: Fri, 15 Nov 2019 08:30:03 +0000 Subject: [PATCH 11/12] Fix some confusing mesh topology code. --- cpp/dolfin/mesh/DistributedMeshTools.cpp | 13 +++++-------- cpp/dolfin/mesh/Mesh.cpp | 2 +- cpp/dolfin/mesh/Partitioning.cpp | 2 +- cpp/dolfin/mesh/Topology.cpp | 6 +++--- cpp/dolfin/mesh/Topology.h | 7 ++++--- python/src/mesh.cpp | 3 +-- 6 files changed, 15 insertions(+), 18 deletions(-) diff --git a/cpp/dolfin/mesh/DistributedMeshTools.cpp b/cpp/dolfin/mesh/DistributedMeshTools.cpp index f5f380fc0fb..59fea567ca6 100644 --- a/cpp/dolfin/mesh/DistributedMeshTools.cpp +++ b/cpp/dolfin/mesh/DistributedMeshTools.cpp @@ -402,16 +402,13 @@ void DistributedMeshTools::number_entities(const Mesh& mesh, int d) return; } - // Get shared entities map - std::map>& shared_entities - = _mesh.topology().shared_entities(d); - // Number entities - std::vector global_entity_indices; - std::size_t num_global_entities; - std::tie(global_entity_indices, shared_entities, num_global_entities) + auto [global_entity_indices, shared_entities, num_global_entities] = compute_entity_numbering(mesh, d); + // Set shared entities + _mesh.topology().set_shared_entities(d, shared_entities); + // Set global entity numbers in mesh _mesh.topology().set_num_entities_global(d, num_global_entities); _mesh.topology().set_global_indices(d, global_entity_indices); @@ -439,7 +436,7 @@ void DistributedMeshTools::init_facet_cell_connections(Mesh& mesh) Eigen::Array num_global_neighbors( mesh.num_entities(D - 1)); - std::map>& shared_facets + const std::map>& shared_facets = mesh.topology().shared_entities(D - 1); // Check if no ghost cells diff --git a/cpp/dolfin/mesh/Mesh.cpp b/cpp/dolfin/mesh/Mesh.cpp index 6727f854de4..ed8b8144d4e 100644 --- a/cpp/dolfin/mesh/Mesh.cpp +++ b/cpp/dolfin/mesh/Mesh.cpp @@ -296,7 +296,7 @@ Mesh::Mesh( _topology = std::make_unique(tdim, num_vertices_local[2], num_vertices_global); _topology->set_global_indices(0, vertex_indices_global); - _topology->shared_entities(0) = shared_vertices; + _topology->set_shared_entities(0, shared_vertices); _topology->init_ghost(0, num_vertices_local[1]); // Set vertex ownership diff --git a/cpp/dolfin/mesh/Partitioning.cpp b/cpp/dolfin/mesh/Partitioning.cpp index 637f8bc2934..60d23dd15aa 100644 --- a/cpp/dolfin/mesh/Partitioning.cpp +++ b/cpp/dolfin/mesh/Partitioning.cpp @@ -689,7 +689,7 @@ mesh::Mesh Partitioning::build_from_partition( new_cell_partition.end()); // Assign map of shared cells (only needed for ghost cells) - mesh.topology().shared_entities(tdim) = shared_cells; + mesh.topology().set_shared_entities(tdim, shared_cells); DistributedMeshTools::init_facet_cell_connections(mesh); return mesh; diff --git a/cpp/dolfin/mesh/Topology.cpp b/cpp/dolfin/mesh/Topology.cpp index 8aa3edd6ef0..edbc6a5fed3 100644 --- a/cpp/dolfin/mesh/Topology.cpp +++ b/cpp/dolfin/mesh/Topology.cpp @@ -103,11 +103,11 @@ const std::vector& Topology::global_indices(std::size_t d) const return _global_indices[d]; } //----------------------------------------------------------------------------- -std::map>& -Topology::shared_entities(int dim) +void Topology::set_shared_entities( + int dim, const std::map>& entities) { assert(dim <= this->dim()); - return _shared_entities[dim]; + _shared_entities[dim] = entities; } //----------------------------------------------------------------------------- const std::map>& diff --git a/cpp/dolfin/mesh/Topology.h b/cpp/dolfin/mesh/Topology.h index 2954540df02..6e4156c8208 100644 --- a/cpp/dolfin/mesh/Topology.h +++ b/cpp/dolfin/mesh/Topology.h @@ -80,9 +80,10 @@ class Topology /// dimension d const std::vector& global_indices(std::size_t d) const; - /// Return map from shared entities (local index) to processes - /// that share the entity - std::map>& shared_entities(int dim); + /// Set the map from shared entities (local index) to processes that + /// share the entity + void set_shared_entities( + int dim, const std::map>& entities); /// Return map from shared entities (local index) to process that /// share the entity (const version) diff --git a/python/src/mesh.cpp b/python/src/mesh.cpp index dd0b81fac63..82d2fa4e4c5 100644 --- a/python/src/mesh.cpp +++ b/python/src/mesh.cpp @@ -149,8 +149,7 @@ void mesh(py::module& m) py::none()); }, py::return_value_policy::reference_internal) - .def("shared_entities", - py::overload_cast(&dolfin::mesh::Topology::shared_entities)) + .def("shared_entities", &dolfin::mesh::Topology::shared_entities) .def("str", &dolfin::mesh::Topology::str); // dolfin::mesh::Mesh From 691ce9a0c9fe40cd8da481c4faec599f56802744 Mon Sep 17 00:00:00 2001 From: "Garth N. Wells" Date: Fri, 15 Nov 2019 09:39:36 +0000 Subject: [PATCH 12/12] Simplify some mesh topology. --- cpp/dolfin/mesh/Mesh.cpp | 2 +- cpp/dolfin/mesh/Partitioning.cpp | 8 +++----- cpp/dolfin/mesh/Topology.cpp | 5 +++-- cpp/dolfin/mesh/Topology.h | 6 +++--- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/cpp/dolfin/mesh/Mesh.cpp b/cpp/dolfin/mesh/Mesh.cpp index ed8b8144d4e..5935ed65f83 100644 --- a/cpp/dolfin/mesh/Mesh.cpp +++ b/cpp/dolfin/mesh/Mesh.cpp @@ -303,7 +303,7 @@ Mesh::Mesh( std::vector vertex_owner; for (int i = num_vertices_local[1]; i < num_vertices_local[2]; ++i) vertex_owner.push_back(*(shared_vertices[i].begin())); - _topology->entity_owner(0) = vertex_owner; + _topology->set_entity_owner(0, vertex_owner); // Initialise cell topology _topology->set_num_entities_global(tdim, num_cells_global); diff --git a/cpp/dolfin/mesh/Partitioning.cpp b/cpp/dolfin/mesh/Partitioning.cpp index 60d23dd15aa..49e7ee74351 100644 --- a/cpp/dolfin/mesh/Partitioning.cpp +++ b/cpp/dolfin/mesh/Partitioning.cpp @@ -682,13 +682,11 @@ mesh::Mesh Partitioning::build_from_partition( return mesh; // Copy cell ownership (only needed for ghost cells) - std::vector& cell_owner = mesh.topology().entity_owner(tdim); - cell_owner.clear(); - cell_owner.insert(cell_owner.begin(), - new_cell_partition.begin() + num_regular_cells, - new_cell_partition.end()); + std::vector cell_owner( + new_cell_partition.begin() + num_regular_cells, new_cell_partition.end()); // Assign map of shared cells (only needed for ghost cells) + mesh.topology().set_entity_owner(tdim, cell_owner); mesh.topology().set_shared_entities(tdim, shared_cells); DistributedMeshTools::init_facet_cell_connections(mesh); diff --git a/cpp/dolfin/mesh/Topology.cpp b/cpp/dolfin/mesh/Topology.cpp index edbc6a5fed3..14424884cef 100644 --- a/cpp/dolfin/mesh/Topology.cpp +++ b/cpp/dolfin/mesh/Topology.cpp @@ -117,9 +117,10 @@ Topology::shared_entities(int dim) const return _shared_entities[dim]; } //----------------------------------------------------------------------------- -std::vector& Topology::entity_owner(int dim) +void Topology::set_entity_owner(int dim, const std::vector& owners) { - return _entity_owner[dim]; + assert(dim <= this->dim()); + _entity_owner[dim] = owners; } //----------------------------------------------------------------------------- const std::vector& Topology::entity_owner(int dim) const diff --git a/cpp/dolfin/mesh/Topology.h b/cpp/dolfin/mesh/Topology.h index 6e4156c8208..a3c0ffaa33c 100644 --- a/cpp/dolfin/mesh/Topology.h +++ b/cpp/dolfin/mesh/Topology.h @@ -90,10 +90,10 @@ class Topology const std::map>& shared_entities(int dim) const; - /// Return mapping from local ghost cell index to owning process. - /// Since ghost cells are at the end of the range, this is just a vector + /// Set map from local ghost cell index to owning process. Since + /// ghost cells are at the end of the range, this is just a vector /// over those cells - std::vector& entity_owner(int dim); + void set_entity_owner(int dim, const std::vector& owners); /// Return mapping from local ghost cell index to owning process /// (const version). Since ghost cells are at the end of the range,