MCPcopy Create free account
hub / github.com/FEniCS/dolfinx / create_sub_index_map

Method create_sub_index_map

cpp/dolfinx/common/IndexMap.cpp:815–853  ·  view source on GitHub ↗

-----------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

813}
814//-----------------------------------------------------------------------------
815std::pair<IndexMap, std::vector<std::int32_t>>
816common::create_sub_index_map(const IndexMap& imap,
817 std::span<const std::int32_t> indices,
818 IndexMapOrder order, bool allow_owner_change)
819{
820 // Compute the owned, ghost, and ghost owners of submap indices.
821 // NOTE: All indices are local and numbered w.r.t. the original (imap)
822 // index map
823 auto [submap_owned, submap_ghost, submap_ghost_owners, submap_src,
824 submap_dest]
825 = compute_submap_indices(imap, indices, order, allow_owner_change);
826
827 // Compute submap offset for this rank
828 std::int64_t submap_local_size = submap_owned.size();
829 std::int64_t submap_offset = 0;
830 int ierr = MPI_Exscan(&submap_local_size, &submap_offset, 1, MPI_INT64_T,
831 MPI_SUM, imap.comm());
832 dolfinx::MPI::check_error(imap.comm(), ierr);
833
834 // Compute the global indices (w.r.t. the submap) of the submap ghosts
835 std::vector<std::int64_t> submap_ghost_global(submap_ghost.size());
836 imap.local_to_global(submap_ghost, submap_ghost_global);
837 std::vector<std::int64_t> submap_ghost_gidxs = compute_submap_ghost_indices(
838 submap_src, submap_dest, submap_owned, submap_ghost_global,
839 submap_ghost_owners, submap_offset, imap);
840
841 // Create a map from (local) indices in the submap to the corresponding
842 // (local) index in the original map
843 std::vector<std::int32_t> sub_imap_to_imap;
844 sub_imap_to_imap.reserve(submap_owned.size() + submap_ghost.size());
845 sub_imap_to_imap.insert(sub_imap_to_imap.end(), submap_owned.begin(),
846 submap_owned.end());
847 sub_imap_to_imap.insert(sub_imap_to_imap.end(), submap_ghost.begin(),
848 submap_ghost.end());
849
850 return {IndexMap(imap.comm(), submap_local_size, {submap_src, submap_dest},
851 submap_ghost_gidxs, submap_ghost_owners),
852 std::move(sub_imap_to_imap)};
853}
854//-----------------------------------------------------------------------------
855//-----------------------------------------------------------------------------
856IndexMap::IndexMap(MPI_Comm comm, std::int32_t local_size) : _comm(comm, true)

Calls 8

compute_submap_indicesFunction · 0.85
insertMethod · 0.80
IndexMapClass · 0.70
check_errorFunction · 0.50
sizeMethod · 0.45
commMethod · 0.45
local_to_globalMethod · 0.45