HM3
Hierarchical Multi-physics Multi-scale Methods
 All Classes Namespaces Functions Variables Typedefs Enumerations Pages
hm3::solver::state::grid< Nd > Struct Template Reference

Description

template<uint_t Nd>
struct hm3::solver::state::grid< Nd >

Stores a solver grid and maintains it in sync with the tree.

For each solver grid node, it stores its corresponding tree node (if any), and it also stores the solver node within the tree.

Note
The solver grid is allowed to have holes in it.
Solver grid nodes do not necessarily need to be part of the grid tree. For example ghost nodes might not exist within the tree.

Instances and minimal complete definitions

struct  refine_t
 RAII object for refining grid nodes. More...
 

Public Member Functions

grid_node_idx capacity () const noexcept
 Maximum number of grid nodes that can be stored.
 
grid_node_idx size () const noexcept
 Number of grid nodes stored.
 
tree_t const & tree () const noexcept
 Access the tree.
 
tree_ttree () noexcept
 Access the tree.
 
grid_idx idx () const noexcept
 Solver grid idx.
 
auto data () const noexcept
 Solver grid data.
 
grid_node_idx in_tree (tree_node_idx i) const noexcept
 Solver grid node at tree node i.
 
grid_node_idx & in_tree (tree_node_idx i) noexcept
 Solver grid node index at tree node i.
 
tree_node_idx & tree_node (grid_node_idx n) noexcept
 Tree node of grid node n.
 
tree_node_idx tree_node (grid_node_idx n) const noexcept
 Tree node of grid node n.
 
tree_node_idx parent (grid_node_idx n) const noexcept
 Parent tree node of grid node n.
 
auto children (grid_node_idx n) const noexcept
 Children of grid node n (in tree nodes)
 
auto tree_siblings (grid_node_idx n) const noexcept
 Siblings of grid node n in tree.
 
auto siblings (grid_node_idx n) const noexcept
 Siblings of grid node n in grid.
 
auto tree_neighbors (grid_node_idx n) const noexcept
 Neighbors of grid node n in tree.
 
auto neighbors (grid_node_idx n) const noexcept
 Neighbors of grid node n in grid.
 
auto level (grid_node_idx n) const noexcept
 Level of grid node n.
 
template<typename At >
void assert_within_capacity (grid_node_idx n, At &&at_) const noexcept
 Asserts that the grid node n is within the capacity of the storage.
 
template<typename At >
void assert_in_use (grid_node_idx n, At &&at_) const noexcept
 Asserts that the grid node n is in use (i.e. it is not a free node)
 
bool is_compact () const noexcept
 Are the grid nodes contiguous.
 
void swap (grid_node_idx i, grid_node_idx j)
 Swaps the positions of two grid nodes. More...
 
auto operator() () const noexcept
 Range of solver grid nodes (fast, requires contiguous solver nodes)
 
auto in_use () const noexcept
 Range of solver grid nodes in use (slow, doesn't require contiguous nodes)
 
auto to_tree_nodes () const noexcept
 Transform a range of grid nodes into a range of tree nodes.
 
grid_node_idx push (tree_node_idx n)
 Push grid node into solver nodes and get solver node. More...
 
void pop (grid_node_idx sn)
 Pop solver node sn. More...
 
auto coordinates (grid_node_idx n) const noexcept
 Coordinates of grid node n.
 
refine_t refine (grid_node_idx n) noexcept
 Refine grid node n.
 
coarsen_t coarsen (grid_node_idx n) noexcept
 Coarsens the parent of node n (i.e. the siblings of n)
 
void reset ()
 Reset.
 
void resize (grid_node_idx s) noexcept
 Resizes a zero sized grid to have s grid nodes.
 

Member Function Documentation

template<uint_t Nd>
void hm3::solver::state::grid< Nd >::swap ( grid_node_idx  i,
grid_node_idx  j 
)

Swaps the positions of two grid nodes.

This swaps their position in the tree_node_ids_ container, it swaps the is_free_, and it updates the back links in the tree to to their new positions.

template<uint_t Nd>
grid_node_idx hm3::solver::state::grid< Nd >::push ( tree_node_idx  n)

Push grid node into solver nodes and get solver node.

TODO: this should probably throw to allow writing a checkpoint before dying

Referenced by hm3::solver::state::grid< dimension()>::coarsen(), and hm3::solver::state::grid< dimension()>::refine().

template<uint_t Nd>
void hm3::solver::state::grid< Nd >::pop ( grid_node_idx  sn)

Pop solver node sn.

Todo:
Provide a way to pop a sibling group (since this is typically what AMR does). Maybe one should provide this in grid::adaptor::multi as well.