Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields > Class Template Reference

Multi-field lattice with selectable storage layout. More...

#include <tpl_ca_multi_field_lattice.H>

Collaboration diagram for Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >:
[legend]

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_ {}
 

Detailed Description

template<typename Layout, typename Boundary, std::size_t Rank, typename... Fields>
class Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >

Multi-field lattice with selectable storage layout.

Template Parameters
LayoutLayout_AoS or Layout_SoA.
Boundaryboundary policy shared by every field (OpenBoundary, ToroidalBoundary, ReflectiveBoundary, NeumannBoundary, ConstantBoundary<T, V>).
Rankcompile-time lattice dimension (1, 2 or 3).
Fieldsper-cell field types. Must satisfy CellState.

Definition at line 128 of file tpl_ca_multi_field_lattice.H.

Member Typedef Documentation

◆ aos_lattice_type

template<typename Layout , typename Boundary , std::size_t Rank, typename... Fields>
using Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >::aos_lattice_type = ca_mf_detail::aos_lattice<Rank, Boundary, Fields...>
private

Definition at line 158 of file tpl_ca_multi_field_lattice.H.

◆ boundary_type

template<typename Layout , typename Boundary , std::size_t Rank, typename... Fields>
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.

◆ coord_type

template<typename Layout , typename Boundary , std::size_t Rank, typename... Fields>
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.

◆ extents_type

template<typename Layout , typename Boundary , std::size_t Rank, typename... Fields>
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.

◆ field_type

template<typename Layout , typename Boundary , std::size_t Rank, typename... Fields>
template<std::size_t I>
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.

◆ field_types

template<typename Layout , typename Boundary , std::size_t Rank, typename... Fields>
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_type

template<typename Layout , typename Boundary , std::size_t Rank, typename... Fields>
using Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >::layout_type = Layout

Layout tag (Layout_AoS or Layout_SoA).

Definition at line 137 of file tpl_ca_multi_field_lattice.H.

◆ soa_storage_type

template<typename Layout , typename Boundary , std::size_t Rank, typename... Fields>
using Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >::soa_storage_type = ca_mf_detail::soa_storages<Rank, Boundary, Fields...>
private

Definition at line 157 of file tpl_ca_multi_field_lattice.H.

◆ storage_type

template<typename Layout , typename Boundary , std::size_t Rank, typename... Fields>
using Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >::storage_type = std::conditional_t<std::is_same_v<Layout, Layout_SoA>, soa_storage_type, aos_lattice_type>
private

Definition at line 160 of file tpl_ca_multi_field_lattice.H.

Constructor & Destructor Documentation

◆ Multi_Field_Lattice() [1/3]

template<typename Layout , typename Boundary , std::size_t Rank, typename... Fields>
Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >::Multi_Field_Lattice ( )
default

Build an empty multi-field lattice.

◆ Multi_Field_Lattice() [2/3]

template<typename Layout , typename Boundary , std::size_t Rank, typename... Fields>
Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >::Multi_Field_Lattice ( const extents_type &  ext)
inlineexplicit

Build a multi-field lattice with the given extents.

Every field is value-initialised (default Field{}).

Parameters
[in]extper-axis sizes.
Exceptions
std::bad_allocon 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_.

◆ Multi_Field_Lattice() [3/3]

template<typename Layout , typename Boundary , std::size_t Rank, typename... Fields>
Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >::Multi_Field_Lattice ( const extents_type &  ext,
const std::tuple< Fields... > &  init 
)
inline

Build a multi-field lattice with the given extents and per-field initial values.

Parameters
[in]extper-axis sizes.
[in]initper-field initial values, one per field, in declaration order.
Exceptions
std::bad_allocon 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_.

Member Function Documentation

◆ at()

template<typename Layout , typename Boundary , std::size_t Rank, typename... Fields>
template<std::size_t I>
field_type< I > Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >::at ( const coord_type &  c) const
inline

Strict read access to field I.

Template Parameters
Ifield index in [0, field_count).
Parameters
[in]ccell coordinate.
Returns
value of field I at c.
Exceptions
std::out_of_rangeif 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_.

◆ at_cell()

template<typename Layout , typename Boundary , std::size_t Rank, typename... Fields>
std::tuple< Fields... > Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >::at_cell ( const coord_type &  c) const
inline

Read every field at coordinate c as a tuple.

Parameters
[in]ccell coordinate.
Returns
tuple of field values.
Exceptions
std::out_of_rangeif 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_.

◆ at_cell_impl()

template<typename Layout , typename Boundary , std::size_t Rank, typename... Fields>
template<std::size_t... I>
std::tuple< Fields... > Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >::at_cell_impl ( const coord_type &  c,
ca_mf_detail::index_seq< I... >   
) const
inlineprivate

◆ at_safe()

template<typename Layout , typename Boundary , std::size_t Rank, typename... Fields>
template<std::size_t I>
field_type< I > Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >::at_safe ( const coord_type &  c) const
inline

Boundary-aware read access to field I.

Template Parameters
Ifield index.
Parameters
[in]cpossibly out-of-range coordinate.
Returns
field 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_.

◆ dimension()

template<typename Layout , typename Boundary , std::size_t Rank, typename... Fields>
static constexpr std::size_t Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >::dimension ( )
inlinestaticconstexprnoexcept

◆ extents()

template<typename Layout , typename Boundary , std::size_t Rank, typename... Fields>
const extents_type & Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >::extents ( ) const
inlinenoexcept

◆ field() [1/2]

template<typename Layout , typename Boundary , std::size_t Rank, typename... Fields>
template<std::size_t I>
requires std::is_same_v<Layout, Layout_SoA>
auto & Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >::field ( )
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.

Template Parameters
Ifield index.
Returns
reference to the per-field lattice.

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().

◆ field() [2/2]

template<typename Layout , typename Boundary , std::size_t Rank, typename... Fields>
template<std::size_t I>
requires std::is_same_v<Layout, Layout_SoA>
const auto & Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >::field ( ) const
inline

Const reference to the underlying single-field lattice for field I (SoA only).

Template Parameters
Ifield 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_.

◆ fill()

template<typename Layout , typename Boundary , std::size_t Rank, typename... Fields>
void Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >::fill ( const std::tuple< Fields... > &  init)
inline

Set every cell to the supplied per-field values.

Parameters
[in]inittuple 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_.

◆ fill_impl()

template<typename Layout , typename Boundary , std::size_t Rank, typename... Fields>
template<std::size_t... I>
void Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >::fill_impl ( const std::tuple< Fields... > &  init,
ca_mf_detail::index_seq< I... >   
)
inlineprivate

◆ make_soa()

template<typename Layout , typename Boundary , std::size_t Rank, typename... Fields>
template<std::size_t... I>
static soa_storage_type Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >::make_soa ( const extents_type &  ext,
ca_mf_detail::index_seq< I... >   
)
inlinestaticprivate

◆ make_soa_init()

template<typename Layout , typename Boundary , std::size_t Rank, typename... Fields>
template<std::size_t... I>
static soa_storage_type Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >::make_soa_init ( const extents_type &  ext,
const std::tuple< Fields... > &  init,
ca_mf_detail::index_seq< I... >   
)
inlinestaticprivate

◆ set()

template<typename Layout , typename Boundary , std::size_t Rank, typename... Fields>
template<std::size_t I, typename V >
void Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >::set ( const coord_type &  c,
const V &  v 
)
inline

Strict write access to field I.

Template Parameters
Ifield index.
Parameters
[in]ccell coordinate.
[in]vnew value for field I at c.
Exceptions
std::out_of_rangeif 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_.

Referenced by TEST(), TEST(), and TEST().

◆ set_cell()

template<typename Layout , typename Boundary , std::size_t Rank, typename... Fields>
void Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >::set_cell ( const coord_type &  c,
const std::tuple< Fields... > &  cell 
)
inline

Strict write of every field at coordinate c.

Parameters
[in]ccell coordinate.
[in]celltuple of new field values.
Exceptions
std::out_of_rangeif 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_.

◆ set_cell_impl()

template<typename Layout , typename Boundary , std::size_t Rank, typename... Fields>
template<std::size_t... I>
void Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >::set_cell_impl ( const coord_type &  c,
const std::tuple< Fields... > &  cell,
ca_mf_detail::index_seq< I... >   
)
inlineprivate

◆ size() [1/2]

template<typename Layout , typename Boundary , std::size_t Rank, typename... Fields>
ca_size_t Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >::size ( ) const
inlinenoexcept

◆ size() [2/2]

template<typename Layout , typename Boundary , std::size_t Rank, typename... Fields>
ca_size_t Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >::size ( const std::size_t  d) const
inline

◆ swap()

◆ swap_field()

template<typename Layout , typename Boundary , std::size_t Rank, typename... Fields>
template<std::size_t I>
requires std::is_same_v<Layout, Layout_SoA>
void Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >::swap_field ( Multi_Field_Lattice< Layout, Boundary, Rank, Fields > &  other)
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.

Template Parameters
Ifield index.
Parameters
[in,out]otherother 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().

Member Data Documentation

◆ extents_

◆ field_count

◆ rank

template<typename Layout , typename Boundary , std::size_t Rank, typename... Fields>
constexpr std::size_t Aleph::CA::Multi_Field_Lattice< Layout, Boundary, Rank, Fields >::rank = Rank
staticconstexpr

Lattice dimension.

Definition at line 147 of file tpl_ca_multi_field_lattice.H.

◆ store_


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