Sie sind auf Seite 1von 121

Introduction

Object Models

System Assembly

Examples

libMesh Finite Element Library


Roy Stogner
roystgnr@cfdlab.ae.utexas.edu

Derek Gaston
drgasto@sandia.gov
1 Univ.

of Texas at Austin

2 Sandia

National Laboratories
Albuquerque,NM

August 22, 2007

Summary

Introduction

Object Models

System Assembly

Outline
1
2

Introduction
Object Models
Core Classes
BVP Framework
System Assembly
Basic Example
Coupled Variables
Essential Boundary Conditions
Examples
Fluid Dynamics
Biology
Material Science
Summary

Examples

Summary

Introduction

Object Models

Goals
libMesh is not

System Assembly

Examples

Summary

Introduction

Object Models

System Assembly

Goals
libMesh is not
A physics implementation.

Examples

Summary

Introduction

Object Models

System Assembly

Goals
libMesh is not
A physics implementation.
A stand-alone application.

Examples

Summary

Introduction

Object Models

System Assembly

Goals
libMesh is not
A physics implementation.
A stand-alone application.
libMesh is

Examples

Summary

Introduction

Object Models

System Assembly

Goals
libMesh is not
A physics implementation.
A stand-alone application.
libMesh is
A software library and toolkit.

Examples

Summary

Introduction

Object Models

System Assembly

Examples

Goals
libMesh is not
A physics implementation.
A stand-alone application.
libMesh is
A software library and toolkit.
Classes and functions for writing parallel adaptive
finite element applications.

Summary

Introduction

Object Models

System Assembly

Examples

Goals
libMesh is not
A physics implementation.
A stand-alone application.
libMesh is
A software library and toolkit.
Classes and functions for writing parallel adaptive
finite element applications.
An interface to linear algebra, meshing, partitioning,
etc. libraries.

Summary

=
=
=
=


D


System Assembly

N


0
uD D
0 N
u0 (x)


= F(u)

For most applications we


assume there is a Boundary
Value Problem to be
approximated in a Finite
Element function space

u
M
t
G(u)
u
N(u)
u(x, 0)

Object Models

Introduction
Examples
Summary

Introduction

Object Models

Associated to is the
Mesh data structure
A Mesh is basically a
collection of geometric
elements and nodes
[
h :=
e
e

System Assembly

Examples

Summary

Introduction

Object Models

System Assembly

Object Oriented Programming

Examples

Summary

Introduction

Object Models

System Assembly

Examples

Object Oriented Programming

Abstract Base Classes define user interfaces.

Summary

Introduction

Object Models

System Assembly

Examples

Object Oriented Programming

Abstract Base Classes define user interfaces.


Concrete Subclasses implement functionality.

Summary

Introduction

Object Models

System Assembly

Examples

Object Oriented Programming

Abstract Base Classes define user interfaces.


Concrete Subclasses implement functionality.
One physics code can work with many
discretizations.

Summary

Introduction

Object Models

System Assembly

Examples

Core Classes

Geometric Element Classes


DofObject
-_n_systems: unsigned char
-_n_vars: unsigned char *
-_n_comp: unsigned char **
-_dof_ids: unsigned int **
-_id: unsigned int
-_processor_id: unsigned short int

Node
Elem
#_nodes: Node **
#_neighbors: Elem **
#_parent: Elem *
#_children: Elem **
#_*flag: RefinementState
#_p_level: unsigned char
#_subdomain_id: unsigned char
+n_{faces,sides,vertices,edges,children}(): unsigned int
+centroid(): Point
+hmin,hmax(): Real

NodeElem

Edge

Prism

Hex8

Face

Cell

Hex

Pyramid

Hex20

InfQuad

Hex27

Tet

InfCell

Abstract interface
gives mesh topology
Concrete
instantiations of
mesh geometry
Hides element type
from most
applications

Summary

Introduction

Object Models

System Assembly

Examples

Core Classes

Finite Element Classes


FEBase
+phi, dphi, d2phi
+quadrature_rule, JxW
+reinit(Elem)
+reinit(Elem,side)

Lagrange

Hermite

Hierarchic

Monomial

Finite Element object


builds data for each
Geometric object
User only deals with
shape function,
quadrature data

Summary

Introduction

Object Models

System Assembly

Examples

Core Classes

Core Features

Mixed element geometries in unstructured grids


Adaptive mesh h refinement with hanging nodes, p
refinement
Integration w/ PETSc, LASPack, METIS, ParMETIS,
Triangle, TetGen
Support for UNV, ExodusII, Tecplot, GMV, UCD files
Mesh creation, modification utilities

Summary

Introduction

Object Models

System Assembly

Core Classes

Degree of Freedom Handling

Examples

Summary

Introduction

Object Models

System Assembly

Examples

Core Classes

Degree of Freedom Handling

DofObject subclasses store global Degree of


Freedom indices

Summary

Introduction

Object Models

System Assembly

Examples

Core Classes

Degree of Freedom Handling

DofObject subclasses store global Degree of


Freedom indices
DofMap class assigns indices to a partitioned mesh

Summary

Introduction

Object Models

System Assembly

Examples

Core Classes

Degree of Freedom Handling

DofObject subclasses store global Degree of


Freedom indices
DofMap class assigns indices to a partitioned mesh
FE classes calculate hanging node, periodic
constraints

Summary

Introduction

Object Models

System Assembly

Examples

Core Classes

Degree of Freedom Handling

DofObject subclasses store global Degree of


Freedom indices
DofMap class assigns indices to a partitioned mesh
FE classes calculate hanging node, periodic
constraints
DofMap class applies constraints

Summary

Introduction

Object Models

System Assembly

Examples

Core Classes

Degree of Freedom Handling

DofObject subclasses store global Degree of


Freedom indices
DofMap class assigns indices to a partitioned mesh
FE classes calculate hanging node, periodic
constraints
DofMap class applies constraints
System class handles AMR/C projections

Summary

Introduction

Object Models

System Assembly

Examples

Core Classes

Generic Constraint Calculations


To maintain function space continuity, constrain hanging
node Degrees of Freedom coefficients on fine elements
in terms of DoFs on coarse neighbors.

uF = uC
X
uCj Cj
uFi Fi =

Aki ui = Bkj uj
ui = A1
ki Bkj uj
1
Integrated values (and fluxes, for C continuity) give
element-independent matrices:
Aki (Fi , Fk )
Bkj (Cj , Ck )

Summary

Introduction

Object Models

System Assembly

Examples

Core Classes

Generic Projection Calculations


Upon element coarsening (or refinement in non-nested
spaces):
Copy nodal Degree of Freedom coefficients
Project edge DoFs, holding nodal DoFs constant
Project face DoFs, holding nodes/edges constant
Project interior DoFs, holding boundaries constant
Advantages / Disadvantages
Requires only local solves
Consistent in parallel
May violate physical conservation laws

Summary

Introduction

Object Models

System Assembly

Core Classes

libMesh Parallelization
Parallel code

Examples

Summary

Introduction

Object Models

System Assembly

Examples

Core Classes

libMesh Parallelization
Parallel code
PetscVector, DistributedVector classes for Linear
Algebra

Summary

Introduction

Object Models

System Assembly

Examples

Core Classes

libMesh Parallelization
Parallel code
PetscVector, DistributedVector classes for Linear
Algebra
Parallel assembly, error indicators, etc.

Summary

Introduction

Object Models

System Assembly

Examples

Core Classes

libMesh Parallelization
Parallel code
PetscVector, DistributedVector classes for Linear
Algebra
Parallel assembly, error indicators, etc.
Mesh partitioning with ParMETIS, etc.

Summary

Introduction

Object Models

System Assembly

Examples

Core Classes

libMesh Parallelization
Parallel code
PetscVector, DistributedVector classes for Linear
Algebra
Parallel assembly, error indicators, etc.
Mesh partitioning with ParMETIS, etc.
Serial code

Summary

Introduction

Object Models

System Assembly

Examples

Core Classes

libMesh Parallelization
Parallel code
PetscVector, DistributedVector classes for Linear
Algebra
Parallel assembly, error indicators, etc.
Mesh partitioning with ParMETIS, etc.
Serial code
Mesh storage on every node

Summary

Introduction

Object Models

System Assembly

Examples

Core Classes

libMesh Parallelization
Parallel code
PetscVector, DistributedVector classes for Linear
Algebra
Parallel assembly, error indicators, etc.
Mesh partitioning with ParMETIS, etc.
Serial code
Mesh storage on every node
DoF renumbering, constraint calculations

Summary

Introduction

Object Models

System Assembly

Examples

Core Classes

libMesh Parallelization
Parallel code
PetscVector, DistributedVector classes for Linear
Algebra
Parallel assembly, error indicators, etc.
Mesh partitioning with ParMETIS, etc.
Serial code
Mesh storage on every node
DoF renumbering, constraint calculations
Refinement/Coarsening flagging

Summary

Introduction

Object Models

System Assembly

Examples

Core Classes

libMesh Parallelization
Parallel code
PetscVector, DistributedVector classes for Linear
Algebra
Parallel assembly, error indicators, etc.
Mesh partitioning with ParMETIS, etc.
Serial code
Mesh storage on every node
DoF renumbering, constraint calculations
Refinement/Coarsening flagging
Mesh, solution I/O

Summary

Introduction

Object Models

System Assembly

Examples

Core Classes

ParallelMesh
Parallel subclassing of MeshBase
Start from unstructured Mesh class
Add methods to delete, reconstruct non-semilocal
Elem and Node objects
Parallelize DofMap methods
Parallelize MeshRefinement methods
Add parallel or chunked I/O support
Add load balancing support
Also want parallel BoundaryInfo, BoundaryMesh, Data,
Function, Generation, Modification, Smoother, and Tools
classes

Summary

Introduction

Object Models

System Assembly

Examples

Summary

BVP Framework

Boundary Value Problem Framework Goals


Goals
Improved test coverage and reliability
Hiding implementation details from user code
Rapid prototyping of new formulations
Physics-dependent error estimators
Methods
Object-oriented System and Solver subclasses
Factoring common patterns into library code
Per-element Numerical Jacobian verification

Introduction

Object Models

System Assembly

Examples

BVP Framework

FEM System Classes

FEMSystem
+elem_solution: DenseVector<Number>
+elem_residual: DenseVector<Number>
+elem_jacobian: DenseMatrix<Number>
#elem_fixed_solution: DenseVector<Number>
#*_fe_var: std::vector<FEBase *>
#elem: Elem *
+*_time_derivative(request_jacobian)
+*_constraint(request_jacobian)
+*_postprocess()

NavierStokesSystem

CahnHilliardSystem

LaplaceYoungSystem

SurfactantSystem

Generalized IBVP
representation
FEMSystem does all
initialization, global
assembly
User code only
needs weighted time
derivative residuals
( u
, vi ) = Fi (u) and/or
t
constraints
Gi (u, vi ) = 0

Summary

Introduction

Object Models

System Assembly

Examples

BVP Framework

ODE Solver Classes

TimeSolver
+*_residual(request_jacobian)
+solve()
+advance_timestep()

SteadySolver

AdamsMoultonSolver

EulerSolver

EigenSolver

Calls user code on


each element
Assembles
element-by-element
time derivatives,
constraints, and
weighted old
solutions

Summary

Introduction

Object Models

System Assembly

Examples

BVP Framework

Nonlinear Solver Classes

NonlinearSolver
+*_tolerance
+*_max_iterations
+solve()

LinearSolver

ContinuationSolver

QuasiNewtonSolver

Acquires residuals,
jacobians from
FEMSystem
assembly
Handles inner loops,
inner solvers and
tolerances,
convergence tests,
etc

Summary

Introduction

Object Models

System Assembly

Examples

Basic Example

System Assembly

For simplicity we will focus on the weighted residual


statement arising from the Poisson equation, with
N = ,
(R(uh ), vh ) :=
Z
 h

u vh fvh dx = 0
h

vh V h

Summary

Introduction

Object Models

System Assembly

Basic Example

The element integrals . . .


Z
 h

u vh fvh dx
e

Examples

Summary

Introduction

Object Models

System Assembly

Examples

Basic Example

The element integrals . . .


Z
 h

u vh fvh dx
e

are written in terms of the local i basis functions


Ns
X
j=1

Z
j i dx

uj
e

f i dx ,
e

i = 1, . . . , Ns

Summary

Introduction

Object Models

System Assembly

Examples

Summary

Basic Example

The element integrals . . .


Z
 h

u vh fvh dx
e

are written in terms of the local i basis functions


Ns
X
j=1

Z
j i dx

uj
e

f i dx ,

i = 1, . . . , Ns

This can be expressed naturally in matrix notation as


K e U e Fe

Introduction

Object Models

System Assembly

Examples

Summary

Basic Example

The integrals are performed on a reference element


e , transformed via Lagrange basis to the geometric

element.

x()

Introduction

Object Models

System Assembly

Examples

Summary

Basic Example

The integrals are performed on a reference element


e , transformed via Lagrange basis to the geometric

element.

x()

The Jacobian of the map x() is J.


Fei

Z
=

Z
f i dx =

f (x())i |J|d

Introduction

Object Models

System Assembly

Examples

Summary

Basic Example

The integrals are performed on a reference element


e , transformed via Lagrange basis to the geometric

element.

x()

Introduction

Object Models

System Assembly

Examples

Basic Example

The integrals on the reference element are


approximated via numerical quadrature.

Summary

Introduction

Object Models

System Assembly

Examples

Basic Example

The integrals on the reference element are


approximated via numerical quadrature.
The quadrature rule has Nq points q and weights
wq .

Summary

Introduction

Object Models

System Assembly

Examples

Basic Example

The integrals on the reference element are


approximated via numerical quadrature.
The quadrature rule has Nq points q and weights
wq .

Fei

Z
=
e

Nq

X
q=1

f i |J|d
f (x(q ))i (q )|J(q )|wq

Summary

Introduction

Object Models

System Assembly

Examples

Basic Example

The integrals on the reference element are


approximated via numerical quadrature.
The quadrature rule has Nq points q and weights
wq .

K eij

Z
=
e

Nq

X
q=1

j i |J|d
j (q ) i (q )|J(q )|wq

Summary

Introduction

Object Models

System Assembly

Examples

Summary

Basic Example

At the qth quadrature point, LibMesh can provide


variables including:

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

d2phi[i][q]

i (q ) value of ith shape fn. Hessian

xyz[q]

x(q )

location of q in physical space

normals[q]

~n(x(q ))

normal vector at x on a side

Introduction

Object Models

System Assembly

Examples

Summary

Basic Example

The LibMesh representation of the matrix and rhs


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

Introduction

Object Models

System Assembly

Examples

Summary

Basic Example

The LibMesh representation of the matrix and rhs


assembly 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
X
q=1

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

Introduction

Object Models

System Assembly

Examples

Summary

Basic Example

The LibMesh representation of the matrix and rhs


assembly 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
X
q=1

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

Introduction

Object Models

System Assembly

Examples

Summary

Basic Example

The LibMesh representation of the matrix and rhs


assembly 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
X
q=1

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

Introduction

Object Models

System Assembly

Examples

Summary

Basic Example

The LibMesh representation of the matrix and rhs


assembly 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
X
q=1

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

Introduction

Object Models

System Assembly

Examples

Summary

Basic Example

The LibMesh representation of the matrix and rhs


assembly 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]);
}
K eij

Nq
X
q=1

j (q )
i (q )|J(q )|wq

Introduction

Object Models

System Assembly

Examples

Summary

Basic Example

The LibMesh representation of the matrix and rhs


assembly 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]);
}
K eij

Nq
X
q=1

j (q )
i (q )|J(q )|wq

Introduction

Object Models

System Assembly

Examples

Summary

Basic Example

The LibMesh representation of the matrix and rhs


assembly 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]);
}
K eij

Nq
X
q=1

j (q )
i (q )|J(q )|wq

Introduction

Object Models

System Assembly

Examples

Summary

Basic Example

Convection-Diffusion Equation
The matrix assembly routine for the linear
convection-diffusion equation,
ku + 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]);
}

Introduction

Object Models

System Assembly

Examples

Summary

Basic Example

Convection-Diffusion Equation
The matrix assembly routine for the linear
convection-diffusion equation,
ku + 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]);
}

Introduction

Object Models

System Assembly

Examples

Summary

Basic Example

Convection-Diffusion Equation
The matrix assembly routine for the linear
convection-diffusion equation,
ku + 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]);
}

Introduction

Object Models

System Assembly

Examples

Summary

Coupled Variables

Stokes Flow
For multi-variable systems like Stokes flow,
p u = f
u = 0

R2

The element stiffness matrix concept can extended to


include sub-matrices
e
e e
Ku1 u1 Kue1 u2 Kue1 p
Uu1
Fu1
Kue u Kue u Kue p Uue Fue
2 1
2 2
2
2
2
e
e
e
e
e
U
F
Kpu
K
K
p
p
pu2
pp
1
We have an array of submatrices: Ke[ ][ ]

Introduction

Object Models

System Assembly

Examples

Summary

Coupled Variables

Stokes Flow
For multi-variable systems like Stokes flow,
p u = f
u = 0

R2

The element stiffness matrix concept can extended to


include sub-matrices
e
e e
Ku1 u1 Kue1 u2 Kue1 p
Uu1
Fu1
Kue u Kue u Kue p Uue Fue
2 1
2 2
2
2
2
e
e
e
e
e
U
F
Kpu
K
K
p
p
pu2
pp
1
We have an array of submatrices: Ke[1][1]

Introduction

Object Models

System Assembly

Examples

Summary

Coupled Variables

Stokes Flow
For multi-variable systems like Stokes flow,
p u = f
u = 0

R2

The element stiffness matrix concept can extended to


include sub-matrices
e
e e
Ku1 u1 Kue1 u2 Kue1 p
Uu1
Fu1
Kue u Kue u Kue p Uue Fue
2 1
2 2
2
2
2
e
e
e
e
e
U
F
Kpu
K
K
p
p
pu2
pp
1
We have an array of submatrices: Ke[2][2]

Introduction

Object Models

System Assembly

Examples

Summary

Coupled Variables

Stokes Flow
For multi-variable systems like Stokes flow,
p u = f
u = 0

R2

The element stiffness matrix concept can extended to


include sub-matrices
e
e e
Ku1 u1 Kue1 u2 Kue1 p
Uu1
Fu1
Kue u Kue u Kue p Uue Fue
2 1
2 2
2
2
2
e
e
e
e
e
U
F
Kpu
K
K
p
p
pu2
pp
1
We have an array of submatrices: Ke[3][2]

Introduction

Object Models

System Assembly

Examples

Summary

Coupled Variables

Stokes Flow
For multi-variable systems like Stokes flow,
p u = f
u = 0

R2

The element stiffness matrix concept can extended to


include sub-matrices
e
e e
Ku1 u1 Kue1 u2 Kue1 p
Uu1
Fu1
Kue u Kue u Kue p Uue Fue
2 1
2 2
2
2
2
e
e
e
e
e
U
F
Kpu
K
K
p
p
pu2
pp
1
And an array of right-hand sides: Fe[].

Introduction

Object Models

System Assembly

Examples

Summary

Coupled Variables

Stokes Flow
For multi-variable systems like Stokes flow,
p u = f
u = 0

R2

The element stiffness matrix concept can extended to


include sub-matrices
e
e e
Ku1 u1 Kue1 u2 Kue1 p
Uu1
Fu1
Kue u Kue u Kue p Uue Fue
2 1
2 2
2
2
2
e
e
e
e
e
U
F
Kpu
K
K
p
p
pu2
pp
1
And an array of right-hand sides: Fe[1].

Introduction

Object Models

System Assembly

Examples

Summary

Coupled Variables

Stokes Flow
For multi-variable systems like Stokes flow,
p u = f
u = 0

R2

The element stiffness matrix concept can extended to


include sub-matrices
e
e e
Ku1 u1 Kue1 u2 Kue1 p
Uu1
Fu1
Kue u Kue u Kue p Uue Fue
2 1
2 2
2
2
2
e
e
e
e
e
U
F
Kpu
K
K
p
p
pu2
pp
1
And an array of right-hand sides: Fe[2].

Introduction

Object Models

System Assembly

Examples

Summary

Coupled Variables

Stokes Flow
The matrix assembly can proceed in essentially the
same 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]);
}

Introduction

Object Models

System Assembly

Examples

Essential Boundary Conditions

Essential Boundary Data


Dirichlet boundary conditions can be enforced after
the global stiffness matrix K has been assembled
This usually involves
1

placing a 1 on the main diagonal of the global


stiffness matrix

Summary

Introduction

Object Models

System Assembly

Examples

Essential Boundary Conditions

Essential Boundary Data


Dirichlet boundary conditions can be enforced after
the global stiffness matrix K has been assembled
This usually involves
1

placing a 1 on the main diagonal of the global


stiffness matrix
zeroing out the row entries

Summary

Introduction

Object Models

System Assembly

Examples

Essential Boundary Conditions

Essential Boundary Data


Dirichlet boundary conditions can be enforced after
the global stiffness matrix K has been assembled
This usually involves
1

2
3

placing a 1 on the main diagonal of the global


stiffness matrix
zeroing out the row entries
placing the Dirichlet value in the rhs vector

Summary

Introduction

Object Models

System Assembly

Examples

Essential Boundary Conditions

Essential Boundary Data


Dirichlet boundary conditions can be enforced after
the global stiffness matrix K has been assembled
This usually involves
1

2
3
4

placing a 1 on the main diagonal of the global


stiffness matrix
zeroing out the row entries
placing the Dirichlet value in the rhs vector
subtracting off the column entries from the rhs

Summary

Introduction

Object Models

System Assembly

Examples

Summary

Essential Boundary Conditions

Essential Boundary Data


Dirichlet boundary conditions can be enforced after
the global stiffness matrix K has been assembled
This usually involves
1

2
3
4

placing a 1 on the main diagonal of the global


stiffness matrix
zeroing out the row entries
placing the Dirichlet value in the rhs vector
subtracting off the column entries from the rhs

k11 k12 k13


k21 k22 k23

k31 k32 k33


.
.
.

f1
1 0 0
.

. f2
0 k22 k23
,

0 k32 k33
. f3
.
0 .
.
.

0
g1

.
, f2 k21 g1
. f3 k31 g1
.
.

Introduction

Object Models

System Assembly

Essential Boundary Conditions

Cons of this approach :

Examples

Summary

Introduction

Object Models

System Assembly

Examples

Summary

Essential Boundary Conditions

Cons of this approach :


Works for an interpolary finite element basis but not in
general.

Introduction

Object Models

System Assembly

Examples

Summary

Essential Boundary Conditions

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.

Introduction

Object Models

System Assembly

Examples

Summary

Essential Boundary Conditions

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 generic


finite element basis at the element stiffness matrix
level.

Introduction

Object Models

System Assembly

Examples

Essential Boundary Conditions

A penalty term is added to the standard weighted


residual statement
Z
1
(R(u), v) +
v V
(u uD )v dx = 0
 D
{z
}
|
penalty term

Summary

Introduction

Object Models

System Assembly

Examples

Essential Boundary Conditions

A penalty term is added to the standard weighted


residual statement
Z
1
(R(u), v) +
v V
(u uD )v dx = 0
 D
{z
}
|
penalty term

Here   1 is chosen so that, in floating point


arithmetic, 1 + 1 = 1 .

Summary

Introduction

Object Models

System Assembly

Examples

Summary

Essential Boundary Conditions

A penalty term is added to the standard weighted


residual statement
Z
1
(R(u), v) +
v V
(u uD )v dx = 0
 D
{z
}
|
penalty term

Here   1 is chosen so that, in floating point


arithmetic, 1 + 1 = 1 .
This weakly enforces u = uD on the Dirichlet
boundary, and works for general finite element bases.

Introduction

Object Models

System Assembly

Examples

Essential Boundary Conditions

LibMesh provides:
A quadrature rule with Nqf points and JxW f[]
A finite element coincident with the boundary face
that 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];
}
}

Summary

Introduction

Object Models

System Assembly

Examples

Essential Boundary Conditions

LibMesh provides:
A quadrature rule with Nqf points and JxW f[]
A finite element coincident with the boundary face
that 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];
}
}

Summary

Introduction

Object Models

System Assembly

Examples

Essential Boundary Conditions

LibMesh provides:
A quadrature rule with Nqf points and JxW f[]
A finite element coincident with the boundary face
that 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];
}
}

Summary

Introduction

Object Models

System Assembly

Examples

Fluid Dynamics

Introduction
Laplace-Young equation model surface tension effects for
enclosed liquids.

Summary

Introduction

Object Models

System Assembly

Examples

Summary

Fluid Dynamics

Introduction
Laplace-Young equation model surface tension effects for
enclosed liquids.
Combining surface tension, gravity and contact the energy
functional for Laplace-Young is:
Z
Z
Z q
1 2
2
1 + |u| d +
u d
u ds

Introduction

Object Models

System Assembly

Examples

Summary

Fluid Dynamics

Introduction
Laplace-Young equation model surface tension effects for
enclosed liquids.
Combining surface tension, gravity and contact the energy
functional for Laplace-Young is:
Z
Z
Z q
1 2
2
1 + |u| d +
u d
u ds

Where is the ratio of surface energy to gravitational


energy and u is the height of the liquid.

Introduction

Object Models

System Assembly

Examples

Summary

Fluid Dynamics

Introduction
Laplace-Young equation model surface tension effects for
enclosed liquids.
Combining surface tension, gravity and contact the energy
functional for Laplace-Young is:
Z
Z
Z q
1 2
2
1 + |u| d +
u d
u ds

Where is the ratio of surface energy to gravitational


energy and u is the height of the liquid.
While the weak formulation of the stationary condition is
given by:
!
u
p
,
+ (u, ) = (1, )
(1)
1 + |u|2

Introduction

Object Models

System Assembly

Examples

Summary

Fluid Dynamics

Introduction
Laplace-Young equation model surface tension effects for
enclosed liquids.
Combining surface tension, gravity and contact the energy
functional for Laplace-Young is:
Z
Z
Z q
1 2
2
1 + |u| d +
u d
u ds

Where is the ratio of surface energy to gravitational


energy and u is the height of the liquid.
While the weak formulation of the stationary condition is
given by:
!
u
p
,
+ (u, ) = (1, )
(1)
1 + |u|2

Introduction

Object Models

System Assembly

Examples

Fluid Dynamics

Instead of explicitly finding the Jacobian, well use FEMSystem to finite difference the weak form.

element constraint()
for (unsigned int qp=0; qp != n_qpoints; qp++) {
Number u = interior_value(0, qp);
Gradient grad_u = interior_gradient(0, qp);
Number K = 1. / sqrt(1. + (grad_u * grad_u));
for (unsigned int i=0; i != n_u_dofs; i++) {
Fu(i) += JxW[qp] * ((_kappa * u * phi[i][qp]) +
(K * grad_u * dphi[i][qp]));
}
}

side constraint()
for (unsigned int qp=0; qp != n_qpoints; qp++) {
for (unsigned int i=0; i != n_u_dofs; i++) {
Fu(i) -= JxW[qp] * _gamma * phi[i][qp];
}
}

1
u
B
C
, A
@q
1 + |u|2

+ (u, ) (1, ) = 0

Summary

Introduction

Object Models

System Assembly

Examples

Fluid Dynamics

Instead of explicitly finding the Jacobian, well use FEMSystem to finite difference the weak form.

element constraint()
for (unsigned int qp=0; qp != n_qpoints; qp++) {
Number u = interior_value(0, qp);
Gradient grad_u = interior_gradient(0, qp);
Number K = 1. / sqrt(1. + (grad_u * grad_u));
for (unsigned int i=0; i != n_u_dofs; i++) {
Fu(i) += JxW[qp] * ((_kappa * u * phi[i][qp]) +
(K * grad_u * dphi[i][qp]));
}
}

side constraint()
for (unsigned int qp=0; qp != n_qpoints; qp++) {
for (unsigned int i=0; i != n_u_dofs; i++) {
Fu(i) -= JxW[qp] * _gamma * phi[i][qp];
}
}

1
u
B
C
, A
@q
1 + |u|2

+ (u, ) (1, ) = 0

Summary

Introduction

Object Models

System Assembly

Examples

Fluid Dynamics

Instead of explicitly finding the Jacobian, well use FEMSystem to finite difference the weak form.

element constraint()
for (unsigned int qp=0; qp != n_qpoints; qp++) {
Number u = interior_value(0, qp);
Gradient grad_u = interior_gradient(0, qp);
Number K = 1. / sqrt(1. + (grad_u * grad_u));
for (unsigned int i=0; i != n_u_dofs; i++) {
Fu(i) += JxW[qp] * ((_kappa * u * phi[i][qp]) +
(K * grad_u * dphi[i][qp]));
}
}

side constraint()
for (unsigned int qp=0; qp != n_qpoints; qp++) {
for (unsigned int i=0; i != n_u_dofs; i++) {
Fu(i) -= JxW[qp] * _gamma * phi[i][qp];
}
}

1
u
B
C
, A
@q
1 + |u|2

+ (u, ) (1, ) = 0

Summary

Introduction

Object Models

System Assembly

Examples

Fluid Dynamics

Instead of explicitly finding the Jacobian, well use FEMSystem to finite difference the weak form.

element constraint()
for (unsigned int qp=0; qp != n_qpoints; qp++) {
Number u = interior_value(0, qp);
Gradient grad_u = interior_gradient(0, qp);
Number K = 1. / sqrt(1. + (grad_u * grad_u));
for (unsigned int i=0; i != n_u_dofs; i++) {
Fu(i) += JxW[qp] * ((_kappa * u * phi[i][qp]) +
(K * grad_u * dphi[i][qp]));
}
}

side constraint()
for (unsigned int qp=0; qp != n_qpoints; qp++) {
for (unsigned int i=0; i != n_u_dofs; i++) {
Fu(i) -= JxW[qp] * _gamma * phi[i][qp];
}
}

1
u
B
C
, A
@q
1 + |u|2

+ (u, ) (1, ) = 0

Summary

Introduction

Object Models

System Assembly

Examples

Fluid Dynamics

Instead of explicitly finding the Jacobian, well use FEMSystem to finite difference the weak form.

element constraint()
for (unsigned int qp=0; qp != n_qpoints; qp++) {
Number u = interior_value(0, qp);
Gradient grad_u = interior_gradient(0, qp);
Number K = 1. / sqrt(1. + (grad_u * grad_u));
for (unsigned int i=0; i != n_u_dofs; i++) {
Fu(i) += JxW[qp] * ((_kappa * u * phi[i][qp]) +
(K * grad_u * dphi[i][qp]));
}
}

side constraint()
for (unsigned int qp=0; qp != n_qpoints; qp++) {
for (unsigned int i=0; i != n_u_dofs; i++) {
Fu(i) -= JxW[qp] * _gamma * phi[i][qp];
}
}

1
u
B
C
, A
@q
1 + |u|2

+ (u, ) (1, ) = 0

Summary

Introduction

Object Models

System Assembly

Examples

Fluid Dynamics

Instead of explicitly finding the Jacobian, well use FEMSystem to finite difference the weak form.

element constraint()
for (unsigned int qp=0; qp != n_qpoints; qp++) {
Number u = interior_value(0, qp);
Gradient grad_u = interior_gradient(0, qp);
Number K = 1. / sqrt(1. + (grad_u * grad_u));
for (unsigned int i=0; i != n_u_dofs; i++) {
Fu(i) += JxW[qp] * ((_kappa * u * phi[i][qp]) +
(K * grad_u * dphi[i][qp]));
}
}

side constraint()
for (unsigned int qp=0; qp != n_qpoints; qp++) {
for (unsigned int i=0; i != n_u_dofs; i++) {
Fu(i) -= JxW[qp] * _gamma * phi[i][qp];
}
}

1
u
B
C
, A
@q
1 + |u|2

+ (u, ) (1, ) = 0

Summary

Introduction

Object Models

System Assembly

Examples

Fluid Dynamics

Solution
An overkill solution containing 200,000 DOFs.

(a) 2D.

(b) Contour Elevation.

Summary

Introduction

Object Models

System Assembly

Examples

Fluid Dynamics

Compressible Shocked Flow

Original compressible flow code written by Ben Kirk


utilizing libMesh.

Summary

Introduction

Object Models

System Assembly

Examples

Summary

Fluid Dynamics

Compressible Shocked Flow

Original compressible flow code written by Ben Kirk


utilizing libMesh.
Solves both Compressible Navier Stokes and Inviscid
Euler.

Introduction

Object Models

System Assembly

Examples

Summary

Fluid Dynamics

Compressible Shocked Flow

Original compressible flow code written by Ben Kirk


utilizing libMesh.
Solves both Compressible Navier Stokes and Inviscid
Euler.
Includes both SUPG and a shock capturing scheme.

Introduction

Object Models

System Assembly

Examples

Fluid Dynamics

Problem Specification
The problem studied is that of an oblique shock
generated by a 10o wedge angle.

Summary

Introduction

Object Models

System Assembly

Examples

Fluid Dynamics

Problem Specification
The problem studied is that of an oblique shock
generated by a 10o wedge angle.
This problem has an exact solution for density which
is a step function.

Summary

Introduction

Object Models

System Assembly

Examples

Fluid Dynamics

Problem Specification
The problem studied is that of an oblique shock
generated by a 10o wedge angle.
This problem has an exact solution for density which
is a step function.
Utilizing libmeshs exact solution capability the exact
L2 error can be solved for.

Summary

Introduction

Object Models

System Assembly

Examples

Fluid Dynamics

Problem Specification
The problem studied is that of an oblique shock
generated by a 10o wedge angle.
This problem has an exact solution for density which
is a step function.
Utilizing libmeshs exact solution capability the exact
L2 error can be solved for.
The exact solution is shown below:

Summary

Introduction

Object Models

System Assembly

Examples

Summary

Fluid Dynamics

Uniformly Refined Solutions


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

0.8

0.8

0.6

0.6

r
1.45
1.4
1.35
1.3
1.25
1.2
1.15
1.1
1.05
1

0.4

0.4

0.2

0.2

0.2

0.4

0.6

0.8

(c) Mesh after 1 uniform

0.2

0.4

0.6

0.8

(d) Solution after 1 uni-

Introduction

Object Models

System Assembly

Examples

Fluid Dynamics

H-Adapted Solutions
A flux jump indicator was employed as the error
indcator along with a statistical flagging scheme.

Summary

Introduction

Object Models

System Assembly

Examples

Summary

Fluid Dynamics

H-Adapted Solutions
A flux jump indicator was employed as the error
indcator along with a statistical flagging scheme.
Here is a mesh and solution after 2 adaptive
refinements containing 10800 DOFs:
1

0.8

0.8

0.6

0.6

r
1.45
1.4
1.35
1.3
1.25
1.2
1.15
1.1
1.05
1

0.4

0.4

0.2

0.2

0.2

0.4

0.6

0.8

0.2

0.4

0.6

0.8

Introduction

Object Models

System Assembly

Examples

Summary

Fluid Dynamics

Redistributed Solutions
Redistribution utilizing the same flux jump indicator.
1

0.8

0.8

0.6

0.6

r
1.45
1.4
1.35
1.3
1.25
1.2
1.15
1.1
1.05
1

0.4

0.4

0.2

0.2

0.2

0.4

0.6

0.8

(i) Mesh after 8 redistributions.

0.2

0.4

0.6

0.8

(j) Solution after 8 redistributions.

Introduction

Object Models

System Assembly

Examples

Summary

Fluid Dynamics

Redistributed and Adapted


Now combining the two, here are the mesh and
solution after 2 adaptations beyond the previous
redistribution containing 10190 DOFs.
1

0.8

0.8

0.6

0.6

r
1.45
1.4
1.35
1.3
1.25
1.2
1.15
1.1
1.05
1

0.4

0.4

0.2

0.2

0.2

0.4

0.6

0.8

0.2

0.4

0.6

0.8

Introduction

Object Models

System Assembly

Examples

Summary

Fluid Dynamics

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

1
r

0.81.45

0.6

0.4

0.4

0.2

0.2

0.2

0.2

0.4

0.6

0.8

(m) Uniform.

0.2

0.4

0.6

0.8

(n) Adaptive.

1.45
1.4
1.35
1.3
1.25
1.2
1.15
1.1
1.05
1

1.4
1.35
1.3
1.25
0.61.2
1.15
1.1
1.05
1

0.4

0.81.45

1.4
1.35
1.3
1.25
0.61.2
1.15
1.1
1.05
1

0.8

0.2

0.4

0.6

(o) R + H.

0.8

Introduction

Object Models

System Assembly

Examples

Summary

Fluid Dynamics

Error Plot
libmesh provides capability for computing error norms
against an exact solution.

Introduction

Object Models

System Assembly

Examples

Summary

Fluid Dynamics

Error Plot
libmesh provides capability for computing error norms
against an exact solution.
The exact solution is not in H 1 therefore we only
obtain the L2 convergence plot:
Uniform
Adaptivity
Redist + Adapt

-1.2

log10(L2Error)

-1.4

-1.6

-1.8

-2.0

-2.2
3.5

4.0

4.5
log10(N Dofs)

5.0

Introduction
Fluid Dynamics

Object Models

System Assembly

Examples

Summary

Introduction

Object Models

System Assembly

Examples

Summary

Fluid Dynamics

Natural Convection

Tetrahedral mesh of pipe geometry. Stream ribbons


colored by temperature.

Introduction

Object Models

System Assembly

Examples

Fluid Dynamics

Surface-Tension-Driven Flow

Adaptive grid solution shown with temperature


contours and velocity vectors.

Summary

Introduction

Object Models

System Assembly

Examples

Summary

Fluid Dynamics

Double-Diffusive Convection

Solute contours: a plume of warm, low-salinity fluid is


convected upward through a porous medium.

Introduction

Object Models

System Assembly

Examples

Biology

Tumor Angiogenesis

The tumor secretes a chemical which stimulates


blood vessel formation.

Summary

Introduction

Object Models

System Assembly

Examples

Summary

Material Science

Free Energy Formulation


Cahn-Hilliard systems model phase separation and
interface evolution
f (c, c) f0 (c) + f (c)
2
f (c) c c c
2
f0 (c) NkT (c ln (c) + (1 c) ln (1 c)) + Nc(1 c)


c
= Mc f00 (c) 2c c
t

Introduction

Object Models

System Assembly

Examples

Summary

Material Science

Phase Separation - Spinodal Decomposition


Initial Evolution
Initial homogeneous blend quenched below critical T
Random perturbations anti-diffuse into two phases
divided by narrow interfaces
Gradual coalescence of single-phase regions
Additional physics leads to pattern self-assembly

Introduction

Object Models

System Assembly

Examples

Summary
libMesh Development
Open Source (LGPL)
Leveraging existing libraries
Public site, mailing lists, CVS tree, examples, etc. at
http://libmesh.sf.net/
18 examples including:
Infinite Elements for the wave equation.
Helmholtz with complex numbers.
Laplace in L-Shaped Domain.
Biharmonic Equation.
Using SLEPc for an Eigen Problem.
Unsteady Navier Stokes.
And More!

Summary

Das könnte Ihnen auch gefallen