Skip to content

Element indexing

Ole Albers edited this page Oct 18, 2024 · 6 revisions

Element indexing

Element indexing in t8code refers to the different ways of uniquely identifying mesh elements. In t8code, we work with four types of indices to identify elements: the global index, the local index, the tree local index, and the linear ID.

Most of our functions require a tree id and a tree local index as input.

When iterating over the elements in a mesh we recommend to iterate over all local trees and for each tree to iterate over its elements.

See also Tree indexing

1. Global index

The global index refers to the unique identification of all elements across all processes. This means that every element in the mesh, regardless of which process it is handled by, is given a unique number in the range 0 to N−1, where N is the total number of elements across all processes.

2. Local index

The local index is specific to the elements handled by a single process. Each process has its own set of elements, which are numbered locally from 0 to n-1, where n is the total number of elements of the current process.

t8_forest_get_first_local_element_id function returns the global index of the first element of a process. Thus, we can convert between global index and local index by:

global_index = t8_forest_get_first_local_element_id(forest) + local_index

3. Tree local index

The tree local index is specific to elements that belong to a particular tree within a process. Each process can manage multiple trees and each tree contains a subset of elements. The tree local index enumerates elements within a particular tree from 0 to t−1, where t is the number of elements in that tree on the current process.

The function t8_forest_get_tree_element_offset returns the local index of a tree's first element. We can convert between local index and tree local index by:

local index = t8_forest_get_tree_element_offset(forest, treeid) + tree local index

4. Linear ID

The linear id is a hypothetical index of the element in a uniform grid. It is mostly used internally.

Clone this wiki locally