|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
Multi-field lattice with selectable storage layout. More...
#include <tpl_ca_multi_field_lattice.H>
Public Types | |
| using | layout_type = Layout |
Layout tag (Layout_AoS or Layout_SoA). | |
| using | boundary_type = Boundary |
| Boundary policy. | |
| using | coord_type = Coord_Vec< Rank > |
| Coordinate type. | |
| using | extents_type = std::array< ca_size_t, Rank > |
| Per-axis extents type. | |
| using | field_types = std::tuple< Fields... > |
| Compile-time tuple of field types. | |
| template<std::size_t I> | |
| using | field_type = std::tuple_element_t< I, field_types > |
Field type at index I. | |
Public Member Functions | |
| Multi_Field_Lattice ()=default | |
| Build an empty multi-field lattice. | |
| Multi_Field_Lattice (const extents_type &ext) | |
| Build a multi-field lattice with the given extents. | |
| Multi_Field_Lattice (const extents_type &ext, const std::tuple< Fields... > &init) | |
| Build a multi-field lattice with the given extents and per-field initial values. | |
| ca_size_t | size () const noexcept |
| Total cell count (product of extents). | |
| ca_size_t | size (const std::size_t d) const |
Extent along axis d (d < Rank). | |
| const extents_type & | extents () const noexcept |
| Per-axis extents. | |
| template<std::size_t I> | |
| field_type< I > | at (const coord_type &c) const |
Strict read access to field I. | |
| template<std::size_t I> | |
| field_type< I > | at_safe (const coord_type &c) const |
Boundary-aware read access to field I. | |
| template<std::size_t I, typename V > | |
| void | set (const coord_type &c, const V &v) |
Strict write access to field I. | |
| void | set_cell (const coord_type &c, const std::tuple< Fields... > &cell) |
Strict write of every field at coordinate c. | |
| std::tuple< Fields... > | at_cell (const coord_type &c) const |
Read every field at coordinate c as a tuple. | |
| template<std::size_t I> requires std::is_same_v<Layout, Layout_SoA> | |
| auto & | field () |
Mutable reference to the underlying single-field lattice for field I. | |
| template<std::size_t I> requires std::is_same_v<Layout, Layout_SoA> | |
| const auto & | field () const |
Const reference to the underlying single-field lattice for field I (SoA only). | |
| void | fill (const std::tuple< Fields... > &init) |
| Set every cell to the supplied per-field values. | |
| void | swap (Multi_Field_Lattice &other) noexcept |
| O(1) swap with another lattice of the same type. | |
| template<std::size_t I> requires std::is_same_v<Layout, Layout_SoA> | |
| void | swap_field (Multi_Field_Lattice &other) |
| Swap a single field's buffer with another lattice. | |
Static Public Member Functions | |
| static constexpr std::size_t | dimension () noexcept |
Static Public Attributes | |
| static constexpr std::size_t | field_count = sizeof...(Fields) |
| Number of fields. | |
| static constexpr std::size_t | rank = Rank |
| Lattice dimension. | |
Private Types | |
| using | soa_storage_type = ca_mf_detail::soa_storages< Rank, Boundary, Fields... > |
| using | aos_lattice_type = ca_mf_detail::aos_lattice< Rank, Boundary, Fields... > |
| using | storage_type = std::conditional_t< std::is_same_v< Layout, Layout_SoA >, soa_storage_type, aos_lattice_type > |
Private Member Functions | |
| template<std::size_t... I> | |
| void | set_cell_impl (const coord_type &c, const std::tuple< Fields... > &cell, ca_mf_detail::index_seq< I... >) |
| template<std::size_t... I> | |
| std::tuple< Fields... > | at_cell_impl (const coord_type &c, ca_mf_detail::index_seq< I... >) const |
| template<std::size_t... I> | |
| void | fill_impl (const std::tuple< Fields... > &init, ca_mf_detail::index_seq< I... >) |
Static Private Member Functions | |
| template<std::size_t... I> | |
| static soa_storage_type | make_soa (const extents_type &ext, ca_mf_detail::index_seq< I... >) |
| template<std::size_t... I> | |
| static soa_storage_type | make_soa_init (const extents_type &ext, const std::tuple< Fields... > &init, ca_mf_detail::index_seq< I... >) |
Private Attributes | |
| storage_type | store_ {} |
| extents_type | extents_ {} |
Multi-field lattice with selectable storage layout.
| Layout | Layout_AoS or Layout_SoA. |
| Boundary | boundary policy shared by every field (OpenBoundary, ToroidalBoundary, ReflectiveBoundary, NeumannBoundary, ConstantBoundary<T, V>). |
| Rank | compile-time lattice dimension (1, 2 or 3). |
| Fields | per-cell field types. Must satisfy CellState. |
Definition at line 128 of file tpl_ca_multi_field_lattice.H.
|
private |
Definition at line 158 of file tpl_ca_multi_field_lattice.H.
| using Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >::boundary_type = Boundary |
Boundary policy.
Definition at line 139 of file tpl_ca_multi_field_lattice.H.
| using Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >::coord_type = Coord_Vec<Rank> |
Coordinate type.
Definition at line 141 of file tpl_ca_multi_field_lattice.H.
| using Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >::extents_type = std::array<ca_size_t, Rank> |
Per-axis extents type.
Definition at line 143 of file tpl_ca_multi_field_lattice.H.
| using Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >::field_type = std::tuple_element_t<I, field_types> |
Field type at index I.
Definition at line 153 of file tpl_ca_multi_field_lattice.H.
| using Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >::field_types = std::tuple<Fields...> |
Compile-time tuple of field types.
Definition at line 149 of file tpl_ca_multi_field_lattice.H.
Layout tag (Layout_AoS or Layout_SoA).
Definition at line 137 of file tpl_ca_multi_field_lattice.H.
|
private |
Definition at line 157 of file tpl_ca_multi_field_lattice.H.
|
private |
Definition at line 160 of file tpl_ca_multi_field_lattice.H.
|
default |
Build an empty multi-field lattice.
|
inlineexplicit |
Build a multi-field lattice with the given extents.
Every field is value-initialised (default Field{}).
| [in] | ext | per-axis sizes. |
| std::bad_alloc | on allocation failure. |
Definition at line 195 of file tpl_ca_multi_field_lattice.H.
References Aleph::blossom_maximum_cardinality_matching(), Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >::make_soa(), and Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >::store_.
|
inline |
Build a multi-field lattice with the given extents and per-field initial values.
| [in] | ext | per-axis sizes. |
| [in] | init | per-field initial values, one per field, in declaration order. |
| std::bad_alloc | on allocation failure. |
Definition at line 211 of file tpl_ca_multi_field_lattice.H.
References Aleph::blossom_maximum_cardinality_matching(), Aleph::init, Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >::make_soa_init(), and Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >::store_.
|
inline |
Strict read access to field I.
| I | field index in [0, field_count). |
| [in] | c | cell coordinate. |
I at c. | std::out_of_range | if c is out of range. |
Definition at line 261 of file tpl_ca_multi_field_lattice.H.
References Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >::field_count, Aleph::CA::I, and Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >::store_.
|
inline |
Read every field at coordinate c as a tuple.
| [in] | c | cell coordinate. |
| std::out_of_range | if c is out of range. |
Definition at line 325 of file tpl_ca_multi_field_lattice.H.
References Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >::at_cell_impl(), and Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >::store_.
|
inlineprivate |
Definition at line 419 of file tpl_ca_multi_field_lattice.H.
References Aleph::blossom_maximum_cardinality_matching(), and Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >::store_.
Referenced by Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >::at_cell().
|
inline |
Boundary-aware read access to field I.
| I | field index. |
| [in] | c | possibly out-of-range coordinate. |
I value resolved through the boundary policy. Definition at line 276 of file tpl_ca_multi_field_lattice.H.
References Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >::field_count, Aleph::CA::I, and Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >::store_.
|
inlinestaticconstexprnoexcept |
Definition at line 223 of file tpl_ca_multi_field_lattice.H.
References Aleph::blossom_maximum_cardinality_matching().
|
inlinenoexcept |
Per-axis extents.
Definition at line 245 of file tpl_ca_multi_field_lattice.H.
References Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >::extents_.
|
inline |
Mutable reference to the underlying single-field lattice for field I.
Available only for the SoA layout: each field owns its own contiguous buffer wrapped as a regular Lattice<Storage, Boundary> that any mono-field engine accepts.
| I | field index. |
Definition at line 349 of file tpl_ca_multi_field_lattice.H.
References Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >::field_count, Aleph::CA::I, and Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >::store_.
Referenced by TEST().
|
inline |
Const reference to the underlying single-field lattice for field I (SoA only).
| I | field index. |
Definition at line 361 of file tpl_ca_multi_field_lattice.H.
References Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >::field_count, Aleph::CA::I, and Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >::store_.
|
inline |
Set every cell to the supplied per-field values.
| [in] | init | tuple of per-field constant values. |
Definition at line 375 of file tpl_ca_multi_field_lattice.H.
References Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >::fill_impl(), Aleph::init, and Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >::store_.
|
inlineprivate |
Definition at line 425 of file tpl_ca_multi_field_lattice.H.
References Aleph::init, and Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >::store_.
Referenced by Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >::fill().
|
inlinestaticprivate |
Definition at line 170 of file tpl_ca_multi_field_lattice.H.
References Aleph::blossom_maximum_cardinality_matching().
Referenced by Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >::Multi_Field_Lattice().
|
inlinestaticprivate |
Definition at line 176 of file tpl_ca_multi_field_lattice.H.
References Aleph::blossom_maximum_cardinality_matching(), and Aleph::init.
Referenced by Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >::Multi_Field_Lattice().
|
inline |
Strict write access to field I.
| I | field index. |
| [in] | c | cell coordinate. |
| [in] | v | new value for field I at c. |
| std::out_of_range | if c is out of range. |
Definition at line 292 of file tpl_ca_multi_field_lattice.H.
References Aleph::blossom_maximum_cardinality_matching(), cell(), Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >::field_count, Aleph::CA::I, and Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >::store_.
|
inline |
Strict write of every field at coordinate c.
| [in] | c | cell coordinate. |
| [in] | cell | tuple of new field values. |
| std::out_of_range | if c is out of range. |
Definition at line 312 of file tpl_ca_multi_field_lattice.H.
References cell(), Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >::set_cell_impl(), and Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >::store_.
|
inlineprivate |
Definition at line 411 of file tpl_ca_multi_field_lattice.H.
References cell(), and Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >::store_.
Referenced by Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >::set_cell().
|
inlinenoexcept |
Total cell count (product of extents).
Definition at line 229 of file tpl_ca_multi_field_lattice.H.
References Aleph::blossom_maximum_cardinality_matching(), and Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >::extents_.
|
inline |
Extent along axis d (d < Rank).
Definition at line 238 of file tpl_ca_multi_field_lattice.H.
References ah_out_of_range_error_if, Aleph::blossom_maximum_cardinality_matching(), and Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >::extents_.
|
inlinenoexcept |
O(1) swap with another lattice of the same type.
Definition at line 384 of file tpl_ca_multi_field_lattice.H.
References Aleph::blossom_maximum_cardinality_matching(), Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >::extents_, Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >::store_, and Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >::swap().
Referenced by Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >::swap(), and Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >::swap_field().
|
inline |
Swap a single field's buffer with another lattice.
Available only for SoA: lets the engine perform per-field double buffering without touching the other fields.
| I | field index. |
| [in,out] | other | other lattice (same type). |
Definition at line 400 of file tpl_ca_multi_field_lattice.H.
References Aleph::blossom_maximum_cardinality_matching(), Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >::field_count, Aleph::CA::I, Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >::store_, and Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >::swap().
|
private |
Definition at line 164 of file tpl_ca_multi_field_lattice.H.
Referenced by Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >::extents(), Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >::size(), Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >::size(), and Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >::swap().
|
staticconstexpr |
Number of fields.
Definition at line 145 of file tpl_ca_multi_field_lattice.H.
Referenced by Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >::at(), Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >::at_safe(), Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >::field(), Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >::field(), Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >::set(), and Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >::swap_field().
|
staticconstexpr |
Lattice dimension.
Definition at line 147 of file tpl_ca_multi_field_lattice.H.
|
private |
Definition at line 163 of file tpl_ca_multi_field_lattice.H.
Referenced by Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >::Multi_Field_Lattice(), Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >::Multi_Field_Lattice(), Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >::at(), Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >::at_cell(), Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >::at_cell_impl(), Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >::at_safe(), Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >::field(), Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >::field(), Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >::fill(), Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >::fill_impl(), Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >::set(), Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >::set_cell(), Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >::set_cell_impl(), Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >::swap(), and Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >::swap_field().