Solving PDEs with freefem++

Similar documents
A short introduction to FreeFem++

Discretization of PDEs and Tools for the Parallel Solution of the Resulting Systems

NUMERICAL INVESTIGATION OF BUOY- ANCY DRIVEN FLOWS IN TIGHT LATTICE FUEL BUNDLES

Proper Orthogonal Decomposition (POD) for Nonlinear Dynamical Systems. Stefan Volkwein

Une méthode de pénalisation par face pour l approximation des équations de Navier-Stokes à nombre de Reynolds élevé

INTRODUCTION TO PDEs

PDEs, part 1: Introduction and elliptic PDEs

Lecture 9 Approximations of Laplace s Equation, Finite Element Method. Mathématiques appliquées (MATH0504-1) B. Dewals, C.

Part IV: Numerical schemes for the phase-filed model

AMS subject classifications. Primary, 65N15, 65N30, 76D07; Secondary, 35B45, 35J50

LECTURE # 0 BASIC NOTATIONS AND CONCEPTS IN THE THEORY OF PARTIAL DIFFERENTIAL EQUATIONS (PDES)

Solving Distributed Optimal Control Problems for the Unsteady Burgers Equation in COMSOL Multiphysics

Chapter 6. Finite Element Method. Literature: (tiny selection from an enormous number of publications)

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

Numerical methods for the Navier- Stokes equations

The Lattice Boltzmann method for hyperbolic systems. Benjamin Graille. October 19, 2016

1 Introduction. J.-L. GUERMOND and L. QUARTAPELLE 1 On incremental projection methods

Some examples in domain decomposition

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

Scientific Computing: An Introductory Survey

A Two-Grid Stabilization Method for Solving the Steady-State Navier-Stokes Equations

Numerical simulations and mesh adaptation : exercise sessions Charles Dapogny 1, Pascal Frey 2, Yannick Privat 2

Info. No lecture on Thursday in a week (March 17) PSet back tonight

CIMPA Summer School on Current Research in Finite Element Methods

From Completing the Squares and Orthogonal Projection to Finite Element Methods

Numerical Methods for PDEs

Introduction into Implementation of Optimization problems with PDEs: Sheet 3

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

Past, present and space-time

1. Introduction. We consider the model problem that seeks an unknown function u = u(x) satisfying

Due Tuesday, November 23 nd, 12:00 midnight

Discontinuous Galerkin Methods

A note on accurate and efficient higher order Galerkin time stepping schemes for the nonstationary Stokes equations

From Boltzmann Equations to Gas Dynamics: From DiPerna-Lions to Leray

Basic Principles of Weak Galerkin Finite Element Methods for PDEs

Vorticity and Dynamics

Modelling of interfaces and free boundaries

The method of lines (MOL) for the diffusion equation

6.2 Governing Equations for Natural Convection

J. Liou Tulsa Research Center Amoco Production Company Tulsa, OK 74102, USA. Received 23 August 1990 Revised manuscript received 24 October 1990

Inverse Lax-Wendroff Procedure for Numerical Boundary Conditions of. Conservation Laws 1. Abstract

Équation de Burgers avec particule ponctuelle

Preconditioned space-time boundary element methods for the heat equation

A Domain Decomposition Method for Quasilinear Elliptic PDEs Using Mortar Finite Elements

Poisson Equation in 2D

Marching on the BL equations

Numerical control and inverse problems and Carleman estimates

Juan Vicente Gutiérrez Santacreu Rafael Rodríguez Galván. Departamento de Matemática Aplicada I Universidad de Sevilla

Xingye Yue. Soochow University, Suzhou, China.

A Stable Spectral Difference Method for Triangles

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

Introduction to Partial Differential Equations

SECOND ORDER TIME DISCONTINUOUS GALERKIN METHOD FOR NONLINEAR CONVECTION-DIFFUSION PROBLEMS

Lecture 1. Finite difference and finite element methods. Partial differential equations (PDEs) Solving the heat equation numerically

A posteriori error estimates for the adaptivity technique for the Tikhonov functional and global convergence for a coefficient inverse problem

Adaptive C1 Macroelements for Fourth Order and Divergence-Free Problems

Efficient Augmented Lagrangian-type Preconditioning for the Oseen Problem using Grad-Div Stabilization

Time stepping methods

Global Carleman inequalities and theoretical and numerical control results for systems governed by PDEs

u(0) = u 0, u(1) = u 1. To prove what we want we introduce a new function, where c = sup x [0,1] a(x) and ɛ 0:

13 PDEs on spatially bounded domains: initial boundary value problems (IBVPs)

Interaction of Incompressible Fluid and Moving Bodies

A High-Order Discontinuous Galerkin Method for the Unsteady Incompressible Navier-Stokes Equations

Basic Aspects of Discretization

Chapter 2. General concepts. 2.1 The Navier-Stokes equations

Partial Differential Equations

Implicit Solution of Viscous Aerodynamic Flows using the Discontinuous Galerkin Method

Spectral element schemes for the. Korteweg-de Vries and Saint-Venant equations

Multi-Factor Finite Differences

Efficient FEM-multigrid solver for granular material

An Introduction to Numerical Methods for Differential Equations. Janet Peterson

Lucio Demeio Dipartimento di Ingegneria Industriale e delle Scienze Matematiche

FEM Convergence for PDEs with Point Sources in 2-D and 3-D

Approximation of fluid-structure interaction problems with Lagrange multiplier

LEAST-SQUARES FINITE ELEMENT MODELS

Non-Differentiable Embedding of Lagrangian structures

Numerical Methods for Partial Differential Equations

Salmon: Lectures on partial differential equations

POD for Parametric PDEs and for Optimality Systems

Proper Orthogonal Decomposition. POD for PDE Constrained Optimization. Stefan Volkwein

R T (u H )v + (2.1) J S (u H )v v V, T (2.2) (2.3) H S J S (u H ) 2 L 2 (S). S T

A posteriori error estimation for elliptic problems

Length Learning Objectives Learning Objectives Assessment

LECTURE 3: DISCRETE GRADIENT FLOWS

Lecture 10. (2) Functions of two variables. Partial derivatives. Dan Nichols February 27, 2018

Experience with DNS of particulate flow using a variant of the immersed boundary method

Computer simulation of multiscale problems

Hp-Adaptivity on Anisotropic Meshes for Hybridized Discontinuous Galerkin Scheme

Notes: Outline. Diffusive flux. Notes: Notes: Advection-diffusion

Control of Interface Evolution in Multi-Phase Fluid Flows

Open boundary conditions in numerical simulations of unsteady incompressible flow

Numerical Solutions to Partial Differential Equations

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

FEM-Level Set Techniques for Multiphase Flow --- Some recent results

A method of Lagrange Galerkin of second order in time. Une méthode de Lagrange Galerkin d ordre deux en temps

Hybrid Discontinuous Galerkin methods for incompressible flow problems

Homework 4 in 5C1212; Part A: Incompressible Navier- Stokes, Finite Volume Methods

10. Buoyancy-driven flow

Hamburger Beiträge zur Angewandten Mathematik

Vector and scalar penalty-projection methods

Transcription:

Solving PDEs with freefem++ Tutorials at Basque Center BCA Olivier Pironneau 1 with Frederic Hecht, LJLL-University of Paris VI 1 March 13, 2011 Do not forget That everything about freefem++ is at www.freefem.org Check for new release every month Now in 3D and in MPI OP ( www/ann.jussieu.fr/pironneau) Solving PDEs with freefem++ March 13, 2011 1 / 38

Outline I 1 Part I: Algorithms Introduction Blocks Rannacher s Projection Scheme for Navier-Stokes eqs Floating Object Fluids and Temperature A Large Example 2 Part II: Playing with Meshes Mesh Adaptivity Domain Decomposition and zoom Application to Hydrology Discontinuous Galerkin freefem++ and Option Pricing OP ( www/ann.jussieu.fr/pironneau) Solving PDEs with freefem++ March 13, 2011 2 / 38

Introduction freefem++ has two building blocks An elliptic PDE system solver problem, solve A convection module convect Most complex nonlinear problems can be solved by appropriate algorithmic combination of both Except hyperbolic problems with shocks The power of freefem++ is also due to the capacity to handle multiple meshes in one script freefem++ has an advanced mesh adaptivity module OP ( www/ann.jussieu.fr/pironneau) Solving PDEs with freefem++ March 13, 2011 3 / 38

A simple elliptic problem u = f in Ω, u Ω = u Γ Ω u û f û = 0, Ω û H 1 0 (Ω) Take Ω the unit circle, f a Dirac at x 0, y 0 and u Γ = 0. The problems is solved in variational form approximated by a finite element method : u H 1 0 (Ω) V h = {û C 0 (Ω h ) : u h Tk P 2 triangle in the mesh} Execute OP ( www/ann.jussieu.fr/pironneau) Solving PDEs with freefem++ March 13, 2011 4 / 38

A simple convection problem Let u be solution of D t u := t u + a u = 0, u(0) = u 0 in Ω, t < T One has D t u(x 0, t 0 ) := lim δt [u(χ(t 0), t 0 ) u(χ(t 0 δt), t 0 δt)] where χ(t) = a(χ(t), t), χ(t 0 ) = x 0 δt 0 1 Hence D t u(x 0 ) 1 δt (um+1 (x 0 ) u m (X m (x 0 ))) with X m (x 0 ) := χ(t δt) x 0 a(x 0 )δt (1) A possible scheme is u m+1 (x) = u m (X m (x)) Π h u m (x a(x)δt) The keyword convect([a1,a2],-dt,u) returns uoχ. Note that the result is not a piecewise polynomial function even when u is. The difference with u(x adt) is a that x adt is not a precise computation of χ(t dt), especially near boundaries. OP ( www/ann.jussieu.fr/pironneau) Solving PDEs with freefem++ March 13, 2011 5 / 38

A simple convection problem (II) Execute OP ( www/ann.jussieu.fr/pironneau) Solving PDEs with freefem++ March 13, 2011 6 / 38

A convection diffusion problem Let u be solution of the convection-diffusion-dissipation equation t u + a u (µ u) + bu = 0, u(0) = u 0 in Ω, t < T It can be rewritten as D t u (µ u) + bu = f, u(0) = u 0 where D t u is the convective derivative. Let us use an implicit Euler scheme in time combined with the previous methods [ u m+1 u m ox m ] û + µ u m+1 û + bu m+1 û = 0, û H0 1 (Ω) δt Ω OP ( www/ann.jussieu.fr/pironneau) Solving PDEs with freefem++ March 13, 2011 7 / 38

Convection Diffusion problem (II) Execute OP ( www/ann.jussieu.fr/pironneau) Solving PDEs with freefem++ March 13, 2011 8 / 38

Publish the results. e.g. Evolution of u and u 2 This exercise will show how to communicate with the outside world Execute Use gnuplot to create a one dimensional graph >cd /Users/pironneau/Desktop/bilbaoFreefem/edp >gnuplot plot "norms.txt"using 1:2 w l, "norms.txt"using 1:3 w l OP ( www/ann.jussieu.fr/pironneau) Solving PDEs with freefem++ March 13, 2011 9 / 38

Rannacher s Projection Scheme Her we used Neumann bdy conditions for the PDE instead of Dirichlet to illustrate the fact that u remains constant and u 2 decays exponentially OP ( www/ann.jussieu.fr/pironneau) Solving PDEs with freefem++ March 13, 2011 10 / 38

Rannacher s Projection Scheme Consider t u + u u + p ν u = 0, u = 0 with u(0) = u 0 and u Γ = u Γ. With X (x) = x u m (x)δt, the following is first order in time: 1 δt (um+1/2 u m ox ) + p m ν u m+1/2 = 0 q = u m+1/2 u m+1/2 u m+1 = u m+1/2 + qδt, p m+1 = p m q p m q Exercise Compare this scheme with a fully coupled scheme like 1 δt (um+1 u m ox ) + p m+1 ν u m+1 = 0, u m+1 = 0 on the driven cavity problem. OP ( www/ann.jussieu.fr/pironneau) Solving PDEs with freefem++ March 13, 2011 11 / 38

Freefem Script for Fully Implicit and Rannacher s OP ( www/ann.jussieu.fr/pironneau) Solving PDEs with freefem++ March 13, 2011 12 / 38

Floating Object Consider a cylinder C of radius R and mass µ and center q 0 := x 0 (t), y 0 (t) floating in the flow of a driven cavity with viscosity ν. To find its motion q 0 and its angular velocity ω we must apply Newtons law: µ d2 q 0 dt 2 = d ω dt = q C [ν( u + u T ) p)] n [ ] [ν( u + u T ) p] n q C The no-slip boundary condition on C requires to impose on C a velocity for the fluid equal to q 0 + ω (q q 0 ). The mesh must be rebuilt at each time step because C moves. we shall use the trick u=u to project u defined on the old triangulation onto a u defined on the new one. OP ( www/ann.jussieu.fr/pironneau) Solving PDEs with freefem++ March 13, 2011 13 / 38

Execute OP ( www/ann.jussieu.fr/pironneau) Solving PDEs with freefem++ March 13, 2011 14 / 38

Fluids at Varying Temperature The Boussinesq approximation assumes that the density changes slightly with the temperature θ and the buyancy is a force in the fluid: t u + u u + p ν u = aθ e y, u = 0 t θ + u θ κ θ = 0 with u(0) = u 0, θ(0) = θ 0 and u Γ = u Γ, θ Γ = θ Γ. Let us study the case of a box with a hot (θ Γ = 1) and a cold wall (θ Γ = 0) t=0.107 IsoValue -412.673-281.849-151.025-20.2012 110.623 t=0.13 IsoValue -335.375-205.732-76.0899 53.5525 183.195 241.447 372.271 503.095 633.919 764.743 895.567 1026.39 1157.22 1288.04 1418.86 1549.69 1680.51 1811.34 1942.16 312.837 442.479 572.122 701.764 831.406 961.049 1090.69 1220.33 1349.98 1479.62 1609.26 1738.9 1868.55 1998.19 2072.98 2127.83 Vec Value 0 5.78617 11.5723 17.3585 23.1447 28.9309 34.717 40.5032 46.2894 52.0755 57.8617 63.6479 69.434 75.2202 81.0064 86.7926 92.5787 98.3649 104.151 Vec Value 0 6.38247 12.7649 19.1474 25.5299 31.9124 38.2948 44.6773 51.0598 57.4423 63.8247 70.2072 76.5897 82.9721 89.3546 95.7371 102.12 108.502 114.885 109.937 121.267 OP ( www/ann.jussieu.fr/pironneau) Solving PDEs with freefem++ March 13, 2011 15 / 38

Execute OP ( www/ann.jussieu.fr/pironneau) Solving PDEs with freefem++ March 13, 2011 16 / 38

Fluids, Temperature and Turbulence t θ + u θ (κ m T θ) = 0 t u + u u (µ T u) + p + e(θ θ 0 ) e 2, u = 0 k 2 µ T = c µ ɛ, κ T = κµ T t k + u k + ɛ (µ T k) = µ T 2 u + ut 2 ɛ 2 t ɛ + u ɛ + c 2 k c ɛ (µ T ɛ) = c 1 c µ 2 k u + ut 2 = 0 1 δt (θm+1 θ m X m ) (κ m T θ m+1 ) = 0 1 δt (um+1 u m X m ) (µ m T u m+1 ) + p m+1 + e(θ m+1 θ 0 ) e 2, u m+1 1 δt (km+1 k m X m ) + k 1 δt (ɛm+1 ɛ m X m ) + c 2 ɛ µ m+1 T = c µ k m+12 ɛ m+1, m+1 ɛm k m (µm T k m+1 ) = µm T 2 um + u mt 2 m+1 ɛm κm+1 T = κµ m+1 T k m c ɛ (µ m T ɛ m+1 ) = c 1 c µ 2 km u m + u mt 2 OP ( www/ann.jussieu.fr/pironneau) Solving PDEs with freefem++ March 13, 2011 17 / 38

Fluids, Temperature and Turbulence (II) IsoValue 22.8513 23.7927 24.4204 25.048 25.6756 26.3032 26.9309 27.5585 28.1861 28.8138 29.4414 30.069 30.6967 31.3243 31.9519 32.5795 33.2072 33.8348 34.4624 36.0315 Execute OP ( www/ann.jussieu.fr/pironneau) Solving PDEs with freefem++ March 13, 2011 18 / 38

Conclusion of Part I 1 Learn Variational Formulations 2 Learn how to devise Algorithms 3 Choose your finite element spaces Thank you for your attention OP ( www/ann.jussieu.fr/pironneau) Solving PDEs with freefem++ March 13, 2011 19 / 38

Outline I 1 Part I: Algorithms Introduction Blocks Rannacher s Projection Scheme for Navier-Stokes eqs Floating Object Fluids and Temperature A Large Example 2 Part II: Playing with Meshes Mesh Adaptivity Domain Decomposition and zoom Application to Hydrology Discontinuous Galerkin freefem++ and Option Pricing OP ( www/ann.jussieu.fr/pironneau) Solving PDEs with freefem++ March 13, 2011 20 / 38

Local Error Minimized: Estimated Results OP ( www/ann.jussieu.fr/pironneau) Solving PDEs with freefem++ March 13, 2011 21 / 38

Mesh Refinement OP ( www/ann.jussieu.fr/pironneau) Solving PDEs with freefem++ March 13, 2011 22 / 38

Local Error and Adaptivity OP ( www/ann.jussieu.fr/pironneau) Solving PDEs with freefem++ March 13, 2011 23 / 38

Mesh Refinement OP ( www/ann.jussieu.fr/pironneau) Solving PDEs with freefem++ March 13, 2011 24 / 38

Domain Decomposition with Overlapping Schwarz Algoritm To Solve u = f in Ω, u Γ = 0 in a domain Ω = Ω 1 Ω 2, on computes u as the limit of u k = f in Ω 1, u k Γ1 = u k 1 u k = f in Ω 2, u k Γ2 = u k 1 OP ( www/ann.jussieu.fr/pironneau) Solving PDEs with freefem++ March 13, 2011 25 / 38

file ddm.edp Execute OP ( www/ann.jussieu.fr/pironneau) Solving PDEs with freefem++ March 13, 2011 26 / 38

The Schwarz-Zoom Method γ H (resp γ h ) is the interpolation operator on V H (resp V h ) Find u m+1 H V H, u m+1 h V h, such that w H V 0H, w h V 0h a H (u m+1 H, w H ) = (f, w H ), u m+1 H SH = γ H uh m, um+1 H ΓH = g H, a h (u m+1 h, w h ) = (f, w h ), u m+1 h Sh = γ h uh m, um+1 Γh = g h h OP ( www/ann.jussieu.fr/pironneau) Solving PDEs with freefem++ March 13, 2011 27 / 38

Hilbert Space Decomposition Method (JL. Lions) Model problem (for instance K = I, f = 1 + δ( x x 0 )): (K v) = f in Ω, u Γ = 0 v = U + u, U H 1 0 (Ω), u Λ H 1 0 (Λ) β(u n+1 U n ) (U n+1 + u n ) = f in Ω β(u n+1 u n ) (U n + u n+1 ) = f in Λ 0-0.1 "usmall.gnu" using 1:3 "ularge.gnu" using 1:3 "u.gnu" using 1:3 "log.gnu" using 1:3-0.2-0.3-0.4-0.5-0.6-0.7. -0.8-1 -0.5 0 0.5 1 OP ( www/ann.jussieu.fr/pironneau) Solving PDEs with freefem++ March 13, 2011 28 / 38

The COUPLEX I Test Case Figure: A 2D multilayered geometry 20km long, 500m high with permeability variations K + K = O(10 9 ). Hydrostatic pressure by a FEM. (K H) = 0, H or H given on Γ n OP ( www/ann.jussieu.fr/pironneau) Solving PDEs with freefem++ March 13, 2011 29 / 38

COUPLEX I : Concentration of Radio-Nucleides Figure: Concentration at 4 times with Discontinuous Galerkin FEM (Apoung-Despré). r t c + λc + u c (K c) = q(t)δ(x x R ) OP ( www/ann.jussieu.fr/pironneau) Solving PDEs with freefem++ March 13, 2011 30 / 38

Solution by Zoom Execute OP ( www/ann.jussieu.fr/pironneau) Solving PDEs with freefem++ March 13, 2011 31 / 38

Execute OP ( www/ann.jussieu.fr/pironneau) Solving PDEs with freefem++ March 13, 2011 32 / 38

Discontinuous Galerkin (II) Execute OP ( www/ann.jussieu.fr/pironneau) Solving PDEs with freefem++ March 13, 2011 33 / 38

Pricing a Basket Option Find Given U h (T ) = (K S 1 S 2 ) + find U h H h such that V h H h ( t U h )V h [ [ 1 2 S i (σi 2 Si 2 V h ) Si U h µ i S i ( Si U h )V h ] Ω Ω i=1,2 S1 (ρσ 1 σ 2 S 1 S 2 V ) h S2 U h ] Execute OP ( www/ann.jussieu.fr/pironneau) Solving PDEs with freefem++ March 13, 2011 34 / 38

Heston Model t P (yx)2 2 xxp (yµ)2 yy P ρy 2 xµ xy P r x P + rp = 0 2 P(x, y, T ) = (K x y) + P(0, y, t) = Ke rt P(+, y, t) = 0 y P(x, 0, t) = y P(x, +, t) = 0 Execute OP ( www/ann.jussieu.fr/pironneau) Solving PDEs with freefem++ March 13, 2011 35 / 38

American Options u t σ2 x 2 2 u 2 x 2 rx u x + ru 0 u u, one is = with u(t, 0) = Ke rt, u(0, x) = u (x) := (K x) + { V = v L 2 (R + ), x v } x L2 (R + ), K = {v L 2 (0, T; V), v u }. Find u K C 0 ([0, T ]; L 2 (R + u )), t L2 (0, T ; V ), s.t. ( u t, v u) + a(u, v u) 0, v K, u(t = 0) = u, with ( σ 2 v w a(v, w) = x2 2 x x + (σ2 + x σ ) x r)x v x w + rvw dx. R + Assume σ [σ, σ] and x x σ 2 < M, then the solution exists and is unique. OP ( www/ann.jussieu.fr/pironneau) Solving PDEs with freefem++ March 13, 2011 36 / 38

Semi-Smooth Newton Method Kunisch et al suggested to reformulate the problem as a(u, v) (λ, v) = (f, v) v H 1 (R + ), λ min{0, λ + c(u φ)} = 0, i.e.au λ = f The last eq. is equivalent to λ 0, λ λ + c(u φ) i.e. u φ, λ 0, with equality on one of them for each S. This problem is equivalent for any real constant c > 0 because λ is the Lagrange multiplier of the constraint. Newton s algorithm applied to (3) gives Choose c > 0,, u 0, λ 0, set k = 0. Determine A k := {S : λ k (S) + c(u k (S) φ(s)) < 0} Set u k+1 = arg min u H 1 (R + ){ 1 2 a(u, u) (f, u) : u = φ on A k} Set λ k+1 = f Au k+1 OP ( www/ann.jussieu.fr/pironneau) Solving PDEs with freefem++ March 13, 2011 37 / 38

Results "exercise_250" 100 90 80 70 60 50 40 30 20 10 0 10 20 30 40 50 60 70 80 90 100 0 Best of put basket option, σ 1 = 0.2, σ 2 = 0.1, ρ = 0.8 Execute OP ( www/ann.jussieu.fr/pironneau) Solving PDEs with freefem++ March 13, 2011 38 / 38