Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
tpl_ca_ghost_lattice.H File Reference

Ghost-layer lattice for high-performance boundary handling. More...

#include <cstddef>
#include <type_traits>
#include <utility>
#include <ah-errors.H>
#include <ca-traits.H>
#include <tpl_ca_concepts.H>
#include <tpl_ca_lattice.H>
Include dependency graph for tpl_ca_ghost_lattice.H:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  Aleph::CA::Ghost_Lattice< Storage, Boundary, Halo >
 Lattice with Halo ghost layers around the user-visible cells. More...
 

Namespaces

namespace  Aleph
 Main namespace for Aleph-w library functions.
 
namespace  Aleph::CA
 
namespace  Aleph::CA::ca_ghost_detail
 

Functions

template<std::size_t N>
std::array< ca_size_t, N > Aleph::CA::ca_ghost_detail::enlarge_extents (const std::array< ca_size_t, N > &user, const std::size_t halo) noexcept
 Bump the storage extents by 2 * Halo on every axis.
 
ca_size_t Aleph::CA::ca_ghost_detail::positive_mod (ca_index_t v, const ca_size_t n) noexcept
 Wrap a possibly-negative index into [0, n) with positive modulo.
 
ca_size_t Aleph::CA::ca_ghost_detail::reflect_index (const ca_index_t v, const ca_size_t n) noexcept
 Reflect a signed coordinate into [0, n) using the no-repeat triangle wave that also powers Lattice::at_safe under ReflectiveBoundary.
 
ca_size_t Aleph::CA::ca_ghost_detail::clamp_index (const ca_index_t v, const ca_size_t n) noexcept
 Clamp a signed coordinate into [0, n - 1] for Neumann fills.
 
template<typename Storage , typename Boundary , std::size_t Halo>
void Aleph::CA::swap (Ghost_Lattice< Storage, Boundary, Halo > &a, Ghost_Lattice< Storage, Boundary, Halo > &b) noexcept(noexcept(a.swap(b)))
 Free-function swap so Ghost_Lattice works with std::swap.
 

Detailed Description

Ghost-layer lattice for high-performance boundary handling.

Aleph::CA::Ghost_Lattice<Storage, Boundary, Halo> wraps a backing storage that is larger than the user-visible lattice by Halo cells on every side of every axis, so that neighbour reads near the border land in real storage instead of branching on the boundary policy.

The lattice exposes user coordinates in [0, size(d)). Internally it translates them to store coordinates in [Halo, Halo + size(d)) of the underlying Storage object.

Halo cells are refreshed by refresh_halo() before every synchronous step (the engine calls it automatically when the lattice advertises the method). Four policies are supported:

  • OpenBoundary — halo cells hold state_type{}.
  • ToroidalBoundary / PeriodicBoundary — halo cells copy the opposite edge.
  • ReflectiveBoundary — halo cells mirror the interior.
  • ConstantBoundary<T, V> / DirichletBoundary<T, V> — halo cells hold V.
  • NeumannBoundary — halo cells replicate the nearest interior cell (zero gradient).

For any neighbourhood radius R <= Halo, at_safe(c) degenerates into a single store_.at(c + Halo) call with no boundary branch inside the rule loop. That is the whole point of Phase 4: lift the boundary logic out of the hot loop.

Author
Leandro Rabindranath Leon

Definition in file tpl_ca_ghost_lattice.H.