SpECTRE  v2024.12.16
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
ElementId< VolumeDim > Class Template Reference

An ElementId uniquely labels an Element. More...

#include <ElementId.hpp>

Public Member Functions

 ElementId ()=default
 Default constructor needed for Charm++ serialization.
 
 ElementId (const ElementId &)=default
 
ElementIdoperator= (const ElementId &)=default
 
 ElementId (ElementId &&)=default
 
ElementIdoperator= (ElementId &&)=default
 
 ElementId (size_t block_id, size_t grid_index=0)
 Create the ElementId of the root Element of a Block.
 
 ElementId (size_t block_id, const std::array< SegmentId, VolumeDim > &segment_ids, size_t grid_index=0)
 Create an arbitrary ElementId.
 
 ElementId (const std::string &grid_name)
 Create an ElementId from its string representation (see operator<<).
 
ElementId< VolumeDim > id_of_child (size_t dim, Side side) const
 
ElementId< VolumeDim > id_of_parent (size_t dim) const
 
size_t block_id () const
 
size_t grid_index () const
 
std::array< size_t, VolumeDim > refinement_levels () const
 
std::array< SegmentId, VolumeDim > segment_ids () const
 
SegmentId segment_id (size_t dim) const
 
size_t number_of_block_boundaries () const
 Returns the number of block boundaries the element has.
 

Static Public Member Functions

static ElementId< VolumeDim > external_boundary_id ()
 Returns an ElementId meant for identifying data on external boundaries, which does not correspond to the Id of an actual element.
 

Static Public Attributes

static constexpr size_t block_id_bits = 8
 
static constexpr size_t grid_index_bits = 4
 
static constexpr size_t direction_bits = 4
 
static constexpr size_t max_refinement_level = 15
 The maximum allowed refinement level.
 
static constexpr uint64_t direction_shift
 
static constexpr uint64_t direction_mask
 
static constexpr size_t volume_dim = VolumeDim
 

Protected Member Functions

 ElementId (const Direction< VolumeDim > &direction, const ElementId< VolumeDim > &element_id)
 Create an ElementId in a specified direction.
 
Direction< VolumeDim > direction () const
 
ElementId without_direction () const
 

Friends

template<size_t Dim>
bool operator== (const ElementId< Dim > &lhs, const ElementId< Dim > &rhs)
 
template<size_t Dim>
bool operator< (const ElementId< Dim > &lhs, const ElementId< Dim > &rhs)
 
template<size_t Dim>
bool is_zeroth_element (const ElementId< Dim > &id, const std::optional< size_t > &grid_index)
 Returns a bool if the element is the zeroth element in the domain. More...
 

Detailed Description

template<size_t VolumeDim>
class ElementId< VolumeDim >

An ElementId uniquely labels an Element.

It is constructed from the BlockId of the Block to which the Element belongs and the VolumeDim SegmentIds that label the segments of the Block that the Element covers. An optional grid_index identifies elements with the same BlockId and SegmentIds across multiple grids.

Details

The ElementId serves as an index that is compatible with Charm++ and therefore must adhere to the restrictions imposed by Charm++. These are:

Friends And Related Function Documentation

◆ is_zeroth_element

template<size_t VolumeDim>
template<size_t Dim>
bool is_zeroth_element ( const ElementId< Dim > &  id,
const std::optional< size_t > &  grid_index 
)
friend

Returns a bool if the element is the zeroth element in the domain.

Details

An element is considered to be the zeroth element if its ElementId id has

  1. id.block_id() == 0
  2. All id.segment_ids() have SegmentId.index() == 0
  3. If the argument grid_index is specified, id.grid_index() == grid_index.

This means that the only element in a domain that this function will return true for is the element in the lower corner of Block0 of that domain. The grid_index will determine which domain is used for the comparison. During evolutions, only one domain will be active at a time so it doesn't make sense to compare the grid_index. However, during an elliptic solve when there are multiple grids, this grid_index is useful for specifying only one element over all domains.

This function is useful if you need a unique element in the domain because only one element in the whole domain can be the zeroth element.

Warning
If you have multiple grids and you don't specify the grid_index argument, this function will return true for one element in every grid and thus can't be used to determine a unique element in a simulation; only a unique element in each grid.
Warning
If the domain is re-gridded, a different ElementId may represent the zeroth element.

Member Data Documentation

◆ direction_mask

template<size_t VolumeDim>
constexpr uint64_t ElementId< VolumeDim >::direction_mask
staticconstexpr
Initial value:
= static_cast<uint64_t>(0b1111)
<< direction_shift

◆ direction_shift

template<size_t VolumeDim>
constexpr uint64_t ElementId< VolumeDim >::direction_shift
staticconstexpr
Initial value:
=
static_cast<uint64_t>(block_id_bits + grid_index_bits)

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