Template Class mesh

Inheritance Relationships

Base Type

  • public TMeshCompetencePack::template apply< mesh< element_competence_pack<>, mesh_competence_pack<> > >

Class Documentation

template<ElementCompetencePack TElementCompetencePack = element_competence_pack<>, MeshCompetencePack TMeshCompetencePack = mesh_competence_pack<>>
class mesh : public TMeshCompetencePack::template apply<mesh<element_competence_pack<>, mesh_competence_pack<>>>

Wrapper for a forest that enables it to be handled as a simple mesh object.

See also

element for more details on the choice of the template parameter.

Note

Please pack your competences using the element_competence_pack class.

Note

Please pack your competences using the t8_mesh_handle::mesh_competence_pack class. One of the most important competences to add is element_data_mesh_competence.

Template Parameters:
  • TElementCompetencePack – The competences you want to add to the default functionality of the elements.

  • TMeshCompetences – The competences you want to add to the default functionality of the mesh.

Public Types

using SelfType = mesh<TElementCompetencePack, TMeshCompetencePack>

Type of the current class.

using element_class = typename TElementCompetencePack::template apply<SelfType, element>

The element class of the mesh with given competences.

using mesh_tag = void

Mesh tag for identification in concept.

using mesh_const_iterator = typename std::vector<element_class>::const_iterator

Constant iterator type for the mesh elements.

using mesh_iterator = typename std::vector<element_class>::iterator

Non-const iterator type for the mesh elements.

using adapt_callback_type = std::function<int(const SelfType &mesh, std::span<const element_class> elements)>

Callback function prototype to decide for refining and coarsening of a family of elements or one element in a mesh handle.

If elements contains more than one element, they must form a family and we decide whether this family should be coarsened or only the first element should be refined. Family means multiple elements that can be coarsened into one parent element.

See also

set_adapt for the usage of this callback.

Note

We currently do not provide functionality to delete elements.

Param mesh:

[in] The mesh that should be adapted.

Param elements:

[in] One element or a family of elements (if more than one element) to consider for adaptation.

Return:

1 if the first entry in elements should be refined, -1 if the family elements shall be coarsened, 0 else.

template<typename TUserDataType>
using adapt_callback_type_with_userdata = std::function<int(const SelfType &mesh, std::span<const element_class> elements, TUserDataType user_data)>

Templated callback function prototype to decide for refining and coarsening of a family of elements or one element in a mesh handle including user data.

See the version without user_data adapt_callback_type for more details. Use mesh_adapt_callback_wrapper to convert this type into adapt_callback_type to be able to pass the callback to set_adapt.

Note

We currently do not provide functionality to delete elements.

Template Parameters:

TUserDataType – The type of the user data to be passed to the callback.

Param mesh:

[in] The mesh that should be adapted.

Param elements:

[in] One element or a family of elements (if more than one element) to consider for adaptation.

Param user_data:

[in] The user data to be used during the adaptation process.

Return:

1 if the first entry in elements should be refined, -1 if the family elements shall be coarsened, 0 else.

Public Functions

inline mesh(t8_forest_t forest)

Constructor for a mesh of the handle.

Parameters:

forest[in] The forest from which the mesh should be created.

inline ~mesh()

Destructor for a mesh of the handle.

The forest in use will be unreferenced. Call t8_forest_ref before if you want to keep it alive.

inline t8_locidx_t get_num_local_elements() const

Getter for the number of local elements in the mesh.

Returns:

Number of local elements in the mesh.

inline t8_locidx_t get_num_ghosts() const

Getter for the number of ghost elements.

Returns:

Number of ghost elements in the mesh.

inline int get_dimension() const

Getter for the dimension of the mesh.

Returns:

The dimension.

inline t8_forest_t get_forest() const

Getter for the forest the mesh is defined for.

Returns:

The forest the mesh is defined for.

inline bool is_balanced()

Check if the local elements of the mesh are balanced.

The mesh is said to be balanced if the level difference between face neighbors is at most 1. at most +1 or -1 of the element’s level.

Returns:

true if the local elements are balanced, false otherwise.

inline mesh_const_iterator cbegin() const

Returns a constant iterator to the first (local) mesh element.

Returns:

Constant iterator to the first (local) mesh element.

inline mesh_const_iterator cend() const

Returns a constant iterator to a mesh element following the last (local) element of the mesh.

Returns:

Constant iterator to the mesh element following the last (local) element of the mesh.

inline mesh_iterator begin()

Returns an iterator to the first (local) mesh element.

Returns:

Iterator to the first (local) mesh element.

inline mesh_iterator end()

Returns an iterator to a mesh element following the last (local) element of the mesh.

Returns:

Iterator to the mesh element following the last (local) element of the mesh.

inline mesh_const_iterator begin() const

Returns a constant iterator to the first (local) mesh element.

Returns:

Constant iterator to the first (local) mesh element.

inline mesh_const_iterator end() const

Returns a constant iterator to a mesh element following the last (local) element of the mesh.

Returns:

Constant iterator to the mesh element following the last (local) element of the mesh.

inline const element_class &operator[](t8_locidx_t local_index) const

Getter for an element given its local index.

This could be a (local) mesh element or a ghost element. The indices 0, 1, … num_local_el - 1 refer to local mesh elements and num_local_el , … , num_local_el + num_ghosts - 1 refer to ghost elements.

Parameters:

local_index[in] The local index of the element to access.

Returns:

Constant reference to the element.

inline element_class &operator[](t8_locidx_t local_index)

Non const version of operator above.

Parameters:

local_index[in] The local index of the element to access.

Returns:

Reference to the element.

inline void set_adapt(adapt_callback_type adapt_callback)

Set an adapt function to be used to adapt the mesh on committing.

Note

The adaptation is carried out only when commit is called.

Note

We currently do not provide the functionality to delete elements.

Note

This setting can be combined with set_partition and set_balance. The order in which these operations are executed is always 1) Adapt 2) Partition 3) Balance.

Parameters:

adapt_callback[in] The adapt callback used on committing.

inline void set_partition(bool set_for_coarsening = false)

If this function is called, the mesh will be partitioned on committing.

The partitioning is done according to the SFC and each rank is assigned the same (maybe +1) number of elements.

Note

The partition is carried out only when commit is called.

Note

This setting can be combined with set_adapt and set_balance. The order in which these operations are executed is always 1) Adapt 2) Partition 3) Balance.

Parameters:

set_for_coarsening[in] If true, the partitions are choose such that coarsening an element once is a process local operation. Default is false.

inline void set_balance(bool no_repartition = false)

If this function is called, the mesh will be balanced on committing.

The mesh is said to be balanced if the element level between face neighbors differs by at most 1.

Note

The balance is carried out only when commit is called.

Note

This setting can be combined with set_adapt and set_partition. The order in which these operations are executed is always 1) Adapt 2) Partition 3) Balance.

Parameters:

no_repartition[in] Balance constructs several intermediate steps that are refined from each other. In order to maintain a balanced load, a repartitioning is performed in each round and the resulting mesh is load-balanced per default. Set no_repartition to true if this behaviour is not desired. If no_repartition is false (default), an additional call of set_partition is not necessary.

inline void set_ghost(bool do_ghost = true, t8_ghost_type_t ghost_type = T8_GHOST_FACES)

Enable or disable the creation of a layer of ghost elements.

Parameters:
  • do_ghost[in] If true a ghost layer will be created.

  • ghost_type[in] Controls which neighbors count as ghost elements, currently only T8_GHOST_FACES is supported. This value is ignored if do_ghost = false.

inline void commit()

After allocating and adding properties to the mesh, commit the changes.

This call updates the internal state of the mesh. The forest used to define the mesh handle is replaced in this function. The previous forest is unreferenced. Call t8_forest_ref before if you want to keep it alive. Specialize the update with calls like set_adapt first.

Public Members

friend element_class

Element class as friend such that private members (e.g.

the forest) can be accessed.

Public Static Functions

template<typename TUserDataType>
static inline adapt_callback_type mesh_adapt_callback_wrapper(adapt_callback_type_with_userdata<TUserDataType> adapt_callback_with_userdata, const TUserDataType &user_data)

Wrapper to convert an adapt callback with user data of type adapt_callback_type_with_userdata into a callback without user data of type adapt_callback_type using the defined user data user_data.

This is required to pass an adapt callback with user data to set_adapt.

Template Parameters:

TUserDataType – The type of the user data to be passed to the callback.

Parameters:
  • adapt_callback_with_userdata[in] The adapt callback including user data.

  • user_data[in] The user data to be used during the adaptation process.

Returns:

An adapt callback without user data parameter that can be passed to set_adapt.

static inline constexpr bool has_element_data_handler_competence()

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

Returns:

true if mesh has a data handler, false otherwise.

Friends

friend struct element_data_element_competence< element_class >