A FEniCS Tutorial - FEniCS Project
A FEniCS Tutorial - FEniCS Project
A FEniCS Tutorial - FEniCS Project
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
seek a new (hopefully improved) solution u k+1 in iteration k+1 such that u k+1<br />
solves the linear problem,<br />
∇·(q(u k )∇u k+1) = 0, k = 0,1,... (43)<br />
The iterations require an initial guess u 0 . The hope is that u k → u as k → ∞,<br />
and that u k+1 is sufficiently close to the exact solution u of the discrete problem<br />
after just a few iterations.<br />
We can easily formulate a variational problem for u k+1 from (43). Equivalently,<br />
we can approximate q(u) by q(u k ) in (41) to obtain the same linear<br />
variational problem. In both cases, the problem consists of seeking u k+1 ∈ V<br />
such that<br />
˜F(u k+1 ;v) = 0 ∀v ∈ ˆV, k = 0,1,..., (44)<br />
with<br />
∫<br />
˜F(u k+1 ;v) =<br />
Ω<br />
q(u k )∇u k+1 ·∇vdx. (45)<br />
Since this is a linear problem in the unknown u k+1 , we can equivalently use the<br />
formulation<br />
a(u k+1 ,v) = L(v), (46)<br />
with<br />
∫<br />
a(u,v) =<br />
Ω<br />
q(u k )∇u·∇vdx (47)<br />
L(v) = 0. (48)<br />
The iterations can be stopped when ǫ ≡ ||u k+1 −u k || < tol, where tol is a<br />
small tolerance, say 10 −5 , or when the number of iterations exceed some critical<br />
limit. The latter case will pick up divergence of the method or unacceptable<br />
slow convergence.<br />
In the solution algorithm we only need to store u k and u k+1 , called u_k and<br />
u in the code below. The algorithm can then be expressed as follows:<br />
def q(u):<br />
return (1+u)**m<br />
# Define variational problem for Picard iteration<br />
u = TrialFunction(V)<br />
v = TestFunction(V)<br />
u_k = interpolate(Constant(0.0), V) # previous (known) u<br />
a = inner(q(u_k)*nabla_grad(u), nabla_grad(v))*dx<br />
f = Constant(0.0)<br />
L = f*v*dx<br />
# Picard iterations<br />
u = Function(V) # new unknown function<br />
eps = 1.0 # error measure ||u-u_k||<br />
tol = 1.0E-5 # tolerance<br />
iter = 0 # iteration counter<br />
maxiter = 25 # max no of iterations allowed<br />
while eps > tol and iter < maxiter:<br />
50