Mundy: Multibody Nonlocal Dynamics Version of the Day
Loading...
Searching...
No Matches
mundy::search::ManagedNeighborList< BuilderState, Rebuilder > Class Template Reference

A neighbor list cache driven by a stateful rebuilder policy. More...

#include <ManagedNeighborList.hpp>

Classes

struct  UpdateResult
 Return type for update() carrying both the list and a rebuild indicator. More...

Public Types

Aliases
using builder_state_type = BuilderState
using list_type = typename BuilderState::neighbor_list_type
using rebuilder_type = Rebuilder
using build_args_type = typename NeighborListBuildTraits<list_type>::args_type

Public Member Functions

Constructors
 ManagedNeighborList (const BuilderState &builder, rebuilder_type rebuilder)
 Construct from a builder state snapshot and a rebuilder.
Fluent configuration (mirrors NeighborListBuilder)
template<typename NewExecutionSpace>
auto exec_space (const NewExecutionSpace &es) const
 Return a new managed list with the execution space supplied.
template<ExcluderType NextExcluder>
auto broad_phase (const NextExcluder &ex) const
 Return a new managed list with an appended broad-phase excluder.
template<ExcluderType NextExcluder>
auto narrow_phase (const NextExcluder &ex) const
 Return a new managed list with an appended narrow-phase excluder.
auto sort_neighbors (bool sort) const
 Return a new managed list with the neighbor-sort flag set.
Core API
template<NeighborListInputType TargetInput, NeighborListInputType SourceInput>
requires (BuilderState::has_exec_space)
UpdateResult update (const stk::mesh::BulkData &bulk, const TargetInput &targets, const SourceInput &sources, const build_args_type &args={})
 Return a valid, up-to-date neighbor list for the given targets and sources.
void invalidate () noexcept
 Discard the cached list so that the next update() unconditionally rebuilds.
bool has_valid_list () const noexcept
 Return whether a valid cached list exists.
const list_typecurrent () const
 Return the cached list without consulting the rebuilder.
Accessors
const BuilderState & builder () const noexcept
rebuilder_typerebuilder () noexcept
const rebuilder_typerebuilder () const noexcept

Detailed Description

template<typename BuilderState, RebuilderType Rebuilder>
class mundy::search::ManagedNeighborList< BuilderState, Rebuilder >

ManagedNeighborList owns a cached ListType instance and a Rebuilder that determines when the cache is stale. On each call to update(bulk, targets, sources, args), the rebuilder is consulted: if it signals that a rebuild is needed (or if no list has been built yet), a fresh list is constructed from the stored builder state with the supplied targets and sources; snapshot is then called on the rebuilder so it can record current geometry or entity state.

A ManagedNeighborList is obtained by calling .manage(rebuilder) on a NeighborListBuilder at any point in the fluent chain. The remaining builder configuration methods — exec_space, broad_phase, narrow_phase, and sort_neighbors — are also available directly on the returned ManagedNeighborList, so the full chain can be written in any order:

// manage() at any position — chain continues after it:
.exec_space(exec)
.broad_phase(ExcludeSelfInteraction{});
// Each time-step:
const auto& nl = managed.update(bulk, targets, sources);
auto exec_space(const NewExecutionSpace &es) const
Return a new managed list with the execution space supplied.
Definition ManagedNeighborList.hpp:137
Rebuilder that triggers when any box corner moves beyond a displacement threshold.
Definition NeighborListRebuilder.hpp:454
Rebuilder that triggers when the target or source entity sequence changes.
Definition NeighborListRebuilder.hpp:314
NeighborListBuilder< ListType > make_neighbor_list_builder()
Create an empty fluent builder for a concrete neighbor-list type.
Definition NeighborListBuilder.hpp:407

update() requires that the execution space has been set (via exec_space(...)) at or before the call; failing to do so produces a compile-time constraint violation.

Member Typedef Documentation

◆ builder_state_type

template<typename BuilderState, RebuilderType Rebuilder>
using mundy::search::ManagedNeighborList< BuilderState, Rebuilder >::builder_state_type = BuilderState

◆ list_type

template<typename BuilderState, RebuilderType Rebuilder>
using mundy::search::ManagedNeighborList< BuilderState, Rebuilder >::list_type = typename BuilderState::neighbor_list_type

◆ rebuilder_type

template<typename BuilderState, RebuilderType Rebuilder>
using mundy::search::ManagedNeighborList< BuilderState, Rebuilder >::rebuilder_type = Rebuilder

◆ build_args_type

template<typename BuilderState, RebuilderType Rebuilder>
using mundy::search::ManagedNeighborList< BuilderState, Rebuilder >::build_args_type = typename NeighborListBuildTraits<list_type>::args_type

Constructor & Destructor Documentation

◆ ManagedNeighborList()

template<typename BuilderState, RebuilderType Rebuilder>
mundy::search::ManagedNeighborList< BuilderState, Rebuilder >::ManagedNeighborList ( const BuilderState & builder,
rebuilder_type rebuilder )
inline

Called by NeighborListBuilder::manage(rebuilder) — prefer that factory.

Member Function Documentation

◆ exec_space()

template<typename BuilderState, RebuilderType Rebuilder>
template<typename NewExecutionSpace>
auto mundy::search::ManagedNeighborList< BuilderState, Rebuilder >::exec_space ( const NewExecutionSpace & es) const
inline
Parameters
es[in] Execution space used by the eventual build.

◆ broad_phase()

template<typename BuilderState, RebuilderType Rebuilder>
template<ExcluderType NextExcluder>
auto mundy::search::ManagedNeighborList< BuilderState, Rebuilder >::broad_phase ( const NextExcluder & ex) const
inline
Parameters
ex[in] Excluder to append to the broad-phase chain.

◆ narrow_phase()

template<typename BuilderState, RebuilderType Rebuilder>
template<ExcluderType NextExcluder>
auto mundy::search::ManagedNeighborList< BuilderState, Rebuilder >::narrow_phase ( const NextExcluder & ex) const
inline
Parameters
ex[in] Excluder to append to the narrow-phase chain.

◆ sort_neighbors()

template<typename BuilderState, RebuilderType Rebuilder>
auto mundy::search::ManagedNeighborList< BuilderState, Rebuilder >::sort_neighbors ( bool sort) const
inline
Parameters
sort[in] Whether to sort neighbor rows by source ordinal after each build.

◆ update()

template<typename BuilderState, RebuilderType Rebuilder>
template<NeighborListInputType TargetInput, NeighborListInputType SourceInput>
requires (BuilderState::has_exec_space)
UpdateResult mundy::search::ManagedNeighborList< BuilderState, Rebuilder >::update ( const stk::mesh::BulkData & bulk,
const TargetInput & targets,
const SourceInput & sources,
const build_args_type & args = {} )
inline

Consults the rebuilder. If no list has been built yet or the rebuilder signals a rebuild is needed, constructs a fresh list from the stored builder state with the supplied targets and sources, then calls snapshot on the rebuilder. Otherwise returns the cached list.

Parameters
bulk[in] STK bulk data used for excluder setup and build.
targets[in] Target input (boxes, selector, …) for this update.
sources[in] Source input (boxes, selector, …) for this update.
args[in] Backend-specific build parameters; default-constructed when omitted.

◆ invalidate()

template<typename BuilderState, RebuilderType Rebuilder>
void mundy::search::ManagedNeighborList< BuilderState, Rebuilder >::invalidate ( )
inlinenoexcept

◆ has_valid_list()

template<typename BuilderState, RebuilderType Rebuilder>
bool mundy::search::ManagedNeighborList< BuilderState, Rebuilder >::has_valid_list ( ) const
inlinenoexcept

◆ current()

template<typename BuilderState, RebuilderType Rebuilder>
const list_type & mundy::search::ManagedNeighborList< BuilderState, Rebuilder >::current ( ) const
inline

Requires that has_valid_list() is true; call update() first.

◆ builder()

template<typename BuilderState, RebuilderType Rebuilder>
const BuilderState & mundy::search::ManagedNeighborList< BuilderState, Rebuilder >::builder ( ) const
inlinenoexcept

◆ rebuilder() [1/2]

template<typename BuilderState, RebuilderType Rebuilder>
rebuilder_type & mundy::search::ManagedNeighborList< BuilderState, Rebuilder >::rebuilder ( )
inlinenoexcept

◆ rebuilder() [2/2]

template<typename BuilderState, RebuilderType Rebuilder>
const rebuilder_type & mundy::search::ManagedNeighborList< BuilderState, Rebuilder >::rebuilder ( ) const
inlinenoexcept