libmesh experience and usage - university of texas at austinroystgnr/libmeshflows1.pdflibmesh...

Post on 28-Jun-2020

1 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

LibMesh Experience and Usage

John W. Petersonpeterson@cfdlab.ae.utexas.edu

and Roy H. Stognerroystgnr@cfdlab.ae.utexas.edu

Univ. of Texas at Austin

September 9, 2008

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

1 Introduction

2 Weighted Residuals

3 Poisson Equation

4 Other Examples

5 Essential BCs

6 Some Extensions

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

1 Introduction

2 Weighted Residuals

3 Poisson Equation

4 Other Examples

5 Essential BCs

6 Some Extensions

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

Library Description

PetscMetis

Mpich

Laspack

LibMesh

STL

RBM

TumorAngiogenesis

CompressibleNS

DD

Library Structure• Basic libraries

are LibMesh’s“roots”

• Application“branches” builtoff the library“trunk”

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

A Generic BVP

• We assume there is aBoundary ValueProblem of the form

M∂u∂t

= F(u) ∈ Ω

G(u) = 0 ∈ Ω

u = uD ∈ ∂ΩD

N(u) = 0 ∈ ∂ΩN

u(x, 0) = u0(x)

Ω

∂ΩD

∂ΩN

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

A Generic BVP

• Associated to theproblem domain Ω is aLibMesh data structurecalled a Mesh

• A Mesh is essentially acollection of finiteelements

Ωh :=⋃

e

Ωe

Ωh

• LibMesh provides some simple structured meshgeneration routines, file inputs, and interfaces toTriangle and TetGen.

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

A Generic BVP

• Associated to theproblem domain Ω is aLibMesh data structurecalled a Mesh

• A Mesh is essentially acollection of finiteelements

Ωh :=⋃

e

Ωe

Ωh

• LibMesh provides some simple structured meshgeneration routines, file inputs, and interfaces toTriangle and TetGen.

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

Non-Trivial Applications

• LibMesh provides several of the tools necessary toconstruct these systems, but it is not specificallywritten to solve any one problem.

• First, a few of the non-trivial applications which havebeen built on top of the library.

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

Natural Convection

• Tetrahedral mesh of “pipe” geometry. Stream ribbonscolored by temperature.

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

Surface-Tension-Driven Flow

• Adaptive grid solution shown with temperaturecontours and velocity vectors.

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

Double-Diffusive Convection

• Solute contours: a plume of warm, low-salinity fluid isconvected upward through a porous medium.

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

Tumor Angiogenesis

• The tumor secretes a chemical which stimulatesblood vessel formation.

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

Phase Separation

• Directed pattern self-assembly in spinodaldecomposition of binary mixture

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

Compressible Flow

Compressible Shocked Flow

• Original compressible flow code written by Ben Kirkutilizing libMesh.• Solves both Compressible Navier Stokes and Inviscid

Euler.• Includes both SUPG and a shock capturing scheme.

• Original redistribution code written by Larisa Branets.• Simultaneous optimization of element shape and size.• Directable via user supplied error estimate.

• Integration work done by Derek Gaston.• Combination of redistribution, h refinement.• Applicable to other problem classes.

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

Compressible Flow

Compressible Shocked Flow

• Original compressible flow code written by Ben Kirkutilizing libMesh.• Solves both Compressible Navier Stokes and Inviscid

Euler.• Includes both SUPG and a shock capturing scheme.

• Original redistribution code written by Larisa Branets.• Simultaneous optimization of element shape and size.• Directable via user supplied error estimate.

• Integration work done by Derek Gaston.• Combination of redistribution, h refinement.• Applicable to other problem classes.

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

Compressible Flow

Compressible Shocked Flow

• Original compressible flow code written by Ben Kirkutilizing libMesh.• Solves both Compressible Navier Stokes and Inviscid

Euler.• Includes both SUPG and a shock capturing scheme.

• Original redistribution code written by Larisa Branets.• Simultaneous optimization of element shape and size.• Directable via user supplied error estimate.

• Integration work done by Derek Gaston.• Combination of redistribution, h refinement.• Applicable to other problem classes.

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

Compressible Flow

Compressible Shocked Flow

• Original compressible flow code written by Ben Kirkutilizing libMesh.• Solves both Compressible Navier Stokes and Inviscid

Euler.• Includes both SUPG and a shock capturing scheme.

• Original redistribution code written by Larisa Branets.• Simultaneous optimization of element shape and size.• Directable via user supplied error estimate.

• Integration work done by Derek Gaston.• Combination of redistribution, h refinement.• Applicable to other problem classes.

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

Compressible Flow

Compressible Shocked Flow

• Original compressible flow code written by Ben Kirkutilizing libMesh.• Solves both Compressible Navier Stokes and Inviscid

Euler.• Includes both SUPG and a shock capturing scheme.

• Original redistribution code written by Larisa Branets.• Simultaneous optimization of element shape and size.• Directable via user supplied error estimate.

• Integration work done by Derek Gaston.• Combination of redistribution, h refinement.• Applicable to other problem classes.

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

Compressible Flow

Compressible Shocked Flow

• Original compressible flow code written by Ben Kirkutilizing libMesh.• Solves both Compressible Navier Stokes and Inviscid

Euler.• Includes both SUPG and a shock capturing scheme.

• Original redistribution code written by Larisa Branets.• Simultaneous optimization of element shape and size.• Directable via user supplied error estimate.

• Integration work done by Derek Gaston.• Combination of redistribution, h refinement.• Applicable to other problem classes.

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

Compressible Flow

Compressible Shocked Flow

• Original compressible flow code written by Ben Kirkutilizing libMesh.• Solves both Compressible Navier Stokes and Inviscid

Euler.• Includes both SUPG and a shock capturing scheme.

• Original redistribution code written by Larisa Branets.• Simultaneous optimization of element shape and size.• Directable via user supplied error estimate.

• Integration work done by Derek Gaston.• Combination of redistribution, h refinement.• Applicable to other problem classes.

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

Compressible Flow

Compressible Shocked Flow

• Original compressible flow code written by Ben Kirkutilizing libMesh.• Solves both Compressible Navier Stokes and Inviscid

Euler.• Includes both SUPG and a shock capturing scheme.

• Original redistribution code written by Larisa Branets.• Simultaneous optimization of element shape and size.• Directable via user supplied error estimate.

• Integration work done by Derek Gaston.• Combination of redistribution, h refinement.• Applicable to other problem classes.

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

Compressible Flow

Compressible Shocked Flow

• Original compressible flow code written by Ben Kirkutilizing libMesh.• Solves both Compressible Navier Stokes and Inviscid

Euler.• Includes both SUPG and a shock capturing scheme.

• Original redistribution code written by Larisa Branets.• Simultaneous optimization of element shape and size.• Directable via user supplied error estimate.

• Integration work done by Derek Gaston.• Combination of redistribution, h refinement.• Applicable to other problem classes.

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

Compressible Flow

Problem Specification

• The problem studied is that of an oblique shockgenerated by a 10o wedge angle.• This problem has an exact solution for density which

is a step function.• Utilizing libmesh’s exact solution capability the exact

L2 error can be solved for.• The exact solution is shown below:

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

Compressible Flow

Problem Specification

• The problem studied is that of an oblique shockgenerated by a 10o wedge angle.• This problem has an exact solution for density which

is a step function.• Utilizing libmesh’s exact solution capability the exact

L2 error can be solved for.• The exact solution is shown below:

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

Compressible Flow

Problem Specification

• The problem studied is that of an oblique shockgenerated by a 10o wedge angle.• This problem has an exact solution for density which

is a step function.• Utilizing libmesh’s exact solution capability the exact

L2 error can be solved for.• The exact solution is shown below:

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

Compressible Flow

Problem Specification

• The problem studied is that of an oblique shockgenerated by a 10o wedge angle.• This problem has an exact solution for density which

is a step function.• Utilizing libmesh’s exact solution capability the exact

L2 error can be solved for.• The exact solution is shown below:

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

Compressible Flow

Uniformly Refined Solutions

• For comparison purposes, here is a mesh and asolution after 1 uniform refinement with 10890 DOFs.

x

y

0 0.2 0.4 0.6 0.8 10

0.2

0.4

0.6

0.8

1

(a) Mesh after 1 uniform re-finement.

x

y

0 0.2 0.4 0.6 0.8 10

0.2

0.4

0.6

0.8

1

r

1.451.41.351.31.251.21.151.11.051

(b) Solution after 1 uniformrefinement.

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

Compressible Flow

H-Adapted Solutions

• A flux jump indicator was employed as the errorindcator along with a statistical flagging scheme.

• Here is a mesh and solution after 2 adaptiverefinements containing 10800 DOFs:

x

y

0 0.2 0.4 0.6 0.8 10

0.2

0.4

0.6

0.8

1

(c) Mesh, 2 refinements

x

y

0 0.2 0.4 0.6 0.8 10

0.2

0.4

0.6

0.8

1

r

1.451.41.351.31.251.21.151.11.051

(d) Solution

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

Compressible Flow

H-Adapted Solutions

• A flux jump indicator was employed as the errorindcator along with a statistical flagging scheme.

• Here is a mesh and solution after 2 adaptiverefinements containing 10800 DOFs:

x

y

0 0.2 0.4 0.6 0.8 10

0.2

0.4

0.6

0.8

1

(e) Mesh, 2 refinements

x

y

0 0.2 0.4 0.6 0.8 10

0.2

0.4

0.6

0.8

1

r

1.451.41.351.31.251.21.151.11.051

(f) Solution

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

Compressible Flow

Redistributed Solutions

• Redistribution utilizing the same flux jump indicator.

x

y

0 0.2 0.4 0.6 0.8 10

0.2

0.4

0.6

0.8

1

(g) Mesh, 8 redistributionsteps

x

y

0 0.2 0.4 0.6 0.8 10

0.2

0.4

0.6

0.8

1

r

1.451.41.351.31.251.21.151.11.051

(h) Solution

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

Compressible Flow

Redistributed and Adapted

• Now combining the two, here are the mesh andsolution after 2 adaptations beyond the previousredistribution containing 10190 DOFs.

x

y

0 0.2 0.4 0.6 0.8 10

0.2

0.4

0.6

0.8

1

(i) Mesh, 2 refinements

x

y

0 0.2 0.4 0.6 0.8 10

0.2

0.4

0.6

0.8

1

r

1.451.41.351.31.251.21.151.11.051

(j) Solution

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

Compressible Flow

Solution Comparison

• For a better comparison here are 3 of the solutions,each with around 11000 DOFs:

x

y

0 0.2 0.4 0.6 0.8 10

0.2

0.4

0.6

0.8

1

r

1.451.41.351.31.251.21.151.11.051

(k) Uniform.

x

y

0 0.2 0.4 0.6 0.8 10

0.2

0.4

0.6

0.8

1

r

1.451.41.351.31.251.21.151.11.051

(l) Adaptive.

x

y

0 0.2 0.4 0.6 0.8 10

0.2

0.4

0.6

0.8

1

r

1.451.41.351.31.251.21.151.11.051

(m) R + H.

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

Compressible Flow

Error Plot

• libmesh provides capability for computing error normsagainst an exact solution.

• The exact solution is not in H1 therefore we onlyobtain the L2 convergence plot:

3.5 4.0 4.5 5.001 sfoD )N(gol

-2.2

-2.0

-1.8

-1.6

-1.4

-1.2

01)r

orrE2

L(g

ol

UniformAdaptivityRedist + Adapt

(n) LogLog plot of L2 vs DOFs.

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

Compressible Flow

Error Plot

• libmesh provides capability for computing error normsagainst an exact solution.

• The exact solution is not in H1 therefore we onlyobtain the L2 convergence plot:

3.5 4.0 4.5 5.001 sfoD )N(gol

-2.2

-2.0

-1.8

-1.6

-1.4

-1.2

01)r

orrE2

L(g

ol

UniformAdaptivityRedist + Adapt

(o) LogLog plot of L2 vs DOFs.

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

Compressible Flow

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

1 Introduction

2 Weighted Residuals

3 Poisson Equation

4 Other Examples

5 Essential BCs

6 Some Extensions

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

• The point of departure in any FE analysis which usesLibMesh is the weighted residual statement

(F(u), v) = 0 ∀v ∈ V

• Or, more precisely, the weighted residual statementassociated with the finite-dimensional space Vh ⊂ V

(F(uh), vh) = 0 ∀vh ∈ Vh

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

• The point of departure in any FE analysis which usesLibMesh is the weighted residual statement

(F(u), v) = 0 ∀v ∈ V

• Or, more precisely, the weighted residual statementassociated with the finite-dimensional space Vh ⊂ V

(F(uh), vh) = 0 ∀vh ∈ Vh

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

Some Examples

Poisson Equation

−∆u = f ∈ Ω

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

Some Examples

Poisson Equation

−∆u = f ∈ Ω

Weighted Residual Statement

(F(u), v) :=

∫Ω

[∇u · ∇v− fv] dx

+

∫∂ΩN

(∇u · n) v ds

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

Some Examples

Linear Convection-Diffusion

−k∆u + b · ∇u = f ∈ Ω

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

Some Examples

Linear Convection-Diffusion

−k∆u + b · ∇u = f ∈ Ω

Weighted Residual Statement

(F(u), v) :=

∫Ω

[k∇u · ∇v + (b · ∇u)v− fv] dx

+

∫∂ΩN

k (∇u · n) v ds

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

Some Examples

Stokes Flow

∇p− ν∆u = f∇ · u = 0 ∈ Ω

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

Some Examples

Stokes Flow

∇p− ν∆u = f∇ · u = 0 ∈ Ω

Weighted Residual Statement

u := [u, p] , v := [v, q]

(F(u), v) :=

∫Ω

[−p (∇ · v) + ν∇u :∇v− f · v

+ (∇ · u) q] dx +

∫∂ΩN

(ν∇u− pI) n · v ds

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

Some Examples

• To obtain the approximate problem, we simplyreplace u← uh, v← vh, and Ω← Ωh in the weightedresidual statement.

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

1 Introduction

2 Weighted Residuals

3 Poisson Equation

4 Other Examples

5 Essential BCs

6 Some Extensions

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

Weighted Residual Statement

• For simplicity we start with the weighted residualstatement arising from the Poisson equation, with∂ΩN = ∅,

(F(uh), vh) :=∫Ωh

[∇uh · ∇vh − fvh] dx = 0 ∀vh ∈ Vh

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

Element Integrals

• The integral over Ωh . . .

is written as a sum ofintegrals over the Ne finite elements:

0 =

∫Ωh

[∇uh · ∇vh − fvh] dx ∀vh ∈ Vh

=Ne∑

e=1

∫Ωe

[∇uh · ∇vh − fvh] dx ∀vh ∈ Vh

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

Element Integrals

• The integral over Ωh . . . is written as a sum ofintegrals over the Ne finite elements:

0 =

∫Ωh

[∇uh · ∇vh − fvh] dx ∀vh ∈ Vh

=Ne∑

e=1

∫Ωe

[∇uh · ∇vh − fvh] dx ∀vh ∈ Vh

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

Finite Element Basis Functions

• An element integral willhave contributions onlyfrom the global basisfunctions correspondingto its nodes.

• We call these local basisfunctions φi, 0 ≤ i ≤ Ns.

vh∣∣Ωe

=

Ns∑i=1

ciφi

∫Ωe

vh dx =

Ns∑i=1

ci

∫Ωe

φi dx

Ωe

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

Finite Element Basis Functions

• An element integral willhave contributions onlyfrom the global basisfunctions correspondingto its nodes.

• We call these local basisfunctions φi, 0 ≤ i ≤ Ns.

vh∣∣Ωe

=

Ns∑i=1

ciφi

∫Ωe

vh dx =

Ns∑i=1

ci

∫Ωe

φi dx

Ωe

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

Element Matrix and Load Vector

• The element integrals . . .∫Ωe

[∇uh · ∇vh − fvh] dx

• are written in terms of the local “φi” basis functions

Ns∑j=1

uj

∫Ωe

∇φj · ∇φi dx−∫

Ωe

fφi dx , i = 1, . . . ,Ns

• This can be expressed naturally in matrix notation as

KeUe − Fe

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

Element Matrix and Load Vector

• The element integrals . . .∫Ωe

[∇uh · ∇vh − fvh] dx

• are written in terms of the local “φi” basis functions

Ns∑j=1

uj

∫Ωe

∇φj · ∇φi dx−∫

Ωe

fφi dx , i = 1, . . . ,Ns

• This can be expressed naturally in matrix notation as

KeUe − Fe

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

Element Matrix and Load Vector

• The element integrals . . .∫Ωe

[∇uh · ∇vh − fvh] dx

• are written in terms of the local “φi” basis functions

Ns∑j=1

uj

∫Ωe

∇φj · ∇φi dx−∫

Ωe

fφi dx , i = 1, . . . ,Ns

• This can be expressed naturally in matrix notation as

KeUe − Fe

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

Global Linear System

• The entries of the element stiffness matrix are theintegrals

Keij :=

∫Ωe

∇φj · ∇φi dx

• While for the element right-hand side we have

Fei :=

∫Ωe

fφi dx

• The element stiffness matrices and right-hand sidescan be “assembled” to obtain the global system ofequations

KU = F

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

Global Linear System

• The entries of the element stiffness matrix are theintegrals

Keij :=

∫Ωe

∇φj · ∇φi dx

• While for the element right-hand side we have

Fei :=

∫Ωe

fφi dx

• The element stiffness matrices and right-hand sidescan be “assembled” to obtain the global system ofequations

KU = F

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

Global Linear System

• The entries of the element stiffness matrix are theintegrals

Keij :=

∫Ωe

∇φj · ∇φi dx

• While for the element right-hand side we have

Fei :=

∫Ωe

fφi dx

• The element stiffness matrices and right-hand sidescan be “assembled” to obtain the global system ofequations

KU = F

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

Reference Element Map

• The integrals are performed on a “reference” elementΩe

eΩx (ξ)x ξ

Ωe

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

Reference Element Map

• The integrals are performed on a “reference” elementΩe

eΩx (ξ)x

Ωe

ξ

• The Jacobian of the map x(ξ) is J.

Fei =

∫Ωe

fφidx =

∫Ωe

f (x(ξ))φi|J|dξ

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

Reference Element Map

• The integrals are performed on a “reference” elementΩe

eΩx (ξ)x

Ωe

ξ

• Chain rule: ∇ = J−1∇ξ := ∇ξ

Keij =

∫Ωe

∇φj · ∇φi dx =

∫Ωe

∇ξφj · ∇ξφi |J|dξ

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

Element Quadrature

• The integrals on the “reference” element areapproximated via numerical quadrature.

• The quadrature rule has Nq points “ξq” and weights“wq”.

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

Element Quadrature

• The integrals on the “reference” element areapproximated via numerical quadrature.

• The quadrature rule has Nq points “ξq” and weights“wq”.

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

Element Quadrature

• The integrals on the “reference” element areapproximated via numerical quadrature.

• The quadrature rule has Nq points “ξq” and weights“wq”.

Fei =

∫Ωe

fφi|J|dξ

≈Nq∑

q=1

f (x(ξq))φi(ξq)|J(ξq)|wq

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

Element Quadrature

• The integrals on the “reference” element areapproximated via numerical quadrature.

• The quadrature rule has Nq points “ξq” and weights“wq”.

Keij =

∫Ωe

∇ξφj · ∇ξφi |J|dξ

≈Nq∑

q=1

∇ξφj(ξq) · ∇ξφi(ξq)|J(ξq)|wq

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

LibMesh Quadrature Point Data

• LibMesh provides the following variables at eachquadrature point q

Code Math Description

JxW[q] |J(ξq)|wq Jacobian times weight

phi[i][q] φi(ξq) value of ith shape fn.

dphi[i][q] ∇ξφi(ξq) value of ith shape fn. gradient

xyz[q] x(ξq) location of ξq in physical space

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

Matrix Assembly Loops

• The LibMesh representation of the matrix and rhsassembly is similar to the mathematical statements.

for (q=0; q<Nq; ++q)for (i=0; i<Ns; ++i) Fe(i) += JxW[q]*f(xyz[q])*phi[i][q];

for (j=0; j<Ns; ++j)Ke(i,j) += JxW[q]*(dphi[j][q]*dphi[i][q]);

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

Matrix Assembly Loops

• The LibMesh representation of the matrix and rhsassembly is similar to the mathematical statements.

for (q=0; q<Nq; ++q)for (i=0; i<Ns; ++i) Fe(i) += JxW[q]*f(xyz[q])*phi[i][q];

for (j=0; j<Ns; ++j)Ke(i,j) += JxW[q]*(dphi[j][q]*dphi[i][q]);

Fei =

Nq∑q=1

f (x(ξq))φi(ξq)|J(ξq)|wq

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

Matrix Assembly Loops

• The LibMesh representation of the matrix and rhsassembly is similar to the mathematical statements.

for (q=0; q<Nq; ++q)for (i=0; i<Ns; ++i) Fe(i) += JxW[q]*f(xyz[q])*phi[i][q];

for (j=0; j<Ns; ++j)Ke(i,j) += JxW[q]*(dphi[j][q]*dphi[i][q]);

Fei =

Nq∑q=1

f (x(ξq))φi(ξq)|J(ξq)|wq

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

Matrix Assembly Loops

• The LibMesh representation of the matrix and rhsassembly is similar to the mathematical statements.

for (q=0; q<Nq; ++q)for (i=0; i<Ns; ++i) Fe(i) += JxW[q]*f(xyz[q])*phi[i][q];

for (j=0; j<Ns; ++j)Ke(i,j) += JxW[q]*(dphi[j][q]*dphi[i][q]);

Fei =

Nq∑q=1

f (x(ξq))φi(ξq)|J(ξq)|wq

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

Matrix Assembly Loops

• The LibMesh representation of the matrix and rhsassembly is similar to the mathematical statements.

for (q=0; q<Nq; ++q)for (i=0; i<Ns; ++i) Fe(i) += JxW[q]*f(xyz[q])*phi[i][q];

for (j=0; j<Ns; ++j)Ke(i,j) += JxW[q]*(dphi[j][q]*dphi[i][q]);

Fei =

Nq∑q=1

f (x(ξq))φi(ξq)|J(ξq)|wq

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

Matrix Assembly Loops

• The LibMesh representation of the matrix and rhsassembly is similar to the mathematical statements.

for (q=0; q<Nq; ++q)for (i=0; i<Ns; ++i) Fe(i) += JxW[q]*f(xyz[q])*phi[i][q];

for (j=0; j<Ns; ++j)Ke(i,j) += JxW[q]*(dphi[j][q]*dphi[i][q]);

Keij =

Nq∑q=1

∇ξφj(ξq) · ∇ξφi(ξq)|J(ξq)|wq

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

Matrix Assembly Loops

• The LibMesh representation of the matrix and rhsassembly is similar to the mathematical statements.

for (q=0; q<Nq; ++q)for (i=0; i<Ns; ++i) Fe(i) += JxW[q]*f(xyz[q])*phi[i][q];

for (j=0; j<Ns; ++j)Ke(i,j) += JxW[q]*(dphi[j][q]*dphi[i][q]);

Keij =

Nq∑q=1

∇ξφj(ξq) · ∇ξφi(ξq)|J(ξq)|wq

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

Matrix Assembly Loops

• The LibMesh representation of the matrix and rhsassembly is similar to the mathematical statements.

for (q=0; q<Nq; ++q)for (i=0; i<Ns; ++i) Fe(i) += JxW[q]*f(xyz[q])*phi[i][q];

for (j=0; j<Ns; ++j)Ke(i,j) += JxW[q]*(dphi[j][q]*dphi[i][q]);

Keij =

Nq∑q=1

∇ξφj(ξq) · ∇ξφi(ξq)|J(ξq)|wq

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

1 Introduction

2 Weighted Residuals

3 Poisson Equation

4 Other Examples

5 Essential BCs

6 Some Extensions

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

Convection-Diffusion Equation

• The matrix assembly routine for the linearconvection-diffusion equation,

−k∆u + b · ∇u = f

for (q=0; q<Nq; ++q)for (i=0; i<Ns; ++i) Fe(i) += JxW[q]*f(xyz[q])*phi[i][q];

for (j=0; j<Ns; ++j)Ke(i,j) += JxW[q]*(k*(dphi[j][q]*dphi[i][q])

+(b*dphi[j][q])*phi[i][q]);

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

Convection-Diffusion Equation

• The matrix assembly routine for the linearconvection-diffusion equation,

−k∆u + b · ∇u = f

for (q=0; q<Nq; ++q)for (i=0; i<Ns; ++i) Fe(i) += JxW[q]*f(xyz[q])*phi[i][q];

for (j=0; j<Ns; ++j)Ke(i,j) += JxW[q]*(k*(dphi[j][q]*dphi[i][q])

+(b*dphi[j][q])*phi[i][q]);

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

Convection-Diffusion Equation

• The matrix assembly routine for the linearconvection-diffusion equation,

−k∆u + b · ∇u = f

for (q=0; q<Nq; ++q)for (i=0; i<Ns; ++i) Fe(i) += JxW[q]*f(xyz[q])*phi[i][q];

for (j=0; j<Ns; ++j)Ke(i,j) += JxW[q]*(k*(dphi[j][q]*dphi[i][q])

+(b*dphi[j][q])*phi[i][q]);

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

Stokes Flow

• For multi-variable systems like Stokes flow,

∇p− ν∆u = f∇ · u = 0 ∈ Ω ⊂ R2

• The element stiffness matrix concept can extended toinclude sub-matrices Ke

u1u1Ke

u1u2Ke

u1pKe

u2u1Ke

u2u2Ke

u2p

Kepu1

Kepu2

Kepp

Ueu1

Ueu2

Uep

− Fe

u1

Feu2

Fep

• We have an array of submatrices: Ke[ ][ ]

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

Stokes Flow

• For multi-variable systems like Stokes flow,

∇p− ν∆u = f∇ · u = 0 ∈ Ω ⊂ R2

• The element stiffness matrix concept can extended toinclude sub-matrices Ke

u1u1Ke

u1u2Ke

u1pKe

u2u1Ke

u2u2Ke

u2p

Kepu1

Kepu2

Kepp

Ueu1

Ueu2

Uep

− Fe

u1

Feu2

Fep

• We have an array of submatrices: Ke[0][0]

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

Stokes Flow

• For multi-variable systems like Stokes flow,

∇p− ν∆u = f∇ · u = 0 ∈ Ω ⊂ R2

• The element stiffness matrix concept can extended toinclude sub-matrices Ke

u1u1Ke

u1u2Ke

u1pKe

u2u1Ke

u2u2Ke

u2p

Kepu1

Kepu2

Kepp

Ueu1

Ueu2

Uep

− Fe

u1

Feu2

Fep

• We have an array of submatrices: Ke[1][1]

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

Stokes Flow

• For multi-variable systems like Stokes flow,

∇p− ν∆u = f∇ · u = 0 ∈ Ω ⊂ R2

• The element stiffness matrix concept can extended toinclude sub-matrices Ke

u1u1Ke

u1u2Ke

u1pKe

u2u1Ke

u2u2Ke

u2p

Kepu1

Kepu2

Kepp

Ueu1

Ueu2

Uep

− Fe

u1

Feu2

Fep

• We have an array of submatrices: Ke[2][1]

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

Stokes Flow

• For multi-variable systems like Stokes flow,

∇p− ν∆u = f∇ · u = 0 ∈ Ω ⊂ R2

• The element stiffness matrix concept can extended toinclude sub-matrices Ke

u1u1Ke

u1u2Ke

u1pKe

u2u1Ke

u2u2Ke

u2p

Kepu1

Kepu2

Kepp

Ueu1

Ueu2

Uep

− Fe

u1

Feu2

Fep

• And an array of right-hand sides: Fe[].

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

Stokes Flow

• For multi-variable systems like Stokes flow,

∇p− ν∆u = f∇ · u = 0 ∈ Ω ⊂ R2

• The element stiffness matrix concept can extended toinclude sub-matrices Ke

u1u1Ke

u1u2Ke

u1pKe

u2u1Ke

u2u2Ke

u2p

Kepu1

Kepu2

Kepp

Ueu1

Ueu2

Uep

− Fe

u1

Feu2

Fep

• And an array of right-hand sides: Fe[0].

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

Stokes Flow

• For multi-variable systems like Stokes flow,

∇p− ν∆u = f∇ · u = 0 ∈ Ω ⊂ R2

• The element stiffness matrix concept can extended toinclude sub-matrices Ke

u1u1Ke

u1u2Ke

u1pKe

u2u1Ke

u2u2Ke

u2p

Kepu1

Kepu2

Kepp

Ueu1

Ueu2

Uep

− Fe

u1

Feu2

Fep

• And an array of right-hand sides: Fe[1].

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

Stokes Flow

• The matrix assembly can proceed in essentially thesame way.

• For the momentum equations:

for (q=0; q<Nq; ++q)for (d=0; d<2; ++d)for (i=0; i<Ns; ++i)

Fe[d](i) += JxW[q]*f(xyz[q],d)*phi[i][q];

for (j=0; j<Ns; ++j)Ke[d][d](i,j) +=

JxW[q]*nu*(dphi[j][q]*dphi[i][q]);

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

1 Introduction

2 Weighted Residuals

3 Poisson Equation

4 Other Examples

5 Essential BCs

6 Some Extensions

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

Essential Boundary Data

• Dirichlet boundary conditions can be enforced afterthe global stiffness matrix K has been assembled

• This usually involves1 placing a “1” on the main diagonal of the global

stiffness matrix2 zeroing out the row entries3 placing the Dirichlet value in the rhs vector4 subtracting off the column entries from the rhs

k11 k12 k13 .k21 k22 k23 .k31 k32 k33 .. . . .

,

f1

f2

f3

.

1 0 0 00 k22 k23 .0 k32 k33 .0 . . .

,

g1

f2 − k21g1

f3 − k31g1

.

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

Essential Boundary Data

• Dirichlet boundary conditions can be enforced afterthe global stiffness matrix K has been assembled

• This usually involves1 placing a “1” on the main diagonal of the global

stiffness matrix2 zeroing out the row entries3 placing the Dirichlet value in the rhs vector4 subtracting off the column entries from the rhs

k11 k12 k13 .k21 k22 k23 .k31 k32 k33 .. . . .

,

f1

f2

f3

.

1 0 0 00 k22 k23 .0 k32 k33 .0 . . .

,

g1

f2 − k21g1

f3 − k31g1

.

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

Essential Boundary Data

• Dirichlet boundary conditions can be enforced afterthe global stiffness matrix K has been assembled

• This usually involves1 placing a “1” on the main diagonal of the global

stiffness matrix2 zeroing out the row entries3 placing the Dirichlet value in the rhs vector4 subtracting off the column entries from the rhs

k11 k12 k13 .k21 k22 k23 .k31 k32 k33 .. . . .

,

f1

f2

f3

.

1 0 0 00 k22 k23 .0 k32 k33 .0 . . .

,

g1

f2 − k21g1

f3 − k31g1

.

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

Essential Boundary Data

• Dirichlet boundary conditions can be enforced afterthe global stiffness matrix K has been assembled

• This usually involves1 placing a “1” on the main diagonal of the global

stiffness matrix2 zeroing out the row entries3 placing the Dirichlet value in the rhs vector4 subtracting off the column entries from the rhs

k11 k12 k13 .k21 k22 k23 .k31 k32 k33 .. . . .

,

f1

f2

f3

.

1 0 0 00 k22 k23 .0 k32 k33 .0 . . .

,

g1

f2 − k21g1

f3 − k31g1

.

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

Essential Boundary Data

• Dirichlet boundary conditions can be enforced afterthe global stiffness matrix K has been assembled

• This usually involves1 placing a “1” on the main diagonal of the global

stiffness matrix2 zeroing out the row entries3 placing the Dirichlet value in the rhs vector4 subtracting off the column entries from the rhs

k11 k12 k13 .k21 k22 k23 .k31 k32 k33 .. . . .

,

f1

f2

f3

.

1 0 0 00 k22 k23 .0 k32 k33 .0 . . .

,

g1

f2 − k21g1

f3 − k31g1

.

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

Essential Boundary Data

• Cons of this approach :• Works for an interpolary finite element basis but not in

general.• May be inefficient to change individual entries once

the global matrix is assembled.

• Need to enforce boundary conditions for a genericfinite element basis at the element stiffness matrixlevel.

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

Essential Boundary Data

• Cons of this approach :• Works for an interpolary finite element basis but not in

general.• May be inefficient to change individual entries once

the global matrix is assembled.

• Need to enforce boundary conditions for a genericfinite element basis at the element stiffness matrixlevel.

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

Essential Boundary Data

• Cons of this approach :• Works for an interpolary finite element basis but not in

general.• May be inefficient to change individual entries once

the global matrix is assembled.

• Need to enforce boundary conditions for a genericfinite element basis at the element stiffness matrixlevel.

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

Essential Boundary Data

• Cons of this approach :• Works for an interpolary finite element basis but not in

general.• May be inefficient to change individual entries once

the global matrix is assembled.

• Need to enforce boundary conditions for a genericfinite element basis at the element stiffness matrixlevel.

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

Penalty Formulation

• One solution is the “penalty” boundary formulation• A term is added to the standard weighted residual

statement

(F(u), v) +1ε

∫∂ΩD

(u− uD)v dx︸ ︷︷ ︸penalty term

= 0 ∀v ∈ V

• Here ε 1 is chosen so that, in floating pointarithmetic, 1

ε+ 1 = 1

ε.

• This weakly enforces u = uD on the Dirichletboundary, and works for general finite element bases.

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

Penalty Formulation

• One solution is the “penalty” boundary formulation• A term is added to the standard weighted residual

statement

(F(u), v) +1ε

∫∂ΩD

(u− uD)v dx︸ ︷︷ ︸penalty term

= 0 ∀v ∈ V

• Here ε 1 is chosen so that, in floating pointarithmetic, 1

ε+ 1 = 1

ε.

• This weakly enforces u = uD on the Dirichletboundary, and works for general finite element bases.

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

Penalty Formulation

• One solution is the “penalty” boundary formulation• A term is added to the standard weighted residual

statement

(F(u), v) +1ε

∫∂ΩD

(u− uD)v dx︸ ︷︷ ︸penalty term

= 0 ∀v ∈ V

• Here ε 1 is chosen so that, in floating pointarithmetic, 1

ε+ 1 = 1

ε.

• This weakly enforces u = uD on the Dirichletboundary, and works for general finite element bases.

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

Penalty Formulation

• One solution is the “penalty” boundary formulation• A term is added to the standard weighted residual

statement

(F(u), v) +1ε

∫∂ΩD

(u− uD)v dx︸ ︷︷ ︸penalty term

= 0 ∀v ∈ V

• Here ε 1 is chosen so that, in floating pointarithmetic, 1

ε+ 1 = 1

ε.

• This weakly enforces u = uD on the Dirichletboundary, and works for general finite element bases.

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

Penalty Formulation

LibMesh provides:• A quadrature rule with Nqf points and JxW f[]

• A finite element coincident with the boundary facethat has shape function values phi f[][]

for (qf=0; qf<Nqf; ++qf) for (i=0; i<Nf; ++i) Fe(i) += JxW_f[qf]*

penalty*uD(xyz[q])*phi_f[i][qf];

for (j=0; j<Nf; ++j)Ke(i,j) += JxW_f[qf]*penalty*phi_f[j][qf]*phi_f[i][qf];

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

Penalty Formulation

LibMesh provides:• A quadrature rule with Nqf points and JxW f[]

• A finite element coincident with the boundary facethat has shape function values phi f[][]

for (qf=0; qf<Nqf; ++qf) for (i=0; i<Nf; ++i) Fe(i) += JxW_f[qf]*

penalty*uD(xyz[q])*phi_f[i][qf];

for (j=0; j<Nf; ++j)Ke(i,j) += JxW_f[qf]*penalty*phi_f[j][qf]*phi_f[i][qf];

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

Penalty Formulation

LibMesh provides:• A quadrature rule with Nqf points and JxW f[]

• A finite element coincident with the boundary facethat has shape function values phi f[][]

for (qf=0; qf<Nqf; ++qf) for (i=0; i<Nf; ++i) Fe(i) += JxW_f[qf]*

penalty*uD(xyz[q])*phi_f[i][qf];

for (j=0; j<Nf; ++j)Ke(i,j) += JxW_f[qf]*penalty*phi_f[j][qf]*phi_f[i][qf];

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

1 Introduction

2 Weighted Residuals

3 Poisson Equation

4 Other Examples

5 Essential BCs

6 Some Extensions

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

Time-Dependent Problems

• For linear problems, we have already seen how theweighted residual statement leads directly to asparse linear system of equations

KU = F

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

Time-Dependent Problems

• For time-dependent problems,

∂u∂t

= F(u)

• we also need a way to advance the solution in time,e.g. a θ-method(

un+1 − un

∆t, vh

)=

(F(uθ), vh) ∀vh ∈ Vh

uθ := θun+1 + (1− θ)un

• Leads to KU = F at each timestep.

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

Nonlinear Problems

• For nonlinear problems, typically a sequence of linearproblems must be solved, e.g. for Newton’s method

(F′(uk)δuk+1, v) = −(F(uk), v)

where F′(uk) is the linearized (Jacobian) operatorassociated with the PDE.

• Must solve KU = F (Inexact Newton method) at eachiteration step.

Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference

• B. Kirk, J. Peterson, R. Stogner and G. Carey,“libMesh: a C++ library for parallel adaptive meshrefinement/coarsening simulations”, Engineering withComputers, vol. 22, no. 3–4, p. 237–254, 2006.

• Public site, mailing lists, SVN tree, examples, etc.:http://libmesh.sf.net/

top related