|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
Synchronous double-buffered engine for multi-field lattices. More...
#include <tpl_ca_multi_field_engine.H>
Public Types | |
| using | lattice_type = Lattice |
| using | rule_type = Rule |
| using | neighborhood_type = Neighborhood |
| using | coord_type = typename Lattice::coord_type |
| using | extents_type = typename Lattice::extents_type |
| using | fields_tuple = typename Lattice::field_types |
| using | hook_type = std::function< void(std::size_t, const Lattice &)> |
Hook signature: (step_index_just_completed, frame). | |
Public Member Functions | |
| Multi_Field_Engine (Lattice initial, Rule r, Neighborhood n) | |
| Build a multi-field engine. | |
| Multi_Field_Engine (Lattice initial, Rule r) | |
| Build with a default-constructed neighbourhood. | |
| const Lattice & | frame () const noexcept |
| std::size_t | steps_run () const noexcept |
| const extents_type & | extents () const noexcept |
| template<typename F > | |
| void | on_pre_step (F &&f) |
Register a hook fired before every step(). | |
| template<typename F > | |
| void | on_post_step (F &&f) |
Register a hook fired after every step(). | |
| void | step () |
| Apply the multi-field rule to every cell once and swap buffers. | |
| void | run (const std::size_t steps) |
| Run several steps. | |
Static Public Attributes | |
| static constexpr std::size_t | rank = Lattice::rank |
| static constexpr std::size_t | field_count = Lattice::field_count |
| static constexpr std::size_t | neighbour_count = Neighborhood::size_v |
Private Member Functions | |
| template<std::size_t... I> | |
| void | write_cell (const coord_type &c, const fields_tuple &v, std::index_sequence< I... >) |
| template<typename F > | |
| void | iterate_lattice (F &&f) |
Static Private Member Functions | |
| template<std::size_t... I> | |
| static auto | make_buffers (std::index_sequence< I... >) |
Private Attributes | |
| Lattice | cur_ |
| Lattice | nxt_ |
| Rule | rule_ |
| Neighborhood | nh_ |
| hook_type | pre_hook_ |
| hook_type | post_hook_ |
| std::size_t | step_count_ = 0 |
Synchronous double-buffered engine for multi-field lattices.
| Lattice | Multi_Field_Lattice<...> instance. |
| Rule | multi-field rule (MultiFieldRuleLike). |
| Neighborhood | mono-field neighbourhood applied uniformly to every field (NeighborhoodLike). |
step() is O(N * S * F) where N is the cell count, S the neighbour count and F the number of fields. Definition at line 122 of file tpl_ca_multi_field_engine.H.
| using Aleph::CA::Multi_Field_Engine< Lattice, Rule, Neighborhood >::coord_type = typename Lattice::coord_type |
Definition at line 134 of file tpl_ca_multi_field_engine.H.
| using Aleph::CA::Multi_Field_Engine< Lattice, Rule, Neighborhood >::extents_type = typename Lattice::extents_type |
Definition at line 135 of file tpl_ca_multi_field_engine.H.
| using Aleph::CA::Multi_Field_Engine< Lattice, Rule, Neighborhood >::fields_tuple = typename Lattice::field_types |
Definition at line 136 of file tpl_ca_multi_field_engine.H.
| using Aleph::CA::Multi_Field_Engine< Lattice, Rule, Neighborhood >::hook_type = std::function<void(std::size_t, const Lattice &)> |
Hook signature: (step_index_just_completed, frame).
Definition at line 143 of file tpl_ca_multi_field_engine.H.
| using Aleph::CA::Multi_Field_Engine< Lattice, Rule, Neighborhood >::lattice_type = Lattice |
Definition at line 131 of file tpl_ca_multi_field_engine.H.
| using Aleph::CA::Multi_Field_Engine< Lattice, Rule, Neighborhood >::neighborhood_type = Neighborhood |
Definition at line 133 of file tpl_ca_multi_field_engine.H.
| using Aleph::CA::Multi_Field_Engine< Lattice, Rule, Neighborhood >::rule_type = Rule |
Definition at line 132 of file tpl_ca_multi_field_engine.H.
|
inline |
Build a multi-field engine.
Allocates a next-step lattice with the same extents as the initial lattice. Both buffers share the boundary policy and layout.
| [in] | initial | initial lattice (consumed by move). |
| [in] | r | rule instance (consumed by move). |
| [in] | n | neighbourhood instance (consumed by move). |
| std::bad_alloc | on next-buffer allocation failure. |
Definition at line 178 of file tpl_ca_multi_field_engine.H.
|
inline |
Build with a default-constructed neighbourhood.
Definition at line 183 of file tpl_ca_multi_field_engine.H.
|
inlinenoexcept |
Definition at line 201 of file tpl_ca_multi_field_engine.H.
References Aleph::CA::Multi_Field_Engine< Lattice, Rule, Neighborhood >::cur_, and Aleph::CA::Lattice< Storage, Boundary >::extents().
|
inlinenoexcept |
Definition at line 189 of file tpl_ca_multi_field_engine.H.
References Aleph::CA::Multi_Field_Engine< Lattice, Rule, Neighborhood >::cur_.
|
inlineprivate |
Definition at line 271 of file tpl_ca_multi_field_engine.H.
References Aleph::CA::Multi_Field_Engine< Lattice, Rule, Neighborhood >::cur_, k, Aleph::CA::Multi_Field_Engine< Lattice, Rule, Neighborhood >::rank, and Aleph::CA::Lattice< Storage, Boundary >::size().
Referenced by Aleph::CA::Multi_Field_Engine< Lattice, Rule, Neighborhood >::step().
|
inlinestaticprivate |
Definition at line 155 of file tpl_ca_multi_field_engine.H.
References Aleph::CA::Multi_Field_Engine< Lattice, Rule, Neighborhood >::neighbour_count.
Referenced by Aleph::CA::Multi_Field_Engine< Lattice, Rule, Neighborhood >::step().
|
inline |
Register a hook fired after every step().
Definition at line 215 of file tpl_ca_multi_field_engine.H.
References Aleph::CA::Multi_Field_Engine< Lattice, Rule, Neighborhood >::post_hook_.
|
inline |
Register a hook fired before every step().
Definition at line 208 of file tpl_ca_multi_field_engine.H.
References Aleph::CA::Multi_Field_Engine< Lattice, Rule, Neighborhood >::pre_hook_.
|
inline |
Run several steps.
| [in] | steps | number of consecutive step() calls. |
| Any | exception propagated by step(). |
Definition at line 263 of file tpl_ca_multi_field_engine.H.
References Aleph::CA::Multi_Field_Engine< Lattice, Rule, Neighborhood >::step(), and steps.
Referenced by main().
|
inline |
Apply the multi-field rule to every cell once and swap buffers.
Per-field neighbour values are gathered into stack arrays whose sizes are fixed at compile time by Neighborhood::size_v.
| Any | exception propagated by the rule, the lattice or the hooks. |
Definition at line 232 of file tpl_ca_multi_field_engine.H.
References Aleph::blossom_maximum_cardinality_matching(), Aleph::CA::ca_mf_engine_detail::build_views(), Aleph::CA::Multi_Field_Engine< Lattice, Rule, Neighborhood >::cur_, Aleph::CA::Multi_Field_Engine< Lattice, Rule, Neighborhood >::iterate_lattice(), Aleph::CA::Multi_Field_Engine< Lattice, Rule, Neighborhood >::make_buffers(), Aleph::CA::Multi_Field_Engine< Lattice, Rule, Neighborhood >::nh_, Aleph::CA::Multi_Field_Engine< Lattice, Rule, Neighborhood >::nxt_, Aleph::CA::Multi_Field_Engine< Lattice, Rule, Neighborhood >::post_hook_, Aleph::CA::Multi_Field_Engine< Lattice, Rule, Neighborhood >::pre_hook_, Aleph::CA::Multi_Field_Engine< Lattice, Rule, Neighborhood >::rule_, Aleph::CA::Multi_Field_Engine< Lattice, Rule, Neighborhood >::step_count_, Aleph::CA::Lattice< Storage, Boundary >::swap(), and Aleph::CA::Multi_Field_Engine< Lattice, Rule, Neighborhood >::write_cell().
Referenced by main(), Aleph::CA::Multi_Field_Engine< Lattice, Rule, Neighborhood >::run(), TEST(), and TEST().
|
inlinenoexcept |
Definition at line 195 of file tpl_ca_multi_field_engine.H.
References Aleph::CA::Multi_Field_Engine< Lattice, Rule, Neighborhood >::step_count_.
|
inlineprivate |
Definition at line 162 of file tpl_ca_multi_field_engine.H.
References Aleph::blossom_maximum_cardinality_matching(), and Aleph::CA::Multi_Field_Engine< Lattice, Rule, Neighborhood >::nxt_.
Referenced by Aleph::CA::Multi_Field_Engine< Lattice, Rule, Neighborhood >::step().
|
private |
Definition at line 146 of file tpl_ca_multi_field_engine.H.
Referenced by Aleph::CA::Multi_Field_Engine< Lattice, Rule, Neighborhood >::extents(), Aleph::CA::Multi_Field_Engine< Lattice, Rule, Neighborhood >::frame(), Aleph::CA::Multi_Field_Engine< Lattice, Rule, Neighborhood >::iterate_lattice(), and Aleph::CA::Multi_Field_Engine< Lattice, Rule, Neighborhood >::step().
|
staticconstexpr |
Definition at line 139 of file tpl_ca_multi_field_engine.H.
|
staticconstexpr |
Definition at line 140 of file tpl_ca_multi_field_engine.H.
Referenced by Aleph::CA::Multi_Field_Engine< Lattice, Rule, Neighborhood >::make_buffers().
|
private |
Definition at line 149 of file tpl_ca_multi_field_engine.H.
Referenced by Aleph::CA::Multi_Field_Engine< Lattice, Rule, Neighborhood >::step().
|
private |
Definition at line 147 of file tpl_ca_multi_field_engine.H.
Referenced by Aleph::CA::Multi_Field_Engine< Lattice, Rule, Neighborhood >::step(), and Aleph::CA::Multi_Field_Engine< Lattice, Rule, Neighborhood >::write_cell().
|
private |
Definition at line 151 of file tpl_ca_multi_field_engine.H.
Referenced by Aleph::CA::Multi_Field_Engine< Lattice, Rule, Neighborhood >::on_post_step(), and Aleph::CA::Multi_Field_Engine< Lattice, Rule, Neighborhood >::step().
|
private |
Definition at line 150 of file tpl_ca_multi_field_engine.H.
Referenced by Aleph::CA::Multi_Field_Engine< Lattice, Rule, Neighborhood >::on_pre_step(), and Aleph::CA::Multi_Field_Engine< Lattice, Rule, Neighborhood >::step().
|
staticconstexpr |
Definition at line 138 of file tpl_ca_multi_field_engine.H.
Referenced by Aleph::CA::Multi_Field_Engine< Lattice, Rule, Neighborhood >::iterate_lattice().
|
private |
Definition at line 148 of file tpl_ca_multi_field_engine.H.
Referenced by Aleph::CA::Multi_Field_Engine< Lattice, Rule, Neighborhood >::step().
|
private |
Definition at line 152 of file tpl_ca_multi_field_engine.H.
Referenced by Aleph::CA::Multi_Field_Engine< Lattice, Rule, Neighborhood >::step(), and Aleph::CA::Multi_Field_Engine< Lattice, Rule, Neighborhood >::steps_run().