% Chapter I

\section{The hierarchical mesh}
\label{S:hierarchical_mesh1}
\idx{hierarchical mesh}

There are basically two ways of storing a finite element grid. One
possibility is to store only the elements of the triangulation in a
vector or a linked list. All information about elements is located at
the elements. In this situation there is no direct information of a
hierarchical structure, needed, for example, for multigrid
methods. Such information has to be generated and stored
separately. During mesh refinement, new elements are added (at the
end) to the vector or list of elements.  During mesh coarsening,
elements are removed. In case of an element vector, `holes' may appear
in the vector that contain no longer a valid element. One has to take
care of them, or remove them by compressing the vector.

\ALBERTA uses the second way of storing the mesh. It keeps information
about the whole hierarchy of grids starting with the macro
triangulation up to the actual one. Storing information about the
whole hierarchical structure will need an additional amount of
computer memory.  On the other hand, we can save computer memory
because such information which can be produced by the hierarchical
structure does not have to be stored explicitly on each element.

The simplicial grid is generated by refinement of a given macro
triangulation. Refined parts of the grid can be de--refined, but we
can not coarsen elements of the macro triangulation. The refinement
and coarsening routines, described in \secref{S:ref.coarse},
construct a sequence of nested grids with a hierarchical structure.
Every refined simplex is refined into two children. Elements that may
be coarsened were created by refining the parent into these two
elements and are now just coarsened back into this parent (compare
Sections~\ref{S:refinement_algorithm}, \ref{S:coarsening_algorithm}).

Using this structure of the refinement/coarsening routines, every
element of the macro triangulation is the root of a binary tree: every
interior node of that tree has two pointers to the two children; the
leaf elements are part of the actual triangulation, which is used to
define the finite element space. The whole triangulation is a list of
given macro elements together with the associated binary trees,
compare \figref{F:mesh_and_trees}.

\begin{figure}[htbp]
\label{F:mesh_and_trees}
\centerline{\includegraphics[scale=0.5]{EPS/mesh+tree1}}
\vspace{5mm}
\centerline{\includegraphics{EPS/mesh+tree2}}
\caption{Sample mesh refinement and corresponding element trees}     
\end{figure}

Some information is stored on the (leaf) elements explicitly, other
information is located at the macro elements and is transferred to the
leaf elements while traversing through the binary tree. For instance,
information about DOFs has to be stored explicitely for all (leaf)
elements whereas geometric information can be produced using the
hierarchical structure.

Operations on elements can only be performed by using the mesh
traversal routines described in \secref{man:S:traverse}. These routines
need as arguments a flag which indicates which information should be
present on the elements, which elements should be called (interior or
leaf elements), and a pointer to a function which performs the
operation on a single element. The traversal routines always start on
the first macro element and go to the indicated elements of the binary
tree at this macro element. This is done in a recursive way by first
traversing through the subtree of the first child and then by
traversing through the subtree of the second child.  This recursion
terminates if a leaf element is reached.  After calling all elements
of this tree we go to the next macro element, traverse through the
binary tree located there, and so on until the end of the list of
macro elements.

All information that should be available for mesh elements is
stored explicitly for elements of the macro triangulation.
Thus, all information is present on the macro level and is
transfered to the other tree elements by transforming requested
data from one element to its children. This can be done
by simple calculations using the hierarchic structure induced
by the refinement algorithm, compare \secref{S:refinement_algorithm}.

As mentioned above, geometric data like coordinates of the element's
vertices can be efficiently computed using the hierarchical structure
(in the case of non-parametric elements and polyhedral boundary).
Going from parent to child only the coordinates of one vertex change
and the new ones are simply the mean value of the coordinates of two
vertices at the refinement edge of the parent. The other vertex
coordinates stay the same.
Another example of such information is information about adjacent
elements. Using adjacency information of the macro elements we can
compute requested information for all elements of the mesh.  

%But especially in the recursive refinement we have to traverse from an element
%to some other elements of the mesh by going to a neighbour. This traversing
%from one neighbour to another takes about 50\% of time which is needed for the
%refinement.  If this is too time consuming for special applications, it is
%also possible to store neighbour information explicitly (which requires more
%storage but less computational time), compare Section \ref{neighbour
%information}.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\paragraph{User data on leaf elements}\idx{leaf data}
Many finite element applications need special information on each
element of the actual triangulation, i.e.\ the leaf elements of the
hierarchical mesh. In adaptive codes this may be, for example, error
indicators produced by an error estimator. Such information
needs to be available only for leaf elements and not for elements inside the
binary tree.

The fact that leaf elements do not have children, and thus the pointers to
such children in leaf element's data structures are not used, can be exploited
by enabling access to special data via these pointers. So, special pointers
for such data do not have to be included in an element data structure.
Details about such an implementation are given in
% \secref{S:leaf_data_info}.


%Macros for testing leaf elements and accessing leaf data are defined
%for the handling of leaf data, see \secref{S:leaf_data_info}.


%%% Local Variables: 
%%% mode: latex
%%% TeX-master: "alberta-book"
%%% End: 
