PDE Solvers for Fluid Flow

Similar documents
Math background. Physics. Simulation. Related phenomena. Frontiers in graphics. Rigid fluids

Fluid Animation. Christopher Batty November 17, 2011

Modeling, Simulating and Rendering Fluids. Thanks to Ron Fediw et al, Jos Stam, Henrik Jensen, Ryan

An Overview of Fluid Animation. Christopher Batty March 11, 2014

Numerical methods for the Navier- Stokes equations

Index. higher order methods, 52 nonlinear, 36 with variable coefficients, 34 Burgers equation, 234 BVP, see boundary value problems

Tutorial 2. Introduction to numerical schemes

2.29 Numerical Fluid Mechanics Spring 2015 Lecture 9

Diffusion / Parabolic Equations. PHY 688: Numerical Methods for (Astro)Physics

A Study on Numerical Solution to the Incompressible Navier-Stokes Equation

( ) Notes. Fluid mechanics. Inviscid Euler model. Lagrangian viewpoint. " = " x,t,#, #

Soft Bodies. Good approximation for hard ones. approximation breaks when objects break, or deform. Generalization: soft (deformable) bodies

Chapter 3. Finite Difference Methods for Hyperbolic Equations Introduction Linear convection 1-D wave equation

Dan s Morris s Notes on Stable Fluids (Jos Stam, SIGGRAPH 1999)

Chapter 9: Differential Analysis

Game Physics. Game and Media Technology Master Program - Utrecht University. Dr. Nicolas Pronost

Partial Differential Equations II

Chapter 9: Differential Analysis of Fluid Flow

AM 205: lecture 14. Last time: Boundary value problems Today: Numerical solution of PDEs

7.2 Steepest Descent and Preconditioning

Open boundary conditions in numerical simulations of unsteady incompressible flow

Elliptic Problems / Multigrid. PHY 604: Computational Methods for Physics and Astrophysics II

Partial Differential Equations

First, Second, and Third Order Finite-Volume Schemes for Diffusion

Block-Structured Adaptive Mesh Refinement

INTRODUCTION TO PDEs

ME Computational Fluid Mechanics Lecture 5

Numerical Optimization Algorithms

CHAPTER 7 SEVERAL FORMS OF THE EQUATIONS OF MOTION

Basic Aspects of Discretization

Physics-Based Animation

Chapter 9 Implicit integration, incompressible flows

Computational Fluid Dynamics-1(CFDI)

Applied Mathematics 205. Unit III: Numerical Calculus. Lecturer: Dr. David Knezevic

Index. C 2 ( ), 447 C k [a,b], 37 C0 ( ), 618 ( ), 447 CD 2 CN 2

Discrete Projection Methods for Incompressible Fluid Flow Problems and Application to a Fluid-Structure Interaction

Introduction to Partial Differential Equations

Vector and scalar penalty-projection methods

Conservation of Mass. Computational Fluid Dynamics. The Equations Governing Fluid Motion

Some notes about PDEs. -Bill Green Nov. 2015

Iterative Solvers in the Finite Element Solution of Transient Heat Conduction

V (r,t) = i ˆ u( x, y,z,t) + ˆ j v( x, y,z,t) + k ˆ w( x, y, z,t)

ENGI 4430 PDEs - d Alembert Solutions Page 11.01

Pressure corrected SPH for fluid animation

Indefinite and physics-based preconditioning

Chapter 5. Methods for Solving Elliptic Equations

Module 1: Introduction to Finite Difference Method and Fundamentals of CFD Lecture 1: Finite Difference Method

A unifying model for fluid flow and elastic solid deformation: a novel approach for fluid-structure interaction and wave propagation

Notes on PCG for Sparse Linear Systems

Additive Manufacturing Module 8

The Orchestra of Partial Differential Equations. Adam Larios

3. FORMS OF GOVERNING EQUATIONS IN CFD

A Robust Preconditioned Iterative Method for the Navier-Stokes Equations with High Reynolds Numbers

Fundamentals of Fluid Dynamics: Ideal Flow Theory & Basic Aerodynamics

Numerical Solutions to PDE s

AA214B: NUMERICAL METHODS FOR COMPRESSIBLE FLOWS

Partial Differential Equations

FEniCS Course. Lecture 6: Incompressible Navier Stokes. Contributors Anders Logg André Massing

Computational Fluid Dynamics I + II. Mathematische Strömungslehre I + II

Scientific Computing: An Introductory Survey

Part 1. The diffusion equation

Introduction to numerical schemes

Riemann Solvers and Numerical Methods for Fluid Dynamics

2.29 Numerical Fluid Mechanics Spring 2015 Lecture 13

AA210A Fundamentals of Compressible Flow. Chapter 1 - Introduction to fluid flow

Computational Fluid Dynamics

Fluid Dynamics. Part 2. Massimo Ricotti. University of Maryland. Fluid Dynamics p.1/17

2.29 Numerical Fluid Mechanics Fall 2011 Lecture 7

Fast Iterative Solution of Saddle Point Problems

fluid mechanics as a prominent discipline of application for numerical

OpenFOAM selected solver

Physically Based Simulations (on the GPU)

Introduction to Heat and Mass Transfer. Week 9

AE301 Aerodynamics I UNIT B: Theory of Aerodynamics

Topics. The CG Algorithm Algorithmic Options CG s Two Main Convergence Theorems

Practical in Numerical Astronomy, SS 2012 LECTURE 9

Active Flux for Advection Diffusion

Scientific Computing: An Introductory Survey

Streamline calculations. Lecture note 2

PDEs, part 1: Introduction and elliptic PDEs

Differential relations for fluid flow

Advection, Conservation, Conserved Physical Quantities, Wave Equations

Iterative Methods for Solving A x = b

Convergence Acceleration for Flow Problems

Partial Differential Equations

Pressure-velocity correction method Finite Volume solution of Navier-Stokes equations Exercise: Finish solving the Navier Stokes equations

STEADY AND UNSTEADY 2D NUMERICAL SOLUTION OF GENERALIZED NEWTONIAN FLUIDS FLOW. Radka Keslerová, Karel Kozel

Mathematical Concepts & Notation

Final Exam May 4, 2016

Chapter Two: Numerical Methods for Elliptic PDEs. 1 Finite Difference Methods for Elliptic PDEs

The Conjugate Gradient Method

MAE 3130: Fluid Mechanics Lecture 7: Differential Analysis/Part 1 Spring Dr. Jason Roney Mechanical and Aerospace Engineering

Detailed 3D modelling of mass transfer processes in two phase flows with dynamic interfaces

Chapter 5. The Differential Forms of the Fundamental Laws

Computation Fluid Dynamics

Lecture 16: Relaxation methods

Review for Exam 2 Ben Wang and Mark Styczynski

Lecture 1: Introduction to Linear and Non-Linear Waves

In this section, mathematical description of the motion of fluid elements moving in a flow field is

Solving PDEs with Multigrid Methods p.1

Transcription:

PDE Solvers for Fluid Flow issues and algorithms for the Streaming Supercomputer Eran Guendelman February 5, 2002

Topics Equations for incompressible fluid flow 3 model PDEs: Hyperbolic, Elliptic, Parabolic Examples Solution methods Issues for Streaming Supercomputer Solving incompressible fluid flow on a uniform Cartesian grid PDE Solvers for Fluid Flow 1

Notation ρ t = ρ t Partial derivative Dρ Dt Material (a.k.a. total) derivative If ρ = ρ (t, x, y, z), then by the chain rule Dρ Dt = ρ t + ρ dx x dt + ρ y Spatial gradient operator ( ) e.g. In 3-d: = x, y, z dy dt + ρ z dz dt = ρ t + u ρ PDE Solvers for Fluid Flow 2

Notation (cont d) Divergence operator e.g. In 3-d: u = u x + v y + w z = = 2 Laplacian operator e.g. In 3-d: = 2 x 2 + 2 y 2 + 2 z 2 It is a generalization of the 1-d curvature operator Bold variables represent vector quantities PDE Solvers for Fluid Flow 3

Equations for Incompressible Fluid Flow The equations come from two fundamental physical principles Conservation of mass Conservation of momentum Conservation of energy does not factor in unless one is simulating compressible fluids PDE Solvers for Fluid Flow 4

Conservation of Mass Conservation of mass leads to the continuity equation: Dρ Dt + ρ ( u) = 0 For incompressible fluids: Incompressibility Mass density independent of time Dρ Dt = 0 Substituting into the continuity equation gives We say u is divergence free u = 0 PDE Solvers for Fluid Flow 5

Conservation of Momentum Expressed in the Navier-Stokes equations: Du Dt = µ u p ρ + f Meaning of each term: Du Dt : We track a particle through the fluid and see how its velocity changes in time µ u: Acceleration due to fluid viscosity (µ is the viscosity coefficient) p ρ : Acceleration due to the local pressure gradient f: Acceleration due to forces such as gravity, buoyancy, etc. Left hand side is often written in expanded form: u t + (u ) u Called Euler equations if µ = 0 (inviscid) PDE Solvers for Fluid Flow 6

Equations for Incompressible Fluid Flow Four equations in four unknowns (p and the three-component u): u = 0 u t + (u ) u + p ρ = µ u + f Solving these equations requires being able to solve the three most fundamental types of partial differential equations (PDEs) PDE Solvers for Fluid Flow 7

The Three Model PDEs Partial differential equations are normally classified using 3 model PDEs: Hyperbolic Elliptic Parabolic Examples and solution methods for each type will now be discussed PDE Solvers for Fluid Flow 8

Hyperbolic PDEs Time dependent Model transient movement of signals along velocity fields i.e. At any point, flow is in one direction PDE Solvers for Fluid Flow 9

Hyperbolic PDEs: Examples One-way wave equation for incompressible flow ρ t + u ρ = 0 which represents the advection of density through the fluid The equation u t + (u ) u = 0 which will come up later when we solve the Navier Stokes equations by splitting The main level set equation φ t + u φ = 0 which, although similar in structure to the above equations, requires different (more accurate) solution methods PDE Solvers for Fluid Flow 10

General Setup for Solving PDEs Space is discretized into a uniform Cartesian grid (we will assume x = y = z for simplicity) t will denote the current time step of the simulation In our 1-d examples, { } n i will denote the quantity at position x = x 0 + i x, and at time t = n 1 k=0 t k (since the time steps may not be uniform) Sometimes I may just use the time index: e.g. u n is the velocity field at time step n PDE Solvers for Fluid Flow 11

Solving Hyperbolic PDEs: Explicit Method We will solve the 1-d version of the one-way wave equation ρ t + uρ x = 0 The explicit method solves this PDE by approximating the partial derivatives using finite differences We approximate ρ t using the forward Euler approximation: {ρ t } n i {ρ}n+1 i {ρ} n i t PDE Solvers for Fluid Flow 12

Solving Hyperbolic PDEs: Explicit Method (cont d) To approximate ρ x, we first define the upwind approximations: D + {ρ x } n i = {ρ}n i+1 {ρ}n i x D {ρ x } n i = {ρ}n i {ρ}n i 1 x Then to approximate ρ x we use either D + or D depending on the velocity at that point: { {ρ x } n D i + {ρ x } n i if {u} n i < 0 D {ρ x } n i otherwise PDE Solvers for Fluid Flow 13

Solving Hyperbolic PDEs: Explicit Method (cont d) This is needed in order to account for the direction in which information is flowing u i 1 i i+1 x So for each i we set the updated density according to {ρ} n+1 i = {ρ} n i t {u}n i D± {ρ x } n i PDE Solvers for Fluid Flow 14

Boundary Conditions We need to specify boundary conditions so that we can evaluate e.g. D {ρ x } n 0 = {ρ}n 0 {ρ}n 1 x Two types of boundary conditions: Dirichlet: Specify the value of an out-of-bound term such as {ρ} n 1 Neumann: Specify the derivative at the boundary, e.g. D {ρ x } n 0 = 0 PDE Solvers for Fluid Flow 15

Explicit Method: Issues For stability, t must obey the Courant-Friedrichs-Lewy (CFL) condition which for this particular discretization is t < x max u Ensures that no information further than one cell away can arrive at the current cell in time interval t (since max u < x t ) PDE Solvers for Fluid Flow 16

Solving Hyperbolic PDEs: Semi-Lagrangian Method Also known as the method of characteristics Suppose a particle at position x 0 at time t 0 moves to position x 0 + x at time t 0 + t The particle s mass density ρ does not change because that s precisely what the PDE is dictating: Dρ Dt = 0 So to determine the new density at point x, we should look up the old density at point x x (the old position of the particle now at x): {ρ} n+1 x = {ρ} n x x u x x x x tu PDE Solvers for Fluid Flow 17

Solving Hyperbolic PDEs: Semi-Lagrangian Method (cont d) Since we don t know the exact displacement x of the particle, we use a first order approximation: x = tu. Evaluating the density at position x tu requires interpolation from neighbouring grid cells. Linear interpolation is acceptable in this case since we re using a first order approximation for the particle path. We could have used a higher order accurate approximation for the particle path x and used a correspondingly higher order interpolation. This method is popular in the atmospheric science community (for clouds, large radioactive plumes, etc.). PDE Solvers for Fluid Flow 18

Semi-Lagrangian Method: Issues Unconditionally stable But lose accuracy Keep t at around 5 CFL limit to maintain good accuracy PDE Solvers for Fluid Flow 19

Hyperbolic PDEs: Issues for Streaming Supercomputer Explicit method The upwind approximations will (in general) require support for conditionals in kernels Only looks to a cell s immediate neighbours, so can make use of locality of reference Semi-Lagrangian method Less locality of reference: For a given cell, may have to look up value at a cell arbitrarily far away (although we can limit this to e.g. 5-30 cells by bounding t) PDE Solvers for Fluid Flow 20

Elliptic PDEs No time dependence Model steady state phenomena PDE Solvers for Fluid Flow 21

Elliptic PDEs: Examples Laplace equation p = f (Recall p = 2 p x 2 + 2 p y 2 + 2 p z 2 = p xx + p yy + p zz ) Poisson equation (β ρ) = f which reduces to the Laplace equation if β is constant. PDE Solvers for Fluid Flow 22

Solving Elliptic PDEs e.g. Solving 1-d Laplace equation: p xx = f We use a central difference approximation for the second order derivative: {p xx } i {p} i+1 2 {p} i + {p} i 1 x 2 Get a linear system of equations of the form {p} i+1 2 {p} i + {p} i 1 = x 2 {f} i PDE Solvers for Fluid Flow 23

Solving Elliptic PDEs (cont d) Boundary conditions: Dirichlet: e.g. Specify {p} 1 = α, get {p} 1 2 {p} 0 = x 2 {f} 0 α Neumann: e.g. Specify {p x } 0 = 0, get {p} 0 = {p} 1, so {p xx } 0 becomes {p xx } 0 = {p} 1 {p} 0 x 2 PDE Solvers for Fluid Flow 24

Solving Elliptic PDEs (cont d) We can write this system of linear equations in matrix form Ax = b A is a square matrix with the following properties: Size N N where N is the number of grid cells Banded: e.g. In 3-d it has 7 bands Only need to store the bands - saves a lot of space! Symmetric Negative definite Means: All eigenvalues are negative; equivalently, x T Ax < 0 for all x 0 PDE Solvers for Fluid Flow 25

Solving Elliptic PDEs (cont d) Various efficient techniques for solving Elliptic PDEs FFT methods Only good for periodic domains Multigrid solvers Optimal, but only become efficient as N gets fairly big Solve Ax = b using Preconditioned Conjugate Gradient Described next! PDE Solvers for Fluid Flow 26

Conjugate Gradient (CG) Method Requires A to be symmetric and positive definite So we will apply this method to A Based on the method of steepest descent: The quadratic form 1 2 xt Ax b T x has a global minimum at the point x satisfying Ax = b Steepest descent is an iterative procedure which gets you to this minimum point by starting at some initial guess x 0, and then at each iteration picking a direction and moving from x n to the minimum point x n+1 along that direction Conjugate gradient is steepest descent with a particular choice of directions PDE Solvers for Fluid Flow 27

Preconditioned Conjugate Gradient (PCG) Speed up CG by solving M 1 Ax = M 1 b instead Use M A Want M 1 easy to compute (or at least want to be able to compute M 1 y efficiently) One particular method is known as incomplete Cholesky preconditioning Note: The Cholesky factorization of A is A = LL T (L lower triangular) Choose M = ˆLˆL T where ˆL is the incomplete Cholesky factor of A ˆL is computed similarly to L, but is zero wherever A is zero So ˆL has the same sparsity pattern as A PDE Solvers for Fluid Flow 28

Preconditioned Conjugate Gradient Algorithm x: iterated solution, r: residual b Ax, d: direction, ɛ: tolerance Initialization: i 0, r b Ax, d M 1 r, δ new r T d, δ 0 δ new while i < i max and δ new > ɛ 2 δ 0 do α δ new d T (Set α so that x + αd is the minimum along direction d) Ad x x + αd r b Ax (Update the residual - can compute r r αad instead) δ old δ new δ new r T M 1 r β δ new δ old d M 1 r + βd (Choose the next A-orthogonal direction) i i + 1 For a 200 200 grid smoke simulation with x 0 = 0 and ɛ = 10 5, PCG takes around 250 iterations for the pressure calculation PDE Solvers for Fluid Flow 29

Elliptic PDEs: Issues for Streaming Supercomputer Need to be able to solve Ax = b! PDE Solvers for Fluid Flow 30

Solving Inviscid, Incompressible Fluid Flow Using our hyperbolic and elliptic PDE solvers is sufficient to solve the special case of inviscid (µ = 0) incompressible fluid flow We ll assume the fluid is homogeneous (ρ = 1) for simplicity We need to solve the following two equations simultaneously u = 0 u t + (u ) u + p = f PDE Solvers for Fluid Flow 31

Splitting We use a forward Euler approximation for u t in the Navier Stokes equations We split the Navier Stokes equations into three equations u u n + (u ) u t = 0 u u t = f u n+1 u + p t = 0 and proceed by solving each in turn u and u are intermediate velocity fields This splitting (a.k.a projection) method is due to Chorin (1965) PDE Solvers for Fluid Flow 32

Solving in Steps Step 1: Solve u u n t + (u ) u = 0 A hyperbolic PDE Use explicit or semi-lagrangian method Step 2: Solve u u t Here we account for gravity, buoyancy, and also add artificial forces such as vorticity confinement which enhances our simulation results = f PDE Solvers for Fluid Flow 33

Solving in Steps (cont d) Step 3: Solve u n+1 u t + p = 0 We want the final velocity field u n+1 to be divergence free (i.e. to satisfy u n+1 = 0) Need to find pressure field p to make this hold PDE Solvers for Fluid Flow 34

Solving in Steps (cont d) Step 3 (cont d): Projection method: Apply divergence operator to both sides: u n+1 u t + p = 0 We assume u n+1 is divergence free, so the u n+1 term disappears, and we get the elliptic PDE p = u t Solve Ax = b using PCG Now that we have p (and u ) we can get u n+1 PDE Solvers for Fluid Flow 35

Visualization The above three steps allow us to simulate the evolution of the velocity field in time To visualize the fluid flow, we can render the density (or any other passive scalar) in each cell, and move it along the velocity field using the hyperbolic PDE ρ t + u ρ = 0 PDE Solvers for Fluid Flow 36

Sample Animations 2-d inviscid fluid flow written in C++ PDE Solvers for Fluid Flow 37

Parabolic PDEs Time dependence Information flows at infinite speed in every direction (infinite domain of dependence) PDE Solvers for Fluid Flow 38

Parabolic PDEs: Examples Heat/Diffusion equation u t = (µ u) where u is the heat and µ the thermal coefficient The equation u t = µ u which will come up when we solve for viscous fluid flow. u is the velocity, µ the viscosity coefficient. (This is similar to the heat equation with constant µ) PDE Solvers for Fluid Flow 39

Solving Parabolic PDEs: Explicit Method e.g. Solving u t = µ u Use forward Euler for u t, and use u n on the right hand side: u n+1 u n t = µ u n This method is explicit because u n+1 does not appear on the right hand side We ve already discussed the finite difference form of u n Requires small t: t = O ( x 2) PDE Solvers for Fluid Flow 40

Solving Parabolic PDEs: Implicit Method Use u n+1 on right hand side: u n+1 u n t = µ u n+1 Rearranging gives u n+1 tµ u n+1 = u n which can be written in matrix form as (I tµ ) u n+1 = u n with the matrix for the Laplacian operator ( ) constructed similar to the solution of the elliptic Laplace equation Comes down to solving Ax = b using preconditioned conjugate gradient as for elliptic PDEs PDE Solvers for Fluid Flow 41

Parabolic PDEs: Issues for Streaming Supercomputer For the implicit method, we again need to able to solve Ax = b PDE Solvers for Fluid Flow 42

Adding Viscosity to our Fluid Flow Solver We need to add one step: Step 1: Solve u u n t + (u ) u = 0 Step 2: Compute u 1/2 by solving the parabolic equation u 1/2 u t = µ u 1/2 using PCG Step 3: Solve u u 1/2 t = f Step 4: Solve un+1 u t + p = 0 PDE Solvers for Fluid Flow 43

Sample Animations 2 Smoke simulation with added viscosity PDE Solvers for Fluid Flow 44

Summary Hyperbolic PDEs (e.g. used for density and velocity advection) Explicit method: Compute next value using forward Euler approximation and upwind approximations (D + or D depending on velocity). Requires looking up neighbouring values Semi-Lagrangian method: Compute next value at x by looking up old value at x tu (interpolate value) Elliptic PDEs (e.g. compute pressure to make velocity divergence free) Solving: Need to solve Ax = b using PCG Parabolic PDEs (e.g. used for viscosity in fluid flow) Explicit method: Compute next value using forward Euler approximation and finite difference form of u (requires looking up neighbouring values) Implicit method: Need to solve Ax = b using PCG PDE Solvers for Fluid Flow 45

Discussion Semi-Lagrangian method Look up grid values arbitrarily far away = no locality? Preconditioned conjugate gradient Using a preconditioner speeds up CG, but also has overhead Investigate different preconditioners and CG with no preconditioning Where do we go next with smoke? Port 2-d code to Brook? PDE Solvers for Fluid Flow 46