MATH 676 Finite element methods in scientifjc computing Wolfgang - - PowerPoint PPT Presentation

math 676 finite element methods in scientifjc computing
SMART_READER_LITE
LIVE PREVIEW

MATH 676 Finite element methods in scientifjc computing Wolfgang - - PowerPoint PPT Presentation

MATH 676 Finite element methods in scientifjc computing Wolfgang Bangerth, T exas A&M University http://www.dealii.org/ Wolfgang Bangerth Lecture 21.6: Boundary conditions Part 3a: Homogenous Dirichlet boundary conditions


slide-1
SLIDE 1

http://www.dealii.org/ Wolfgang Bangerth

MATH 676 – Finite element methods in scientifjc computing

Wolfgang Bangerth, T exas A&M University

slide-2
SLIDE 2

http://www.dealii.org/ Wolfgang Bangerth

Lecture 21.6: Boundary conditions Part 3a: Homogenous Dirichlet boundary conditions

slide-3
SLIDE 3

http://www.dealii.org/ Wolfgang Bangerth

Zero Dirichlet conditions

Consider this simple example:

  • Solve the Laplace equation with zero boundary values:
  • Assume we use the following mesh:

{1,5,6}: “real” degrees of freedom {0,2…4,7…9}: Constrained to zero

−Δu = f in Ω u = 0 on Γ=∂Ω

1 2 3 4 5 6 7 8 9

slide-4
SLIDE 4

http://www.dealii.org/ Wolfgang Bangerth

Zero Dirichlet conditions

There are three approaches:

  • Consider only “free” degrees of freedom
  • Consider all degrees of freedom

– do local assembly without boundary conditions – copy to global system – eliminate boundary DoFs

  • Consider all degrees of freedom

– do local assembly without boundary conditions – eliminate boundary DoFs – copy to global system Criteria: All approaches are correct; which one we like best is determined by considerations of algorithm design!

slide-5
SLIDE 5

http://www.dealii.org/ Wolfgang Bangerth

Zero Dirichlet conditions

Approach 1:

  • Don't enumerate constrained degrees of freedom
  • Only enumerate the 3 unconstrained ones:

1 0, 5 1, 6 2 → → →

1 2 3 4 5 6 7 8 9 X X X X 1 2 X X X

slide-6
SLIDE 6

http://www.dealii.org/ Wolfgang Bangerth

Zero Dirichlet conditions

Approach 1:

  • Then assemble a 3x3 linear system as usual:

1 2 3 4 5 6 7 8 9 X X X X 1 2 X X X

∑j=0

2 [∑K=0 11

(∇ φi, ∇ φ j)K]

Aij

U j=∑K=0

11

(φi,f )K

Fi

∀i=0...2

slide-7
SLIDE 7

http://www.dealii.org/ Wolfgang Bangerth

Zero Dirichlet conditions

Advantages of approach 1:

  • All degrees of freedom are really “free” (i.e., determined

by a linear system)

  • Linear system is much smaller (3x3 vs 10x10)

1 2 3 4 5 6 7 8 9 X X X X 1 2 X X X

slide-8
SLIDE 8

http://www.dealii.org/ Wolfgang Bangerth

Zero Dirichlet conditions

Advantages of approach 1:

  • All degrees of freedom are really “free” (i.e., determined

by a linear system)

  • Linear system is much smaller (3x3 vs 10x10)

But: This size reduction doesn't matter on finer meshes! 1 vs 9 DoFs 9 vs 25 DoFs 49 vs 81 DoFs

slide-9
SLIDE 9

http://www.dealii.org/ Wolfgang Bangerth

Zero Dirichlet conditions

Disdvantages of approach 1:

  • The FEM is at its best if you can do the same on every

cell: – when enumerating degrees of freedom – when assembling – when evaluating the solution at individual points – …

X X X X 1 2 X X X

slide-10
SLIDE 10

http://www.dealii.org/ Wolfgang Bangerth

Zero Dirichlet conditions

Disdvantages of approach 1:

  • If Dirichlet conditions only on parts of the boundary:

Some boundary nodes would have to be treated differently than others.

X 4 6 5 1 2 X X X

slide-11
SLIDE 11

http://www.dealii.org/ Wolfgang Bangerth

Zero Dirichlet conditions

Disdvantages of approach 1:

  • What to do in cases of vector-valued problems and

conditions of the sort u.n=0?

  • Example: Fluid flow with velocity components (ux,uy)
  • Boundary condition here is nxux=-nyuy

1 8 9 2 3 4 5 6 7 10 11 14 15 18 19 16 17 12 13 X 1 8 9 2 X 4 X 10 11 14 15 18 X 16 X X 13 X 7

slide-12
SLIDE 12

http://www.dealii.org/ Wolfgang Bangerth

Zero Dirichlet conditions

Approach 2:

  • Enumerate all degrees of freedom regardless of boundary

conditions Variation 2a:

  • Compute local contributions regardless
  • f boundary DoFs
  • Assemble into one big linear system
  • Zero out rows and columns

for boundary DoFs {0,2,3,4,7,8,9}

  • Fix up zero rows

1 2 3 4 5 6 7 8 9

slide-13
SLIDE 13

http://www.dealii.org/ Wolfgang Bangerth

Zero Dirichlet conditions

Example for approach 2a:

  • Compute local contributions regardless of boundary DoFs
  • Assemble into one big linear system

(forget about sparsity for a moment)

1 2 3 4 5 6 7 8 9

(

a00 a01 a02 a03 a04 a05 a06 a07 a08 a09 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19 a20 a21 a22 a23 a24 a25 a26 a27 a28 a29 a30 a31 a32 a33 a34 a35 a36 a37 a38 a39 a40 a41 a42 a43 a44 a45 a46 a47 a48 a49 a50 a51 a52 a53 a54 a55 a56 a57 a58 a59 a60 a61 a62 a63 a64 a65 a66 a67 a68 a69 a70 a71 a72 a73 a74 a75 a76 a77 a78 a79 a80 a81 a82 a83 a84 a85 a86 a87 a88 a89 a90 a91 a92 a93 a94 a95 a96 a97 a98 a99)( u0 u1 u2 u3 u4 u5 u6 u7 u8 u9) =

(

f 0 f 1 f 2 f 3 f 4 f 5 f 6 f 7 f 8 f 9)

slide-14
SLIDE 14

http://www.dealii.org/ Wolfgang Bangerth

Zero Dirichlet conditions

Example for approach 2a:

  • Compute local contributions regardless of boundary DoFs
  • Assemble into one big linear system
  • Zero out rows and columns for DoFs {0,2,3,4,7,8,9}

1 2 3 4 5 6 7 8 9

(

a00 a01 a02 a03 a04 a05 a06 a07 a08 a09 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19 a20 a21 a22 a23 a24 a25 a26 a27 a28 a29 a30 a31 a32 a33 a34 a35 a36 a37 a38 a39 a40 a41 a42 a43 a44 a45 a46 a47 a48 a49 a50 a51 a52 a53 a54 a55 a56 a57 a58 a59 a60 a61 a62 a63 a64 a65 a66 a67 a68 a69 a70 a71 a72 a73 a74 a75 a76 a77 a78 a79 a80 a81 a82 a83 a84 a85 a86 a87 a88 a89 a90 a91 a92 a93 a94 a95 a96 a97 a98 a99)( u0 u1 u2 u3 u4 u5 u6 u7 u8 u9) =

(

f 0 f 1 f 2 f 3 f 4 f 5 f 6 f 7 f 8 f 9)

slide-15
SLIDE 15

http://www.dealii.org/ Wolfgang Bangerth

Zero Dirichlet conditions

Example for approach 2a:

  • Compute local contributions regardless of boundary DoFs
  • Assemble into one big linear system
  • Zero out rows and columns for DoFs {0,2,3,4,7,8,9}

The resulting system has a 3x3 sub-block for “free” DoFs

1 2 3 4 5 6 7 8 9

(

a11 a15 a16 a51 a55 a56 a61 a65 a66 0)( u0 u1 u2 u3 u4 u5 u6 u7 u8 u9) =

(

f 1 f 5 f 6 0)

slide-16
SLIDE 16

http://www.dealii.org/ Wolfgang Bangerth

Zero Dirichlet conditions

Example for approach 2a:

  • Compute local contributions regardless of boundary DoFs
  • Assemble into one big linear system
  • Zero out rows and columns for DoFs {0,2,3,4,7,8,9}
  • Fix under-determination:

1 2 3 4 5 6 7 8 9

(

1 a11 a15 a16 1 1 1 a51 a55 a56 a61 a65 a66 1 1 1)( u0 u1 u2 u3 u4 u5 u6 u7 u8 u9) =

(

f 1 f 5 f 6 0)

slide-17
SLIDE 17

http://www.dealii.org/ Wolfgang Bangerth

Zero Dirichlet conditions

Result for approach 2a: We get a linear system of the form The solution satisfies

1 2 3 4 5 6 7 8 9

(

1 a11 a15 a16 1 1 1 a51 a55 a56 a61 a65 a66 1 1 1)( u0 u1 u2 u3 u4 u5 u6 u7 u8 u9) =

(

f 1 f 5 f 6 0)

U 0=U 2=U 3=U 4=U 7=U 8=U 9=0

slide-18
SLIDE 18

http://www.dealii.org/ Wolfgang Bangerth

Zero Dirichlet conditions

Result for approach 2a: We get a linear system of the form The solution satisfies

1 2 3 4 5 6 7 8 9

(

1 a11 a15 a16 1 1 1 a51 a55 a56 a61 a65 a66 1 1 1)( u0 u1 u2 u3 u4 u5 u6 u7 u8 u9) =

(

f 1 f 5 f 6 0)

(

a11 a15 a16 a51 a55 a56 a61 a65 a66)( u1 u5 u6) =( f 1 f 5 f 6)

slide-19
SLIDE 19

http://www.dealii.org/ Wolfgang Bangerth

Zero Dirichlet conditions

Summary approach 2a:

  • Compute local contributions regardless of boundary DoFs
  • Assemble into one big linear system
  • Zero out rows and columns for boundary DoFs
  • Fix up zero rows

This results in a linear system that:

  • Has the desired solution
  • Is invertible
  • Has a few more zeros in it
  • Is symmetric if the original matrix was symmetric
  • Is SPD if the original matrix was SPD

1 2 3 4 5 6 7 8 9

slide-20
SLIDE 20

http://www.dealii.org/ Wolfgang Bangerth

Zero Dirichlet conditions

Implementation approach 2a (step-4):

void Step4::assemble_system { …; for (cell=...) { ...assemble cell_matrix, cell_rhs...; ...add cell_matrix, cell_rhs to system_matrix, system_rhs...; } std::map<types::global_dof_index,double> boundary_values; VectorTools::interpolate_boundary_values (dof_handler, 0, ZeroFunction<dim>(), boundary_values); MatrixTools::apply_boundary_values (boundary_values, system_matrix, solution, system_rhs); }

slide-21
SLIDE 21

http://www.dealii.org/ Wolfgang Bangerth

Zero Dirichlet conditions

Summary approach 2a:

  • Compute local contributions regardless of boundary DoFs
  • Assemble into one big linear system
  • Zero out rows and columns for boundary DoFs
  • Fix up zero rows

Advantages:

  • Can do the exact same thing on

every cell during assembly/postprocessing

  • Relegate handling b.c. to a separate

part of the code, independent of assembly

  • Can use same solver regardless of boundary conditions

1 2 3 4 5 6 7 8 9

slide-22
SLIDE 22

http://www.dealii.org/ Wolfgang Bangerth

Zero Dirichlet conditions

Summary approach 2a:

  • Compute local contributions regardless of boundary DoFs
  • Assemble into one big linear system
  • Zero out rows and columns for boundary DoFs
  • Fix up zero rows

Disadvantages:

  • We have a few more rows and columns
  • We have to modify the linear system

after global assembly

1 2 3 4 5 6 7 8 9

slide-23
SLIDE 23

http://www.dealii.org/ Wolfgang Bangerth

Zero Dirichlet conditions

Approach 2:

  • Enumerate all degrees of freedom regardless of boundary

conditions Variation 2b:

  • Compute local contributions regardless
  • f boundary DoFs
  • Zero out rows and columns

for boundary DoFs {0,2,3,4,7,8,9}

  • Fix up zero rows
  • Assemble into one big linear system

1 2 3 4 5 6 7 8 9

slide-24
SLIDE 24

http://www.dealii.org/ Wolfgang Bangerth

Zero Dirichlet conditions

Example for approach 2b: Recall that the linear system is computed from contributions of all cells:

1 2 3 4 5 6 7 8 9

AU = F A = ∑K=0

10

A K F = ∑K=0

10

F

K

1 2 3 4 5 4 6 7 8 10 9

slide-25
SLIDE 25

http://www.dealii.org/ Wolfgang Bangerth

Zero Dirichlet conditions

Example for approach 2b: Recall that the linear system is computed from contributions of all cells. For example:

1 2 3 4 5 6 7 8 9

AU = F

1 2 3 4 5 4 6 7 8 10 9

A

1=

(

a00

1

a01

1

a06

1

a10

1

a11

1

a16

1

a60

1

a61

1

a66

1

0) , F

1=

(

f 0

1

f 1

1

f 6

1

0)

slide-26
SLIDE 26

http://www.dealii.org/ Wolfgang Bangerth

Zero Dirichlet conditions

Example for approach 2b: Recall that the linear system is computed from contributions of all cells. In reality, of course, we only store the dense 3x3 sub-block:

1 2 3 4 5 6 7 8 9

AU = F

1 2 3 4 5 4 6 7 8 10 9

A

1, loc=(

a00

1

a01

1

a06

1

a10

1

a11

1

a16

1

a60

1

a61

1

a66

1 )

, F

1,loc=(

f 0

1

f 1

1

f 6

1)

slide-27
SLIDE 27

http://www.dealii.org/ Wolfgang Bangerth

Zero Dirichlet conditions

Example for approach 2b: Recall that the linear system is computed from contributions of all cells. Zero out rows and columns DoFs {0,2,3,4,7,8,9}:

1 2 3 4 5 6 7 8 9

AU = F

1 2 3 4 5 4 6 7 8 10 9

A

1, loc=(

a00

1

a01

1

a06

1

a10

1

a11

1

a16

1

a60

1

a61

1

a66

1 )

, F

1,loc=(

f 0

1

f 1

1

f 6

1)

slide-28
SLIDE 28

http://www.dealii.org/ Wolfgang Bangerth

Zero Dirichlet conditions

Example for approach 2b: Recall that the linear system is computed from contributions of all cells. Zero out rows and columns DoFs {0,2,3,4,7,8,9}:

1 2 3 4 5 6 7 8 9

AU = F

1 2 3 4 5 4 6 7 8 10 9

A1, loc=( a11

1

a16

1

a61

1

a66

1 )

, F 1,loc=( f 1

1

f 6

1)

slide-29
SLIDE 29

http://www.dealii.org/ Wolfgang Bangerth

Zero Dirichlet conditions

Example for approach 2b: Recall that the linear system is computed from contributions of all cells. Fix up under-determinedness:

1 2 3 4 5 6 7 8 9

AU = F

1 2 3 4 5 4 6 7 8 10 9

A1, loc=( 1 a11

1

a16

1

a61

1

a66

1 )

, F 1,loc=( f 1

1

f 6

1)

slide-30
SLIDE 30

http://www.dealii.org/ Wolfgang Bangerth

Zero Dirichlet conditions

Example for approach 2b: Recall that the linear system is computed from contributions of all cells. Then add to global linear system:

1 2 3 4 5 6 7 8 9

AU = F

1 2 3 4 5 4 6 7 8 10 9

A := A+expand( A

1, loc)

F := F+expand(F

1,loc)

slide-31
SLIDE 31

http://www.dealii.org/ Wolfgang Bangerth

Zero Dirichlet conditions

Summary approach 2b:

  • Compute local contributions regardless of boundary DoFs
  • Zero out rows and columns for boundary DoFs
  • Fix up zero rows
  • Assemble into one big linear system

Actual implementation:

  • The last three operations are all done

at the same time

  • The local contributions are not modified

1 2 3 4 5 6 7 8 9

slide-32
SLIDE 32

http://www.dealii.org/ Wolfgang Bangerth

Zero Dirichlet conditions

Implementation approach 2b (step-6):

void Step6::assemble_system { ConstraintMatrix constraints; VectorTools::interpolate_boundary_values (dof_handler, 0, ZeroFunction<dim>(), constraints); …; for (cell=...) { ...assemble cell_matrix, cell_rhs...; cell->get_dof_indices (local_dof_indices); constraints.distribute_local_to_global (cell_matrix, cell_rhs, local_dof_indices, system_matrix, system_rhs); } }

slide-33
SLIDE 33

http://www.dealii.org/ Wolfgang Bangerth

Zero Dirichlet conditions

Summary approach 2b:

  • Compute local contributions regardless of boundary DoFs
  • Zero out rows and columns for boundary DoFs
  • Fix up zero rows
  • Assemble into one big linear system

Advantages:

  • Can do the exact same thing on

every cell during assembly/postprocessing

  • Relegate handling b.c. to a separate

part of the code, independent of assembly

  • Can use same solver regardless of boundary conditions

1 2 3 4 5 6 7 8 9

slide-34
SLIDE 34

http://www.dealii.org/ Wolfgang Bangerth

Zero Dirichlet conditions

Summary approach 2b:

  • Compute local contributions regardless of boundary DoFs
  • Zero out rows and columns for boundary DoFs
  • Fix up zero rows
  • Assemble into one big linear system

Disdvantages:

  • We have a few more rows and columns
  • We have to modify the linear system

after local integration or during copy-local-to-global (both options are easy and cheap)

1 2 3 4 5 6 7 8 9

slide-35
SLIDE 35

http://www.dealii.org/ Wolfgang Bangerth

Summary

We are driven by algorithm design considerations:

  • We want to do the exact same thing on every cell
  • We want to isolate handling of boundary values to as few

code pieces as possible

  • Dealing with small, dense, local

contributions is simpler than with global linear systems Consequently:

  • Enumerate all degrees of freedom
  • Integrate locally regardless of boundary conditions
  • Deal with boundary values during assembly or after

1 2 3 4 5 6 7 8 9

slide-36
SLIDE 36

http://www.dealii.org/ Wolfgang Bangerth

A final implementation detail

As a postscript: Consider a linear system of the form This matrix is ill-conditioned if Consequence:

  • We should not place 1.0 on the diagonal
  • Algorithm instead use values “similar to other entries”

(

1 a11 a15 a16 1 1 1 a51 a55 a56 a61 a65 a66 1 1 1)( u0 u1 u2 u3 u4 u5 u6 u7 u8 u9) =

(

f 1 f 5 f 6 0)

|aij|≫1 or |aij|≪1

slide-37
SLIDE 37

http://www.dealii.org/ Wolfgang Bangerth

MATH 676 – Finite element methods in scientifjc computing

Wolfgang Bangerth, T exas A&M University