Numerical methods for PDEs 1
2016/17 – problem set n. 3
Practical part for 21.10.2016
3.1. Implementation of a finite element method. Implement the
linear finite element method for the boundary value problem
−u�� = f in [a, b],
u(0) = 0,
u� (1) = 0,
where a, b ∈ R with a < b. More precisely, implement a function, for
example in C of the type
void SolveLins(int N, double *mesh, double *sol)
where
N: stands for the dimension of the discrete space,
mesh: points to an array of double containing the nodes of the mesh
and
sol: points to an array of double where the coefficients of the approximate solution can be stored.
To this end,
• assume that the load term f is given as a function, for example in
C of the type
double f(double x)
• use the approach of problem 2.2 to assemble the linear system by
means of a loop over the small intervals, computing the stiffness
matrix on the reference interval by hand,
• use the function thomas of problem 2.1 to solve the assembled linear
system.
Ensure that, apart from the zeros in the stiffness matrix, the linear
system is assembled with a number of operations that is of order N.
Moreover, implement a function, for example in C of the type
double *MakeUnifMesh(double a, double b, int NPoints,
double *mesh)
that returns the pointer to an array containing the NPoints+2 equidistant nodes of a uniform mesh of the interval [a,b]. If mesh == NIL,
allocate the memory for the array, otherwise use the address mesh.
Test MakeUnifMesh and SolveLins.
Theoretical part for 24.10.2016
3.2. Finite elements and finite differences. Consider the problem
−u�� = f in ]0, 1[,
u(0) = 0 = u(1)
with f ∈ C 0 [0, 1]. Given a uniform mesh
i
(i = 0, . . . , n ∈ N),
M:
xi =
n
set
�
S := V ∈ C 0 [0, 1] | ∀i = 1, . . . n V|]xi−1 ,xi [ ∈ P1 (]xi−1 , xi [),
V (0) = 0 = V (1)
and recall the trapezoidal rule
� 1
n
�
�
1�
g≈
(xi − xi−1 ) g(xi−1 ) + g(xi )
2 i=1
0
�
Let UFE ∈ S be such that
� 1
n
�
�
1�
�
UFE
ϕ� =
(xi − xi−1 ) (f ϕ)(xi−1 ) + (f ϕ)(xi )
∀ϕ ∈ S
2 i=1
0
and (UFD,i )i be such that
−UFD,i−1 + 2UFD,i − UFD,i+1
= f (xi ) i = 1, . . . n − 1
h2
UFD,0 = 0 = UFD,n
with h = 1/n. Verify that
∀i = 0, . . . , n
UFE (xi ) = UFD,i .
3.3. Simplices and affine maps. Let Kd := conv{0, e1 , . . . , ed } be
the Cartesian reference simplex in Rd . Prove that for any d-simplex K
there is a bi-affine map F such that
F (Kd ) = K.
Deduce that all d-simplices in Rd are affine equivalent. Moreover, show
that the matrix A of F verifies
√
� −1 �
diam K
2
and �A � ≤
.
�A� ≤
Cd
ρK
where Cd is a constant depending only on d.
© Copyright 2025 Paperzz