fast implementation of mixed finite elements in matlabsousedik/classes/slides/undergraduate/... ·...

16
Fast Implementation of mixed finite elements in MATLAB Teddy Weinberg mentor: Bedˇ rich Soused´ ık Department of Mathematics and Statistics University of Maryland, Baltimore County Supported by the National Science Foundation (award DMS-1521563) and by an Undergraduate Research Award from the UMBC Office of Undergraduate Education. DE seminar, April 30, 2018 Teddy Weinberg (UMBC) Vectorized FEM in Matlab April 30, 2018 1 / 16

Upload: others

Post on 11-May-2021

8 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Fast Implementation of mixed finite elements in MATLABsousedik/classes/slides/undergraduate/... · Fast Implementation of mixed nite elements in MATLAB Teddy Weinberg mentor: Bed

Fast Implementation of mixed finite elements inMATLAB

Teddy Weinberg

mentor: Bedrich Sousedık

Department of Mathematics and StatisticsUniversity of Maryland, Baltimore County

Supported by the National Science Foundation (award DMS-1521563) and by anUndergraduate Research Award from the UMBC Office of Undergraduate Education.

DE seminar, April 30, 2018Teddy Weinberg (UMBC) Vectorized FEM in Matlab April 30, 2018 1 / 16

Page 2: Fast Implementation of mixed finite elements in MATLABsousedik/classes/slides/undergraduate/... · Fast Implementation of mixed nite elements in MATLAB Teddy Weinberg mentor: Bed

Objectives

Study partial differential equations modeling flow in porous media.

Implement vectorized finite element method to simulate flow inporous media in MATLAB for various elements.

Compare the effectiveness of the efficient implementation with that ofthe standard approach by numerical experiments.

Teddy Weinberg (UMBC) Vectorized FEM in Matlab April 30, 2018 2 / 16

Page 3: Fast Implementation of mixed finite elements in MATLABsousedik/classes/slides/undergraduate/... · Fast Implementation of mixed nite elements in MATLAB Teddy Weinberg mentor: Bed

Flow in Porous media

Understanding flow in porous media is important for many applications

Managing groundwater reserves

Maintaining CO2 storage facilities

Simulating petroleum reservoirs.

SPE 10 visualization

Teddy Weinberg (UMBC) Vectorized FEM in Matlab April 30, 2018 3 / 16

Page 4: Fast Implementation of mixed finite elements in MATLABsousedik/classes/slides/undergraduate/... · Fast Implementation of mixed nite elements in MATLAB Teddy Weinberg mentor: Bed

Model Problem

From Darcy’s law, consider the model problem:

k−1~u +∇p = 0, (1)

∇ · ~u = f , (2)

wherek ... permeability coefficient,~u ... velocity,p ... pressure,f ... source terms.

Teddy Weinberg (UMBC) Vectorized FEM in Matlab April 30, 2018 4 / 16

Page 5: Fast Implementation of mixed finite elements in MATLABsousedik/classes/slides/undergraduate/... · Fast Implementation of mixed nite elements in MATLAB Teddy Weinberg mentor: Bed

Weak Formulation

In the mixed variational formulation of (1)-(2) we wish to find(~u, p) ∈ (UE ,Q) such that∫

Ωk−1~u · ~v dx −

∫Ωp∇ · ~v dx = 0, ∀~v ∈ U, (3)

−∫

Ω∇ · ~uq dx = −

∫Ωfq dx , ∀q ∈ Q, (4)

where the pair of spaces (U,Q) is selected so that U ⊂ H (Ω; div) andQ ⊂ L2 (Ω), and UE is an extension of U containing velocities that satisfythe essential boundary condition.

Teddy Weinberg (UMBC) Vectorized FEM in Matlab April 30, 2018 5 / 16

Page 6: Fast Implementation of mixed finite elements in MATLABsousedik/classes/slides/undergraduate/... · Fast Implementation of mixed nite elements in MATLAB Teddy Weinberg mentor: Bed

Discretization

We used lowest order Raviart-Thomas finite elements (RT0).

We implemented for triangular, quadrilateral, tetrahedral, andhexahedral elements.

3 1

2

x1

4

x2

2

5

4

1

3

6

Teddy Weinberg (UMBC) Vectorized FEM in Matlab April 30, 2018 6 / 16

Page 7: Fast Implementation of mixed finite elements in MATLABsousedik/classes/slides/undergraduate/... · Fast Implementation of mixed nite elements in MATLAB Teddy Weinberg mentor: Bed

Matrix Form

Let the basis functions for the velocity and pressure spaces be denoted ϕi

and ψj , respectively. In matrix terminology, the discretization of (3)–(4)can be written as a saddle-point linear system[

A BT

B 0

] [up

]=

[0f

], (5)

where

A = [aij ] , aij =

∫Ωk−1 ϕi · ϕj dx ,

B = [bk`] , bk` = −∫

Ω∇ · ϕk ψ` dx ,

f = [f`] , f` = −∫

Ωf ψ` dx

Teddy Weinberg (UMBC) Vectorized FEM in Matlab April 30, 2018 7 / 16

Page 8: Fast Implementation of mixed finite elements in MATLABsousedik/classes/slides/undergraduate/... · Fast Implementation of mixed nite elements in MATLAB Teddy Weinberg mentor: Bed

Vectorization

In MATLAB, iterative structures, also known as loops, are notefficient

However, matrix operations are very efficient

By converting loops to matrix operations, we can significantlyincrease the speed of our code.

Teddy Weinberg (UMBC) Vectorized FEM in Matlab April 30, 2018 8 / 16

Page 9: Fast Implementation of mixed finite elements in MATLABsousedik/classes/slides/undergraduate/... · Fast Implementation of mixed nite elements in MATLAB Teddy Weinberg mentor: Bed

Vectorization

We implemented both a standard and a vectorized version of ourcode.

The standard version finds the stiffness matrices by looping througheach element.

The vectorized version calculates all of the local element matricessimultaneously.

The assembly process of the local element matrices into the globalsystem was also vectorized.

Teddy Weinberg (UMBC) Vectorized FEM in Matlab April 30, 2018 9 / 16

Page 10: Fast Implementation of mixed finite elements in MATLABsousedik/classes/slides/undergraduate/... · Fast Implementation of mixed nite elements in MATLAB Teddy Weinberg mentor: Bed

Non-Vectorized Code

Teddy Weinberg (UMBC) Vectorized FEM in Matlab April 30, 2018 10 / 16

Page 11: Fast Implementation of mixed finite elements in MATLABsousedik/classes/slides/undergraduate/... · Fast Implementation of mixed nite elements in MATLAB Teddy Weinberg mentor: Bed

Vectorized Code

Teddy Weinberg (UMBC) Vectorized FEM in Matlab April 30, 2018 11 / 16

Page 12: Fast Implementation of mixed finite elements in MATLABsousedik/classes/slides/undergraduate/... · Fast Implementation of mixed nite elements in MATLAB Teddy Weinberg mentor: Bed

Testing

Experiments were performed on a (0,1)x(0,1) domain for 2-D and a(0,1)x(0,1)x(0,1).

The domain was discretized into smaller equally sized squares orblocks used for setup of linear system

The experiments were run on a computer with two 8-core Intel XeonE5-2620v4 2.10 GHz procesors with 1 TB memory and LinuxopenSUSE 42.3.

Teddy Weinberg (UMBC) Vectorized FEM in Matlab April 30, 2018 12 / 16

Page 13: Fast Implementation of mixed finite elements in MATLABsousedik/classes/slides/undergraduate/... · Fast Implementation of mixed nite elements in MATLAB Teddy Weinberg mentor: Bed

Results (Quadrilaterals)

problem setup standard vectorized

partitioning te ta te + ta te ta te + ta4× 4 .13 .01 .14 .06 .02 .088× 8 .03 .00 .03 .00 .01 .02

16× 16 .08 .02 .10 .02 .01 .0332× 32 .03 .10 .38 .02 .03 .0564× 64 1.10 .94 2.04 .06 .15 .21

128× 128 5.37 11.96 17.33 .15 .74 .88256× 256 20.02 196.49 216.51 .51 2.25 2.76512× 512 70.12 5163.50 5233.62 2.07 9.55 11.62

Teddy Weinberg (UMBC) Vectorized FEM in Matlab April 30, 2018 13 / 16

Page 14: Fast Implementation of mixed finite elements in MATLABsousedik/classes/slides/undergraduate/... · Fast Implementation of mixed nite elements in MATLAB Teddy Weinberg mentor: Bed

Results (Blocks)

problem setup standard vectorized

partitioning te ta te + ta te ta te + ta4× 4× 4 .18 .01 .19 .04 .02 .068× 8× 8 .31 .09 .40 .03 .02 .05

16× 16× 16 .2.35 2.47 4.82 .15 .14 .2932× 32× 32 18.73 147.96 166.69 .84 .98 1.8264× 64× 64 148.95 18822 18970.95 7.42 8.13 15.55

Teddy Weinberg (UMBC) Vectorized FEM in Matlab April 30, 2018 14 / 16

Page 15: Fast Implementation of mixed finite elements in MATLABsousedik/classes/slides/undergraduate/... · Fast Implementation of mixed nite elements in MATLAB Teddy Weinberg mentor: Bed

Conclusions

As expected, the vectorized version significantly outperformed thestandard version for large numbers of elements

The vectorized version had runtime increase approximately linearlywith the number of elements

Teddy Weinberg (UMBC) Vectorized FEM in Matlab April 30, 2018 15 / 16

Page 16: Fast Implementation of mixed finite elements in MATLABsousedik/classes/slides/undergraduate/... · Fast Implementation of mixed nite elements in MATLAB Teddy Weinberg mentor: Bed

Future Research

Our next step is to work on efficiently solving the linear systemproduced by the current code.

We want to develop and implement preconditioners for iterativesolvers.

We want to determine a posteriori error estimates for our computedsolutions.

Teddy Weinberg (UMBC) Vectorized FEM in Matlab April 30, 2018 16 / 16