Notes Shallow Water Equations Advection Exploiting Lagrangian View

Notes Shallow Water Equations Advection Exploiting Lagrangian View

Notes Shallow water equations ! To recap, using eta for depth=h+H: D! = "!# $ u Dt Du = "g#h Dt ! We!re currently working on the advection (material derivative) part cs533d-term1-2005 1 cs533d-term1-2005 2 Advection Exploiting Lagrangian view ! Let!s discretize just the material derivative ! We want to stick an Eulerian grid for now, (advection equation): but somehow exploit the fact that Dq q + u! "q = 0 or = 0 • If we know q at some point x at time t, we just t Dt follow a particle through the flow starting at x ! For a Lagrangian scheme this is trivial: just to see where that value of q ends up move the particle that stores q, don!t change the value of q at all q(x(t + !t),t + !t) = q(x(t),t) q(x(t),t) = q(x0,0) dx = u(x), x(t) = x0 dt cs533d-term1-2005 3 cs533d-term1-2005 4 Looking backwards Semi-Lagrangian method ! Problem with tracing particles - we want values at grid ! Developed in weather prediction, going back to nodes at the end of the step the 50!s • Particles could end up anywhere ! Also dubbed “stable fluids” in graphics ! But… we can look backwards in time (reinvention by Stam #99) q = q x(t ! "t),t ! "t ijk ( ) ! To find new value of q at a grid point, trace dx particle backwards from grid point (with velocity = u(x), x(t) = xijk dt u) for -"t and interpolate from old values of q ! Same formulas as before - but new interpretation ! Two questions • To get value of q at a grid point, follow a particle backwards • How do we trace? through flow to wherever it started • How do we interpolate? cs533d-term1-2005 5 cs533d-term1-2005 6 Tracing Tracing: 1st order ! The errors we make in tracing backwards ! We!re at grid node (i,j,k) at position xijk aren!t too big a deal ! Trace backwards through flow for -"t • We don!t compound them - stability isn!t an x = x ! "t u issue old ijk ijk • How accurate we are in tracing doesn!t effect • Note - using u value at grid point (what we know shape of q much, just location already) like Forward Euler. ! Whether we get too much blurring, oscillations, or ! Then can get new q value (with interpolation) a nice result is really up to interpolation n +1 n ! Thus look at “Forward” Euler and RK2 qijk = q (xold ) n = q (xijk ! "tuijk ) cs533d-term1-2005 7 cs533d-term1-2005 8 Interpolation Linear interpolation ! “First” order accurate: nearest neighbour ! Error in linear interpolation is proportional to 2 • Just pick q value at grid node closest to xold " q !x 2 • Doesn!t work for slow fluid (small time steps) -- "x 2 nothing changes! • When we divide by grid spacing to put in terms of ! Modified PDE ends up something like… advection equation, drops to zero!th order accuracy Dq " 2q = k(!t)!x 2 ! “Second” order accurate: linear or bilinear (2D) Dt "x 2 • Ends up first order in advection equation • We have numerical viscosity, things will smear out • Still fast, easy to handle boundary conditions… • For reasonable time steps, k looks like 1/"t ~ 1/"x • How well does it work? ! [Equivalent to 1st order upwind for CFL "t] ! In practice, too much smearing for inviscid fluids cs533d-term1-2005 9 cs533d-term1-2005 10 Nice properties of lerping Cubic interpolation ! Linear interpolation is completely stable ! To fix the problem of excessive smearing, • Interpolated value of q must lie between the go to higher order old values of q on the grid ! E.g. use cubic splines • Thus with each time step, max(q) cannot • Finding interpolating C2 cubic spline is a little increase, and min(q) cannot decrease painful, an alternative is the ! Thus we end up with a fully stable • C1 Catmull-Rom (cubic Hermite) spline algorithm - take "t as big as you want ! [derive] • Great for interactive applications ! Introduces overshoot problems • Also simplifies whole issue of picking time • Stability isn!t so easy to guarantee anymore steps cs533d-term1-2005 11 cs533d-term1-2005 12 Min-mod limited Catmull-Rom Back to Shallow Water ! See Fedkiw, Stam, Jensen #01 ! So we can now handle advection of both ! Trick is to check if either slope at the endpoints water depth and each component of water of the interval has the wrong sign velocity • If so, clamp the slope to zero ! Left with the divergence and gradient • Still use cubic Hermite formulas with more reliable slopes terms !" $ !u !w' = #"& + ) ! This has same stability guarantee as linear !t % !x !z ( interpolation !u !h • But in smoother parts of flow, higher order accurate = #g • Called “high resolution” !t !x ! Still has issues with boundary conditions… !w !h = #g cs533d-term1-2005 13 !t !z cs533d-term1-2005 14 Staggered grid Spatial Discretization ! We like central differences - more ! So on the MAC grid: accurate, unbiased ! So natural to use a staggered grid for % u 1 # u 1 w 1 # w 1 ( !"ij i+ 2, j i# 2, j i, j + 2 i, j# 2 velocity and height variables = #"ij ' + * • Called MAC grid after the Marker-and-Cell !t & $x $z ) method (Harlow and Welch #65) that !u 1 h # h introduced it i+ 2, j = #g i+1, j i, j ! Heights at cell centres !t $x ! u-velocities at x-faces of cells !wi, j + 1 hi, j +1 # hi, j 2 = #g ! w-velocities at z-faces of cells !t $z cs533d-term1-2005 15 cs533d-term1-2005 16 Solving Full Equations Operator Splitting ! Let!s now solve the full incompressible ! Generally a bad idea to treat Euler or Navier-Stokes equations incompressible flow as conservation laws ! We!ll first avoid interfaces with constraints (e.g. free surfaces) ! Instead: split equations up into easy ! Think smoke chunks, just like Shallow Water ut + u! "u = 0 2 ut = #" u ut = g 1 ut + $ "p = 0 (" ! u = 0) cs533d-term1-2005 17 cs533d-term1-2005 18 Time integration Advection boundary conditions ! Don!t mix the steps at all - 1st order accurate ! But first, one last issue u(1) = advect(un ,!t) ! Semi-Lagrangian procedure may need to (2) (1) 2 (2) interpolate from values of u outside the domain, u = u + "!t# u or inside solids u(3) = u(2) + !tg • Outside: no correct answer. Extrapolating from nearest point on domain is fine, or assuming some n +1 (3) 1 u = u $ !t % #p far-field velocity perhaps ! We!ve already seen how to do the advection step • Solid walls: velocity should be velocity of wall (e.g.zero) ! Often can ignore the second step (viscosity) ! Technically only normal component of velocity needs to be ! Let!s focus for now on the last step (pressure) taken from wall, in absence of viscosity the tangential component may be better extrapolated from the fluid cs533d-term1-2005 19 cs533d-term1-2005 20 Continuous pressure Pressure boundary conditions ! Before we discretize in space, last step is ! Issue of what to do for p and u at to take u(3), figure out the pressure p that boundaries in pressure solve n+1 makes u incompressible: ! Think in terms of control volumes: • Want ! " un +1 = 0 subtract pn from u on boundary so that u(3) t 1 p 0 • Plug in pressure update formula: ! " ( # $ % ! ) = integral of u•n is zero • Rearrange: t 1 p u(3) ! " (# $ ! ) = ! " ! So at closed boundary we end up with • Solve this Poisson problem (often density is n +1 constant and you can rescale p by it, also "t) u ! n = 0 ! Make this assumption from now on: 2 (3) #p ! p = ! " u un +1 ! n = u(3) ! n " un +1 = u(3) # !p #n cs533d-term1-2005 21 cs533d-term1-2005 22 Pressure BC’s cont’d. Approximate projection ! At closed wall boundary have two choices: ! Can now directly discretize Poisson equation on a grid # " 2 p " 2 p " 2 p& • Set u•n=0 first, then solve for p with $p/$n=0, 2 p (! ) = % 2 + 2 + 2 ( don!t update velocity at boundary ijk $ "x "y "z ' p * 2p + p p * 2p + p p * 2p + p ) i+1 jk ijk i*1 jk + ij +1k ijk ij*1k + ijk+1 ijk ijk*1 • Or simply solve for p with $p/$n=u•n and +x 2 +y 2 +z2 update u•n at boundary with -$p/$n # "u "v "w& (! , u) = % + + ( ijk "x "y "z • Equivalent, but the second option make sense $ ' ijk u * u v * v w * w in the continuous setting, and generally keeps ) i+1 jk i*1 jk + ij +1k ij*1k + ijk+1 ijk*1 you more honest 2+x 2+y 2+z - pi+1 jk * pi*1 jk pij +1k * pij*1k pijk+1 * pijk*1 0 (!p) ) / , , 2 ! At open (or free-surface) boundaries, no ijk . 2+x 2+y 2+z 1 constraint on u•n, so typically pick p=0 ! Central differences - 2nd order, no bias cs533d-term1-2005 23 cs533d-term1-2005 24 Issues Exact projection (1st try) ! On the plus side: simple grid, simple discretization, ! Connection becomes exact in limit for smooth u… ! But it doesn!t work • use the discrete divergence as a hard • Divergence part of equation can!t “see” high frequency constraint to enforce, pressure p turns out to compression waves be the Lagrange multipliers… • Left with high frequency oscillatory error • Need to filter this out - smooth out velocity field before ! Or let!s just follow the route before, but subtracting off pressure gradient • Filtering introduces more numerical viscosity, eliminates features discretize divergence and gradient first on coarse grids First try: use centred differences as before ! Also: doesn!t exactly make u incompressible • • Measuring divergence of result gives nonzero • u and p all “live” on same grid: uijk, pijk ! So let!s look at exactly enforcing the incompressibility This is called a “collocated” scheme constraint • cs533d-term1-2005 25 cs533d-term1-2005 26 Exact collocated projection Problems ! " un +1 = 0 ! So want ( )ijk ! Pressure problem decouples into 8 independent un +1 # un +1 v n +1 # v n +1 w n +1 # w n +1 subproblems i+1 jk i#1 jk + ij +1k ij#1k + ijk+1 ijk#1 = 0 2$x 2$y 2$z ! “Checkerboard” instability • Divergence still doesn!t see high-frequency ! Update with discrete gradient of p un +1 = u(3) ! "p compression waves # p ! p p !

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    10 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us