A FEniCS Tutorial - FEniCS Project
A FEniCS Tutorial - FEniCS Project
A FEniCS Tutorial - FEniCS Project
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
To see how repeated assembly can be avoided, we look at the L(v) form in<br />
(75), which in general varies with time through u k−1 , f k , and possibly also with<br />
∆t if the time step is adjusted during the simulation. The technique for avoiding<br />
repeated assembly consists in expanding the finite element functions in sums<br />
overthebasisfunctionsφ i , asexplainedinSection1.15, toidentifymatrix-vector<br />
products that build up the complete system. We have u k−1 = ∑ N<br />
j=1 Uk−1 j φ j ,<br />
and we can expand f k as f k = ∑ N<br />
j=1 Fk j φ j. Inserting these expressions in L(v)<br />
and using v = ˆφ i result in<br />
∫<br />
Ω<br />
(<br />
u k−1 +∆tf k) ∫<br />
vdx =<br />
=<br />
Ω<br />
⎛<br />
N∑<br />
⎝<br />
j=1<br />
N∑<br />
(∫<br />
j=1<br />
Ω<br />
U k−1<br />
j<br />
φ j +∆t<br />
)<br />
ˆφ i φ j dx U k−1<br />
j<br />
N∑<br />
j=1<br />
F k j φ j<br />
⎞<br />
⎠ ˆφi dx,<br />
+∆t<br />
N∑<br />
(∫<br />
j=1<br />
Ω<br />
)<br />
ˆφ i φ j dx Fj k .<br />
Introducing M ij = ∫ Ω ˆφ i φ j dx, we see that the last expression can be written<br />
N∑<br />
j=1<br />
M ij U k−1<br />
j<br />
+∆t<br />
N∑<br />
M ij Fj k ,<br />
j=1<br />
which is nothing but two matrix-vector products,<br />
MU k−1 +∆tMF k ,<br />
if M is the matrix with entries M ij and<br />
and<br />
U k−1 = (U k−1<br />
1 ,...,U k−1<br />
N )T ,<br />
F k = (F k 1,...,F k N) T .<br />
We have immediate access to U k−1 in the program since that is the vector<br />
in the u_1 function. The F k vector can easily be computed by interpolating<br />
the prescribed f function (at each time level if f varies with time). Given M,<br />
U k−1 , and F k , the right-hand side b can be calculated as<br />
b = MU k−1 +∆tMF k .<br />
That is, no assembly is necessary to compute b.<br />
The coefficient matrix A can also be split into two terms. We insert v = ˆφ i<br />
and u k = ∑ N<br />
j=1 Uk j φ j in the expression (74) to get<br />
N∑<br />
(∫<br />
j=1<br />
Ω<br />
)<br />
ˆφ i φ j dx Uj k +∆t<br />
N∑<br />
(∫<br />
j=1<br />
∇ˆφ i ·∇φ j dx<br />
Ω<br />
which can be written as a sum of matrix-vector products,<br />
MU k +∆tKU k = (M +∆tK)U k ,<br />
)<br />
Uj k ,<br />
64