|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
Deterministic open-boundary Bak-Tang-Wiesenfeld sandpile. More...
#include <ca_reproduction_support.H>
Public Types | |
| using | Grid = Lattice< Dense_Cell_Storage< int, 2 >, OpenBoundary > |
| using | update_scheme = Sequential_Update< RowMajor > |
Public Member Functions | |
| BTW_Sandpile (const ca_size_t side, const std::uint64_t seed=0) | |
| Construct an empty square sandpile. | |
| Avalanche | drop_random () |
| Drop one grain at a uniformly selected cell and stabilise. | |
| Avalanche | drop_at (const ca_size_t row, const ca_size_t column) |
Drop one grain at (row, column) and stabilise. | |
| const Grid & | frame () const noexcept |
| Return the current stable grid. | |
| bool | stable () const |
| Test whether every cell is below the toppling threshold. | |
Private Member Functions | |
| void | add_if_inside (const ca_index_t row, const ca_index_t column) |
Add one grain when (row, column) lies inside the open grid. | |
Private Attributes | |
| Grid | grid_ |
| std::mt19937_64 | rng_ |
Deterministic open-boundary Bak-Tang-Wiesenfeld sandpile.
The implementation performs in-place row-major toppling sweeps. It names Sequential_Update<RowMajor> as its update scheme because direct BTW toppling writes both the selected cell and its neighbours; a pull-only local rule cannot preserve grains while expressing that operation.
Definition at line 312 of file ca_reproduction_support.H.
| using Aleph::CA::Reproductions::BTW_Sandpile::Grid = Lattice<Dense_Cell_Storage<int, 2>, OpenBoundary> |
Definition at line 315 of file ca_reproduction_support.H.
Definition at line 316 of file ca_reproduction_support.H.
|
inlineexplicit |
Construct an empty square sandpile.
| side | grid side length. |
| seed | seed used for uniformly distributed grain drops. |
| std::domain_error | if side == 0. |
Definition at line 323 of file ca_reproduction_support.H.
References Aleph::blossom_maximum_cardinality_matching().
|
inlineprivate |
Add one grain when (row, column) lies inside the open grid.
| row | candidate row. |
| column | candidate column. |
Definition at line 406 of file ca_reproduction_support.H.
References Aleph::CA::Lattice< Storage, Boundary >::at(), Aleph::blossom_maximum_cardinality_matching(), grid_, row, Aleph::CA::Lattice< Storage, Boundary >::set(), and Aleph::CA::Lattice< Storage, Boundary >::size().
Referenced by drop_at().
|
inline |
Drop one grain at (row, column) and stabilise.
| row | zero-based row. |
| column | zero-based column. |
| std::domain_error | if the coordinate is out of range. |
Definition at line 344 of file ca_reproduction_support.H.
References add_if_inside(), ah_domain_error_if, Aleph::CA::Lattice< Storage, Boundary >::at(), Aleph::blossom_maximum_cardinality_matching(), Aleph::CA::Reproductions::Avalanche::duration, grid_, r, row, Aleph::CA::Lattice< Storage, Boundary >::set(), Aleph::CA::Reproductions::Avalanche::size, and Aleph::CA::Lattice< Storage, Boundary >::size().
Referenced by drop_random().
|
inline |
Drop one grain at a uniformly selected cell and stabilise.
Definition at line 332 of file ca_reproduction_support.H.
References drop_at(), grid_, rng_, and Aleph::CA::Lattice< Storage, Boundary >::size().
Return the current stable grid.
Definition at line 381 of file ca_reproduction_support.H.
References grid_.
|
inline |
Test whether every cell is below the toppling threshold.
true when the frame is stable. Definition at line 389 of file ca_reproduction_support.H.
References Aleph::CA::Lattice< Storage, Boundary >::at(), grid_, r, and Aleph::CA::Lattice< Storage, Boundary >::size().
|
private |
Definition at line 399 of file ca_reproduction_support.H.
Referenced by add_if_inside(), drop_at(), drop_random(), frame(), and stable().
|
private |
Definition at line 400 of file ca_reproduction_support.H.
Referenced by drop_random().