107
Outline Introduction Weighted Residuals Poisson Equation Other Examples Essential BCs Some Extensions Reference LibMesh Experience and Usage John W. Peterson [email protected] and Roy H. Stogner [email protected] Univ. of Texas at Austin September 9, 2008

LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson [email protected] and Roy H. Stogner

  • Upload
    others

  • View
    30

  • Download
    0

Embed Size (px)

Citation preview

Page 1: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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

LibMesh Experience and Usage

John W. [email protected]

and Roy H. [email protected]

Univ. of Texas at Austin

September 9, 2008

Page 2: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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

Page 3: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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

Page 4: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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”

Page 5: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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

Page 6: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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.

Page 7: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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.

Page 8: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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.

Page 9: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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

Natural Convection

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

Page 10: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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.

Page 11: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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.

Page 12: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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

Tumor Angiogenesis

• The tumor secretes a chemical which stimulatesblood vessel formation.

Page 13: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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

Phase Separation

• Directed pattern self-assembly in spinodaldecomposition of binary mixture

Page 14: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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.

Page 15: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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.

Page 16: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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.

Page 17: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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.

Page 18: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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.

Page 19: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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.

Page 20: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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.

Page 21: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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.

Page 22: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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.

Page 23: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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:

Page 24: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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:

Page 25: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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:

Page 26: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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:

Page 27: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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.

Page 28: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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

Page 29: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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

Page 30: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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

Page 31: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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

Page 32: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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.

Page 33: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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.

Page 34: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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.

Page 35: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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

Compressible Flow

Page 36: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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

Page 37: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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

Page 38: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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

Page 39: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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

Some Examples

Poisson Equation

−∆u = f ∈ Ω

Page 40: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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

Page 41: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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

Some Examples

Linear Convection-Diffusion

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

Page 42: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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

Page 43: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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

Some Examples

Stokes Flow

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

Page 44: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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

Page 45: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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.

Page 46: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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

Page 47: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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

Page 48: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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

Page 49: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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

Page 50: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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

Page 51: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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

Page 52: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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

Page 53: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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

Page 54: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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

Page 55: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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

Page 56: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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

Page 57: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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

Page 58: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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

Page 59: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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ξ

Page 60: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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ξ

Page 61: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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”.

Page 62: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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”.

Page 63: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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

Page 64: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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

Page 65: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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

Page 66: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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]);

Page 67: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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

Page 68: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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

Page 69: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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

Page 70: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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

Page 71: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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

Page 72: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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

Page 73: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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

Page 74: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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

Page 75: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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]);

Page 76: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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]);

Page 77: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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]);

Page 78: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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[ ][ ]

Page 79: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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]

Page 80: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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]

Page 81: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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]

Page 82: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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[].

Page 83: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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].

Page 84: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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].

Page 85: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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]);

Page 86: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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

Page 87: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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

.

Page 88: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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

.

Page 89: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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

.

Page 90: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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

.

Page 91: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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

.

Page 92: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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.

Page 93: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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.

Page 94: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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.

Page 95: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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.

Page 96: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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.

Page 97: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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.

Page 98: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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.

Page 99: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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.

Page 100: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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];

Page 101: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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];

Page 102: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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];

Page 103: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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

Page 104: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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

Page 105: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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.

Page 106: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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.

Page 107: LibMesh Experience and Usage - University of Texas at Austinroystgnr/libmeshflows1.pdfLibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner

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/