Lecture 9 PDF
Lecture 9 PDF
Lecture 9 PDF
Anders Logg
1 / 13
Course outline
Sunday
L1 Introduction to FEM
Monday
L2 Fundamentals of continuum mechanics (I)
L3 Fundamentals of continuum mechanics (II)
L4 Introduction to FEniCS
Tuesday
L5 Solid mechanics
L6 Static hyperelasticity in FEniCS
L7 Dynamic hyperelasticity in FEniCS
Wednesday
L8 Fluid mechanics
L9 Navier–Stokes in FEniCS
2 / 13
The incompressible Navier–Stokes equations
ρ(u̇ + u · ∇u) − ∇ · σ(u, p) = f in Ω × (0, T ]
∇·u=0 in Ω × (0, T ]
u = gD on ΓD × (0, T ]
σ · n = gN on ΓN × (0, T ]
u(·, 0) = u0 in Ω
Short-hand notation:
4 / 13
Discrete variational problem
efficient)
5 / 13
A splitting method
cG(1) / Crank-Nicolson approximation with explicit convection:
Subtract:
∂n ṗ = 0
1
hρDtn uF , vi + hρun−1 · ∇un−1 , vi + hσ(un− 2 , pn−3/2 ), (v)i
1
− hµn · (∇un− 2 )> , vi∂Ω + hpn−3/2 n, vi∂Ω = hf n−1/2 , vi
9 / 13
Useful FEniCS tools (I)
Note grad vs. ∇:
dot ( grad ( u ) , u )
dot (u , nabla_grad ( u ) )
Defining operators:
def sigma (u , p ) :
return 2 . 0 * mu * sym ( grad ( u ) ) - p * Identity ( 2 )
n = FacetNormal ( mesh )
10 / 13
Useful FEniCS tools (II)
A = assemble ( a )
b = assemble ( L )
solve (A , x , b )
solve (A , x , b , " gmres " , " ilu " )
solve (A , x , b , " cg " , " amg " )
11 / 13
The FEniCS challenge!
Solve the incompressible Navier–Stokes equations for the flow of
water around a dolphin. The water is initially at rest and the
flow is driven by a pressure gradient.
12 / 13
The FEniCS challenge!
• Compute the solution on the time interval [0, 0.1] with time
µ = 0.001002 kg/(m · s)
x-direction.
13 / 13