\documentclass{article}
\textwidth 6.5in
\oddsidemargin 0in
\evensidemargin 0in

\def\dx2i {\frac{1}{\left(\Delta x\right)^2}}
\def\dy2i {\frac{1}{\left(\Delta y\right)^2}}
\def\dz2i {\frac{1}{\left(\Delta z\right)^2}}

\def\nx {\mathrm{nx}}
\def\ny {\mathrm{ny}}
\def\nz {\mathrm{nz}}

\def\cc {\mathrm{cc}_{ijk}}
\def\ce {\mathrm{ce}_{ijk}}
\def\cw {\mathrm{cw}_{ijk}}
\def\cn {\mathrm{cn}_{ijk}}
\def\cs {\mathrm{cs}_{ijk}}
\def\ct {\mathrm{ct}_{ijk}}
\def\cb {\mathrm{cb}_{ijk}}
\def\rhs {\mathrm{rhs}_{ijk}}

\begin{document}

\title{Laplace3D}
\author{Karen Camarda}
\date{January 18, 2001}
\maketitle

\abstract{}

\section{Purpose}

\section{The equation being solved}
This thorn solves Laplace's equation
\begin{equation}
\nabla^2 u = 0.
\end{equation}
In the three-dimensional Cartesian coordinates employed
in this thorn, this equation takes the form
\begin{equation}
\frac{\partial^2 u}{\partial x^2} +
\frac{\partial^2 u}{\partial y^2} +
\frac{\partial^2 u}{\partial z^2} = 0.
\end{equation}

We solve this equation numerically using CG...

\section{Numerical Methods}

\section{Appendix: Coding of boundary conditions for CG}

The equation
\begin{equation}
\cc u_{ijk} +
\ce u_{i+1,jk} +
\cw u_{i-1,jk} +
\cn u_{i,j+1,k} +
\cs u_{i,j-1,k} +
\ct u_{ij,k+1} +
\cb u_{ij,k-1} = \rhs
\end{equation}
is valid for the interior points of the computational domain. In C these points
are given by the indices
\begin{eqnarray}
1 \le i < \nx-1 \\
1 \le j < \ny-1 \\
1 \le k < \nz-1
\end{eqnarray}
We incorporate the boundary conditions by adjusting the stencil coefficients
next to the boundary in such a way as to eliminate the boundary points from
the computation.

\subsection{Dirichlet}
% Case 1
$i=1$, $j=1$, $k=1$:
\begin{eqnarray}
\rhs &=& \rhs - \cw u_{0jk} - \cs u_{i0k} - \cb u_{ij0} \\
\cw &=& 0 \\
\cs &=& 0 \\
\cb &=& 0
\end{eqnarray}

% Case 2
\noindent $2 \le i < \nx-2$, $j=1$, $k=1$:
\begin{eqnarray}
\rhs &=& \rhs - \cs u_{i0k} - \cb u_{ij0} \\
\cs &=& 0 \\
\cb &=& 0
\end{eqnarray}

% Case 3
\noindent $i=\nx-2$, $j=1$, $k=1$:
\begin{eqnarray}
\rhs &=& \rhs - \ce u_{\nx-1,jk} - \cs u_{i0k} - \cb u_{ij0} \\
\ce &=& 0 \\
\cs &=& 0 \\
\cb &=& 0
\end{eqnarray}

% Case 4
\noindent $i=1$, $2 \le j < \ny-2$, $k=1$:
\begin{eqnarray}
\rhs &=& \rhs - \cw u_{0jk} - \cb u_{ij0} \\
\cw &=& 0 \\
\cb &=& 0
\end{eqnarray}

% Case 5
\noindent $2 \le i < \nx-2$, $2 \le j < \ny-2$, $k=1$:
\begin{eqnarray}
\rhs &=& \rhs - \cb u_{ij0} \\
\cb &=& 0
\end{eqnarray}

% Case 6
\noindent $i=\nx-2$, $2 \le j < \ny-2$, $k=1$:
\begin{eqnarray}
\rhs &=& \rhs - \ce u_{\nx-1,jk} - \cb u_{ij0} \\
\ce &=& 0 \\
\cb &=& 0
\end{eqnarray}

% Case 7
\noindent $i=1$, $j=\ny-2$, $k=1$:
\begin{eqnarray}
\rhs &=& \rhs - \cw u_{0jk} - \cn u_{i,\ny-1,k} - \cb u_{ij0} \\
\cw &=& 0 \\
\cn &=& 0 \\
\cb &=& 0
\end{eqnarray}

% Case 8
\noindent $2 \le i < \nx-2$, $j=\ny-2$, $k=1$:
\begin{eqnarray}
\rhs &=& \rhs - \cn u_{i,\ny-1,k} - \cb u_{ij0} \\
\cn &=& 0 \\
\cb &=& 0
\end{eqnarray}

% Case 9
\noindent $i=\nx-2$, $j=\ny-2$, $k=1$:
\begin{eqnarray}
\rhs &=& \rhs - \ce u_{\nx-1,jk} - \cn u_{i,\ny-1,k} - \cb u_{ij0} \\
\ce &=& 0 \\
\cn &=& 0 \\
\cb &=& 0
\end{eqnarray}

%Case 10
\noindent $i=1$, $j=1$, $2 \le k < \nz-2$:
\begin{eqnarray}
\rhs &=& \rhs - \cw u_{0jk} - \cs u_{i0k} \\
\cw &=& 0 \\
\cs &=& 0
\end{eqnarray}

% Case 11
\noindent $2 \le i < \nx-2$, $j=1$, $2 \le k < \nz-2$:
\begin{eqnarray}
\rhs &=& \rhs - \cs u_{i0k} \\
\cs &=& 0
\end{eqnarray}

% Case 12
\noindent $i=\nx-2$, $j=1$, $2 \le k < \nz-2$:
\begin{eqnarray}
\rhs &=& \rhs - \ce u_{\nx-1,jk} - \cs u_{i0k} \\
\ce &=& 0 \\
\cs &=& 0
\end{eqnarray}

% Case 13
\noindent $i=1$, $2 \le j < \ny-2$, $2 \le k < \nz-2$:
\begin{eqnarray}
\rhs &=& \rhs - \cw u_{0jk} \\
\cw &=& 0
\end{eqnarray}

% Case 14
% All points interior

% Case 15
\noindent $i=\nx-2$, $2 \le j < \ny-2$, $2 \le k < \nz-2$:
\begin{eqnarray}
\rhs &=& \rhs - \ce u_{\nx-1,jk} \\
\ce &=& 0
\end{eqnarray}

% Case 16
\noindent $i=1$, $j=\ny-2$, $2 \le k < \nz-2$:
\begin{eqnarray}
\rhs &=& \rhs - \cw u_{0jk} - \cn u_{i,\ny-1,k} \\
\cw &=& 0 \\
\cn &=& 0
\end{eqnarray}

% Case 17
\noindent $2 \le i < \nx-2$, $j=\ny-2$, $2 \le k < \nz-2$:
\begin{eqnarray}
\rhs &=& \rhs - \cn u_{i,\ny-1,k} \\
\cn &=& 0
\end{eqnarray}

% Case 18
\noindent $i=\nx-2$, $j=\ny-2$, $2 \le k < \nz-2$:
\begin{eqnarray}
\rhs &=& \rhs - \ce u_{\nx-1,jk} - \cn u_{i,\ny-1,k} \\
\ce &=& 0 \\
\cn &=& 0
\end{eqnarray}

% Case 19
\noindent $i=1$, $j=1$, $k=\nz-2$:
\begin{eqnarray}
\rhs &=& \rhs - \cw u_{0jk} - \cs u_{i0k} - \ct u_{ij,\nx-1} \\
\cw &=& 0 \\
\cs &=& 0 \\
\ct &=& 0
\end{eqnarray}

% Case 20
\noindent $2 \le i < \nx-2$, $j=1$, $k=\nz-2$:
\begin{eqnarray}
\rhs &=& \rhs - \cs u_{i0k} - \ct u_{ij,\nz-1} \\
\cs &=& 0 \\
\ct &=& 0
\end{eqnarray}

% Case 21
\noindent $i=\nx-2$, $j=1$, $k=\nz-2$:
\begin{eqnarray}
\rhs &=& \rhs - \ce u_{\nx-1,jk} - \cs u_{i0k} - \ct u_{ij,\nz-1} \\
\ce &=& 0 \\
\cs &=& 0 \\
\ct &=& 0
\end{eqnarray}

% Case 22
\noindent $i=1$, $2 \le j < \ny-2$, $k=\nz-2$:
\begin{eqnarray}
\rhs &=& \rhs - \cw u_{0jk} - \ct u_{ij,\nz-1} \\
\cw &=& 0 \\
\ct &=& 0
\end{eqnarray}

% Case 23
\noindent $2 \le i < \nx-2$, $2 \le j < \ny-2$, $k=\nz-2$:
\begin{eqnarray}
\rhs &=& \rhs - \ct u_{ij,\nz-1} \\
\ct &=& 0
\end{eqnarray}

% Case 24
\noindent $i=\nx-2$, $2 \le j < \ny-2$, $k=\nz-2$:
\begin{eqnarray}
\rhs &=& \rhs - \ce u_{\nx-1,jk} - \ct u_{ij,\nz-1} \\
\ce &=& 0 \\
\ct &=& 0
\end{eqnarray}

% Case 25
\noindent $i=1$, $j=\ny-2$, $k=\nz-2$:
\begin{eqnarray}
\rhs &=& \rhs - \cw u_{0jk} - \cn u_{i,\ny-1,k} - \ct u_{ij,\nz-1} \\
\cw &=& 0 \\
\cn &=& 0 \\
\ct &=& 0
\end{eqnarray}

% Case 26
\noindent $2 \le i < \nx-2$, $j=\ny-2$, $k=\nz-2$:
\begin{eqnarray}
\rhs &=& \rhs - \cn u_{i,\ny-1,k} - \ct u_{ij,\nz-1} \\
\cn &=& 0 \\
\ct &=& 0
\end{eqnarray}

% Case 27
\noindent $i=\nx-2$, $j=\ny-2$, $k=\nz-2$:
\begin{eqnarray}
\rhs &=& \rhs - \ce u_{\nx-1,jk} - \cn u_{i,\ny-1,k} - \ct u_{ij,\nz-1} \\
\ce &=& 0 \\
\cn &=& 0 \\
\ct &=& 0
\end{eqnarray}

\begin{thebibliography}{10}

\bibitem{Press86}
W. H. Press, B. P. Flannery, S. A. Teukolsky, and W. T. Vetterling.
{\em Numerical Recipes}. Cambridge University Press, Cambridge, England, 1986.

\end{thebibliography}

\end{document}
