|
DNDSR 0.2.1
Distributed Numeric Data Structure for CFV
|
#include <MeshConnectivity.hpp>
Public Member Functions | |
| void | registerAdj (AdjKind kind, ssp< AdjVariant > adjPtr) |
| template<class TPair > | |
| void | registerAdj (AdjKind kind, TPair &pair) |
| template<class TPair > | |
| void | registerAdj (AdjKind kind, const TPair &pair) |
| template<class TPair > | |
| void | registerAdj (AdjKind kind, AdjPairTracked< TPair > &pair) |
| Overload for AdjPairTracked<TPair>: unwrap to base TPair. | |
| template<class TPair > | |
| void | registerAdj (AdjKind kind, const AdjPairTracked< TPair > &pair) |
| Const overload for AdjPairTracked<TPair>. | |
| void | registerGlobalMapping (EntityKind kind, const ssp< GlobalOffsetsMapping > &gm) |
| Register a GlobalOffsetsMapping for an EntityKind. | |
| ssp< AdjVariant > | resolveAdj (AdjKind kind) const |
| const ssp< GlobalOffsetsMapping > & | getGlobalMapping (EntityKind kind) const |
| bool | hasAdj (AdjKind kind) const |
| Check whether an AdjKind is registered. | |
| ConeAdj & | addCone (int fromDepth, int toDepth) |
| ConeAdj * | findCone (int fromDepth, int toDepth) |
| Find a cone by (fromDepth, toDepth). Returns nullptr if not found. | |
| const ConeAdj * | findCone (int fromDepth, int toDepth) const |
| bool | hasCone (int fromDepth, int toDepth) const |
| SupportAdj & | addSupport (int fromDepth, int toDepth) |
| SupportAdj * | findSupport (int fromDepth, int toDepth) |
| Find a support by (fromDepth, toDepth). Returns nullptr if not found. | |
| const SupportAdj * | findSupport (int fromDepth, int toDepth) const |
| bool | hasSupport (int fromDepth, int toDepth) const |
| GhostResult | evaluateGhostTree (const CompiledGhostTree &tree, const MPIInfo &mpi) const |
Static Public Member Functions | |
| template<rowsize cone_rs = NonUniformSize> | |
| static tAdjPair | Inverse (const ArrayAdjacencyPair< cone_rs > &cone, index nToLocal, const MPIInfo &mpi, const std::function< index(index)> &fromLocal2Global, const std::function< index(index)> &toLocal2Global, const ssp< GlobalOffsetsMapping > &toGlobalMapping) |
| template<rowsize rs_AB = NonUniformSize, rowsize rs_BC = NonUniformSize, rowsize out_rs = NonUniformSize> | |
| static ArrayAdjacencyPair< out_rs > | Compose (const ArrayAdjacencyPair< rs_AB > &AB, const ArrayAdjacencyPair< rs_BC > &BC, index nALocal, const std::unordered_map< index, index > &bGlobal2Local, const std::function< index(index)> &aLocal2Global, bool removeSelf=false) |
| template<rowsize rs_AB = NonUniformSize, rowsize rs_BC = NonUniformSize, rowsize out_rs = NonUniformSize, class Predicate = SharedCountPredicate> | |
| static ArrayAdjacencyPair< out_rs > | ComposeFiltered (const ArrayAdjacencyPair< rs_AB > &AB, const ArrayAdjacencyPair< rs_BC > &BC, index nALocal, const std::unordered_map< index, index > &bGlobal2Local, const std::function< index(index)> &aLocal2Global, Predicate &&pred, const std::function< bool(index aLocal, index cGlobal, const std::vector< index > &sharedBGlobals)> &matchExtra=nullptr) |
| template<rowsize p2n_rs = NonUniformSize> | |
| static InterpolateResult | Interpolate (const ArrayAdjacencyPair< p2n_rs > &parent2node, const SubEntityQuery &query, index nParent, index nNode, const MPIInfo &mpi) |
| template<rowsize p2n_rs = NonUniformSize> | |
| static InterpolateDistributedResult | InterpolateDistributed (const ArrayAdjacencyPair< p2n_rs > &parent2node, const OffsetAscendIndexMapping &parentGhostMapping, const SubEntityQuery &query, index nLocalParents, index nTotalParents, index nNode, const OwnershipResolver2 &resolver, const OffsetAscendIndexMapping &nodeGhostMapping, const MPIInfo &mpi) |
| template<rowsize p2n_rs = NonUniformSize, rowsize e2p_rs = NonUniformSize> | |
| static InterpolateGlobalResultT< e2p_rs > | InterpolateGlobal (const ArrayAdjacencyPair< p2n_rs > &parent2node, const tPbiPair &parent2nodePbi, const OffsetAscendIndexMapping &parentGhostMapping, const GlobalOffsetsMapping &parentGlobalMapping, const OffsetAscendIndexMapping &nodeGhostMapping, const SubEntityQueryPbi &query, index nLocalParents, index nTotalParents, index nNode, const OwnershipResolverMulti &resolver, const MPIInfo &mpi) |
Public Attributes | |
| int | meshDim {0} |
| std::vector< ConeAdj > | cones |
| std::vector< SupportAdj > | supports |
| std::unordered_map< AdjKind, ssp< AdjVariant >, AdjKindHash > | adjRegistry |
| std::unordered_map< EntityKind, ssp< GlobalOffsetsMapping > > | globalMappings |
Manages the layered DAG of mesh adjacency relations.
Cones (downward adjacencies) and supports (upward adjacencies) are stored in separate vectors. Each is identified by a (fromDepth, toDepth) pair using dynamic depth tags (e.g., (dim, 0) for cell→node).
Adjacency data is stored via ssp<AdjVariant> for shared ownership. Both the DAG's ConeAdj/SupportAdj and the legacy mesh members can share the same underlying arrays (shallow copy of ssp<Array> pointers).
The adjacency registry (adjRegistry) maps AdjKind tags to ssp<AdjVariant> for use by the ghost traversal system. No raw pointers. Only a restricted set of adjacencies may be registered:
Definition at line 835 of file MeshConnectivity.hpp.
| ConeAdj & DNDS::Geom::MeshConnectivity::addCone | ( | int | fromDepth, |
| int | toDepth | ||
| ) |
Add a new cone for (fromDepth, toDepth). Returns reference. Asserts no duplicate exists.
Definition at line 62 of file MeshConnectivity.cpp.
| SupportAdj & DNDS::Geom::MeshConnectivity::addSupport | ( | int | fromDepth, |
| int | toDepth | ||
| ) |
Add a new support for (fromDepth, toDepth). Returns reference. Asserts no duplicate exists.
Definition at line 95 of file MeshConnectivity.cpp.
|
static |
Compose two adjacencies: A→B + B→C → A→C (delegates to ComposeFiltered with SharedCountPredicate{1}).
| rs_AB | Row-size of AB adjacency. |
| rs_BC | Row-size of BC adjacency. |
| out_rs | Row-size of output (NonUniformSize or fixed). |
Definition at line 1352 of file MeshConnectivity.hpp.
|
static |
Compose two adjacencies with on-the-fly predicate filtering.
For each row a in AB, iterates b in AB[a], collects c in BC[b]. Counts shared B-entities per candidate, applies predicate.
BC must contain (father+son) all B-entities referenced by AB. The caller must ghost-pull BC for every global B-index that appears in any row of AB. The bGlobal2Local map must cover all such B-globals. If a B-global from AB is not in bGlobal2Local, the method asserts (fatal error indicating incomplete ghost pull).
Typical pattern: before calling ComposeFiltered, the caller builds BC (e.g., node2cell via Inverse), then ghost-pulls it for all off-rank B-entities referenced by local AB rows.
| rs_AB | Row-size of AB adjacency. |
| rs_BC | Row-size of BC adjacency. |
| Predicate | Predicate type. |
| AB | A → B (father only, global B indices). |
| BC | B → C (father+son, global C indices). |
| nALocal | Number of local A-entities. |
| bGlobal2Local | Maps global B-index to local-appended index in BC. Must contain every B-global that appears in AB. |
| aLocal2Global | Maps local A-index to global A-index. |
| pred | Predicate(a_global, c_global, nShared) → keep? |
| matchExtra | Optional second predicate called after pred passes. Receives (aLocal, cGlobal, sharedBGlobals) where sharedBGlobals is the list of B-entities through which A and C are connected. If set and returns false, the (A, C) pair is rejected. Used for periodic pbi filtering. |
| out_rs | Row-size of output (NonUniformSize = variable, or fixed: rows shorter than out_rs are padded with UnInitIndex, rows longer trigger assert). |
Definition at line 1252 of file MeshConnectivity.hpp.
| GhostResult DNDS::Geom::MeshConnectivity::evaluateGhostTree | ( | const CompiledGhostTree & | tree, |
| const MPIInfo & | mpi | ||
| ) | const |
Evaluate a compiled ghost tree to determine which entities to ghost.
BFS level-by-level evaluation with scratch pulls between levels. Produces a GhostResult containing per-EntityKind ghost index sets (union of all COLLECT nodes).
| tree | Compiled ghost tree (from CompiledGhostTree::compile). |
| mpi | MPI communicator. |
Preconditions:
Definition at line 378 of file MeshConnectivity_Ghost.cpp.
| ConeAdj * DNDS::Geom::MeshConnectivity::findCone | ( | int | fromDepth, |
| int | toDepth | ||
| ) |
Find a cone by (fromDepth, toDepth). Returns nullptr if not found.
Definition at line 70 of file MeshConnectivity.cpp.
| const ConeAdj * DNDS::Geom::MeshConnectivity::findCone | ( | int | fromDepth, |
| int | toDepth | ||
| ) | const |
Definition at line 78 of file MeshConnectivity.cpp.
| SupportAdj * DNDS::Geom::MeshConnectivity::findSupport | ( | int | fromDepth, |
| int | toDepth | ||
| ) |
Find a support by (fromDepth, toDepth). Returns nullptr if not found.
Definition at line 103 of file MeshConnectivity.cpp.
| const SupportAdj * DNDS::Geom::MeshConnectivity::findSupport | ( | int | fromDepth, |
| int | toDepth | ||
| ) | const |
Definition at line 111 of file MeshConnectivity.cpp.
| const ssp< GlobalOffsetsMapping > & DNDS::Geom::MeshConnectivity::getGlobalMapping | ( | EntityKind | kind | ) | const |
Resolve a GlobalOffsetsMapping for an EntityKind. Returns nullptr if not registered.
Definition at line 44 of file MeshConnectivity.cpp.
| bool DNDS::Geom::MeshConnectivity::hasAdj | ( | AdjKind | kind | ) | const |
Check whether an AdjKind is registered.
Definition at line 53 of file MeshConnectivity.cpp.
| bool DNDS::Geom::MeshConnectivity::hasCone | ( | int | fromDepth, |
| int | toDepth | ||
| ) | const |
Definition at line 86 of file MeshConnectivity.cpp.
| bool DNDS::Geom::MeshConnectivity::hasSupport | ( | int | fromDepth, |
| int | toDepth | ||
| ) | const |
Definition at line 119 of file MeshConnectivity.cpp.
|
static |
Extract sub-entities (faces or edges) from parent→node connectivity. This is a local-only operation — no MPI communication.
Enumerates and deduplicates B entities within a contiguous block of parent A entities (typically local + ghost cells). Produces local-indexed parent→entity, entity→node, and entity→parent adjacencies.
Used internally by InterpolateGlobal (Step 1). Can also be used directly for rank-local analysis or testing.
Two sub-entities are considered the same B entity if:
The caller typically passes all A parents (father+son) so that shared sub-entities are deduplicated within the local view. If ghost A parents are omitted, shared B entities at rank boundaries will appear as separate single-sided entities.
InterpolateLocal does not handle pbi. parent2entityPbi in the result is left empty. InterpolateGlobal computes it in Step 2b after calling InterpolateLocal, using the parent2nodePbi input and extractPbi callback.
| parent2node | Parent → nodes (father-only or father+son). Accessed via operator[] for indices [0, nParent). |
| p2n_rs | Row-size of parent2node (NonUniformSize or fixed). |
| query | User-provided callbacks describing sub-entity topology. |
| nParent | Number of parent entities to process. |
| nNode | Total number of nodes (for reverse-index sizing). |
| mpi | MPI info (only for array allocation, no communication). |
Definition at line 14 of file MeshConnectivity_Interpolate.hxx.
|
static |
Legacy distributed interpolation (2-parent only, no pbi output).
Superseded by InterpolateGlobal for production use. Retained for backward compatibility. Limitations vs InterpolateGlobal:
Extends Interpolate by:
| parent2node | CSR: parent → nodes (father + son). |
| parentGhostMapping | Ghost mapping for parent entities (for global index lookups). Must map local-appended index to global parent index. |
| query | Sub-entity topology callbacks. |
| nLocalParents | Number of local (owned/father) parents. |
| nTotalParents | Total parents (father + son). |
| nNode | Total number of nodes. |
| resolver | Ownership callback. |
| nodeGhostMapping | Ghost mapping for nodes (local-appended → global). Used to convert entity2node to global before push and back to local on the receiver. |
| mpi | MPI communicator. |
Definition at line 176 of file MeshConnectivity_Interpolate.hxx.
|
static |
Distributed interpolation producing globally-unique B entities.
Given an A→C cone with pbi (where A is ghosted via A→C→A), creates globally-unique B entities (faces or edges). B entities are created only from local (non-ghost) A parents. Ghost A parents are used solely for deduplication — when a local A's sub-entity shares C-vertices with a ghost A's sub-entity, they are recognized as the same B entity.
A must be ghosted by at least the A→C→A 1-hop node-neighbor set. Every A entity sharing at least one C-vertex with a local A must be present as a ghost. This guarantees:
If the ghost set is insufficient, shared B entities across ranks will appear as single-sided. This is a silent error the method cannot detect (boundary faces/edges are legitimately single-sided).
C (nodes) must be ghosted to cover all C-vertices referenced by ghost A parents. Typically guaranteed by the A→C→A ghost chain.
Ghost B entities are NOT produced. Use evaluateGhostTree(A→A2B→B) after this call to pull them.
parent2entity[iParent][j] corresponds to sub-entity j per element topology (ObtainFace(j) / ObtainEdge(j)). entity2node stores nodes in the first- discovered parent's extraction order. All pbi arrays are parallel to their adjacency counterparts.
| parent2node | CSR: A → C (father+son, local C indices). |
| parent2nodePbi | A → C pbi (father+son). Pass empty pair if not periodic. |
| parentGhostMapping | Ghost mapping for A (local-appended → global). |
| parentGlobalMapping | Global offsets mapping for A (for rank lookup). |
| nodeGhostMapping | Ghost mapping for C (local-appended → global). |
| query | Sub-entity topology + pbi extraction callbacks. |
| nLocalParents | Number of owned A. |
| nTotalParents | Total A (father + son). |
| nNode | Total C (father + son). |
| resolver | N-parent ownership callback. |
| mpi | MPI communicator. |
| p2n_rs | Row-size of parent2node input. |
| e2p_rs | Row-size of entity2parent output (NonUniformSize = variable, 2 = fixed for faces). Fixed-width rows shorter than e2p_rs are padded with UnInitIndex. |
Definition at line 442 of file MeshConnectivity_Interpolate.hxx.
|
static |
Invert a cone to get its support (distributed, MPI push-back).
Given a cone adjacency A→B (for each A-entity, list of B-entities), compute the support adjacency B→A (for each B-entity, list of A-entities that reference it). Result is globally complete via MPI push-back.
The input cone can be any row-size (fixed or variable). The output support is always variable-width (tAdjPair) because fan-in is not known at compile time.
| cone_rs | Row-size of the input cone (NonUniformSize or fixed). |
| cone | Adjacency: from → to (global indices). |
| nToLocal | Local number of "to" entities on this rank. |
| mpi | MPI communicator. |
| fromLocal2Global | Maps local from-entity index to global index. |
| toLocal2Global | Maps local to-entity index to global index. |
| toGlobalMapping | Global mapping for to-entities (ownership lookup). |
Definition at line 1370 of file MeshConnectivity.hpp.
|
inline |
Overload for AdjPairTracked<TPair>: unwrap to base TPair.
Definition at line 888 of file MeshConnectivity.hpp.
|
inline |
Const overload for AdjPairTracked<TPair>.
Definition at line 895 of file MeshConnectivity.hpp.
|
inline |
Const overload: same as above but accepts a const reference. Safe because we only copy the father shared_ptr (no mutation).
Definition at line 878 of file MeshConnectivity.hpp.
| void DNDS::Geom::MeshConnectivity::registerAdj | ( | AdjKind | kind, |
| ssp< AdjVariant > | adjPtr | ||
| ) |
Register an adjacency for ghost traversal. The ssp shares ownership with the ConeAdj/SupportAdj that holds the data. Overwrites any existing registration for the same AdjKind.
Definition at line 28 of file MeshConnectivity.cpp.
|
inline |
Convenience: register a specific pair type (tAdjPair, tAdj2Pair, etc.). Stores a father-only shallow reference. The evaluator creates its own scratch transformers internally for any ghost data it needs.
Definition at line 865 of file MeshConnectivity.hpp.
| void DNDS::Geom::MeshConnectivity::registerGlobalMapping | ( | EntityKind | kind, |
| const ssp< GlobalOffsetsMapping > & | gm | ||
| ) |
Register a GlobalOffsetsMapping for an EntityKind.
Definition at line 33 of file MeshConnectivity.cpp.
| ssp< AdjVariant > DNDS::Geom::MeshConnectivity::resolveAdj | ( | AdjKind | kind | ) | const |
Resolve an AdjKind to the registered AdjVariant. Returns nullptr if not registered.
Definition at line 38 of file MeshConnectivity.cpp.
| std::unordered_map<AdjKind, ssp<AdjVariant>, AdjKindHash> DNDS::Geom::MeshConnectivity::adjRegistry |
Maps AdjKind to the shared AdjVariant used by ghost chain evaluation. Only direct cones/supports and intra-level (via Node/Face) adjacencies are allowed. Registered via registerAdj(). Owns shared references (ssp) — no raw pointers.
Definition at line 849 of file MeshConnectivity.hpp.
| std::vector<ConeAdj> DNDS::Geom::MeshConnectivity::cones |
Definition at line 838 of file MeshConnectivity.hpp.
| std::unordered_map<EntityKind, ssp<GlobalOffsetsMapping> > DNDS::Geom::MeshConnectivity::globalMappings |
Per-EntityKind global offsets mapping (for ownership determination). Must be registered for every EntityKind that appears as a root anchor or COLLECT target in any ghost chain.
Definition at line 854 of file MeshConnectivity.hpp.
| int DNDS::Geom::MeshConnectivity::meshDim {0} |
Definition at line 837 of file MeshConnectivity.hpp.
| std::vector<SupportAdj> DNDS::Geom::MeshConnectivity::supports |
Definition at line 839 of file MeshConnectivity.hpp.