19 January 2020 11:30:35 AM
FEM2D_BVP_SERENE_TEST
C version
Test the FEM2D_BVP_SERENE library.
TEST01
Solve - del ( A del U ) + C U = F
on the unit square with zero boundary conditions.
A1(X,Y) = 1.0
C1(X,Y) = 0.0
F1(X,Y) = 2*X*(1-X)+2*Y*(1-Y)
U1(X,Y) = X * ( 1 - X ) * Y * ( 1 - Y )
Number of X grid values NX = 5
Number of Y grid values NY = 5
I J X Y U Uexact Error
0 0 0.000000 0.000000 0.000000 0.000000 0.000000e+00
1 0 0.250000 0.000000 0.000000 0.000000 0.000000e+00
2 0 0.500000 0.000000 0.000000 0.000000 0.000000e+00
3 0 0.750000 0.000000 0.000000 0.000000 0.000000e+00
4 0 1.000000 0.000000 0.000000 0.000000 0.000000e+00
0 1 0.000000 0.250000 0.000000 0.000000 0.000000e+00
2 1 0.500000 0.250000 0.048631 0.046875 1.755618e-03
4 1 1.000000 0.250000 0.000000 0.000000 0.000000e+00
0 2 0.000000 0.500000 0.000000 0.000000 0.000000e+00
1 2 0.250000 0.500000 0.048631 0.046875 1.755618e-03
2 2 0.500000 0.500000 0.058989 0.062500 3.511236e-03
3 2 0.750000 0.500000 0.048631 0.046875 1.755618e-03
4 2 1.000000 0.500000 0.000000 0.000000 0.000000e+00
0 3 0.000000 0.750000 0.000000 0.000000 0.000000e+00
2 3 0.500000 0.750000 0.048631 0.046875 1.755618e-03
4 3 1.000000 0.750000 0.000000 0.000000 0.000000e+00
0 4 0.000000 1.000000 0.000000 0.000000 0.000000e+00
1 4 0.250000 1.000000 0.000000 0.000000 0.000000e+00
2 4 0.500000 1.000000 0.000000 0.000000 0.000000e+00
3 4 0.750000 1.000000 0.000000 0.000000 0.000000e+00
4 4 1.000000 1.000000 0.000000 0.000000 0.000000e+00
l1 norm of error = 0.000501605
L2 norm of error = 0.000805291
Seminorm of error = 0.0123351
TEST02
Basis function checks.
The matrix Aij = V(j)(X(i),Y(i)) should be the identity.
1.0000 -0.0000 0.0000 0.0000 -0.0000 0.0000 0.0000 -0.0000
0.0000 1.0000 0.0000 -0.0000 0.0000 -0.0000 0.0000 -0.0000
-0.0000 0.0000 1.0000 -0.0000 0.0000 -0.0000 0.0000 -0.0000
-0.0000 0.0000 0.0000 1.0000 -0.0000 0.0000 -0.0000 0.0000
-0.0000 0.0000 -0.0000 0.0000 1.0000 0.0000 -0.0000 0.0000
-0.0000 0.0000 -0.0000 0.0000 0.0000 1.0000 0.0000 0.0000
-0.0000 -0.0000 0.0000 -0.0000 0.0000 -0.0000 1.0000 0.0000
0.0000 -0.0000 0.0000 -0.0000 0.0000 -0.0000 0.0000 1.0000
The vectors dVdX(1:8)(X,Y) and dVdY(1:8)(X,Y)
should both sum to zero for any (X,Y).
Random evaluation point is (0.436837,4.91264)
dVdX dVdY
0 -0.1022 0.1378
1 1.077 0.3414
2 -0.9749 0.9334
3 -0.08355 -1.427
4 -0.004667 0.4932
5 0.0492 -0.3414
6 -0.04453 0.2608
7 0.08355 -0.3987
Sum: -9.714e-17 1.11e-16
TEST03
Solve - del ( A del U ) + C U = F
on the unit square with zero boundary conditions.
A1(X,Y) = 0.0
C1(X,Y) = 1.0
F1(X,Y) = X * ( 1 - X ) * Y * ( 1 - Y )
U1(X,Y) = X * ( 1 - X ) * Y * ( 1 - Y )
This example is contrived so that the system matrix
is the WATHEN matrix.
Number of X grid values NX = 5
Number of Y grid values NY = 5
Wathen elementary mass matrix:
Col: 0 1 2 3 4
Row
0: 6 -6 2 -8 3
1: -6 32 -6 20 -8
2: 2 -6 6 -6 2
3: -8 20 -6 32 -6
4: 3 -8 2 -6 6
5: -8 16 -8 20 -6
6: 2 -8 3 -8 2
7: -6 20 -8 16 -8
Col: 5 6 7
Row
0: -8 2 -6
1: 16 -8 20
2: -8 3 -8
3: 20 -8 16
4: -6 2 -8
5: 32 -6 20
6: -6 6 -6
7: 20 -6 32
I J X Y U Uexact Error
0 0 0.000000 0.000000 0.000000 0.000000 0.000000e+00
1 0 0.250000 0.000000 0.000000 0.000000 0.000000e+00
2 0 0.500000 0.000000 0.000000 0.000000 0.000000e+00
3 0 0.750000 0.000000 0.000000 0.000000 0.000000e+00
4 0 1.000000 0.000000 0.000000 0.000000 0.000000e+00
0 1 0.000000 0.250000 0.000000 0.000000 0.000000e+00
2 1 0.500000 0.250000 0.048828 0.046875 1.953125e-03
4 1 1.000000 0.250000 0.000000 0.000000 0.000000e+00
0 2 0.000000 0.500000 0.000000 0.000000 0.000000e+00
1 2 0.250000 0.500000 0.048828 0.046875 1.953125e-03
2 2 0.500000 0.500000 0.058594 0.062500 3.906250e-03
3 2 0.750000 0.500000 0.048828 0.046875 1.953125e-03
4 2 1.000000 0.500000 0.000000 0.000000 0.000000e+00
0 3 0.000000 0.750000 0.000000 0.000000 0.000000e+00
2 3 0.500000 0.750000 0.048828 0.046875 1.953125e-03
4 3 1.000000 0.750000 0.000000 0.000000 0.000000e+00
0 4 0.000000 1.000000 0.000000 0.000000 0.000000e+00
1 4 0.250000 1.000000 0.000000 0.000000 0.000000e+00
2 4 0.500000 1.000000 0.000000 0.000000 0.000000e+00
3 4 0.750000 1.000000 0.000000 0.000000 0.000000e+00
4 4 1.000000 1.000000 0.000000 0.000000 0.000000e+00
l1 norm of error = 0.000558036
L2 norm of error = 0.00078125
Seminorm of error = 0.0124347
Wathen matrix:
Col: 0 1 2 3 4
Row
0: 6 -6 2 -6 -8
1: -6 32 -6 20 20
2: 2 -6 6 -8 -6
3: -6 20 -8 32 16
4: -8 20 -6 16 32
5: 2 -8 3 -6 -8
6: -8 16 -8 20 20
7: 3 -8 2 -8 -6
Col: 5 6 7
Row
0: 2 -8 3
1: -8 16 -8
2: 3 -8 2
3: -6