Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
Aleph::CA::Multi_Field_Engine< Lattice, Rule, Neighborhood > Class Template Reference

Synchronous double-buffered engine for multi-field lattices. More...

#include <tpl_ca_multi_field_engine.H>

Collaboration diagram for Aleph::CA::Multi_Field_Engine< Lattice, Rule, Neighborhood >:
[legend]

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
 

Detailed Description

template<typename Lattice, typename Rule, typename Neighborhood>
class Aleph::CA::Multi_Field_Engine< Lattice, Rule, Neighborhood >

Synchronous double-buffered engine for multi-field lattices.

Template Parameters
LatticeMulti_Field_Lattice<...> instance.
Rulemulti-field rule (MultiFieldRuleLike).
Neighborhoodmono-field neighbourhood applied uniformly to every field (NeighborhoodLike).
Complexity
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.

Member Typedef Documentation

◆ coord_type

◆ extents_type

◆ fields_tuple

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.

◆ hook_type

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.

◆ lattice_type

◆ neighborhood_type

Definition at line 133 of file tpl_ca_multi_field_engine.H.

◆ rule_type

Definition at line 132 of file tpl_ca_multi_field_engine.H.

Constructor & Destructor Documentation

◆ Multi_Field_Engine() [1/2]

Aleph::CA::Multi_Field_Engine< Lattice, Rule, Neighborhood >::Multi_Field_Engine ( Lattice  initial,
Rule  r,
Neighborhood  n 
)
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.

Parameters
[in]initialinitial lattice (consumed by move).
[in]rrule instance (consumed by move).
[in]nneighbourhood instance (consumed by move).
Exceptions
std::bad_allocon next-buffer allocation failure.

Definition at line 178 of file tpl_ca_multi_field_engine.H.

◆ Multi_Field_Engine() [2/2]

Aleph::CA::Multi_Field_Engine< Lattice, Rule, Neighborhood >::Multi_Field_Engine ( Lattice  initial,
Rule  r 
)
inline

Build with a default-constructed neighbourhood.

Definition at line 183 of file tpl_ca_multi_field_engine.H.

Member Function Documentation

◆ extents()

◆ frame()

const Lattice & Aleph::CA::Multi_Field_Engine< Lattice, Rule, Neighborhood >::frame ( ) const
inlinenoexcept
Returns
the current frame.

Definition at line 189 of file tpl_ca_multi_field_engine.H.

References Aleph::CA::Multi_Field_Engine< Lattice, Rule, Neighborhood >::cur_.

◆ iterate_lattice()

◆ make_buffers()

template<std::size_t... I>
static auto Aleph::CA::Multi_Field_Engine< Lattice, Rule, Neighborhood >::make_buffers ( std::index_sequence< I... >  )
inlinestaticprivate

◆ on_post_step()

template<typename F >
void Aleph::CA::Multi_Field_Engine< Lattice, Rule, Neighborhood >::on_post_step ( F &&  f)
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_.

◆ on_pre_step()

template<typename F >
void Aleph::CA::Multi_Field_Engine< Lattice, Rule, Neighborhood >::on_pre_step ( F &&  f)
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_.

◆ run()

void Aleph::CA::Multi_Field_Engine< Lattice, Rule, Neighborhood >::run ( const std::size_t  steps)
inline

Run several steps.

Parameters
[in]stepsnumber of consecutive step() calls.
Exceptions
Anyexception 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().

◆ step()

◆ steps_run()

std::size_t Aleph::CA::Multi_Field_Engine< Lattice, Rule, Neighborhood >::steps_run ( ) const
inlinenoexcept
Returns
the number of completed steps.

Definition at line 195 of file tpl_ca_multi_field_engine.H.

References Aleph::CA::Multi_Field_Engine< Lattice, Rule, Neighborhood >::step_count_.

◆ write_cell()

Member Data Documentation

◆ cur_

◆ field_count

constexpr std::size_t Aleph::CA::Multi_Field_Engine< Lattice, Rule, Neighborhood >::field_count = Lattice::field_count
staticconstexpr

Definition at line 139 of file tpl_ca_multi_field_engine.H.

◆ neighbour_count

constexpr std::size_t Aleph::CA::Multi_Field_Engine< Lattice, Rule, Neighborhood >::neighbour_count = Neighborhood::size_v
staticconstexpr

◆ nh_

◆ nxt_

◆ post_hook_

◆ pre_hook_

◆ rank

◆ rule_

◆ step_count_


The documentation for this class was generated from the following file: