Math 610 Computing Assignment 3 2D Boundary Value Problem Spencer Patty

advertisement

Math 610 Computing Assignment 3

Spencer Patty

April 5, 2016

2D Boundary Value Problem

Consider the elliptic boundary value problem: Find u ∈ H 1 (Ω) with Ω ⊂

R

2 satisfying

− ∆ u + qu = f,

∂u

= g,

∂ν for for x x

∂ Ω with q > 0 given, f ∈ L

2

(Ω) and ν the outward pointing unit normal to ∂ Ω.

Exercise 1: 2D Laplacian with Neumann Data and Lower Order

Terms (50%)

Let Ω = (0 , 1)

2

, q = 3, g = 0, and f ( x, y ) = (3 + 2 π

2

) cos( πx ) cos( πy ) which has exact solution u ( x, y ) = cos(

1

32

,

πx

1 ,

) cos(

1

πy ). Compute the L 2 (Ω) and H 1 (Ω) errors with the meshes defined by

. Use the linear finite element method to compute your solution.

| T | ≤ 1

2 h 2 with h = 1

16

64 128

In addition to the table of rates, provide a log-log plot with x-axis mesh size (h) and y-axis the L2 and H1

, errors. Matlab provides a nice l oglog() plotting function for doing this. Since you are using linear elements, you should observe that the L2 norm has slope converging to 2 and the H1 norm has slope converging to 1.

Exercise 2: 2D Laplacian with Neumann Data and Lower Order

Terms (50%)

Now compute the solution with Ω = [ − 1 , 1] 2 \ ( − 1 , 0) 2 , the L-shaped domain from Lab 02. Let q = 1, g = 1 and f = 1. Plot the solutions.

Notice we do not provide a solution to compare against so there is no way to compute the error rates to know if our solution is even remotely correct. In Exercise 1, we (hopefully) verified that that our solutions are behaving properly with respect to the FEM theory. Once we are resonably confident that our implementation is behaving properly by debugging and testing with various known solutions, we are ready to run it for problems with which we don’t know the solution and still feel somewhat confident in our results.

What happens if we instead set q = 0?

1

Bonus: Implement a solver for Poisson Equation with Pure Neumann data

Notice that for Poisson’s equation with pure Neumann data

− ∆ u = f,

∂u

= g,

∂ν for for x x

∂ Ω there are some compatibility conditions that must be met for well posedness, namely

Z

Ω f ( x ) d x =

Z

− ∆ u · 1 d x = −

Z

∂ Ω

1 ·

∂u d x +

∂ν

Z

∇ 1 · ∇ ud x = −

Z

∂ Ω gd x (1)

Since − ∆ u = − ∆( u + c ) for c ∈

R

, there is an extra degree of freedom that is not specified by your system.

We typically choose the solution to have mean value 0

1

| Ω |

Z

Ω u ( x ) d x = 0 (2) to take care of this final dof. In order to implement this, there are three main options: 1) build this null space into our basis functions (hard) 2) augment the system with a lagrange multiplier that enforces the mean value constraint (not so hard but not very easy either) 3) fix a degree of freedom (change the system

(matrix and rhs) to enforce one of the degrees of freedom, say u

1

= 0 to be zero), solve the adjusted system, compute the mean value by looping through the triangles, and then adjust the solution to have mean value

= 0. (easy)

There is much discussion about which is best. A good approach is to use a solver which can handle the null spaces and are built for solving the Poisson equation with pure neumann data. The PETSc linear algebra (KrylovSolver) package has such a solver and would be appropriate to use for solving systems like this. However, in many cases, the ”easy” solution where we fix a degree of freedom is often sufficient.

You could write a function to compute the mean value (don’t forget to divide by the size of the domain) of a given FE function and adjust your system to account for the extra degree of freedom to be fixed. You could try a manufactured solution to test your system and test out your solution and obtain the convergence rates.

A manufactured solution for the poisson equation with pure neumann data can be computed by starting with an exact solution u ( x, y ) = cos(2 πx ) cos(2 πy ) that has mean zero on Ω = (0 , 1) 2 . Then run it through the pde to compute the exact rhs and neumann data.

f ( x, y ) = − ∆ u ( x, y ) = 8 π

2 cos(2 πx ) cos(2 πy ) (3) and g ( x, y ) = ∇ u · ν

= − 2 π sin(2 πx ) cos(2 πy ) cos(2 πx ) sin(2 πy )

· ν

 − cos(2 πx ) sin(2 πy ) , on line segment (0,0) to (1,0)

 sin(2 πx ) cos(2 πy ) , on line segment (1,0) to (1,1)

= − 2 π

 cos(2 πx ) sin(2 πy ) , on line segment (0,1) to (1,1)

 − sin(2 πx ) cos(2 πy ) , on line segment (0,0) to (0,1)

= 0

Notice that R

Ω f d x = 0 = R

∂ Ω gd x so our compatibility conditions are satisfied. Test your fem approach with the above f , g and u , you should obtain the optimal convergence rates as in problem 1.

2

Download