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

Description

template<typename Target>
struct hm3::amr::state< Target >

Adaptive mesh refinement algorithm.

Public Member Functions

node * find (amr_node_idx n) noexcept
 Finds a node in a sorted node_data container using binary search.
 
node const * find (amr_node_idx n) const noexcept
 Finds a node in a sorted node_data container using binary search.
 
node_data const & data () const noexcept
 Returns the node data (useful for visualizing/debugging)
 
template<typename Action >
void compute_actions (Action &&action)
 Computes the actions on every node and sorts them.
 
bool enforce_2_to_1_ratio_step ()
 Enforces 2:1 across all neighbor directions (single step) More...
 
template<typename AfterIt = std::function<void()>>
int enforce_2_to_1_ratio (AfterIt &&after_it=[](){})
 Enforces 2:1 across all neighbor directions. More...
 
auto apply ()
 Applies the refinement and coarsening to the target's grid.
 
template<typename Action , typename AfterIt = std::function<void()>>
bool adapt (Action &&action, AfterIt &&after_it=[](){})
 Adapts the target t.
 

Member Function Documentation

template<typename Target >
bool hm3::amr::state< Target >::enforce_2_to_1_ratio_step ( )

Enforces 2:1 across all neighbor directions (single step)

Returns
True if the algorithm finishes
Warning
This performs a single step of the 2:1 algorithm, which is an iterative algorithm.

Step 1: Remove coarsening flags (sibling group local):

  • Only those sibling groups where all siblings:
    • have no children, and
    • are marked for coarsening Can be coarsened (set them to nothing otherwise)

      Step 2: Remove coarsening flags (between sibling groups):

  • A sibling group marked for coarsening cannot have a neighbor that is marked for refinement since this would break 2:1

note: if a node is marked for coarsening here, all its siblings are marked for coarsening too due to Step 1

Or if any of the siblings is at a level greater than the node but not marked for coarsening

Step 3: Balance future refined nodes Every neighbor of a marked-for-refinement node that it is located at its parent level must also be marked for refinement to ensure 2:1

template<typename Target >
template<typename AfterIt = std::function<void()>>
int hm3::amr::state< Target >::enforce_2_to_1_ratio ( AfterIt &&  after_it = []() {})

Enforces 2:1 across all neighbor directions.

This is an iterative process