1 
ksteube 
1811 

2 


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
3 
lgraham 
1701 
% 
4 
ksteube 
1811 
% Copyright (c) 20032008 by University of Queensland 
5 


% Earth Systems Science Computational Center (ESSCC) 
6 


% http://www.uq.edu.au/esscc 
7 
lgraham 
1701 
% 
8 
ksteube 
1811 
% Primary Business: Queensland, Australia 
9 


% Licensed under the Open Software License version 3.0 
10 


% http://www.opensource.org/licenses/osl3.0.php 
11 
lgraham 
1701 
% 
12 
ksteube 
1811 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
13 
lgraham 
1701 

14 
ksteube 
1811 

15 
lgraham 
1701 
\section{RayleighTaylor Instability} 
16 


\label{LEVELSET CHAP} 
17 



18 
lgraham 
1973 
In this chapter we will implement the Level Set Method in Escript for tracking the interface between two fluids for Computational Fluid Dynamics (CFD). The method is tested with a RayleighTaylor Instability problem, which is an instability of the interface between two fluids with differing densities. \\ 
19 
lgraham 
1701 
Normally in Earth science problems two or more fluids in a system with different properties are of interest. For example, lava dome growth in volcanology, with the contrast of the two mediums as being lava and air. The interface between the two mediums is often referred to as a free surface (free boundary value problem); the problem arises due to the large differences in densities between the lava and air, with their ratio being around 2000, and so the interface between the two fluids move with respect to each other. 
20 


%and so the lava with the much higher density is able to move independently with respect to the air, and the interface between the two fluids is not constrained. 
21 


There are a number of numerical techniques to define and track the free surfaces. One of these methods, which is conceptually the simplest, is to construct a Lagrangian grid which moves with the fluid, and so it tracks the free surface. The limitation of this method is that it cannot track surfaces that break apart or intersect. Another limitation is that the elements in the grid can become severely distorted, resulting in numerical instability. The Arbitrary LagrangianEulerian (ALE) method for CFD in moving domains is used to overcome this problem by remeshing, but there is an overhead in computational time, and it results in a loss of accuracy due to the process of mapping the state variables every remesh by interpolation. 
22 



23 
lgraham 
1973 
There is a technique to overcome these limitations called the Level Set Method, for tracking interfaces between two fluids. The advantages of the method is that CFD can be performed on a fixed Cartesian mesh, and therefore problems with remeshing can be avoided. The field equations for calculating variables such as velocity and pressure are solved on the the same mesh. The Level Set Method is based upon the implicit representation of the interface by a continuous function. The function takes the form as a signed distance function, $\phi(x)$, of the interface in a Eulerian coordinate system. For example, the zero isocontour of the unit circle $\phi(x)=x^2 + y^2 1$ is the set of all points where $\phi(x)=0$. Refer to Figure \ref{UNITCIRCLE}. 
24 
lgraham 
1701 
% 
25 


\begin{figure} 
26 


\center 
27 
lgraham 
1973 
\scalebox{0.7}{\includegraphics{figures/unitcircle.eps}} 
28 
lgraham 
1701 
\caption{Implicit representation of the curve $x^2 + y^2 = 1$.} 
29 


\label{UNITCIRCLE} 
30 


\end{figure} 
31 


% 
32 
lgraham 
1973 
The implicit representation can be used to define the interior and exterior of a fluid region. Since the isocontour at $\phi(x)=0$ has been defined as the interface, a point in the domain can be determined if its inside or outside of the interface, by looking at the local sign of $\phi(x)$. For example, a point is inside the interface when $\phi(x)<0$, and outside the interface when $\phi(x)>0$. Parameters values such as density and viscosity can then be defined for two different mediums, depending on which side of the interface they are located. 
33 
lgraham 
1701 

34 
lgraham 
1973 

35 


\subsection{Calculation of the Displacement of the Interface} 
36 



37 


The displacement of the interface at the zero isocontour of $\phi(x)$ is calculated each timestep by using the velocity field. This is achieved my solving the advection equation: 
38 


% 
39 
lgraham 
1701 
\begin{equation} 
40 


\frac{\partial \phi}{\partial t} + \vec{v} \cdot \nabla \phi = 0, 
41 


\label{ADVECTION} 
42 


\end{equation} 
43 
lgraham 
1973 
% 
44 
lgraham 
2115 
where $\vec{v}$ is the velocity field. The advection equation is solved using a midpoint, which is a two step procedure: 
45 
lgraham 
1701 

46 


Firstly, $\phi^{1/2}$ is calculated solving: 
47 
lgraham 
1973 
% 
48 
lgraham 
1701 
\begin{equation} 
49 


\frac{\phi^{1/2}  \phi^{}}{dt/2} + \vec{v} \cdot \nabla \phi^{} = 0. 
50 


\label{MIDPOINT FIST} 
51 


\end{equation} 
52 
lgraham 
1973 
% 
53 
lgraham 
1701 
Secondly, using $\phi^{1/2}$, $\phi^{+}$ is calculated solving: 
54 
lgraham 
1973 
% 
55 
lgraham 
1701 
\begin{equation} 
56 


\frac{\phi^{+}  \phi^{}}{dt} + \vec{v} \cdot \nabla \phi^{1/2} = 0. 
57 


\label{MIDPOINT SECOND} 
58 


\end{equation} 
59 
lgraham 
1973 
% 
60 
lgraham 
2115 
This procedure works provided that the discretization of the lefthand side of Equations (\ref{MIDPOINT FIST}) and (\ref{MIDPOINT SECOND}) is a lumped mass matrix. For more details on the midpoint procedure see reference \cite{BOURGOUIN2006}. In certain situations the midpoint procedure has been shown to produce artifacts in the numerical solutions. A more robust procedure is to use the TaylorGalerkin scheme with the presence of diffusion, which gives more stable solutions. The expression is derived by either inserting Equation (\ref{MIDPOINT FIST}) into Equation (\ref{MIDPOINT SECOND}), or by expanding $\phi$ into a Taylor series: 
61 
lgraham 
1973 
% 
62 
lgraham 
1701 
\begin{equation} 
63 


\phi^{+} \simeq \phi^{} + dt\frac{\partial \phi^{}}{\partial t} + \frac{dt^2}{2}\frac{\partial^{2}\phi^{}}{\partial t^{2}}, 
64 


\label{TAYLOR EXPANSION} 
65 


\end{equation} 
66 
lgraham 
1973 
% 
67 
lgraham 
1701 
by inserting 
68 
lgraham 
1973 
% 
69 
lgraham 
1701 
\begin{equation} 
70 


\frac{\partial \phi^{}}{\partial t} =  \vec{v} \cdot \nabla \phi^{}, 
71 


\label{INSERT ADVECTION} 
72 


\end{equation} 
73 
lgraham 
1973 
% 
74 
lgraham 
1701 
and 
75 
lgraham 
1973 
% 
76 
lgraham 
1701 
\begin{equation} 
77 


\frac{\partial^{2} \phi^{}}{\partial t^{2}} = \frac{\partial}{\partial t}(\vec{v} \cdot \nabla \phi^{}) = \vec{v}\cdot \nabla (\vec{v}\cdot \nabla \phi^{}), 
78 


\label{SECOND ORDER} 
79 


\end{equation} 
80 
lgraham 
1973 
% 
81 


into Equation (\ref{TAYLOR EXPANSION}) 
82 


% 
83 
lgraham 
1701 
\begin{equation} 
84 


\phi^{+} = \phi^{}  dt\vec{v}\cdot \nabla \phi^{} + \frac{dt^2}{2}\vec{v}\cdot \nabla (\vec{v}\cdot \nabla \phi^{}). 
85 


\label{TAYLOR GALERKIN} 
86 


\end{equation} 
87 



88 
lgraham 
1973 

89 


\subsection{Governing Equations for Fluid Flow} 
90 



91 
lgraham 
1701 
The fluid dynamics is governed by the Stokes equations. In geophysical problems the velocity of fluids are low; that is, the inertial forces are small compared with the viscous forces, therefore the inertial terms in the NavierStokes equations can be ignored. For a body force $f$ the governing equations are given by: 
92 
lgraham 
1973 
% 
93 
lgraham 
1701 
\begin{equation} 
94 


\nabla \cdot (\eta(\nabla \vec{v} + \nabla^{T} \vec{v}))  \nabla p = f, 
95 


\label{GENERAL NAVIER STOKES} 
96 


\end{equation} 
97 
lgraham 
1973 
% 
98 
lgraham 
1701 
with the incompressibility condition 
99 
lgraham 
1973 
% 
100 
lgraham 
1701 
\begin{equation} 
101 


\nabla \cdot \vec{v} = 0. 
102 


\label{INCOMPRESSIBILITY} 
103 


\end{equation} 
104 
lgraham 
1973 
% 
105 
lgraham 
1701 
where $p$, $\eta$ and $f$ are the pressure, viscosity and body forces, respectively. 
106 


Alternatively, the Stokes equations can be represented in Einstein summation tensor notation (compact notation): 
107 
lgraham 
1973 
% 
108 
lgraham 
1701 
\begin{equation} 
109 


(\eta(v\hackscore{i,j} + v\hackscore{j,i})),\hackscore{j}  p,\hackscore{i} = f\hackscore{i}, 
110 


\label{GENERAL NAVIER STOKES COM} 
111 


\end{equation} 
112 
lgraham 
1973 
% 
113 
lgraham 
1701 
with the incompressibility condition 
114 
lgraham 
1973 
% 
115 
lgraham 
1701 
\begin{equation} 
116 


v\hackscore{i,i} = 0. 
117 


\label{INCOMPRESSIBILITY COM} 
118 


\end{equation} 
119 
lgraham 
1973 
% 
120 


The subscript comma $i$ denotes the derivative of the function with respect to $x\hackscore{i}$. A linear relationship between the deviatoric stress $\sigma^{'}\hackscore{ij}$ and the stretching $D\hackscore{ij} = \frac{1}{2}(v\hackscore{i,j} + v\hackscore{j,i})$ is defined as \cite{GROSS2006}: 
121 


% 
122 
lgraham 
1701 
\begin{equation} 
123 


\sigma^{'}\hackscore{ij} = 2\eta D^{'}\hackscore{ij}, 
124 


\label{STRESS} 
125 


\end{equation} 
126 
lgraham 
1973 
% 
127 
lgraham 
1701 
where the deviatoric stretching $D^{'}\hackscore{ij}$ is defined as 
128 
lgraham 
1973 
% 
129 
lgraham 
1701 
\begin{equation} 
130 


D^{'}\hackscore{ij} = D^{'}\hackscore{ij}  \frac{1}{3}D\hackscore{kk}\delta\hackscore{ij}. 
131 


\label{DEVIATORIC STRETCHING} 
132 


\end{equation} 
133 
lgraham 
1973 
% 
134 


where $\delta\hackscore{ij}$ is the Kronecker $\delta$symbol, which is a matrix with ones for its diagonal entries ($i = j$) and zeros for the remaining entries ($i \neq j$). The body force $f$ in Equation (\ref{GENERAL NAVIER STOKES COM}) is the gravity acting in the $x\hackscore{3}$ direction and is given as $f = g \rho \delta\hackscore{i3}$. 
135 
lgraham 
1701 
The Stokes equations is a saddle point problem, and can be solved using a Uzawa scheme. A class called StokesProblemCartesian in Escript can be used to solve for velocity and pressure. 
136 
lgraham 
1973 
In order to keep numerical stability, the timestep size needs to be below a certain value, known as the Courant number. The Courant number is defined as: 
137 


% 
138 
lgraham 
1701 
\begin{equation} 
139 


C = \frac{v \delta t}{h}. 
140 


\label{COURANT} 
141 


\end{equation} 
142 
lgraham 
1973 
% 
143 


where $\delta t$, $v$, and $h$ are the timestep, velocity, and the width of an element in the mesh, respectively. The velocity $v$ may be chosen as the maximum velocity in the domain. In this problem the Courant number is taken to be 0.4 \cite{BOURGOUIN2006}. 
144 
lgraham 
1701 

145 



146 
lgraham 
1973 
\subsection{Reinitialization of Interface} 
147 



148 
lgraham 
2115 
As the computation of the distance function progresses, it becomes distorted, and so it needs to be updated in order to stay regular \cite{SUSSMAN1994}. This process is known as the reinitialization procedure. The aim is to iteratively find a solution to the reinitialization equation: 
149 
lgraham 
1973 
% 
150 
lgraham 
1701 
\begin{equation} 
151 
lgraham 
2115 
\frac{\partial \psi}{\partial \tau} + sign(\phi)(1  \nabla \psi) = 0. 
152 
lgraham 
1701 
\label{REINITIALISATION} 
153 


\end{equation} 
154 
lgraham 
1973 
% 
155 
lgraham 
2115 
where $\psi$ shares the same level set with $\phi$, $\tau$ is pseudo time, and $sign(\phi)$ is the smoothed sign function. This equation is solved to meet the definition of the level set function, $\lvert \nabla \psi \rvert = 1$; the normalization condition. Equation (\ref{REINITIALISATION}) can be rewritten in similar form to the advection equation: 
156 


% 
157 


\begin{equation} 
158 


\frac{\partial \psi}{\partial \tau} + \vec{w} \cdot \nabla \psi = sign(\phi), 
159 


\label{REINITIALISATION2} 
160 


\end{equation} 
161 


% 
162 


where 
163 


% 
164 


\begin{equation} 
165 


\vec{w} = sign(\phi)\frac{\nabla \psi}{\nabla \psi}. 
166 


\label{REINITIALISATION3} 
167 


\end{equation} 
168 


% 
169 


$\vec{w}$ is the characteristic velocity pointing outward from the free surface. Equation (\ref{REINITIALISATION2}) can be solved by a similar technique to what was used in the advection step; either by the midpoint technique \cite{BOURGOUIN2006} or the TaylorGalerkin procedure. For the midpoint technique, the reinitialization technique algorithm is: 
170 
lgraham 
1701 

171 
lgraham 
2115 
1. Calculate 
172 


% 
173 


\begin{equation} 
174 


\vec{w} = sign(\phi)\frac{\nabla \psi}{\nabla \psi}, 
175 


\label{REINITIAL MIDPOINT1} 
176 


\end{equation} 
177 


% 
178 
lgraham 
1973 

179 
lgraham 
2115 
2. Calculate $\psi^{1/2}$ solving 
180 


% 
181 


\begin{equation} 
182 


\frac{\psi^{1/2}  \psi^{}}{d\tau/2} + \vec{w} \cdot \nabla \psi^{}= sign(\phi), 
183 


\label{REINITIAL MIDPOINT2} 
184 


\end{equation} 
185 


% 
186 



187 


3. using $\psi^{1/2}$, calculate $\psi^{+}$ solving 
188 


% 
189 


\begin{equation} 
190 


\frac{\psi^{+}  \psi^{}}{d\tau} + \vec{w} \cdot \nabla \psi^{1/2}= sign(\phi), 
191 


\label{REINITIAL MIDPOINT3} 
192 


\end{equation} 
193 


% 
194 



195 


4. if the convergence criterion has not been met, go back to step 2. Convergence is declared if 
196 


% 
197 


\begin{equation} 
198 


\nabla \psi \hackscore{\infty}  1 < \epsilon \hackscore{\psi}. 
199 


\label{REINITIAL CONVERGE} 
200 


\end{equation} 
201 


% 
202 


where $\epsilon$ 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: 
205 


% 
206 


\begin{equation} 
207 


\psi^{+} = \psi^{}  \tau \vec{w} \cdot \nabla \psi^{} + \frac{d \tau^{2}}{2} \vec{w} \cdot \nabla(\vec{w} \cdot \nabla \psi^{}). 
208 


\label{REINITIAL ONESTEP} 
209 


\end{equation} 
210 


% 
211 


The accuracy of $\phi$ is only needed within the transition zone; and so it can be calculated in a narrow band between the interface of the fluids. 
212 


% 
213 


\begin{figure} 
214 


\center 
215 


\scalebox{0.45}{\includegraphics{figures/LevelSetFlowChart.eps}} 
216 


\caption{Flow chart of level set procedure \cite{LIN2005}.} 
217 


\label{LEVELSET FLOWCHART} 
218 


\end{figure} 
219 


% 
220 


When the distance function, $\phi$, is calculated, the physical parameters, density and viscosity, are updated using the sign of $\phi$. The jump in material properties between two fluids, such as air and water can be extreme, and so the transition of the properties from one medium to another is smoothed. The region of the interface is assumed to be of finite thickness of $\alpha h$, where $h$ is the size of the elements in the computational mesh and $\alpha$ is a smoothing parameter. The parameters are updated by the following expression: 
221 


% 
222 


\begin{equation} 
223 


P = 
224 


\left \{ \begin{array}{l} 
225 


P\hackscore{1} \hspace{5cm} where \ \ \psi <  \alpha h \\ 
226 


P\hackscore{2} \hspace{5cm} where \ \ \psi > \alpha h \\ 
227 


(P\hackscore{2}  P\hackscore{1}) \psi/2\alpha h + (P\hackscore{1} + P\hackscore{2})/2 \ \ \ \ \ \ where \ \ \psi < \alpha h. 
228 


\end{array} 
229 


\right. 
230 


\label{UPDATE PARAMETERS} 
231 


\end{equation} 
232 


% 
233 


where the subscripts $1$ and $2$ denote the different fluids. The procedure of the level set calculation is shown in Figure \ref{LEVELSET FLOWCHART}. 
234 


Further work is needed in the reinitialization procedure, as it has been shown that it is prone to mass loss and inconsistent positioning of the interface \cite{SUCKALE2008}. 
235 



236 
lgraham 
1973 
\subsection{Benchmark Problem} 
237 



238 
lgraham 
2115 
The RayleighTaylor instability problem is used as a benchmark to validate CFD implementations \cite{VANKEKEN1997}. Figure \ref{RT2DSETUP} shows the setup of the problem. A rectangular domain with two different fluids is considered, with the greater density fluid on the top and the lighter density fluid on the bottom. The viscosities of the two fluids are equal (isoviscous). An initial perturbation is given to the interface of $\phi=0.02cos(\frac{\pi x}{\lambda}) + 0.2$. The aspect ratio $\lambda = L/H = 0.9142$ is chosen such that it gives the greatest disturbance of the fluids. 
239 
lgraham 
1973 
% 
240 
lgraham 
1701 
\begin{figure} 
241 


\center 
242 


\scalebox{0.7}{\includegraphics{figures/RT2Dsetup.eps}} 
243 
lgraham 
2115 
\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).} 
244 
lgraham 
1701 
\label{RT2DSETUP} 
245 


\end{figure} 
246 



247 


%The Level Set Method can be applied to many areas of science, for example simulating subduction zones in geophysics, motion of bubbles, and flame propagation. Its also used in image processing. However, the Level Set Method does have limitations. The level set function can still become irregular after reinitialisation, leading to artifacts in the simulations, requiring more thought into the implementation of the reinitialisation step. 
248 
lgraham 
2115 

249 


\begin{python} 
250 



251 



252 


\end{python} 