 # Diff of /trunk/doc/user/levelset.tex

revision 1973 by lgraham, Thu Nov 6 02:31:37 2008 UTC revision 2120 by lgraham, Tue Dec 2 06:21:49 2008 UTC
# Line 41  The displacement of the interface at the Line 41  The displacement of the interface at the
42  \end{equation}  \end{equation}
43  %  %
44  where $\vec{v}$ is the velocity field. The advection equation is solved using a mid-point method, which is a two step procedure:  where $\vec{v}$ is the velocity field. The advection equation is solved using a mid-point, which is a two step procedure:
45
46  Firstly, $\phi^{1/2}$ is calculated solving:  Firstly, $\phi^{1/2}$ is calculated solving:
47  %  %
# Line 57  Secondly, using $\phi^{1/2}$, $\phi^{+}$ Line 57  Secondly, using $\phi^{1/2}$, $\phi^{+}$
57  \label{MIDPOINT SECOND}  \label{MIDPOINT SECOND}
58  \end{equation}  \end{equation}
59  %  %
60  For more details on the mid-point procedure see reference \cite{BOURGOUIN2006}. In certain situations the mid-point procedure has been shown to produce artifacts in the numerical solutions. A more robust procedure is to use the Taylor-Galerkin 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:  This procedure works provided that the discretization of the left-hand side of Equations (\ref{MIDPOINT FIST}) and (\ref{MIDPOINT SECOND}) is a lumped mass matrix. For more details on the mid-point procedure see reference \cite{BOURGOUIN2006}. In certain situations the mid-point procedure has been shown to produce artifacts in the numerical solutions. A more robust procedure is to use the Taylor-Galerkin 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  %  %
62  \begin{equation}  \begin{equation}
63  \phi^{+} \simeq \phi^{-} + dt\frac{\partial \phi^{-}}{\partial t} + \frac{dt^2}{2}\frac{\partial^{2}\phi^{-}}{\partial t^{2}},  \phi^{+} \simeq \phi^{-} + dt\frac{\partial \phi^{-}}{\partial t} + \frac{dt^2}{2}\frac{\partial^{2}\phi^{-}}{\partial t^{2}},
# Line 145  where $\delta t$, $v$, and $h$ are the t Line 145  where $\delta t$, $v$, and $h$ are the t
145
146  \subsection{Reinitialization of Interface}  \subsection{Reinitialization of Interface}
147
148  As the computation of the distance function progresses, it becomes distorted, and so it needs to be updated in order to stay regular. This process is known as the reinitialization procedure. The aim is to iteratively find a solution to the reinitialization equation:  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  %  %
150  \begin{equation}  \begin{equation}
151  \frac{\partial \psi}{\partial \tau} + sign(\psi)(1 - \nabla \psi) = 0.  \frac{\partial \psi}{\partial \tau} + sign(\phi)(1 - \nabla \psi) = 0.
152  \label{REINITIALISATION}  \label{REINITIALISATION}
153  \end{equation}  \end{equation}
154  %  %
155  where $\tau$ is artificial time. This equation is solved to meet the definition of the level set function, $\lvert \nabla \psi \rvert = 1$; the normalization condition. However, it has been shown that in using this reinitialization procedure it is prone to mass loss and inconsistent positioning of the interface \cite{SUCKALE2008}.  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 mid-point technique \cite{BOURGOUIN2006} or the Taylor-Galerkin procedure. For the mid-point technique, the reinitialization technique algorithm is:
170
171    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
179    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 time-step of solving the Stokes equation.
203
204    The mid-point technique works provided that the left-hand side of Equations (\ref{REINITIAL MIDPOINT2}) and (\ref{REINITIAL MIDPOINT3}) is a lumped mass matrix. Alternatively, for a one-step 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  \subsection{Benchmark Problem}  \subsection{Benchmark Problem}
237
238  The Rayleigh-Taylor 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 (isoviscos). 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.  The Rayleigh-Taylor 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  %  %
240  \begin{figure}  \begin{figure}
241  \center  \center
242  \scalebox{0.7}{\includegraphics{figures/RT2Dsetup.eps}}  \scalebox{0.7}{\includegraphics{figures/RT2Dsetup.eps}}
243  \caption{Parameters, initial interface and boundary conditions for the Rayleigh-Taylor 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 (isovisous).}  \caption{Parameters, initial interface and boundary conditions for the Rayleigh-Taylor 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}.}
244  \label{RT2DSETUP}  \label{RT2DSETUP}
245  \end{figure}  \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.  %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
249    \begin{python}
250
251    from esys.escript import *
252    import esys.finley
253    from esys.escript.models import StokesProblemCartesian
254    from esys.finley import finley
255    from LevelSet import *
256
257    #physical properties
258    rho1 = 1000     #fluid density on bottom
259    rho2 = 1010     #fluid density on top
260    eta1 = 100.0        #fluid viscosity on bottom
261    eta2 = 100.0        #fluid viscosity on top
262    penalty = 100.0
263    g=10.0
264
265    #solver settings
266    dt = 0.001
267    t_step = 0
268    t_step_end = 2000
269    TOL = 1.0e-5
270    max_iter=400
271    verbose=True
272    useUzawa=True
273
274    #define mesh
275    l0=0.9142
276    l1=1.0
277    n0=100
278    n1=100
279
280    mesh=esys.finley.Rectangle(l0=l0, l1=l1, order=2, n0=n0, n1=n1)
281    #get mesh dimensions
282    numDim = mesh.getDim()
283    #get element size
284    h = Lsup(mesh.getSize())
285    print "element size",h
286
287    #level set parameters
288    tolerance = 1.0e-6
289    reinit_max = 30
290    reinit_each = 3
291    alpha = 1
292    smooth = alpha*h
293
294    #boundary conditions
295    x = mesh.getX()
296    #left + bottom + right + top
297    b_c = whereZero(x)*[1.0,0.0] + whereZero(x)*[1.0,1.0] + whereZero(x-l0)*[1.0,0.0] + whereZero(x-l1)*[1.0,1.0]
298
299    velocity = Vector(0.0, ContinuousFunction(mesh))
300    pressure = Scalar(0.0, ContinuousFunction(mesh))
301    Y = Vector(0.0,Function(mesh))
302
303    #define initial interface between fluids
304    xx = mesh.getX()
305    yy = mesh.getX()
306    func = Scalar(0.0, ContinuousFunction(mesh))
307    h_interface = Scalar(0.0, ContinuousFunction(mesh))
308    h_interface = h_interface + (0.02*cos(math.pi*xx/l0) + 0.2)
309    func = yy - h_interface
310    func_new = func.interpolate(ReducedSolution(mesh))
311
312    #Stokes cartesian
313    solution=StokesProblemCartesian(mesh,debug=True)
314    solution.setTolerance(TOL)
315    solution.setSubProblemTolerance(TOL**2)
316
317    #level set
318    levelset = LevelSet(mesh, func_new, reinit_max, reinit_each, tolerance, smooth)
319
320    while t_step <= t_step_end:
321      #update density and viscosity
322      rho = levelset.update_parameter(rho1, rho2)
323      eta = levelset.update_parameter(eta1, eta2)
324
325      #get velocity and pressue of fluid
326      Y = -rho*g
328      velocity,pressure=solution.solve(velocity,pressure,max_iter=max_iter,verbose=verbose,useUzawa=useUzawa)
329
330      #update the interface
331      func = levelset.update_phi(velocity, dt, t_step)
332
333      print "##########################################################"
334      print "time step:", t_step, " completed with dt:", dt
335      print "Velocity: min =", inf(velocity), "max =", Lsup(velocity)
336      print "##########################################################"
337
338      #save interface, velocity and pressure
339      saveVTK("phi2D.%2.4i.vtu"%t_step,interface=func,velocity=velocity,pressure=pressure)
340      #courant condition
341      dt = 0.4*Lsup(mesh.getSize())/Lsup(velocity)
342      t_step += 1
343
344    \end{python}

Legend:
 Removed from v.1973 changed lines Added in v.2120