1 


2 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
3 
% 
% 
4 
% Copyright (c) 20032008 by University of Queensland 
% Copyright (c) 20032009 by University of Queensland 
5 
% Earth Systems Science Computational Center (ESSCC) 
% Earth Systems Science Computational Center (ESSCC) 
6 
% http://www.uq.edu.au/esscc 
% http://www.uq.edu.au/esscc 
7 
% 
% 
24 
% 
% 
25 
\begin{figure} 
\begin{figure} 
26 
\center 
\center 
27 
\scalebox{0.7}{\includegraphics{figures/unitcircle.eps}} 
\scalebox{0.8}{\includegraphics{figures/unitcircle}} 
28 
\caption{Implicit representation of the curve $x^2 + y^2 = 1$.} 
\caption{Implicit representation of the curve $x^2 + y^2 = 1$.} 
29 
\label{UNITCIRCLE} 
\label{UNITCIRCLE} 
30 
\end{figure} 
\end{figure} 
95 
%\label{GENERAL NAVIER STOKES} 
%\label{GENERAL NAVIER STOKES} 
96 
%\end{equation} 
%\end{equation} 
97 
% 
% 
98 
5with the incompressibility condition 
%with the incompressibility condition 
99 
% 
% 
100 
%\begin{equation} 
%\begin{equation} 
101 
%\nabla \cdot \vec{v} = 0. 
%\nabla \cdot \vec{v} = 0. 
110 
%\label{GENERAL NAVIER STOKES COM} 
%\label{GENERAL NAVIER STOKES COM} 
111 
%\end{equation} 
%\end{equation} 
112 
% 
% 
113 
5with the incompressibility condition 
%with the incompressibility condition 
114 
% 
% 
115 
%\begin{equation} 
%\begin{equation} 
116 
%v\hackscore{i,i} = 0. 
%v\hackscore{i,i} = 0. 
124 
%\label{STRESS} 
%\label{STRESS} 
125 
%\end{equation} 
%\end{equation} 
126 
% 
% 
127 
5where the deviatoric stretching $D^{'}\hackscore{ij}$ is defined as 
%where the deviatoric stretching $D^{'}\hackscore{ij}$ is defined as 
128 
% 
% 
129 
%\begin{equation} 
%\begin{equation} 
130 
%D^{'}\hackscore{ij} = D^{'}\hackscore{ij}  \frac{1}{3}D\hackscore{kk}\delta\hackscore{ij}. 
%D^{'}\hackscore{ij} = D^{'}\hackscore{ij}  \frac{1}{3}D\hackscore{kk}\delta\hackscore{ij}. 
199 
\label{REINITIAL CONVERGE} 
\label{REINITIAL CONVERGE} 
200 
\end{equation} 
\end{equation} 
201 
% 
% 
202 
where $\epsilon$ is the convergence tolerance. Normally, the reinitialization procedure is performed every third timestep of solving the Stokes equation. 
where $\epsilon \hackscore{\psi}$ is the convergence tolerance. Normally, the reinitialization procedure is performed every third timestep of solving the Stokes equation. 
203 


204 
The midpoint technique works provided that the lefthand side of Equations (\ref{REINITIAL MIDPOINT2}) and (\ref{REINITIAL MIDPOINT3}) is a lumped mass matrix. Alternatively, for a onestep procedure, the reinitialization equation can be given by: 
The midpoint technique works provided that the lefthand side of Equations (\ref{REINITIAL MIDPOINT2}) and (\ref{REINITIAL MIDPOINT3}) is a lumped mass matrix. Alternatively, for a onestep procedure, the reinitialization equation can be given by: 
205 
% 
% 
212 
% 
% 
213 
\begin{figure} 
\begin{figure} 
214 
\center 
\center 
215 
\scalebox{0.45}{\includegraphics{figures/LevelSetFlowChart.eps}} 
\scalebox{0.5}{\includegraphics{figures/LevelSetFlowChart}} 
216 
\caption{Flow chart of level set procedure \cite{LIN2005}.} 
\caption{Flow chart of Level Set Method procedure \cite{LIN2005}.} 
217 
\label{LEVELSET FLOWCHART} 
\label{LEVELSET FLOWCHART} 
218 
\end{figure} 
\end{figure} 
219 
% 
% 
247 
% 
% 
248 
\begin{figure} 
\begin{figure} 
249 
\center 
\center 
250 
\scalebox{0.7}{\includegraphics{figures/RT2Dsetup.eps}} 
\scalebox{0.7}{\includegraphics{figures/RT2Dsetup}} 
251 
\caption{Parameters, initial interface and boundary conditions for the RayleighTaylor instability problem. The interface is defined as $\phi=0.02cos(\frac{\pi x}{\lambda}) + 0.2$. The fluids have been assigned different densities and equal viscosity (isoviscous) \cite{BOURGOUIN2006}.} 
\caption{Parameters, initial interface and boundary conditions for the RayleighTaylor instability problem. The interface is defined as $\phi=0.02cos(\frac{\pi x}{\lambda}) + 0.2$. The fluids have been assigned different densities and equal viscosity (isoviscous) \cite{BOURGOUIN2006}.} 
252 
\label{RT2DSETUP} 
\label{RT2DSETUP} 
253 
\end{figure} 
\end{figure} 
254 
% 
% 
255 
% 
% 
256 
The following python code is for the RayleighTaylor instability problem, which is available in the example directory as 'RT2D.py'. This script uses the 'StokesProblemCartesian' class for solving the Stokes equation, along with the incompressibility condition. A class called 'LevelSet' is also used, which performs the advection and reinitialization procedures to track the movement of the interface of the fluids. The details and use of these classes are described in Chapter \ref{MODELS CHAPTER} (Models Chapter). 
The following PYTHON code is for the RayleighTaylor instability problem, which is available in the example directory as 'RT2D.py'. This script uses the 'StokesProblemCartesian' class for solving the Stokes equation, along with the incompressibility condition. A class called 'LevelSet' is also used, which performs the advection and reinitialization procedures to track the movement of the interface of the fluids. The details and use of these classes are described in Chapter \ref{MODELS CHAPTER} (Models Chapter). 
257 


258 
The script starts off by importing the necessary classes. The physical properties of the two fluids are defined, such as density and viscosity. Acceleration due to gravity is taken as 10.0 $ms^{2}$. Solver settings are set for solving the Stokes problem, with the number of timesteps, solver tolerance, maximum solver iterations, and the option to use the Uzawa scheme or not; the default solver is the PCG solver. A regular mesh is defined with 200$\times$200 elements. Level set parameters are set for the reinitialization procedure, such as the convergence tolerance, number of reinitialization steps, the frequency of the reinitialization, for example, every third timestep, and the smoothing parameter to smooth the physical properties across the interface. A noslip boundary condition is set for the top and bottom of the domain, while on the left and righthand sides there is a slip condition. The initial interface between the two fluids is defined as in Figure \ref{RT2DSETUP}. Instances of the StokesProblemCartesian and LevelSet class are created. The iteration throughout the timesteps involves the update of the physical parameters of the fluids; the initialization of the boundary conditions, viscosity, and body forces; the solving of the Stokes problem for velocity and pressure; then the level set procedure. The output of the level set function, velocity and pressure is saved to file. The timestep size is selected based on the Courant condition. The simulation may take a long time to complete on a desktop computer due to the number of elements, so it is recommended to run it on the super computer. 
The script starts off by importing the necessary classes. The physical properties of the two fluids are defined, such as density and viscosity. Acceleration due to gravity is taken as 10.0 $ms^{2}$. Solver settings are set for solving the Stokes problem, with the number of timesteps, solver tolerance, maximum solver iterations, and the option to use the Uzawa scheme or not; the default solver is the PCG solver. A regular mesh is defined with 200$\times$200 elements. Level set parameters are set for the reinitialization procedure, such as the convergence tolerance, number of reinitialization steps, the frequency of the reinitialization, for example, every third timestep, and the smoothing parameter to smooth the physical properties across the interface. A noslip boundary condition is set for the top and bottom of the domain, while on the left and righthand sides there is a slip condition. The initial interface between the two fluids is defined as in Figure \ref{RT2DSETUP}. Instances of the StokesProblemCartesian and LevelSet class are created. The iteration throughout the timesteps involves the update of the physical parameters of the fluids; the initialization of the boundary conditions, viscosity, and body forces; the solving of the Stokes problem for velocity and pressure; then the level set procedure. The output of the level set function, velocity and pressure is saved to file. The timestep size is selected based on the Courant condition. Due to the number of elements in the computational mesh, the simulation may take a long time to complete on a desktop computer, so it is recommended to run it on the super computer. At present, the fine mesh is required to capture the details of the fluid motion and for numerical stability. 
259 
% 
% 
260 
\begin{python} 
\begin{python} 
261 


304 
#boundary conditions 
#boundary conditions 
305 
x = mesh.getX() 
x = mesh.getX() 
306 
#left + bottom + right + top 
#left + bottom + right + top 
307 
b_c = whereZero(x[0])*[1.0,0.0] + whereZero(x[1])*[1.0,1.0] + whereZero(x[0]l0)*[1.0,0.0] + whereZero(x[1]l1)*[1.0,1.0] 
b_c = whereZero(x[0])*[1.0,0.0] + whereZero(x[1])*[1.0,1.0] + whereZero(x[0]l0)*[1.0,0.0] \ 
308 

+ whereZero(x[1]l1)*[1.0,1.0] 
309 


310 
velocity = Vector(0.0, ContinuousFunction(mesh)) 
velocity = Vector(0.0, ContinuousFunction(mesh)) 
311 
pressure = Scalar(0.0, ContinuousFunction(mesh)) 
pressure = Scalar(0.0, ContinuousFunction(mesh)) 
336 
#get velocity and pressure of fluid 
#get velocity and pressure of fluid 
337 
Y[1] = rho*g 
Y[1] = rho*g 
338 
solution.initialize(fixed_u_mask=b_c,eta=eta,f=Y) 
solution.initialize(fixed_u_mask=b_c,eta=eta,f=Y) 
339 
velocity,pressure=solution.solve(velocity,pressure,max_iter=max_iter,verbose=verbose,useUzawa=useUzawa) 
velocity,pressure=solution.solve(velocity,pressure,max_iter=max_iter,verbose=verbose, \ 
340 

useUzawa=useUzawa) 
341 


342 
#update the interface 
#update the interface 
343 
func = levelset.update_phi(velocity, dt, t_step) 
func = levelset.update_phi(velocity, dt, t_step) 
367 
The simulation output is shown in Figures \ref{RT2D OUTPUT1} and \ref{RT2D OUTPUT1} showing the progression of the interface of the two fluids. A diapir can be seen rising on the lefthand side of the domain, and then later on, a second one rises on the righthand side. 
The simulation output is shown in Figures \ref{RT2D OUTPUT1} and \ref{RT2D OUTPUT1} showing the progression of the interface of the two fluids. A diapir can be seen rising on the lefthand side of the domain, and then later on, a second one rises on the righthand side. 
368 
\begin{figure} 
\begin{figure} 
369 
\center 
\center 
370 
\subfigure[t=300]{\label{RT OUTPUT300}\includegraphics[scale=0.252]{figures/RT2D200by200t300.eps}} 
\subfigure[t=300]{\label{RT OUTPUT300}\includegraphics[scale=0.252]{figures/RT2D200by200t300}} 
371 
\subfigure[t=600]{\label{RT OUTPUT600}\includegraphics[scale=0.252]{figures/RT2D200by200t600.eps}} 
\subfigure[t=600]{\label{RT OUTPUT600}\includegraphics[scale=0.252]{figures/RT2D200by200t600}} 
372 
\subfigure[t=900]{\label{RT OUTPUT900}\includegraphics[scale=0.252]{figures/RT2D200by200t900.eps}} 
\subfigure[t=900]{\label{RT OUTPUT900}\includegraphics[scale=0.252]{figures/RT2D200by200t900}} 
373 
\subfigure[t=1200]{\label{RT OUTPUT1200}\includegraphics[scale=0.252]{figures/RT2D200by200t1200.eps}} 
\subfigure[t=1200]{\label{RT OUTPUT1200}\includegraphics[scale=0.252]{figures/RT2D200by200t1200}} 
374 
\caption{Simulation output of RayleighTaylor instability, showing the movement of the interface of the fluids. The contour line represents the interface between the two fluids; the zero contour of the level set function. Velocity vectors are displayed showing the flow field. Computational mesh used was 200$\times$200 elements.} 
\caption{Simulation output of RayleighTaylor instability, showing the movement of the interface of the fluids. The contour line represents the interface between the two fluids; the zero contour of the Level Set function. Velocity vectors are displayed showing the flow field. Computational mesh used was 200$\times$200 elements.} 
375 
\label{RT2D OUTPUT1} 
\label{RT2D OUTPUT1} 
376 
\end{figure} 
\end{figure} 
377 
% 
% 
378 
\begin{figure} 
\begin{figure} 
379 
\center 
\center 
380 
\subfigure[t=1500]{\label{RT OUTPUT1500}\includegraphics[scale=0.252]{figures/RT2D200by200t1500.eps}} 
\subfigure[t=1500]{\label{RT OUTPUT1500}\includegraphics[scale=0.252]{figures/RT2D200by200t1500}} 
381 
\subfigure[t=1800]{\label{RT OUTPUT1800}\includegraphics[scale=0.252]{figures/RT2D200by200t1800.eps}} 
\subfigure[t=1800]{\label{RT OUTPUT1800}\includegraphics[scale=0.252]{figures/RT2D200by200t1800}} 
382 
\caption{Simulation output of RayleighTaylor instability.} 
\caption{Simulation output of RayleighTaylor instability.} 
383 
\label{RT2D OUTPUT2} 
\label{RT2D OUTPUT2} 
384 
\end{figure} 
\end{figure} 