/[escript]/trunk/doc/user/stokesflow.tex
ViewVC logotype

Diff of /trunk/doc/user/stokesflow.tex

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2192 by lgraham, Mon Jan 5 02:41:34 2009 UTC revision 2193 by lgraham, Mon Jan 5 04:29:06 2009 UTC
# Line 59  C = \frac{v \delta t}{h}. Line 59  C = \frac{v \delta t}{h}.
59  %  %
60  where $\delta t$, $v$, and $h$ are the time-step, 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 time-step size was calculated for a Courant number of 0.4.  where $\delta t$, $v$, and $h$ are the time-step, 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 time-step size was calculated for a Courant number of 0.4.
61    
62  The following PYTHON script is the setup for the simulation. It starts off by importing the classes, such as the StokesProblemCartesian class, for solving the Stokes equation and the incompressibility condition for velocity and pressure. Physical constants are defined for the viscosity and density of the fluid, along with the acceleration due to gravity. Solver settings are set for the maximum iterations and tolerance; the default solver used is PCG. The mesh is defined as a rectangle, to represent the body of fluid. The gravitational force is calculated base on the fluid density and the acceleration due to gravity. The boundary conditions are set for a slip condition at the base of the mesh; fluid movement in the x-direction is free, but fixed in the y-direction. An instance of the StokesProblemCartesian is defined for the given computational mesh, and the solver tolerance set. Inside the while loop, the boundary conditions, viscosity and body force are initialized. The Stokes equation is then solved for velocity and pressure. The time-step size is calculated base on the Courant condition, to ensure stable solutions. The nodes in the mesh are then displaced based on the current velocity and time-step size, to move the body of fluid. The output for the simulation of velocity and pressure is then save to file for visualization.  The following PYTHON script is the setup for the Stokes flow simulation, and is available in the example directory as 'fluid.py'. It starts off by importing the classes, such as the StokesProblemCartesian class, for solving the Stokes equation and the incompressibility condition for velocity and pressure. Physical constants are defined for the viscosity and density of the fluid, along with the acceleration due to gravity. Solver settings are set for the maximum iterations and tolerance; the default solver used is PCG. The mesh is defined as a rectangle, to represent the body of fluid. The gravitational force is calculated base on the fluid density and the acceleration due to gravity. The boundary conditions are set for a slip condition at the base of the mesh; fluid movement in the x-direction is free, but fixed in the y-direction. An instance of the StokesProblemCartesian is defined for the given computational mesh, and the solver tolerance set. Inside the while loop, the boundary conditions, viscosity and body force are initialized. The Stokes equation is then solved for velocity and pressure. The time-step size is calculated base on the Courant condition, to ensure stable solutions. The nodes in the mesh are then displaced based on the current velocity and time-step size, to move the body of fluid. The output for the simulation of velocity and pressure is then save to file for visualization.
63  %  %
64  \begin{python}  \begin{python}
65  from esys.escript import *  from esys.escript import *
# Line 112  while t <= t_end: Line 112  while t <= t_end:
112    print "Time = %s seconds"%( time )      print "Time = %s seconds"%( time )  
113    
114    solution.initialize(fixed_u_mask=boundary_cond,eta=eta,f=Y)    solution.initialize(fixed_u_mask=boundary_cond,eta=eta,f=Y)
115    velocity,pressure=solution.solve(velocity,pressure,max_iter=max_iter,verbose=verbose,useUzawa=useUzawa)    velocity,pressure=solution.solve(velocity,pressure,max_iter=max_iter, \
116      verbose=verbose,useUzawa=useUzawa)
117        
118    print "Max velocity =", Lsup(velocity), "m/s"    print "Max velocity =", Lsup(velocity), "m/s"
119        
# Line 134  while t <= t_end: Line 135  while t <= t_end:
135    t = t+1.0    t = t+1.0
136    
137  \end{python}  \end{python}
138    %
139  The results from the simulation can be viewed with \mayavi, by executing the following command:  The results from the simulation can be viewed with \mayavi, by executing the following command:
140  %  %
141  \begin{python}  \begin{python}
142  mayavi -d vel.00.vtu -m SurfaceMap  mayavi -d vel.00.vtu -m SurfaceMap
143  \end{python}  \end{python}
144  %  %
145  Colour coded scalar maps and velocity flow fields can be viewed by selecting them in the menu. The time-steps can be sweeped through to view a movie of the simulation.  Colour coded scalar maps and velocity flow fields can be viewed by selecting them in the menu. The time-steps can be swept through to view a movie of the simulation.
146  Figures \ref{FLUID OUTPUT1} and \ref{FLUID OUTPUT2} shows the simulation output. Velocity vectors and a colour map for pressure are shown. As the time progresses the body of fluid falls under the influence of gravity.  Figures \ref{FLUID OUTPUT1} and \ref{FLUID OUTPUT2} shows the simulation output. Velocity vectors and a colour map for pressure are shown. As the time progresses the body of fluid falls under the influence of gravity.
147    %
148  \begin{figure}  \begin{figure}
149  \center  \center
150  \subfigure[t=1]{\label{FLOW OUTPUT 01}\includegraphics[scale=0.25]{figures/stokes-fluid-t01.eps}}  \subfigure[t=1]{\label{FLOW OUTPUT 01}\includegraphics[scale=0.25]{figures/stokes-fluid-t01.eps}}
# Line 153  Figures \ref{FLUID OUTPUT1} and \ref{FLU Line 154  Figures \ref{FLUID OUTPUT1} and \ref{FLU
154  \caption{Simulation output for Stokes flow. Fluid body starts off as a rectangular shape, then progresses downwards under the influence of gravity. Color coded distribution represents the scalar values for pressure. Velocity vectors are displayed at each node in the mesh to show the flow field. Computational mesh used was 20$\times$20 elements.}  \caption{Simulation output for Stokes flow. Fluid body starts off as a rectangular shape, then progresses downwards under the influence of gravity. Color coded distribution represents the scalar values for pressure. Velocity vectors are displayed at each node in the mesh to show the flow field. Computational mesh used was 20$\times$20 elements.}
155  \label{FLUID OUTPUT1}  \label{FLUID OUTPUT1}
156  \end{figure}  \end{figure}
157    %
158  \begin{figure}  \begin{figure}
159  \center  \center
160  \subfigure[t=40]{\label{FLOW OUTPUT 30}\includegraphics[scale=0.25]{figures/stokes-fluid-t30.eps}}  \subfigure[t=40]{\label{FLOW OUTPUT 30}\includegraphics[scale=0.25]{figures/stokes-fluid-t30.eps}}
# Line 163  Figures \ref{FLUID OUTPUT1} and \ref{FLU Line 164  Figures \ref{FLUID OUTPUT1} and \ref{FLU
164  \caption{Simulation output for Stokes flow.}  \caption{Simulation output for Stokes flow.}
165  \label{FLUID OUTPUT2}  \label{FLUID OUTPUT2}
166  \end{figure}  \end{figure}
167    %
168    The view used here to track the fluid is the Lagrangian view, since the mesh moves with the fluid. One of the disadvantages of using the Lagrangian view is that the elements in the mesh become severely distorted after a period of time and introduce solver errors. To get around this limitation the Level Set Method is used, with the Eulerian point of view for a fixed mesh. The Level Set Method is discussed in Section \ref{LEVELSET CHAP}.

Legend:
Removed from v.2192  
changed lines
  Added in v.2193

  ViewVC Help
Powered by ViewVC 1.1.26