\documentclass{article}
\usepackage{amsmath}
\usepackage[mathletters]{ucs}
\usepackage[utf8x]{inputenc}
\setlength{\parindent}{0pt}
\setlength{\parskip}{6pt plus 2pt minus 1pt}
\usepackage{graphics}
\usepackage[ps,dvips,xdvi,arrow,frame,matrix,graph,curve,cmtip]{xy}
\usepackage[pdftex]{graphicx}

\usepackage[breaklinks=true]{hyperref}
\usepackage{enumerate}

\setcounter{secnumdepth}{0}
\title{Week 6 Progress Report}
\author{Abdulmajed Dakkak}
\date{July 18th, 2008}
\begin{document}
\maketitle

\section{Monday}

Got the FCHC program to work and explained how to split a CUDA
program to Professor Francis and Katie.

\subsection{Code}

\begin{itemize}
\item 
  FCHC (\href{code/fchc.m6/main.c}{.c},
  \href{code/fchc.m6.tar.gz}{xcode.tar.gz})
\end{itemize}
\section{Tuesday}

Fixed an embarrassing bug in the FCHC code (all the indecies were
off by one). Dr. Francis told me that there is no reason to pursue
FCHC anymore since it branches too much to be placed on a
\verb!SIMD! machine. It seemed like the project has ended and I had
to pick a new one, but after doing some more research I found a
different way of doing 3D fluid simulation using Cellular automata
--- the Lattice Boltzmann Method. The 3D version, namely D3Q19, is
used frequently to model free surfaces. The collision could also be
written using no \verb!if! statements, which makes it ideal for
\verb!CUDA!.

The only disadvantage of LBM is that while it can be thought of as
an extension of Lattice Gases and uses CA as its basis, its
detached for the CA.

\subsection{Code}

\begin{itemize}
\item 
  \href{code/fchc.t6.c}{FCHC.c} (fixed)
\item 
  \href{code/d2q9.c}{D2Q9.c}
\end{itemize}
\section{Wednesday}

Started implementing \verb!D2Q9!, and by the middle of the day I
had something working, but blew up to infinity after a few time
steps. I spent the rest of the day debugging the code.

\section{Thursday}

Read a bit about adaptive time stepping and wrote some
\href{code/d2q9-adaptive-time.c}{code} to perform it, but quickly
realized that the paper I was looking at did not define what mass
is, and I did not know. The paper defined mass based on density,
and density based on mass, and while density makes sense to define,
mass was not. Just before the visit to Wolfram, I did get the
\verb!d2q9! code to work. The problem with going to infinity was
because the equations will blow up if any of the velocity vectors
in the cell exceed $\frac{1}{3}$. After setting the initial vectors
to $\frac{1}{3}$ and disallowing any vectors to grow over
$\frac{1}{3}$, the system works.

The visit to Wolfram was helpful, and he gave me good advice. It
seems that only one things was of interest to him, however, and
that is CUDA. I described what CUDA is to him, and what work I have
been doing. Wolfram said that the best experiment to do is to use
FHP and have a system where there are no random choices and only a
cylinder as an obstacle. It seems like he wants to see whether
turbulence occurs because of the obstacle. He said that there are
three scientific camps each believing they know the cause of the
turbulence (which is not predicted by the Navier-Stokes
equations):

\begin{enumerate}[1.]
\item 
  The molecular dynamics at the atomics level are noticeable at the
  fluids level and that is the cause of the turbulence.
\item 
  The initial conditions are the cause of the turbulence. This is the
  Chaos camp that believes that small variations of the initial
  conditions have a grave impact on the final outcome.
\item 
  The cellular automata view, which he advocates, is that randomness
  can grow out of a deterministic system (I did not understand this
  point as I did for the other two).
\end{enumerate}
He says that while some work has been done in the early 90s to show
that his theory works (citing an example where scientists found a
periodicity of 2 hours in the turbulence of liquid nitrogen), the
work of lattice gases has faded.

While it is clear that he values lattice gases over lattice
Boltzmann, he did offer a compelling argument to use LGCA and that
is that whatever outcome is produced is due to molecular
interaction --- no scientist will blame error on numerical
inaccuracies. He mentioned that turbulence was for many years
regarded as an numerical error in computation fluid dynamics, but
he showed that it wasn't.

He did mention that he worked on a 3D version of LGCA and that it
is simple to derive a boolean expression for it, but I have yet to
find a paper describing anything but FCHC for 3D LGCA.

After getting the advice from Wolfram, and two copies of the
periodic table poster, I went home to sleep. After 2 hours of
attempting to sleep, I figured out how to place obstacles in my
\verb!d2q9! program and how to perform collisions. I quickly wrote
the program down, and it worked.

\subsection{Code}

\begin{itemize}
\item 
  \href{code/d2q9.c}{D2Q9.c}
\end{itemize}
\section{Friday}

Starting placing the \verb!d2q9! in CUDA. While this process is
trivial, there are many nuances one has to deal with. First, one
has to identify which part of the program must be parallelize ---
the collision and propagation in my case. Second, one must flatten
the array --- 3D in my case. Finally, one must copy the data from
the CPU to the GPU correctly and have optimization in mind from the
beginning --- placing unchanging data in constant cached memory. I
spent 2 hours to get the function parallelize, the arrays
flattened, and the constant data into cache. While the program does
not work correctly, it does compile. A few hours were then spent
teaching Katie how to parallelize the Mandelbrot set.

\subsection{Code}

\begin{itemize}
\item 
  \href{code/lbm-d2q9}{d2q9-cuda}(\href{code/lbm-d2q9.tar.gz}{tar.gz})
\end{itemize}
\end{document}
