\chapter{Hexahedral Quality Metrics\label{s:hex}}

All the metrics in this section are defined on a hexahedral element
as shown in Figure~\ref{f:hex}.
Unless noted otherwise, hexahedra are assumed to have planar faces.

\begin{figure}[bhp]
  \centering
  \includegraphics[width=2.5in]{hex}
  \caption{A prototypical hexahedral finite element.%
                                                                  \label{f:hex}}
\end{figure}

We index the edges as follows.
Note that order of the edges does \textbf{not} match \vtk.
\begin{equation*}
\begin{array}{lclcl}
  \vec L_0    &=& \vec P_1 - \vec P_0\\
  \vec L_1    &=& \vec P_2 - \vec P_1\\
  \vec L_2    &=& \vec P_3 - \vec P_2\\
  \vec L_3    &=& \vec P_3 - \vec P_0
\end{array}\rule{2em}{0pt}
\begin{array}{lclcl}
  \vec L_4    &=& \vec P_4 - \vec P_0\\
  \vec L_5    &=& \vec P_5 - \vec P_1\\
  \vec L_6    &=& \vec P_6 - \vec P_2\\
  \vec L_7    &=& \vec P_7 - \vec P_3
\end{array}\rule{2em}{0pt}
\begin{array}{lclcl}
  \vec L_8    &=& \vec P_5 - \vec P_4\\
  \vec L_9    &=& \vec P_6 - \vec P_5\\
  \vec L_{10} &=& \vec P_7 - \vec P_6\\
  \vec L_{11} &=& \vec P_7 - \vec P_4
\end{array}
\end{equation*}

The tetrahedron edge lengths are denoted as follows:
\[
L_0 = \normvec{L_0}\quad
\dots\quad
L_{11} = \normvec{L_{11}}
\]
and the largest and smallest edge lenghts are, respectively,
\begin{equation*}
\begin{array}{lcl}
  L_{\min} &=& \min\left\{L_0, \dots, L_{11} \right\}\\
  L_{\max} &=& \max\left\{L_0, \dots, L_{11} \right\}.
\end{array}
\end{equation*}

Hexahedra have four diagonal vectors:
\begin{equation*}
\begin{array}{lcl}
\vec D_0 &=& \vec P_6 - \vec P_0\\
\vec D_1 &=& \vec P_7 - \vec P_1
\end{array}\rule{10em}{0pt}
\begin{array}{lcl}
\vec D_2 &=& \vec P_4 - \vec P_2\\
\vec D_3 &=& \vec P_5 - \vec P_3
\end{array}
\end{equation*}

\begin{equation*}
\begin{array}{lcl}
  D_{\min} &=& \min\left\{\normvec{D_0},\normvec{D_1},\normvec{D_2},\normvec{D_3} \right\}\\
  D_{\max} &=& \max\left\{\normvec{D_0},\normvec{D_1},\normvec{D_2},\normvec{D_3} \right\}
\end{array}
\end{equation*}

The principal axes are
\begin{equation*}
\begin{array}{lcl}
  \vec X_1 &=&
    \left(\vec P_1-\vec P_0\right) + \left(\vec P_2-\vec P_3\right) +
    \left(\vec P_5-\vec P_4\right) + \left(\vec P_6-\vec P_7\right)\\
  \vec X_2 &=&
    \left(\vec P_3-\vec P_0\right) + \left(\vec P_2-\vec P_1\right) +
    \left(\vec P_7-\vec P_4\right) + \left(\vec P_6-\vec P_5\right)\\
  \vec X_3 &=&
    \left(\vec P_4-\vec P_0\right) + \left(\vec P_5-\vec P_1\right) +
    \left(\vec P_6-\vec P_2\right) + \left(\vec P_7-\vec P_3\right)\\
\end{array}
\end{equation*}

The cross derivatives are then
\begin{equation*}
\begin{array}{lclcl}
  \vec X_{12} &=& \vec X_{21} &=&
    \left(\vec P_2-\vec P_3\right) - \left(\vec P_1-\vec P_0\right) +
    \left(\vec P_6-\vec P_7\right) - \left(\vec P_5-\vec P_4\right) \\
  \vec X_{13} &=& \vec X_{31} &=&
    \left(\vec P_5-\vec P_1\right) - \left(\vec P_4-\vec P_0\right) +
    \left(\vec P_6-\vec P_2\right) - \left(\vec P_7-\vec P_3\right) \\
  \vec X_{23} &=& \vec X_{32} &=&
    \left(\vec P_7-\vec P_4\right) - \left(\vec P_3-\vec P_0\right) +
    \left(\vec P_6-\vec P_5\right) - \left(\vec P_2-\vec P_1\right) \\
\end{array}
\end{equation*}

We can define a series of $3\times 3$ Jacobian matrices on a given hexahedron using
the edge vectors $\vec L_i$ to form columns of each matrix:
\begin{equation*}
\begin{array}{lrrcrcrl}
A_0 &= (&  \vec L_0   &,&  \vec L_3   &,&  \vec L_4 &)\\
A_1 &= (&  \vec L_1   &,& -\vec L_0   &,&  \vec L_5 &)\\
A_2 &= (&  \vec L_2   &,& -\vec L_1   &,&  \vec L_6 &)\\
A_3 &= (& -\vec L_3   &,& -\vec L_2   &,&  \vec L_7 &)\\
A_4 &= (&  \vec L_{11}&,&  \vec L_8   &,& -\vec L_4 &)\\
A_5 &= (& -\vec L_8   &,&  \vec L_9   &,& -\vec L_5 &)\\
A_6 &= (& -\vec L_9   &,&  \vec L_{10}&,& -\vec L_6 &)\\
A_7 &= (& -\vec L_{10}&,& -\vec L_{11}&,& -\vec L_7 &)\\
A_8 &= (&  \vec X_1   &,&  \vec X_2   &,&  \vec X_3 &)
\end{array}
\end{equation*}
These matrices will be useful in calculating the volume and condition number of a hexahedron.
Some operations we will need to perform on these matrices can be reduced to simple vector operations.
Since this is how we define the matrices, these forms of the operations serve as efficient implementations.

Let $A$ be one of these $3 \times 3$ matrix defined by the
column vectors $\vec v_1, \vec v_2, \vec v_3,$ i.e., $A = [\vec v_1, \vec v_2, \vec v_3]$. 
Then, 
\[
|A|^2 = \normvec{ v_1}^2 + \normvec{ v_2}^2 + \normvec{ v_3}^2 
\]
and
\[
|\mathrm{adj}(A)|^2 = \normvec{ v_1 \times \vec v_2}^2 + 
             \normvec{ v_2 \times \vec v_3}^2 +
             \normvec{ v_3 \times \vec v_1}^2 .
\]
We then define $\alpha$ to be the determinant of $A$
\[
\alpha = \det(A) = \vec v_1 \cdot (\vec v_2 \times \vec v_3 )
\]
and we denote the determinant of a specific one of the $A_i$ as
\[
\alpha_i = \det(A_i)
\]
where $i\in\{0,1,\ldots,8\}$.
Finally, we define normalized versions of the Jacobian matrices
\[
  \hat A = \left(
    \frac{\vec v_1}{\normvec{ v_1}}\;,
    \frac{\vec v_2}{\normvec{ v_2}}\;,
    \frac{\vec v_3}{\normvec{ v_3}}
  \right)
\]
and their normalized determinants
\[
  \hat\alpha_u = \det\left(\hat A_i\right).
\]

% -------------------Metric Table-------------------
\newcommand{\hexmetrictable}[8]{%
  \begin{center}
  \begin{tabular}{ll}
    \multicolumn{2}{r}{\textbf{\sffamily\Large hexahedral #1}}\\\hline
    Dimension:             & #2\\ 
    Acceptable Range:      & #3\\ 
    Normal Range:          & #4\\ 
    Full Range:            & #5\\ 
    $q$ for unit cube:     & #6\\
    Reference:             & #7\\
    \verd\ function:       & \texttt{#8}\\ \hline
  \end{tabular} 
  \end{center}
}

\newpage \input{HexDiagonal}
\newpage \input{HexDimension}
\newpage \input{HexDistortion}
\newpage \input{HexEdgeRatio}
\newpage \input{HexJacobian}
\newpage \input{HexMaximumEdgeRatio}
\newpage \input{HexMaxAspectFrobenius}
\newpage \input{HexMedAspectFrobenius}
\newpage \input{HexOddy}
\newpage \input{HexRelativeSizeSquared}
\newpage \input{HexScaledJacobian}
\newpage \input{HexShape}
\newpage \input{HexShapeAndSize}
\newpage \input{HexShear}
\newpage \input{HexShearAndSize}
\newpage \input{HexSkew}
\newpage \input{HexStretch}
\newpage \input{HexTaper}
\newpage \input{HexVolume}

