16#include <unordered_map>
17#include <unordered_set>
92 if (
adj.isIntraLevel())
95 bool fromReordered = reorderedKinds.count(
adj.from) > 0;
96 bool toReordered = reorderedKinds.count(
adj.to) > 0;
98 if (!fromReordered && !toReordered)
100 if (fromReordered && !toReordered)
102 if (!fromReordered && toReordered)
151 std::unordered_map<EntityKind, std::vector<index>>
pullSets;
155 std::string name = {})
157 adjs.push_back(
AdjEntry{kind, std::move(remap), std::move(relocate), std::move(name)});
192 std::unordered_map<EntityKind, PermutationTransfer>
transfers;
195 std::unordered_map<EntityKind, PermutationTransfer::LookupResult>
lookups;
239 template <
class TPair>
242 auto it =
lookups.find(targetKind);
244 "remapEntries: no lookup for target kind");
245 const auto &lookup = it->second;
246 for (
index i = 0;
i < pair.father->Size();
i++)
252 v = lookup.resolve(
v);
257 template <
class TPair>
262 "relocateRows: no transfer for source kind");
263 it->second.transferRows(pair, mpi);
#define DNDS_assert_info(expr, info)
Debug-only assertion with an extra std::string info message.
Layered DAG of mesh adjacency relations with composable DSL operations.
Utility for distributed or local row permutation/transfer of arrays.
AdjAction classifyAdj(AdjKind adj, const std::unordered_set< EntityKind > &reorderedKinds)
Classify an adjacency given the set of reordered entity kinds.
std::function< void(const PermutationTransfer::LookupResult &lookup)> AdjRemapFn
Callback invoked during REMAP phase for an adjacency array.
AdjAction
Action to take on an adjacency during reorder.
@ RELOCATE
Source reordered, target not: move rows.
@ REMAP
Target reordered, source not: update entries.
@ RELOCATE_REMAP
Both reordered: update entries then move rows.
@ SKIP
Neither source nor target reordered.
@ SELF
Intra-level (A==A): update entries then move rows.
std::function< void(const PermutationTransfer &transfer, const MPIInfo &mpi)> AdjRelocateFn
Callback invoked during RELOCATE phase for an adjacency or companion array.
DNDS_CONSTANT const index UnInitIndex
Sentinel "not initialised" index value (= INT64_MIN).
int32_t rowsize
Row-width / per-row element-count type (signed 32-bit).
int64_t index
Global row / DOF index type (signed 64-bit; handles multi-billion-cell meshes).
std::shared_ptr< T > ssp
Shortened alias for std::shared_ptr used pervasively in DNDSR.
One registered adjacency entry.
AdjRelocateFn relocateFn
Relocate rows (null if not needed).
AdjRemapFn remapFn
Remap entries (null if not needed).
One registered companion entry.
EntityKind kind
Entity kind this array is parallel to.
AdjRelocateFn fn
Callback to relocate the array.
Per-entity reorder specification: where each owned entity goes.
std::vector< MPI_int > targetRanks
Per father slot: target rank after reorder. Size == father size.
AdjKind follower2leader
Support adj: follower -> leader.
EntityKind follower
Entity kind to derive map for.
EntityKind leader
Explicit-map entity kind to follow.
void remapEntries(TPair &pair, EntityKind targetKind) const
Remap entries of an adjacency array whose target kind is targetKind.
void apply(ReorderRegistry ®istry, const MPIInfo &mpi) const
bool isLocalOnly
Whether all transfers are local-only (collective agreement).
std::unordered_map< EntityKind, PermutationTransfer > transfers
Per reordered entity kind: the computed transfer.
std::unordered_map< EntityKind, PermutationTransfer::LookupResult > lookups
Per reordered entity kind: the old->new global lookup.
static ReorderPlan build(const ReorderInput &input, const ReorderRegistry ®istry, const MPIInfo &mpi)
void relocateRows(TPair &pair, EntityKind sourceKind, const MPIInfo &mpi) const
Relocate rows of an array pair whose source kind is sourceKind.
std::unordered_set< EntityKind > reorderedKinds
Set of entity kinds being reordered.
void registerGlobalMapping(EntityKind kind, ssp< GlobalOffsetsMapping > gm)
Register a GlobalOffsetsMapping for an entity kind.
ssp< GlobalOffsetsMapping > getGlobalMapping(EntityKind kind) const
Get a registered global mapping (nullptr if not registered).
std::unordered_map< EntityKind, std::vector< index > > pullSets
std::vector< AdjEntry > adjs
All adjacency entries (mesh members + external).
std::vector< CompanionEntry > companions
All companion entries (mesh members + external).
std::unordered_map< EntityKind, ssp< GlobalOffsetsMapping > > globalMappings
Global offsets mappings per entity kind (for PermutationTransfer).
void registerCompanion(EntityKind kind, AdjRelocateFn fn, std::string name={})
Register a companion with a type-erased relocate callback.
void registerAdj(AdjKind kind, AdjRemapFn remap, AdjRelocateFn relocate, std::string name={})
Register an adjacency with type-erased callbacks.
Lightweight bundle of an MPI communicator and the calling rank's coordinates.
Result of buildLookup: ghost-pullable old-global -> new-global map.
Eigen::Matrix< real, 5, 1 > v