SpECTRE  v2024.09.29
Adaptive Mesh Refinement

Functions and classes specific to hp-adaptive mesh refinement. More...

Namespaces

namespace  amr
 Items for adaptive mesh refinement.
 
namespace  amr::Criteria
 Criteria for deciding how a mesh should be adapted.
 
namespace  amr::Events
 Events for adaptive mesh refinement
 

Classes

class  amr::Criterion
 Base class for something that determines how an adaptive mesh should be changed. More...
 
class  amr::Events::RefineMesh
 Performs p-refinement on the domain. More...
 

Enumerations

enum class  amr::Flag {
  amr::Flag::Undefined , amr::Flag::Join , amr::Flag::DecreaseResolution , amr::Flag::DoNothing ,
  amr::Flag::IncreaseResolution , amr::Flag::Split
}
 Flags that represent decisions about mesh refinement. More...
 
enum class  amr::Isotropy { amr::Isotropy::Anisotropic , amr::Isotropy::Isotropic }
 Isotropy of adaptive mesh refinement. More...
 

Functions

template<size_t VolumeDim>
std::array< size_t, VolumeDim > amr::desired_refinement_levels (const ElementId< VolumeDim > &id, const std::array< Flag, VolumeDim > &flags)
 Computes the desired refinement level of the Element with ElementId id given the desired amr::Flags flags
 
template<size_t VolumeDim>
std::array< size_t, VolumeDim > amr::desired_refinement_levels_of_neighbor (const ElementId< VolumeDim > &neighbor_id, const std::array< Flag, VolumeDim > &neighbor_flags, const OrientationMap< VolumeDim > &orientation)
 Computes the desired refinement level of a neighboring Element with ElementId neighbor_id given its desired amr::Flags neighbor_flags taking into account the OrientationMap orientation of the neighbor. More...
 
template<size_t VolumeDim>
boost::rational< size_t > amr::fraction_of_block_volume (const ElementId< VolumeDim > &element_id)
 Fraction of the logical volume of a block covered by an element. More...
 
template<size_t VolumeDim>
bool amr::has_potential_sibling (const ElementId< VolumeDim > &element_id, const Direction< VolumeDim > &direction)
 Whether or not the Element with element_id can have a sibling in the given direction
 
template<size_t VolumeDim>
ElementId< VolumeDim > amr::id_of_parent (const ElementId< VolumeDim > &element_id, const std::array< Flag, VolumeDim > &flags)
 Returns the ElementId of the parent of the Element with element_id using the refinement flags associated with element_id More...
 
template<size_t VolumeDim>
std::vector< ElementId< VolumeDim > > amr::ids_of_children (const ElementId< VolumeDim > &element_id, const std::array< Flag, VolumeDim > &flags)
 Returns the ElementIds of the children of the Element with element_id using the refinement flags associated with element_id More...
 
template<size_t VolumeDim>
std::deque< ElementId< VolumeDim > > amr::ids_of_joining_neighbors (const Element< VolumeDim > &element, const std::array< Flag, VolumeDim > &flags)
 The ElementIds of the neighbors of element that will join with it given refinement flags More...
 
template<size_t VolumeDim>
bool amr::is_child_that_creates_parent (const ElementId< VolumeDim > &element_id, const std::array< Flag, VolumeDim > &flags)
 Whether or not the Element is the child that should create the parent Element when joining elements. More...
 
template<size_t VolumeDim>
bool amr::prevent_element_from_joining_while_splitting (gsl::not_null< std::array< Flag, VolumeDim > * > flags)
 Prevent an Element from splitting in one dimension, while joining in another. More...
 
template<size_t VolumeDim>
std::pair< DirectionMap< VolumeDim, Neighbors< VolumeDim > >, DirectionalIdMap< VolumeDim, Mesh< VolumeDim > > > amr::neighbors_of_child (const Element< VolumeDim > &parent, const Info< VolumeDim > &parent_info, const std::unordered_map< ElementId< VolumeDim >, Info< VolumeDim > > &parent_neighbor_info, const ElementId< VolumeDim > &child_id)
 returns the neighbors and their Meshes of the Element with ElementId child_id, whose parent Element is parent which has Info parent_info and neighbor Info parent_neighbor_info
 
template<size_t VolumeDim>
std::pair< DirectionMap< VolumeDim, Neighbors< VolumeDim > >, DirectionalIdMap< VolumeDim, Mesh< VolumeDim > > > amr::neighbors_of_parent (const ElementId< VolumeDim > &parent_id, const std::vector< std::tuple< const Element< VolumeDim > &, const std::unordered_map< ElementId< VolumeDim >, Info< VolumeDim > > & > > &children_elements_and_neighbor_info)
 returns the neighbors and their Meshes of the Element with ElementId parent_id, that is created from its children_elements_and_neighbor_info
 
template<size_t VolumeDim>
std::unordered_map< ElementId< VolumeDim >, Mesh< VolumeDim > > amr::new_neighbor_ids (const ElementId< VolumeDim > &my_id, const Direction< VolumeDim > &direction, const Neighbors< VolumeDim > &previous_neighbors_in_direction, const std::unordered_map< ElementId< VolumeDim >, Info< VolumeDim > > &previous_neighbors_amr_info)
 returns the ElementId and Mesh of the new neighbors in the given direction of the Element whose ElementId is my_id given the previous_neighbors_in_direction and their amr::Info. More...
 
template<size_t VolumeDim>
bool amr::update_amr_decision (gsl::not_null< std::array< Flag, VolumeDim > * > my_current_amr_flags, const Element< VolumeDim > &element, const ElementId< VolumeDim > &neighbor_id, const std::array< Flag, VolumeDim > &neighbor_amr_flags, bool enforce_two_to_one_balance_in_normal_direction)
 Updates the AMR decisions my_current_amr_flags of the Element element based on the AMR decisions neighbor_amr_flags of a neighbor Element with ElementId neighbor_id. More...
 

Detailed Description

Functions and classes specific to hp-adaptive mesh refinement.

Enumeration Type Documentation

◆ Flag

enum class amr::Flag
strong

Flags that represent decisions about mesh refinement.

In order to support anisotropic mesh refinement, a flag is specified for each dimension.

Enumerator
Undefined 

used to initialize flags before a decision is made

Join 

join the sibling of an Element

DecreaseResolution 

decrease number of points in an Element

DoNothing 

stay the same

IncreaseResolution 

increase number of points in an Element

Split 

split the Element into two smaller elements

◆ Isotropy

enum class amr::Isotropy
strong

Isotropy of adaptive mesh refinement.

Enumerator
Anisotropic 

each dimension can be refined independently

Isotropic 

all dimensions must be refined the same

Function Documentation

◆ desired_refinement_levels_of_neighbor()

template<size_t VolumeDim>
std::array< size_t, VolumeDim > amr::desired_refinement_levels_of_neighbor ( const ElementId< VolumeDim > &  neighbor_id,
const std::array< Flag, VolumeDim > &  neighbor_flags,
const OrientationMap< VolumeDim > &  orientation 
)

Computes the desired refinement level of a neighboring Element with ElementId neighbor_id given its desired amr::Flags neighbor_flags taking into account the OrientationMap orientation of the neighbor.

Details

The OrientationMap orientation is that from the Element that has a neighbor with ElementId neighbor_id

◆ fraction_of_block_volume()

template<size_t VolumeDim>
boost::rational< size_t > amr::fraction_of_block_volume ( const ElementId< VolumeDim > &  element_id)

Fraction of the logical volume of a block covered by an element.

Note
The sum of this over all the elements of a block should be one

◆ id_of_parent()

template<size_t VolumeDim>
ElementId< VolumeDim > amr::id_of_parent ( const ElementId< VolumeDim > &  element_id,
const std::array< Flag, VolumeDim > &  flags 
)

Returns the ElementId of the parent of the Element with element_id using the refinement flags associated with element_id

Details

Note that at least one flag of flags must be Flag::Join and none of the flags can be Flag::Split. The parent ElementId is computed by looping over the SegmentIds of element_id and using either the SegmentId or its parent depending upon whether or not the corresponding Flag is Flag::Join.

◆ ids_of_children()

template<size_t VolumeDim>
std::vector< ElementId< VolumeDim > > amr::ids_of_children ( const ElementId< VolumeDim > &  element_id,
const std::array< Flag, VolumeDim > &  flags 
)

Returns the ElementIds of the children of the Element with element_id using the refinement flags associated with element_id

Details

Note that at least one flag of flags must be Flag::Split and none of the flags can be Flag::Join. The child ElementIds are computed by looping over the SegmentIds of element_id and using either the SegmentId or its children depending upon whether or not the corresponding flag is Flag::Split.

◆ ids_of_joining_neighbors()

template<size_t VolumeDim>
std::deque< ElementId< VolumeDim > > amr::ids_of_joining_neighbors ( const Element< VolumeDim > &  element,
const std::array< Flag, VolumeDim > &  flags 
)

The ElementIds of the neighbors of element that will join with it given refinement flags

Note
This function only returns the face neighbors of element that will join with it, and not the joining corner neighbors

◆ is_child_that_creates_parent()

template<size_t VolumeDim>
bool amr::is_child_that_creates_parent ( const ElementId< VolumeDim > &  element_id,
const std::array< Flag, VolumeDim > &  flags 
)

Whether or not the Element is the child that should create the parent Element when joining elements.

Details

This returns true if the Element is the lower sibling segment in all dimensions that are joining

◆ new_neighbor_ids()

template<size_t VolumeDim>
std::unordered_map< ElementId< VolumeDim >, Mesh< VolumeDim > > amr::new_neighbor_ids ( const ElementId< VolumeDim > &  my_id,
const Direction< VolumeDim > &  direction,
const Neighbors< VolumeDim > &  previous_neighbors_in_direction,
const std::unordered_map< ElementId< VolumeDim >, Info< VolumeDim > > &  previous_neighbors_amr_info 
)

returns the ElementId and Mesh of the new neighbors in the given direction of the Element whose ElementId is my_id given the previous_neighbors_in_direction and their amr::Info.

Note
previous_neighbors_in_direction should be from the parent (or a child) of the Element with my_id if my_id corresponds to a newly created child (or parent) Element.
previous_neighbors_amr_info may contain info from neighbors in directions other than direction

◆ prevent_element_from_joining_while_splitting()

template<size_t VolumeDim>
bool amr::prevent_element_from_joining_while_splitting ( gsl::not_null< std::array< Flag, VolumeDim > * >  flags)

Prevent an Element from splitting in one dimension, while joining in another.

Details

If flags (the AMR decisions of an Element) contains both amr::Flag::Split and amr::Flag::Join, then all change Join to amr::Flag::DoNothing.

Returns: true if any flag is changed

Note
This restriction could be relaxed, but it would greatly complicate the AMR algorithm. As a Join flag has the lowest priority, it causes no problems to replace it with a DoNothing flag.

◆ update_amr_decision()

template<size_t VolumeDim>
bool amr::update_amr_decision ( gsl::not_null< std::array< Flag, VolumeDim > * >  my_current_amr_flags,
const Element< VolumeDim > &  element,
const ElementId< VolumeDim > &  neighbor_id,
const std::array< Flag, VolumeDim > &  neighbor_amr_flags,
bool  enforce_two_to_one_balance_in_normal_direction 
)

Updates the AMR decisions my_current_amr_flags of the Element element based on the AMR decisions neighbor_amr_flags of a neighbor Element with ElementId neighbor_id.

Details

This function is called by each element when it receives the AMR decisions of one of its neighbors. If any of its flags are updated, the element should send its new decisions to each of its neighbors. The following changes are made to the current flags of the element:

  • If the neighbor wants to be two or more refinement levels higher than the element, the flag is updated to bring the element to within one level (unless this occurs in the direction to the neighbor and enforce_two_to_one_balance_in_normal_direction is set to false).
  • If the element wants to join, and the neighbor is a potential sibling but wants to be at a different refinement level in any dimension, the flag is updated to not do h-refinement.
  • An Element that is splitting in one dimension is not allowed to join in another dimension. If this is occurs when updating the decision, the decision to join is changed to do nothing.

Returns: true if any flag is changed

Note
Modifies my_current_amr_flags which are the AMR decisions of element.