19.06.2015 Views

A FEniCS Tutorial - FEniCS Project

A FEniCS Tutorial - FEniCS Project

A FEniCS Tutorial - FEniCS Project

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

We may collect the terms with the unknown δu on the left-hand side,<br />

∇·(q(u k )∇δu ) +∇·(q ′ (u k )δu∇u k) = −∇·(q(u k )∇u k) , (58)<br />

The weak form of this PDE is derived by multiplying by a test function v and<br />

integrating over Ω, integrating as usual the second-order derivatives by parts:<br />

∫<br />

(<br />

q(u k )∇δu·∇v +q ′ (u k )δu∇u k ·∇v ) ∫<br />

dx = − q(u k )∇u k ·∇vdx. (59)<br />

Ω<br />

The variational problem reads: find δu ∈ V such that a(δu,v) = L(v) for all<br />

v ∈ ˆV, where<br />

∫<br />

(<br />

a(δu,v) = q(u k )∇δu·∇v +q ′ (u k )δu∇u k ·∇v ) dx, (60)<br />

Ω∫<br />

L(v) = − q(u k )∇u k ·∇vdx. (61)<br />

Ω<br />

The function spaces V and ˆV, being continuous or discrete, are as in the linear<br />

Poisson problem from Section 1.2.<br />

We must provide some initial guess, e.g., the solution of the PDE with<br />

q(u) = 1. The corresponding weak form a 0 (u 0 ,v) = L 0 (v) has<br />

∫<br />

a 0 (u,v) = ∇u·∇vdx, L 0 (v) = 0.<br />

Ω<br />

Thereafter, we enter a loop and solve a(δu,v) = L(v) for δu and compute a new<br />

approximation u k+1 = u k + δu. Note that δu is a correction, so if u 0 satisfies<br />

the prescribed Dirichlet conditions on some part Γ D of the boundary, we must<br />

demand δu = 0 on Γ D .<br />

Looking at (60) and (61), we see that the variational form is the same as for<br />

the Newton method at thealgebraic level inSection 2.2. SinceNewton’s method<br />

at the algebraic level required some ”backward” construction of the underlying<br />

weak forms, <strong>FEniCS</strong> users may prefer Newton’s method at the PDE level, which<br />

this author finds more straightforward, although not so commonly documented<br />

in the literature on numerical methods for PDEs. There is seemingly no need<br />

for differentiations to derive a Jacobian matrix, but a mathematically equivalent<br />

derivation is done when nonlinear terms are linearized using the first two Taylor<br />

series terms and when products in the perturbation δu are neglected.<br />

The implementation is identical to the one in Section 2.2 and is found in the<br />

file pde_newton_np.py. The reader is encouraged to go through this code to be<br />

convinced that the present method actually ends up with the same program as<br />

needed for the Newton method at the linear algebra level in Section 2.2.<br />

2.4 Solving the Nonlinear Variational Problem Directly<br />

The previous hand-calculations and manual implementation of Picard or Newton<br />

methods can be automated by tools in <strong>FEniCS</strong>. In a nutshell, one can just<br />

write<br />

Ω<br />

55

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!