Template Class element

Inheritance Relationships

Base Type

  • public TCompetences< element< TMeshClass, TCompetences... > >

Class Documentation

template<typename TMeshClass, template<typename> class ...TCompetences>
class element : public TCompetences<element<TMeshClass, TCompetences...>>

Definition of the mesh element class of the mesh handle.

An element without specified template parameters provides default implementations for basic functionality as accessing the refinement level or the centroid. With this implementation, the functionality is calculated each time the function is called. Use the competences defined in competences.hxx as template parameter to cache the functionality instead of recalculation in every function call. To add functionality to the element, you can also simply write your own competence and give it as a template parameter. You can access the functions implemented in your competence via the element. Please note that the competence should be valid for both, mesh elements and ghost elements.

The inheritance pattern is inspired by T8Type (which also uses the CRTP). We decided to use this structure 1.) to be able to add new functionality easily and 2.) for the cached options to keep the number of member variables of the default element to a minimum to save memory. The choice between calculate and cache is a tradeoff between runtime and memory usage.

Template Parameters:

TCompetences – The competences you want to add to the default functionality of the element.

Public Functions

inline t8_element_level get_level() const

Getter for the refinement level of the element.

For this easily accessible variable, it makes no sense to provide a cached version.

Returns:

Refinement level of the element.

inline int get_num_faces() const

Getter for the number of faces of the element.

For this easily accessible variable, it makes no sense to provide a cached version.

Returns:

Number of faces of the element.

inline int get_num_vertices() const

Getter for the number of vertices of the element.

For this easily accessible variable, it makes no sense to provide a cached version.

Returns:

Number of vertices of the element.

inline t8_element_shape_t get_shape() const

Getter for the element’s shape.

For this easily accessible variable, it makes no sense to provide a cached version.

Returns:

The shape of the element.

inline double get_volume() const

Getter for the element’s volume.

This is only an approximation. This function uses or sets the cached version defined in TCompetence if available and calculates if not.

Returns:

The volume of the element.

inline double get_diameter() const

Getter for the element’s diameter.

This is only an approximation. This function uses or sets the cached version defined in TCompetence if available and calculates if not.

Returns:

The diameter of the element.

inline std::vector<t8_3D_vec> get_vertex_coordinates() const

Getter for the vertex coordinates of the element.

This function uses or sets the cached version defined in TCompetence if available and calculates if not.

Returns:

Vector with one coordinate array for each vertex of the element.

inline t8_3D_vec get_vertex_coordinates(int vertex) const

Getter for the coordinates of one specific vertex of the element.

This function uses or sets the cached version defined in TCompetence if available and calculates if not. The cache is filled for all vertices simultaneously.

Parameters:

vertex[in] Index of the vertex.

Returns:

Coordinates of the vertex.

inline t8_3D_vec get_centroid() const

Getter for the center of mass of the element.

This function uses the cached version defined in TCompetence if available and calculates if not.

Returns:

Coordinates of the center.

inline std::vector<const SelfType*> get_face_neighbors(int face, std::optional<std::reference_wrapper<std::vector<int>>> dual_faces = std::nullopt) const

Getter for the face neighbors of the mesh element at a given face.

This function uses the cached version defined in TCompetences if available and calculates if not.

Parameters:
  • face[in] The index of the face across which the face neighbors are searched.

  • dual_faces[out] On output the face id’s of the neighboring elements’ faces.

Returns:

Vector of length num_neighbors with pointers to the elements neighboring at the given face.

inline void fill_face_neighbor_cache() const
requires (has_face_neighbor_cache())

Function to fill the face neighbor cache for all faces of the mesh element.

inline double get_face_area(int face) const

The area of a face of the element.

This is only an approximation. This function uses the cached version defined in TCompetence if available and calculates if not.

Parameters:

face[in] Index of a face of the element.

Returns:

The area of the face with id face.

inline t8_3D_vec get_face_centroid(int face) const

The centroid of a face of the element.

This function uses the cached version defined in TCompetence if available and calculates if not.

Parameters:

face[in] Index of a face of the element.

Returns:

The centroid of the face with id face.

inline t8_3D_vec get_face_normal(int face) const

The normal vector of a face of the element.

This function uses the cached version defined in TCompetence if available and calculates if not.

Parameters:

face[in] Index of a face of the element.

Returns:

The normal vector of the face with id face.

inline t8_element_shape_t get_face_shape(int face) const

Getter for the element’s face shape.

For this easily accessible variable, it makes no sense to provide a cached version.

Parameters:

face[in] Index of a face of the element.

Returns:

The shape of the face with id face.

inline void print_element_debug() const

Print the element.

For example, print the coordinates and level of a triangle.

This function is only available in the debugging configuration.

inline t8_locidx_t get_element_handle_id() const

Getter for the index of the element in the mesh to which the element belongs.

Returns:

The local element id of the element in the mesh.

inline t8_locidx_t get_local_tree_id() const

Getter for the tree id of the element in the forest related to the mesh.

Warning

This is related to t8code’s tree structure and should not be confused with mesh specific ids. This function is mainly relevant for writing custom competences that need to access t8code functionality.

Returns:

The element’s local tree id in the forest.

inline t8_locidx_t get_local_element_id() const

Getter for the local element id in the tree of the element in the forest related to the mesh.

Warning

This is related to t8code’s tree structure and should not be confused with mesh specific ids. For mesh specific id use get_element_handle_id. This function is mainly relevant for writing custom competences that need to access t8code functionality.

Returns:

The local element id in the tree of the element in the forest.

inline const TMeshClass *get_mesh() const

Getter for the mesh to which the element belongs.

Returns:

Reference to the mesh.

inline bool is_ghost_element() const

Function to check if the element is a ghost element.

Returns:

true if the element is a ghost element, false otherwise.

Public Static Functions

static inline constexpr bool has_volume_cache()

Function that checks if a cache for the element’s volume exists.

Returns:

true if a cache exists, false otherwise.

static inline constexpr bool has_diameter_cache()

Function that checks if a cache for the element’s diameter exists.

Returns:

true if a cache exists, false otherwise.

static inline constexpr bool has_vertex_cache()

Function that checks if a cache for the vertex coordinates exists.

Returns:

true if a cache for the vertex coordinates exists, false otherwise.

static inline constexpr bool has_centroid_cache()

Function that checks if a cache for the centroid exists.

Returns:

true if a cache for the centroid exists, false otherwise.

static inline constexpr bool has_face_neighbor_cache()

Function that checks if a cache for the face neighbors exists.

Returns:

true if a cache exists, false otherwise.

static inline constexpr bool has_face_areas_cache()

Function that checks if a cache for the element’s face areas exists.

Returns:

true if a cache exists, false otherwise.

static inline constexpr bool has_face_centroids_cache()

Function that checks if a cache for the element’s face centroids exists.

Returns:

true if a cache exists, false otherwise.

static inline constexpr bool has_face_normals_cache()

Function that checks if a cache for the element’s face normals exists.

Returns:

true if a cache exists, false otherwise.

static inline constexpr bool has_element_data_handler_competence()

Function that checks if a competence for element data handling is given to the element.

Returns:

true if element has a data handler, false otherwise.