\documentclass{amsart}
\usepackage[margin=1in]{geometry}
\usepackage{underscore}
\date{Time-stamp: "ssa-discretization.tex, saved on Mon, Apr 18, 2011 at 12:16pm"}

% Read in formulas generated by Maxima:
\input{formulas.tex}

\begin{document}
\title{On computing coefficients in a discretization of SSA equations}
\author{C. Khroulev}
\maketitle

The SSA equations (ignoring basal drag) are
\begin{align}
-\left[ 2\bar\nu H\left( 2u_{x} + v_{y}\right)\right]_{x} - \left[\bar\nu
  H\left(u_{y}+v_{x} \right) \right]_{y} &= - \rho gH h_{x} \label{SSA1} \\
-\left[ \bar\nu H\left( u_{y} + v_{x} \right)\right]_{x} - \left[2\bar\nu
  H\left(u_{x}+2v_{y}  \right) \right]_{y} &= -\rho gH h_{y} \label{SSA2}
\end{align}

We use centered finite differences to create a discretization of these
equations. For outer derivatives, these differences are centered at the current
$(i,j)$ point and use staggered grid locations. Hence $\bar \nu H$ is evaluated on the staggered grid.

The one-sided differences below are, in fact, centered with the center at the
staggered grid location.

\medskip
The four terms of the discretization of left hand side of the \eqref{SSA1} are
given below\footnote{These formulas are not as pretty as they should be because
they are automatically generated using Maxima.}.
\begin{eqnarray*}
  \lhsI
\end{eqnarray*}

The discretization of the left hand side of \eqref{SSA2} is the sum of the following.
\begin{eqnarray*}
  \lhsII
\end{eqnarray*}

Here
\begin{itemize}
\item $w_{i+\frac12,j}$ is a constant equal to $1$ if the face at $(i+\frac12,j)$ is
  an interface between two ice-filled cells and $0$ if it is an interface
  between ice-filled and ice-free cells.

  This allows us to drop one of four terms in left hand sides of equations
  \eqref{SSA1} and \eqref{SSA2} to implement the calving front boundary
  condition.

\item $\delta_{+x}f_{i,j} = f_{i+1,j}-f_{i,j}$, $\delta_{-x}f_{i,j} =
  f_{i,j}-f_{i-1,j}$, and $\Delta_{x}f_{i,j} = f_{i+1,j}-f_{i-1,j}$, and
  similarly for $y$.
\item Note that the $y$-derivative at $(i+\frac12,j)$ is computed as the
  average of two centered differences using regular grid points.
\item $N := \bar \nu H$.
\item $c_{w}$ is the value of $N$ at the western face of the current cell;
  $c_{e}$, $c_{n}$ and $c_{s}$ are shortcuts for $N$ at the east, north and
  south faces.
\end{itemize}

The next issue we need to handle is the fact that at the ice front some values
used in the discretization above are not available. To resolve this, we rewrite
$\Delta_{x}f_{i,j}$ as $\Delta_{x}f_{i,j} = \delta_{+x}f_{i,j} +
\delta_{-x}f_{i,j}$ and add ``weights'' $w_{\cdot,\cdot}$:

\begin{equation}
  \label{eq:1}
  \Delta_{x}f_{i,j} = w_{i+\frac12,j}\delta_{+x}f_{i,j} + w_{i-\frac12,j}\delta_{-x}f_{i,j}
\end{equation}
where $w_{\cdot,\cdot}$ is defined above.

If one of $w_{\cdot,j}$ in equation \eqref{eq:1} is zero and another is one,
this centered difference becomes a one-sided one.

Now we can write a discretization that works both in the interior and at
the ice margin by ``switching'' from a second-order centered difference in the
interior to first-order, ice-inward one-sided differences at the margin.

This yields (for the left hand side of equation \eqref{SSA1}):
\begin{eqnarray*}
  \lhsIII
\end{eqnarray*}
which is almost incomprehensible.

\newpage
\section{Coefficients for the shelf interior (computed using Maxima)}
\label{sec:shelf-interior}

\begin{table}[h]
  \centering
  \begin{tabular}{r||c|c|c}
    \CUfirstInterior
  \end{tabular}
 \caption{$u$, first equation}
 \label{tab:u-interior-i}
\end{table}

\begin{table}[h]
  \centering
  \begin{tabular}{r||c|c|c}
    \CUsecondInterior
  \end{tabular}
 \caption{$u$, second equation}
 \label{tab:u-interior-ii}
\end{table}

\begin{table}[h]
  \centering
  \begin{tabular}{r||c|c|c}
    \CVfirstInterior
  \end{tabular}
 \caption{$v$, first equation}
 \label{tab:v-interior-i}
\end{table}

\begin{table}[h]
  \centering
  \begin{tabular}{r||c|c|c}
    \CVsecondInterior
  \end{tabular}
 \caption{$v$, second equation}
 \label{tab:v-interior-ii}
\end{table}

\newpage
\section{At the ice margin}
\label{sec:at-ice-margin}

\begin{table}[h]
  \centering
  \begin{tabular}{r||c|c|c}
    \CUfirstMargin
  \end{tabular}
 \caption{$u$, first equation}
 \label{tab:u-margin-i}
\end{table}

Unknown $u$ in the second equation:
\begin{eqnarray*}
  \CUsecondMargin
\end{eqnarray*}

\newpage

Unknown $v$ in the first equation:
\begin{eqnarray*}
  \CVfirstMargin
\end{eqnarray*}

\begin{table}[h]
  \centering
  \begin{tabular}{r||c|c|c}
    \CVsecondMargin
  \end{tabular}
 \caption{$v$, second equation}
 \label{tab:v-margin-ii}
\end{table}

\end{document}
