Mundy: Multibody Nonlocal Dynamics Version of the Day
Loading...
Searching...
No Matches
EntityIndices.hpp File Reference

Memoized helpers that enumerate the entities of a (rank, selector) chunk into device-usable views. More...

Namespaces

namespace  mundy
namespace  mundy::mesh

Functions

template<typename OurExecSpace>
NgpViewT< stk::mesh::FastMeshIndex *, OurExecSpace > mundy::mesh::get_local_entity_indices (const stk::mesh::BulkData &bulk_data, stk::mesh::EntityRank rank, const stk::mesh::Selector &selector, const OurExecSpace &)
 Get the local fast mesh indices for the entities of a (rank, selector) chunk as an NgpView (memoized).
template<typename OurExecSpace>
NgpViewT< stk::mesh::Entity *, OurExecSpace > mundy::mesh::get_local_entities (const stk::mesh::BulkData &bulk_data, stk::mesh::EntityRank rank, const stk::mesh::Selector &selector, const OurExecSpace &)
 Get the entities of a (rank, selector) chunk as an NgpView, in the same order as get_local_entity_indices (memoized).

Detailed Description

These pair a selector with a dense, deterministically-ordered enumeration of its entities:

  • get_local_entity_indices returns the per-entity FastMeshIndex (for NGP field / component access),
  • get_local_entities returns the matching stk::mesh::Entity (for entity keys, ghosting, etc.).

Both use stk::mesh::get_entities(bulk, rank, selector, ...) ordering, so the i-th FastMeshIndex and the i-th Entity refer to the same entity.

Memoization
Enumerating a selector is host work (get_entities + a host fill + a host→device sync) that recurs across phases and consumers (the neighbor-list build, excluders, rebuilders, …). To avoid redundant re-enumeration, the results are cached on the BulkData's MetaData as an attribute (one cache per execution space), keyed by (rank, selector) using Selector::operator==, and tagged with the BulkData::synchronized_count() at which they were built. A lookup returns the cached view when the synchronized count is unchanged; otherwise the view is rebuilt and the cached count updated. Because synchronized_count() advances on every mesh modification (the only thing that can change a selector's entity sequence, or invalidate a bucket-relative FastMeshIndex), the cache is self-invalidating — callers never see a stale enumeration. The enumeration and cache machinery live in impl/EntityIndicesImpl.hpp.