Neighborhood Search

The neighborhood search is one of the most performance-critical components. We provide several implementations in the package PointNeighbors.jl. See the PointNeighbors.jl documentation for an overview and a comparison of the different implementations.

Usage

To run a simulation with a neighborhood search implementation, pass a neighborhood search template to the constructor of the Semidiscretization. A template is just an empty neighborhood search with search radius 0.0. See copy_neighborhood_search and the examples below for more details.

semi = Semidiscretization(system1, system2,
                          neighborhood_search=PrecomputedNeighborhoodSearch{2}())

The keyword argument periodic_box in the neighborhood search constructors can be used to define a periodic domain. See the PointNeighbors.jl docs for more details.

periodic_box = PeriodicBox(min_corner=[0.0, -0.25], max_corner=[1.0, 0.75])
semi = Semidiscretization(system1, system2,
                          neighborhood_search=GridNeighborhoodSearch{2}(; periodic_box))

Neighborhood Search Handlers

Neighborhood search handlers control how neighborhood searches for the interacting systems are stored and looked up. This only affects memory use and update cost by avoiding redundant neighborhood searches, not the underlying search algorithm.

To choose a handler explicitly, pass the handler type to Semidiscretization.

semi = Semidiscretization(system1, system2,
                          neighborhood_search_handler=PairsNHSHandler)
TrixiParticles.PairsNHSHandlerType
PairsNHSHandler

Neighborhood search handler that stores one neighborhood search for each ordered pair of systems.

PairsNHSHandler is the fully generic handler. Use it for neighborhood search implementations whose data are tied to the specific pair of systems used during an update, e.g., PrecomputedNeighborhoodSearch. It is compatible with all neighborhood search implementations and is the default for searches that cannot use SharedNHSHandler.

Examples

semi = Semidiscretization(system1, system2;
                          neighborhood_search_handler=PairsNHSHandler)
source
TrixiParticles.SharedNHSHandlerType
SharedNHSHandler

Neighborhood search handler optimized for reusable neighborhood searches.

SharedNHSHandler stores one neighborhood search for each neighbor system and required search radius, instead of one search for every ordered pair of systems. For a query involving (system, neighbor), it selects the stored search for the neighbor system with a radius large enough for that pair's compact support.

This handler reuses the same neighborhood search for all interactions that have the same neighbor system and search radius. This is only possible if the neighborhood search stores information about the neighbor particles only. For example, a grid-based search can be shared because it stores the neighbor particles in grid cells and it does not store information about the first particle set. In contrast, a precomputed neighbor list cannot be shared because its stored neighbors are tied to the specific query particles used during initialization.

The SharedNHSHandler is the default handler for compatible neighborhood search implementations because it avoids storing and updating redundant neighborhood searches.

Warning

This handler is only compatible with neighborhood searches that can query neighbors of arbitrary points in space after an update, e.g. GridNeighborhoodSearch and TrivialNeighborhoodSearch. PrecomputedNeighborhoodSearch is not compatible because it can only query neighbors for the particles that were used to update the search.

Examples

semi = Semidiscretization(system1, system2;
                          neighborhood_search=GridNeighborhoodSearch{2}(),
                          neighborhood_search_handler=SharedNHSHandler)
source