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 http://www.dealii.org/ Wolfgang Bangerth
Zero Dirichlet conditions Consider this simple example: ● Solve the Laplace equation with zero boundary values: −Δ u = f in Ω u = 0 on Γ=∂Ω ● Assume we use the following mesh: 3 2 4 {1,5,6}: “real” degrees of freedom 1 0 5 {0,2…4,7…9}: Constrained to zero 9 6 7 8 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 ! 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 → → → 3 X 2 4 X X 1 0 0 5 X 1 9 6 X 2 7 X 8 X http://www.dealii.org/ Wolfgang Bangerth
Zero Dirichlet conditions Approach 1: ● Then assemble a 3x3 linear system as usual: 2 [ ∑ K = 0 (∇ φ i , ∇ φ j ) K ] 11 11 ∑ j = 0 U j = ∑ K = 0 (φ i ,f ) K ∀ i = 0...2 ⏟ ⏟ F i A ij 3 X 2 4 X X 1 0 0 5 X 1 9 6 X 2 7 X 8 X 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) 3 X 2 4 X X 1 0 0 5 X 1 9 6 X 2 7 X 8 X 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 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 0 X 1 X 2 X X 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. 6 4 5 0 X 1 X 2 X X 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 ( u x ,u y ) ● Boundary condition here is n x u x =- n y u y 2 2 6 X 3 4 4 X 7 7 5 X 8 8 0 10 X 10 9 9 1 11 1 11 12 14 X 14 13 15 13 15 18 18 16 16 19 X 17 X 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 of boundary DoFs ● Assemble into one big linear system ● Zero out rows and columns 3 2 4 for boundary DoFs {0,2,3,4,7,8,9} 1 0 5 ● Fix up zero rows 9 6 7 8 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) ( a 99 )( u 9 ) ( f 9 ) a 00 a 01 a 02 a 03 a 04 a 05 a 06 a 07 a 08 a 09 u 0 f 0 a 10 a 11 a 12 a 13 a 14 a 15 a 16 a 17 a 18 a 19 u 1 f 1 3 2 4 a 20 a 21 a 22 a 23 a 24 a 25 a 26 a 27 a 28 a 29 u 2 f 2 a 30 a 31 a 32 a 33 a 34 a 35 a 36 a 37 a 38 a 39 u 3 f 3 1 a 40 a 41 a 42 a 43 a 44 a 45 a 46 a 47 a 48 a 49 u 4 f 4 0 5 = a 50 a 51 a 52 a 53 a 54 a 55 a 56 a 57 a 58 a 59 u 5 f 5 a 60 a 61 a 62 a 63 a 64 a 65 a 66 a 67 a 68 a 69 u 6 f 6 9 6 a 70 a 71 a 72 a 73 a 74 a 75 a 76 a 77 a 78 a 79 u 7 f 7 a 80 a 81 a 82 a 83 a 84 a 85 a 86 a 87 a 88 a 89 u 8 f 8 7 a 90 a 91 a 92 a 93 a 94 a 95 a 96 a 97 a 98 8 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} ( a 99 )( u 9 ) ( f 9 ) a 00 a 01 a 02 a 03 a 04 a 05 a 06 a 07 a 08 a 09 u 0 f 0 a 10 a 11 a 12 a 13 a 14 a 15 a 16 a 17 a 18 a 19 u 1 f 1 3 2 4 a 20 a 21 a 22 a 23 a 24 a 25 a 26 a 27 a 28 a 29 u 2 f 2 a 30 a 31 a 32 a 33 a 34 a 35 a 36 a 37 a 38 a 39 u 3 f 3 1 a 40 a 41 a 42 a 43 a 44 a 45 a 46 a 47 a 48 a 49 u 4 f 4 0 5 = a 50 a 51 a 52 a 53 a 54 a 55 a 56 a 57 a 58 a 59 u 5 f 5 a 60 a 61 a 62 a 63 a 64 a 65 a 66 a 67 a 68 a 69 u 6 f 6 9 6 a 70 a 71 a 72 a 73 a 74 a 75 a 76 a 77 a 78 a 79 u 7 f 7 a 80 a 81 a 82 a 83 a 84 a 85 a 86 a 87 a 88 a 89 u 8 f 8 7 a 90 a 91 a 92 a 93 a 94 a 95 a 96 a 97 a 98 8 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 0 ) ( u 9 ) ( ( 0 ) u 0 0 0 0 0 0 0 0 0 0 0 0 u 1 0 a 11 0 0 0 a 15 a 16 0 0 0 f 1 3 2 4 u 2 0 0 0 0 0 0 0 0 0 0 0 u 3 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 u 4 0 0 5 = 0 a 51 0 0 0 a 55 a 56 0 0 0 f 5 u 5 0 a 61 0 0 0 a 65 a 66 0 0 0 f 6 u 6 9 6 0 0 0 0 0 0 0 0 0 0 0 u 7 0 0 0 0 0 0 0 0 0 0 0 u 8 0 0 0 0 0 0 0 0 0 7 8 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 ) ( u 9 ) ( ( 0 ) u 0 1 0 0 0 0 0 0 0 0 0 0 u 1 0 a 11 0 0 0 a 15 a 16 0 0 0 f 1 3 2 4 u 2 0 0 1 0 0 0 0 0 0 0 0 u 3 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 u 4 0 0 5 = 0 a 51 0 0 0 a 55 a 56 0 0 0 f 5 u 5 0 a 61 0 0 0 a 65 a 66 0 0 0 f 6 u 6 9 6 0 0 0 0 0 0 0 1 0 0 0 u 7 0 0 0 0 0 0 0 0 1 0 0 u 8 0 0 0 0 0 0 0 0 0 7 8 http://www.dealii.org/ Wolfgang Bangerth
Zero Dirichlet conditions Result for approach 2a: We get a linear system of the form 1 ) ( u 9 ) ( ( 0 ) u 0 1 0 u 1 a 11 a 15 a 16 f 1 u 2 1 0 u 3 1 0 1 u 4 0 = a 51 a 55 a 56 f 5 u 5 a 61 a 65 a 66 f 6 u 6 1 0 u 7 3 1 0 u 8 2 4 1 The solution satisfies 0 5 U 0 = U 2 = U 3 = U 4 = U 7 = U 8 = U 9 = 0 9 6 7 8 http://www.dealii.org/ Wolfgang Bangerth
Zero Dirichlet conditions Result for approach 2a: We get a linear system of the form 1 ) ( u 9 ) ( ( 0 ) u 0 1 0 u 1 a 11 a 15 a 16 f 1 u 2 1 0 u 3 1 0 1 u 4 0 = a 51 a 55 a 56 f 5 u 5 a 61 a 65 a 66 f 6 u 6 1 0 u 7 3 1 0 u 8 2 4 1 The solution satisfies 0 5 ( a 66 )( u 6 ) = ( f 6 ) a 11 a 15 a 16 u 1 f 1 9 6 a 51 a 55 a 56 u 5 f 5 7 a 61 a 65 8 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 3 2 4 1 This results in a linear system that: 0 5 ● Has the desired solution 9 6 ● Is invertible ● Has a few more zeros in it 7 8 ● Is symmetric if the original matrix was symmetric ● Is SPD if the original matrix was SPD 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); } 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 3 2 4 1 Advantages: 0 5 ● Can do the exact same thing on 9 6 every cell during assembly/postprocessing ● Relegate handling b.c. to a separate 7 8 part of the code, independent of assembly ● Can use same solver regardless of boundary conditions http://www.dealii.org/ Wolfgang Bangerth
Recommend
More recommend