%%% Debut du preambule %%%

\documentclass[letterpaper]{report}     % Classe du document
\usepackage[T1]{fontenc}            % Encodage de sortie (l'encodage T1 convient mieux aux langues autres que l'Anglais)
\usepackage{aeguill,aecompl}        % Fontes virtuelles (nuit aux recherches et aux copies de texte dans le document PDF) pour PDF:
                                    % ameliore la qualite de la visualisation avec Acrobat Reader

%\hypersetup{colorlinks=true,linkcolor=blue,citecolor=magenta}


\title{ISSM documentation}
\author{Larour, Morlighem, Seroussi, Khazendar}
\date{2008}

\usepackage{graphicx}                        % Inclusion d'images
\usepackage{array, multirow}                 % Tableaux
\usepackage{amsmath}                         % Mode mathematique
\usepackage{amsfonts}                        % Polices mathematiques
\usepackage{amssymb}                         % Symboles mathematiques
\usepackage{makeidx}
\usepackage{float}                           %Pour faire [H] sur les float
\usepackage[left=3cm, right=3cm,
                        top=2cm, bottom=2cm]{geometry}

\usepackage{fancyhdr}
\usepackage{subfig}
\usepackage{longtable}
\usepackage{cancel}

\lhead{\leftmark{}} %en haut a gauche, titre de section
\rhead{\thepage}   %en haut a droite, page
\lfoot{NASA - Jet Propulsion Laboratory} %en bas a gauche
\rfoot{\scriptsize{\today}} %en bas a droite
\cfoot{ISSM Documentation} %en bas, au milieu
\setcounter{tocdepth}{4}                     %pour afficher la table des matiere au niveau subsection
\setcounter{secnumdepth}{4}


\usepackage[plainpages=false]{hyperref}

\hypersetup{% Links Options for the document%
colorlinks=true,
linkcolor=blue,
urlcolor=blue,
% anchorcolor=darkblue,
citecolor=blue,
plainpages=false,
%PDF Options%
pdftitle={Formulations},
pdfauthor={Larour, Morlighem, Seroussi,Khazendar},
pdfsubject={Numerical modelling of ice sheets}}
\newcommand*{\BigO}[1]{\mathcal{O}\left( #1\right) }   %Big O landau notation

\pagestyle{fancy}
\bibliographystyle{plain}

%%% Fin du preambule %%%
\begin{document}
%%Page de titre

\thispagestyle{empty}

\vspace{10cm}
\begin{center}
\bf \LARGE Ice Sheet System Model 2008\\  Theory Guide
\end{center}

\vspace{4cm}

\begin{center}
Authors:\\   
\vspace{.5cm}
{\bf \large \'Eric Larour$^{1}$} \\
\smallskip
{\bf \large Mathieu Morlighem$^{2,4}$} \\
\smallskip
{\bf \large H\'el\`ene Seroussi$^{2,4}$} \\
\smallskip
{\bf \large \'Eric Rignot$^{2,3}$} \\
\vfill
%\vspace{4.5cm}
$^{1}$Division 35, Thermal and Cryogenics Section, \\
Mechanical Division, MS 157-316.  \\
Jet Propulsion Laboratory, 4800 Oak Grove Drive, Pasadena, CA 91109.\\
\vspace{.2cm}
$^{2}$Division 33, Radar Science and Enginnering Section, \\
Communications, Tracking and Radar Division, MS 157-316.  \\
Jet Propulsion Laboratory, 4800 Oak Grove Drive, Pasadena, CA 91109.\\
\vspace{.2cm}
$^{3}$University of California, Irvine\\
Department of Earth System Science\\
Croul Hall, Irvine, CA 92697-3100\\
\vspace{.2cm}
$^{4}$Laboratoire de M\'ecanique des sols, Structures et  mat\'eriaux (MSSMat)\\
\'Ecole Centrale Paris, CNRS UMR 8579\\
Grande Voie des Vignes, 92295 Châtenay-Malabry Cedex, FRANCE\\

\vspace{0.5cm}
\today
\end{center}

\cleardoublepage

\begin{center}
{\Large \bf Summary}
\end{center}
This manual explains ... 

\vspace{1cm}
Key-words : ICE, ice flow, finite elements, 2-D, 3-D, matlab

\cleardoublepage

%%Table of content
%%%%%%%%%%%%%%%%%%%
%\pagestyle{headings} %entete et pieds de pages par defaut


\tableofcontents
        
\newpage

%%Body
%%%%%%%%%%%
        \chapter*{Introduction}
This document...
\\
\\
\\
KEYWORD: Models, weak formulation, Galerkin, finite element, gauss quadrature,Full stokes, ice sheet numerical finite element model,...

\newpage
\chapter{Physical basis}
This chapter describes the principles of glacier mechanics. We introduce the constitutive relation of ice: Glen's flow law, as well as some basic concepts such as conservation of mass and momentum balance. These equations are used to deduce the three models used in $ISSM$ (Ice Sheet System Model). In a second part, the boundary conditions are presented. The last part is dedicated to a thermodynamic model that was also implemented in $ISSM$.

\section{Notations and geometry}

We consider an ice sheet extending into the ocean. The floating part is an ice shelf.
Deformable subglacial till is present below the grounded ice. The geometry is described by the following scheme:
\\
\begin{figure}[H]
\begin{center}
\includegraphics[width=11cm]{schema1.png}
\caption{Schematic cross section of the glacier}
\label{schema1}
\end{center}
\end{figure}
\vspace*{-0.4cm}
\noindent
The z axis is vertically pointing upward and the sea level is at $z=0$, the xy-plane is horizontal. We note:
\begin{itemize}
        \item[--] $H (x,y)$ glacier thickness
                \vspace*{-0.9mm}
        \item[--] $s(x,y)$  glacier's upper surface z coordinate
                \vspace*{-0.9mm}
        \item[--] $b(x,y)$ glacier's lower surface z coordinate 
\end{itemize}
\vspace*{0.4cm}
Regarding kinematic quantities, we adopt the following notations:
\begin{itemize}
        \item[--] $\overrightarrow{v}(x,y,z)$ is the glacier velocity
                \vspace*{-0.9mm}
        \item[--] $u(x,y,z)$ velocity x-component
                \vspace*{-0.9mm}
        \item[--] $v(x,y,z)$ velocity y-component
                \vspace*{-0.9mm}
        \item[--] $w(x,y,z)$ velocity z-component
                \vspace*{-0.9mm}
        \item[--] $\varepsilon(x,y,z)$ strain tensor
                \vspace*{-0.9mm}
        \item[--] $\dot{\varepsilon}(x,y,z)$ strain rate tensor
                \vspace*{-0.9mm}
        \item[--] $\sigma (x,y,z)$ stress tensor
\end{itemize}

\newpage
\section{Deformation Law}
\subsection{Flow law}

The deformation of ice involves the deviatoric stress tensor because hydrostatic pressure does not contribute to ice deformation. It only depends on shear (Hooke, 2005 \cite{Hooke2005} p13 and Paterson,1994 \cite{Paterson1994}). The deviatoric stress is:

\begin{equation}
\sigma '=\sigma-\frac{1}{3} Tr(\sigma)=\sigma + P \left[ I \right]
\label{deviatoric stress}
\end{equation}
\\
where $\sigma$ is the stress tensor and $P$ is the hydrostatic pressure\footnote{$\displaystyle Tr(\sigma)=\sum_i \sigma_{ii}$ is the stress trace}.The
effective strain and the effective shear stress are defined as follows:

\begin{equation}
\dot{\varepsilon_{e}}= \frac{1}{\sqrt{2}} \left( \sum_{i,j=1..3}
\dot{\varepsilon}_{ij}^{2}\right) ^{1/2}
\qquad \qquad
\sigma'_{e}= \frac{1}{\sqrt{2}} \left( \sum_{i,j=1..3} \sigma_{ij}'^{2}\right) ^{1/2}
\label{epsilone1}
\end{equation}
\\
where $\dot{\varepsilon}$ is the strain rate tensor. The most common flow law is Glen's flow law,
based on John W. Glen's experiments (Glen, 1955 \cite{Glen1955}). He used the form:

\begin{equation}
\begin{array}{|c|}
\hline
\\
\displaystyle \dot{\varepsilon_{e}}=\left( \frac{\sigma'_{e}}{B}\right) ^{n} \\
\\
\hline
\end{array}
\end{equation}
\\
where $B$ is a viscosity parameter which increases as the ice becomes stiffer ($MPa.a^{\frac{1}{n}} $), $n$ is empirically determined(most studies have found that $ n\simeq 3 $, see Hooke, 2005 \cite{Hooke2005} p15 and Paterson, 1994 \cite{Paterson1994} p86) and is called flow law exponent.

\subsection{Constitutive relation of ice}

We consider that ice is an isotropic and incompressible material. This implies that the principal axes
of the deviatoric stress $ \sigma' $ and the strain rate tensor $ \dot{\varepsilon} $
coincide. The ice that constitutes glaciers is not isotropic and incompressible;
but this approximation is a convenient starting point for calculations of glacier flow. If the principal axes of deviatoric stress and  strain rate coincide, the flow law becomes (Hooke, 2005 \cite{Hooke2005}, p269):

\begin{equation}
\dot{\varepsilon}= \frac{{\sigma'_{e}}^{n-1}}{B^n} \sigma '
\end{equation}
\\
Then, combining Glen's flow law to eliminate $\sigma_{e}$, we obtain:

\begin{equation}
\dot{\varepsilon}= \frac{\dot{\varepsilon_{e}}^{\frac{n-1}{n}}}{B} \sigma '
\end{equation}
\\
Following MacAyeal (MacAyeal, 1989 \cite{Macayeal1989}), we define the viscosity $\mu$ as:

\begin{equation}
\begin{array}{|c|}
\hline
\\
\displaystyle \mu= \frac{B}{2\left( \dot{\varepsilon_{e}}^{1-\frac{1}{n}}\right) }\\
\\
\hline
\end{array}
\label{visco}
\end{equation}
\\
Then the constitutive relation for ice becomes:

\begin{equation}
\begin{array}{|c|}
\hline
\\
\displaystyle \sigma'=2\mu\dot{\varepsilon}\\
\\
\hline
\end{array}
\label{constitutive relation}
\end{equation}

\section{Local Conservation of Mass and Momentum}

\subsection{Mass balance}
The most general equation of local mass balance includes a production term $\dot{M}$. With $\rho$ the density of ice, the equation is:

\begin{equation}
\frac{\partial \rho}{\partial t} + div \left( \rho \overrightarrow{v}\right) = \dot{M}
\end{equation}
\\
In a glacier, there is no production of mass locally (surface accumulation and basal melting are not involved in local mass balance, they are treated as boundary conditions). The ice is also treated as incompressible: $\rho$ is constant (Hooke, 2005 \cite{Hooke2005} p14). The previous equation
can be rewritten as follows:

\begin{equation}
\begin{array}{|c|}
\hline
\\
div \left(\overrightarrow{v}\right) = 0\\
\label{incompressibility}
\\
\hline
\end{array}
\end{equation}

\subsection{Momentum balance}
The fundamental equation of momentum conservation (with $\overrightarrow{g}$ the acceleration due to gravity):

\begin{equation}
\underline{Div}\left( \sigma \right) + \rho \overrightarrow{g} =  \rho\frac{d\overrightarrow{v}}{d t}
\end{equation}
\\
For a glacier, the acceleration is small. Thus the acceleration term is negligible compared to the other terms: the ice is described by a quasi-static model (Paterson,1994 \cite{Paterson1994} p258).
If we use the deviatoric stress defined in (\ref{deviatoric stress}), the momentum balance becomes:

\begin{equation}
\underline{Div}\left( \sigma ' \right) -\overrightarrow{grad}P+ \rho\overrightarrow{g} = 0
\end{equation}
\\
using the constitutive relation (\ref{constitutive relation}) gives:

\begin{equation}
 \left\{ \begin{array}{l}
                2 \underline{Div} \left(\mu\dot{\varepsilon}\right) -\overrightarrow{grad}P+ \rho\overrightarrow{g} = 0\\
\\
 \displaystyle           \mu= \frac{B}{2\left( \dot{\varepsilon_{e}}^{1-\frac{1}{n}}\right) }
                 \end{array} \right.
\end{equation}
\\
The momentum balance can hence be described by three different sets of equations that are strictly equivalent to each other:

\subsubsection*{Momentum balance in terms of stress}

\begin{equation}
\begin{array}{| c c c|}
\hline
&&\\ &
 \left\{ \begin{array}{l}
\displaystyle                \frac{\partial{\sigma}_{xx}}{\partial x}+\frac{\partial {\sigma}_{xy}}{\partial y}+\frac{\partial {\sigma}_{xz}}{\partial z}=0\\
\\
\displaystyle              \frac{\partial{\sigma}_{yx}}{\partial x}+\frac{\partial {\sigma}_{yy}}{\partial y}+\frac{\partial {\sigma}_{yz}}{\partial z}=0\\
\\
\displaystyle               \frac{\partial{\sigma}_{zx}}{\partial x}+\frac{\partial {\sigma}_{zy}}{\partial y}+\frac{\partial {\sigma}_{zz}}{\partial z}- \rho g=0
                 \end{array} \right. &\\
&&\\
\hline
\end{array}
\label{dynamics_stress}
\end{equation}  

\subsubsection*{Momentum balance in terms of deviatoric stress}
             
\begin{equation}
\begin{array}{|c c c|}
\hline
&&\\&
 \left\{ \begin{array}{l}
\displaystyle                \frac{\partial{\sigma'}_{xx}}{\partial x}+\frac{\partial {\sigma'}_{xy}}{\partial y}+\frac{\partial {\sigma'}_{xz}}{\partial z}-\frac{\partial P}{\partial x}=0\\
\\
\displaystyle              \frac{\partial{\sigma'}_{yx}}{\partial x}+\frac{\partial {\sigma'}_{yy}}{\partial y}+\frac{\partial {\sigma'}_{yz}}{\partial z}-\frac{\partial P}{\partial y}=0\\
\\
\displaystyle               \frac{\partial{\sigma'}_{zx}}{\partial x}+\frac{\partial {\sigma'}_{zy}}{\partial y}+\frac{\partial {\sigma'}_{zz}}{\partial z}-\frac{\partial P}{\partial z}- \rho g=0
                 \end{array} \right. & \\
&&\\
\hline
\end{array}
\label{dynamics_deviatoricstress}
\end{equation}      

\subsubsection*{Momentum balance in terms of strain rate} 
         
\begin{equation}
\begin{array}{|c c c|}
\hline
&&\\&
 \left\{ \begin{array}{l}
\displaystyle                2\frac{\partial\mu\dot{\varepsilon}_{xx}}{\partial x}+2\frac{\partial \mu\dot{\varepsilon}_{xy}}{\partial y}+2\frac{\partial \mu\dot{\varepsilon}_{xz}}{\partial z}-\frac{\partial P}{\partial x}=0\\
\\
\displaystyle              2\frac{\partial\mu\dot{\varepsilon}_{yx}}{\partial x}+2\frac{\partial \mu\dot{\varepsilon}_{yy}}{\partial y}+2\frac{\partial \mu\dot{\varepsilon}_{yz}}{\partial z}-\frac{\partial P}{\partial y}=0\\
\\
\displaystyle               2\frac{\partial\mu\dot{\varepsilon}_{zx}}{\partial x}+2\frac{\partial \mu\dot{\varepsilon}_{zy}}{\partial y}+2\frac{\partial \mu\dot{\varepsilon}_{zz}}{\partial z}-\frac{\partial P}{\partial z} - \rho g=0\\

                 \end{array} \right. & \\
&&\\
\hline
\end{array}
\label{dynamics_strainrate}
\end{equation}

\newpage
\section{Time evolution of ice thickness}

The thickness of ice varies in time because of: (1) basal melting, (2) surface accumulation and (3) the flow of the glacier itself.
The mass balance of an ice column of section $dxdy$ and height $H$ between a time $t$ and $t+dt$ is:
\vspace*{-3mm}
\begin{figure}[H]
\begin{center}
\includegraphics[width=8cm]{bilanmass.png}
\caption{Mass balance of an ice column}
\label{bilan_mass2}
\end{center}
\end{figure}
\begin{multline}
m(t+dt)-m(t)=\underbrace{dy\int_{b(x)}^{s(x)}\rho u\left( x\right)  dt\;dz + dx\int_{b(y)}^{s(y)}\rho v\left( y\right) dt\;dz}_{Input\quad mass} 
+ \underbrace{\rho\dot{M}_s dxdydt}_{Accumulation}\\
\underbrace{-dy\int_{b(x+dx)}^{s(x+dx)}\rho u\left( x+dx\right)  dt\;dz - dx\int_{b(y+dy)}^{s(y+dy)}\rho v\left( y+dy\right) dt\;dz}_{Output\quad mass}
 - \underbrace{\rho\dot{M}_b dxdydt}_{Melting}
\end{multline}
\\
where $\dot{M}_s$ is the local accumulation-ablation function at the surface ($m.a^{-1}$ ice equivalent, positive when accumulation) and  $\dot{M}_b$ is the local melting rate at the base of the glacier ($m.a^{-1}$ ice equivalent positive when melting).\\
If one uses the relation of incompressibility:

\begin{equation*}
\begin{array}{r c l}
\displaystyle \dfrac{m(t+dt)-m(t)}{\rho dx dy dt} = \dfrac{\partial H}{\partial t} & = &
\displaystyle -\dfrac{1}{dx}\left( \int_{b(x+dx)}^{s(x+dx)}u\left( x+dx\right)  dz -\int_{b(x)}^{s(x)} u\left( x\right)  dz\right) \\
\\
&&
\displaystyle -\dfrac{1}{dy}\left(\int_{b(y+dy)}^{s(y+dy)}v\left( y+dy\right) dz-\int_{b(y)}^{s(y)} v\left( y\right) dz \right) 
 + \dot{M}_s - \dot{M}_b \\
 \\
\end{array}
\end{equation*}
We now introduce the depth-averaged velocity $\quad \displaystyle H\overline{u}=\int_b^s udz\quad$ and $\quad \displaystyle H\overline{v}=\int_b^s vdz$, and obtain:
\vspace*{3mm}
\begin{equation}
\dfrac{\partial H}{\partial t}=-\dfrac{1}{dx}\left( \left( H\overline{u}\right) \left( x+dx\right)-\left( H\overline{u}\right)\left( x\right)\right) \\
-\dfrac{1}{dy}\left(\left( H\overline{v}\right)\left( y+dy\right)-\left( H\overline{v}\right)\left( y\right)\right)
 + \dot{M}_s - \dot{M}_b 
\end{equation}
\\
The evolution of ice thickness is then written as :

\begin{equation}
\begin{array}{|c|}
\hline
\\
\displaystyle \dfrac{\partial H}{\partial t} = - div \left( H 
\left[ \begin{array}{c}
\bar{u} \\
\bar{v}
\end{array}\right] 
\right)+ \dot{M}_s - \dot{M}_b\\
\\
\hline
\end{array}  
\label{prognosticequation}
\end{equation}
\newpage

\section{Boundary Conditions}

All the equations governing ice flow were described in the previous section. The mass conservation, the momentum balance and the constitutive relation of ice give a set of equations that describes completely the ice sheet system dynamics. But one needs boundary conditions to constrain these equations. There are many boundary conditions depending on the interface: ice/atmosphere boundary (air pressure), ice/ocean boundary (water pressure) and ice till boundary (friction). All these boundary conditions are described in this section.

\subsection{Ice/Atmosphere boundary}
The upper surface of the glacier can be viewed as a free surface (since the atmospheric pressure $P_0$ is negligible), the boundary condition is hence:

\begin{equation}
\sigma \overrightarrow{n} = \sigma' \overrightarrow{n} - P\overrightarrow{n} = P_0\overrightarrow{n}\simeq \overrightarrow{0}
\label{iceatm}
\end{equation}
\\
The upper surface of the glacier has the following equation : $ z-s \left( x,y,t\right)=0 $.
The unit normal vector pointing outward from the glacier $\overrightarrow{n}$ is the gradient of the previous equation:

\begin{equation}
 \displaystyle 
\overrightarrow{n}= \frac{1}{ \left(  \displaystyle  \left( \frac{\partial s}{\partial x} \right)^2 + \left( \frac{\partial s}{\partial y} \right)^2+1 \right)^{1/2} }
\left( \begin{array}{c}
\displaystyle                -\frac{\partial s}{\partial x}\\
\\
\displaystyle                 -\frac{\partial s}{\partial y}\\
\\
                1
                \end{array} \right)
\end{equation}


	\subsection{Ice front boundary}
Water applies a pressure on the ice front equal to $P_w= -\rho_w g z$:
\begin{figure}[H]
\begin{center}
\includegraphics[width=13cm]{schema4.png}
\caption{Water pressure on the front of an ice shelf}
\label{schema4}
\end{center}
\end{figure}
The boundary condition is thus:

\begin{equation}
\label{icefrontBC}
\sigma \overrightarrow{n} = \sigma' \overrightarrow{n} - P\overrightarrow{n} = -P_w\overrightarrow{n}
\end{equation}


\newpage

\subsection{Ice/Water boundary}
\label{dirichletvsneumann}
The exact Ice/water boundary condition is a Neumann condition\footnote{A Neumann boundary condition specifies the values that the derivative of a solution is to take on the boundary of the domain}. Unfortunately, if one uses the incompressibility equation to deduce the vertical velocity (e.g. Pattyn), a Dirichlet boundary condition\footnote{A Dirichlet boundary condition specifies the values a solution needs to take on the boundary of the domain} is required. The only way to provide a Dirichlet boundary condition is to assume hydrostatic equilibrium. This gives an expression of the basal vertical velocity.
						\subsubsection{Neumann boundary condition}

The lower surface of the ice shelf in contact with water is subject to the pressure of the water $P_w=-\rho_w g b(x,y)$ where $\rho_w$ is the water density and $b(x,y)$ the glacier base:

\begin{equation}
\sigma \overrightarrow{n} = \sigma' \overrightarrow{n} - P\left[ I \right] \overrightarrow{n} = -P_w\overrightarrow{n}
\end{equation}
\\
%The pressure of the ice at the base of the glacier is $P_i=\rho_i g H(x,y)$ where $\rho_i$ is the ice density and $H(x,y)$ is the ice thickness at this point. So we can write the boundary condition as:
%
%\begin{equation}
%\sigma \overrightarrow{n} = \sigma' \overrightarrow{n} -  \rho_i g H(x,y) \overrightarrow{n} = \rho_w g b(x,y) \overrightarrow{n}
%\end{equation}
%\\
When there is a hydrostatic equilibrium, the water and ice pressure are equal, the boundary condition becomes: 

\begin{equation}
 \sigma' \overrightarrow{n}  = \overrightarrow{0}
\end{equation}
\\
The lower surface of the ice shelf verifies: $ z-b \left( x,y,t\right)=0 $. The unit normal vector pointing outward $\overrightarrow{n}$ is the opposite of the gradient of the previous equation:
\begin{equation}
\overrightarrow{n}= \frac{1}{\left(   \displaystyle  \left( \frac{\partial b}{\partial x} \right)^2 + \left( \frac{\partial b}{\partial y} \right)^2+1 \right)^{1/2}}
\left( \begin{array}{c}
\displaystyle \frac{\partial b}{\partial x}\\
\\
\displaystyle \frac{\partial b}{\partial y}\\
\\
 -1
\end{array} \right)
\end{equation}
						\subsubsection{Dirichlet boundary condition assuming hydrostatic equilibrium}
Using the Lagrangian derivative, the vertical basal velocity is:

\begin{equation}
w_b=\frac{d b}{d t}=\frac{\partial b}{\partial t}+ u_b \frac{\partial b}{\partial x}+v_b \frac{\partial b}{\partial y}
\label{initialwb}
\end{equation}
\\
The ice shelf lies on sea water. We do not have any kinematic information if we do not make any assumption. We suppose as a first order approximation that there is a hydrostatic equilibrium. This imposes:

\begin{equation}
\rho_i H = - \rho_w b
\end{equation}
\\
where $H$ is the ice thickness and $b$ the vertical position of the bed $(b<0)$. If one differentiates this equation, given that $\rho_i$ and $\rho_w$ are constant, one finds :

\begin{equation}
\frac{\partial b }{\partial t } = - \frac{\rho_i }{\rho_w } \frac{\partial H}{\partial t}
\end{equation}
\\
The mass balance of an ice column gives the local ice thickness evolution:

\begin{equation}
\dfrac{\partial H}{\partial t} = - div \left( H 
\left[ \begin{array}{c}
\bar{u} \\
\bar{v}
\end{array}\right] 
\right)+ \dot{M}_s - \dot{M}_b\\
\label{prognosticequation}
\end{equation}
\\
We then use the equation (\ref{prognosticequation}) to evaluate the evolution of the ice thickness with time. With no accumulation and melting, the basal vertical velocity (\ref{initialwb}) is:

\begin{equation}
w_b = u_b \frac{\partial b}{\partial x}+v_b \frac{\partial b}{\partial y} - \frac{\rho_i }{\rho_w } \left( - div \left( H \bar{u} \right) \right)
\end{equation}
\\
Now let us consider the influence of accumulation and melting. If an accumulation of thickness $h$ appears on an ice shelf in hydrostatic equilibrium, it will sink by a height equal to $  \rho_i /\rho_w h$:
\begin{figure}[H]
\begin{center}
\includegraphics[width=12cm]{accumulation.png}
\caption{Evolution of an ice shelf subjected to accumulation}
\label{accumulation}
\end{center}
Same thing for melting: if a thickness $h$ melts at the ice shelf base in hydrostatic equilibrium, it will sink by a height equal to $( 1-\rho_i /\rho_w ) h$:
\vspace*{-5mm}
\end{figure}
\begin{figure}[H]
\begin{center}
\includegraphics[width=12cm]{melting.png}
\caption{Evolution of an ice shelf subjected to melting}
\label{melting}
\end{center}
\end{figure}
\vspace*{-3mm}
\noindent One uses the derivative of the previous equations with respect to time. If there is accumulation at the ice surface, the ice will sink into water with a velocity equal to: 

\begin{equation}
w_b=- \frac{\rho_i }{\rho_w } \dot{M_a} 
\end{equation}
\\
If ice melts at the bottom, the ice will sink with a velocity:

\begin{equation}
w_b=-\left( 1-\frac{\rho_i }{\rho_w } \right)  \dot{M_b}
\end{equation}
Eventually, the basal vertical velocity at ice/water interface is:

\begin{equation}
\begin{array}{|c|}
\hline
\\ \displaystyle
w_b = u_b \frac{\partial b}{\partial x}+v_b \frac{\partial b}{\partial y} - \frac{\rho_i }{\rho_w } \left( - div \left( H \left[ \begin{array}{c}
\bar{u} \\
\bar{v}
\end{array}\right]  \right) \right) - \frac{\rho_i }{\rho_w } \dot{M_a} -\left(1- \frac{\rho_i }{\rho_w }\right)  \dot{M_b}\\
\\
\hline
\end{array}
\label{basalvelocity}
\end{equation}
\newpage

	\subsection{Ice/Till interface}
	The Ice/Till interface is constrained by two boundary conditions. The first one is a Neumann boundary condition describing basal drag (tangent to the interface) and the other one is a Dirichlet boundary condition constraining the vertical velocity.
		\subsubsection{Dynamic boundary condition}
		\label{frictionlawchapter}
The basal friction given by Paterson\cite{Paterson1994} (p151) is: 

\begin{equation}
\Vert \overrightarrow{u_b}\Vert = K N_{eff}^{-q} \Vert \overrightarrow{\tau_b} \Vert^p
\end{equation}
\begin{itemize}
\item[--] $\overrightarrow{u_b}$ is the velocity component, parallel to the bedrock surface $z=b(x,y)$ ($\overrightarrow{v}=\overrightarrow{u_b}+\left(\overrightarrow{v}.\overrightarrow{n} \right) \overrightarrow{n}$)
\item[--] $N_{eff}=g ( \rho H(x,y) + \rho_w b(x,y))$ is the effective pressure at the base
\item[--] $\overrightarrow{\tau_b}$ is the friction stress component, parallel to the bedrock surface  ($\sigma\overrightarrow{n}=\overrightarrow{\tau_b}+\left( \sigma\left( \overrightarrow{n}\right).\overrightarrow{n}\right)  \overrightarrow{n}$)
\item[--] $K$, $q$ and $p$ are constants
\end{itemize}
\vspace*{-0.3cm}
\begin{figure}[H]
\begin{center}
\includegraphics[width=8cm]{friction_geometry.png}
\caption{Ice/Till interface geometry}
\label{friction_geometry}
\end{center}
\end{figure}
\vspace*{-0.4cm}
This friction law may be written in vector form:

\begin{equation}
\overrightarrow{\tau_b} \quad  =  \quad -K^2 N_{eff}^r \|\overrightarrow{v} \|^{s-1}\overrightarrow{u_b} \quad \stackrel{def}{=} \quad -\alpha^2 \overrightarrow{u_b}
\end{equation}
\\
with $r=q/p$ and $s=1/p$. We use $K^2$ to be sure that this quantity is positive (ie. stress opposes the motion).
The unit normal vector $\overrightarrow{n}$ is:
\begin{equation}
\overrightarrow{n}= \frac{1}{\left(   \displaystyle  \left( \frac{\partial b}{\partial x} \right)^2 + \left( \frac{\partial z_b}{\partial y} \right)^2+1 \right)^{1/2}}
\left( \begin{array}{c}
\displaystyle -\frac{\partial b}{\partial x}\\
\\
\displaystyle -\frac{\partial b}{\partial y}\\
\\
+1
\end{array} \right)=
\left( \begin{array}{c}
n_x\\
\\
n_y\\
\\
n_z
\end{array} \right)
\end{equation}
\\
Several approximations can be made depending on the slope. They are despcribed in section \ref{Friction simplifications}.
\newpage

		\subsubsection{Kinematic boundary condition}
There is also a kinematic boundary condition which constraints the vertical component of the glacier velocity $w_b$ at its base. The following scheme (Fig.\ref{friction_kin}) represents a point $M$ on the lower surface of the glacier at a time $t$ and $t+dt$ in the velocity plane (plane $(\overrightarrow{v}, \overrightarrow{e_z})$). The accumulation/ablation is not represented.
\begin{figure}[H]
\begin{center}
\includegraphics[width=13cm]{friction_kin.png}
\caption{vertical displacement of the glacier base}
\label{friction_kin}
\end{center}
\end{figure}
\vspace{-3mm} \noindent
The vertical displacement of $M$ is due to:
\begin{itemize}
\item[--] The bedrock motion (isostatic adjustment): $b(t+dt)-b(t)$
\item[--] The velocity of the glacier (the glacier is sliding and $M$ follows the bedrock geometry)
\end{itemize}
Therefore we have the following equation:

\begin{equation}
z_M(t+dt)-z_M(t)=w_M dt = \left(u \frac{\partial b}{\partial x}+v \frac{\partial b}{\partial y}\right)dt+b(t+dt)-b(t)
\end{equation}
\\
And then one must add the melting rate $\dot{M}_b$ at the base:

\begin{equation}
z_M(t+dt)-z_M(t)=w_Mdt = \left(u_b \frac{\partial b}{\partial x}+v_b \frac{\partial b}{\partial y}\right)dt+b(t+dt)-b(t)-\dot{M}_b dt
\end{equation}
\\
That gives us a constraint\footnote{usually the term $\displaystyle \frac{\partial b}{\partial t}$ is ignored} for the vertical component of the glacier velocity at its base\footnote{The expression of $w_b$ can also be found using the same approach as the ice/water boundary condition. The equation (\ref{initialwb}) is still true without melting or accumulation. Since ice is grounded, the accumulation $\dot{M}_s$ has no effect on $w_b$, whereas basal melting leads to a thinning of the ice sheet at a velocity equal to $ \displaystyle -\dot{M}_b$. If one adds this velocity to equation (\ref{initialwb}), one obtains the exact same equation as demonstrated here} $w_b$:

\begin{equation}
\begin{array}{|c|}
\hline
\\
\displaystyle
w_b =\frac{\partial b}{\partial t}+ u_b \frac{\partial b}{\partial x}+v_b \frac{\partial b}{\partial y}-\dot{M}_b \\
\\
\hline
\end{array}
\end{equation}

\newpage



\subsection{Friction simplifications}
\label{Friction simplifications}

\subsubsection{Development of the boundary condition}

We have the following equations:

\begin{equation}
\label{eq1}
\overrightarrow{\tau_b}=-\alpha^2 u_b= -\alpha^2 \left( \overrightarrow{u}-\left(\overrightarrow{u}.\overrightarrow{n}\right)\overrightarrow{n} \right) 
=-\alpha^2 \left( 
\begin{array}{c}
u\left( 1-{n_x}^2\right)-v n_x n_y -w n_x n_z\\
\\
-u n_x n_y +v\left( 1-{n_y}^2\right) -w n_y n_z\\
\\
-u n_x n_z-v n_y n_z +w\left( 1-{n_z}^2\right)
\end{array}\right) 
\end{equation}
\\
Finally, the exact boundary condition:

\begin{equation}
\overrightarrow{F}=\sigma \overrightarrow{n}=\overrightarrow{\tau_b} + \sigma_{nn} \overrightarrow{n}
= \left(
\begin{array}{c}
-\alpha^2 u\left( 1-{n_x}^2\right)+\alpha^2 v n_x n_y +\alpha^2 w n_x n_z+\sigma_{nn}n_x\\
\\
\alpha^2 u n_x n_y -\alpha^2 v\left( 1-{n_y}^2\right) +\alpha^2 w n_y n_z+\sigma_{nn}n_y\\
\\
\alpha^2 u n_x n_z +\alpha^2 v n_y n_z -\alpha^2 w\left( 1-{n_z}^2\right)+\sigma_{nn}n_z
\end{array}
\right)
\end{equation}
\\
with:

\begin{equation}
\sigma_{nn}  \stackrel{def}{=} 
\sigma  \overrightarrow{n}  . \overrightarrow{n} = \sigma_{xx}{n_x}^2 + \sigma_{yy}{n_y}^2 + \sigma_{zz}{n_z}^2 
+ 2 \sigma_{xy}n_x n_y + 2 \sigma_{xz}n_z n_x + 2 \sigma_{yz}n_z n_y\\
\end{equation}

\subsubsection{Zero order}
We can use a development of near zero order in $n_x$ and $n_y$ condering that the other terms have roughly the same order of magnitude\footnote{An adimensionnalization study not detailed here shows that the results of the following developments are consistent}. We consider that the normal vector is such as $n_x=n_y=0$ and $n_z=-1$. So we have $\sigma_{nn}=\sigma_{zz}+\mathcal{O}(n_x,n_y)$\\
\\
So the previous force becomes:


\begin{equation}
\label{friction0}
\overrightarrow{F}
=  \left(
\begin{array}{c}
-\alpha^2 u+\mathcal{O}(n_x,n_y)\\
\\
-\alpha^2 v+\mathcal{O}(n_x,n_y)\\
\\
\sigma_{zz}+\mathcal{O}(n_x,n_y)
\end{array}
\right)
\end{equation}

\subsubsection{First order}
This relation doesn't consider the slope of the ice sheet base. That's why we will now use a first order development of the boundary condition to consider this slope. We neglect the terms composed with a product of $n_x$ or $n_y$. This imposes:
\begin{equation}
\begin{array}{c c l}
{n_z}^2 & = & 1-{n_x}^2-{n_y}^2 = 1+ \mathcal{O}(n_x^2,n_y^2)\\
\\
\sigma_{nn}  & = & \sigma_{zz} + 2 \sigma_{xz}n_z n_x + 2 \sigma_{yz}n_z n_y+ \mathcal{O}(n_x^2,n_y^2)
\end{array}
\end{equation}
\\
The boundary condition becomes:

\begin{equation}
\label{friction1}
\overrightarrow{F}
= \left(
\begin{array}{c}
-\alpha^2 u +\alpha^2 w n_x n_z+\sigma_{zz}n_x+\mathcal{O}(n_x^2,n_y^2)\\
\\
-\alpha^2 v +\alpha^2 w n_y n_z+\sigma_{zz}n_y+\mathcal{O}(n_x^2,n_y^2)\\
\\
\alpha^2 u n_x n_z+\alpha^2 v n_y n_z+\sigma_{zz}n_z + 2 \sigma_{xz}n_x + 2 \sigma_{yz} n_y+\mathcal{O}(n_x^2,n_y^2)
\end{array}
\right)
\end{equation}

\newpage
\section{Simplified ice flow models}
\label{models}
This section presents the three ice flow models that are implemented in $ISSM$, from the most complex to the simplest. They all use the set of equations described in the first part of this chapter (mass balance, momentum equilibrium and constitutive relation) but have different levels of assumptions to simplify this initial set of equations. The idea is that the simpler, the faster in terms of computational time, but the less precise in terms of physics.

\subsection{Full Stokes Model}

The full Stokes model consists in resolving equations (\ref{dynamics_strainrate}) without approximation. It is a 3d incompressible ice flow model. The pressure $P$ becomes a variable like the velocity $(u, v,w)$. The additional fourth equation comes from incompressibility (\ref{incompressibility}). The equations are:

\begin{equation}
\begin{array}{|c|}
\hline
\\
 \left\{ \begin{array}{l}
\displaystyle                \frac{\partial}{\partial x} \left(  2 \mu \frac{\partial u}{\partial x} \right)
+\frac{\partial}{\partial y} \left(  \mu \frac{\partial u}{\partial y} +\mu \frac{\partial v}{\partial x} \right)
+\frac{\partial}{\partial z} \left(  \mu \frac{\partial u}{\partial z} +\mu \frac{\partial w}{\partial x} \right)
-\frac{\partial P}{\partial x}=0\\
\\
\displaystyle               \frac{\partial}{\partial x} \left(  \mu \frac{\partial u}{\partial y} +\mu \frac{\partial v}{\partial x} \right)
+\frac{\partial}{\partial y} \left(  2 \mu \frac{\partial v}{\partial y} \right)
+\frac{\partial}{\partial z} \left(  \mu \frac{\partial v}{\partial z} +\mu \frac{\partial w}{\partial y} \right)
-\frac{\partial P}{\partial y}=0\\            
\\
\displaystyle               \frac{\partial}{\partial x} \left(  \mu \frac{\partial u}{\partial z} +\mu \frac{\partial w}{\partial x} \right)
+\frac{\partial}{\partial y} \left(  \mu \frac{\partial v}{\partial z} +\mu \frac{\partial w}{\partial y} \right)
+\frac{\partial}{\partial z} \left(  2 \mu \frac{\partial w}{\partial z} \right)
-\frac{\partial P}{\partial z} - \rho g=0\\     
                 \end{array} \right.
                 \\
                 \\
\displaystyle \frac{\partial u}{\partial x}+\frac{\partial v}{\partial y}+\frac{\partial w}{\partial z}=0
\\
\\
\hline
\end{array}
\label{full-stokes}
\end{equation}


\subsection{Pattyn's Higher-order 3d Model}

Pattyn's model is described in Pattyn's 2003 paper \emph{A new three-dimensional higher-order thermomechanical ice sheet model} \cite{Pattyn2003}.
It is a 3d model in which the vertical velocity is deduced from the horizontal components of velocity.
The two main assumptions of this model are (1) the horizontal gradients of the vertical velocity are small compared to the vertical gradient of the horizontal velocity, and (2) the hydrostatic approximation in the vertical. This translates to:
 
\begin{itemize}
\item $\dfrac{\partial w}{\partial x}\ll \dfrac{\partial u}{\partial z}$
\item $\dfrac{\partial w}{\partial y}\ll \dfrac{\partial v}{\partial z}$
\item $\dfrac{\partial \sigma_{xz}}{\partial x} \ll \dfrac{\partial \sigma_{zz}}{\partial z}$
\item $\dfrac{\partial \sigma_{yz}}{\partial y} \ll \dfrac{\partial \sigma_{zz}}{\partial z}$
\\
\end{itemize}
With the second assumption, the third equation of (\ref{full-stokes}) is reduced to:

\begin{equation}
\frac{\partial}{\partial z} \left(  2 \mu \frac{\partial w}{\partial z} \right)-\frac{\partial P}{\partial z} - \rho g=0
\end{equation}
\\
If we integrate this equation from $z$ to the surface $s$, we obtain:

\begin{equation}
P(s)-P(z)=2 \left. \mu \frac{\partial w}{\partial z}\right|_s-2 \left. \mu \frac{\partial w}{\partial z}\right|_z -\rho g \left( s-z\right)
\end{equation}
\\
The boundary conditions at the ice/atmosphere interface (\ref{iceatm}) impose:

\begin{equation}
\sigma_{zz}(s)= 2 \left. \mu \frac{\partial w}{\partial z}\right|_s-P(s)\simeq 0
\end{equation}
\\
Finally the pressure is:

\begin{equation}
P(z)=2 \mu \frac{\partial w}{\partial z}+\rho g \left( s-z\right)
\end{equation}
\\
With this approximation, full Stokes equations (\ref{full-stokes}) become:

\begin{equation}
\begin{array}{c}
 \left\{ \begin{array}{l}
\displaystyle                \frac{\partial}{\partial x} \left(  2 \mu \frac{\partial u}{\partial x} \right)
+\frac{\partial}{\partial y} \left(  \mu \frac{\partial u}{\partial y} +\mu \frac{\partial v}{\partial x} \right)
+\frac{\partial}{\partial z} \left(  \mu \frac{\partial u}{\partial z} -\mu \frac{\partial w}{\partial x} \right)
= \rho g \dfrac{\partial s}{\partial x}\\
\\
\displaystyle               \frac{\partial}{\partial x} \left(  \mu \frac{\partial u}{\partial y} +\mu \frac{\partial v}{\partial x} \right)
+\frac{\partial}{\partial y} \left(  2 \mu \frac{\partial v}{\partial y} \right)
+\frac{\partial}{\partial z} \left(  \mu \frac{\partial v}{\partial z} -\mu \frac{\partial w}{\partial y} \right)
= \rho g \dfrac{\partial s}{\partial y}\\            
\\
\displaystyle               P(z)=2 \mu \frac{\partial w}{\partial z}+\rho g \left( s-z\right)\\     
                 \end{array} \right.
                 \\
                 \\
\displaystyle \frac{\partial u}{\partial x}+\frac{\partial v}{\partial y}+\frac{\partial w}{\partial z}=0
\end{array}
\end{equation}
\\
The second assumption simplifies the first two equations:

\begin{equation}
\begin{array}{c}
 \left\{ \begin{array}{l}
\displaystyle                \frac{\partial}{\partial x} \left(  2 \mu \frac{\partial u}{\partial x} \right)
+\frac{\partial}{\partial y} \left(  \mu \frac{\partial u}{\partial y} +\mu \frac{\partial v}{\partial x} \right)
+\frac{\partial}{\partial z} \left(  \mu \frac{\partial u}{\partial z}\right)
= \rho g \dfrac{\partial s}{\partial x}\\
\\
\displaystyle               \frac{\partial}{\partial x} \left(  \mu \frac{\partial u}{\partial y} +\mu \frac{\partial v}{\partial x} \right)
+\frac{\partial}{\partial y} \left(  2 \mu \frac{\partial v}{\partial y} \right)
+\frac{\partial}{\partial z} \left(  \mu \frac{\partial v}{\partial z} \right)
= \rho g \dfrac{\partial s}{\partial y}\\            
\\
\displaystyle               P(z)=2 \mu \frac{\partial w}{\partial z}+\rho g \left( s-z\right)\\     
                 \end{array} \right.
                 \\
                 \\
\displaystyle \frac{\partial u}{\partial x}+\frac{\partial v}{\partial y}+\frac{\partial w}{\partial z}=0
\end{array}
\end{equation}
\\
The vertical component of the velocity is deduced from the incompressibility equation\footnote{For ice shelves, we will assume hydrostatic equilibrium so that we can use a Dirichlet boundary condition at the ice shelf base for the vertical velocity computation (See section \ref{dirichletvsneumann})} that is integrated from $b$ to $z$. The equations of Pattyn's model become :

\begin{equation}
\begin{array}{|c|}
\hline
\\
 \left\{ \begin{array}{l}
\dfrac{\partial }{\partial x} \left(4 \mu \dfrac{\partial u}{\partial x} + 2 \mu \dfrac{\partial v}{\partial y} \right)+ \dfrac{\partial }{\partial y} \left(\mu \dfrac{\partial u}{\partial y} + \mu \dfrac{\partial v}{\partial x} \right) + \dfrac{\partial }{\partial z}\left( \mu \dfrac{\partial u}{\partial z}\right)= \rho g \dfrac{\partial s}{\partial x}\\
\\
\dfrac{\partial }{\partial x} \left( \mu \dfrac{\partial u}{\partial y} +  \mu \dfrac{\partial v}{\partial x} \right)+ \dfrac{\partial }{\partial y} \left(4 \mu \dfrac{\partial v}{\partial y} + 2 \mu \dfrac{\partial u}{\partial x} \right) + \dfrac{\partial }{\partial z}\left( \mu \dfrac{\partial v}{\partial z}\right)= \rho g \dfrac{\partial s}{\partial y}\\
\\
\displaystyle w\left( x,y,z\right)= w_b\left( x,y,z\right) - \int_{b(x,y)}^{z} \dfrac{\partial u}{\partial x} + \dfrac{\partial v}{\partial y} dz'
                 \end{array} \right.
\\
\\
\hline
\end{array}
\label{Pattyn equations}
\end{equation}
\newpage
\subsection{MacAyeal's Shelfy-stream 2d model}
\label{MAsection}
MacAyeal's model is described in Douglas MacAyeal's 1989 paper \emph{Large-scale Ice Flow Over a Viscous Basal Sediment} \cite{Macayeal1989}.
It is a 2d model, the horizontal components of the velocity are vertically integrated.
The main assumption is that the basal drag associated with deforming basal sediment does not induce significant vertical
gradients of the horizontal velocity. This drove him to make the following assumptions:

\begin{itemize}
\item $\displaystyle \dfrac{\partial u}{\partial z}=0$
\item $\displaystyle \dfrac{\partial v}{\partial z}=0$
\item $\dot{\varepsilon}_{xz}=0$
\item $\dot{\varepsilon}_{yz}=0$
\item bedrock slope assumed to be negligible
\end{itemize}

\noindent These assumptions are stronger than Pattyn's. Therefore, we can use Pattyn's higher order model equations (\ref{Pattyn equations}) as a starting point. If we use the first two assumptions, the first equations of Pattyn's model become:

\begin{equation}
 \left\{ \begin{array}{l}
\displaystyle \dfrac{\partial }{\partial x} \left(4 \mu \dfrac{\partial u}{\partial x} + 2 \mu \dfrac{\partial v}{\partial y} \right)+ \dfrac{\partial }{\partial y} \left(\mu \dfrac{\partial u}{\partial y} + \mu \dfrac{\partial v}{\partial x} \right)  = \rho g \dfrac{\partial s}{\partial x}\\
\\
\displaystyle\dfrac{\partial }{\partial x} \left( \mu \dfrac{\partial u}{\partial y} +  \mu \dfrac{\partial v}{\partial x} \right)+ \dfrac{\partial }{\partial y} \left(4 \mu \dfrac{\partial v}{\partial y} + 2 \mu \dfrac{\partial u}{\partial x} \right)  = \rho g \dfrac{\partial s}{\partial y}\\
                 \end{array} \right.
\end{equation}
\\
One can integrate these equations from the bed $b(x,y)$ to the surface $s(x,y)$:

\begin{equation}
 \left\{ \begin{array}{l}
\displaystyle \int_{b(x,y)}^{s(x,y)}\left(\dfrac{\partial }{\partial x} \left(4 \mu \dfrac{\partial u}{\partial x} + 2 \mu \dfrac{\partial v}{\partial y} \right)+ \dfrac{\partial }{\partial y} \left(\mu \dfrac{\partial u}{\partial y} + \mu \dfrac{\partial v}{\partial x} \right) + \dfrac{\partial }{\partial z}\left( \mu \dfrac{\partial u}{\partial z}\right)\right) dz= \rho g H \dfrac{\partial s}{\partial x}\\
\\
\displaystyle \int_{b(x,y)}^{s(x,y)}\left(\dfrac{\partial }{\partial x} \left( \mu \dfrac{\partial u}{\partial y} +  \mu \dfrac{\partial v}{\partial x} \right)+ \dfrac{\partial }{\partial y} \left(4 \mu \dfrac{\partial v}{\partial y} + 2 \mu \dfrac{\partial u}{\partial x} \right) + \dfrac{\partial }{\partial z}\left( \mu \dfrac{\partial v}{\partial z}\right)\right)  dz= \rho g H \dfrac{\partial s}{\partial y}\\
                 \end{array} \right.
\end{equation}
\\
We can use Leibniz integral rule\footnote{For a given scalar quantity $f(x,z)$, Leibniz integral rule is written:

\begin{equation*}
\dfrac{\partial}{\partial x} \int_{\alpha (x)}^{\beta (x)}f(x,z) dz = \int_{\alpha (x)}^{\beta (x)} \dfrac{\partial}{\partial x} f(x,z) dz + f(x,\beta (x)) \dfrac{\partial \beta (x)}{\partial x}- f(x,\alpha (x)) \dfrac{\partial \alpha (x)}{\partial x}
\end{equation*}
\\
In our case, we use:

\begin{equation*}
\int_{\alpha (x)}^{\beta (x)} \dfrac{\partial}{\partial x} f(x,z) dz = \dfrac{\partial}{\partial x} \int_{\alpha (x)}^{\beta (x)}f(x,z) dz - f(x,\beta (x)) \dfrac{\partial \beta (x)}{\partial x}+ f(x,\alpha (x)) \dfrac{\partial \alpha (x)}{\partial x}
\end{equation*}
} which gives:

\begin{multline}
\dfrac{\partial }{\partial x} \int_{b(x,y)}^{s(x,y)}\left(4 \mu \dfrac{\partial u}{\partial x} + 2 \mu \dfrac{\partial v}{\partial y} \right) dz
+ \dfrac{\partial }{\partial y} \int_{b(x,y)}^{s(x,y)}\left(\mu \dfrac{\partial u}{\partial y} + \mu \dfrac{\partial v}{\partial x} \right) dz\\
-\sigma'_{xx}(s)\dfrac{\partial s}{\partial x}-\sigma'_{xy}(s)\dfrac{\partial s}{\partial x}+\sigma'_{xz}(s)
+\sigma'_{xx}(b)\dfrac{\partial b}{\partial x}+\sigma'_{xy}(b)\dfrac{\partial b}{\partial x}-\sigma'_{xz}(b)
= \rho g H \dfrac{\partial s}{\partial x}\label{MA1}
\end{multline}
\begin{multline}
\dfrac{\partial }{\partial x} \int_{b(x,y)}^{s(x,y)}\left( \mu \dfrac{\partial u}{\partial y} +  \mu \dfrac{\partial v}{\partial x} \right)dz
+ \dfrac{\partial }{\partial y} \int_{b(x,y)}^{s(x,y)}\left(4 \mu \dfrac{\partial v}{\partial y} + 2 \mu \dfrac{\partial u}{\partial x} \right)dz\\
-\sigma'_{yx}(s)\dfrac{\partial s}{\partial x}-\sigma'_{yy}(s)\dfrac{\partial s}{\partial x}+\sigma'_{yz}(s)
+\sigma'_{yx}(b)\dfrac{\partial b}{\partial x}+\sigma'_{yy}(b)\dfrac{\partial b}{\partial x}-\sigma'_{yz}(b)
= \rho g H \dfrac{\partial s}{\partial y}\label{MA2}
\end{multline}

\noindent The boundary conditions at the ice/atmosphere interface (\ref{iceatm}) imposes:

\begin{equation}
\sigma'(s)\overrightarrow{n}=\overrightarrow{0}\\
\end{equation}
\\
To the zero order (horizontal bedrock), the boundary conditions at the ice/till interface (\ref{friction0}) is:

\begin{equation}
\begin{array}{c}
\left( \sigma'(b)\overrightarrow{n}\right)_x=\alpha^2 u\\
\\
\left( \sigma'(b)\overrightarrow{n}\right)_y=\alpha^2 v
\end{array}
\end{equation}
\\
Equation (\ref{MA1}) and (\ref{MA2}) become:

\begin{equation}
 \left\{ \begin{array}{l}
\displaystyle \dfrac{\partial }{\partial x} \int_{b(x,y)}^{s(x,y)}\left(4 \mu \dfrac{\partial u}{\partial x} + 2 \mu \dfrac{\partial v}{\partial y} \right) dz
+ \dfrac{\partial }{\partial y} \int_{b(x,y)}^{s(x,y)}\left(\mu \dfrac{\partial u}{\partial y} + \mu \dfrac{\partial v}{\partial x} \right) dz
= \rho g H \dfrac{\partial s}{\partial x}+\alpha^2 u\\
\\
\displaystyle \dfrac{\partial }{\partial x} \int_{b(x,y)}^{s(x,y)}\left( \mu \dfrac{\partial u}{\partial y} +  \mu \dfrac{\partial v}{\partial x} \right)dz
+ \dfrac{\partial }{\partial y} \int_{b(x,y)}^{s(x,y)}\left(4 \mu \dfrac{\partial v}{\partial y} + 2 \mu \dfrac{\partial u}{\partial x} \right)dz 
= \rho g H \dfrac{\partial s}{\partial y}+\alpha^2 v\\
                 \end{array} \right.
\end{equation}
\\
MacAyeal's assumptions imply that velocities ($u$ and $v$) do not depend on $z$: there is no need to use Leibniz integral law here. We define the depth averaged viscosity as: $\displaystyle H\overline{\mu}=\int_b^s \mu dz$ so that finally we obtain:

\begin{equation}
\begin{array}{|c|}
\hline
\\
\left\{ \begin{array}{l}
\displaystyle \frac{\partial}{\partial x} \left( 4H \bar{\mu} \frac{\partial u}{\partial x}+ 2H \bar{\mu}\frac{\partial v}{\partial y} \right)
+\frac{\partial}{\partial y}\left( H\bar{\mu}  \frac{\partial u}{\partial y}+H\bar{\mu}  \frac{\partial v}{\partial x}\right)
=\rho g H \frac{\partial s}{\partial x} +\alpha^2 u\\
\\
\displaystyle \frac{\partial}{\partial y} \left( 4H \bar{\mu} \frac{\partial v}{\partial y}+2H \bar{\mu}\frac{\partial u}{\partial x}\right) 
+\frac{\partial}{\partial x}\left( H\bar{\mu}\frac{\partial u}{\partial y}+H\bar{\mu}  \frac{\partial v}{\partial x}\right)
=\rho g H \frac{\partial s}{\partial y}+\alpha^2 v\\
                 \end{array} \right.
                 \\
\\
\hline
\end{array}
\end{equation}

\newpage
\section{Thermodynamic model}

A thermal model is essential to predict an ice sheet system's evolution since it affects the flow. The viscosity parameter $B$ is highly temperature-dependent. Temperature also affects melting, which in turn affects the glacier geometry and sliding. It is hence needed in a comprehensive time evolution model.

	\subsection{Local equation}
	
The most general energy balance (Hooke, 2005 \cite{Hooke2005} p117, Paterson, 1994 \cite{Paterson1994} p224) equation includes a conduction term and a source term (here due to viscous heating):

\begin{equation}
\dfrac{d \left( \rho c T\right) }{d t}= div \left( k \; \overrightarrow{grad}\: T\right) +\Phi  
\end{equation}
where:
\begin{itemize}
\item[--] $c$ ice heat capacity ($J kg\textsuperscript{-1} K\textsuperscript{-1}$)
\item[--] $T$ ice temperature ($K$)
\item[--] $k$ ice heat conductivity ($W m\textsuperscript{-1} K\textsuperscript{-1}$)
\item[--] $\Phi$ viscous heating due to ice flow ($W m\textsuperscript{-3}$)
\end{itemize}
Advection appears when one takes the Eulerian version of the previous equations:

\begin{equation}
\dfrac{d \left( \rho c T\right)}{d t}= \dfrac{\partial \left( \rho c T\right)}{\partial t} + \overrightarrow{v}. \overrightarrow{grad}\left( \rho c T \right) 
\end{equation}
this gives:
\begin{equation}
\dfrac{\partial \left( \rho c T\right)}{\partial t}= -\overrightarrow{v}. \overrightarrow{grad}\left( \rho c T \right)
+ div \left( k \; \overrightarrow{grad}\: T\right) +\Phi
\label{thermal1}   
\end{equation}

	\subsection{Simplifications}
In $ISSM$, several assumptions are employed. The first one is that (1) the heat capacity and conductivity are constant, and (2) spatial and thermal dependence of $k$ and $c$ are neglected. These are classical assumptions (Hooke, 2005 \cite{Hooke2005} p117). Using the ice incompressibility, equation (\ref{thermal1}) becomes:
\begin{equation}
\dfrac{\partial T}{\partial t}= -\overrightarrow{v}. \overrightarrow{grad}\left( T \right)+ \dfrac{k}{ \rho c } \Delta T +\dfrac{\Phi}{ \rho c }
\end{equation}
\\
The local heat transfer is thus a result of horizontal and vertical advection, conduction\footnote{In many thermal models, the horizontal advection is neglected (Paterson, 1994 \cite{Paterson1994} p216; Hooke, 2005 \cite{Hooke2005} p118). Horizontal conduction is often neglected as well (Hulbe, 1999 \cite{Hulbe1999}; Hooke, 2005 \cite{Hooke2005} p118). These assumptions are not employed here.}, and internal deformation heating:

\begin{equation}
\begin{array}{|c|}
\hline
\\ \displaystyle
\dfrac{\partial T}{\partial t}= -\left( u\dfrac{\partial T}{\partial x} +v\dfrac{\partial T}{\partial y}  +w\dfrac{\partial T}{\partial z} \right)+ \dfrac{k}{ \rho c }\left( \dfrac{\partial^2 T}{\partial x^2}+\dfrac{\partial^2 T}{\partial y^2}+\dfrac{\partial^2 T}{\partial z^2}\right)   +\dfrac{\Phi}{ \rho c }\\
\\
\hline
\end{array}
\label{thermalequation}
\end{equation}

	\subsection{Internal deformation heating}

The viscous heating due to ice flow is 
\begin{equation}
\Phi=Tr\left( \sigma\dot{\varepsilon}\right)
\end{equation}
\\
One can use the deviatoric stress tensor and use the incompressibility:

\begin{equation}
\Phi =Tr\left( \sigma'\dot{\varepsilon}-P\dot{\varepsilon} \right)= Tr\left( \sigma'\dot{\varepsilon}\right) -P \;Tr\left( \dot{\varepsilon} \right) =Tr\left( \sigma'\dot{\varepsilon}\right)
\end{equation}
We do not use this equation in $ISSM$. We use the effective strain rate $\dot{\varepsilon}_e $ and effective deviatoric stress $\sigma_e $ defined in (\ref{epsilone1}) to obtain:
\begin{equation}
\begin{array}{r l}
\displaystyle \Phi^2 & \displaystyle
= \left( Tr\left( \sigma'\dot{\varepsilon}\right)\right)^2
= \left( \sum_{i,j} \sigma'_{ij} \dot{\varepsilon}_{ji} \right)^2
= \left(\sum_{i,j} \sigma'_{ij} \dot{\varepsilon}_{ij} \right)^2
= \left(\sum_{i,j} \sigma'_{ij} \dot{\varepsilon}_{ij} \right) \left(\sum_{k,l} \sigma'_{kl}\dot{\varepsilon}_{kl} \right)\\
\\ & \displaystyle
= \left(\sum_{i,j} 2 \mu \dot{\varepsilon}_{ij} \dot{\varepsilon}_{ij}\right) \left(  \sum_{k,l} \sigma'_{kl}\dfrac{1}{2 \mu}\sigma'_{kl}\right)
= \sum_{i,j} \dot{\varepsilon}_{ij} ^2 \sum_{kl} {\sigma'_{kl}} ^2
= 2 \dot{\varepsilon}_e^2 \;\; 2  {\sigma'_e }^2
\end{array}
\end{equation}
\\
In conclusion, $ISSM$ uses the following equation:

\begin{equation}
\Phi = 2\dot{\varepsilon}_e \sigma'_e = 4\mu \dot{\varepsilon}_e^2
\end{equation}

	\subsection{Thermal model boundary conditions}
			\subsubsection*{Ice/Atmosphere interface}	
On the upper surface, the temperature is imposed as the mean annual air temperature at the surface, $T_s$.

			\subsubsection*{Ice/Water boundary}
On the Ice/Water interface, there is an imposed flux, which depends on the temperature difference between the ice shelf surface $T_b$ and the ocean $T=T_{pmp}$:

\begin{equation}
k\left. \left( \overrightarrow{grad}\;T\right) \right|_b.\overrightarrow{n} \simeq -k \left. \dfrac{\partial T}{\partial z}\right| _{b}
 =  -\rho_w c_{pM}\gamma\left(T_b-T_{pmp} \right) 
\end{equation}
With: 
\begin{itemize}
\item[--] $\overrightarrow{n}=( n_x, n_y, n_z)$ normal vector pointing outward
\item[--] $c_{pM}$ mixed layer (see Holland, 1999 \cite{Holland1999} p5) specific heat capacity ($J kg\textsuperscript{-1} K\textsuperscript{-1}$)
\item[--] $\gamma$ thermal exchange velocity ($ m s\textsuperscript{-1}$)
\item[--] $T_{pmp}=273.15 - \beta P$ pressure melting point ($K$)(See Paterson \cite{Paterson1994} p212)
\end{itemize}
If the ocean temperature is above the ice shelf base temperature, the flux is positive (heat goes from the ocean to the ice shelf), whereas when the ice shelf base is warmer than the ocean, the flux is negative (heat goes from the ice shelf to the ocean).

			\subsubsection*{Ice/Till boundary}
The basal thermal boundary condition is supplied by a geothermal flux $G$ at the ice sheet bottom and the heat due to basal friction. When the pressure melting point is reached, an additional flux is generated:

\begin{equation}
k\left. \left( \overrightarrow{grad}\;T\right) \right| _b.\overrightarrow{n} \simeq \underbrace{-k \left. \dfrac{\partial T}{\partial z}\right| _{b}}_{Conduction}
 =  \underbrace{G+\overrightarrow{\tau}_b . \overrightarrow{u}_b}_{Energy \; input}+ \underbrace{\rho L \dot{M}_b }_{Melting}
\end{equation}
\\
Where $\overrightarrow{n}=( n_x, n_y, n_z)$ is the unit normal vector pointing outward and $L$ is the specific latent heat of fusion. The basal temperature in the ice mass is kept at the pressure melting point $T_{pmp}= 273.15 - \beta P$ (See Paterson \cite{Paterson1994} p212) whenever it is reached (Pattyn, 2003 \cite{Pattyn2003}). In other words, the boundary condition at the ice/till interface is an imposed flux. When this imposed flux generates ice temperatures above the pressure melting point, the boundary condition is changed into an imposed temperature $T_b=T_{pmp}$.

	\subsection{Transformation of the basal boundary condition}
\label{meltingsection}
At the base, we impose a heat flux, and the temperature cannot exceed $T_{pmp}$. If the temperature reaches the pressure melting point, melting occurs. All these conditions can be summarized by the following equations:

\begin{equation}
\left\{ \begin{array}{l}
\displaystyle -k \left. \dfrac{\partial T}{\partial z}\right| _b =G + \overrightarrow{\tau}_b . \overrightarrow{u}_b - \rho L\dot{M}_b  \\
\\
\displaystyle \dot{M}_b\left( T-T_{pmp}\right) =0 \\
\\
\displaystyle T-T_{pmp} \leq 0 \\
\\
\displaystyle \dot{M}_b \geq 0 \\
                 \end{array} \right.
\end{equation}
\\
The last three equations can be represented by the following graph:
\begin{figure}[H]
\begin{center}
\includegraphics[width=9cm]{TpmpMb.png}
\caption{$\dot{M}_b$ as a function of $T-T_{pmp}$}
\label{TpmpMb}
\end{center}
\end{figure}
\noindent
These equations are not used in $ISSM$ since they are introducing nonlinearities. To avoid that, we use a penalty method exactly as in contact mechanics (See Chapter \ref{chappenalty} for more details).

\section*{Conclusion}
We used the mass conservation, the momentum balance and Glen's flow law to deduce the system of equations that is governing ice flow. This system of equations constitutes the full Stokes equations. This model unfortunately requires huge computational resources in terms of computer memory and execution time: it is a 3d model that solves 4 unknowns ($u,v,w,P$). We also presented two other models: MacAyeal's shelfy-stream model and Frank Pattyn's higher-order model. Frank Pattyn uses still a 3d mesh but decorellates the horizontal velocity components from the vertical component. There are hence only 2 unknowns ($u,v$). Doug MacAyeal went further by vertically integrating the equations, neglecting vertical shear. These three models give three different refinement levels and require three different computational powers, which is priceless to model a continent such as Antarctica since one can use different models on different areas depending on the accuracy needed and the phenomena involved.

\newpage
\chapter{Dynamic Models Finite Element Formulation}
\label{Appendix1}
$ISSM$ uses finite element method to solve the equations described in the first chapter. This chapter explains how we built a finite element model for each solution. MacAyeal's model formulation is very detailed for those who are not very familiar with finite element method.
For more details about finite element method,
the reader is invited to consult Zienkiewicz \emph{The Finite Element Method, Fourth Edition}, 1994 \cite{Zienkiewicz1994}.
    \section{MacAyeal's Shelfy-stream model}

    \subsection{Geometry and notations}
\begin{figure}[H]
\begin{center}
\includegraphics[width=11cm]{schema5.png}
\caption{Geometry and notations}
\label{schema5}
\end{center}
\end{figure}
\vspace*{-0.4cm}
We adopt the following notations:
\begin{itemize}
        \item[--] $\Omega$ is the open surface that constitutes the entire glacier system
                        \vspace*{-0.9mm}
        \item[--] $\partial\Omega$ are  points located at the boundary
                        \vspace*{-0.9mm}
        \item[--] $\Gamma$ are  points located at the ice front
                        \vspace*{-0.9mm}
        \item[--] $\Gamma_u=\partial\Omega\backslash\Gamma$ are all other points located at the boundary\\
\end{itemize}

        \subsection{Equations}

The equations of MacAyeal's Shelfy-stream model are:

\begin{equation}
\label{FEMacAyealEq}
\left\{ \begin{array}{l}
\displaystyle \frac{\partial}{\partial x} \left( 2H \mu \left( 2\frac{\partial u}{\partial x}+\frac{\partial v}{\partial y}\right) \right)
+\frac{\partial}{\partial y}\left( H\mu \left( \frac{\partial u}{\partial y}+\frac{\partial v}{\partial x}\right) \right)
-\rho g H \frac{\partial s}{\partial x} +\tau_x=0\\
\\
\displaystyle \frac{\partial}{\partial y} \left( 2H \mu \left( 2\frac{\partial v}{\partial y}+\frac{\partial u}{\partial x}\right) \right)
+\frac{\partial}{\partial x}\left( H\mu \left( \frac{\partial u}{\partial y}+\frac{\partial v}{\partial x}\right) \right)
-\rho g H \frac{\partial s}{\partial y}+\tau_y=0\\
                 \end{array} \right.
\end{equation}
\\
At the ice front, the boundary condition is (\ref{icefrontBC}):

\begin{equation}
\sigma'  \overrightarrow{n} = \left( P-P_w\right) \overrightarrow{n}
\end{equation}
where:
\begin{itemize}
\item $P=\rho g \left( s-z\right) $ is the ice pressure
\item $P=-\rho_w g z $ is the water pressure $\left( z\leq 0\right) $
\end{itemize}
MacAyeal's model uses vericaly integrated quantities, we must apply the verticaly-integrated form of the previous equation which is:

\begin{equation}
\sigma'  \overrightarrow{n} =\left( \int_b^s \rho g \left( s-z \right) dz+\int_b^0 \rho_w g z dz \right) \overrightarrow{n}  
= \left( \dfrac{1}{2}\rho g H^2 -\dfrac{1}{2} \rho_w g b^2 \right) \overrightarrow{n}
\end{equation}
\\
The boundary conditions are: a dynamic boundary condition (Neumann) at the ice front, a friction law on the ice sheet, and single point constraint (Dirichlet) on the other borders of the domain $\Omega$.
It is more convenient to consider these specified velocities as nill. At the end of the process, the velocity field will be updated to take these constraints into account.

\begin{equation}
\left\{ \begin{array}{l l}
\text{Ice Front } \Gamma_i: & \displaystyle \sigma'   \overrightarrow{n} = F \overrightarrow{n} =\left( \dfrac{1}{2}\rho g H^2 -\dfrac{1}{2}\rho_w g b^2\right) \overrightarrow{n}\\
\\
\text{Other  borders } \Gamma_u: & u=v=0\\
\end{array} \right.
\end{equation}
\newpage
        \subsection{Weak Formulation}

Now that we have all the equations and boundary conditions, we  write the weak formulation to solve these equations
using finite element. We define a kinematically admissible velocity field\footnote{$H^{1}(\Omega\cup\partial\Omega)$ is a Sobolev space that contains all the square-integrable functions defined on $\Omega\cup\partial\Omega$ that have a square-integrable first derivative 
\begin{equation} 
\int_{\Omega\cup\partial\Omega} \phi^2 d\Omega<\infty \text{ and }
\int_{\Omega\cup\partial\Omega} \left( \dfrac{\partial \phi}{\partial x_i}\right) ^2 d\Omega<\infty 
\end{equation}}\footnote{$\overrightarrow{\phi}$ is a 2d function and each of its component 
$\left( \phi_x,\phi_y\right)$ is in $H^{1}(\Omega\cup\partial\Omega)$. Therefore 
$\overrightarrow{\phi} \in \left( H^{1}(\Omega\cup\partial\Omega) \right)^2$ }
 $\overrightarrow{\phi}$:
\begin{equation}
\overrightarrow{\phi}(x,y)\in\lbrace \left( H^{1}(\Omega\cup\partial\Omega) \right)^2 \quad \backslash\quad \overrightarrow{\phi}(x,y)=\overrightarrow{0}\qquad (x,y)\in\Gamma_u\rbrace
\end{equation}
\\
For any function of this virtual field, we take the scalar product of the equations (\ref{FEMacAyealEq}) with $\overrightarrow{\phi}=\left(\phi_x,0 \right) $ and $\overrightarrow{\phi}=\left(0,\phi_y \right) $ that are 2 other kinematically admissible velocity fields, and integrate these products over the domain. Indeed, if $\overrightarrow{\phi}$ is a kinematically admissible velocity field, then $\overrightarrow{\phi_1}=\left(\phi_x,0 \right) $ and $\overrightarrow{\phi_2}=\left(0,\phi_y \right) $ are also two kinematically admissible velocity fields. This gives us:

\begin{equation*}
\iint_\Omega %double
\left[ \frac{\partial}{\partial x} \left(2 H \mu \left( 2\frac{\partial u}{\partial x}+\frac{\partial v}{\partial y}\right) \right)\phi_x
+\frac{\partial}{\partial y}\left( H\mu \left( \frac{\partial u}{\partial y}+\frac{\partial v}{\partial x}\right) \right)\phi_x
-\rho g H \frac{\partial s}{\partial x}\phi_x +\tau_x\phi_x \right]  d\Omega =0
\end{equation*}

\begin{equation*}
\iint_\Omega %double
\left[\frac{\partial}{\partial y} \left( 2H \mu \left( 2\frac{\partial v}{\partial y}+\frac{\partial u}{\partial x}\right) \right) \phi_y
+\frac{\partial}{\partial x}\left( H\mu \left( \frac{\partial u}{\partial y}+\frac{\partial v}{\partial x}\right) \right) \phi_y
-\rho g H \frac{\partial s}{\partial y}\phi_y +\tau_y\phi_y \right]  d\Omega =0
\end{equation*}
\\
One intergrates by parts the two first terms in order to merge in the force on the ice front $\Gamma$:

\begin{multline}
\iint_\Omega  %double
 2H \mu \left( 2\frac{\partial u}{\partial x}+\frac{\partial v}{\partial y}\right) \frac{\partial \phi_x}{\partial x}
+ H\mu \left( \frac{\partial u}{\partial y}+\frac{\partial v}{\partial x}\right)  \frac{\partial \phi_x }{\partial y} -\tau_x\phi_x d\Omega\\
 =\int_\Gamma F n_x\phi_xd\Gamma -
\iint_\Omega %double
\rho g H \frac{\partial s}{\partial x}\phi_x d\Omega
\label{FFU}
\end{multline}
\begin{multline}
\iint_\Omega %double
 2 H \mu \left( 2\frac{\partial v}{\partial y}+\frac{\partial u}{\partial x}\right) \frac{\partial \phi_y}{\partial x}
+ H\mu \left( \frac{\partial u}{\partial y}+\frac{\partial v}{\partial x}\right)  \frac{\partial \phi_y}{\partial y}  -\tau_y\phi_yd\Omega \\
=\int_\Gamma F n_y\phi_y d\Gamma -
\iint_\Omega %double
\rho g H \frac{\partial s}{\partial y}\phi_y d\Omega
\label{FFV}
\end{multline}

        \subsection{Finite element discretisation, Galerkin method}

The domain is meshed using triangles. There are a $nel$ elements and $nods$ grids. We use the nodal functions of each grid, which are continuous on the domain and affine on each element.
We now project the unknows on the nodal functions:

\begin{center}
 $(\phi_i)_{1\leq i\leq nods}$
\end{center}
\begin{equation}
\begin{array}{c}
\displaystyle u\left( x,y\right) = \sum_{i=1}^{nods}u_{i}\phi_{i}\left( x,y\right) \\
\\
\displaystyle v\left( x,y\right) = \sum_{i=1}^{nods}v_{i}\phi_{i}\left( x,y\right)
\end{array}
\label{decomp}
\end{equation}
\\
We build a vector $U$ that holds all the unknowns of the velocity field:

\begin{equation}
U=\left[ \begin{array}{c}
u_{1}\\
v_{1}\\
...\\
u_{nods}\\
v_{nods}\\
                 \end{array} \right]
\end{equation}
\\
With this new field and with $\tau_x = -\alpha^2 u$, $\tau_y = -\alpha^2 v$, we have:
\begin{center}
 $\forall 1 \leq i \leq nods$
\end{center}
\begin{multline}
\sum_{j=1}^{nods} \iint_\Omega  %double
 2H \mu \left( 2 u_{j} \frac{\partial \phi_{j}}{\partial x}+v_j \frac{\partial \phi_{j}}{\partial y}\right) \frac{\partial \phi_i}{\partial x}
+ H\mu \left( u_j \frac{\partial \phi_{j}}{\partial y}+v_j \frac{\partial \phi_{j}}{\partial x}\right)  \frac{\partial \phi_i }{\partial y} +\alpha^2 u_j\phi_j \phi_i d\Omega\\
 =\int_\Gamma F n_x\phi_i d\Gamma -
\iint_\Omega %double
\rho g H \frac{\partial s}{\partial x}\phi_i d\Omega
\end{multline}
\begin{multline}
\sum_{j=1}^{nods} \iint_\Omega %double
 2 H \mu \left( 2 v_j \frac{\partial \phi_{j}}{\partial y}+u_j \frac{\partial \phi_{j}}{\partial x}\right) \frac{\partial \phi_i}{\partial y}
+ H\mu \left( u_j\frac{\partial \phi_{j}}{\partial y}+v_j\frac{\partial \phi_{j}}{\partial x}\right)  \frac{\partial \phi_i}{\partial x}  +\alpha^2 v_j\phi_j\phi_id\Omega \\
=\int_\Gamma F n_y\phi_i d\Gamma -
\iint_\Omega %double
\rho g H \frac{\partial s}{\partial y}\phi_i d\Omega
\end{multline}
By rearranging terms:
\begin{center}
 $\forall 1 \leq i \leq nods$
\end{center}
\begin{multline}
\sum_{j=1}^{nods} \iint_\Omega  %double
  \left( 4 H \mu \frac{\partial \phi_{j}}{\partial r} \frac{\partial \phi_i}{\partial r} 
  + H \mu \frac{\partial \phi_{j}}{\partial y} \frac{\partial \phi_i}{\partial y} +\alpha^2 \phi_j \phi_i \right)  u_j
+ \left( 2 H \mu \frac{\partial \phi_{j}}{\partial y}\frac{\partial \phi_i }{\partial x} + 
H \mu\frac{\partial \phi_{j}}{\partial x} \frac{\partial \phi_{i}}{\partial y} \right) v_j  d\Omega\\
 =\int_\Gamma F n_x\phi_i d\Gamma -
\iint_\Omega %double
\rho g H \frac{\partial s}{\partial x}\phi_i d\Omega
\label{FFU2} 
\end{multline}
\begin{multline}
\sum_{j=1}^{nods} \iint_\Omega  %double
  \left( 2 H \mu \frac{\partial \phi_{j}}{\partial x} \frac{\partial \phi_i}{\partial y} 
  + H \mu \frac{\partial \phi_{j}}{\partial y} \frac{\partial \phi_i}{\partial x} \right)  u_j
+ \left( 4 H \mu \frac{\partial \phi_{j}}{\partial y}\frac{\partial \phi_i }{\partial y} + 
H \mu\frac{\partial \phi_{j}}{\partial x} \frac{\partial \phi_{i}}{\partial x}+\alpha^2 \phi_j \phi_i  \right) v_j  d\Omega\\
 =\int_\Gamma F n_y\phi_i d\Gamma -
\iint_\Omega %double
\rho g H \frac{\partial s}{\partial y}\phi_i d\Omega
\label{FFV2} 
\end{multline}
\\
We see the stiffness matrix $K$ and load vector $F$ appearing, so that the previous equation can be written in matrix form:
\begin{equation}
\left[ K \right] U =F 
\label{FE}
\end{equation} 
\\
or

\begin{equation}
\left[
\begin{array}{c c c c} %K
 & \vdots & \vdots & \\
 \cdots & K_{2i-1,2j-1} &  K_{2i-1,2j} & \cdots\\
 &&& \\
  \cdots & K_{2i,2j-1} &  K_{2i,2j} & \cdots\\
   & \vdots & \vdots & \\
\end{array}
\right]
\left[
\begin{array}{c} %U
\vdots \\
u_j\\
\\
v_j\\
\vdots\\
\end{array}
\right]
=
\left[
\begin{array}{c} %F
\vdots \\
F_{2j-1}\\
\\
F_{2j}\\
\vdots\\
\end{array}
\right]
\end{equation}
\\
We have the following expressions:

\begin{equation}
\begin{array}{l l}
\displaystyle

K_{2i-1,2j-1} &\displaystyle = 
\iint_\Omega  %double
  \left( 4 H \mu \frac{\partial \phi_{j}}{\partial x} \frac{\partial \phi_i}{\partial x} 
  + H \mu \frac{\partial \phi_{j}}{\partial y} \frac{\partial \phi_i}{\partial y} +\alpha^2 \phi_j \phi_i \right) d\Omega\\

\\

\displaystyle
K_{2i-1,2j} &\displaystyle = 
\iint_\Omega  %double
\left( 2 H \mu \frac{\partial \phi_{j}}{\partial y}\frac{\partial \phi_i }{\partial x} + 
H \mu\frac{\partial \phi_{j}}{\partial x} \frac{\partial \phi_{i}}{\partial y} \right) d\Omega \\

\\

\displaystyle
K_{2i,2j-1} &\displaystyle = 
\iint_\Omega  %double
  \left( 2 H \mu \frac{\partial \phi_{j}}{\partial x} \frac{\partial \phi_i}{\partial y} 
  + H \mu \frac{\partial \phi_{j}}{\partial y} \frac{\partial \phi_i}{\partial x} \right)  d\Omega\\
  
\\

\displaystyle
K_{2i,2j} &\displaystyle = 
\iint_\Omega  %double
\left( 4 H \mu \frac{\partial \phi_{j}}{\partial y}\frac{\partial \phi_i }{\partial y} + 
H \mu\frac{\partial \phi_{j}}{\partial x} \frac{\partial \phi_{i}}{\partial x}+\alpha^2 \phi_j \phi_i  \right)  d\Omega \\

\\

\displaystyle
F_{2i-1} &\displaystyle =
\int_\Gamma F n_x\phi_i d\Gamma -
\iint_\Omega %double
\rho g H \frac{\partial s}{\partial x}\phi_i d\Omega\\

\\

\displaystyle
 F_{2i} & \displaystyle = 
\int_\Gamma F n_y\phi_i d\Gamma -
\iint_\Omega %double
\rho g H \frac{\partial s}{\partial y}\phi_i d\Omega \\
\end{array}
\end{equation}
\newpage
        \subsection{Decomposition over the elements}
        
The integrals over $\Omega$ can be divided in several integrals over each elements. Remembering that the mesh contains $nel$ elements,equations (\ref{FFU2}) and (\ref{FFV2}) become: 
\begin{center}
 $\forall 1 \leq i \leq nods$
\end{center}
\begin{multline}
\sum_{E=1}^{nel} \left( 
\sum_{j=1}^{nods} \iint_E  %double
  \left( 4 H \mu \frac{\partial \phi_{j}}{\partial x} \frac{\partial \phi_i}{\partial x} 
  + H \mu \frac{\partial \phi_{j}}{\partial y} \frac{\partial \phi_i}{\partial y} +\alpha^2 \phi_j \phi_i \right)  u_j
+ \left( 2 H \mu \frac{\partial \phi_{j}}{\partial y}\frac{\partial \phi_i }{\partial x} + 
H \mu\frac{\partial \phi_{j}}{\partial x} \frac{\partial \phi_{i}}{\partial y} \right) v_j
dS \right) \\
 =\sum_{E=1}^{nel} \left(
\int_{E \cup\Gamma} 
F n_x\phi_i dl -
\iint_E %double
\rho g H \frac{\partial s}{\partial x}\phi_i dS  
\right)
\end{multline}
\begin{multline}
\sum_{E=1}^{nel} \left(
\sum_{j=1}^{nods}  
\iint_E %double
 \left( 2 H \mu \frac{\partial \phi_{j}}{\partial x} \frac{\partial \phi_i}{\partial y} 
  + H \mu \frac{\partial \phi_{j}}{\partial y} \frac{\partial \phi_i}{\partial x} \right)  u_j
+ \left( 4 H \mu \frac{\partial \phi_{j}}{\partial y}\frac{\partial \phi_i }{\partial y} + 
H \mu\frac{\partial \phi_{j}}{\partial x} \frac{\partial \phi_{i}}{\partial x}+\alpha^2 \phi_j \phi_i  \right) v_j
 dS  \right) \\
=\sum_{E=1}^{nel}\left(
\int_{E \cup\Gamma} F n_y\phi_i dl -
\iint_E %double
\rho g H \frac{\partial s}{\partial y}\phi_i dS  
\right)
\end{multline}
\\
To compute the matrices $K$ and $F$, instead of calculating the integral over $\Omega$ directly, we will first integrate over each element $E$ 
of the mesh to obtain several \emph{Elementary Matrices}, that will be assembled to get the final Stiffness matrix and load vector during the assembly process.\\
\\
The nodal functions are built so that $\forall 1\leq i \leq nods$:

\begin{equation}
\phi_i(N_j)=\delta_{ij}
\end{equation}
\\
where $\delta_{ij}$ is the Kronecker symbol. The nodal function is equal to 1 at a node and 0 on every other nodes. So for one element $E$, the only nodal 
functions that are useful in (\ref{FFU}) and (\ref{FFV}) (ie: do not give 0=0) are the nodal functions corresponding to the vertexes of the element.
 Since the elements are triangle, there are only 3 nodal functions that need to be taken into account.\\
\\
One element $E$ gives 6 equations: we take 3 nodal functions for $\phi_i(x,y)$ (the nodal functions corresponding to the vertexes of $E$),
and each $\phi_i$ gives 2 equations (one for the x-component, and one for the y-component). Therefore, an elementary stiffness matrix $K_E$ will be $6 \times 6$, and the elementary load vector will be of size $6$.
\newpage
        \subsection{Reference element and numerical integration}
        
Rather than calculating these integrals for each element, one uses a \emph{Reference Element} $\hat{E}$, and a transformation $\varphi$ that transforms the reference element to the element $E$ (See Fig.\ref{triangles}):
\begin{figure}[H]
\begin{center}
\includegraphics[width=15cm]{triaelem.png}
\caption{Transformation from the reference triangle, to the current element of the mesh}
\label{triangles}
\end{center}
\end{figure}
For any function $f(x,y)$, the transformation verifies:

\begin{equation}
\iint_E f(x,y)dS = \iint_{\hat{E}} \hat{f}(r,s) \vert J \vert d\hat{S}
\end{equation}
\\
Where $J$ is the Jacobian determinant of the $\varphi$. This Jacobian is calculated in section \ref{RE2D} and is constant over the element:

\begin{equation}
J=
\left[
\begin{array}{c c}
\displaystyle 
\frac{1}{2}\left( x_2-x_1 \right) & \displaystyle  \frac{\sqrt{3}}{6}\left(2x_3-x_1-x_2\right) \\
\\
\displaystyle 
\frac{1}{2}\left( y_2- y_1\right)& \displaystyle  \frac{\sqrt{3}}{6}\left(2y_3-y_1-y_2\right)
 \\
\end{array}
\right]
\end{equation}
\\
Since $ISSM$ is a Matlab code, the integrals cannot be calculated directly. The numerical integration use a gaussian quadrature to approximate the integral as a weighted sum of function values at specified points (gaussian points) within the domain:

\begin{equation}
\iint_E f(x,y)dS = \iint_{\hat{E}} \hat{f}(r,s) \vert J\vert d\hat{S} \simeq \sum_{g=1}^{n} w_g \hat{f}(r_g,s_g)
\end{equation}
\\
where $w_g$ are the quadrature rules weights and $(r_g,s_g)$ are the evaluation points, $g=1,2...,n$. The gauss quadrature is such that it makes the computed integral exact for all polynomials of a certain degree. All the integrals that appear in the stiffness matrix and load vector involve polynomials since nodal function are polynomials of degree 1. It is then easy to evaluate the degree of the polynomial to integrate (usually 2), and then find the gauss quadrature that gives an exact computed integral. 

The integration points are given with their area coordinates (See Fig.\ref{triangles2}): 

\begin{equation}
\displaystyle (r_g,s_g)\equiv (\frac{A_1}{A_1+A_2+A_3},\frac{A_2}{A_1+A_2+A_3},\frac{A_3}{A_1+A_2+A_3})
\end{equation}
\\
We use this system of coordinates because they have the following property:

\begin{equation}
1 \leq k \leq 3\quad \quad \frac{A_k}{A_1+A_2+A_3}=L_k(r_i,s_i)
\end{equation}
\\\begin{figure}[H]
\begin{center}
\includegraphics[width=8cm]{barycentric_tria.png} 
\caption{Area coordinates}
\label{triangles2}
\end{center}
\end{figure}

The number of gaussian points depends on the order of integration. The order of integration can be computed from the polynomial degree $p$ that needs to be integrated. The formula is:

\begin{equation}
order=\frac{p+1}{2}
\end{equation}
\\
Here, the degree of the polynome under the integral is $2$ (the drag implies the calculation of $\phi_j \phi_i$ whose degree is 2). The order of integration is hence 2 (the order must be an integer). For this order, $3$ gaussian points are required:

\begin{center}
\begin{tabular}{|l |c| c| c|}
\hline
&&&\\
Gaussian point & 1 & 2 & 3 \\
&&&\\
\hline
\hline
&&&\\
Weight & 0.577 & 0.577 & 0.577\\
&&&\\
\hline
&&&\\
Area coordinates &
$
\begin{array}{c}
\displaystyle \frac{2}{3}\\
\\
\displaystyle \frac{1}{6}\\
\\
\displaystyle \frac{1}{6}\\
\end{array}
$
&
$
\begin{array}{c}
\displaystyle \frac{1}{6}\\
\\
\displaystyle \frac{2}{3}\\
\\
\displaystyle \frac{1}{6}\\
\end{array}
$
&
$
\begin{array}{c}
\displaystyle \frac{1}{6}\\
\\
\displaystyle \frac{1}{6}\\
\\
\displaystyle \frac{2}{3}\\
\end{array}
$
\\
&&&\\
\hline
\end{tabular}
\end{center}
\newpage
        \subsection{Elementary stiffness matrix}
To compute the elementary stiffness matrix, we first remove the basal drag, that will create a first elementary stiffness matrix $K1$, the basal drag will constitute another stiffness matrix $K2$. The elementary stiffness matrix will be the sum of $K1$ and $K2$ ($K_E=K1+K2$).

        \subsubsection{Without basal drag}

This matrix has the following shape:

\begin{center}
 $1 \leq i \leq 3$ and  $1 \leq j \leq 3$ 
\end{center}
\begin{equation}
\begin{array}{l c r}
\displaystyle
K1_{2i-1,2j-1} & = & \displaystyle 
\iint_E  %double
  \left( 4 H \mu \frac{\partial \phi_{j}}{\partial x} \frac{\partial \phi_i}{\partial x} 
  + H \mu \frac{\partial \phi_{j}}{\partial y} \frac{\partial \phi_i}{\partial y}\right) d\Omega\\

\\

\displaystyle
K1_{2i-1,2j}& = & \displaystyle  
\iint_E  %double
\left( 2 H \mu \frac{\partial \phi_{j}}{\partial y}\frac{\partial \phi_i }{\partial x} + 
H \mu\frac{\partial \phi_{j}}{\partial x} \frac{\partial \phi_{i}}{\partial y} \right) d\Omega \\

\\

\displaystyle
K1_{2i,2j-1}& = & \displaystyle 
\iint_E  %double
  \left( 2 H \mu \frac{\partial \phi_{j}}{\partial x} \frac{\partial \phi_i}{\partial y} 
  + H \mu \frac{\partial \phi_{j}}{\partial y} \frac{\partial \phi_i}{\partial x} \right)  d\Omega\\
  
\\

\displaystyle
K1_{2i,2j}& = & \displaystyle 
\iint_E  %double
\left( 4 H \mu \frac{\partial \phi_{j}}{\partial y}\frac{\partial \phi_i }{\partial y} + 
H \mu\frac{\partial \phi_{j}}{\partial x} \frac{\partial \phi_{i}}{\partial x} \right)  d\Omega \\
\end{array}
\end{equation}
\\
Using the reference element $\hat{E}$ and the gaussian points, this matrix become:
\begin{center}
 $1 \leq i \leq 3$ and  $1 \leq j \leq 3$ 
\end{center}
\begin{equation*}
\begin{array}{l l}
\displaystyle
K1_{2i-1,2j-1}&\displaystyle = 
\iint_{\hat{E}}  %double
  \left( 4 H \mu \frac{\partial L_{j}}{\partial \varphi_x(r,s)} \frac{\partial L_i}{\partial \varphi_x(r,s)} 
  + H \mu \frac{\partial L_{j}}{\partial \varphi_y(r,s)} \frac{\partial L_i}{\partial \varphi_y(r,s)}\right) \vert J \vert d\hat{S}
\\ \\ &
\displaystyle \simeq
\sum_{g=1}^3  w_g \left( 4 H \mu \frac{\partial L_{j}}{\partial \varphi_x(r,s)} \frac{\partial L_i}{\partial \varphi_x(r,s)} 
  + H \mu \frac{\partial L_{j}}{\partial \varphi_y(r,s)} \frac{\partial L_i}{\partial \varphi_y(r,s)}\right) \vert J \vert  \\

\\

\displaystyle
K1_{2i-1,2j} &\displaystyle = 
\iint_{\hat{E}}  %double
\left( 2 H \mu \frac{\partial L_{j}}{\partial \varphi_y(r,s)}\frac{\partial L_i }{\partial \varphi_x(r,s)} + 
H \mu\frac{\partial L_{j}}{\partial \varphi_x(r,s)} \frac{\partial L_{i}}{\partial \varphi_y(r,s)} \right) \vert J \vert d\hat{S} 
\\ \\ &
\displaystyle \simeq
\sum_{g=1}^3  w_g 
\left( 2 H \mu \frac{\partial L_{j}}{\partial \varphi_y(r,s)}\frac{\partial L_i }{\partial \varphi_x(r,s)} + 
H \mu\frac{\partial L_{j}}{\partial \varphi_x(r,s)} \frac{\partial L_{i}}{\partial \varphi_y(r,s)} \right) \vert J \vert
\\

\\

\displaystyle
K1_{2i,2j-1} & \displaystyle = 
\iint_{\hat{E}}  %double
  \left( 2 H \mu \frac{\partial L_{j}}{\partial \varphi_x(r,s)} \frac{\partial L_i}{\partial \varphi_y(r,s)} 
  + H \mu \frac{\partial L_{j}}{\partial \varphi_y(r,s)} \frac{\partial L_i}{\partial \varphi_x(r,s)} \right)  \vert J \vert d\hat{S}
\\ \\ &
\displaystyle \simeq
\sum_{g=1}^3  w_g 
\left( 2 H \mu \frac{\partial L_{j}}{\partial \varphi_x(r,s)} \frac{\partial L_i}{\partial \varphi_y(r,s)} 
  + H \mu \frac{\partial L_{j}}{\partial \varphi_y(r,s)} \frac{\partial L_i}{\partial \varphi_x(r,s)} \right)
\vert J \vert
\\

\\

\displaystyle
K1_{2i,2j} & \displaystyle = 
\iint_{\hat{E}}  %double
\left( 4 H \mu \frac{\partial L_{j}}{\partial \varphi_y(r,s)}\frac{\partial L_i }{\partial \varphi_y(r,s)} + 
H \mu\frac{\partial L_{j}}{\partial \varphi_x(r,s)} \frac{\partial L_{i}}{\partial \varphi_x(r,s)} \right)  \vert J \vert d\hat{S} 
\\ \\ &
\displaystyle \simeq
\sum_{g=1}^3  w_g 
\left( 4 H \mu \frac{\partial L_{j}}{\partial \varphi_y(r,s)}\frac{\partial L_i }{\partial \varphi_y(r,s)} + 
H \mu\frac{\partial L_{j}}{\partial \varphi_x(r,s)} \frac{\partial L_{i}}{\partial \varphi_x(r,s)} \right)
\vert J \vert
\\
\end{array}
\end{equation*}
\\
This elementary stiffness matrix is calculated with three matrices: $\displaystyle K1= \sum_{g=1}^3 [B]^T[D][B']$ as follows\footnote{$\left[ I_n\right]$ is a common notation for an identity matrix of size $n\times n$}:
\begin{center}
$D=2 w_g H \mu \vert J \vert \left[ I_3\right]  $ 
\end{center}
\begin{equation}
[B]^T=
\left[
\begin{array}{c c c}
\displaystyle 
\frac{\partial L_1}{\partial \varphi_x(r,s)} & 0 & \displaystyle  \frac{1}{2} \frac{\partial L_1}{\partial \varphi_y(r,s)} \\
\\
\displaystyle 
0 &\displaystyle   \frac{\partial L_1}{\partial \varphi_y(r,s)} & \displaystyle  \frac{1}{2} \frac{\partial L_1}{\partial \varphi_x(r,s)} \\
\\
 \displaystyle 
 \frac{\partial L_2}{\partial \varphi_x(r,s)} & 0 &\displaystyle   \frac{1}{2} \frac{\partial L_2}{\partial \varphi_y(r,s)} \\
\\
\displaystyle 
0 &\displaystyle   \frac{\partial L_2}{\partial \varphi_y(r,s)} & \displaystyle  \frac{1}{2} \frac{\partial L_2}{\partial \varphi_x(r,s)}  \\
\\
\displaystyle 
\frac{\partial L_3}{\partial \varphi_x(r,s)} & 0 &\displaystyle  \frac{1}{2} \frac{\partial L_3}{\partial \varphi_y(r,s)}  \\
\\
\displaystyle 
0 &\displaystyle   \frac{\partial L_3}{\partial \varphi_y(r,s)} &\displaystyle   \frac{1}{2} \frac{\partial L_3}{\partial \varphi_x(r,s)} \\
\\
\end{array}
\right]
\end{equation}
\begin{equation}
[B']=
\left[
\begin{array}{c c c c c c}
\displaystyle 
2 \frac{\partial L_1}{\partial \varphi_x(r,s)} & \displaystyle   \frac{\partial L_1}{\partial \varphi_y(r,s)} 
& \displaystyle 2\frac{\partial L_2}{\partial \varphi_x(r,s)} & \displaystyle   \frac{\partial L_2}{\partial \varphi_y(r,s)} 
& \displaystyle  2\frac{\partial L_3}{\partial \varphi_x(r,s)} & \displaystyle  \frac{\partial L_3}{\partial \varphi_y(r,s)}\\
\\
\displaystyle   \frac{\partial L_1}{\partial \varphi_x(r,s)} &  \displaystyle  2\frac{\partial L_1}{\partial \varphi_y(r,s)} &
\displaystyle   \frac{\partial L_2}{\partial \varphi_x(r,s)} &  \displaystyle  2\frac{\partial L_2}{\partial \varphi_y(r,s)} &
\displaystyle    \frac{\partial L_3}{\partial \varphi_x(r,s)} & \displaystyle   2\frac{\partial L_3}{\partial \varphi_y(r,s)}\\
  \\
\displaystyle   \frac{\partial L_1}{\partial \varphi_y(r,s)} &  \displaystyle  \frac{\partial L_1}{\partial \varphi_x(r,s)} &
\displaystyle   \frac{\partial L_2}{\partial \varphi_y(r,s)} &  \displaystyle  \frac{\partial L_2}{\partial \varphi_x(r,s)} &
\displaystyle    \frac{\partial L_3}{\partial \varphi_y(r,s)} & \displaystyle  \frac{\partial L_3}{\partial \varphi_x(r,s)}\\  
\end{array}
\right]
\end{equation}
\\
\emph{NB:} in $ISSM$ code, the factor $2$ in the $D$ matrix does not exist since the constitutive relation used is $\sigma'=\mu\varepsilon$ instead of $\sigma'=2\mu\varepsilon$. This changes the viscosity definition that must be multiplied by $2$.

               \subsubsection{Computation of nodal function derivatives}
               
               
The computation of $\displaystyle \frac{\partial L_i}{\partial \varphi_x(r,s)}$ and $\displaystyle \frac{\partial L_i}{\partial \varphi_y(r,s)}$ is done using the Jacobian of $\varphi$. We have:
\begin{equation}
\left[
\begin{array}{c}
\displaystyle 
\frac{\partial L_i}{\partial \varphi_x(r,s)}\\
\\
\displaystyle 
\frac{\partial L_i}{\partial \varphi_y(r,s)}
\end{array}
\right] = \left[
\begin{array}{c c}
\displaystyle 
\frac{\partial r}{\partial \varphi_x(r,s)} & \displaystyle \frac{\partial s}{\partial \varphi_x(r,s)}\\
\\
\displaystyle 
\frac{\partial r}{\partial \varphi_y(r,s)} & \displaystyle \frac{\partial s}{\partial \varphi_y(r,s)}\\
\end{array}
\right] 
\left[
\begin{array}{c}
\displaystyle 
\frac{\partial L_i}{\partial r}\\
\\
\displaystyle 
\frac{\partial L_i}{\partial s}
\end{array}
\right] 
\end{equation}
\\
The Jacobian of $\varphi$ is:

\begin{equation}
\left[ J_\varphi\right]=
\left[
\begin{array}{c c}
\displaystyle 
\frac{\partial \varphi_x }{\partial r} & \displaystyle  \frac{\partial \varphi_x }{\partial s} \\
\\
\displaystyle 
\frac{\partial \varphi_y }{\partial r} & \displaystyle  \frac{\partial \varphi_y }{\partial s} \\
\end{array}
\right]
\end{equation}
\\
We have: $\displaystyle \left[ J_\varphi\right] ^{-1}=\left[ J_{\varphi^{-1}}\right] $. This gives us:

\begin{equation}
\left[ J_\varphi\right] ^{-1}=
\left[
\begin{array}{c c}
\displaystyle 
\frac{\partial r}{\partial \varphi_x } & \displaystyle  \frac{\partial r }{\partial \varphi_y } \\
\\
\displaystyle 
\frac{\partial s }{\partial \varphi_x } & \displaystyle  \frac{\partial s }{\partial \varphi_y } \\
\end{array}
\right]
\end{equation}
\\
And finally, we obtain:

\begin{equation}
\left[
\begin{array}{c}
\displaystyle 
\frac{\partial L_i}{\partial \varphi_x(r,s)}\\
\\
\displaystyle 
\frac{\partial L_i}{\partial \varphi_y(r,s)}
\end{array}
\right] = \left( \left[
J
\right]^{-1} \right) ^{T}
\left[
\begin{array}{c}
\displaystyle 
\frac{\partial L_i}{\partial r}\\
\\
\displaystyle 
\frac{\partial L_i}{\partial s}
\end{array}
\right] 
\end{equation}

       
               \subsubsection{Basal drag}
This matrix has the following shape:

\begin{equation}
\begin{array}{l}
\displaystyle
K_{2i-1,2j-1}= 
\iint_E  %double
\alpha^2 \phi_j \phi_i  d\Omega\\
\\
\displaystyle
K_{2i-1,2j}= 0\\
\\
\displaystyle
K_{2i,2j-1}= 0\\
\\
\displaystyle
K_{2i,2j}= 
\iint_E  %double
\alpha^2 \phi_j \phi_i d\Omega \\
\end{array}
\end{equation}
\\        
Using the reference element $\hat{E}$ and the gaussian points, this matrix become:
        
        \begin{equation}
\begin{array}{l l l}
\displaystyle
K_{2i-1,2j-1} & = \displaystyle 
\iint_{\hat{E}}  %double
\alpha^2 L_j(r,s) L_i(r,s)   \vert J \vert d\hat{S}
&
\displaystyle \simeq
\sum_{g=1}^3
w_g \alpha^2 L_j(r_g,s_g) L_i(r_g,s_g)   \vert J \vert
 \\
\\
\displaystyle
K_{2i-1,2j} & = 0 &\\
\\
\displaystyle
K_{2i,2j-1} & = 0 &\\
\\
\displaystyle
K_{2i,2j} & = \displaystyle 
\iint_{\hat{E}}  %double
\alpha^2 L_j(r,s) L_i(r,s)  \vert J \vert d\hat{S} &
\displaystyle \simeq
\sum_{g=1}^3
w_g \alpha^2 L_j(r_g,s_g) L_i(r_g,s_g)   \vert J \vert 
 \\
 \\
\end{array}
\end{equation}
\\     
The values $L_i(r_g,s_g)$ are equal to the component of the area coordinates (ie. for example $L_1(r_2,s_2)=1/6$). This matrix is calculated with three matrices: $\displaystyle K1=\sum_{g=1}^3 [L]^T[D_{drag}][L]$ as follows:
\begin{equation}
[L]=
\left[
\begin{array}{c c c c c c}
\displaystyle 
L_1 & 0 & L_2 & 0 & L_3 & 0 \\
\\
0 & L_1 & 0 & L_2 & 0 & L_3 \\
\end{array}
\right]
\end{equation}
and $D=w_g \alpha^2  \vert J \vert \left[ I_2\right]$

\newpage
        \subsection{Elementary load vector}
To compute the elementary load vector, we first calculate the force due to the driving stress only, andthen we and to this vector the force on the ice front due to the water pressure.

			\subsubsection{Driving stress}

The elementary load vector due to driving stress has the following shape:

\begin{equation}
\begin{array}{l}
\displaystyle
F1_{2i-1}= -
\iint_E %double
\rho g H \frac{\partial s}{\partial x}\phi_i d\Omega\\

\\

\displaystyle
 F1_{2i}= -
\iint_E %double
\rho g H \frac{\partial s}{\partial y}\phi_i dS \\
\end{array}
\end{equation}
\\
The slopes $\frac{\partial s}{\partial x}$ and $\frac{\partial s}{\partial y}$ are constant on the element. Using the reference element $\hat{E}$ and the gaussian points, this vector become:

\begin{equation}
\begin{array}{l l}
\displaystyle
F1_{2i-1}= -
\iint_{\hat{E}} %double
\rho g H \frac{\partial s}{\partial x}L_i(r,s) \vert J \vert d\hat{S}
&
\displaystyle \simeq
\sum_{g=1}^3
 - w_g \rho g H \frac{\partial s}{\partial x} L_i(r_g,s_g)   \vert J \vert \\
\\
\displaystyle
F1_{2i}= -
\iint_{\hat{E}} %double
\rho g H \frac{\partial s}{\partial y}L_i(r,s) \vert J \vert d\hat{S}
&
\displaystyle \simeq
\sum_{g=1}^3
 - w_g \rho g H \frac{\partial s}{\partial y} L_i(r_g,s_g)   \vert J \vert \\
\end{array}
\end{equation}

			\subsubsection{Ice front}
The load on the ice front have the following shape:

\begin{equation}
\begin{array}{l}
\displaystyle
F2_{2i-1}=\int_{E \cup\Gamma}\left( \dfrac{1}{2}\rho g H^2 -\dfrac{1}{2}\rho_w g b^2\right)n_x\phi_i dl\\
\\
\displaystyle
F2_{2i}=\int_{E \cup\Gamma} \left( \dfrac{1}{2}\rho g H^2 -\dfrac{1}{2}\rho_w g b^2\right)n_y\phi_i dl\\
\end{array}
\end{equation}
\\
Here, the reference element are segment. Using these reference elements $\hat{E}$ and the gaussian points, this vector become:

\begin{equation*}
\begin{array}{l l l}
\displaystyle
F2_{2i-1} & \displaystyle =\int_{\hat{E} \cup\Gamma} \left( \dfrac{1}{2}\rho g H^2 -\dfrac{1}{2}\rho_w g b^2\right)n_x L_i \vert J \vert  d\hat{l}
&
\displaystyle \simeq
\sum_{g=1}^2
w_g \left( \dfrac{1}{2}\rho g H(r_g)^2 -\dfrac{1}{2}\rho_w g b(r_g)^2\right)n_x L_i(r_g)   
 \vert J \vert \\
\\
\displaystyle
F2_{2i} & \displaystyle =\int_{\hat{E} \cup\Gamma} \left( \dfrac{1}{2}\rho g H^2 -\dfrac{1}{2}\rho_w g b^2\right)n_y L_i \vert J \vert d\hat{l}
&
\displaystyle \simeq
\sum_{g=1}^2
w_g \left( \dfrac{1}{2}\rho g H(r_g)^2 -\dfrac{1}{2}\rho_w g b(r_g)^2\right)n_y L_i(r_g)   
 \vert J \vert 
\end{array}
\end{equation*}
\newpage

        \subsection{Assembly}
Once an element stiffness matrix or a load vector is computed, it is plugged into the global stiffness matrix or global load vector. That step requires the knowledge of the global degrees of freedom. Indeed, each component of the element stiffness matrix or load vector is initially indexed by local degrees of freedom but each one of these local degrees of freedom is linked to a global degree of freedom. Once an elementary stiffness matrix is computed, each term is added to the corresponding term in the global stiffness matrix depending on the global degrees of freedom involved.\\
\\
Let us illustrate this process with Fig.\ref{Assembly}, there are 6 local degrees of freedom for a given triangle of the mesh (3 nodes and two degrees of freedom per node: one for $x$ and another for $y$). The local degree of freedom number $5$ correspond to a global degree of freedom number $809$, and the local degree of freedom number $1$ is the global degree of freedom number $12$. Therefore, the component $Ke_{1,5}$ of the element stiffness matrix must be added to $K_{12,809}$ of the global stiffness matrix.
\begin{figure}[H]
\begin{center}
\includegraphics[width=15cm]{Assembly.png}
\caption{Assembly process}
\label{Assembly}
\end{center}
\end{figure}
After the assembly process, one obtains a global stiffness matrix whose size is $2nods \times 2nods$, but to build the weak formulation, we made the assumption that $\phi$ was kinematically admissible:

\begin{equation}
\overrightarrow{\phi}(x,y)\in\lbrace \left( H^{1}(\Omega\cup\partial\Omega) \right)^2 \quad \backslash\quad \overrightarrow{\phi}(x,y)=0\qquad (x,y)\in\Gamma_u\rbrace
\end{equation}
\\
Therefore, all the nodal functions of the nods located on $\Gamma_u$ that we used to build the global stiffness matrix are not kinematically admissible. We must reduce the global stiffness matrix $K_{gg}$ to the final stiffness matrix $K_{ff}$ by erasing all the rows and columns related to these nodal functions.

\newpage
			\subsection{Resolution}
We saw that the velocity on each node could be calculated with $U=K^{-1}F$, but we assumed that the specified velocity $U_s$ of the nodes located on $\Gamma_u$ was $0$. To take into account the fact that the constraint can be different than $0$, the velocity field is calculated as follows:

\begin{equation}
U_f = [K_{ff}]^{-1} \left(  F +K_{fs}U_s \right)
\end{equation}
\\
Where $f$ stands for "free" and $s$ for "single point constraint". Then, we must add the single point constraints to the vector $U_f$ in order to have the velocity of all the nodes of the domain $U_g$.







			\subsection{Summary}
The computation of the velocity field is not linear since the viscosity depends directly on the solution. The following algorithm is used: an initial viscosity is assumed. Each elementary stiffness matrix and load vector is computed using gauss quadratures. They are then plugged into the global stiffness matrix and global load vector. The global stiffness matrix and load vector are reduced depending on the constraints (The velocity of a constrained node is not computed, the corresponding line and column in the stiffness matrix and load vector must be deleted). Then the velocity field is computed and compared to the one of the previous iteration (for the first iteration, there is no convergence test, a second iteration must be launched). If the convergence criterion is not fulfilled (ei. the results are too different from one another), a new iteration is computed, using the velocity field of the previous iteration to compute the viscosity.
\begin{figure}[H]
\begin{center}
\includegraphics[width=16cm]{Algorithm.png}
\caption{Schematic algorithm used by $ISSM$}
\label{algorithm}
\end{center}
\end{figure}
\newpage




\section{Pattyn's Higher-order model}

    \subsection{Geometry and notations}
The glacier system is 3d. With the assumptions detailed in the first chapter, we only solve the problem for the horizontal components of velocity and deduce the vertical term from them using the incompressibility. \\

\begin{center}
\begin{figure}[H]
\includegraphics[width=15cm]{geometry3D.png}
\caption{Geometry and notations}
\label{geometrypattyn}
\end{figure}
\end{center}
We adopt the following notations:
\begin{itemize}
        \item[--] $\Omega$ is the open surface that constitutes the entire glacier system
        \item[--] $\partial\Omega$ are the points located at the boundary
        \item[--] $\Gamma_i$ are  points at the ice front (Ice/Water interface)
        \item[--] $\Gamma_s$ are  points at the surface of the glacier (Ice/Atmosphere interface $z=s$)
        \item[--] $\Gamma_b$ are  points at the interface between glacier and bedrock (Ice/Till interface $z=b$)
        \item[--] $\Gamma_w$ are  points at the interface between glacier and water (Ice/Water interface $z=b$)
        \item[--] $\Gamma_u=\partial\Omega\backslash\left(\Gamma_i\cup\Gamma_s\cup\Gamma_b\cup\Gamma_w\right)$ are all other points on the boundary\\
\end{itemize}

        \subsection{Equations}

The equations of Pattyn's model are (\ref{Pattyn equations}):
\begin{equation}
 \left\{ \begin{array}{l}
\dfrac{\partial }{\partial x} \left(4 \mu \dfrac{\partial u}{\partial x} + 2 \mu \dfrac{\partial v}{\partial y} \right)+ \dfrac{\partial }{\partial y} \left(\mu \dfrac{\partial u}{\partial y} + \mu \dfrac{\partial v}{\partial x} \right) + \dfrac{\partial }{\partial z}\left( \mu \dfrac{\partial u}{\partial z}\right)= \rho g \dfrac{\partial s}{\partial x}\\
\\
\dfrac{\partial }{\partial x} \left( \mu \dfrac{\partial u}{\partial y} +  \mu \dfrac{\partial v}{\partial x} \right)+ \dfrac{\partial }{\partial y} \left(4 \mu \dfrac{\partial v}{\partial y} + 2 \mu \dfrac{\partial u}{\partial x} \right) + \dfrac{\partial }{\partial z}\left( \mu \dfrac{\partial v}{\partial z}\right)= \rho g \dfrac{\partial s}{\partial y}\\
                 \end{array} \right.
\end{equation}
\\
The boundary conditions are: a dynamic boundary condition (Neumann) at the ice front, a friction law on the ice sheet, and single point constraint (Dirichlet) on the other borders of the domain $\Omega$.
It is more convenient to consider these specified velocities as nill. At the end of the process, the velocity field will be updated to take these
constraints into account.

\begin{equation}
\left\{ \begin{array}{l l}
\text{Ice Front } \Gamma_i: & \displaystyle \sigma' \overrightarrow{n} = F_i \overrightarrow{n}=\left(\rho_i g \left( s-z\right) + \rho_w g \min\left( 0,z\right)  \right) \overrightarrow{n}\\
\\
\text{Upper surface } \Gamma_s: & \sigma' \left(  \overrightarrow{n}\right) =0\\
\\
\text{Ice sheet base } \Gamma_b: &  \left(\sigma' \left(  \overrightarrow{n}\right)\right)_x = - K^2 N_{eff}^r \|\overrightarrow{v} \|^{s-1} u=-\alpha^2 u\\
\\
& \left(\sigma' \left(  \overrightarrow{n}\right)\right)_y = - K^2 N_{eff}^r \|\overrightarrow{v} \|^{s-1}v=-\alpha^2 v\\

\\
\text{Ice shelf base } \Gamma_w: &  \sigma' \overrightarrow{n} = F_w \overrightarrow{n}= g \left(\rho_i h(x,y) + \rho_w g b(x,y)  \right) \overrightarrow{n}\\
\\ 
\text{Other  borders } \Gamma_u: & u=v=0\\
\end{array} \right.
\end{equation}
For the boundary condition on the ice sheet base, we use $r=q/p$ and $s=1/p$ as explained in the first chapter (\ref{friction})

\newpage
        \subsection{Weak Formulation}

Now that we have all the equations and boundary conditions, we  write the weak formulation to solve these equations
using finite element. We define a kinematically admissible velocity field $\overrightarrow{\phi}$:

\begin{equation}
\overrightarrow{\phi}(x,y)\in\lbrace \left( H^{1}(\Omega\cup\partial\Omega) \right)^2 \quad \backslash\quad \overrightarrow{\phi}(x,y,z)=0\qquad (x,y,z)\in\Gamma_u\rbrace
\end{equation}
\\
For any function of this virtual field, we take the scalar product of the equations with $\overrightarrow{\phi}=\left(\phi_x,0 \right) $ and $\overrightarrow{\phi}=\left(0,\phi_y \right) $ that are 2 other kinematically admissible velocity fields, and integrate these products over the domain to obtain:

\begin{equation*}
\iiint_\Omega %triple
\left[ \frac{\partial}{\partial x} \left(4 \mu  \frac{\partial u}{\partial x}+2 \mu\frac{\partial v}{\partial y} \right)\phi_x
+\frac{\partial}{\partial y}  \left(\mu  \frac{\partial u}{\partial y}+ \mu \frac{\partial v}{\partial x} \right)\phi_x
+ \frac{\partial}{\partial z} \left( \mu \frac{\partial u}{\partial z}\right) \phi_x - \rho g \frac{\partial s}{\partial x}\phi_x  \right]  d\Omega =0
\end{equation*}

\begin{equation*}
\iiint_\Omega %triple
\left[\frac{\partial}{\partial y} \left( 4 \mu \frac{\partial v}{\partial y}+ 2 \mu \frac{\partial u}{\partial x} \right) \phi_y
+\frac{\partial}{\partial x}\left( \mu \frac{\partial u}{\partial y}+\mu \frac{\partial v}{\partial x} \right) \phi_y
+ \frac{\partial}{\partial z} \left( \mu \frac{\partial v}{\partial z}\right) \phi_y -\rho g  \frac{\partial s}{\partial y}\phi_y \right]  d\Omega =0
\end{equation*}
\\
One intergrates by parts the first three terms in order to merge in the force on the ice front $\Gamma_i$, the interface with the bedrock $\Gamma_b$ (ice sheet base) and the interface with the water $\Gamma_w$ (ice shelf base):

\begin{multline}
\iiint_\Omega  %triple
\left( 4 \mu \frac{\partial u}{\partial x}+2 \mu \frac{\partial v}{\partial y}\right) \frac{\partial \phi_x}{\partial x}
+  \left(\mu \frac{\partial u}{\partial y}+\mu \frac{\partial v}{\partial x}\right)  \frac{\partial \phi_x }{\partial y} 
+ \mu \frac{\partial u}{\partial z}  \frac{\partial \phi_x }{\partial z} d\Omega\\
 =\iint_{\Gamma_i\cup \Gamma_b \cup \Gamma_w} F n_x\phi_xd\Gamma -
\iiint_\Omega %triple
\rho g \frac{\partial s}{\partial x}\phi_x d\Omega
\label{FFU Pattyn}
\end{multline}
\begin{multline}
\iiint_\Omega  %triple
\left( 4 \mu \frac{\partial v}{\partial y}+2 \mu \frac{\partial u}{\partial x}\right) \frac{\partial \phi_y}{\partial y}
+  \left(\mu \frac{\partial v}{\partial x}+\mu \frac{\partial u}{\partial y}\right)  \frac{\partial \phi_y }{\partial x} 
+ \mu \frac{\partial v}{\partial z}  \frac{\partial \phi_y }{\partial z} d\Omega\\
 =\iint_{\Gamma_i\cup \Gamma_b \cup \Gamma_w}F n_y\phi_yd\Gamma -
\iiint_\Omega %triple
\rho g \frac{\partial s}{\partial y}\phi_y d\Omega
\label{FFV Pattyn}
\end{multline}
It is easier to put the basal friction at the left hand side of the equation since it is velocity dependant. The equations become:

\begin{multline}
\iiint_\Omega  %triple
\left( 4 \mu \frac{\partial u}{\partial x}+2 \mu \frac{\partial v}{\partial y}\right) \frac{\partial \phi_x}{\partial x}
+  \left(\mu \frac{\partial u}{\partial y}+\mu \frac{\partial v}{\partial x}\right)  \frac{\partial \phi_x }{\partial y} 
+ \mu \frac{\partial u}{\partial z}  \frac{\partial \phi_x }{\partial z} d\Omega
+\iint_{\Gamma_b } \alpha^2 u \phi_xd\Gamma\\
 =\iint_{\Gamma_i } F_i n_x\phi_x d\Gamma +
\iint_{\Gamma_w }F_w n_x\phi_yx\Gamma -
\iiint_\Omega %triple
\rho g \frac{\partial s}{\partial x}\phi_x d\Omega
\end{multline}
\begin{multline}
\iiint_\Omega  %triple
\left( 4 \mu \frac{\partial v}{\partial y}+2 \mu \frac{\partial u}{\partial x}\right) \frac{\partial \phi_y}{\partial y}
+  \left(\mu \frac{\partial v}{\partial x}+\mu \frac{\partial u}{\partial y}\right)  \frac{\partial \phi_y}{\partial x} 
+ \mu \frac{\partial v}{\partial z}  \frac{\partial \phi_y }{\partial z} d\Omega
+\iint_{\Gamma_b }\alpha^2 v \phi_y d\Gamma\\
 =\iint_{\Gamma_i }F_i n_y\phi_yd\Gamma +
\iint_{\Gamma_w }F_w n_y\phi_yd\Gamma -
\iiint_\Omega %triple
\rho g \frac{\partial s}{\partial y}\phi_y d\Omega
\end{multline}
\newpage
        \subsection{Finite element discretisation, Galerkin method}
 The domain is meshed using pentahedrons. There are a $nel$ elements and $nods$ grids. We use the nodal functions of each grid, which are continuous on the domain and affine on each element.
We now project the unknows $u$ and $v$ on the nodal functions:
\begin{center}
 $(\phi_i)_{1\leq i\leq nods}$
\end{center}
\begin{equation}
\begin{array}{c}
\displaystyle u\left( x,y,z\right) = \sum_{i=1}^{nods}u_{i}\phi_{i}\left( x,y,z\right) \\
\\
\displaystyle v\left( x,y,z\right) = \sum_{i=1}^{nods}v_{i}\phi_{i}\left( x,y,z\right) \\
\end{array}
\end{equation}
\\
We build a vector $U$ that holds all the unknows of the velocity field:

\begin{equation}
U=\left[ \begin{array}{c}
u_{1}\\
v_{1}\\
...\\
u_{nods}\\
v_{nods}\\
  \end{array} \right]
\end{equation}
\\
With this new field, we  replace the component of the virtual function $\overrightarrow{\phi}$ by the nodal functions:
\begin{center}
 $\forall 1 \leq i \leq nods$
\end{center}
\begin{multline}
\sum_{j=1}^{nods} 
\iiint_\Omega  %triple
 \left(  4 \mu u_j\frac{\partial \phi_j}{\partial x} + 2 \mu v_j\frac{\partial \phi_j}{\partial y}\right)\frac{\partial \phi_i}{\partial x}
+\left(  \mu u_j\frac{\partial \phi_j}{\partial y} +\mu v_j \frac{\partial \phi_j}{\partial x} \right)\frac{\partial \phi_i}{\partial y} 
+  \mu u_j\frac{\partial \phi_j}{\partial z} \frac{\partial \phi_i}{\partial z} 
d\Omega
\\
+\iint_{\Gamma_b} \alpha^2 u_j \phi_j \phi_i d\Gamma
 =
\iint_{\Gamma_i} F_i n_x\phi_i d\Gamma
+ \iint_{\Gamma_w} F_w n_x\phi_i d\Gamma
- \iiint_\Omega %triple
\rho g \frac{\partial s}{\partial x} \phi_i d\Omega
\end{multline}
\begin{multline}
\sum_{j=1}^{nods} 
\iiint_\Omega %triple
\left(  \mu u_j\frac{\partial \phi_j}{\partial y} +\mu v_j\frac{\partial \phi_j}{\partial x} \right)\frac{\partial \phi_i  }{\partial x} 
+\left(  4 \mu v_j\frac{\partial \phi_j}{\partial y} + 2 \mu u_j \frac{\partial \phi_i}{\partial x}\right)\frac{\partial \phi_i }{\partial y} 
+  \mu v_j\frac{\partial \phi_j}{\partial z}\frac{\partial \phi_i  }{\partial z}
d\Omega
\\
+\iint_{\Gamma_b} \alpha^2 v_j \phi_j \phi_i d\Gamma
 =
\iint_{\Gamma_i} F_i n_y\phi_i d\Gamma
+ \iint_{\Gamma_w} F_w n_y\phi_i d\Gamma
- \iiint_\Omega %triple
\rho g \frac{\partial s}{\partial y} \phi_i d\Omega
\end{multline}
\\


By rearranging terms:
\begin{center}
 $\forall 1 \leq i \leq nods$
\end{center}
\begin{multline}
\sum_{j=1}^{nods} 
\iiint_\Omega  %triple
\left[
 4 \mu \frac{\partial \phi_j}{\partial x} \frac{\partial \phi_i}{\partial x}
 + \mu \frac{\partial \phi_j}{\partial y} \frac{\partial \phi_i}{\partial y} 
 + \mu \frac{\partial \phi_j}{\partial z} \frac{\partial \phi_i}{\partial z} 
\right] u_j
+
\left[
 2 \mu \frac{\partial \phi_j}{\partial y} \frac{\partial \phi_i}{\partial x} 
 + \mu \frac{\partial \phi_j}{\partial x} \frac{\partial \phi_i}{\partial y}
\right] v_j d\Omega
\\
+\iint_{\Gamma_b} \alpha^2 u_j \phi_j \phi_i d\Gamma
 =
\iint_{\Gamma_i} F_i n_x\phi_i d\Gamma +
\iint_{\Gamma_w} F_w n_x\phi_i d\Gamma
- \iiint_\Omega %triple
\rho g \frac{\partial s}{\partial x} \phi_i d\Omega 
\end{multline}
\begin{multline}
\sum_{j=1}^{nods} 
\iiint_\Omega %triple
\left[
  \mu \frac{\partial \phi_j}{\partial y} \frac{\partial \phi_i}{\partial x} 
 + 2 \mu \frac{\partial \phi_j}{\partial x} \frac{\partial \phi_i}{\partial y}
\right] u_j
+
\left[
   \mu \frac{\partial \phi_j}{\partial x} \frac{\partial \phi_i}{\partial x}
 +4\mu \frac{\partial \phi_j}{\partial y} \frac{\partial \phi_i}{\partial y} 
 + \mu \frac{\partial \phi_j}{\partial z} \frac{\partial \phi_i}{\partial z} 
\right] v_j d\Omega
\\
+\iint_{\Gamma_b} \alpha^2 v_j \phi_j \phi_i d\Gamma
 =
\iint_{\Gamma_i} F_i n_y\phi_i d\Gamma +
\iint_{\Gamma_w} F_w n_y\phi_i d\Gamma
- \iiint_\Omega %triple
\rho g \frac{\partial s}{\partial y} \phi_i d\Omega 
\end{multline}
\\
We see the stiffness matrix $K$ and load vector $F$ appearing, so that the previous equations can be written as a matrix form:

\begin{equation}
\left[ K \right] U =F 
\end{equation} 
\\
We use the following index:

\begin{equation}
\left[
\begin{array}{c c c c} %K
  & \vdots &\vdots &\\
 \cdots & K_{2i-1,2j-1} & K_{2i-1,2j} & \cdots\\
 \cdots & K_{2i,2j-1} &   K_{2i,2j} & \cdots\\
  & \vdots &\vdots &\\
\end{array}
\right]
\left[
\begin{array}{c} %U
\vdots \\
u_j\\
v_j\\
\vdots\\
\end{array}
\right]
=
\left[
\begin{array}{c} %F
\vdots \\
F_{2j-1}\\
F_{2j}\\
\vdots\\
\end{array}
\right]
\end{equation}
\\
And  we have the following expressions for the stiffness matrix and the load vector :

\begin{equation}
\begin{array}{l l}
\displaystyle

K_{2i-1,2j-1} &\displaystyle = 
\iiint_\Omega  %triple
 4 \mu \frac{\partial \phi_j}{\partial x} \frac{\partial \phi_i}{\partial x}
 + \mu \frac{\partial \phi_j}{\partial y} \frac{\partial \phi_i}{\partial y} 
 + \mu \frac{\partial \phi_j}{\partial z} \frac{\partial \phi_i}{\partial z} 
d\Omega
+\iint_{\Gamma_b} \alpha^2 u_j \phi_j \phi_i d\Gamma \\
\\
K_{2i-1,2j} &\displaystyle = 
\iiint_\Omega  %triple
 2 \mu \frac{\partial \phi_j}{\partial y} \frac{\partial \phi_i}{\partial x} 
 + \mu \frac{\partial \phi_j}{\partial x} \frac{\partial \phi_i}{\partial y}
d\Omega\\
\\
K_{2i,2j-1} &\displaystyle = 
\iiint_\Omega  %triple
2 \mu \frac{\partial \phi_j}{\partial x} \frac{\partial \phi_i}{\partial y} 
+ \mu \frac{\partial \phi_j}{\partial y} \frac{\partial \phi_i}{\partial x}
d\Omega\\
\\
K_{2i,2i} &\displaystyle = 
\iiint_\Omega  %triple
   \mu \frac{\partial \phi_j}{\partial x} \frac{\partial \phi_i}{\partial x}
 +4\mu \frac{\partial \phi_j}{\partial y} \frac{\partial \phi_i}{\partial y} 
 + \mu \frac{\partial \phi_j}{\partial z} \frac{\partial \phi_i}{\partial z} 
d\Omega
+\iint_{\Gamma_b} \alpha^2 v_j \phi_j \phi_i d\Gamma\\
\\
F_{2i-1} &\displaystyle = 
\iint_{\Gamma_i} F_i n_x\phi_i d\Gamma +
\iint_{\Gamma_w} F_w n_x\phi_i d\Gamma
- \iiint_\Omega %triple
\rho g \frac{\partial s}{\partial x} \phi_i d\Omega \\
\\
F_{2i} &\displaystyle = 
\iint_{\Gamma_i} F_i n_y\phi_i d\Gamma +
\iint_{\Gamma_w} F_w n_y\phi_i d\Gamma
- \iiint_\Omega %triple
\rho g \frac{\partial s}{\partial y} \phi_i d\Omega \\
\\
\end{array}
\end{equation}

        \subsection{Decomposition over the elements and reference element}
        The integrals over $\Omega$ can be divided in several integrals over each elements. To compute the matrices $K$ and $F$, instead of calculating the integral over $\Omega$ directly, we will first calculate the integrales over each element $E$ 
of the mesh, that will give us several \emph{Element Matrices}, that will be plugged into the global matrices to get the final Stiffness matrix and load vector.\\
\\
One element $E$ gives 12 equations: we can take 6 nodal functions for $\phi_i(x,y,z)$ (the nodal functions corresponding to the vertexes of $E$, which is an pentahedron), each $\phi_i$ gives 2 equations (one for the x-component and one for the y-component). Therefore, an elementary stiffness matrix $K_E$ will be $12 \times 12$, and the elementary load vector will be of size $19$.

Exactly as in MacAyeal's model,  rather than calculating these integrals for each element, one uses a \emph{Reference Element} $\hat{E}$, and a transformation $\varphi$ that transforms the reference element to the element $E$ (See Fig.\ref{hexa}):
\begin{figure}[H]
\begin{center}
\includegraphics[width=15cm]{pentaelem.png}
\caption{Transformation from the reference element, to the current element of the pentahedral mesh}
\label{hexa}
\end{center}
\end{figure}
For any function $f(x,y,z)$, the transformation verifies:

\begin{equation}
\iiint_E f(x,y,z)dV = \iiint_{\hat{E}} \hat{f}(r,s,\zeta) \vert J \vert d\hat{V}
\end{equation}
\\
Where $J$ is the Jacobian determinant of the $\varphi$ function.  This Jacobian is calculated in section \ref{RE3D}:

\begin{equation}
J=
\left[
\begin{array}{c c c}
\displaystyle 
\frac{\partial \varphi_x }{\partial r} & \displaystyle  \frac{\partial \varphi_x }{\partial s} &  \displaystyle  \frac{\partial \varphi_x }{\partial \zeta} \\
\\
\displaystyle 
\frac{\partial \varphi_y }{\partial r} & \displaystyle  \frac{\partial \varphi_y }{\partial s} &  \displaystyle  \frac{\partial \varphi_y }{\partial \zeta}  \\
\\
\displaystyle 
\frac{\partial \varphi_z }{\partial r} & \displaystyle  \frac{\partial \varphi_z }{\partial s} &  \displaystyle  \frac{\partial \varphi_z }{\partial \zeta}  \\
\end{array}
\right]
\end{equation}
\\
with:

\begin{equation*}
\begin{array}{c l}
\displaystyle 
J_{11}= &  \displaystyle 
 \frac{1}{4}\left( x_1-x_2-x_4+x_5 \right)+ \frac{1}{4}\left( -x_1+x_2-x_4+x_5 \right) \zeta \\
\\
J_{21}= &  \displaystyle 
 \frac{1}{4}\left( y_1-y_2-y_4+y_5 \right)+ \frac{1}{4}\left( -y_1+y_2-y_4+y_5 \right) \zeta \\
\\
J_{31}= &    \displaystyle 
 \frac{1}{4}\left( z_1-z_2-z_4+z_5 \right)+ \frac{1}{4}\left( -z_1+z_2-z_4+z_5 \right) \zeta \\
\end{array}
\end{equation*}
\begin{equation}
\begin{array}{c l}
J_{12}= &  \displaystyle  
\frac{\sqrt{3}}{12} \left( x_1+x_2-2 x_3- x_4- x_5+ 2 x_6 \right)+ \frac{\sqrt{3}}{12} \left( -x_1-x_2+ 2 x_3- x_4- x_5+2 x_6 \right)\zeta\\
\\
J_{22}= &  \displaystyle 
\frac{\sqrt{3}}{12} \left( y_1+y_2-2 y_3- y_4- y_5+ 2 y_6 \right)+ \frac{\sqrt{3}}{12} \left( -y_1-y_2+ 2 y_3- y_4- y_5+2 y_6 \right)\zeta\\
\\
J_{32}= &  \displaystyle 
\frac{\sqrt{3}}{12} \left( z_1+z_2-2 z_3- z_4- z_5+ 2 z_6 \right)+ \frac{\sqrt{3}}{12} \left( -z_1-z_2+ 2 z_3- z_4- z_5+2 z_6 \right)\zeta\\
\end{array}
\end{equation}
\begin{equation*}
\begin{array}{c l}
J_{31}= &  \displaystyle  
\frac{1}{4}\left( -x_1+x_2-x_4+x_5 \right) r
+ \frac{\sqrt{3}}{12} \left( -x_1-x_2+ 2 x_3- x_4- x_5+2 x_6 \right)s\\ 
\\
J_{32}= &  \displaystyle 
\frac{1}{4}\left( -y_1+y_2-y_4+y_5 \right) r
+ \frac{\sqrt{3}}{12} \left( -y_1-y_2+ 2 y_3- y_4- y_5+2 y_6 \right)s\\ 
\\
J_{33}= &  \displaystyle 
\frac{1}{4}\left( -z_1+z_2-z_4+z_5 \right) r
+ \frac{\sqrt{3}}{12} \left( -z_1-z_2+ 2 z_3- z_4- z_5+2 z_6 \right)s\\ 
\\
\end{array}
\end{equation*}
\\
Now, we have all the tools to calculate the integrals over the reference element instead of the element itself.
Since $ISSM$ is a Matlab code, the integrals cannot be calculated directly. The numerical integration uses a gaussian quadrature to approximate the integral as a weighted sum of function values at specified points (gaussian points) within the domain:

\begin{equation}
\iiint_E f(x,y,z)dV = \iint_{\hat{E}} \hat{f}(r,s,\zeta) \vert J\vert d\hat{V} \simeq \sum_{g=1}^{n} W_g \hat{f}(r_g,s_g,\zeta_g)
\end{equation}
\\
where $W_i$ are the quadrature rules weights and $(r_g,s_g,\zeta_g)$ are the evaluation points, $g=1,2...,n$. The integration points are given with their area coordinates: 

\begin{equation}
\displaystyle (r_g,s_g,\zeta_g)\equiv (\frac{A_1}{A},\frac{A_2}{A},\frac{A_3}{A},\zeta_g)
\end{equation}
\begin{figure}[H]
\begin{center}
\includegraphics[width=9cm]{barycentric_penta.png} 
\caption{Area coordinates}
\end{center}
\end{figure}

The number of gaussian points depends on the order of integration. The order of integration can be computed from the polynomial degree $p$ that needs to be integrated. The formula is:

\begin{equation}
order=\frac{p+1}{2}
\end{equation}
\\
Here, the degree of the polynome under the integral is $2$ (the drag implies the calculation of $\phi_j \phi_i$ whose degree is 2). The order of integration is hence 2 (the order must be an integer). For this order, $6$ gaussian points are required (See in $ISSM$ code $GaussPenta.m$ for more details).

\newpage
 \subsection{Elementary stiffness matrix}
To compute the elementary stiffness matrix, we first remove the basal drag, that will create a first elementary stiffness matrix $K1$, the basal drag will constitute another stiffness matrix $K2$. The elementary stiffness matrix will be the sum of $K1$ and $K2$ ($K_E=K1+K2$).

        \subsubsection{Without basal drag}

This matrix has the following shape:

\begin{center}
 $1 \leq i \leq 6$ and  $1 \leq j \leq 6$ 
\end{center}
\begin{equation}
\begin{array}{l}
\displaystyle
K1_{2i-1,2j-1}= 
\iiint_E  %triple
  \left( 4 \mu \frac{\partial \phi_{j}}{\partial x} \frac{\partial \phi_i}{\partial x} 
  + \mu \frac{\partial \phi_{j}}{\partial y} \frac{\partial \phi_i}{\partial y}
  + \mu \frac{\partial \phi_{j}}{\partial z} \frac{\partial \phi_i}{\partial z}\right)d\Omega\\

\\

\displaystyle
K1_{2i-1,2j}= 
\iiint_E  %triple
\left( 2 \mu \frac{\partial \phi_{j}}{\partial y}\frac{\partial \phi_i }{\partial x} + 
\mu\frac{\partial \phi_{j}}{\partial x} \frac{\partial \phi_{i}}{\partial y} \right) d\Omega \\

\\

\displaystyle
K1_{2i,2j-1}= 
\iiint_E  %triple
  \left( 2 \mu \frac{\partial \phi_{j}}{\partial x} \frac{\partial \phi_i}{\partial y} 
  + \mu \frac{\partial \phi_{j}}{\partial y} \frac{\partial \phi_i}{\partial x} \right)  d\Omega\\
  
\\

\displaystyle
K1_{2i,2j}= 
\iiint_E  %triple
\left( 4 \mu \frac{\partial \phi_{j}}{\partial y}\frac{\partial \phi_i }{\partial y} + 
\mu\frac{\partial \phi_{j}}{\partial x} \frac{\partial \phi_{i}}{\partial x} 
+ \mu\frac{\partial \phi_{j}}{\partial z} \frac{\partial \phi_{i}}{\partial z} \right)  d\Omega \\
\end{array}
\end{equation}
\\
Using the reference element $\hat{E}$ and the gaussian points, this matrix becomes:
\begin{center}
 $1 \leq i \leq 6$ and  $1 \leq j \leq 6$ 
\end{center}
\medskip
\begin{equation*}
\begin{array}{c l}
\displaystyle
K1_{2i-1,2j-1} & \displaystyle = 
\iiint_{\hat{E}}  %triple
  \left( 4  \mu \frac{\partial L_{j}}{\partial \varphi_x} \frac{\partial L_i}{\partial \varphi_x} 
  +  \mu \frac{\partial L_{j}}{\partial \varphi_y} \frac{\partial L_i}{\partial \varphi_y}
  +  \mu \frac{\partial L_{j}}{\partial \varphi_z} \frac{\partial L_i}{\partial \varphi_z} \right) \vert J \vert d\hat{V} \\
  \\
& \displaystyle \simeq
\sum_{g=1}^6  W_g \left( 4  \mu \left.\frac{\partial L_{j}}{\partial \varphi_x}\right|_g \left.\frac{\partial L_i}{\partial \varphi_x} \right|_g
  +  \mu \left.\frac{\partial L_{j}}{\partial \varphi_y}\right| _g \left.\frac{\partial L_i}{\partial \varphi_y}\right|_g
  +  \mu \left.\frac{\partial L_{j}}{\partial \varphi_z} \right|_g \left. \frac{\partial L_i}{\partial \varphi_z}\right|_g \right) \vert J_g \vert \\

\\

\displaystyle
K1_{2i-1,2j} &\displaystyle = 
\iiint_{\hat{E}}  %triple
\left( 2  \mu \frac{\partial L_{j}}{\partial \varphi_y}\frac{\partial L_i }{\partial \varphi_x} + 
 \mu\frac{\partial L_{j}}{\partial \varphi_x} \frac{\partial L_{i}}{\partial \varphi_y} \right) \vert J \vert d\hat{V} \\
\\
& \displaystyle \simeq
\sum_{g=1}^6  W_g 
\left( 2  \mu \left. \frac{\partial L_{j}}{\partial \varphi_y}\right|_g \left. \frac{\partial L_i }{\partial \varphi_x}\right|_g + 
 \mu\left.\frac{\partial L_{j}}{\partial \varphi_x}\right|_g \left. \frac{\partial L_{i}}{\partial \varphi_y} \right|_g \right) \vert J_g \vert\\
\\

\\

\displaystyle
K1_{2i,2j-1} & \displaystyle = 
\iiint_{\hat{E}}  %triple
  \left( 2  \mu \frac{\partial L_{j}}{\partial \varphi_x} \frac{\partial L_i}{\partial \varphi_y} 
  +  \mu \frac{\partial L_{j}}{\partial \varphi_y} \frac{\partial L_i}{\partial \varphi_x} \right)  \vert J \vert d\hat{V} \\
  \\
& \displaystyle \simeq
\sum_{g=1}^6  W_g 
\left( 2  \mu \left.\frac{\partial L_{j}}{\partial \varphi_x}\right|_g \left. \frac{\partial L_i}{\partial \varphi_y} \right|_g
  +  \mu \left.\frac{\partial L_{j}}{\partial \varphi_y}\right|_g \left. \frac{\partial L_i}{\partial \varphi_x}\right|_g \right) \vert J_g \vert\\
\\

\\

\displaystyle
K1_{2i,2j} & \displaystyle = 
\iiint_{\hat{E}}  %triple
\left( 4  \mu \frac{\partial L_{j}}{\partial \varphi_y}\frac{\partial L_i }{\partial \varphi_y} + 
 \mu\frac{\partial L_{j}}{\partial \varphi_x} \frac{\partial L_{i}}{\partial \varphi_x} 
+  \mu\frac{\partial L_{j}}{\partial \varphi_z} \frac{\partial L_{i}}{\partial \varphi_z} \right)  \vert J \vert d\hat{V} \\
\\
& \displaystyle \simeq
\sum_{g=1}^6  W_g 
\left( 4  \mu \left.\frac{\partial L_{j}}{\partial \varphi_y}\right|_g \left.\frac{\partial L_i }{\partial \varphi_y}\right|_g + 
 \mu\left.\frac{\partial L_{j}}{\partial \varphi_x}\right|_g \left. \frac{\partial L_{i}}{\partial \varphi_x}\right|_g 
+  \mu\left.\frac{\partial L_{j}}{\partial \varphi_z}\right|_g \left. \frac{\partial L_{i}}{\partial \varphi_z}\right|_g \right) \vert J_g \vert\\
\\
\end{array}
\end{equation*}
\\
This elementary stiffness matrix is calculated with three matrices: $\displaystyle K1= \sum_{g=1}^6 [B]^T[D][B']$ as follows:

\begin{equation}
[B]=\left[\begin{array}{c c c c c c}
B_1 & B_2 & B_3 & B_4 & B_5 & B_6
\end{array}\right]
\quad and \quad
[B']=\left[\begin{array}{c c c c c c}
B'_1 & B'_2 & B'_3 & B'_4 & B'_5 & B'_6
\end{array}\right]
\end{equation}
\\
with:

\begin{equation}
[B_i]=
\left[
\begin{array}{c c}
\displaystyle 
\left. \frac{\partial L_i}{\partial \varphi_x}\right|_g & 0\\
\\
\displaystyle 
0 &\displaystyle   \left.\frac{\partial L_i}{\partial \varphi_y}\right|_g \\
\\
\displaystyle 
\frac{1}{2} \left.\frac{\partial L_i}{\partial \varphi_y}\right|_g & \displaystyle \frac{1}{2} \left.\frac{\partial L_i}{\partial \varphi_x}\right|_g \\
\\
\displaystyle 
\frac{1}{2} \left.\frac{\partial L_i}{\partial \varphi_z}\right|_g & 0\\
\\
\displaystyle 
0 & \displaystyle \frac{1}{2} \left.\frac{\partial L_i}{\partial \varphi_z}\right|_g \\
\end{array}
\right]\\
\quad \quad
[B'_i]=
\left[
\begin{array}{c c}
\displaystyle 
2 \left.\frac{\partial L_i}{\partial \varphi_x} \right|_g & \displaystyle  \left. \frac{\partial L_i}{\partial \varphi_y} \right|_g\\
\\
\displaystyle   \left.\frac{\partial L_i}{\partial \varphi_x}\right|_g &  \displaystyle  2\left.\frac{\partial L_i}{\partial \varphi_y}\right|_g \\
  \\
\displaystyle   \left.\frac{\partial L_i}{\partial \varphi_y}\right|_g &  \displaystyle  \left.\frac{\partial L_i}{\partial \varphi_x}\right|_g\\  
 \\
\displaystyle   \left.\frac{\partial L_i}{\partial \varphi_z}\right|_g &  0 \\  

\displaystyle   0 &  \displaystyle  \left.\frac{\partial L_i}{\partial \varphi_z}\right|_g \\  
\end{array}
\right]\\
\end{equation}
\\
and $D=W_g 2 \mu \vert J_g \vert \left[I_5\right] $ 
\\
 \\
\emph{NB:} in $ISSM$ code, the factor $2$ in the $D$ matrix does not exist since the constitutive relation used is $\sigma'=\mu\varepsilon$ instead of $\sigma'=2\mu\varepsilon$. This changes the viscosity definition that must be multiplied by $2$.      
               \subsubsection{Basal drag}
Basal drag get involved only for the nods on the ice/bedrock interface. Thus, only surface integrals are required. The elements are triangles and there are only 3 nodal functions to take into account. Therefore, the stiffness matrix that stands for basal drag is $6 \times 6$.\\
The basal drag matrix has the following shape:

\begin{center}
 $1 \leq i \leq 3$ and  $1 \leq j \leq 3$ 
\end{center}
\medskip
\begin{equation}
\begin{array}{l}
\displaystyle
K_{2i-1,2j-1}= 
\iint_{E\cap \Gamma_b}  %double
 \alpha^2 \phi_j \phi_i  dS\\
\\
\displaystyle
K_{2i-1,2j}= 0\\
\\
\displaystyle
K_{2i,2j-1}= 0\\
\\
\displaystyle
K_{2i,2j}= 
\iint_{E \cap \Gamma_b}  %double
\alpha^2 \phi_j \phi_i dS \\
\end{array}
\end{equation}
\\        
This time, the reference element are triangles, as in MacAyeal's model. Using the reference element $\hat{E}$ and the gaussian points, this matrix become:
        
        \begin{equation}
\begin{array}{l l l}
\displaystyle
K_{2i-1,2j-1} & = 
\displaystyle \iint_{\hat{E}\cap \hat{\Gamma_b}}  %double
\alpha^2 L_j(r,s) L_i(r,s)   \vert J \vert d\hat{S}
&
\displaystyle \simeq
\sum_{g=1}^3
W_g \alpha^2 L_j(r_g,s_g) L_i(r_g,s_g)   \vert J_g \vert
 \\
\\
\displaystyle
K_{2i-1,2j} & = 0 &\\
\\
\displaystyle
K_{2i,2j-1} & = 0 &\\
\\
\displaystyle
K_{2i,2j} & = 
\displaystyle \iint_{\hat{E}\cap \hat{\Gamma_b}}  %double
\alpha^2 L_j(r,s) L_i(r,s)  \vert J \vert d\hat{S} &
\displaystyle \simeq
\sum_{g=1}^3
W_g \alpha^2 L_j(r_g,s_g) L_i(r_g,s_g)   \vert J_g \vert 
 \\
 \\
\end{array}
\end{equation}
\\     
This matrix is calculated with three matrices: $\displaystyle K1=\sum_{g=1}^3 [L]^T[D_{drag}][L]$ as follows:
\begin{equation}
[L]=
\left[
\begin{array}{c c c c c c c}
\displaystyle 
L_1(r_g,s_g) & 0 & L_2(r_g,s_g) & 0 &  L_3(r_g,s_g) & 0 \\
\\
0 & L_1(r_g,s_g) & 0 & L_2(r_g,s_g) &  0 & L_3(r_g,s_g) \\
\end{array}
\right]
\end{equation}
and $\left[D_{drag} \right]=W_g \alpha^2  \vert J_g \vert \left[ I_{6} \right]$


 \subsection{Elementary load vector}
To compute the elementary load vector, we first calculate the force due to the driving stress only, the water pressure only, and we then add these two terms.

			\subsubsection{Driving stress}

The elementary load vector due to driving stress has the following shape:

\begin{equation}
\begin{array}{l}
\displaystyle
F1_{2i-1}= -
\iiint_{E} %triple
\rho g \frac{\partial s}{\partial x}\phi_i d\Omega\\

\\

\displaystyle
 F1_{2i}= -
\iiint_E %triple
\rho g \frac{\partial s}{\partial y}\phi_i d\Omega \\
\end{array}
\end{equation}
\\
Using the reference element $\hat{E}$ and the gaussian points, this vector become:

\begin{equation}
\begin{array}{l l}
\displaystyle
F1_{2i-1}= -
\iiint_{\hat{E}} %triple
\rho g \frac{\partial s}{\partial x}L_i(r,s,\zeta) \vert J \vert d\hat{\Omega}
&
\displaystyle \simeq
\sum_{g=1}^6
 - W_g \rho g \frac{\partial s}{\partial x} L_i(r_g,s_g,\zeta_g)   \vert J_g \vert \\
\\
\displaystyle
F1_{2i}= -
\iiint_{\hat{E}} %triple
\rho g \frac{\partial s}{\partial y}L_i(r,s,\zeta) \vert J \vert d\hat{\Omega}
&
\displaystyle \simeq
\sum_{g=1}^6
 - W_g \rho g \frac{\partial s}{\partial y} L_i(r_g,s_g,\zeta_g)   \vert J_g \vert \\
\end{array}
\end{equation}

			\subsubsection{Ice front}
The load on the ice front involves only the nodes on the ice/sea interface. As with basal drag, only surface integrals are required. The elements are quadrangle (See section\ref{RE2D2}). The load on the ice front have the following shape:

\begin{equation}
\begin{array}{l}
\displaystyle
F2_{2i-1}=\iint_{E \cap \Gamma_i} F_i n_x\phi_i dS\\
\\
\displaystyle
F2_{2i}=\iint_{E \cap\Gamma_i} F_i n_y\phi_i dS\\
\end{array}
\end{equation}
\\
Using the reference element $\hat{E}$ and the gaussian points, this vector become:

\begin{equation}
\begin{array}{l l l}
\displaystyle
F2_{2i-1} & \displaystyle =\iint_{\hat{E} \hat{\cup\Gamma_i}} \hat{F_i} n_x L_i \vert J \vert  d\hat{S}
&
\displaystyle \simeq
\sum_{g=1}^4
W_g \left( \rho_i g\left(s-z \right)+\rho_w g \min\left( 0,z\right)     \right)n_x L_i(r_g,s_g,\zeta_g) \vert J_g \vert \\
\\
\displaystyle
F2_{2i} & \displaystyle =\iint_{\hat{E} \hat{\cup\Gamma_i}} \hat{F_i} n_y L_i \vert J \vert d\hat{S}
&
\displaystyle \simeq
\sum_{g=1}^4
W_g \left( \rho_i  g\left(s-z \right)+\rho_w g \min\left( 0,z\right)     \right)n_y L_i(r_g,s_g,\zeta_g) \vert J_g \vert \\
\end{array}
\end{equation}

			\subsubsection{Ice/water interface}
The load on the ice/water interface involves only the nodes at the base on the iceshelf. As with basal drag and ice front, only surface integrals are required. The elements are triangles. The load on the ice shelf base have the following shape:

\begin{equation}
\begin{array}{l}
\displaystyle
F3_{2i-1}=\iint_{E \cap \Gamma_w} F_w n_x\phi_i dS\\
\\
\displaystyle
F3_{2i}=\iint_{E \cap\Gamma_w} F_w n_y\phi_i dS\\
\end{array}
\end{equation}
\\
Using the reference element $\hat{E}$ and the gaussian points, this vector become:

\begin{equation}
\begin{array}{l l l}
\displaystyle
F3_{2i-1} & \displaystyle =\iint_{\hat{E} \hat{\cup\Gamma_w}} \hat{F_w} n_x L_i \vert J \vert  d\hat{S}
&
\displaystyle \simeq
\sum_{g=1}^3
W_g g\left( \rho_i h(r_g,s_g) + \rho_w b(r_g,s_g)     \right)n_x L_i(r_g,s_g) \vert J_g \vert \\
\\
\displaystyle
F3_{2i} & \displaystyle =\iint_{\hat{E} \hat{\cup\Gamma_w}} \hat{F_w} n_y L_i \vert J \vert d\hat{S}
&
\displaystyle \simeq
\sum_{g=1}^3
W_g g\left( \rho_i h(r_g,s_g) + \rho_w b(r_g,s_g)     \right)n_y L_i(r_g,s_g) \vert J_g \vert \\
\end{array}
\end{equation}

\newpage
\section{Vertical Velocity computation}
        \subsection{Equations}
        
In the first chapter, we saw that we used the incompressibility to calculate the vertical component of the velocity:

\begin{equation}
\dfrac{\partial w}{\partial z}=-\dfrac{\partial u}{\partial x}-\dfrac{\partial v}{\partial y}
\label{verticalequation}
\end{equation}
\\
The boundary condition on the lower surface is $w=w_b$ with (see (\ref{basalvelocity})):

\begin{equation}
w_b = u \frac{\partial b}{\partial x}+v \frac{\partial b}{\partial y} - \frac{\rho_w }{\rho_i } \left( - div \left( H \left[ \begin{array}{c}
\bar{u} \\
\bar{v}
\end{array}\right] \right) \right)
\end{equation}


				\subsection{Basal velocity formulation}

						\subsubsection{Basal velocity weak formulation}
As usual, We define a kinematically admissible velocity field $\phi$:

\begin{equation}
\phi(x,y,z)\in\lbrace H^{1}(\Omega\cup\partial\Omega) \rbrace
\end{equation}
\\									
If one integrates the product of the equation (\ref{verticalequation}) by a kinematically admissible velocity field:						
\begin{equation}
\begin{array}{r c l}
\displaystyle \iint_{\Gamma_b\cup\Gamma_w} w_b \phi d\Gamma &
= &
\displaystyle \iint_{\Gamma_b\cup\Gamma_w} u \frac{\partial b}{\partial x} \phi +v \frac{\partial b}{\partial y} \phi d\Gamma
+\iint_{\Gamma_b} -\dot{M_b} \phi d\Gamma \\
\\
&&
\displaystyle +\iint_{\Gamma_w} - \frac{\rho_w }{\rho_i } \left( - div \left( H \left[ \begin{array}{c}
\bar{u} \\
\bar{v}
\end{array}\right] \right) \right) \phi  - \frac{\rho_w }{\rho_i } \dot{M_a} \phi +\left( \frac{\rho_w }{\rho_i } -1\right)  \dot{M_b} \phi d\Gamma
\end{array}
\end{equation}

						\subsubsection{Elementary stiffness matrix and load vector}
Following the same method as in the previous situations, we obtain the stiffness matrix as follows:

\begin{equation}
\begin{array}{l c l}
\displaystyle K_{i,j} &\displaystyle = &
\displaystyle \iint_{\Gamma_b\cup\Gamma_w} \phi_j \phi_i d\Gamma \\ 
\\
F_{i} &\displaystyle = & 
\displaystyle \iint_{\Gamma_b\cup\Gamma_w} u \frac{\partial b}{\partial x} \phi_i +v \frac{\partial b}{\partial y} \phi_i d\Gamma
+\iint_{\Gamma_b} -\dot{M_b} \phi_i d\Gamma \\
\\
&& \displaystyle 
+\iint_{\Gamma_w} - \frac{\rho_w }{\rho_i } \left( - div \left( H \left[ \begin{array}{c}
\bar{u} \\
\bar{v}
\end{array}\right] \right) \right) \phi_i - \frac{\rho_w }{\rho_i } \dot{M_a} \phi_i +\left( \frac{\rho_w }{\rho_i } -1\right)  \dot{M_b} \phi_i d\Gamma
\end{array}
\end{equation}
We now decompose these two matrices over the reference elements and use gaussian points for the integration :

\begin{center}
 $1 \leq i \leq 6$ and  $1 \leq j \leq 6$ 
\end{center}
\begin{equation}
\begin{array}{c l}
\displaystyle
K_{i,j} & \displaystyle = 
\iint_{\hat{E}} L_j  L_i \vert J \vert d\hat{\Gamma}\\
\\
& \displaystyle \simeq
\sum_{g=1}^3  W_g L_j(g) L_i(g) \vert J_g \vert 
\end{array}
\end{equation}
\\
This elementary stiffness matrix is calculated with three matrices: $\displaystyle K1= \sum_{g=1}^3 [B]^T[D][B]$ as follows:

\begin{equation}
[B]=\left[\begin{array}{c c c}
B_1 & B_2 & B_3 
\end{array}\right] \quad \text{and} \quad D=W_g \vert J_g \vert
\end{equation}
with:
\begin{equation}
B_i= L_i(g )
\end{equation}\\

\begin{center}
 $1 \leq i \leq 6$
\end{center}
\medskip
\begin{equation}
\begin{array}{l c l}
\displaystyle
F_{i} & \displaystyle = & \displaystyle
\iint_{\hat{E}} u \frac{\partial b}{\partial x} L_i +v \frac{\partial b}{\partial y} L_i \vert J \vert d\hat{\Gamma}
+\iint_{\hat{E}\cap\Gamma_b} -\dot{M_b} L_i \vert J \vert d\Gamma \\
\\
&& \displaystyle 
+\iint_{\hat{E}\cap\Gamma_w} - \frac{\rho_w }{\rho_i } \left( - div \left( H \left[ \begin{array}{c}
\bar{u} \\
\bar{v}
\end{array}\right] \right) \right) L_i - \frac{\rho_w }{\rho_i } \dot{M_a} L_i +\left( \frac{\rho_w }{\rho_i } -1\right)  \dot{M_b} L_i  \vert J \vert d\Gamma\\
\\
& \displaystyle \simeq & \displaystyle
\sum_{g=1}^3 u \frac{\partial b}{\partial x} L_i(g) +v \frac{\partial b}{\partial y} L_i (g) \vert J_g \vert 
+\underbrace{\sum_{g=1}^3 -\dot{M_b} L_i(g) \vert J_g \vert)}_{\text{ice shelf}}\\
\\
&& \displaystyle 
+\sum_{g=1}^3 - \frac{\rho_w }{\rho_i } \left( - div \left( H \left[ \begin{array}{c}
\bar{u} \\
\bar{v}
\end{array}\right]\right) \right) L_i(g) - \frac{\rho_w }{\rho_i } \dot{M_a} L_i(g) +\underbrace{\left( \frac{\rho_w }{\rho_i } -1\right)  \dot{M_b} L_i(g)  \vert J_g \vert}_{\text{ice sheet}}
\end{array}
\end{equation}




















        \subsection{Vertical velocity weak formulation}
As usual, We define a kinematically admissible velocity field $\phi$:

\begin{equation}
\phi(x,y,z)\in\lbrace H^{1}(\Omega\cup\partial\Omega) \quad \backslash\quad \phi(x,y,z)=0\qquad (x,y,z)\in \Gamma_b \rbrace
\end{equation}
\\
If one integrates the product of the equation (\ref{verticalequation}) by a kinematically admissible velocity field: 

\begin{equation}
\iiint_\Omega \dfrac{\partial w}{\partial z}\phi d\Omega 
=
- \iiint_\Omega 
\dfrac{\partial u}{\partial x}\phi + \dfrac{\partial v}{\partial y}\phi d\Omega
\end{equation}
\\
One can integrate by parts the left handside of the previous equation:

\begin{equation}
\iiint_\Omega w \dfrac{\partial \phi}{\partial z} d\Omega 
=
\iiint_\Omega 
\dfrac{\partial u}{\partial x}\phi + \dfrac{\partial v}{\partial y}\phi d\Omega +
\iiint_{\partial\Omega }
w\phi n_z dS
\end{equation}
\\
Where $\overrightarrow{n}=( n_x, n_y, n_z)$ is the unit normal vector pointing outward from the glacier. Since we work on a vertically extruded mesh, $n_z$ is equal to zero except on the upper and lower surface $\Gamma_b \cup \Gamma_s$. The function $\phi$ is cinematically admissible and is hence equal to zero on the lower surface $\Gamma_b$:

\begin{equation}
\iiint_\Omega w \dfrac{\partial \phi}{\partial z} d\Omega 
=
\iiint_\Omega 
\dfrac{\partial u}{\partial x}\phi + \dfrac{\partial v}{\partial y}\phi d\Omega +
\iint_{\Gamma_s}
w\phi n_z dS
\end{equation}
\\
The term $\displaystyle \iint_{ \Gamma_s} w\phi n_z dS$ is unknown. Therefore, we put it in the left handside of the weak formulation:

\begin{equation}
\iiint_\Omega w \dfrac{\partial \phi}{\partial z} d\Omega 
-
\iint_{\Gamma_s}
w\phi n_z dS
=
\iiint_\Omega 
\dfrac{\partial u}{\partial x}\phi + \dfrac{\partial v}{\partial y}\phi d\Omega
\end{equation}

        \subsection{Finite element discretisation, Galerkin method}
The domain is meshed using pentahedrons. There are a $nel$ elements and $nods$ grids. We use the nodal functions of each grid, which are continuous on the domain and affine on each element.
We now project the unknown $w$ on the nodal functions:
\begin{center}
 $(\phi_i)_{1\leq i\leq nods}$
\end{center}
\begin{equation}
w\left( x,y,z\right) = \sum_{i=1}^{nods}w_{i}\phi_{i}\left( x,y,z\right) \\
\end{equation}
\\
We build a vector $W$ that holds all the unknows of the velocity field:

\begin{equation}
U=\left[ \begin{array}{c}
w_{1}\\
...\\
w_{nods}
  \end{array} \right]
\end{equation}
\\
With this new field, we  replace the component of the virtual function $\phi$ by the nodal functions:
\begin{center}
 $\forall 1 \leq i \leq nods$
\end{center}
\begin{equation}
\sum_{j=1}^{nods} 
\iiint_\Omega w_j \phi_j \dfrac{\partial \phi_i}{\partial z} d\Omega 
-
\iint_{\Gamma_s}
w_j \phi_j\phi_i n_z dS
=
\iiint_\Omega 
\dfrac{\partial u}{\partial x}\phi_i + \dfrac{\partial v}{\partial y}\phi_i d\Omega
\end{equation}
\\
We see the stiffness matrix $K$ and load vector $F$ appearing, so that the previous equations can be written as a system matrix :

\begin{equation}
\left[ K \right] W =F 
\end{equation} 
\\
We use the following index:

\begin{equation}
\left[
\begin{array}{c c c} %K
  & \vdots  &\\
 \cdots & K & \cdots\\
  & \vdots  &\\
\end{array}
\right]
\left[
\begin{array}{c} %U
\vdots \\
w_j\\
\vdots\\
\end{array}
\right]
=
\left[
\begin{array}{c} %F
\vdots \\
F_{j}\\
\vdots\\
\end{array}
\right]
\end{equation}
\\
And  we have the following expressions for the stiffness matrix and the load vector :

\begin{equation}
\begin{array}{l l}
\displaystyle

K_{i,j} &\displaystyle = 
\iiint_\Omega \phi_j \dfrac{\partial \phi_i}{\partial z} d\Omega 
-
\iint_{\Gamma_s}
\phi_j \phi_i n_z dS\\
\\
F_{i} &\displaystyle = 
\iiint_\Omega 
\dfrac{\partial u}{\partial x}\phi_i + \dfrac{\partial v}{\partial y}\phi_i d\Omega
\end{array}
\end{equation}


 \subsection{Elementary stiffness matrix}
To compute the elementary stiffness matrix, we first remove the integral over the upper surface, that will create a first elementary stiffness matrix $K1$, the upper surface integral will constitute another stiffness matrix $K2$. The elementary stiffness matrix will be the sum of $K1$ and $K2$ ($K_E=K1+K2$).

        \subsubsection{Without the upper surface}

This matrix has the following shape:

\begin{center}
 $1 \leq i \leq 6$ and  $1 \leq j \leq 6$ 
\end{center}
\begin{equation}
\displaystyle
K1_{i,j}= 
\iiint_E \phi_j \dfrac{\partial \phi_i}{\partial z} dV
\end{equation}
\\
Using the reference element $\hat{E}$ and the gaussian points, this matrix becomes:
\begin{center}
 $1 \leq i \leq 6$ and  $1 \leq j \leq 6$ 
\end{center}
\medskip
\begin{equation}
\begin{array}{c l}
\displaystyle
K1_{i,j} & \displaystyle = 
\iiint_{\hat{E}} L_j \dfrac{\partial L_i}{\partial \varphi_z} \vert J \vert d\hat{V}\\
\\
& \displaystyle \simeq
\sum_{g=1}^6  W_g L_j(g) \left.\dfrac{\partial L_i}{\partial \varphi_z}\right| _g \vert J_g \vert 
\end{array}
\end{equation}
\\
This elementary stiffness matrix is calculated with three matrices: $\displaystyle K1= \sum_{g=1}^6 [B]^T[D][B']$ as follows:

\begin{equation}
[B]=\left[\begin{array}{c c c c c c}
B_1 & B_2 & B_3 & B_4 & B_5 & B_6
\end{array}\right]
\quad \text{and} \quad
[B']=\left[\begin{array}{c c c c c c}
B'_1 & B'_2 & B'_3 & B'_4 & B'_5 & B'_6
\end{array}\right]
\end{equation}
with:
\begin{equation}
B_i= \left.\dfrac{\partial L_i}{\partial \varphi_z}\right| _g 
\quad \quad
B'_i= L_i(g)
\end{equation}
\\
and $D=W_g \vert J_g \vert$ 

        \subsubsection{Upper surface integral}
The upper surface involves only the three upper nods on the top of the upper pentahedrons of the mesh (which are the last three grids of the pentahedron grids lists). The elements are triangles and there are only 3 nodal functions to take into account. Therefore, this stiffness matrix is $3 \times 3$.\\
The basal drag matrix has the following shape:

\begin{center}
 $4 \leq i \leq 6$ and  $4 \leq j \leq 6$ 
\end{center}
\begin{equation}
\displaystyle
K2_{i,j}= 
-
\iint_{E\cup\Gamma_s}
\phi_j \phi_i n_z dS
\end{equation}
\\
Using the reference element $\hat{E}$ and the gaussian points, this matrix becomes:
\begin{center}
 $4 \leq i \leq 6$ and  $4 \leq j \leq 6$ 
\end{center}
\medskip
\begin{equation}
\begin{array}{c l}
\displaystyle
K2_{i,j} & \displaystyle = 
-\iiint_{\hat{E}\cup \Gamma_s} L_j(g)Li(g) \vert J \vert d\hat{S}\\
\\
& \displaystyle \simeq
-\sum_{g=1}^6  W_g L_j(g)L_i(g) \vert J_g \vert 
\end{array}
\end{equation}
\\
This elementary stiffness matrix is calculated with three matrices: $\displaystyle K1= \sum_{g=1}^6 [L]^T[D][L]$ as follows:

\begin{equation}
[L]=\left[\begin{array}{c c c}
L_4 & L_5 & L_6
\end{array}\right]
\end{equation}
\\
with:

\begin{equation}
L_i= Li(g)
\end{equation}
\\
and $D=-W_g \vert J_g \vert$ 

 \subsection{Elementary load vector}
The elementary load vector has the following shape:

\begin{equation}
F_{i} = 
\iiint_E  \dfrac{\partial}{\partial x}\left( \sum_{k=1}^6 u_k \phi_k \right) \phi_i + \dfrac{\partial}{\partial y}\left( \sum_{k=1}^6 v_k \phi_k \right)\phi_i dV
\end{equation}
\\
Using the reference element $\hat{E}$ and the gaussian points, this matrix becomes:
\begin{center}
 $1 \leq i \leq 6$
\end{center}
\medskip
\begin{equation}
\begin{array}{c l}
\displaystyle
F_{i} & \displaystyle = 
\iiint_{\hat{E}}  \dfrac{\partial}{\partial \varphi_x}\left( \sum_{k=1}^6 u_k L_k \right)L_i 
+ \dfrac{\partial}{\partial \varphi_y} \left( \sum_{k=1}^6 v_k L_k \right)L_i d\hat{V}
\\
& \displaystyle \simeq
\sum_{g=1}^6 \left(  \left.\dfrac{\partial}{\partial \varphi_x}\left( \sum_{k=1}^6 u_k L_k \right)\right| _gL_i(g) 
+ \left.\dfrac{\partial}{\partial \varphi_y} \left( \sum_{k=1}^6 v_k L_k \right)\right| _g L_i(g)\right) \vert J_g \vert 
\end{array}
\end{equation}




















\newpage
   \section{Full Stokes Model}
   \label{stokessection}

    \subsection{Geometry and notations}
 
The geometry is exactly the same as in Pattyn's model.
        \subsection{Equations}
        
In the first chapter, we had:

\begin{equation}
\begin{array}{c}
 \left\{ \begin{array}{l}
\displaystyle                \frac{\partial}{\partial x} \left(  2 \mu \frac{\partial u}{\partial x} \right)
+\frac{\partial}{\partial y} \left(  \mu \frac{\partial u}{\partial y} +\mu \frac{\partial v}{\partial x} \right)
+\frac{\partial}{\partial z} \left(  \mu \frac{\partial u}{\partial z} +\mu \frac{\partial w}{\partial x} \right)
-\frac{\partial P}{\partial x}=0\\
\\
\displaystyle               \frac{\partial}{\partial x} \left(  \mu \frac{\partial u}{\partial y} +\mu \frac{\partial v}{\partial x} \right)
+\frac{\partial}{\partial y} \left(  2 \mu \frac{\partial v}{\partial y} \right)
+\frac{\partial}{\partial z} \left(  \mu \frac{\partial v}{\partial z} +\mu \frac{\partial w}{\partial y} \right)
-\frac{\partial P}{\partial y}=0\\            
\\
\displaystyle               \frac{\partial}{\partial x} \left(  \mu \frac{\partial u}{\partial z} +\mu \frac{\partial w}{\partial x} \right)
+\frac{\partial}{\partial y} \left(  \mu \frac{\partial v}{\partial z} +\mu \frac{\partial w}{\partial y} \right)
+\frac{\partial}{\partial z} \left(  2 \mu \frac{\partial w}{\partial z} \right)
-\frac{\partial P}{\partial z} - \rho g=0\\     
                 \end{array} \right.
                 \\
                 \\
\displaystyle \frac{\partial u}{\partial x}+\frac{\partial v}{\partial y}+\frac{\partial w}{\partial z}=0
\end{array}
\end{equation}
\\
The boundary conditions are:
 a dynamic boundary condition (Neumann) at the ice front, a friction law on the ice sheet, and single point constraint (Dirichlet) on the other borders of the domain $\Omega$.
Exactly as in Pattyn's formulation, it is more convenient to consider these specified velocities as nill. For the vertical basal velocity, we use a multiple points constraint. This process, similar to a pemalty method, is explained in section \ref{stokespenaltiessection}.

\begin{equation}
\left\{ \begin{array}{l l}
\text{Ice Front } \Gamma_i: & \displaystyle \sigma \overrightarrow{n} = F_i \overrightarrow{n}= \rho_w g \min\left( 0,z\right)  \overrightarrow{n}\\
\\
\text{Upper surface } \Gamma_s: & \sigma \left(  \overrightarrow{n}\right) =0\\
\\
\text{Ice sheet base } \Gamma_b: & \left( \sigma \left(  \overrightarrow{n}\right)\right)_x  + p\;n_x= -K^2 N_{eff}^r \|\overrightarrow{v} \|^{s-1} u =-\alpha^2 u \\
\\
& \left( \sigma \left(  \overrightarrow{n}\right)\right)_y  + p\;n_y= -K^2 N_{eff}^r \|\overrightarrow{v} \|^{s-1} v =-\alpha^2 v \\
\\
& \displaystyle w=0\\
\\ 
\text{Ice shelf base } \Gamma_w: &  \sigma \overrightarrow{n} = F_w \overrightarrow{n}= \rho_w g b(x,y)  \overrightarrow{n}\\
\\ 
\text{Other  borders } \Gamma_u: & u=v=w=0\\
\end{array} \right.
\end{equation}

        \subsection{Weak Formulation}

we  write the weak formulation to solve these equations
using finite element method. We define a kinematically admissible velocity field $\overrightarrow{\phi}$ and pressure field $P^*$ such that:

\begin{equation}
\overrightarrow{\phi}(x,y,z)\in\lbrace \left( H^{1}(\Omega\cup\partial\Omega) \right)^3 \quad \backslash\quad \overrightarrow{\phi}(x,y,z)=0\qquad (x,y,z)\in\Gamma_u\rbrace
\end{equation}
\begin{equation}
P^*(x,y,z)\in H^{1}(\Omega\cup\partial\Omega)
\end{equation}
\\
For any function of these virtual fields, one can take the scalar product of the equations with $\overrightarrow{\phi}=\left(\phi_x,0 ,0\right) $,  $\overrightarrow{\phi}=\left(0,\phi_y,0 \right) $ and $\overrightarrow{\phi}=\left(0,0,\phi_z \right) $ that are 3 other kinematically admissible velocity fields. One can also multiply the last equation by the virtual pressure field and integrate this product over the domain. This gives us:

\begin{equation}
\begin{array}{l}
\displaystyle \iiint_\Omega %double
\left[
\frac{\partial}{\partial x} \left(  2 \mu \frac{\partial u}{\partial x} \right)
+\frac{\partial}{\partial y} \left(  \mu \frac{\partial u}{\partial y} +\mu \frac{\partial v}{\partial x} \right)
+\frac{\partial}{\partial z} \left(  \mu \frac{\partial u}{\partial z} +\mu \frac{\partial w}{\partial x} \right)
-\frac{\partial P}{\partial x}
\right] \phi_x  d\Omega =0
\\
\\
\displaystyle \iiint_\Omega %double
\left[
\frac{\partial}{\partial x} \left(  \mu \frac{\partial u}{\partial y} +\mu \frac{\partial v}{\partial x} \right)
+\frac{\partial}{\partial y} \left(  2 \mu \frac{\partial v}{\partial y} \right)
+\frac{\partial}{\partial z} \left(  \mu \frac{\partial v}{\partial z} +\mu \frac{\partial w}{\partial y} \right)
-\frac{\partial P}{\partial y}
\right] \phi_y  d\Omega =0
\\
\\
\displaystyle \iiint_\Omega %double
\left[
\frac{\partial}{\partial x} \left(  \mu \frac{\partial u}{\partial z} +\mu \frac{\partial w}{\partial x} \right)
+\frac{\partial}{\partial y} \left(  \mu \frac{\partial v}{\partial z} +\mu \frac{\partial w}{\partial y} \right)
+\frac{\partial}{\partial z} \left(  2 \mu \frac{\partial w}{\partial z} \right)
-\frac{\partial P}{\partial z} - \rho g
\right] \phi_z  d\Omega =0
\\
\\
\displaystyle \iiint_\Omega %double
\left[
-\frac{\partial u}{\partial x}-\frac{\partial v}{\partial y}-\frac{\partial w}{\partial z}
\right] P^*  d\Omega =0
\end{array}
\end{equation}
\\
\emph{NB}: We change the sign of the incompressibility equation because otherwise the stiffness matrix wouldn't be symmetric.\\
One intergrates by parts the first three equations in order to merge in the force on the ice front $\Gamma_i$ and the basal friction $\Gamma_b$:

\begin{multline}
\iiint_\Omega  %double
\left[
 \left(  2 \mu \frac{\partial u}{\partial x} \right)\frac{\partial \phi_x}{\partial x}
+\left(  \mu \frac{\partial u}{\partial y} +\mu \frac{\partial v}{\partial x} \right)\frac{\partial \phi_x}{\partial y} 
+\left(  \mu \frac{\partial u}{\partial z} +\mu \frac{\partial w}{\partial x} \right)\frac{\partial \phi_x}{\partial z} 
-P\frac{\partial \phi_x}{\partial x}
\right]   d\Omega
\\
 =
\iint_{\Gamma_i\cup\Gamma_b} F n_x\phi_x d\Gamma
\end{multline}
\begin{multline}
\iiint_\Omega %double
\left[
\left(  \mu \frac{\partial u}{\partial y} +\mu \frac{\partial v}{\partial x} \right)\frac{\partial \phi_y  }{\partial x} 
+\left(  2 \mu \frac{\partial v}{\partial y} \right)\frac{\partial \phi_y  }{\partial y} 
+ \left(  \mu \frac{\partial v}{\partial z} +\mu \frac{\partial w}{\partial y} \right)\frac{\partial \phi_y  }{\partial z}
-P \frac{\partial \phi_y  }{\partial y}
\right]d\Omega
\\
 =
\iint_{\Gamma_i\cup\Gamma_b} F n_y\phi_y d\Gamma
\end{multline}
\begin{multline}
\iiint_\Omega %double
\left[
\left(  \mu \frac{\partial u}{\partial z} +\mu \frac{\partial w}{\partial x} \right)\frac{\partial \phi_z  }{\partial x} 
+\left(  \mu \frac{\partial v}{\partial z} +\mu \frac{\partial w}{\partial y} \right)\frac{\partial \phi_z  }{\partial y} 
+\left(  2 \mu \frac{\partial w}{\partial z} \right)\frac{\partial \phi_z  }{\partial z} 
-P\frac{\partial \phi_z   }{\partial z}
\right]d\Omega 
\\
=
\iint_{\Gamma_i} F n_z\phi_z d\Gamma
-\iiint_\Omega %double
\rho g \phi_z d\Omega
\end{multline}
\\
It is easier to put the basal friction at the left hand side of the equation since it is velocity dependant. The first two equations become:

\begin{multline}
\iiint_\Omega  %double
\left[
 \left(  2 \mu \frac{\partial u}{\partial x} \right)\frac{\partial \phi_x}{\partial x}
+\left(  \mu \frac{\partial u}{\partial y} +\mu \frac{\partial v}{\partial x} \right)\frac{\partial \phi_x}{\partial y} 
+\left(  \mu \frac{\partial u}{\partial z} +\mu \frac{\partial w}{\partial x} \right)\frac{\partial \phi_x}{\partial z} 
-P\frac{\partial \phi_x}{\partial x}
\right]   d\Omega
\\
 + \iint_{\Gamma_b} \alpha^2 u \phi_x d\Gamma
 =
\iint_{\Gamma_i} F n_x\phi_x d\Gamma
\end{multline}
\begin{multline}
\iiint_\Omega %double
\left[
\left(  \mu \frac{\partial u}{\partial y} +\mu \frac{\partial v}{\partial x} \right)\frac{\partial \phi_y  }{\partial x} 
+\left(  2 \mu \frac{\partial v}{\partial y} \right)\frac{\partial \phi_y  }{\partial y} 
+ \left(  \mu \frac{\partial v}{\partial z} +\mu \frac{\partial w}{\partial y} \right)\frac{\partial \phi_y  }{\partial z}
-P \frac{\partial \phi_y  }{\partial y}
\right]d\Omega
\\
 + \iint_{\Gamma_b} \alpha^2 v \phi_y d\Gamma
 =
\iint_{\Gamma_i} F n_y\phi_y d\Gamma
\end{multline}
\newpage
        \subsection{Finite element discretisation, Galerkin method}

The domain is meshed using MINI elements (See \ref{MINI} for more details). The pressure is evaluated on the pentahedron vertices ($nods$), and the velocity is evaluated on the same vertices and also in a grid located in the middle of each element ($nods+nel$). We use the nodal functions of each grid, which are continuous on the domain.\\
We now project the velocities on the classical nodal functions $\phi_{j}$ and on the bubble function $\phi_{b_j}$, and the pressur on the classical nodal functions:

\begin{equation}
\begin{array}{c}
\displaystyle u\left( x,y,z\right) = \sum_{i=1}^{nods}u_{i}\phi_{i}\left( x,y,z\right)+\sum_{j=1}^{nels}u_{j}\phi_{b_j}\left( x,y,z\right)
= \sum_{j=1}^{nods+nels}u_{j}\phi_{j}\left( x,y,z\right) \\
\\
\displaystyle v\left( x,y,z\right) = \sum_{i=1}^{nods}v_{i}\phi_{i}\left( x,y,z\right)+\sum_{j=1}^{nels}v_{j}\phi_{b_j}\left( x,y,z\right) 
= \sum_{j=1}^{nods+nels}v_{j}\phi_{j}\left( x,y,z\right) \\
\\
\displaystyle w\left( x,y,z\right) = \sum_{i=1}^{nods}w_{i}\phi_{i}\left( x,y,z\right)+\sum_{j=1}^{nels}w_{j}\phi_{b_j}\left( x,y,z\right)
= \sum_{j=1}^{nods+nels}w_{j}\phi_{j}\left( x,y,z\right) \\
\\
\displaystyle P\left( x,y,z\right)=  \sum_{k=1}^{nods}P_{k}\phi_{k}\left( x,y,z\right)
\end{array}
\end{equation}
\\
The nodal functions $\phi_{i}$ are bubble functions if $i>nods$. We build a vector $W$ that holds all the unknows of the velocity  and pressure field (for the sake of simplicity, this vector holds the speed components first and then the pressure of each element. This is not exactly what is done in ICE since the stiffness matrix would be badly conditioned):
:

\begin{equation}
W=\left[ \begin{array}{l}
u_{1}\\
v_{1}\\
w_{1}\\
\vdots\\
w_{nods}\\
P_{nods}\\
\vdots\\
P_{nods+nel}\\
\end{array} \right]
\end{equation}
\\
With these new unknows, one can replace the components of the virtual function $\overrightarrow{\phi}$ by any nodal functions (classical or bubble):
\begin{center}
 $\forall 1 \leq i \leq nods+nel$
\end{center}
\begin{multline}
\sum_{j=1}^{nods+nel} 
\iiint_\Omega  %double
 \left(  2 \mu u_j\frac{\partial \phi_j}{\partial x} \right)\frac{\partial \phi_i}{\partial x}
+\left(  \mu u_j\frac{\partial \phi_j}{\partial y} +\mu v_j \frac{\partial \phi_j}{\partial x} \right)\frac{\partial \phi_i}{\partial y} 
+\left(  \mu u_j\frac{\partial \phi_j}{\partial z} +\mu w_j \frac{\partial \phi_j}{\partial x} \right)\frac{\partial \phi_i}{\partial z} 
d\Omega
\\
+ \sum_{j=1}^{nods+nel} \iint_{\Gamma_b}  \alpha^2 u_j \phi_j\phi_i d\Gamma
+ \sum_{k=1}^{nods} \iint_{\Gamma_b} P_k \phi_k\phi_i n_x d\Gamma
-\sum_{k=1}^{nods}\iiint_\Omega 
P_{k} \phi_k\frac{\partial \phi_i}{\partial x}
d\Omega  
 =
\iint_{\Gamma_i} F n_x\phi_i d\Gamma
\end{multline}
\begin{multline}
\sum_{j=1}^{nods+nel} 
\iiint_\Omega %double
\left(  \mu u_j\frac{\partial \phi_j}{\partial y} +\mu v_j\frac{\partial \phi_j}{\partial x} \right)\frac{\partial \phi_i  }{\partial x} 
+\left(  2 \mu v_j\frac{\partial \phi_j}{\partial y} \right)\frac{\partial \phi_i  }{\partial y} 
+ \left(  \mu v_j\frac{\partial \phi_j}{\partial z} +\mu w_j\frac{\partial \phi_j}{\partial y} \right)\frac{\partial \phi_i  }{\partial z}
d\Omega
\\
+ \sum_{j=1}^{nods+nel} \iint_{\Gamma_b} \alpha^2 v_j \phi_j\phi_i d\Gamma 
+ \sum_{k=1}^{nods} \iint_{\Gamma_b} P_k \phi_k\phi_i n_y d\Gamma 
-\sum_{k=1}^{nods}\iiint_\Omega 
P_{k} \phi_k\frac{\partial \phi_i}{\partial y}
d\Omega 
 =
\iint_{\Gamma_i} F n_y\phi_i d\Gamma
\end{multline}
\begin{multline}
\sum_{j=1}^{nods+nel} 
\iiint_\Omega %double
\left(  \mu u_j\frac{\partial \phi_j}{\partial z} +\mu w_j\frac{\partial \phi_j}{\partial x} \right)\frac{\partial \phi_i  }{\partial x} 
+\left(  \mu v_j\frac{\partial \phi_j }{\partial z} +\mu w_j\frac{\partial \phi_j}{\partial y} \right)\frac{\partial \phi_i  }{\partial y} 
+\left(  2 \mu w_j\frac{\partial \phi_j}{\partial z} \right)\frac{\partial \phi_i  }{\partial z} 
d\Omega
\\
-\sum_{k=1}^{nods}\iiint_\Omega 
P_{k} \phi_k\frac{\partial \phi_i}{\partial z}
d\Omega 
=
\iint_{\Gamma_i} F n_z\phi_i d\Gamma
-\iiint_\Omega %double
\rho g \phi_i d\Omega
\end{multline}
\\
By rearranging terms:
\begin{center}
 $\forall 1 \leq i \leq nods+nel$
\end{center}
\begin{multline}
\sum_{j=1}^{nods+nel}
u_j \left[
\iiint_\Omega  %double
 2 \mu \frac{\partial \phi_j}{\partial x} \frac{\partial \phi_i}{\partial x}
 + \mu \frac{\partial \phi_j}{\partial y} \frac{\partial \phi_i}{\partial y} 
 + \mu \frac{\partial \phi_j}{\partial z} \frac{\partial \phi_i}{\partial z} d\Omega
 + \iint_{\Gamma_b} \alpha^2 \phi_j\phi_i d\Gamma 
\right] 
+
v_j \left[
\iiint_\Omega  %double
 \mu \frac{\partial \phi_j}{\partial x} \frac{\partial \phi_i}{\partial y} 
d\Omega 
\right]\\
+
 w_j\left[
 \iiint_\Omega  %double
\mu \frac{\partial \phi_j}{\partial x} \frac{\partial \phi_i}{\partial z} 
d\Omega 
\right]
+\sum_{k=1}^{nods} P_{k} 
\left[\iint_{\Gamma_b}  \phi_k\phi_i n_x d\Gamma
-\iiint_\Omega 
\phi_k\frac{\partial \phi_i}{\partial x}
d\Omega \right]
 =
\iint_{\Gamma_i} F n_x\phi_i d\Gamma
\end{multline}
\begin{multline}
\sum_{j=1}^{nods+nel} 
u_j \left[
\iiint_\Omega %double
  \mu \frac{\partial \phi_j}{\partial y} \frac{\partial \phi_i}{\partial x} 
d\Omega \right] 
+
v_j\left[
\iiint_\Omega %double
   \mu \frac{\partial \phi_j}{\partial x} \frac{\partial \phi_i}{\partial x}
 +2\mu \frac{\partial \phi_j}{\partial y} \frac{\partial \phi_i}{\partial y} 
 + \mu \frac{\partial \phi_j}{\partial z} \frac{\partial \phi_i}{\partial z} d\Omega
 + \iint_{\Gamma_b} \alpha^2 \phi_j\phi_i d\Gamma 
\right] \\
+
w_j\left[
\iiint_\Omega %double
\mu \frac{\partial \phi_j}{\partial y} \frac{\partial \phi_i}{\partial z} d\Omega
\right]
+\sum_{k=1}^{nods} P_{k}
\left[ \iint_{\Gamma_b} \phi_k\phi_i n_y d\Gamma
- \iiint_\Omega 
\phi_k\frac{\partial \phi_i}{\partial z}
d\Omega \right]  
 =
\iint_{\Gamma_i} F n_y\phi_i d\Gamma
\end{multline}
\begin{multline}
\sum_{j=1}^{nods+nel} 
\iiint_\Omega %double
u_j\left[
\iiint_\Omega %double
\mu \frac{\partial \phi_j}{\partial z} \frac{\partial \phi_i}{\partial x} d\Omega
\right] 
+
 v_j\left[
\iiint_\Omega %double
\mu \frac{\partial \phi_j}{\partial z} \frac{\partial \phi_i}{\partial y} d\Omega
\right]\\
+
 w_j \left[   
\iiint_\Omega %double
    \mu \frac{\partial \phi_j}{\partial x} \frac{\partial \phi_i}{\partial x}
 +  \mu \frac{\partial \phi_j}{\partial y} \frac{\partial \phi_i}{\partial y} 
 +2 \mu \frac{\partial \phi_j}{\partial z} \frac{\partial \phi_i}{\partial z} d\Omega
\right]
-\sum_{k=1}^{nods} P_{k}\iiint_\Omega 
\phi_k\frac{\partial \phi_i}{\partial y}
d\Omega
=
\iint_{\Gamma_i} F n_z\phi_i d\Gamma
-\iiint_\Omega %double
\rho g \phi_i d\Omega
\end{multline}
\\
And the incompressibility gives an additional equation, with $P^*=\phi_l\left( x,y,z\right)$ ($1\leq l\leq nods$, no bubble functions):
\vspace*{-2mm}
\begin{center}
 $\forall 1 \leq l \leq nods $
\end{center}
\begin{equation}
\displaystyle \sum_{j=1}^{nods+nel}  \iiint_\Omega %double
\left[
-\frac{\partial \phi_j}{\partial x}u_j-\frac{\partial \phi_j}{\partial y}v_j-\frac{\partial\phi_j }{\partial z}w_j
\right] \phi_l d\Omega =0
\end{equation}
\\
We see the stiffness matrix $K$ and load vector $F$ appearing, so that the previous equation can be written as follows:

\begin{equation*}
\left[
\begin{array}{c c c c c c c} %K
 & \vdots & \vdots &\vdots & &\vdots &\\
 \cdots & K_{3i-2,3j-2} &  K_{3i-2,3j-1} &  K_{3i-2,3j} &\cdots &   K_{3i-2,3nods+k} & \cdots\\
 &&&&& \\
 \cdots & K_{3i-1,3j-2} &  K_{3i-1,3j-1} &  K_{3i-1,3j} &\cdots &   K_{3i-1,3nods+k} & \cdots\\
 &&&&& \\
  \cdots & K_{3i,3j-2} &  K_{3i,3j-1} &  K_{3i,3j} & \cdots &  K_{3i,3nods+k} & \cdots\\
 & \vdots & \vdots &\vdots & &\vdots &\\
  \cdots & K_{3nods+l,3j-2} &  K_{3nods+l,3j-1} &  K_{3nods+l,3j} &\cdots &   K_{3nods+l,3nods+k} & \cdots\\
 & \vdots & \vdots &\vdots & &\vdots &\\
\end{array}
\right]
\left[
\begin{array}{c} %U
\vdots \\
u_j\\
\\
v_j\\
\\
w_j\\
\vdots\\
P_k\\
\vdots\\
\end{array}
\right]
=
\left[
\begin{array}{c} %F
\vdots \\
F_{3j-2}\\
\\
F_{3j-1}\\
\\
F_{3j}\\
\vdots\\
F_{3nods+k}\\
\vdots\\
\end{array}
\right]
\end{equation*}
\begin{equation}
\begin{array}{l l}
\displaystyle
K_{3i-2,3j-2} &\displaystyle = 
\iiint_\Omega  %double
 2 \mu \frac{\partial \phi_j}{\partial x} \frac{\partial \phi_i}{\partial x}
 + \mu \frac{\partial \phi_j}{\partial y} \frac{\partial \phi_i}{\partial y} 
 + \mu \frac{\partial \phi_j}{\partial z} \frac{\partial \phi_i}{\partial z} 
d\Omega
 + \iint_{\Gamma_b} \alpha^2 \phi_j\phi_i d\Gamma \\
\\
K_{3i-2,3j-1} &\displaystyle = 
\iiint_\Omega  %double
 \mu \frac{\partial \phi_j}{\partial x} \frac{\partial \phi_i}{\partial y} 
d\Omega\\
\\
K_{3i-2,3j} &\displaystyle = 
\iiint_\Omega  %double
\mu \frac{\partial \phi_j}{\partial x} \frac{\partial \phi_i}{\partial z} 
d\Omega\\
\\
K_{3i-2,3nods+k} &\displaystyle = 
\iint_{\Gamma_b} \phi_k\phi_i n_x d\Gamma
+\iiint_\Omega  %double
-\phi_k\frac{\partial \phi_i}{\partial x}
d\Omega\\
\\
\displaystyle
K_{3i-1,3j-2} &\displaystyle = 
\iiint_\Omega  %double
\mu \frac{\partial \phi_j}{\partial y} \frac{\partial \phi_i}{\partial x} 
d\Omega\\
\\
K_{3i-1,3j-1} &\displaystyle = 
\iiint_\Omega  %double
   \mu \frac{\partial \phi_j}{\partial x} \frac{\partial \phi_i}{\partial x}
 +2\mu \frac{\partial \phi_j}{\partial y} \frac{\partial \phi_i}{\partial y} 
 + \mu \frac{\partial \phi_j}{\partial z} \frac{\partial \phi_i}{\partial z} 
d\Omega
 + \iint_{\Gamma_b} \alpha^2 \phi_j\phi_i d\Gamma \\
\\
K_{3i-1,3j} &\displaystyle = 
\iiint_\Omega  %double
\mu \frac{\partial \phi_j}{\partial y} \frac{\partial \phi_i}{\partial z} 
d\Omega\\
\\
K_{3i-1,3nods+k} &\displaystyle = 
\iint_{\Gamma_b} \phi_k\phi_i n_x d\Gamma
+
\iiint_\Omega  %double
-\phi_k\frac{\partial \phi_i}{\partial y}
d\Omega\\
\\
\displaystyle
K_{3i,3j-2} &\displaystyle = 
\iiint_\Omega  %double
\mu \frac{\partial \phi_j}{\partial z} \frac{\partial \phi_i}{\partial x} 
d\Omega\\
\\
K_{3i,3j-1} &\displaystyle = 
\iiint_\Omega  %double
\mu \frac{\partial \phi_j}{\partial z} \frac{\partial \phi_i}{\partial y} 
d\Omega\\
\\
K_{3i,3j} &\displaystyle = 
\iiint_\Omega  %double
    \mu \frac{\partial \phi_j}{\partial x} \frac{\partial \phi_i}{\partial x}
 +  \mu \frac{\partial \phi_j}{\partial y} \frac{\partial \phi_i}{\partial y} 
 +2 \mu \frac{\partial \phi_j}{\partial z} \frac{\partial \phi_i}{\partial z}
d\Omega\\
\\
K_{3i,3nods+k} &\displaystyle = 
\iiint_\Omega  %double
-\phi_k\frac{\partial \phi_i}{\partial z}
d\Omega\\
\\
\displaystyle
K_{3nods+l,3j-2} &\displaystyle = 
\iiint_\Omega %double
-\frac{\partial \phi_j}{\partial x}\phi_l d\Omega\\
\\
K_{3nods+l,3j-1} &\displaystyle = 
\iiint_\Omega %double
-\frac{\partial \phi_j}{\partial y}\phi_l d\Omega\\
\\
K_{3nods+l,3j} &\displaystyle = 
\iiint_\Omega %double
-\frac{\partial \phi_j}{\partial z}\phi_l d\Omega\\
\\
K_{3nods+l,3nods+k} & =0\\
\end{array}
\end{equation}
And the load vector has the following expression:
\begin{equation}
\begin{array}{l l}
\displaystyle
F_{3i-2} &\displaystyle = 
\iint_{\Gamma_i} F n_x\phi_i d\Gamma\\
\\
F_{3i-1} &\displaystyle = 
\iint_{\Gamma_i} F n_y\phi_i d\Gamma\\
\\
F_{3i} &\displaystyle = 
\iint_{\Gamma_i} F n_z\phi_i d\Gamma
-\iiint_\Omega %double
\rho g \phi_i d\Omega\\
\\
F_{3nods+k} &\displaystyle = 0
\end{array}
\end{equation}
\newpage
        \subsection{Decomposition over the elements and reference element}
See the same section for Pattyn's model.\\
\\
One element $E$ gives 19 equations: we can take 6 classical nodal functions for $\phi_i(x,y,z)$ (the nodal functions corresponding to the vertexes of $E$, which is an pentahedron), each $\phi_i$ gives 4 equations (one for the x-component, one for the y-component, one for the z-component and one for the pressure) and there are 3 additional equations using the grid in the middle of the pentahedron (3 compenents of the velocity). Therefore, an elementary stiffness matrix $K_E$ will be $27 \times 27$, and the elementary load vector will be of size $27$.

\newpage
        \subsection{Elementary stiffness matrix}
        
To compute the elementary stiffness matrix, we first remove the basal drag, that will create a first elementary stiffness matrix $K1$, the basal drag will constitute another stiffness matrix $K2$. The elementary stiffness matrix will be the sum of $K1$ and $K2$ ($K_E=K1+K2$).

        \subsubsection{Without basal drag}

This matrix has the following shape:

\begin{center}
 $1 \leq i \leq 7$, $1 \leq j \leq 7$,  $1 \leq k \leq 6$ and $1 \leq l \leq 6$
\end{center}
\begin{equation}
\begin{array}{l l}
\displaystyle
K_{3i-2,3j-2} &\displaystyle = 
\iiint_E  %double
 2 \mu \frac{\partial \phi_j}{\partial x} \frac{\partial \phi_i}{\partial x}
 + \mu \frac{\partial \phi_j}{\partial y} \frac{\partial \phi_i}{\partial y} 
 + \mu \frac{\partial \phi_j}{\partial z} \frac{\partial \phi_i}{\partial z} 
d\Omega\\
\\
K_{3i-2,3j-1} &\displaystyle = 
\iiint_E  %double
 \mu \frac{\partial \phi_j}{\partial x} \frac{\partial \phi_i}{\partial y} 
d\Omega\\
\\
K_{3i-2,3j} &\displaystyle = 
\iiint_E  %double
\mu \frac{\partial \phi_j}{\partial x} \frac{\partial \phi_i}{\partial z} 
d\Omega\\
\\
K_{3i-2,k} &\displaystyle = 
\iiint_E  %double
-\phi_k\frac{\partial \phi_i}{\partial x}
d\Omega\\
\end{array}
\end{equation}
\begin{equation}
\begin{array}{l l}
\displaystyle
K_{3i-1,3j-2} &\displaystyle = 
\iiint_E  %double
\mu \frac{\partial \phi_j}{\partial y} \frac{\partial \phi_i}{\partial x} 
d\Omega\\
\\
K_{3i-1,3j-1} &\displaystyle = 
\iiint_E  %double
   \mu \frac{\partial \phi_j}{\partial x} \frac{\partial \phi_i}{\partial x}
 +2\mu \frac{\partial \phi_j}{\partial y} \frac{\partial \phi_i}{\partial y} 
 + \mu \frac{\partial \phi_j}{\partial z} \frac{\partial \phi_i}{\partial z} 
d\Omega\\
\\
K_{3i-1,3j} &\displaystyle = 
\iiint_E  %double
\mu \frac{\partial \phi_j}{\partial y} \frac{\partial \phi_i}{\partial z} 
d\Omega\\
\\
K_{3i-1,k} &\displaystyle = 
\iiint_E  %double
-\phi_k\frac{\partial \phi_i}{\partial y}
d\Omega\\
\end{array}
\end{equation}
\begin{equation}
\begin{array}{l l}
\displaystyle
K_{3i,3j-2} &\displaystyle = 
\iiint_E  %double
\mu \frac{\partial \phi_j}{\partial z} \frac{\partial \phi_i}{\partial x} 
d\Omega\\
\\
K_{3i,3j-1} &\displaystyle = 
\iiint_E  %double
\mu \frac{\partial \phi_j}{\partial z} \frac{\partial \phi_i}{\partial y} 
d\Omega\\
\\
K_{3i,3j} &\displaystyle = 
\iiint_E  %double
    \mu \frac{\partial \phi_j}{\partial x} \frac{\partial \phi_i}{\partial x}
 +  \mu \frac{\partial \phi_j}{\partial y} \frac{\partial \phi_i}{\partial y} 
 +2 \mu \frac{\partial \phi_j}{\partial z} \frac{\partial \phi_i}{\partial z}
d\Omega\\
\\
K_{3i,k} &\displaystyle = 
\iiint_E  %double
-\frac{\partial \phi_i}{\partial z}\phi_k
d\Omega\\
\\
\displaystyle
K_{l,3j-2} &\displaystyle = 
\iiint_E %double
-\frac{\partial \phi_j}{\partial x}\phi_l d\Omega\\
\\
K_{l,3j-1} &\displaystyle = 
\iiint_E %double
-\frac{\partial \phi_j}{\partial y}\phi_l d\Omega\\
\\
K_{l,3j} &\displaystyle = 
\iiint_E %double
-\frac{\partial \phi_j}{\partial z}\phi_l d\Omega\\
\\
K_{l,k} & =0\\
\end{array}
\end{equation}
\\
\newpage
Using the reference element $\hat{E}$ and the gaussian points, this matrix becomes:
\begin{center}
 $1 \leq i \leq 7$, $1 \leq j \leq 7$,  $1 \leq k \leq 6$ and $1 \leq l \leq 6$
\end{center}
\medskip
\begin{equation*}
\begin{array}{c l}
\displaystyle
K1_{3i-2,3j-2} & \displaystyle = 
\iiint_{\hat{E}}  %triple
  \left( 
 2 \mu \frac{\partial L_j}{\partial \varphi_x} \frac{\partial L_i}{\partial \varphi_x}
 + \mu \frac{\partial L_j}{\partial \varphi_y} \frac{\partial L_i}{\partial \varphi_y} 
 + \mu \frac{\partial L_j}{\partial \varphi_z} \frac{\partial L_i}{\partial \varphi_z} 
  \right) \vert J \vert d\hat{V} \\ \\
& \displaystyle \simeq
\sum_{g=1}^3  W_g \left( 
 2 \mu \left.\frac{\partial L_j}{\partial \varphi_x} \right|_g \left.\frac{\partial L_i}{\partial \varphi_x} \right|_g
 + \mu \left.\frac{\partial L_j}{\partial \varphi_y} \right|_g \left.\frac{\partial L_i}{\partial \varphi_y} \right|_g 
+ \mu \left.\frac{\partial L_j}{\partial \varphi_z} \right|_g \left.\frac{\partial L_i}{\partial \varphi_z} \right|_g 
\right) \vert J_g \vert \\
\\
\displaystyle
K1_{3i-2,3j-1} & \displaystyle = 
\iiint_{\hat{E}}  %triple
  \left( 
   \mu \frac{\partial L_j}{\partial \varphi_x} \frac{\partial L_i}{\partial \varphi_y} 
  \right) \vert J \vert d\hat{V} \\ \\
& \displaystyle \simeq
\sum_{g=1}^3  W_g \left( 
   \mu \left.\frac{\partial L_j}{\partial \varphi_x}\right|_g \left.\frac{\partial L_i}{\partial \varphi_y}\right|_g 
\right) \vert J_g \vert \\
\\
\displaystyle
K1_{3i-2,3j} & \displaystyle = 
\iiint_{\hat{E}}  %triple
  \left( 
\mu \frac{\partial L_j}{\partial \varphi_x} \frac{\partial L_i}{\partial \varphi_z} 
  \right) \vert J \vert d\hat{V} \\ \\
& \displaystyle \simeq
\sum_{g=1}^3  W_g \left( 
\mu \left.\frac{\partial L_j}{\partial \varphi_x}\right|_g \left.\frac{\partial L_i}{\partial \varphi_z} \right|_g
\right) \vert J_g \vert \\
\\
\displaystyle
K1_{3i-2,k} & \displaystyle = 
\iiint_{\hat{E}}  %triple
  \left( 
-L_k\frac{\partial L_i}{\partial \varphi_x}
  \right) \vert J \vert d\hat{V} \\ \\
& \displaystyle \simeq
\sum_{g=1}^3  W_g \left( 
-L_k(g)\left.\frac{\partial L_i}{\partial \varphi_x}\right|_g
\right) \vert J_g \vert \\
\end{array}
\end{equation*}
\begin{equation*}
\begin{array}{c l}
\displaystyle
K_{3i-1,3j-2} &\displaystyle = 
\iiint_{\hat{E}}  %triple
\left( 
\mu \frac{\partial L_j}{\partial \varphi_y} \frac{\partial L_i}{\partial \varphi_x} 
\right) \vert J \vert d\hat{V} \\ \\
& \displaystyle \simeq
\sum_{g=1}^3  W_g \left( 
  \mu \left.\frac{\partial L_j}{\partial \varphi_y}\right|_g \left.\frac{\partial L_i}{\partial \varphi_x} \right|_g
\right) \vert J_g \vert \\
\\
\displaystyle
K_{3i-1,3j-1} &\displaystyle = 
\iiint_{\hat{E}}  %triple
\left( 
\mu \frac{\partial L_j}{\partial \varphi_x} \frac{\partial L_i}{\partial \varphi_x}
 +2\mu \frac{\partial L_j}{\partial \varphi_y} \frac{\partial L_i}{\partial \varphi_y} 
 + \mu \frac{\partial L_j}{\partial \varphi_z} \frac{\partial L_i}{\partial \varphi_z} 
\right) \vert J \vert d\hat{V} \\ \\
& \displaystyle \simeq
\sum_{g=1}^3  W_g \left( 
   \mu \left.\frac{\partial L_j}{\partial \varphi_x}\right|_g \left.\frac{\partial L_i}{\partial \varphi_x}\right|_g
 +2\mu \left.\frac{\partial L_j}{\partial \varphi_y}\right|_g \left.\frac{\partial L_i}{\partial \varphi_y} \right|_g
+ \mu \left.\frac{\partial L_j}{\partial \varphi_z}\right|_g \left.\frac{\partial L_i}{\partial \varphi_z} \right|_g
\right) \vert J_g \vert \\
\\
\displaystyle
K_{3i-1,3j} &\displaystyle = 
\iiint_{\hat{E}}  %triple
\left( 
\mu \frac{\partial L_j}{\partial \varphi_y} \frac{\partial L_i}{\partial \varphi_z}   
\right) \vert J \vert d\hat{V} \\ \\
& \displaystyle \simeq
\sum_{g=1}^3  W_g \left( 
\mu \left.\frac{\partial L_j}{\partial \varphi_y}\right|_g \left.\frac{\partial L_i}{\partial \varphi_z}\right|_g   
\right) \vert J_g \vert \\
\\
\displaystyle
K_{3i-1,k} &\displaystyle = 
\iiint_{\hat{E}}  %triple
\left( 
-L_k\frac{\partial L_i}{\partial \varphi_y}
\right) \vert J \vert d\hat{V} \\ \\
& \displaystyle \simeq
\sum_{g=1}^3  W_g \left( 
  -L_k(g)\left.\frac{\partial L_i}{\partial \varphi_y}\right|_g
\right) \vert J_g \vert \\
\end{array}
\end{equation*}
\begin{equation*}
\begin{array}{c l}
\displaystyle
K_{3i,3j-2} &\displaystyle = 
\iiint_{\hat{E}}  %triple
\left( 
  \mu \frac{\partial L_j}{\partial \varphi_z} \frac{\partial L_i}{\partial \varphi_x} 
\right) \vert J \vert d\hat{V} \\ \\
& \displaystyle \simeq
\sum_{g=1}^3  W_g \left( 
  \mu \left.\frac{\partial L_j}{\partial \varphi_z}\right|_g \left.\frac{\partial L_i}{\partial \varphi_x} \right|_g
\right) \vert J_g \vert \\
\\
\displaystyle
K_{3i,3j-1} &\displaystyle = 
\iiint_{\hat{E}}  %triple
\left( 
  \mu \frac{\partial L_j}{\partial \varphi_z} \frac{\partial L_i}{\partial \varphi_y} 
\right) \vert J \vert d\hat{V} \\ \\
& \displaystyle \simeq
\sum_{g=1}^3  W_g \left( 
  \mu \left.\frac{\partial L_j}{\partial \varphi_z}\right|_g \left.\frac{\partial L_i}{\partial \varphi_y} \right|_g
\right) \vert J_g \vert \\
\\
\displaystyle
K_{3i,3j} &\displaystyle = 
\iiint_{\hat{E}}  %triple
\left( 
    \mu \frac{\partial L_j}{\partial \varphi_x} \frac{\partial L_i}{\partial \varphi_x}
 +  \mu \frac{\partial L_j}{\partial \varphi_y} \frac{\partial L_i}{\partial \varphi_y} 
 +2 \mu \frac{\partial L_j}{\partial \varphi_z} \frac{\partial L_i}{\partial \varphi_z}
\right) \vert J \vert d\hat{V} \\ \\
& \displaystyle \simeq
\sum_{g=1}^3  W_g \left( 
    \mu \left.\frac{\partial L_j}{\partial \varphi_x} \right|_g \left.\frac{\partial L_i}{\partial \varphi_x}\right|_g
 +  \mu \left.\frac{\partial L_j}{\partial \varphi_y}\right|_g \left.\frac{\partial L_i}{\partial \varphi_y}\right|_g 
+2 \mu \left.\frac{\partial L_j}{\partial \varphi_z}\right|_g \left.\frac{\partial L_i}{\partial \varphi_z}\right|_g
\right) \vert J_g \vert \\
\\
\displaystyle
K_{3i,k} &\displaystyle = 
\iiint_{\hat{E}}  %triple
\left( 
-L_k\frac{\partial L_i}{\partial \varphi_z}
\right) \vert J \vert d\hat{V} \\ \\
& \displaystyle \simeq
\sum_{g=1}^3  W_g \left( 
-L_k(g)\left.\frac{\partial L_i}{\partial \varphi_z}\right|_g
\right) \vert J_g \vert \\
\\
\displaystyle
K_{l,3j-2} &\displaystyle = 
\iiint_{\hat{E}}  %triple
\left( 
  -\frac{\partial L_j}{\partial \varphi_x} L_l
\right) \vert J \vert d\hat{V} \\ \\
& \displaystyle \simeq
\sum_{g=1}^3  W_g \left( 
  -\left.\frac{\partial L_j}{\partial \varphi_x} \right|_g L_l(g)
\right) \vert J_g \vert \\
\\
\displaystyle
K_{l,3j-1} &\displaystyle = 
\iiint_{\hat{E}}  %triple
\left( 
  -\frac{\partial L_j}{\partial \varphi_y}L_l
\right) \vert J \vert d\hat{V} \\ \\
& \displaystyle \simeq
\sum_{g=1}^3  W_g \left( 
  -\left.\frac{\partial L_j}{\partial \varphi_y}\right|_g L_l(g)
\right) \vert J_g \vert \\
\\
\displaystyle
K_{l,3j} &\displaystyle = 
\iiint_{\hat{E}}  %triple
\left( 
  -\frac{\partial L_j}{\partial \varphi_z} L_l
\right) \vert J \vert d\hat{V} \\ \\
& \displaystyle \simeq
\sum_{g=1}^3  W_g \left( 
  -\left.\frac{\partial L_j}{\partial \varphi_z}\right|_g L_l(g)
\right) \vert J_g \vert \\
\\
\displaystyle
K_{l,k} &\displaystyle = 
0 \\ \\
& \displaystyle \simeq
\sum_{g=1}^3 0 \\
\end{array}
\end{equation*}
\newpage
This elementary stiffness matrix is calculated with three matrices: $\displaystyle K1= \sum_{g=1}^3 [B]^T[D][B']$ as follows:
\\
\begin{equation*}
[B]=\left[\begin{array}{c c c c c c c}
B_1 & B_2 & B_3 & B_4 & B_5 & B_6 & B_b
\end{array}\right]
\quad \text{and} \quad
[B']=\left[\begin{array}{c c c c c c c}
B'_1 & B'_2 & B'_3 & B'_4 & B'_5 & B'_6 & B_b
\end{array}\right]
\end{equation*}
\\
with:
\begin{equation*}
[B_i]=\left[
\begin{array}{c c c c}
\displaystyle \left.\frac{\partial L_i}{\partial \varphi_x}\right|_g & 0 & 0 & 0\\
\\
0 & \displaystyle \left.\frac{\partial L_i}{\partial \varphi_y}\right|_g & 0 & 0\\
\\
0 & 0 & \displaystyle \left.\frac{\partial L_i}{\partial \varphi_z}\right|_g & 0\\
\\
\displaystyle \frac{1}{2}\left.\frac{\partial L_i}{\partial \varphi_y}\right|_g & \displaystyle \frac{1}{2}\left.\frac{\partial L_i}{\partial \varphi_x}\right|_g  & 0 & 0\\
\\
\displaystyle \frac{1}{2}\left.\frac{\partial L_i}{\partial \varphi_z}\right|_g & 0 & \displaystyle \frac{1}{2}\left.\frac{\partial L_i}{\partial \varphi_x}\right|_g  & 0\\
\\
0 & \displaystyle \frac{1}{2}\left.\frac{\partial L_i}{\partial \varphi_z}\right|_g  & \displaystyle \frac{1}{2}\left.\frac{\partial L_i}{\partial \varphi_y}\right|_g  & 0\\
\\
0 & 0 & 0 & L_i(g)\\
\\
\displaystyle \left.\frac{\partial L_i}{\partial \varphi_x}\right|_g  & \displaystyle \left.\frac{\partial L_i}{\partial \varphi_y}\right|_g  & \displaystyle \left.\frac{\partial L_i}{\partial \varphi_z}\right|_g & 0 \\
\end{array}
\right]\quad \text{and} \quad
[B_b]=\left[
\begin{array}{c c c}
\displaystyle \left.\frac{\partial L_b}{\partial \varphi_x}\right|_g & 0 & 0\\
\\
0 & \displaystyle \left.\frac{\partial L_b}{\partial \varphi_y}\right|_g & 0\\
\\
0 & 0 & \displaystyle \left.\frac{\partial L_b}{\partial \varphi_z}\right|_g \\
\\
\displaystyle \frac{1}{2}\left.\frac{\partial L_b}{\partial \varphi_y}\right|_g & \displaystyle \frac{1}{2}\left.\frac{\partial L_b}{\partial \varphi_x}\right|_g  & 0 \\
\\
\displaystyle \frac{1}{2}\left.\frac{\partial L_b}{\partial \varphi_z}\right|_g & 0 & \displaystyle \frac{1}{2}\left.\frac{\partial L_b}{\partial \varphi_x}\right|_g  \\
\\
0 & \displaystyle \frac{1}{2}\left.\frac{\partial L_b}{\partial \varphi_z}\right|_g  & \displaystyle \frac{1}{2}\left.\frac{\partial L_b}{\partial \varphi_y}\right|_g  \\
\\
0 & 0 & 0 \\
\\
\displaystyle \left.\frac{\partial L_b}{\partial \varphi_x}\right|_g  & \displaystyle \left.\frac{\partial L_b}{\partial \varphi_y}\right|_g  & \displaystyle \left.\frac{\partial L_b}{\partial \varphi_z}\right|_g \\
\end{array}
\right]
\end{equation*}\\
\\
\begin{equation*}
[B_i']=
\left[
\begin{array}{c c c c}
\displaystyle \quad \left.\frac{\partial L_i}{\partial \varphi_x}\right|_g & 0 &  0 & 0\\
\\
0 & \displaystyle \quad\left.\frac{\partial L_i}{\partial \varphi_y}\right|_g & 0& 0\\
\\
0 & 0 & \displaystyle \quad\left.\frac{\partial L_i}{\partial \varphi_z}\right|_g & 0\\
\\
\displaystyle \left.\frac{\partial L_i}{\partial \varphi_y}\right|_g & \displaystyle \left.\frac{\partial L_i}{\partial \varphi_x}\right|_g  & 0& 0\\
\\
\displaystyle \left.\frac{\partial L_i}{\partial \varphi_z}\right|_g  & 0 & \displaystyle \left.\frac{\partial L_i}{\partial \varphi_x}\right|_g & 0\\
\\
0 & \displaystyle \left.\frac{\partial L_i}{\partial \varphi_z}\right|_g & \displaystyle \left.\frac{\partial L_i}{\partial \varphi_y}\right|_g & 0\\
\\
\displaystyle \left.\frac{\partial L_i}{\partial \varphi_x}\right|_g  & \displaystyle \left.\frac{\partial L_i}{\partial \varphi_y}\right|_g  & \displaystyle \left.\frac{\partial L_i}{\partial \varphi_z}\right|_g & 0 \\
\\
0 & 0 & 0 & L_i(g)\\
\\
\end{array}
\right]\quad \text{and} \quad
[B_b']=\left[
\begin{array}{c c c c}
\displaystyle \quad\left.\frac{\partial L_b}{\partial \varphi_x}\right|_g & 0 & 0 \\
\\
0 & \displaystyle \quad\left.\frac{\partial L_b}{\partial \varphi_y}\right|_g & 0\\
\\
0 & 0 &\displaystyle \quad \left.\frac{\partial L_b}{\partial \varphi_z}\right|_g \\
\\
\displaystyle \left.\frac{\partial L_b}{\partial \varphi_y}\right|_g & \displaystyle \left.\frac{\partial L_b}{\partial \varphi_x}\right|_g  & 0\\
\\
\displaystyle \left.\frac{\partial L_b}{\partial \varphi_z}\right|_g  & 0 & \displaystyle \left.\frac{\partial L_b}{\partial \varphi_x}\right|_g\\
\\
0 & \displaystyle \left.\frac{\partial L_b}{\partial \varphi_z}\right|_g & \displaystyle \left.\frac{\partial L_b}{\partial \varphi_y}\right|_g\\
\\
\displaystyle \left.\frac{\partial L_b}{\partial \varphi_x}\right|_g  & \displaystyle \left.\frac{\partial L_b}{\partial \varphi_y}\right|_g  & \displaystyle \left.\frac{\partial L_b}{\partial \varphi_z}\right|_g \\
\\
0 & 0 & 0\\
\end{array}
\right]
\end{equation*}
and 
\begin{equation}
\displaystyle D=W_g \vert J_g \vert \left[
\begin{array}{c c c c c c c c}
\displaystyle 2\mu & 0 & 0 & 0 & 0 & 0 & 0 & 0\\
\\
0 & \displaystyle 2\mu & 0 & 0 & 0 & 0 & 0 & 0\\
\\
0 & 0 & \displaystyle 2\mu & 0 & 0 & 0 & 0 & 0\\
\\
0 & 0 & 0 & \displaystyle 2\mu & 0 & 0 & 0 & 0\\
\\
0 & 0 & 0 & 0 & \displaystyle 2\mu & 0 & 0 & 0\\
\\
0 & 0 & 0 & 0 & 0 & \displaystyle 2\mu & 0 & 0\\
\\
0 & 0 & 0 & 0 & 0 & 0 & \displaystyle -1 & 0\\
\\
0 & 0 & 0 & 0 & 0 & 0 & 0 & \displaystyle -1\\
\end{array}
\right] \end{equation} 
\\\emph{NB:} in $ISSM$ code, the factor $2$ in the $D$ matrix does not exist since the constitutive relation used is $\sigma'=\mu\varepsilon$ instead of $\sigma'=2\mu\varepsilon$. This changes the viscosity definition that must be multiplied by $2$. 

	\subsubsection{Basal drag}
As with Pattyn's, the elements are triangles and there are only 3 nodal functions to take into account. Therefore, the stiffness matrix that stands for basal drag is $9 \times 9$.\\
The basal drag stiffness matrix is such that:
\begin{center}
 $1 \leq i \leq 3$, $1 \leq j \leq 3$ and  $1 \leq k \leq 3$ 
\end{center}
\begin{equation}
\begin{array}{l c c}
\displaystyle
K_{3i-2,3j-2} &\displaystyle = &\displaystyle \iint_{E\cap \Gamma_b} \alpha^2 \phi_j\phi_i d\Gamma \\
\\
\displaystyle K_{3i-1,3j-1} &\displaystyle = &\displaystyle \iint_{E\cap \Gamma_b} \alpha^2 \phi_j\phi_i d\Gamma \\
\\
\displaystyle K_{3i-2,k} &\displaystyle = &\displaystyle \iint_{E\cap \Gamma_b} \phi_k\phi_i n_x d\Gamma \\
\\
\displaystyle K_{3i-1,k} &\displaystyle = &\displaystyle \iint_{E\cap \Gamma_b} \phi_k\phi_i n_y d\Gamma \\
\end{array}
\end{equation}
\\ 
The other terms are equal to zero.\\
\\       
Using the reference element $\hat{E}$ and the gaussian points, this matrix become:
        
        \begin{equation}
\begin{array}{l l l}
\displaystyle
K_{3i-2,3j-2} & = 
\displaystyle \iint_{\hat{E}\cap \hat{\Gamma_b}}  %double
\alpha^2 L_j(r,s) L_i(r,s)   \vert J \vert d\hat{S}
&
\displaystyle \simeq
\sum_{g=1}^3
W_g \alpha^2 L_j(r_g,s_g) L_i(r_g,s_g)   \vert J_g \vert
 \\
\\
\displaystyle
K_{3i-1,3j-1} & = 
\displaystyle \iint_{\hat{E}\cap \hat{\Gamma_b}}  %double
\alpha^2 L_j(r,s) L_i(r,s)  \vert J \vert d\hat{S} &
\displaystyle \simeq
\sum_{g=1}^3
W_g \alpha^2 L_j(r_g,s_g) L_i(r_g,s_g)   \vert J_g \vert 
 \\
 \\
 \displaystyle
K_{3i-2,k} & = 
\displaystyle \iint_{\hat{E}\cap \hat{\Gamma_b}}  %double
 L_k(r,s) L_i(r,s)  \vert J \vert  n_x d\hat{S} &
\displaystyle \simeq
\sum_{g=1}^3
W_g  L_k(r_g,s_g) L_i(r_g,s_g) \vert J_g \vert  n_x 
 \\
 \\
 \displaystyle
K_{3i-1,k} & = 
\displaystyle \iint_{\hat{E}\cap \hat{\Gamma_b}}  %double
 L_k(r,s) L_i(r,s)  \vert J \vert n_y d\hat{S} &
\displaystyle \simeq
\sum_{g=1}^3
W_g  L_k(r_g,s_g) L_i(r_g,s_g) \vert J_g \vert n_y
 \\
 \\
\end{array}
\end{equation}
\\     
This matrix is calculated with three matrices: $\displaystyle K2=\sum_{g=1}^3 [L]^T[D_{drag}][L']$ as follows:
\\
\begin{equation*}
[L]=\left[\begin{array}{c c c}
L_1 & L_2 & L_3 
\end{array}\right]
\quad \text{and} \quad
[L']=\left[\begin{array}{c c c}
L'_1 & L'_2 & L'_3
\end{array}\right]
\end{equation*}
\\
with:
\begin{equation*}
[L_i]=
\left[
\begin{array}{c c c c}
\displaystyle 
L_i(r_g,s_g) & 0 & 0 & 0 \\
\\
0 & L_i(r_g,s_g) & 0 & 0 \\
\\
L_i(r_g,s_g) & 0 & 0 & 0 \\
\\
0 & L_i(r_g,s_g) & 0 & 0 \\
\\
\end{array}
\right]\quad \text{and} \quad
[L'_i]=
\left[
\begin{array}{c c c c}
\displaystyle 
L_i(r_g,s_g) & 0 & 0 & 0  \\
\\
0 & L_i(r_g,s_g) & 0 & 0 \\
\\
0 & 0 & 0 & L_i(r_g,s_g) \\
\\
0 & 0 & 0 & L_i(r_g,s_g) \\
\end{array}
\right]
\end{equation*}
and 
\begin{equation}
\displaystyle D=W_g \vert J_g \vert \left[
\begin{array}{c c c c c}
\displaystyle \alpha^2 & 0 & 0 & 0 \\
\\
0 & \displaystyle \alpha^2 & 0 & 0 \\
\\
0 & 0 & \displaystyle n_x & 0 \\
\\
0 & 0 & 0 & \displaystyle n_y \\
\end{array}
\right] \end{equation} 


 \subsection{Elementary load vector}
To compute the elementary load vector, we first calculate the force due to the driving stress only, the water pressure only, and we then add these two terms.
			\subsubsection{Driving stress}

The elementary load vector due to driving stress has the following shape:

\begin{equation}
F1_{3i}= -\iiint_\Omega \rho g \phi_i d\Omega
\end{equation}
\\
Using the reference element $\hat{E}$ and the gaussian points, this vector become:

\begin{equation}
F1_{3i}= -
\iiint_{\hat{E}} %triple
\rho g L_i(r,s,\zeta) \vert J \vert d\hat{\Omega}
\simeq
\sum_{g=1}^6
 - W_g \rho g \L_i(r_g,s_g,\zeta_g)   \vert J_g \vert
\end{equation}

			\subsubsection{Ice front}
The load on the ice front involves only the nodes on the ice/sea interface. As with basal drag, only surface integrals are required. The elements are quadrangle (See section\ref{RE2D2}). The load on the ice front have the following shape:

\begin{equation}
\begin{array}{l}
\displaystyle
F2_{3i-2}=\iint_{E \cap \Gamma_i} F_in_x\phi_i dS\\
\\
\displaystyle
F2_{3i-1}=\iint_{E \cap\Gamma_i} F_in_y\phi_i dS\\
\\
\displaystyle
F2_{3i}=\iint_{E \cap\Gamma_i} F_in_z\phi_i dS
\end{array}
\end{equation}
\\
Using the reference element $\hat{E}$ and the gaussian points, this vector become:

\begin{equation}
\begin{array}{l l l}
\displaystyle
F2_{3i-2} & \displaystyle =\iint_{\hat{E} \hat{\cup\Gamma_i}} \hat{F_i}n_x L_i \vert J \vert  d\hat{S}
&
\displaystyle \simeq
\sum_{g=1}^4
W_g \rho_w g \min\left( 0,z\right) n_x L_i(r_g,s_g,\zeta_g) \vert J_g \vert \\
\\
\displaystyle
F2_{3i-1} & \displaystyle =\iint_{\hat{E} \hat{\cup\Gamma_i}} \hat{F_i}n_y L_i \vert J \vert d\hat{S}
&
\displaystyle \simeq
\sum_{g=1}^4
W_g \rho_w g \min\left( 0,z\right) n_y L_i(r_g,s_g,\zeta_g) \vert J_g \vert \\
\\
\displaystyle
F2_{3i} & \displaystyle =\iint_{\hat{E} \hat{\cup\Gamma_i}} \hat{F_i}n_z L_i \vert J \vert d\hat{S}
&
\displaystyle \simeq
\sum_{g=1}^4
W_g \rho_w g \min\left( 0,z\right)n_z L_i(r_g,s_g,\zeta_g) \vert J_g \vert
\end{array}
\end{equation}

			\subsubsection{Ice/water interface}
The load on the ice/water interface involves only the nodes at the base on the iceshelf. As with basal drag and ice front, only surface integrals are required. The elements are triangles. The load on the ice shelf base have the following shape:

\begin{equation}
\begin{array}{l}
\displaystyle
F3_{3i-2}=\iint_{E \cap \Gamma_w} F_wn_x\phi_i dS\\
\\
\displaystyle
F3_{3i-1}=\iint_{E \cap\Gamma_w} F_wn_y\phi_i dS\\
\\
\displaystyle
F3_{3i}=\iint_{E \cap\Gamma_w} F_wn_z\phi_i dS
\end{array}
\end{equation}
\\
Using the reference element $\hat{E}$ and the gaussian points, this vector become:

\begin{equation}
\begin{array}{l l l}
\displaystyle
F3_{2i-1} & \displaystyle =\iint_{\hat{E} \hat{\cup\Gamma_w}} \hat{F_w} n_x L_i \vert J \vert  d\hat{S}
&
\displaystyle \simeq
\sum_{g=1}^3
W_g \rho_w g b(r_g,s_g)  n_x L_i(r_g,s_g) \vert J_g \vert \\
\\
\displaystyle
F3_{2i} & \displaystyle =\iint_{\hat{E} \hat{\cup\Gamma_w}} \hat{F_w} n_y L_i \vert J \vert d\hat{S}
&
\displaystyle \simeq
\sum_{g=1}^3
W_g \rho_w g b(r_g,s_g) n_y L_i(r_g,s_g) \vert J_g \vert \\
\\
\displaystyle
F3_{2i} & \displaystyle =\iint_{\hat{E} \hat{\cup\Gamma_w}} \hat{F_w} n_y L_i \vert J \vert d\hat{S}
&
\displaystyle \simeq
\sum_{g=1}^3
W_g  \rho_w g b(r_g,s_g)  n_y L_i(r_g,s_g) \vert J_g \vert 
\end{array}
\end{equation}
\newpage

	\subsection{Collapsing of the seventh grid}
In order to use the same mesh for all the 3d models, we have to get rid of the grid located on the middle of the pentahedron. To do so, we have to collapse this grid and reduce the elementary matrix and load vector to the first six grids. \\
\\
The elementary equation before collapsing is:

\begin{equation}
\left[\begin{array}{c c c|c}
&&&\\
&K_{ii}&&K_{ib}\\
&&&\\
\hline
&K_{bi}&&K_{bb}
\end{array}\right]
\left[\begin{array}{c}
\\
W_{i}\\
\\
\hline
W_{b}
\end{array}\right]
=
\left[\begin{array}{c}
\\
F_{i}\\
\\
\hline
F_{b}
\end{array}\right]
\end{equation}
\\
where index $b$ relates to the seventh grid and index $i$ refers to the first six grids. $W$ contains all the unknows of the element, ie $u$, $v$, $w$, and $p$. So that $W_{i}$ has 24 components and $W_{b}$ has 3 components (there is no pressure on the seventh grid).\\
\\
We separate this system of equations in two parts as follows:

\begin{equation}
\left\{\begin{array}{c}
K_{ii}W_i+K_{ib}W_b=F_i\\
\\
K_{bi}W_i+K_{bb}W_b=F_b
\end{array}\right.
\end{equation}
\\
The second equation gives us $W_b=K_{bb}^{-1}\left(F_b-K_{bi}W_i\right)$ so that we can replace $W_b$ on the first equation. We now have a linear system on the first six grids. So we do solve the system on these six grids and use the same mesh as in the other 3d computations.\\
\\
The system to solve becomes:

\begin{equation}
\begin{array}{|c|}
\hline 
\\
\displaystyle \left(K_{ii}-K_{ib}K_{bb}^{-1}K_{bi}\right)W_i=F_i-K_{ib}K_{bb}^{-1}F_b\\
\\
\hline
\end{array}
\end{equation}

\newpage
\chapter{Thermal Model Finite Element Formulation}
The thermal equation (\ref{thermalequation}) involves a transient term $\dfrac{\partial T}{\partial t}$. This term can be neglected if the glacier is considered in a steady state. If it is not the case, this term must be taken into account and finite differences time domain scheme is required.
\section{Steady state}

    \subsection{Geometry and notations}
 
The geometry is exactly the same as in the 3d models. We adopt the following notations:
\begin{itemize}
        \item[--] $\Omega$ is the open surface that constitutes the entire glacier system
        \item[--] $\partial\Omega$ are points located at the boundary
        \item[--] $\Gamma_b$ are points at the interface between glacier and bedrock (Ice/Till interface $z=b$)
        \item[--] $\Gamma_w$ are points at the interface between glacier and water.
\end{itemize}

        \subsection{Equations}
        
For a steady state, one can neglect $\dfrac{\partial T}{\partial t}$. Given this assumption, the thermal equation (\ref{thermalequation}) is reduced to:

\begin{equation}
u\dfrac{\partial T}{\partial x} +v\dfrac{\partial T}{\partial y}  +w\dfrac{\partial T}{\partial z} = \dfrac{k}{ \rho c }\left( \dfrac{\partial^2 T}{\partial x^2}+\dfrac{\partial^2 T}{\partial y^2}+\dfrac{\partial^2 T}{\partial z^2}\right)  +\dfrac{\Phi}{ \rho c }
\end{equation}
\\
For the temperature computation, the melting is not taken into account. When the pressure melting point is reached, one will use penalty method to constrain this point to this temperature. Thus, the boundary conditions are limited to:
an imposed flux (Neumann) at the base of the grouded part, an imposed temperature (Dirichlet) on the lower surface of the floating part. The sides of the domain $\Gamma_u \cup \Gamma_i$ are treated as zero-flux surfaces.
It is more convenient to consider the imposed temperatures as nill. At the end of the process, the temperature field will be updated to take these
constraints into account.

\begin{equation}
\left\{ \begin{array}{l l l }
\text{Icesheet  base } \Gamma_b: & 
\displaystyle \left. k \left( \overrightarrow{grad}\;T\right) \right| _b.\overrightarrow{n} =  G + \overrightarrow{\tau}_b . \overrightarrow{u}_b\\
\\
\text{Iceshelf  base } \Gamma_w: & 
\displaystyle k\left. \left( \overrightarrow{grad}\;T\right) \right|_b.\overrightarrow{n} = -\rho_w c_{pM}\gamma\left(T_b-T_{pmp} \right) \\
\\
\text{Other  borders } \Gamma_u\cup \Gamma_i:& \displaystyle  \left( \overrightarrow{grad}\;T\right).\overrightarrow{n}=0
\end{array} \right.
\end{equation}
        \subsection{Weak Formulation}

we  write the weak formulation to solve the previous equation
using finite element. One defines an admissible thermal field $\theta$ such that:

\begin{equation}
\theta(x,y,z)\in\lbrace \left( H^{1}(\Omega\cup\partial\Omega) \right) \quad \vert \quad \theta(x,y,z)=0\qquad (x,y,z)\in \partial \Omega \setminus \Gamma_b\rbrace
\end{equation}
\\
For any virtual field as described above:

\begin{equation}
\iiint_\Omega 
\left[
u\dfrac{\partial T}{\partial x} +v\dfrac{\partial T}{\partial y}  +w\dfrac{\partial T}{\partial z} - \dfrac{k}{ \rho c } \left( \dfrac{\partial^2 T}{\partial x^2}+\dfrac{\partial^2 T}{\partial y^2}+\dfrac{\partial^2 T}{\partial z^2}\right) - \dfrac{\Phi}{ \rho c }
\right] \theta  d\Omega =0
\end{equation}
\\
One intergrates by parts the conduction term in order to use the boundary conditions:

\begin{multline}
\iiint_\Omega 
\dfrac{k}{ \rho c } \left(\dfrac{\partial T}{\partial x}\dfrac{\partial \theta}{\partial x}+\dfrac{\partial T}{\partial y}\dfrac{\partial \theta}{\partial y} +\dfrac{\partial T}{\partial z}\dfrac{\partial \theta}{\partial z}\right) 
d\Omega
=
\iiint_\Omega 
\left[ 
-  u\dfrac{\partial T}{\partial x} -v\dfrac{\partial T}{\partial y}  -w\dfrac{\partial T}{\partial z} + \dfrac{\Phi}{ \rho c }
\right] \theta  d\Omega\\
\\
+
\iint_{\partial\Omega }
\dfrac{k}{ \rho c } \left(\dfrac{\partial T}{\partial x}\theta n_x+\dfrac{\partial T}{\partial y}\theta n_y+ \dfrac{\partial T}{\partial z}\theta n_z\right) 
dS
\end{multline}
\\
Where $\overrightarrow{n}=( n_x, n_y, n_z)$ is the unit normal vector pointing outward from the glacier. Since $\theta$ is admissible, the last integrale is nill except on $\Gamma_b$, where one can use the boundary condition:

\begin{multline}
\iiint_\Omega 
\dfrac{k}{ \rho c } \left(\dfrac{\partial T}{\partial x}\dfrac{\partial \theta}{\partial x}+\dfrac{\partial T}{\partial y}\dfrac{\partial \theta}{\partial y} +\dfrac{\partial T}{\partial z}\dfrac{\partial \theta}{\partial z}\right) 
d\Omega
=
\iiint_\Omega
\left[  
-  u\dfrac{\partial T}{\partial x} -v\dfrac{\partial T}{\partial y}  -w\dfrac{\partial T}{\partial z}+ \dfrac{\Phi}{ \rho c }
\right] \theta  d\Omega \\
\\
+\iint_{\Gamma_w }\dfrac{\rho_w c_{pM}\gamma}{ \rho c } \left(T_{pmp} -T\right) \theta dS
+
\iint_{\Gamma_b }
\dfrac{1}{ \rho c } \left(G + \overrightarrow{\tau}_b . \overrightarrow{u}_b \right) \theta
dS
\end{multline}
\\
By rearranging terms:

\begin{multline}
\iiint_\Omega 
\dfrac{k}{ \rho c }\left(\dfrac{\partial T}{\partial x}\dfrac{\partial \theta}{\partial x}+\dfrac{\partial T}{\partial y}\dfrac{\partial \theta}{\partial y} +\dfrac{\partial T}{\partial z}\dfrac{\partial \theta}{\partial z}\right) 
d\Omega
+
\iiint_\Omega
u\dfrac{\partial T}{\partial x}\theta +v\dfrac{\partial T}{\partial y}\theta  +w\dfrac{\partial T}{\partial z}\theta
d\Omega \\
\\
=
\iiint_\Omega
\dfrac{\Phi}{ \rho c }
\theta  d\Omega 
+\iint_{\Gamma_w }\dfrac{\rho_w c_{pM}\gamma}{ \rho c } \left(T_{pmp} -T\right) \theta dS
+
\iint_{\Gamma_b }
\dfrac{1}{ \rho c } \left(G + \overrightarrow{\tau}_b . \overrightarrow{u}_b \right) \theta
dS
\end{multline}
\\


        \subsection{Finite element discretisation, Galerkin method}

The domain is meshed using pentahedrons. There are a $nel$ elements and $nods$ grids. We use the nodal functions of each grid, which are continuous on the domain and affine on each element.
We now project the unknown on the nodal functions:
\begin{center}
 $(\phi_i)_{1\leq i\leq nods}$
\end{center}
\begin{equation}
T\left( x,y,z\right) = \sum_{i=1}^{nods}T_{i}\theta_{i}\left( x,y,z\right) \\
\end{equation}
\\
We build a vector $T$ that holds all the unknowns:

\begin{equation}
T=\left[ \begin{array}{c}
T_{1}\\
...\\
T_{nods}
                 \end{array} \right]
\end{equation}
\\
With this new field, we have the following equations:
\begin{center}
 $\forall 1 \leq i \leq nods$
\end{center}
\begin{multline}
\sum_{j=1}^{nods}
\iiint_\Omega 
\dfrac{k}{ \rho c }\left(\dfrac{\partial T_j\theta_j}{\partial x}\dfrac{\partial \theta_i}{\partial x}+\dfrac{\partial T_j\theta_j}{\partial y}\dfrac{\partial \theta_i}{\partial y}+  \dfrac{\partial T_j\theta_j}{\partial z}\dfrac{\partial \theta_i}{\partial z}\right) 
d\Omega
+
\iiint_\Omega
u\dfrac{\partial T_j\theta_j}{\partial x}\theta_i +v\dfrac{\partial T_j\theta_j}{\partial y}\theta_i  +w\dfrac{\partial T_j\theta_j}{\partial z}\theta_i
d\Omega\\
\\
=
\iiint_\Omega 
 \dfrac{\Phi}{ \rho c }
\theta_i  d\Omega 
+
\iint_{\Gamma_w }
\dfrac{\rho_w c_{pM}\gamma}{ \rho c } \left(T_{pmp} -\sum_{j=1}^{nods}T_j \theta_j\right)\theta_i
dS
+
\iint_{\Gamma_b }
\dfrac{1}{ \rho c } \left(G + \overrightarrow{\tau}_b . \overrightarrow{u}_b \right) \theta_i
dS
\end{multline}
\\
One can extract $T_j$:

\begin{multline*}
\sum_{j=1}^{nods}\left[ 
\iiint_\Omega 
\dfrac{k}{ \rho c }\left(\dfrac{\partial \theta_j}{\partial x}\dfrac{\partial \theta_i}{\partial x}+\dfrac{\partial \theta_j}{\partial y}\dfrac{\partial \theta_i}{\partial y}+ \dfrac{\partial \theta_j}{\partial z}\dfrac{\partial \theta_i}{\partial z}\right) 
d\Omega \right.  \\
\\
\left. 
+
\iiint_\Omega
u\dfrac{\partial \theta_j}{\partial x}\theta_i +v\dfrac{\partial \theta_j}{\partial y}\theta_i  +w\dfrac{\partial \theta_j}{\partial z}\theta_i
d\Omega
+
\iint_{\Gamma_w }
\dfrac{\rho_w c_{pM}\gamma}{ \rho c } \theta_j\theta_i
dS \right] T_j\\
\\
=
\iiint_\Omega
\dfrac{\Phi}{ \rho c }
\theta_i  d\Omega 
+
\iint_{\Gamma_w }
\dfrac{\rho_w c_{pM}\gamma}{ \rho c }T_{pmp}\theta_i
dS
+
\iint_{\Gamma_b }
\dfrac{1}{ \rho c } \left(G + \overrightarrow{\tau}_b . \overrightarrow{u}_b\right) \theta_i
dS
\end{multline*}
\\
We see the stiffness matrix $K$ and load vector $F$ appearing, so that the previous equations can be written as a system matrix :

\begin{equation}
\left[ K \right] T =F 
\label{FET}
\end{equation} 
\\
We use the following index:

\begin{equation}
\left[
\begin{array}{c c c} %K
  & \vdots &\\
 \cdots & K_{ij} & \cdots\\
  & \vdots &\\
\end{array}
\right]
\left[
\begin{array}{c} %U
\vdots \\
T_i\\
\vdots\\
\end{array}
\right]
=
\left[
\begin{array}{c} %F
\vdots \\
F_{i}\\
\vdots\\
\end{array}
\right]
\end{equation}
\\
And  we have the following expressions for the stiffness matrix and the load vector :

\begin{equation}
\begin{array}{l c l}
\displaystyle
K_{i,j} & = &\displaystyle  
\iiint_\Omega 
\dfrac{k}{ \rho c }\left(\dfrac{\partial \theta_j}{\partial x}\dfrac{\partial \theta_i}{\partial x}+\dfrac{\partial \theta_j}{\partial y}\dfrac{\partial \theta_i}{\partial y}+ \dfrac{\partial \theta_j}{\partial z}\dfrac{\partial \theta_i}{\partial z}\right) 
d\Omega\\
\\
&& \displaystyle
+
\iiint_\Omega
u\dfrac{\partial \theta_j}{\partial x}\theta_i +v\dfrac{\partial \theta_j}{\partial y}\theta_i  +w\dfrac{\partial \theta_j}{\partial z}\theta_i
d\Omega +
\iint_{\Gamma_w }
\dfrac{\rho_w c_{pM}\gamma}{ \rho c } \theta_j\theta_i
dS
\\
\\
F_{i} &=&\displaystyle
\iiint_\Omega
\dfrac{\Phi}{ \rho c }
\theta_i  d\Omega 
+
\iint_{\Gamma_w }
\dfrac{\rho_w c_{pM}\gamma}{ \rho c } T_{pmp}\theta_i
dS\\
\\
&& \displaystyle
+
\iint_{\Gamma_b }
\dfrac{1}{ \rho c } \left(G + \overrightarrow{\tau}_b . \overrightarrow{u}_b \right) \theta_i
dS\\
\end{array}
\end{equation}

        \subsection{Decomposition over the elements and reference element}
See same section in Pattyn's Model.
One element $E$ gives 6 equations: we can take 6 nodal functions for $\theta_i(x,y,z)$ (the nodal functions corresponding to the vertexes of $E$, which is an pentahedron), each $\theta_i$ gives 1 equation. Therefore, an elementary stiffness matrix $K_E$ will be $6 \times 6$, and the elementary load vector will be of size $6$.
\newpage
        \subsection{Elementary stiffness matrix}
The elementary stiffness matrix is divided into 3 matrices: one conduction stiffness matrix, one advection stiffness matrix, and one ocean/ice heat exchange stiffness matrix.

   	     \subsubsection{Conduction stiffness matrix}
This matrix has the following shape:

\begin{center}
 $1 \leq i \leq 6$ and  $1 \leq j \leq 6$ 
\end{center}
\begin{equation}
K1_{i,j}  = 
\iiint_E
\dfrac{k}{ \rho c }\left(\dfrac{\partial \theta_j}{\partial x}\dfrac{\partial \theta_i}{\partial x}+\dfrac{\partial \theta_j}{\partial y}\dfrac{\partial \theta_i}{\partial y}+ \dfrac{\partial \theta_j}{\partial z}\dfrac{\partial \theta_i}{\partial z}\right)
dV
\end{equation}  
\\
Using the reference element $\hat{E}$ and the gaussian points, this matrix becomes:
\begin{center}
 $1 \leq i \leq 6$ and  $1 \leq j \leq 6$ 
\end{center}
\begin{equation*}
\begin{array}{l c l}
K1_{i,j} &=& \displaystyle 
\iiint_{\hat{E}}  %triple
  \left( 
\dfrac{k}{ \rho c }\left(\dfrac{\partial L_j}{\partial \varphi_x}\dfrac{\partial L_i}{\partial \varphi_x}
+\dfrac{\partial L_j}{\partial \varphi_y}\dfrac{\partial L_i}{\partial \varphi_y}
+ \dfrac{\partial L_j}{\partial \varphi_z}\dfrac{\partial L_i}{\partial \varphi_z}\right) 
  \right) \vert J \vert d\hat{V}  \\
  \\
  & \simeq &  \displaystyle 
\sum_{g=1}^6  W_g \left( 
\dfrac{k}{ \rho c }\left( \left.\dfrac{\partial L_j}{\partial \varphi_x} \right|_g \left.\dfrac{\partial L_i}{\partial \varphi_x} \right|_g
+ \left.\dfrac{\partial L_j}{\partial \varphi_y} \right|_g \left.\dfrac{\partial L_i}{\partial \varphi_y} \right|_g
+ \left.\dfrac{\partial L_j}{\partial \varphi_z} \right|_g \left.\dfrac{\partial L_i}{\partial \varphi_z} \right|_g\right) 
\right) \vert J_g \vert
\end{array}
\end{equation*}

This elementary stiffness matrix is calculated with three matrices: $\displaystyle K1= \sum_{g=1}^6 [B]^T[D][B]$ as follows:
\\
\begin{equation}
[B]=\left[\begin{array}{c c c c c c}
B_1 & B_2 & B_3 & B_4 & B_5 & B_6
\end{array}\right]
\end{equation}
\\
with:

\begin{equation}
B_i=\left[\begin{array}{c}
\left.\dfrac{\partial L_i}{\partial \varphi_x}\right|_g\\
\\
\left.\dfrac{\partial L_i}{\partial \varphi_y}\right|_g\\
\\
\left.\dfrac{\partial L_i}{\partial \varphi_z}\right|_g 
\end{array}\right]
\end{equation}
\\
and 
\begin{equation}
\displaystyle D=  W_g \vert J_g \vert \dfrac{k}{ \rho c } \end{equation} 

   	     \subsubsection{Advection stiffness matrix}
This matrix has the following shape:

\begin{center}
 $1 \leq i \leq 6$ and  $1 \leq j \leq 6$ 
\end{center}
\begin{equation}
K2_{i,j}  = 
\iiint_E
u\dfrac{\partial \theta_j}{\partial x}\theta_i +v\dfrac{\partial \theta_j}{\partial y}\theta_i  +w\dfrac{\partial \theta_j}{\partial z}\theta_i
dV
\end{equation}  
\\
Using the reference element $\hat{E}$ and the gaussian points, this matrix becomes:
\begin{center}
 $1 \leq i \leq 6$ and  $1 \leq j \leq 6$ 
\end{center}
\begin{equation}
\begin{array}{r c l}
K2_{i,j} & = & \displaystyle
\iiint_{\hat{E}}  %triple
  \left( 
u\dfrac{\partial L_j}{\partial \varphi_x}L_i +v\dfrac{\partial L_j}{\partial \varphi_y}L_i  +w\dfrac{\partial L_j}{\partial \varphi_z}L_i
  \right) \vert J \vert d\hat{V}  \\
  \\
  & \simeq & \displaystyle
\sum_{g=1}^6   W_g \left( 
u\left(g \right) \left.\dfrac{\partial L_j}{\partial \varphi_x}\right|_g L_i\left(g \right) +v\left(g \right)\left.\dfrac{\partial L_j}{\partial \varphi_y}\right|_g  L_i \left(g \right) +w\left(g \right)\left.\dfrac{\partial L_j}{\partial \varphi_z}\right|_g L_i\left(g \right)
\right) \vert J_g \vert
\end{array}
\end{equation}
This elementary stiffness matrix is calculated with three matrices: $\displaystyle K2= \sum_{g=1}^6 [B]^T[D][B']$ as follows:

\begin{equation}
[B]=\left[\begin{array}{c c c c c c}
B_1 & B_2 & B_3 & B_4 & B_5 & B_6
\end{array}\right]
\end{equation}
\\
with:

\begin{equation}
B_i=\left[\begin{array}{c}
L_i(g)\\
\\
L_i(g)\\
\\
L_i(g)
\end{array}\right]
\quad
B_i'=\left[\begin{array}{c}
\left.\dfrac{\partial L_i}{\partial \varphi_x}\right|_g\\
\\
\left.\dfrac{\partial L_i}{\partial \varphi_y}\right|_g\\
\\
\left.\dfrac{\partial L_i}{\partial \varphi_z}\right|_g\\
\end{array}\right]
\end{equation}
\\
and 
\begin{equation}
\displaystyle D= W_g \vert J_g \vert
\left[\begin{array}{c c c}
\displaystyle \sum_{k=1}^6 u_k L_k(g) & 0 & 0 \\
0 & \displaystyle \sum_{k=1}^6 v_k L_k(g)  & 0\\
0 & 0 & \displaystyle \sum_{k=1}^6 w_k L_k(g) 
\end{array}\right]  \end{equation} 

			\subsubsection{Ocean/ice heat exchange}

This elementary stiffness has the following shape:

\begin{center}
 $1 \leq i \leq 3$ and  $1 \leq j \leq 3$ 
\end{center}
\begin{equation}
K3_{i,j} = 
\iint_{\Gamma_w \cap E }
\dfrac{\rho_w c_{pM}\gamma}{ \rho c }\theta_j\theta_i
dS
\end{equation} 
\\
Using the reference element $\hat{E}$ and the gaussian points, this vector becomes:
\begin{center}
 $1 \leq i \leq 6$
\end{center}
\begin{equation}
\begin{array}{r c l}
K3_{i,j} & = & \displaystyle
\iint_{\Gamma_w \cap \hat{E} }
\dfrac{\rho_w c_{pM}\gamma}{ \rho c }L_j L_i
\vert J \vert d\hat{S}\\
\\
& \simeq & \displaystyle
\sum_{g=1}^3  W_g \vert J_g \vert 
\dfrac{\rho_w c_{pM}\gamma}{ \rho c }L_j(g)L_i(g)
\end{array}
\end{equation}
This elementary stiffness matrix is calculated with three matrices: $\displaystyle K3= \sum_{g=1}^3 [B]^T[D][B]$ as follows:

\begin{equation}
[B]=\left[\begin{array}{c c c}
B_1 & B_2 & B_3 
\end{array}\right] \quad \text{and} \quad D= W_g \vert J_g \vert \dfrac{\rho_w c_{pM}\gamma}{ \rho c }
\end{equation}
with:
\begin{equation}
B_i=L_i(g)
\end{equation}

\newpage
 \subsection{Elementary load vector}

			\subsubsection{Deformational heating}
			
This elementary load vector has the following shape:

\begin{center}
 $1 \leq i \leq 6$
\end{center}
\begin{equation}
F_{i} = 
\iiint_E
\dfrac{\Phi}{ \rho c }
\theta_i  d\Omega 
dV
\end{equation} 
\\
Using the reference element $\hat{E}$ and the gaussian points, this vector becomes:
\begin{center}
 $1 \leq i \leq 6$
\end{center}
\begin{equation}
F_{i} = 
\iiint_{\hat{E}}  %triple
\dfrac{\Phi}{ \rho c } 
 L_i  \vert J \vert d\hat{V}
 = 
\sum_{g=1}^6  W_g \vert J_g \vert 
\dfrac{\Phi (g)}{ \rho c } 
L_i(g)
\end{equation}


			\subsubsection{Basal heating}

This elementary load vector has the following shape:

\begin{center}
 $1 \leq i \leq 6$
\end{center}
\begin{equation}
F_{i} = 
\iint_{\Gamma_b \cap E }
\dfrac{1}{ \rho c } \left( G + \overrightarrow{\tau}_b . \overrightarrow{u}_b \right) \theta_i
dS
\end{equation} 
\\
Using the reference element $\hat{E}$ and the gaussian points, this vector becomes:
\begin{center}
 $1 \leq i \leq 6$
\end{center}
\begin{equation}
\begin{array}{r c l}
F_{i} & = & \displaystyle
\iint_{\Gamma_b \cap \hat{E} }
\dfrac{1}{ \rho c } \left( G + \overrightarrow{\tau}_b . \overrightarrow{u}_b \right) L_i
\vert J \vert d\hat{S}\\
\\
& \simeq & \displaystyle
\sum_{g=1}^3  W_g \vert J_g \vert 
\dfrac{1}{ \rho c } \left( G(g) + \overrightarrow{\tau}_b(g) . \overrightarrow{u}_b(g)\right) L_i(g)
\end{array}
\end{equation}
Only the nodal functions assigned to the nodes on $\Gamma_b$ are involved.


			\subsubsection{Ocean/ice heat exchange}

This elementary load vector has the following shape:

\begin{center}
 $1 \leq i \leq 6$
\end{center}
\begin{equation}
F_{i} = 
\iint_{\Gamma_w \cap E }
\dfrac{\rho_w c_{pM}\gamma}{ \rho c }T_{pmp}\theta_i
dS
\end{equation} 
\\
Using the reference element $\hat{E}$ and the gaussian points, this vector becomes:
\begin{center}
 $1 \leq i \leq 6$
\end{center}
\begin{equation}
\begin{array}{r c l}
F_{i} & = & \displaystyle
\iint_{\Gamma_w \cap \hat{E} }
\dfrac{\rho_w c_{pM}\gamma}{ \rho c }T_{pmp} L_i
\vert J \vert d\hat{S}\\
\\
& \simeq & \displaystyle
\sum_{g=1}^3  W_g \vert J_g \vert 
\dfrac{\rho_w c_{pM}\gamma}{ \rho c }T_{pmp}(g)L_i(g)
\end{array}
\end{equation}
Only the nodal functions assigned to the nodes on $\Gamma_w$ are involved.

\newpage
\section{Transient}

        \subsection{Equations}
        
This time, one cannot neglect $\dfrac{\partial T}{\partial t}$. The equation is the same as in the first chapter (\ref{thermalequation}):

\begin{equation}
\dfrac{\partial T}{\partial t}= -\left( u\dfrac{\partial T}{\partial x} +v\dfrac{\partial T}{\partial y}  +w\dfrac{\partial T}{\partial z} \right)+ \dfrac{k}{ \rho c }\left( \dfrac{\partial^2 T}{\partial x^2}+\dfrac{\partial^2 T}{\partial y^2}+\dfrac{\partial^2 T}{\partial z^2}\right)  +\dfrac{\Phi}{ \rho c }
\end{equation}
\\
The boundary conditions are the same as in the previous chapter.

        \subsection{Weak Formulation}

The weak formulation is the same as in the previoous chapter with the transient term:

\begin{multline}
\iiint_\Omega 
\dfrac{k}{ \rho c }\left(\dfrac{\partial T}{\partial x}\dfrac{\partial \theta}{\partial x}+\dfrac{\partial T}{\partial y}\dfrac{\partial \theta}{\partial y} +\dfrac{\partial T}{\partial z}\dfrac{\partial \theta}{\partial z}\right) 
d\Omega
+
\iiint_\Omega
u\dfrac{\partial T}{\partial x}\theta +v\dfrac{\partial T}{\partial y}\theta  +w\dfrac{\partial T}{\partial z}\theta
d\Omega \\
\\
=
\iiint_\Omega
\left(  
-\dfrac{\partial T}{\partial t} + \dfrac{\Phi}{ \rho c }
\right) \theta  d\Omega 
+
\iint_{\Gamma_b }
\dfrac{1}{ \rho c } \left(G + \overrightarrow{\tau}_b . \overrightarrow{u}_b \right) \theta
dS
\end{multline}

        \subsection{Finite difference scheme}
To evaluate the transient term, one uses a finite differences time domain scheme. For a given time step $i$, the transient term is computed implicitly\footnote{an implicit method is much more stable for this kind of equation} as follow:

\begin{equation}
\left. \dfrac{\partial T}{\partial t}\right|_{i} =\dfrac{T_{i}-T_{i-1}}{\Delta t }
\end{equation}
\\
Where $\Delta t$ is the time difference between $t_{i}$ and $t_{i-1}$. The weak formuation becomes:

\begin{multline}
\iiint_\Omega 
\dfrac{k}{ \rho c }\left(\dfrac{\partial T_{i}}{\partial x}\dfrac{\partial \theta}{\partial x}+\dfrac{\partial T_{i}}{\partial y}\dfrac{\partial \theta}{\partial y} +\dfrac{\partial T_{i}}{\partial z}\dfrac{\partial \theta}{\partial z}\right) 
d\Omega
+
\iiint_\Omega
u\dfrac{\partial T_{i}}{\partial x}\theta +v\dfrac{\partial T_{i}}{\partial y}\theta  +w\dfrac{\partial T_{i}}{\partial z}\theta
d\Omega \\
\\
=
\iiint_\Omega
\left(  
-\dfrac{T_{i}-T_{i-1}}{\Delta t } + \dfrac{\Phi}{ \rho c }
\right) \theta  d\Omega 
+
\iint_{\Gamma_b }
\dfrac{1}{ \rho c } \left(G + \overrightarrow{\tau}_b . \overrightarrow{u}_b \right) \theta
dS
\end{multline}
\\
By rearranging terms:

\begin{multline}
\iiint_\Omega
T_{i}
\theta  d\Omega 
+
\Delta t \iiint_\Omega 
\dfrac{k}{ \rho c }\left(\dfrac{\partial T_{i}}{\partial x}\dfrac{\partial \theta}{\partial x}+\dfrac{\partial T_{i}}{\partial y}\dfrac{\partial \theta}{\partial y} +\dfrac{\partial T_{i}}{\partial z}\dfrac{\partial \theta}{\partial z}\right) 
d\Omega
+
\Delta t \iiint_\Omega
u\dfrac{\partial T_{i}}{\partial x}\theta +v\dfrac{\partial T_{i}}{\partial y}\theta  +w\dfrac{\partial T_{i}}{\partial z}\theta
d\Omega \\
\\
=
\iiint_\Omega 
T_{i-1}\theta  d\Omega 
+
\Delta t \iiint_\Omega
\dfrac{\Phi}{ \rho c }
\theta  d\Omega 
+
\Delta t \iint_{\Gamma_b }
\dfrac{1}{ \rho c } \left(G + \overrightarrow{\tau}_b . \overrightarrow{u}_b \right) \theta
dS
\end{multline}
\newpage
        \subsection{Elementary stiffness matrix}
The elementary stiffness matrix is very similar to the one of the steady state case: all the previous matrices are multiplied by $\Delta t$, and a transient term is added:

   	     \subsubsection{Conduction stiffness matrix}
This matrix has the following shape:

\begin{center}
 $1 \leq i \leq 6$ and  $1 \leq j \leq 6$ 
\end{center}
\begin{equation}
K1_{i,j}  = 
\Delta t\iiint_E
\dfrac{k}{ \rho c }\left(\dfrac{\partial \theta_j}{\partial x}\dfrac{\partial \theta_i}{\partial x}+\dfrac{\partial \theta_j}{\partial y}\dfrac{\partial \theta_i}{\partial y}+ \dfrac{\partial \theta_j}{\partial z}\dfrac{\partial \theta_i}{\partial z}\right)
dV
\end{equation}  
\\
Using the reference element $\hat{E}$ and the gaussian points, this matrix becomes:
\begin{center}
 $1 \leq i \leq 6$ and  $1 \leq j \leq 6$ 
\end{center}
\begin{equation*}
\begin{array}{l c l}
K1_{i,j} &=& \displaystyle 
\Delta t\iiint_{\hat{E}}  %triple
  \left( 
\dfrac{k}{ \rho c }\left(\dfrac{\partial L_j}{\partial \varphi_x}\dfrac{\partial L_i}{\partial \varphi_x}
+\dfrac{\partial L_j}{\partial \varphi_y}\dfrac{\partial L_i}{\partial \varphi_y}
+ \dfrac{\partial L_j}{\partial \varphi_z}\dfrac{\partial L_i}{\partial \varphi_z}\right) 
  \right) \vert J \vert d\hat{V}  \\
  \\
  & \simeq &  \displaystyle 
\sum_{g=1}^6  W_g \Delta t\left( 
\dfrac{k}{ \rho c }\left( \left.\dfrac{\partial L_j}{\partial \varphi_x} \right|_g \left.\dfrac{\partial L_i}{\partial \varphi_x} \right|_g
+ \left.\dfrac{\partial L_j}{\partial \varphi_y} \right|_g \left.\dfrac{\partial L_i}{\partial \varphi_y} \right|_g
+ \left.\dfrac{\partial L_j}{\partial \varphi_z} \right|_g \left.\dfrac{\partial L_i}{\partial \varphi_z} \right|_g\right) 
\right) \vert J_g \vert
\end{array}
\end{equation*}

This elementary stiffness matrix is calculated with three matrices: $\displaystyle K1= \sum_{g=1}^6 [B]^T[D][B]$ as follows:
\\
\begin{equation}
[B]=\left[\begin{array}{c c c c c c}
B_1 & B_2 & B_3 & B_4 & B_5 & B_6
\end{array}\right]
\end{equation}
\\
with:

\begin{equation}
B_i=\left[\begin{array}{c}
\left.\dfrac{\partial L_i}{\partial \varphi_x}\right|_g\\
\\
\left.\dfrac{\partial L_i}{\partial \varphi_y}\right|_g\\
\\
\left.\dfrac{\partial L_i}{\partial \varphi_z}\right|_g 
\end{array}\right]
\end{equation}
\\
and 
\begin{equation}
\displaystyle D=  W_g \vert J_g \vert \Delta t\dfrac{k}{ \rho c } \end{equation} 

   	     \subsubsection{Advection stiffness matrix}
This matrix has the following shape:

\begin{center}
 $1 \leq i \leq 6$ and  $1 \leq j \leq 6$ 
\end{center}
\begin{equation}
K2_{i,j}  = 
\Delta t\iiint_E
u\dfrac{\partial \theta_j}{\partial x}\theta_i +v\dfrac{\partial \theta_j}{\partial y}\theta_i  +w\dfrac{\partial \theta_j}{\partial z}\theta_i
dV
\end{equation}  
\\
Using the reference element $\hat{E}$ and the gaussian points, this matrix becomes:
\begin{center}
 $1 \leq i \leq 6$ and  $1 \leq j \leq 6$ 
\end{center}
\begin{equation}
\begin{array}{r c l}
K2_{i,j} & = & \displaystyle
\Delta t\iiint_{\hat{E}}  %triple
  \left( 
u\dfrac{\partial L_j}{\partial \varphi_x}L_i +v\dfrac{\partial L_j}{\partial \varphi_y}L_i  +w\dfrac{\partial L_j}{\partial \varphi_z}L_i
  \right) \vert J \vert d\hat{V}  \\
  \\
  & \simeq & \displaystyle
\sum_{g=1}^6   W_g \Delta t\left( 
u\left(g \right) \left.\dfrac{\partial L_j}{\partial \varphi_x}\right|_g L_i\left(g \right) +v\left(g \right)\left.\dfrac{\partial L_j}{\partial \varphi_y}\right|_g  L_i \left(g \right) +w\left(g \right)\left.\dfrac{\partial L_j}{\partial \varphi_z}\right|_g L_i\left(g \right)
\right) \vert J_g \vert
\end{array}
\end{equation}
\\
This elementary stiffness matrix is calculated with three matrices: $\displaystyle K2= \sum_{g=1}^6 [B]^T[D][B']$ as follows:

\begin{equation}
[B]=\left[\begin{array}{c c c c c c}
B_1 & B_2 & B_3 & B_4 & B_5 & B_6
\end{array}\right]
\end{equation}
\\
with:

\begin{equation}
B_i=\left[\begin{array}{c}
L_i(g)\\
\\
L_i(g)\\
\\
L_i(g)
\end{array}\right]
\quad
B_i'=\left[\begin{array}{c}
\left.\dfrac{\partial L_i}{\partial \varphi_x}\right|_g\\
\\
\left.\dfrac{\partial L_i}{\partial \varphi_y}\right|_g\\
\\
\left.\dfrac{\partial L_i}{\partial \varphi_z}\right|_g\\
\end{array}\right]
\end{equation}
\\
and 
\begin{equation}
\displaystyle D= W_g \vert J_g \vert \Delta t
\left[\begin{array}{c c c}
\displaystyle \sum_{k=1}^6 u_k L_k(g) & 0 & 0 \\
0 & \displaystyle \sum_{k=1}^6 v_k L_k(g)  & 0\\
0 & 0 & \displaystyle \sum_{k=1}^6 w_k L_k(g) 
\end{array}\right]  \end{equation} 

			\subsubsection{Transient}

The transient stiffness matrix has the following shape

\begin{equation}
K_{i,j}  = 
\iint_{E} \theta_j \phi_i dV \\ 
\end{equation}
\\
We now use gaussian points for the integration :

\begin{center}
 $1 \leq i \leq 6$ and  $1 \leq j \leq 6$ 
\end{center}
\medskip
\begin{equation}
\begin{array}{c l}
\displaystyle
K_{i,j} & \displaystyle = 
\iint_{\hat{E}} L_j  L_i \vert J \vert d\hat{V}\\
\\
& \displaystyle \simeq
\sum_{g=1}^6  W_g L_j(g) L_i(g) \vert J_g \vert 
\end{array}
\end{equation}
\\
This elementary stiffness matrix is calculated with three matrices: $\displaystyle K3= \sum_{g=1}^3 [B]^T[D][B]$ as follows:

\begin{equation}
[B]=\left[\begin{array}{c c c c c c}
B_1 & B_2 & B_3 & B_4 & B_5 & B_6 
\end{array}\right] \quad \text{and} \quad D=W_g \vert J_g \vert
\end{equation}
with:
\begin{equation}
B_i= L_i(g )
\end{equation}\\
\newpage
 \subsection{Elementary load vector}

			\subsubsection{Deformational heating}
			
This elementary load vector has the following shape:

\begin{center}
 $1 \leq j \leq 6$
\end{center}
\begin{equation}
F_{j} = 
\iiint_E
\left(  
-\dfrac{\partial T}{\partial t}+ \dfrac{\Phi}{ \rho c }
\right) \theta_j  d\Omega 
dV
\end{equation} 
\\
Using the reference element $\hat{E}$ and the gaussian points, this vector becomes:
\begin{center}
 $1 \leq i \leq 6$
\end{center}
\begin{equation}
F_{j} = 
\iiint_{\hat{E}}  %triple
\left( 
-\dfrac{\partial T}{\partial t} 
+ \dfrac{\Phi}{ \rho c } 
\right) L_j  \vert J \vert d\hat{V}
 = 
\sum_{g=1}^6  W_g \vert J_g \vert 
\left(  
-\left. \dfrac{\partial T}{\partial t}\right|_g
+ \dfrac{\Phi (g)}{ \rho c } 
\right) L_j(g)
\end{equation}


			\subsubsection{Basal heating}

This elementary load vector has the following shape:

\begin{center}
 $1 \leq i \leq 6$
\end{center}
\begin{equation}
F_{j} = 
\iint_{\Gamma_b \cap E }
\dfrac{1}{ \rho c } \left( G + \overrightarrow{\tau}_b . \overrightarrow{u}_b \right) \theta_j
dS
\end{equation} 
\\
Using the reference element $\hat{E}$ and the gaussian points, this vector becomes:
\begin{center}
 $1 \leq j \leq 6$
\end{center}
\begin{equation}
\begin{array}{r c l}
F_{j} & = & \displaystyle
\iint_{\Gamma_b \cap \hat{E} }
\dfrac{1}{ \rho c } \left( G + \overrightarrow{\tau}_b . \overrightarrow{u}_b \right) L_j
\vert J \vert d\hat{S}\\
\\
& \simeq & \displaystyle
\sum_{g=1}^3  W_g \vert J_g \vert 
\dfrac{1}{ \rho c } \left( G(g) + \overrightarrow{\tau}_b(g) . \overrightarrow{u}_b(g)\right) L_j(g)
\end{array}
\end{equation}
Only the nodal functions assigned to the nodes on $\Gamma_b$ are involved.

			\subsubsection{Transient}
			
The transient load vector has the following shape\footnote{NB: $T_i$ stands for the time step $i$ temperature field}:

\begin{equation}
\displaystyle F_{j} =\iint_{E} T_i  \theta_j \vert J \vert dV
\end{equation}
\\
We now use gaussian points for the integration :

\begin{center}
$1 \leq j \leq 6$ 
\end{center}
\medskip
\begin{equation}
\begin{array}{c l}
\displaystyle
F_{j} & \displaystyle = 
\iint_{\hat{E}} T_i  L_j \vert J \vert d\hat{V}\\
\\
& \displaystyle \simeq
\sum_{g=1}^6  W_g T_i(g) L_j(g)  \vert J_g \vert 
\end{array}
\end{equation}


\newpage
\chapter{Prognostic Finite Element Formulation}

	\section{Introduction: presentation of the problem}
	
For transient computation, one uses a finite differences time domain scheme. For each time step, the velocity is computed as well as the temperature (taken as transient). But to compute the next time step, one needs to update the glacier's geometry: the thickness evolution is required. This is done thanks to equation (\ref{prognosticequation}):

\begin{equation}
\dfrac{\partial H}{\partial t} = - div \left( H \left[ \begin{array}{c}
\bar{u} \\
\bar{v}
\end{array}\right] \right)+ \dot{M}_s - \dot{M}_b
\label{prog1}
\end{equation}
\\
We implemented this model using an implicit finite difference approximation for time:

\begin{equation}
\dfrac{H\left(t_{i+1}\right) -H\left(t_{i}\right) }{\Delta t} \simeq - div \left( H \left[ \begin{array}{c}
\bar{u} \\
\bar{v}
\end{array}\right] \right)+ \dot{M}_s - \dot{M}_b
\label{progBad}
\end{equation}
\\
But doing so introduces a negative diffusion term that leads to unstable solutions. To avoid wiggly solutions, we use the classical technique of adding an  \emph{artificial diffusivity}. For a square ice shelf with an accumulation of 10 m/year it gives:
\begin{figure}[H]
  \centering \hspace*{-1cm}
  \subfloat[Initial thickness]{\includegraphics[width=6.7cm]{progi.png}}  
  \hspace*{-1cm}              
  \subfloat[Final thickness]{\includegraphics[width=6.7cm]{prog2.png}}  
  \hspace*{-1cm}
  \subfloat[With artificial diffusivity]{\includegraphics[width=6.7cm]{prog1.png}}  
\caption{Results of the prognostic model for a square ice shelf after 100 years}\label{prog}
\end{figure}

	\section{Why is the solution unstable?}
	
To make things simpler, we will consider a one-dimensional problem with a constant velocity $u$ with no melting and no accumulation:

\begin{equation}
\dfrac{\partial H}{\partial t}=-u\dfrac{\partial H}{\partial x}
\label{prog2}
\end{equation}
\\
With an implicit finite difference scheme for time, we are actually solving:

\begin{equation}
\dfrac{H\left(t_{i+1}\right) -H\left(t_{i}\right) }{\Delta t}
=-u\dfrac{\partial H\left( t_i\right) }{\partial x}
\label{prog3}
\end{equation}
\\
A Taylor development to the order 2 gives:

\begin{equation}
\left.\dfrac{\partial H}{\partial t}\right|_{t_i}
=\dfrac{H\left(t_{i+1}\right) -H\left(t_{i}\right) }{\Delta t} -\dfrac{\Delta t}{2}\left.\dfrac{\partial^2 H}{\partial t^2}\right|_{t_i} +\BigO{\Delta t^2}
\label{taylor}
\end{equation}
\\
Therefore, the exact solution of (\ref{prog2}) is:

\begin{equation}
\dfrac{H\left(t_{i+1}\right) -H\left(t_{i}\right) }{\Delta t} 
= - u\dfrac{\partial H\left(t_i \right) }{\partial x}+\dfrac{\Delta t}{2}\left.\dfrac{\partial^2 H}{\partial t^2}\right|_{t_i} +\BigO{\Delta t^2}
\label{prog4}
\end{equation}
\\
But by solving (\ref{prog3}) only, we are actually neglecting the last term. By doing so, we are actually solving:

\begin{equation}
\dfrac{\partial H}{\partial t}
=-u\dfrac{\partial H}{\partial x}\color{red} -\dfrac{\Delta t}{2}\dfrac{\partial^2 H}{\partial t^2}\color{black}
\label{prog4}
\end{equation}
\\
We have the following property (progressive waves equation):

\begin{equation}
\dfrac{\partial^2 H}{\partial t^2} 
= \dfrac{\partial}{\partial t} \left( -u\dfrac{\partial H}{\partial x}\right)=u^2\dfrac{\partial^2 H}{\partial x^2}
\end{equation}
\\
Therefore, the solution of (\ref{prog3}) is the same as the solution of the following diffusion equation in which the diffusion coefficient is negative:

\begin{equation}
\dfrac{\partial H}{\partial t}
=-u\dfrac{\partial H}{\partial x}\color{red} -\dfrac{\Delta t}{2}u^2\dfrac{\partial^2 H}{\partial x^2}\color{black}
\label{prog5}
\end{equation}
\\
This negative diffusion term that leads to unstable solutions: progressive waves of $H$ (oscillations) are exponentially growing with time.

	\section{Streamline upwind / Petrov Galerkin formulation}

It can be shown that for finite differences, a cure for the unwanted wiggles is provided by use of upwind differences to approximate the convective term, which essentially introduces a truncation error having the form of a physical diffusion. This term is a "balancing-diffusion" that is counteracting the negative diffusion introduced by the truncation error. By so doing, the numerical solution will yield exact values at the nodes.
In addition to directly adding a diffusion term, similar effects of stabilization can be achieved in finite difference through 
According to Brooks and Hughes (1982), the artificial diffusion is only desirable and required in the direction of the
flow vector. The schemes eliminated the crosswind diffusion, which unnecessarily overdiffuses. This technique is named the \emph{streamline upwind/Petrov-Galerkin} (SUPG) formulation.\\
\\
For finite elements, a conventional Galerkin finite element discretization is employed with the same additional artificial diffusion:

\begin{equation}
\dfrac{\partial H}{\partial t} = - div \left( H \left[ \begin{array}{c}
\bar{u} \\
\bar{v}
\end{array}\right] \right)+ \dot{M}_s - \dot{M}_b +div\left( \underline{\kappa}\; \overrightarrow{grad}H\right) 
\label{prog2}
\end{equation}
\\
where $\underline{\kappa}$ is a $2\times 2$ diffusivity tensor designed to diffuse along flowlines and minimize diffusion across flowlines. According to MacAyeal\cite{{Macayeal1997}} (p172), for a given element $E$ of the mesh it has the following expression:

\begin{equation}
\underline{\kappa}=\left(\dfrac{\sqrt{2Area(E)}}{2} \right) 
\left[ 
\begin{array}{c c}
\displaystyle \dfrac{1}{3}\left| \sum_{i=1}^3 u_i\right| & 0\\
0 & \displaystyle \dfrac{1}{3}\left| \sum_{i=1}^3 v_i\right| 
\end{array}\right] =
\left[ 
\begin{array}{c c}
\kappa_{xx} & 0\\
0 & \kappa_{yy}
\end{array}\right]
\end{equation}
\\
where $\left( u_i v_i\right)$ are the nodal values of the depth averaged horizontal velocity components. The artificial diffusivity tensor is designed to give about the same damping as that which would be associated with upwind differencing if the finite-element mesh consisted of a 2d regular array of nodes similar to a finite difference grid. (The absolute value of the local velocity is used in defining $\underline{\kappa}$ to ensure the diffusivity will always be positive). The addition of artificial diffusion bumps the prognostic equation up to a higher order (two spatial derivatives instead of one are now involved), and this necessitates specifying additional boundary conditions. For our purposes, we might as well take $\overrightarrow{grad}H.\overrightarrow{n} = 0$ on all portions of $\partial \Omega$.

        \section{Weak Formulation}
Here, the domain $\Omega$ is a 2d domain (since $H$ only depends on $x$ and $y$). We define a kinematically admissible velocity field $\overrightarrow{\phi}$:

\begin{equation}
\phi(x,y)\in\lbrace H^{1}(\Omega\cup\partial\Omega)\rbrace
\end{equation}
\\
For any function of this virtual field, we can take the product of the equation (\ref{prog2}) with $\phi$, and integrate this product over the domain. This gives us:

\begin{equation}
\iint_\Omega %triple
\dfrac{\partial H}{\partial t}\phi + div \left( H \left[ \begin{array}{c}
\bar{u} \\
\bar{v}
\end{array}\right] \right)\phi- \dot{M}_s\phi + \dot{M}_b\phi 
-div\left( \underline{\kappa}\; \overrightarrow{grad}H_{i}\right) \phi
d\Omega =0
\end{equation}
\\
Exactly as in the transient thermal section,  one uses a finite differences time domain scheme to evaluate the transient term. For a given time step $n$, the transient term is computed implicitly\footnote{an implicit method is much more stable for this kind of equation} as follow:

\begin{equation}
\left. \dfrac{\partial H}{\partial t}\right|_{n} =\dfrac{H_{n}-H_{n-1}}{\Delta t }
\end{equation}
\\
Where $\Delta t$ is the time difference between $t_{n}$ and $t_{n-1}$. The weak formuation becomes:

\begin{equation}
\iint_\Omega %triple
 H_{i}\phi-H_{n-1}\phi + \Delta t\;div \left( H_{n} \left[ \begin{array}{c}
\bar{u} \\
\bar{v}
\end{array}\right] \right)\phi- \Delta t\;\dot{M}_s\phi + \Delta t\;\dot{M}_b\phi 
 -\Delta t\;div\left( \underline{\kappa}\; \overrightarrow{grad}H_{i}\right)\phi 
d\Omega =0
\end{equation}
\\
One can integrate by part the artifficial damping term:

\begin{multline}
\iint_\Omega %triple
 H_{n}\phi + \Delta t\;div \left( H_{n} \left[ \begin{array}{c}
\bar{u} \\
\bar{v}
\end{array}\right] \right)\phi 
+\Delta t\;\left(  \underline{\kappa}\; \overrightarrow{grad}H_{n}\right) .\overrightarrow{grad}\phi
d\Omega =\\
\iint_\Omega %triple
H_{n-1}\phi+ \Delta t\;\dot{M}_s\phi - \Delta t\;\dot{M}_b\phi
d\Omega
+
\int_{\partial\Omega}
\Delta t\; \left( \underline{\kappa}\; \overrightarrow{grad}H_{n}\right) .\overrightarrow{n}\phi dS
d\Omega
\end{multline}
\\
Using the boudary condition, the last term vanishes:

\begin{equation}
\iint_\Omega %triple
 H_{n}\phi + \Delta t\;div \left( H_{n} \left[ \begin{array}{c}
\bar{u} \\
\bar{v}
\end{array}\right] \right)\phi 
+\Delta t\left(  \underline{\kappa}\; \overrightarrow{grad}H_{n}\right) .\overrightarrow{grad}\phi
d\Omega =
\iint_\Omega %triple
H_{n-1}\phi+ \Delta t\dot{M}_s\phi - \Delta t\dot{M}_b\phi
d\Omega
\end{equation}

					\section{Elementary stiffness matrix and load vector}
Following the same method as in the previous chapters, we obtain the stiffness matrix as follows:

\begin{equation}
\begin{array}{l c l}
\displaystyle K_{i,j} &\displaystyle = &
\displaystyle \iint_{\Omega} 
\phi_j \phi_i +\Delta t \;div \left( \left[ \begin{array}{c}
\bar{u} \\
\bar{v}
\end{array}\right]\phi_j \right)\phi_i
+\Delta t\left(\kappa_{xx}\dfrac{\partial \phi_j}{\partial x}\dfrac{\partial \phi_i}{\partial x}
+\kappa_{yy}\dfrac{\partial \phi_j}{\partial y}\dfrac{\partial \phi_i}{\partial y} \right) 
d\Omega \\ 
\\
F_{i} &\displaystyle = & 
\displaystyle \iint_\Omega %triple
H_{n-1}\phi_i+ \Delta t\dot{M}_s\phi_i - \Delta t\dot{M}_b\phi_i
d\Omega
\end{array}
\end{equation}
\\
We now decompose these two matrices over the reference elements and use gaussian points for the integration :

\begin{center}
 $1 \leq i \leq 3$ and  $1 \leq j \leq 3$ 
\end{center}
\medskip
\begin{equation*}
\begin{array}{c l}
\displaystyle
K_{i,j} & \displaystyle = 
\iint_{\hat{E}}
 L_j  L_i 
 +\Delta t \;div \left( \left[ \begin{array}{c}
\bar{u} \\
\bar{v}
\end{array}\right]L_j \right)L_i
+\Delta t\left(\kappa_{xx}\dfrac{\partial L_j}{\partial x}\dfrac{\partial L_i}{\partial x}
+\kappa_{yy}\dfrac{\partial L_j}{\partial y}\dfrac{\partial L_i}{\partial y} \right)
 \vert J \vert d\hat{S}\\
\\
& \displaystyle \simeq
\sum_{g=1}^3  W_g\left( 
\underbrace{L_j  L_i}_{K1} 
 +\underbrace{\Delta t \;\left. div  \left( \left[ \begin{array}{c}
\bar{u} \\
\bar{v}
\end{array}\right]L_j \right) \right|_g L_i(g )}_{K2} 
+\underbrace{\Delta t\left(\kappa_{xx}\left.\dfrac{\partial L_j}{\partial x}\right|_g\left.\dfrac{\partial L_i}{\partial x}\right|_g
+\kappa_{yy}\left.\dfrac{\partial L_j}{\partial y}\right|_g\left.\dfrac{\partial L_i}{\partial y}\right|_g \right)}_{K3} 
\right) \vert J_g \vert \\
\\
\displaystyle
F_{i} & \displaystyle =
\iint_{\hat{E}} H_{n-1}L_i+ \Delta t\dot{M}_s L_i - \Delta t\dot{M}_b L_i
\vert J \vert d\Gamma \\
\\
& \displaystyle \simeq 
\sum_{g=1}^3 \left(  H_{n-1}L_i(g)+ \Delta t\dot{M}_s L_i(g) - \Delta t\dot{M}_b L_i(g)\right)  \vert J_g \vert \delta(icesheet)\\
\end{array}
\end{equation*}

\subsection{First term $K1$}

This elementary stiffness matrix is calculated with three matrices: $\displaystyle K1= \sum_{g=1}^3 [B]^T[D][B]$ as follows:
\begin{equation}
[B]=\left[\begin{array}{c c c}
B_1 & B_2 & B_3 
\end{array}\right]\quad \text{and} \quad D=W_g \vert J_g \vert
\end{equation}
with:
\begin{equation}
B_i= L_i(g )
\end{equation}

\subsection{Second term $K2$}

The second elementary stiffness matrix is computed as follows: $\displaystyle K2= \sum_{g=1}^3 [B]^T[D][B]+[B]^T[D'][B']$

\begin{equation}
[B]=\left[\begin{array}{c c c}
B_1 & B_2 & B_3 
\end{array}\right]
\quad 
[B']=\left[\begin{array}{c c c}
B_1' & B_2' & B_3' 
\end{array}\right]
\end{equation}

\begin{equation}
D=\Delta t \;W_g \vert J_g \vert
\left[\begin{array}{c c}
\left.\dfrac{ \partial \overline{u}}{\partial \varphi_x}\right|_g & 0\\
0 &  \left. \dfrac{\partial \overline{v}}{\partial \varphi_y}\right|_g
\end{array}\right]
\quad \text{and} \quad
D'=\Delta t \;W_g \vert J_g \vert
\left[\begin{array}{c c}
\overline{u}(g) & 0\\
0 &  \overline{v}(g)
\end{array}\right]
\end{equation}
\\
with:
\begin{equation}
B_i=
\left[ \begin{array}{c}
 L_i(g) \\
 L_i(g) 
\end{array}\right] 
\quad \text{and} \quad B_i'=
\left[ \begin{array}{c}
\left.\dfrac{ \partial L_i}{\partial \varphi_x}\right|_g \\
 \left.\dfrac{ \partial L_i}{\partial \varphi_y}\right|_g
\end{array}\right]
\end{equation}

\subsection{Third term $K3$}

The third elementary stiffness matrix is computed with three matrices: $\displaystyle K3= \sum_{g=1}^3 [B]^T[D][B]$ as follows:

\begin{equation}
[B]=\left[\begin{array}{c c c }
B_1 & B_2 & B_3 
\end{array}\right]\quad \text{and} \quad D=\Delta t \;W_g \vert J_g \vert \underline{\kappa}
\end{equation}
with:
\begin{equation}
B_i= \left[\begin{array}{c }
\left.\dfrac{ \partial L_i}{\partial \varphi_x}\right|_g \\
 \left.\dfrac{ \partial L_i}{\partial \varphi_y}\right|_g
\end{array}\right]
\end{equation}

	\section{A comment on $\Delta t$}

According to MacAyeal\cite{{Macayeal1997}} (p175), the implicit time-stepping scheme suggests that the solution of the prognostic (mass balance) equation should be stable for any time-step size. In practice, the time-step size should be chosen so that all imaginary passive-tracer particles initially released at the nodal points (except those starting at ice-front nodes) remain confined by one single element throughout the time span $\left[t,t+\Delta t \right]$. In other words, it is best to choose a $\Delta t$ small enough so that the distance traveled by one of these imaginary passive-tracer particles
will not exceed the mesh spacing. In circumstances where the velocity field of the ice shelf changes substantially through the time, it may be wise to
consider adaptively modifying $\Delta t$ during the simulation. The time-step size should follow the rule:

\begin{equation}
\Delta t = \dfrac{\frac{\Delta L}{\sqrt{2}}}{2\max\left(v\right) }
\end{equation}
\\
where $\Delta L$ is the nondimensional size of the finite-element mesh spacing (shortest distance between node points in the regular mesh). The idea of the above equation is that $\Delta t$ is just large enough so that the fastest moving passive-tracer particle will move half the distance along a diagonal trajectory across a typical triangular element.
\newpage
\chapter{Penalty Method}
\label{chappenalty}
\section{Introduction}

Penalty method is a well known method which is often applied in finite element analysis of contact problems (See Wriggers \cite{Wriggers2002}). A penalty term, which can be interpreted as a spring with a very large stiffness, is added to the energy so that when a constraint is not fulfilled, the energy is much higher than it should be. Thanks to this penalized energy, a state that minimizes the energy is also a state that respects the constraints. Since finite element is a method that tries to minimize the energy of a system, the penalty forces the model to be properly constrained. In $ISSM$, penalties are used beween 2d and 3d meshes (horizontal velocities), bewteen 2d and 2d meshes (basal vertical velocity), bewteen 3d and 3d meshes (vertical velocity and temperature), and for melting.

\section{Constraining velocities of two meshes}
The first exemple of penalty used in $ISSM$ is between the 2d and the 3d model (to compute the horizontal velocity $\left(u,v \right) $). In the same mesh, one wants to compute the velocity field with a 2d model on one part of the mesh, and with a 3d model on the other. We start from a 2d mesh, the grids on the boundary between the 2d model and the 3d model are splitted into 2 grids. Then, the part of the mesh assigned to compute the 3d model is extruded into several layers in order to compute have a 3d mesh. For example, one can have the following geometry:
\begin{figure}[H]
\begin{center}
\includegraphics[width=11.5cm]{meshpenalty.png}
\caption{Mesh of a system coupling a 2d and a 3d model}
\end{center}
\end{figure}
Although two different models are used, one wants to have a continuous velocity between the two part of the mesh. The penalties applied here are used to constrain the velocity of the 2d grids (in red) at the models interface to a value equal to the one of all the grids vertically extruded of the 3d mesh (blue). 
\begin{figure}[H]
\begin{center}
\includegraphics[width=11.5cm]{penalties1.png}
\caption{Applied penalties at the models interface}
\end{center}
\end{figure}
\noindent
To ensure that, one adds penalties to the energy of the system: when the velocity of one of the 2d grid on the boundary is not the same as the corresponding 3d grids the energy must increase. Here, we have 10 red grids and for each red grid there are 10 blue grids (there are 10 layers). Therefore, there are 100 pair of grids and one wants the velocity of each grid to be the same as its pair. The penalized energy has the following expression (for the sake of simplicity, only one component is represented):

\begin{equation}
E=
\left[ U\right] ^T \left[K \right] \left[U\right] +\left[U\right] ^T \left[F\right] 
+
\color{red}\sum^{red\;grids}_{n=1}
\color{black}\left( 
\color{blue}\sum^{layers}_{l=1}
\color{black}\kappa
\left(\color{red}u_n\color{black}-\color{blue}u_{nl}\color{black} \right)^2
\right) 
\end{equation}
\\
Where $K$ and $F$ are the stiffness matrix and the load vetor of the system, $U$ is the velocity of the grids, and $\kappa$ is the penalty term: a very large number compared to $K_{ij}$ so that the energy of the system explode when one $\color{red}u_n$ is two far from its corresponding $\color{blue}u_{nl}$ (ie. when the velocities of the 2 grids belonging to the same pair of grids are not equal). From now on, we will explain the penalty method only for one pair of grids. The general case can be easily found by reproducing the following pattern for every pair of grids. The penalized energy is:

\begin{equation}
E=
\left[ U\right] ^T \left[K \right] \left[U\right] +\left[U\right] ^T \left[F\right] 
+
\kappa
\left(\color{red}u_{red}\color{black}-\color{blue}u_{blue}\color{black} \right)^2
\end{equation}
\\
We can transform this expression as follows:

\begin{equation}
E=
\left[
\begin{array}{c} %U
\vdots \\
u_j\\
\vdots\\
\end{array}
\right]^T
\left[
\begin{array}{c c c} %K
& \vdots &  \\
\cdots & K_{ij} &  \cdots\\
& \vdots & \\
\end{array}
\right]
\left[
\begin{array}{c} %U
\vdots \\
u_j\\
\vdots\\
\end{array}
\right]
+\left[
\begin{array}{c} %U
\vdots \\
u_j\\
\vdots\\
\end{array}
\right]^T
\left[
\begin{array}{c} %U
\vdots \\
F_j\\
\vdots\\
\end{array}
\right]
+
\left[
\begin{array}{c} %U
\color{red}u_{red}\\
\color{blue}u_{blue}\\
\end{array}
\right]^T
\left[
\begin{array}{c c} %K
\kappa & -\kappa \\
-\kappa & \kappa\\
\end{array}
\right]
\left[
\begin{array}{c} %U
\color{red}u_{red}\\
\color{blue}u_{blue}\\
\end{array}
\right]
\end{equation}
\\
Finally one can concatenate the stiffness matrix with the penalty matrix:

\begin{equation}
E=
\left[
\begin{array}{c} %U
\vdots \\
\color{red}u_{red}\\
\vdots\\
\color{blue}u_{blue}\\
\vdots
\end{array}
\right]^T
\left[
\begin{array}{c c c c c} %K
& \vdots & \vdots & \vdots & \\
\cdots & K_{rr}+\kappa & \cdots & K_{rb}-\kappa & \cdots\\
& \vdots & \vdots & \vdots& \\
\cdots &  K_{br}-\kappa & \cdots & K_{bb}+\kappa & \cdots\\
& \vdots & \vdots & \vdots &
\end{array}
\right]
\left[
\begin{array}{c} %U
\vdots \\
\color{red}u_{red}\\
\vdots\\
\color{blue}u_{blue}\\
\vdots
\end{array}
\right]+\left[
\begin{array}{c} %U
\vdots \\
u_j\\
\vdots\\
\end{array}
\right]^T
\left[
\begin{array}{c} %U
\vdots \\
F_j\\
\vdots\\
\end{array}
\right]
\end{equation}
\\
Given that energy, the linear system to solve is:

\begin{equation}
\begin{array}{|c c c|}
\hline
&&\\
&\left[
\begin{array}{c c c c c} %K
& \vdots & \vdots & \vdots & \\
\cdots & K_{rr}+\kappa & \cdots & K_{rb}-\kappa & \cdots\\
& \vdots & \vdots & \vdots& \\
\cdots &  K_{br}-\kappa & \cdots & K_{bb}+\kappa & \cdots\\
& \vdots & \vdots & \vdots &
\end{array}
\right]
\left[
\begin{array}{c} %U
\vdots \\
\color{red}u_{red}\\
\vdots\\
\color{blue}u_{blue}\\
\vdots
\end{array}
\right]
=
\left[
\begin{array}{c} %U
\vdots \\
F_j\\
\vdots\\
\end{array}
\right]&\\
&&\\
\hline
\end{array}
\end{equation}
\\
Since $\kappa$ is much larger that $K_{ij}$, the first equation that links $\color{red}u_{red}$ to $\color{blue}u_{blue}$:

\begin{equation}
\sum_{i=1}^{n}K_{ir}u_i +\kappa\left( \color{red}u_{red}\color{black}-\color{blue}u_{blue}\color{black}\right)=F_r
\end{equation}
\\
To the zero order:

\begin{equation}
\kappa\left( \color{red}u_{red}\color{black}-\color{blue}u_{blue} \color{black}\right)=0 
\hspace{1cm} \Longleftrightarrow \hspace{1cm} 
\color{red}u_{red}\color{black} =\color{blue}u_{blue}\color{black}
\end{equation}
\\
We see that the penalized stiffness matrix ensure that the velocities of the grids pair is the same. The exact same process is used between two 2d meshes (basal vertical velocity) and two 3d meshes (temperature or vertical velocity). The crucial step is to build the pairs of grids and then add penalties on the corresponding rows and clumns of the stiffness matrix.\\
\\
Here are the results for a square iceshelf. The upperview does not show any discontinuity in the velocity field:
\begin{figure}[H]
\begin{center}
\includegraphics[width=10cm]{penalized_vel_2.png}
\caption{coupling between a 2d and a 3d model, upper view}
\end{center}
\end{figure}
\begin{figure}[H]
\begin{center}
\includegraphics[width=10cm]{penalized_vel_3.png}
\caption{coupling between a 2d and a 3d model, 3d view}
\end{center}
\end{figure}

\section{Stokes model}
\label{stokespenaltiessection}
We have seen in section \ref{stokessection} that the boundary condition on ice/till interface for the vertical velocity was:
\begin{equation}
w=-\frac{\partial b}{\partial x}u-\frac{\partial b}{\partial y}v
\end{equation}
\\
In order to apply this boundary condition, we use a penalty to connect the three components of the velocity.\\
The equation of the penalty we have to add in the elementary matrix is:

\begin{equation}
\kappa \left( w+\frac{\partial b}{\partial x}u+\frac{\partial b}{\partial y}v\right)=0
\end{equation}
\\
If we note $K$ the elementary stiffness matrix, and $F$ the elementary load vector , the system to solve with these penalties is:

\begin{equation}
\left[
\begin{array}{c c c c c} %K
& \vdots & \vdots & \vdots &  \\
\cdots & K_{3i,3j-2}+\kappa\; n_x & K_{3i,3j-1}+\kappa\; n_y & K_{3i,3j}+\kappa  &  \cdots\\
& \vdots & \vdots & \vdots & 
\end{array}
\right]
\left[
\begin{array}{c} %U
\vdots \\
u_j\\
v_j\\
w_j\\
\vdots\\
\end{array}
\right]
=
\left[
\begin{array}{c} %U
\vdots \\
F_j\\
\vdots
\end{array}
\right]\\
\end{equation}
\newpage
\section{Thermal model}
We have seen in section \ref{meltingsection} that the equation on the Ice/Till interface was:

\begin{equation}
\label{basalthermal}
\left\{ \begin{array}{l}
\displaystyle -k \left. \dfrac{\partial T}{\partial z}\right| _b =G + \overrightarrow{\tau}_b . \overrightarrow{u}_b - \rho L\dot{M}_b  \\
\\
\displaystyle \dot{M}_b\left( T-T_{pmp}\right) =0 \\
\\
\displaystyle T-T_{pmp} \leq 0 \\
\\
\displaystyle \dot{M}_b \geq 0 \\
                 \end{array} \right.
\end{equation}
\\
The third equation imposes the temperature to be below the pressure melting point $T_{pmp}$. One can use penalty to constrain the temperature. We will see that one can then use these penalties to deduce the melting rate.

\subsection{Constraining temperature}
The temperature of each grid must stay below the pressure melting point $T_{pmp}$. In the first step, it is assumed that the computed temperature is everywhere below $T_{pmp}$. The computed temperature is then compared to the pressure melting point. When a grid goes above $T_{pmp}$, one adds penalties in the stiffness matrix and in the load vector  to keep it at the pressure melting point as follows:

\begin{equation}
\begin{array}{|c c c|}
\hline
&&\\
&
\left[
\begin{array}{c c c} %K
& \vdots &  \\
\cdots & K_{ij}+\kappa &  \cdots\\
& \vdots & \\
\end{array}
\right]
\left[
\begin{array}{c} %U
\vdots \\
T_j\\
\vdots\\
\end{array}
\right]
=
\left[
\begin{array}{c} %U
\vdots \\
F_j+\kappa T_{pmp}\\
\vdots\\
\end{array}
\right] &\\
&&\\
\hline
\end{array}
\end{equation}
\\
So that $T_j$ is constrained to $T_{pmp}$. One does that for all the grids above the pressure melting point. Then the temperature is computed again and compared to $T_{pmp}$. The grids above this temperature are the penalized, whereas those which were already penalized and present a temperature now below the pressure melting point are released. After several iterations, one finaly gets the temperature field.
\begin{figure}[H]
\begin{center}
\includegraphics[width=11cm]{thermal_loop.png}
\caption{Thermal Algotithm of $ISSM$}
\end{center}
\end{figure}

\subsection{Basal melting}
using the previous algorithm, one can solve the third equation of the system (\ref{basalthermal}). But the use of penalties allows also to compute melting. One a penalty is applied ($T$ reaches the pressure melting point), the system to solve is:

\begin{equation}
\left[
\begin{array}{c c c} %K
& \vdots &  \\
\cdots & K_{ij} &  \cdots\\
& \vdots & \\
\end{array}
\right]
\left[
\begin{array}{c} %U
\vdots \\
T_j\\
\vdots\\
\end{array}
\right]
=
\left[
\begin{array}{c} %U
\vdots \\
F_j+\kappa \left( T_{pmp}-T_j\right) \\
\vdots\\
\end{array}
\right]
\end{equation}
\\
We saw that the melting was not computed in the load vector. But one can use the previous load vector to deduce melting: the total load veclor (that includes basal melting) should have had the following expression:

\begin{equation}
\begin{array}{l c l}
\displaystyle
F_{j}^{tot} &=&\displaystyle
\iiint_\Omega
\left(  
-\dfrac{\partial T}{\partial t} + \dfrac{\Phi}{ \rho c }
\right) \theta_i  d\Omega 
+
\iint_{\Gamma_b }
\dfrac{1}{ \rho c } \left(G + \overrightarrow{\tau}_b . \overrightarrow{u}_b + \rho L\dot{M}_b\right) \theta_j
dS\\
\\
&=&\displaystyle F_{j} +
\dfrac{1}{ \rho c }\iint_{\Gamma_b }
\rho L\dot{M}_b \theta_j
dS\\
\end{array}
\end{equation}
\\
That gives a simple relation between the penalized load and basal melting:

\begin{equation}
\kappa \left( T_{pmp}-T_j\right)=
\dfrac{L}{ c }\iint_{\Gamma_b } \dot{M}_b \theta_jdS
\end{equation}
\\
We can use a 2d mesh (we are dealing with the glacier base only), to deduce $\dot{M}_{b_j}$:

\begin{equation}
\begin{array}{|c c c|}
\hline
&&\\
&
\left[
\begin{array}{c c c} %K
& \vdots &  \\
\cdots & K'_{ij} &  \cdots\\
& \vdots & \\
\end{array}
\right]
\left[
\begin{array}{c} %U
\vdots \\
\dot{M}_{b_j}\\
\vdots\\
\end{array}
\right]
=
\left[
\begin{array}{c} %U
\vdots \\
F'_j\\
\vdots\\
\end{array}
\right]
&\\
&&\\
\hline
\end{array}
\end{equation}
\\
with:

\begin{equation}
\begin{array}{|r c l|}
\hline
&&\\
K'_{ij} & = & \displaystyle
\dfrac{L}{c}\iint_{\Gamma_b }
\theta_i\theta_j
dS\\
&&\\
F'_{j} & = & \displaystyle
\kappa \left( T_{pmp}-T_j\right)\\
&&\\
\hline
\end{array}
\end{equation}
\\
The grids where no penalty is applied (ie. the temperature is below the pressure melting point) are constrained to 0. Thanks to that we solved all the equations of the system (\ref{basalthermal}).

\newpage
\appendix
\chapter{Reference Elements}
In finite element models, rather than calculating the integrals for each element, one uses a \emph{Reference Element} $\hat{E}$, and a transformation $\varphi$ that transforms the reference element to the element $E$.

	\section{One dimension, Segment}
\label{RE1D}         
\begin{figure}[H]
\begin{center}
\includegraphics[width=15cm]{segment.png}
\caption{Transformation from the reference segment, to the current segment of the mesh}
\end{center}
\end{figure}

For any function $f(x)$, we have the following equation:

\begin{equation}
\int_E f(x)dx = \int_{\hat{E}} {f}(\varphi(r)) \vert  \varphi' \vert dr
\end{equation}
\\
For the reference element $\hat{E}$, the nodal functions are:

\begin{equation}
\begin{array}{l}
\displaystyle L_1(r)= -\frac{1}{2}r + \frac{1}{2}\\
\\
\displaystyle L_2(r)= \frac{1}{2}r + \frac{1}{2}\\
\end{array}
\end{equation}
\\
One can use these nodal functions to calculate the function $\varphi$:

\begin{equation}
\varphi(r)= x_1 L_1(r) +  x_2 L_2(r)\\
\end{equation}
So,
\begin{equation}
\varphi(r)= \frac{1}{2}\left( - x_1 + x_2\right) r +\frac{1}{2}\left( x_1+x_2\right)\\
\end{equation}
\\
The derivative of $ \varphi$  is :
\begin{equation}
\varphi'(r)=\frac{1}{2} \left( -x_1 + x_2 \right)\\
\end{equation}



\newpage
	\section{Two dimensions, Triangle}	 
\label{RE2D}      
\begin{figure}[H]
\begin{center}
\includegraphics[width=15cm]{triaelem.png}
\caption{Transformation from the reference triangle, to the current element of the mesh}
\end{center}
\end{figure}
For any function $f(x,y)$, we have the following equation:

\begin{equation}
\iint_E f(x,y)dS = \iint_{\hat{E}} \hat{f}(r,s) \vert J \vert dS
\end{equation}
\\
Where $J$ is the Jacobian determinant of the $\varphi$ function.
For the reference element $\hat{E}$, the nodal functions are:

\begin{equation}
\begin{array}{l}
\displaystyle L_1(r,s)= -\frac{1}{2}r -\frac{\sqrt{3}}{6}s + \frac{1}{3}\\
\\
\displaystyle L_2(r,s)= \frac{1}{2}r -\frac{\sqrt{3}}{6}s + \frac{1}{3}\\
\\
\displaystyle L_3(r,s)= \frac{\sqrt{3}}{3}s + \frac{1}{3}\\
\end{array}
\end{equation}
\\
One can use these nodal functions to calculate the function $\varphi$:

\begin{equation}
\varphi(r,s)=
\left\lbrace
\begin{array}{l l}
\displaystyle x= & x_1 L_1(r,s) +  x_2 L_2(r,s) +  x_3 L_3(r,s)\\
\\
\displaystyle y= & y_1 L_1(r,s) +  y_2 L_2(r,s) +  y_3 L_3(r,s) \\
\end{array}
\right.
\end{equation}
So,
\begin{equation}
\varphi(r,s)=
\left\lbrace
\begin{array}{l}
\displaystyle 
x = \left( - \frac{1}{2}x_1 + \frac{1}{2} x_2\right) r 
+ \left(-\frac{\sqrt{3}}{6}x_1 -\frac{\sqrt{3}}{6}x_2+\frac{\sqrt{3}}{3}x_3\right) s 
+\frac{1}{6}\left( 2x_1+2x_2+x_3 \right)\\
\\
\displaystyle 
y=\left( - \frac{1}{2}y_1 + \frac{1}{2} y_2\right) r 
+ \left(-\frac{\sqrt{3}}{6}y_1 -\frac{\sqrt{3}}{6}y_2+\frac{\sqrt{3}}{3}y_3\right) s 
+\frac{1}{6}\left( 2y_1+2y_2+y_3 \right)
 \\
\end{array}
\right.
\end{equation}
\\
The Jacobian of the  $\varphi$ function is now easily computable:

\begin{equation}
J=
\left[
\begin{array}{c c}
\displaystyle 
\frac{\partial \varphi_x }{\partial r} & \displaystyle  \frac{\partial \varphi_x }{\partial s} \\
\\
\displaystyle 
\frac{\partial \varphi_y }{\partial r} & \displaystyle  \frac{\partial \varphi_y }{\partial s} \\
\end{array}
\right]
=
\left[
\begin{array}{c c}
\displaystyle 
\frac{1}{2}\left( x_2-x_1 \right) & \displaystyle  \frac{\sqrt{3}}{6}\left(2x_3-x_1-x_2\right) \\
\\
\displaystyle 
\frac{1}{2}\left( y_2- y_1\right)& \displaystyle  \frac{\sqrt{3}}{6}\left(2y_3-y_1-y_2\right)
 \\
\end{array}
\right]
\end{equation}



\newpage
	\section{Two dimensions, Squares}	 
\label{RE2D2}      
\begin{figure}[H]
\begin{center}
\includegraphics[width=15cm]{quadelem.png}
\caption{Transformation from the reference quadrangle, to the current element of the mesh}
\end{center}
\end{figure}
For any function $f(x,y)$, we have the following equation:

\begin{equation}
\iint_E f(x,z)dS = \iint_{\hat{E}} \hat{f}(r,s) \vert J \vert dS
\end{equation}
\\
Where $J$ is the Jacobian determinant of the $\varphi$ function.
For the reference element $\hat{E}$, the nodal functions are:

\begin{equation}
\begin{array}{l}
\displaystyle L_1(r,s)= -\frac{1}{4} \left(r+1\right)\left(s-1\right)\\ 
\\
\displaystyle L_2(r,s)= \frac{1}{4} \left(r-1\right)\left(s-1\right)\\
\\
\displaystyle L_3(r,s)= - \frac{1}{4} \left(r-1\right)\left(s+1\right)\\
\\
\displaystyle L_4(r,s)= \frac{1}{4} \left(r+1\right)\left(s+1\right)\\
\end{array}
\end{equation}
\\
One can use these nodal functions to calculate the function $\varphi$:

\begin{equation}
\varphi(r,s)=
\left\lbrace
\begin{array}{l l}
\displaystyle x= & x_1 L_1(r,s) +  x_2 L_2(r,s) +  x_3 L_3(r,s) +  x_4 L_4(r,s)\\
\\
\displaystyle z= & z_1 L_1(r,s) +  z_2 L_2(r,s) +  z_3 L_3(r,s)  +  z_4 L_4(r,s)\\
\end{array}
\right.
\end{equation}
So,
\begin{equation}
\varphi(r,s)=
\left\lbrace
\begin{array}{r c l}
\displaystyle 
x & = &\displaystyle \frac{1}{4}\left(  -x_1 +  x_2 -  x_3 + x_4\right) rs 
+ \frac{1}{4}\left(x_1 -x_2-x_3 +x_4\right) r\\
\\
&& 
\displaystyle + \frac{1}{4}\left(-x_1 -x_2+x_3+ x_4\right) s 
+ \frac{1}{4}\left(x_1 +x_2+x_3 + x_4\right) 
\\
\displaystyle
\\ 
z & = &\displaystyle \frac{1}{4}\left(  -z_1 +  z_2 -  z_3 + z_4\right) rs 
+ \frac{1}{4}\left(z_1 -z_2-z_3 +z_4\right) r\\
\\
&& 
\displaystyle + \frac{1}{4}\left(-z_1 -z_2+z_3+ z_4\right) s 
+ \frac{1}{4}\left(z_1 +z_2+z_3 + z_4\right) 
 \\
\end{array}
\right.
\end{equation}
\\
The Jacobian of the  $\varphi$ function is now easily computable:

\begin{equation}
J=
\left[
\begin{array}{c c}
\displaystyle 
\frac{\partial \varphi_x }{\partial r} & \displaystyle  \frac{\partial \varphi_x }{\partial s} \\
\\
\displaystyle 
\frac{\partial \varphi_y }{\partial r} & \displaystyle  \frac{\partial \varphi_y }{\partial s} \\
\end{array}
\right]
\end{equation}
\\
\begin{equation}
\begin{array}{c}
\displaystyle J_{11}= 
\frac{1}{4} \left(- x_1+x_2 - x_3 + x_4 \right) s + \frac{1}{4}\left(  x_1 -  x_2 - x_3 +x_4\right)\\
\\
\displaystyle J_{12}=  \frac{1}{4}\left(  -x_1 +  x_2 -  x_3 + x_4 \right) r + \frac{1}{4}\left( - x_1 - x_2 + x_3 + x_4 \right) \\ 
\\
\displaystyle J_{12}= 
\frac{1}{4} \left(- z_1+z_2 - z_3 + z_4 \right) s + \frac{1}{4}\left(  z_1 -  z_2 - z_3 +z_4\right)\\
\\
\displaystyle J_{22}=  \frac{1}{4}\left(  -z_1 +  z_2 -  z_3 + z_4 \right) r + \frac{1}{4}\left( - z_1 - z_2 + z_3 + z_4 \right) \\ 
\\
\end{array}
\end{equation}

\newpage
	\section{Three dimensions, tetrahedron}	
\label{RE3D1}   
\begin{figure}[H]
\begin{center}
\includegraphics[width=15cm]{tetraelem.png}
\caption{Transformation from the reference element, to the current pentahedron of the mesh}
\end{center}
\end{figure}
For any function $f(x,y,z)$, the transformation verifies:

\begin{equation}
\iiint_E f(x,y,z)dV = \iiint_{\hat{E}} \hat{f}(r,s,\zeta) \vert J \vert d\hat{V}
\end{equation}
\\
Where $J$ is the Jacobian determinant of the $\varphi$ function.
For the reference element $\hat{E}$, the nodal functions are:

\begin{equation}
\begin{array}{l}
\displaystyle L_1(r,s,\zeta)= \dfrac{1}{2}\left( 1-r-\dfrac{1}{\sqrt{3}}s-\dfrac{1}{\sqrt{6}}\zeta\right)\\
\\
\displaystyle L_2(r,s,\zeta)= \dfrac{1}{2}\left( 1+r-\dfrac{1}{\sqrt{3}}s-\dfrac{1}{\sqrt{6}}\zeta\right)\\
\\
\displaystyle L_3(r,s,\zeta)= \dfrac{1}{\sqrt{3}}\left( s-\dfrac{1}{\sqrt{8}}\zeta\right)\\
\\
\displaystyle L_4(r,s,\zeta)= \sqrt{\dfrac{3}{8}}\zeta\\
\end{array}
\end{equation}
\\
One can use these nodal functions to calculate the function $\varphi$:

\begin{equation}
\varphi(r,s)=
\left\lbrace
\begin{array}{l}
\displaystyle x=\sum_{i=1}^4 x_i L_i(r,s,\zeta)\\
\\
\displaystyle y=\sum_{i=1}^4 y_i L_i(r,s,\zeta)\\
\\
\displaystyle z=\sum_{i=1}^4 z_i L_i(r,s,\zeta)\\
\end{array}
\right.
\end{equation}
For example, the first component of $\varphi(r,s,\zeta)$ is:
\begin{equation*}
\varphi_x(r,s,t)=
\frac{1}{2}\left( x_1+x_2\right)
+ \frac{1}{2}\left( -x_1+x_2\right) r
+ \frac{1}{2\sqrt{3}} \left( -x_1-x_2+2 x_3\right)s
+ \frac{1}{2\sqrt{6}}\left( -x_1-x_2-x_3+x_4\right)\zeta
\end{equation*}
\\
The 2 other components have exactly the same equation, except the the $x_i$ must be replaced by in turn $y_i$ and $z_i$.
The Jacobian of the  $\varphi$ function is now easily computable:

\begin{equation}
J=
\left[
\begin{array}{c c c}
\displaystyle 
\frac{\partial \varphi_x }{\partial r} & \displaystyle  \frac{\partial \varphi_x }{\partial s} &  \displaystyle  \frac{\partial \varphi_x }{\partial \zeta} \\
\\
\displaystyle 
\frac{\partial \varphi_y }{\partial r} & \displaystyle  \frac{\partial \varphi_y }{\partial s} &  \displaystyle  \frac{\partial \varphi_y }{\partial \zeta}  \\
\\
\displaystyle 
\frac{\partial \varphi_z }{\partial r} & \displaystyle  \frac{\partial \varphi_z }{\partial s} &  \displaystyle  \frac{\partial \varphi_z }{\partial \zeta}  \\
\end{array}
\right]
\end{equation}
\\
with:
\begin{equation*}
\begin{array}{l l l}
\displaystyle 
J_{11}= 
 \frac{1}{2}\left( -x_1+x_2\right) &
J_{21}=   \displaystyle 
\frac{1}{2}\left( -y_1+y_2\right) &
J_{31}=    \displaystyle 
\frac{1}{2}\left( -z_1+z_2\right) \\
\\
J_{12}= \displaystyle  
\frac{1}{2\sqrt{3}} \left( -x_1-x_2+2 x_3\right)&
J_{22}=  \displaystyle 
\frac{1}{2\sqrt{3}} \left( -y_1-y_2+2 y_3\right)&
J_{32}=  \displaystyle 
\frac{1}{2\sqrt{3}} \left( -z_1-z_2+2 z_3\right)\\
\\
J_{31}=  \displaystyle  
\frac{1}{2\sqrt{6}}\left( -x_1-x_2-x_3+x_4\right))& 
J_{32}=  \displaystyle 
\frac{1}{2\sqrt{6}}\left( -x_1-y_2-x_3+y_4\right)& 
J_{33}=  \displaystyle 
\frac{1}{2\sqrt{6}}\left( -z_1-z_2-z_3+z_4\right)\\ 
\end{array}
\end{equation*}
\newpage

	
	
	
\newpage
	\section{Three dimensions, pentahedron}	
\label{RE3D}   
\begin{figure}[H]
\begin{center}
\includegraphics[width=15cm]{pentaelem.png}
\caption{Transformation from the reference element, to the current pentahedron of the mesh}
\end{center}
\end{figure}
For any function $f(x,y,z)$, the transformation verifies:

\begin{equation}
\iiint_E f(x,y,z)dV = \iiint_{\hat{E}} \hat{f}(r,s,\zeta) \vert J \vert d\hat{V}
\end{equation}
\\
Where $J$ is the Jacobian determinant of the $\varphi$ function.
For the reference element $\hat{E}$, the nodal functions are:

\begin{equation}
\begin{array}{l}
\displaystyle L_1(r,s,\zeta)= \left( -\frac{1}{2}r -\frac{\sqrt{3}}{6}s + \frac{1}{3}\right) \frac{1-\zeta}{2}\\
\\
\displaystyle L_2(r,s,\zeta)= \left(\frac{1}{2}r -\frac{\sqrt{3}}{6}s + \frac{1}{3}\right) \frac{1-\zeta}{2}\\
\\
\displaystyle L_3(r,s,\zeta)=\left( \frac{\sqrt{3}}{3}s + \frac{1}{3}\right) \frac{1-\zeta}{2}\\
\\
\displaystyle L_4(r,s,\zeta)= \left( -\frac{1}{2}r -\frac{\sqrt{3}}{6}s + \frac{1}{3}\right) \frac{\zeta+1}{2} \\
\\
\displaystyle L_5(r,s,\zeta)= \left(\frac{1}{2}r -\frac{\sqrt{3}}{6}s + \frac{1}{3}\right) \frac{\zeta+1}{2}\\
\\
\displaystyle L_6(r,s,\zeta)=\left( \frac{\sqrt{3}}{3}s + \frac{1}{3}\right) \frac{\zeta+1}{2}\\
\end{array}
\end{equation}
\\
One can use these nodal functions to calculate the function $\varphi$:

\begin{equation}
\varphi(r,s)=
\left\lbrace
\begin{array}{l}
\displaystyle x=\sum_{i=1}^6 x_i L_i(r,s,\zeta)\\
\\
\displaystyle y=\sum_{i=1}^6 y_i L_i(r,s,\zeta)\\
\\
\displaystyle z=\sum_{i=1}^6 z_i L_i(r,s,\zeta)\\
\end{array}
\right.
\end{equation}
For example, the first component of $\varphi(r,s,\zeta)$ is:
\begin{multline*}
\varphi_x(r,s,t)=
\frac{1}{6}\left( x_1+x_2+x_3+x_4+x_5+x_6 \right)
+ \frac{1}{4}\left( -x_1+x_2-x_4+x_5 \right) r \\
+ \frac{\sqrt{3}}{12} \left( -x_1-x_2+2 x_3- x_4- x_5+ 2 x_6 \right)s
+ \frac{1}{6}\left( -x_1-x_2-x_3+x_4+x_5+x_6 \right)\zeta\\ 
+ \frac{1}{4}\left( x_1-x_2-x_4+x_5 \right) r\zeta
+ \frac{\sqrt{3}}{12} \left( x_1+x_2- 2 x_3- x_4- x_5+2 x_6 \right)s\zeta\\ 
\end{multline*}
\\
The 2 other components have exactly the same equation, except the the $x_i$ must be replaced by in turn $y_i$ and $z_i$.
The Jacobian of the  $\varphi$ function is now easily computable:

\begin{equation}
J=
\left[
\begin{array}{c c c}
\displaystyle 
\frac{\partial \varphi_x }{\partial r} & \displaystyle  \frac{\partial \varphi_x }{\partial s} &  \displaystyle  \frac{\partial \varphi_x }{\partial \zeta} \\
\\
\displaystyle 
\frac{\partial \varphi_y }{\partial r} & \displaystyle  \frac{\partial \varphi_y }{\partial s} &  \displaystyle  \frac{\partial \varphi_y }{\partial \zeta}  \\
\\
\displaystyle 
\frac{\partial \varphi_z }{\partial r} & \displaystyle  \frac{\partial \varphi_z }{\partial s} &  \displaystyle  \frac{\partial \varphi_z }{\partial \zeta}  \\
\end{array}
\right]
\end{equation}
\\
with:
\begin{equation*}
\begin{array}{c l}
\displaystyle 
J_{11}= &  \displaystyle 
 \frac{1}{4}\left( -x_1+x_2-x_4+x_5 \right)+ \frac{1}{4}\left( x_1-x_2-x_4+x_5 \right) \zeta \\
\\
J_{21}= &  \displaystyle 
 \frac{1}{4}\left( -y_1+y_2-y_4+y_5 \right)+ \frac{1}{4}\left( y_1-y_2-y_4+y_5 \right) \zeta \\
\\
J_{31}= &    \displaystyle 
 \frac{1}{4}\left( -z_1+z_2-z_4+z_5 \right)+ \frac{1}{4}\left( z_1-z_2-z_4+z_5 \right) \zeta \\
\end{array}
\end{equation*}
\begin{equation}
\begin{array}{c l}
J_{12}= &  \displaystyle  
\frac{\sqrt{3}}{12} \left( -x_1-x_2+2 x_3- x_4- x_5+ 2 x_6 \right)+ \frac{\sqrt{3}}{12} \left( x_1+x_2- 2 x_3- x_4- x_5+2 x_6 \right)\zeta\\
\\
J_{22}= &  \displaystyle 
\frac{\sqrt{3}}{12} \left( -y_1-y_2+2 y_3- y_4- y_5+ 2 y_6 \right)+ \frac{\sqrt{3}}{12} \left( y_1+y_2- 2 y_3- y_4- y_5+2 y_6 \right)\zeta\\
\\
J_{32}= &  \displaystyle 
\frac{\sqrt{3}}{12} \left( -z_1-z_2+2 z_3- z_4- z_5+ 2 z_6 \right)+ \frac{\sqrt{3}}{12} \left( z_1+z_2 - 2 z_3- z_4- z_5+2 z_6 \right)\zeta\\
\end{array}
\end{equation}
\begin{equation*}
\begin{array}{c l}
J_{13}= &  \displaystyle  
\frac{1}{4}\left( x_1-x_2-x_4+x_5 \right) r
+ \frac{\sqrt{3}}{12} \left( x_1+x_2- 2 x_3- x_4- x_5+2 x_6 \right)s
+ \frac{1}{6}\left( -x_1-x_2-x_3+x_4+x_5+x_6 \right)\\ 
\\
J_{32}= &  \displaystyle 
\frac{1}{4}\left( y_1-y_2-y_4+y_5 \right) r
+ \frac{\sqrt{3}}{12} \left( y_1+y_2- 2 y_3- y_4- y_5+2 y_6 \right)s
+ \frac{1}{6}\left( -y_1-y_2-y_3+y_4+y_5+y_6 \right)\\ 
\\
J_{33}= &  \displaystyle 
\frac{1}{4}\left( z_1-z_2-z_4+z_5 \right) r
+ \frac{\sqrt{3}}{12} \left( z_1+z_2- 2 z_3- z_4- z_5+2 z_6 \right)s
+ \frac{1}{6}\left( -z_1-z_2-z_3+z_4+z_5+z_6 \right)\\ 
\\
\end{array}
\end{equation*}
\newpage
	\section{MINI element}
\label{MINI}   
\begin{figure}[H]
\begin{center}
\includegraphics[width=8cm]{MINI.png}
\caption{MINI element}
\end{center}
\end{figure}
The MINI element is an extruded triangular element with continuous velocity and pressure approximations. Introduced by Arnold et al. (1984), the MINI element
satisfies the LLB conditions (Ladyzhenskaya-Babuska-Brezzi, See Nowicki \cite{Nowicki2007} for more details), and therefore results in stable velocities and pressure.\\
\\
The MINI element is based on a extruded straight-sided triangular element (called P1-P1), which has a node at each vertex. In the MINI element, the pressure and velocity are approximated via

\begin{equation}
\begin{array}{r c l}
P\left(x,y,z \right)  & = & \displaystyle \sum_{i=1}^6 P_j \phi_j\left(x,y,z \right) \\
\\
u\left(x,y,z \right)  & = & \displaystyle \sum_{i=1}^6 u_j \phi_j\left(x,y,z \right) +u_b \phi_b\left(x,y,z \right)  \\
\\
v\left(x,y,z \right)  & = & \displaystyle \sum_{i=1}^6 v_j \phi_j\left(x,y,z \right) +v_b \phi_b\left(x,y,z \right)  \\
\\
w\left(x,y,z \right)  & = & \displaystyle \sum_{i=1}^6 w_j \phi_j\left(x,y,z \right) +w_b \phi_b\left(x,y,z \right)
\end{array}
\end{equation}
\\
The $\phi_j$ functions has the same shape as in the pentahedron (\ref{RE3D}). Therefore, the transformation $\varphi$ that transforms the reference element to the element $E$ has exactly the same shape as inthe previous section (\ref{RE3D}).\\
\\
The nodal function $ \phi_b\left(x,y,z \right)$ is called bubble function. According to Nowicki \cite{Nowicki2007} and Guillem \cite{Guillen2005}, the bubble shape function in a reference element $ L_b\left(x,y,z \right)$ is:

\begin{equation}
L_b\left(x,y,z \right)=27\left( -\frac{1}{2}r -\frac{\sqrt{3}}{6}s + \frac{1}{3}\right)\left(\frac{1}{2}r -\frac{\sqrt{3}}{6}s + \frac{1}{3}\right)\left( \frac{\sqrt{3}}{3}s + \frac{1}{3}\right)\left( \zeta+1\right)\left(1- \zeta\right)
\end{equation}
\\
$ \phi_b\left(x,y,z \right)$ is equal to 1 at the center of the element (due to the factor $27$), and vanishes at the element boundary.

\newpage




\chapter{Parameters and constants}

\begin{center}
\begin{longtable}{l l l l}
\hline
\hline
\multicolumn{1}{c}{Parameter} & \multicolumn{1}{c}{Symbol} & \multicolumn{1}{c}{Unit} & \multicolumn{1}{c}{Value}\\
\hline
\\
Glacier's lower surface z-coordinate & $b$ & m &\\
Glen's flow law viscosity parameter & $B$ & MPa a\textsuperscript{1/n}\\
Ice specific heat capacity & $c$ & J kg\textsuperscript{-1} K\textsuperscript{-1}  & 2093\\
Mixed layer specific heat & $c_{pM}$ & J kg\textsuperscript{-1} K\textsuperscript{-1}  & 3974\\
Acceleration due to gravity & $g$ & m s\textsuperscript{-1} & 9.81\\
Geothermal heat flux & $G$ & W m\textsuperscript{-2} & $\sim$0.05\\
Glacier's Height &$H$ & m &\\
Ice thermal conductivity & $k$ & W m\textsuperscript{-1} K\textsuperscript{-1} & 2.4\\
Basal drag parameter & $K$ & Pa\textsuperscript{$\frac{1-r}{2}$} s\textsuperscript{$\frac{s}{2}$} m\textsuperscript{$-\frac{s}{2}$} &\\
Ice specific latent heat of fusion & $L$ & J kg\textsuperscript{-1} & 3.34 $\times$ 10\textsuperscript{5}\\
Mass production term ($m/a$ ice equivalent) & $\dot{M}$ & m a\textsuperscript{-1} &\\
Melting ($m/a$ ice equivalent) & $\dot{M}_b$ & m a\textsuperscript{-1} &\\
Accumulation ($m/a$ ice equivalent) & $\dot{M}_s$ & m a\textsuperscript{-1} &\\
Glen's flow law exponent & $n$ & dimensionless\\
Normal vector x-component & $n_x$ & dimensionless &\\
Normal vector y-component & $n_y$ & dimensionless &\\
Normal vector z-component & $n_z$ & dimensionless &\\
Normal vector pointing outward from the galcier & $\overrightarrow{n}$ & dimensionless &\\
Effective pressure & $N_{eff}$ & Pa &\\
Basal drag first exponent & $p$ & dimensionless &\\
Ice pressure & $P$ & Pa &\\
Atmosphere pressure & $P_{air}$ & Pa &\\
Water pressure & $P_w$ & Pa &\\
Basal drag second exponent & $q$ & dimensionless &\\
Glacier's upper surface z-coordinate & $s$ & m &\\
Ice temperature & $T$ & K &\\
Glacier base temperature & $T_{b}$ & K &\\
Pressure melting point & $T_{pmp}$ & K &\\
Ice velocity x-component& $u$ & m s\textsuperscript{-1} &\\
Depth averaged ice velocity x-component& $\overline{u}$ & m s\textsuperscript{-1} &\\
Basal velocity x-component& $u_b$ & m s\textsuperscript{-1} &\\
Basal velocity parallel to the bedrock surface & $\overrightarrow{u_b}$ & m s\textsuperscript{-1} &\\
Ice velocity y-component& $v$ & m s\textsuperscript{-1} &\\
Depth averaged ice velocity y-component& $\overline{v}$ & m s\textsuperscript{-1} &\\
Basal velocity y-component& $v_b$ & m s\textsuperscript{-1} &\\
Ice velocity &$\overrightarrow{v}$ & m s\textsuperscript{-1}  &\\
Ice velocity z-component& $w$ & m s\textsuperscript{-1} &\\
Basal velocity z-component& $w_b$ & m s\textsuperscript{-1} &\\
First horizontal coordinate & $x$ & m &\\
Second horizontal coordinate & $y$ & m &\\
Vertical coordinate & $z$ & m &\\
Rate of change of melting point with pressure & $\beta$ & K Pa\textsuperscript{-1} & 9.8 $\times$ 10\textsuperscript{-8}\\
Thermal exchange velocity & $\gamma$ & m s\textsuperscript{-1} & $\sim$1.00 $\times$ 10\textsuperscript{-4}\\
Strain tensor & $\varepsilon$ & dimensionless &\\
Strain rate tensor & $\dot{\varepsilon}$ & s\textsuperscript{-1} &\\
Effective strain rate tensor & $\dot{\varepsilon}_e $ & s\textsuperscript{-1} &\\
Ice viscosity & $\mu$ & Pa s &\\
Viscous heating & $\Phi$ & W m\textsuperscript{-3} &\\
Ice density & $\rho$ & kg m\textsuperscript{-3} & 916\\
Ice density & $\rho_i$ & kg m\textsuperscript{-3} & 916\\
Water density & $\rho_w$ & kg m\textsuperscript{-3} & 1000\\
Stress tensor & $\sigma$ & Pa &\\
Deviatoric stress tensor & $\sigma'$ & Pa &\\
Effective shear stress & $\sigma_e$ & Pa &\\
Friction stress & $\overrightarrow{\tau_b}$ & Pa &\\
\hline
\end{longtable}
\end{center}




















\newpage
\begin{thebibliography}{99}

\bibitem{Glen1955} \textsc{Glen} J. W.,\newblock \emph{The creep of polycrystalline ice}.  \newblock Proceedings of the Royal Society, London, 1955.
  
\bibitem{Guillen2005} \textsc{Guill\'en-Gonz\`alez} F., \textsc{Rodr\'iguez-G\'omez} D., \newblock \emph{Bubble finite elements for the primitive
equations of the ocean}, Numerische Mathematik 101: 689-728, 2005.

\bibitem{Holland1999} \textsc{Holland} D.M., \textsc{Jenkins} A., \newblock \emph{Modeling Thermodynamic Ice-Ocean Interactions at the Base of an Ice Shelf}.  \newblock J. Phys. Oceanogr., 29, 1787-1800, 1999.

\bibitem{Hooke2005} \textsc{Hooke} Roger LeB.,  \newblock \emph{Principles of Glacier Mechanics}.  \newblock 2d                                                                                                  		Edition,Cambridge University Press, 2005.

\bibitem{Hulbe1999} \textsc{Hulbe}, Christina L., \textsc{MacAyeal} Douglas  \newblock \emph{A new numerical model of coupled inland ice sheet, ice stream, and ice shelf flow and its application to the West Antarctique Ice Sheet}.  \newblock Journal of Geophysical Research, vol 104, B11, pages 25,349-25,366, November 10th, 1999.                                                                                                  		

\bibitem{Larour2005} \textsc{Larour} \'Eric,  \newblock \emph{Mod\'elisation numerique du comportement des banquises 			flottantes, valid\'ee par imagerie satellitaire}.  \newblock Th\`ese de l'\'ecole doctorale de l'\'Ecole Centrale Paris, 2005.

\bibitem{Macayeal1989} \textsc{MacAyeal} Douglas R.,  \newblock \emph{Large-scale Ice Flow Over a Viscous Basal Sediment: Theory and Application 
}.  \newblock Journal of Geophysical Research-Solid Earth and Planets, 1989.

\bibitem{Macayeal1997} \textsc{MacAyeal} Douglas R.,  \newblock \emph{EISMINT: Lessons in Ice-Sheet Modelling
}. 21st May 1997.\\ \url{http://homepages.vub.ac.be/~phuybrec/pdf/MacAyeal.lessons.pdf}

\bibitem{Nowicki2007} \textsc{Nowicki} Sophie M. J.,  \newblock \emph{Modelling the transition zone of marine ice sheets}, PhD Thesis of University College London, Centre for Polar Observation and Modelling Department of Space and Climate Physics, September 2007.

\bibitem{Paterson1994} \textsc{Paterson} W. S. B.,  \newblock \emph{The Physics of glaciers}.  \newblock 3ieme 			Edition, Butterworth Heinemann, 1994.

\bibitem{Pattyn2003} \textsc{Pattyn} F., \newblock \emph{A new three-dimensional higher-order thermomechanical ice sheet model: basic sensitivity, ice stream development and ice flow across subglacial lakes} \newblock Journal of Geophysical Research (Solid Earth), 2003

\bibitem{Wriggers2002} \textsc{Wriggers} P., \newblock \emph{Computational Contact Mechanics} \newblock Springers 2d edition, 2002

\bibitem{Zienkiewicz1994} \textsc{Zienkiewicz}, O.C. and \textsc{Taylor} R.L., \newblock \emph{The Finite Element Method} \newblock Fourth
Edition. McGraw-Hill Book Company Europe. Berkshire England., 1994.
\end{thebibliography}
\end{document}
