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

Method adjust_indices

cpp/dolfinx/refinement/utils.cpp:102–151  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

100}
101//-----------------------------------------------------------------------------
102std::vector<std::int64_t>
103refinement::adjust_indices(const common::IndexMap& map, std::int32_t n)
104{
105 // NOTE: Is this effectively concatenating index maps?
106
107 // Get offset for 'n' for this process
108 const std::int64_t num_local = n;
109 std::int64_t global_offset = 0;
110 MPI_Exscan(&num_local, &global_offset, 1, MPI_INT64_T, MPI_SUM, map.comm());
111
112 std::span owners = map.owners();
113 std::span src = map.src();
114 std::span dest = map.dest();
115
116 MPI_Comm comm;
117 MPI_Dist_graph_create_adjacent(map.comm(), src.size(), src.data(),
118 MPI_UNWEIGHTED, dest.size(), dest.data(),
119 MPI_UNWEIGHTED, MPI_INFO_NULL, false, &comm);
120
121 // Communicate offset to neighbors
122 std::vector<std::int64_t> offsets(src.size(), 0);
123 offsets.reserve(1);
124 MPI_Neighbor_allgather(&global_offset, 1, MPI_INT64_T, offsets.data(), 1,
125 MPI_INT64_T, comm);
126
127 MPI_Comm_free(&comm);
128
129 int local_size = map.size_local();
130 std::vector<std::int64_t> global_indices = map.global_indices();
131
132 // Add new offset to owned indices
133 std::transform(global_indices.begin(),
134 std::next(global_indices.begin(), local_size),
135 global_indices.begin(),
136 [global_offset](auto x) { return x + global_offset; });
137
138 // Add offsets to ghost indices
139 std::transform(std::next(global_indices.begin(), local_size),
140 global_indices.end(), owners.begin(),
141 std::next(global_indices.begin(), local_size),
142 [&src, &offsets](auto idx, auto r)
143 {
144 auto it = std::ranges::lower_bound(src, r);
145 assert(it != src.end() and *it == r);
146 int rank = std::distance(src.begin(), it);
147 return idx + offsets[rank];
148 });
149
150 return global_indices;
151}
152//-----------------------------------------------------------------------------
153std::array<std::vector<std::int32_t>, 2> refinement::transfer_facet_meshtag(
154 const mesh::MeshTags<std::int32_t>& tags0, const mesh::Topology& topology1,

Callers

nothing calls this directly

Calls 9

transformFunction · 0.85
ownersMethod · 0.80
srcMethod · 0.80
destMethod · 0.80
dataMethod · 0.80
size_localMethod · 0.80
global_indicesMethod · 0.80
commMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected