LibMesh Experience and Usage

Similar documents
LibMesh Experience and Usage

libmesh Finite Element Library

Adaptive C1 Macroelements for Fourth Order and Divergence-Free Problems

Parallel Adaptive Finite Element Methods for Problems in Natural Convection

Cahn-Hilliard Phase Decomposition and

LEAST-SQUARES FINITE ELEMENT MODELS

Scientific Computing I

Lehrstuhl Informatik V. Lehrstuhl Informatik V. 1. solve weak form of PDE to reduce regularity properties. Lehrstuhl Informatik V

Finite Elements for Nonlinear Problems

Math background. Physics. Simulation. Related phenomena. Frontiers in graphics. Rigid fluids

1. Let a(x) > 0, and assume that u and u h are the solutions of the Dirichlet problem:

Numerical Solutions to Partial Differential Equations

AMS 529: Finite Element Methods: Fundamentals, Applications, and New Trends

The Virtual Element Method: an introduction with focus on fluid flows

A simple FEM solver and its data parallelism

HYPERSONIC AERO-THERMO-DYNAMIC HEATING PREDICTION WITH HIGH-ORDER DISCONTINOUS GALERKIN SPECTRAL ELEMENT METHODS

Space-time XFEM for two-phase mass transport

AMS 529: Finite Element Methods: Fundamentals, Applications, and New Trends

Numerical methods for the Navier- Stokes equations

An Introduction to the Discontinuous Galerkin Method

OUTLINE ffl CFD: elliptic pde's! Ax = b ffl Basic iterative methods ffl Krylov subspace methods ffl Preconditioning techniques: Iterative methods ILU

Algebraic flux correction and its application to convection-dominated flow. Matthias Möller

Sparse Linear Systems. Iterative Methods for Sparse Linear Systems. Motivation for Studying Sparse Linear Systems. Partial Differential Equations

Discontinuous Galerkin Methods

Scientific Computing WS 2017/2018. Lecture 18. Jürgen Fuhrmann Lecture 18 Slide 1

Iterative Methods for Linear Systems

LECTURE # 0 BASIC NOTATIONS AND CONCEPTS IN THE THEORY OF PARTIAL DIFFERENTIAL EQUATIONS (PDES)

Discretization of PDEs and Tools for the Parallel Solution of the Resulting Systems

FINITE ELEMENT SUPG PARAMETERS COMPUTED FROM LOCAL DOF-MATRICES FOR COMPRESSIBLE FLOWS

[2] (a) Develop and describe the piecewise linear Galerkin finite element approximation of,

Concepts. 3.1 Numerical Analysis. Chapter Numerical Analysis Scheme

Finite Elements. Colin Cotter. January 15, Colin Cotter FEM

A High-Order Discontinuous Galerkin Method for the Unsteady Incompressible Navier-Stokes Equations

A Hybrid Method for the Wave Equation. beilina

Chapter 2. General concepts. 2.1 The Navier-Stokes equations

Iterative Methods for Incompressible Flow

Non-Newtonian Fluids and Finite Elements

Finite Difference Methods for Boundary Value Problems

Relevant self-assessment exercises: [LIST SELF-ASSESSMENT EXERCISES HERE]

Spline Element Method for Partial Differential Equations

DUE: WEDS MARCH 26TH 2018

Finite Volume Method

Finite Difference Methods (FDMs) 1

Spatial discretization scheme for incompressible viscous flows

Lecture 9 Approximations of Laplace s Equation, Finite Element Method. Mathématiques appliquées (MATH0504-1) B. Dewals, C.

Zonal modelling approach in aerodynamic simulation

Implicit Solution of Viscous Aerodynamic Flows using the Discontinuous Galerkin Method

Lecture 18 Classical Iterative Methods

A recovery-assisted DG code for the compressible Navier-Stokes equations

A Bound-Preserving Fourth Order Compact Finite Difference Scheme for Scalar Convection Diffusion Equations

A high-order discontinuous Galerkin solver for 3D aerodynamic turbulent flows

TMA4220: Programming project - part 1

FEniCS Course. Lecture 0: Introduction to FEM. Contributors Anders Logg, Kent-Andre Mardal

Solving PDEs with Multigrid Methods p.1

Non-Conforming Finite Element Methods for Nonmatching Grids in Three Dimensions

Solving PDEs with freefem++

V (r,t) = i ˆ u( x, y,z,t) + ˆ j v( x, y,z,t) + k ˆ w( x, y, z,t)

Method of Finite Elements I

Linear Solvers. Andrew Hazel

Physics 202 Laboratory 5. Linear Algebra 1. Laboratory 5. Physics 202 Laboratory

Recovery-Based A Posteriori Error Estimation

Iterative methods for positive definite linear systems with a complex shift

The Discontinuous Galerkin Finite Element Method

A Central Compact-Reconstruction WENO Method for Hyperbolic Conservation Laws

ON THE BENEFIT OF THE SUMMATION-BY-PARTS PROPERTY ON INTERIOR NODAL SETS

A Matlab Tutorial for Diffusion-Convection-Reaction Equations using DGFEM

Discontinuous Galerkin methods for nonlinear elasticity

Numerical Methods for Partial Differential Equations: an Overview.

On a Discontinuous Galerkin Method for Surface PDEs

A hybrid method for hydrodynamic-kinetic flow - Part II - Coupling of hydrodynamic and kinetic models

Wave propagation methods for hyperbolic problems on mapped grids

Hp-Adaptivity on Anisotropic Meshes for Hybridized Discontinuous Galerkin Scheme

Solving Large Nonlinear Sparse Systems

On finite element methods for 3D time dependent convection diffusion reaction equations with small diffusion

New DPG techniques for designing numerical schemes

Large-Scale Nonlinear Optimization with Inexact Step Computations

ADAPTIVE DETERMINATION OF THE FINITE ELEMENT STABILIZATION PARAMETERS

Space-time Finite Element Methods for Parabolic Evolution Problems

Numerical Solution I

Matrix Assembly in FEA

Lecture Note III: Least-Squares Method

Elliptic Problems / Multigrid. PHY 604: Computational Methods for Physics and Astrophysics II

Numerical Solutions to Partial Differential Equations

Shock Capturing for Discontinuous Galerkin Methods using Finite Volume Sub-cells

Is My CFD Mesh Adequate? A Quantitative Answer

1 PART1: Bratu problem

Finite Difference Solution of the Heat Equation

FEniCS Course. Lecture 6: Incompressible Navier Stokes. Contributors Anders Logg André Massing

Question 9: PDEs Given the function f(x, y), consider the problem: = f(x, y) 2 y2 for 0 < x < 1 and 0 < x < 1. x 2 u. u(x, 0) = u(x, 1) = 0 for 0 x 1

Study of Forced and Free convection in Lid driven cavity problem

Parallel Discontinuous Galerkin Method

Modeling, Simulating and Rendering Fluids. Thanks to Ron Fediw et al, Jos Stam, Henrik Jensen, Ryan

Universität des Saarlandes. Fachrichtung 6.1 Mathematik

IMA Preprint Series # 2143

Chapter 6. Finite Element Method. Literature: (tiny selection from an enormous number of publications)

A Space-Time Multigrid Solver Methodology for the Optimal Control of Time-Dependent Fluid Flow

Generalized Finite Element Methods for Three Dimensional Structural Mechanics Problems. C. A. Duarte. I. Babuška and J. T. Oden

Compressible Navier-Stokes (Euler) Solver based on Deal.II Library

Multiphysics Coupling: Hypersonic Flow with Radiation and Ablation

MATH 333: Partial Differential Equations

Transcription:

LibMesh Experience and Usage John W. Peterson peterson@cfdlab.ae.utexas.edu and Roy H. Stogner roystgnr@cfdlab.ae.utexas.edu Univ. of Texas at Austin September 9, 2008

1 Introduction 2 Weighted Residuals 3 Poisson Equation 4 Other Examples 5 Essential BCs 6 Some Extensions

1 Introduction 2 Weighted Residuals 3 Poisson Equation 4 Other Examples 5 Essential BCs 6 Some Extensions

Library Description Tumor Angiogenesis Compressible RBM NS Petsc Laspack DD LibMesh STL Metis Library Structure Basic libraries are LibMesh s roots Application branches built off the library trunk Mpich

A Generic BVP We assume there is a Boundary Value Problem of the form M u t = F(u) Ω G(u) = 0 Ω u = u D Ω D Ω Ω D N(u) = 0 Ω N u(x, 0) = u 0 (x) Ω N

A Generic BVP Associated to the problem domain Ω is a LibMesh data structure called a Mesh A Mesh is essentially a collection of finite elements Ω h Ω h := e Ω e

A Generic BVP Associated to the problem domain Ω is a LibMesh data structure called a Mesh A Mesh is essentially a collection of finite elements Ω h Ω h := e Ω e LibMesh provides some simple structured mesh generation routines, file inputs, and interfaces to Triangle and TetGen.

Non-Trivial Applications LibMesh provides several of the tools necessary to construct these systems, but it is not specifically written to solve any one problem. First, a few of the non-trivial applications which have been built on top of the library.

Natural Convection Tetrahedral mesh of pipe geometry. Stream ribbons colored by temperature.

Surface-Tension-Driven Flow Adaptive grid solution shown with temperature contours and velocity vectors.

Double-Diffusive Convection Solute contours: a plume of warm, low-salinity fluid is convected upward through a porous medium.

Tumor Angiogenesis The tumor secretes a chemical which stimulates blood vessel formation.

Phase Separation Directed pattern self-assembly in spinodal decomposition of binary mixture

Compressible Flow 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. 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.

Compressible Flow 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. 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.

Compressible Flow 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. 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.

Compressible Flow 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. 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.

Compressible Flow 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. 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.

Compressible Flow 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. 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.

Compressible Flow 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. 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.

Compressible Flow 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. 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.

Compressible Flow 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. 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.

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

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

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

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

Compressible Flow Uniformly Refined Solutions For comparison purposes, here is a mesh and a solution after 1 uniform refinement with 10890 DOFs. 1 1 r y 0.8 0.6 0.4 y 0.8 0.6 0.4 1.45 1.4 1.35 1.3 1.25 1.2 1.15 1.1 1.05 1 0.2 0.2 0 0 0.2 0.4 0.6 0.8 1 x 0 0 0.2 0.4 0.6 0.8 1 x (a) Mesh after 1 uniform refinement. (b) Solution after 1 uniform refinement.

Compressible Flow 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 1 r y 0.8 0.6 0.4 y 0.8 0.6 0.4 1.45 1.4 1.35 1.3 1.25 1.2 1.15 1.1 1.05 1 0.2 0.2 0 0 0.2 0.4 0.6 0.8 1 x 0 0 0.2 0.4 0.6 0.8 1 x

Compressible Flow 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 1 r y 0.8 0.6 0.4 y 0.8 0.6 0.4 1.45 1.4 1.35 1.3 1.25 1.2 1.15 1.1 1.05 1 0.2 0.2 0 0 0.2 0.4 0.6 0.8 1 x 0 0 0.2 0.4 0.6 0.8 1 x

Compressible Flow Redistributed Solutions Redistribution utilizing the same flux jump indicator. 1 1 r y 0.8 0.6 0.4 y 0.8 0.6 0.4 1.45 1.4 1.35 1.3 1.25 1.2 1.15 1.1 1.05 1 0.2 0.2 0 0 0.2 0.4 0.6 0.8 1 x (g) Mesh, 8 redistribution steps 0 0 0.2 0.4 0.6 0.8 1 x (h) Solution

Compressible Flow Redistributed and Adapted Now combining the two, here are the mesh and solution after 2 adaptations beyond the previous redistribution containing 10190 DOFs. 1 1 r y 0.8 0.6 0.4 y 0.8 0.6 0.4 1.45 1.4 1.35 1.3 1.25 1.2 1.15 1.1 1.05 1 0.2 0.2 0 0 0.2 0.4 0.6 0.8 1 x (i) Mesh, 2 refinements 0 0 0.2 0.4 0.6 0.8 1 x (j) Solution

Compressible Flow Solution Comparison For a better comparison here are 3 of the solutions, each with around 11000 DOFs: 1 1 1 r r r y 0.8 0.6 y 0.81.45 1.4 1.35 1.3 1.25 1.2 0.6 1.15 1.1 1.05 1 y 0.81.45 1.4 1.35 1.3 1.25 1.2 0.6 1.15 1.1 1.05 1 1.45 1.4 1.35 1.3 1.25 1.2 1.15 1.1 1.05 1 0.4 0.4 0.4 0.2 0.2 0.2 0 0 0.2 0.4 0.6 0.8 1 x (k) Uniform. 0 0 0.2 0.4 0.6 0.8 1 x (l) Adaptive. 0 0 0.2 0.4 0.6 0.8 1 x (m) R + H.

2 0 Compressible Flow 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 L 2 convergence plot: -1.2 Uniform Adaptivity Redist + Adapt -1.4 1 (L Error ) log -1.6-1.8-2.0-2.2 3.5 4.0 4.5 5.0 log 10 D ofs

2 0 Compressible Flow 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 L 2 convergence plot: -1.2 Uniform Adaptivity Redist + Adapt -1.4 1 (L Error ) log -1.6-1.8-2.0-2.2 3.5 4.0 4.5 5.0 log 10 D ofs

Outline Introduction Compressible Flow 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

The point of departure in any FE analysis which uses LibMesh is the weighted residual statement (F(u), v) = 0 v V Or, more precisely, the weighted residual statement associated with the finite-dimensional space V h V (F(u h ), v h ) = 0 v h V h

The point of departure in any FE analysis which uses LibMesh is the weighted residual statement (F(u), v) = 0 v V Or, more precisely, the weighted residual statement associated with the finite-dimensional space V h V (F(u h ), v h ) = 0 v h V h

Some Examples Poisson Equation u = f Ω

Some Examples Poisson Equation u = f Ω Weighted Residual Statement (F(u), v) := [ u v fv] dx Ω + ( u n) v ds Ω N

Some Examples Linear Convection-Diffusion k u + b u = f Ω

Some Examples Linear Convection-Diffusion k u + b u = f Ω Weighted Residual Statement (F(u), v) := [k u v + (b u)v fv] dx Ω + k ( u n) v ds Ω N

Some Examples Stokes Flow p ν u = f u = 0 Ω

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 + (ν u pi) n v ds Ω N

Some Examples To obtain the approximate problem, we simply replace u u h, v v h, and Ω Ω h in the weighted residual statement.

1 Introduction 2 Weighted Residuals 3 Poisson Equation 4 Other Examples 5 Essential BCs 6 Some Extensions

Weighted Residual Statement For simplicity we start with the weighted residual statement arising from the Poisson equation, with Ω N =, (F(u h ), v h ) := Ω h [ uh v h fv h] dx = 0 v h V h

Element Integrals The integral over Ω h... 0 = Ω h [ uh v h fv h] dx v h V h

Element Integrals The integral over Ω h... is written as a sum of integrals over the N e finite elements: 0 = = [ uh v h fv h] dx Ω h N e [ uh v h fv h] dx Ω e e=1 v h V h v h V h

Finite Element Basis Functions An element integral will have contributions only from the global basis functions corresponding to its nodes. We call these local basis functions φ i, 0 i N s. v h N s Ωe = c i φ i i=1 000 111 0000 1111 00000 11111 00000 11111 0000 1111 00 11 Ω e

Finite Element Basis Functions An element integral will have contributions only from the global basis functions corresponding to its nodes. We call these local basis functions φ i, 0 i N s. v h N s Ωe = c i φ i i=1 N s v h dx = c i φ i dx Ω e Ω e i=1 000 111 0000 1111 00000 11111 00000 11111 0000 1111 00 11 Ω e

Element Matrix and Load Vector The element integrals... Ω e [ uh v h fv h] dx

Element Matrix and Load Vector The element integrals... Ω e [ uh v h fv h] dx are written in terms of the local φ i basis functions N s j=1 u j φ j φ i dx f φ i dx, i = 1,..., N s Ω e Ω e

Element Matrix and Load Vector The element integrals... Ω e [ uh v h fv h] dx are written in terms of the local φ i basis functions N s j=1 u j φ j φ i dx f φ i dx, i = 1,..., N s Ω e Ω e This can be expressed naturally in matrix notation as K e U e F e

Global Linear System The entries of the element stiffness matrix are the integrals K e ij := φ j φ i dx Ω e

Global Linear System The entries of the element stiffness matrix are the integrals K e ij := φ j φ i dx Ω e While for the element right-hand side we have F e i := f φ i dx Ω e

Global Linear System The entries of the element stiffness matrix are the integrals K e ij := φ j φ i dx Ω e While for the element right-hand side we have F e i := f φ i dx Ω e The element stiffness matrices and right-hand sides can be assembled to obtain the global system of equations KU = F

Reference Element Map The integrals are performed on a reference element ˆΩ e x Ω e (ξ) x ξ Ω e

Reference Element Map The integrals are performed on a reference element ˆΩ e x Ω e (ξ) x ξ Ω e The Jacobian of the map x(ξ) is J. F e i = f φ i dx = Ω e f (x(ξ))φ i J dξ ˆΩ e

Reference Element Map The integrals are performed on a reference element ˆΩ e x Ω e (ξ) x ξ Ω e Chain rule: = J 1 ξ := ˆ ξ K e ij = φ j φ i dx = Ω e ˆΩ e ˆ ξ φ j ˆ ξ φ i J dξ

Element Quadrature The integrals on the reference element are approximated via numerical quadrature.

Element Quadrature The integrals on the reference element are approximated via numerical quadrature. The quadrature rule has N q points ξ q and weights w q.

Element Quadrature The integrals on the reference element are approximated via numerical quadrature. The quadrature rule has N q points ξ q and weights w q. F e i = f φ i J dξ ˆΩ e N q q=1 f (x(ξ q ))φ i (ξ q ) J(ξ q ) w q

Element Quadrature The integrals on the reference element are approximated via numerical quadrature. The quadrature rule has N q points ξ q and weights w q. K e ij = ˆΩ e N q q=1 ˆ ξ φ j ˆ ξ φ i J dξ ˆ ξ φ j (ξ q ) ˆ ξ φ i (ξ q ) J(ξ q ) w q

LibMesh Quadrature Point Data LibMesh provides the following variables at each quadrature point q Code Math Description JxW[q] J(ξ q ) w q Jacobian times weight phi[i][q] φ i (ξ q ) value of i th shape fn. dphi[i][q] ˆ ξ φ i (ξ q ) value of i th shape fn. gradient xyz[q] x(ξ q ) location of ξ q in physical space

Matrix Assembly Loops 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]);

Matrix Assembly Loops 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]); N q F e i = f (x(ξ q ))φ i (ξ q ) J(ξ q ) w q q=1

Matrix Assembly Loops 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]); N q F e i = f (x(ξ q ))φ i (ξ q ) J(ξ q ) w q q=1

Matrix Assembly Loops 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]); N q F e i = f (x(ξ q ))φ i (ξ q ) J(ξ q ) w q q=1

Matrix Assembly Loops 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]); N q F e i = f (x(ξ q ))φ i (ξ q ) J(ξ q ) w q q=1

Matrix Assembly Loops 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 e ij = N q q=1 ˆ ξ φ j (ξ q ) ˆ ξ φ i (ξ q ) J(ξ q ) w q

Matrix Assembly Loops 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 e ij = N q q=1 ˆ ξ φ j (ξ q ) ˆ ξ φ i (ξ q ) J(ξ q ) w q

Matrix Assembly Loops 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 e ij = N q q=1 ˆ ξ φ j (ξ q ) ˆ ξ φ i (ξ q ) J(ξ q ) w q

1 Introduction 2 Weighted Residuals 3 Poisson Equation 4 Other Examples 5 Essential BCs 6 Some Extensions

Convection-Diffusion Equation The matrix assembly routine for the linear convection-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]);

Convection-Diffusion Equation The matrix assembly routine for the linear convection-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]);

Convection-Diffusion Equation The matrix assembly routine for the linear convection-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]);

Stokes Flow For multi-variable systems like Stokes flow, p ν u = f u = 0 Ω R 2 The element stiffness matrix concept can extended to include sub-matrices Ku e 1 u 1 Ku e 1 u 2 Ku e 1 p U Ku e 2 u 1 Ku e 2 u 2 Ku e u e 1 F 2 p U e u e 1 Kpu e 1 Kpu e 2 Kpp e u 2 F e Up e u 2 Fp e We have an array of submatrices: Ke[ ][ ]

Stokes Flow For multi-variable systems like Stokes flow, p ν u = f u = 0 Ω R 2 The element stiffness matrix concept can extended to include sub-matrices Ku e 1 u 1 Ku e 1 u 2 Ku e 1 p U Ku e 2 u 1 Ku e 2 u 2 Ku e u e 1 F 2 p U e u e 1 Kpu e 1 Kpu e 2 Kpp e u 2 F e Up e u 2 Fp e We have an array of submatrices: Ke[0][0]

Stokes Flow For multi-variable systems like Stokes flow, p ν u = f u = 0 Ω R 2 The element stiffness matrix concept can extended to include sub-matrices Ku e 1 u 1 Ku e 1 u 2 Ku e 1 p U Ku e 2 u 1 Ku e 2 u 2 Ku e u e 1 F 2 p U e u e 1 Kpu e 1 Kpu e 2 Kpp e u 2 F e Up e u 2 Fp e We have an array of submatrices: Ke[1][1]

Stokes Flow For multi-variable systems like Stokes flow, p ν u = f u = 0 Ω R 2 The element stiffness matrix concept can extended to include sub-matrices Ku e 1 u 1 Ku e 1 u 2 Ku e 1 p U Ku e 2 u 1 Ku e 2 u 2 Ku e u e 1 F 2 p U e u e 1 Kpu e 1 Kpu e 2 Kpp e u 2 F e Up e u 2 Fp e We have an array of submatrices: Ke[2][1]

Stokes Flow For multi-variable systems like Stokes flow, p ν u = f u = 0 Ω R 2 The element stiffness matrix concept can extended to include sub-matrices Ku e 1 u 1 Ku e 1 u 2 Ku e 1 p U Ku e 2 u 1 Ku e 2 u 2 Ku e u e 1 F 2 p U e u e 1 Kpu e 1 Kpu e 2 Kpp e u 2 F e Up e u 2 Fp e And an array of right-hand sides: Fe[].

Stokes Flow For multi-variable systems like Stokes flow, p ν u = f u = 0 Ω R 2 The element stiffness matrix concept can extended to include sub-matrices Ku e 1 u 1 Ku e 1 u 2 Ku e 1 p U Ku e 2 u 1 Ku e 2 u 2 Ku e u e 1 F 2 p U e u e 1 Kpu e 1 Kpu e 2 Kpp e u 2 F e Up e u 2 Fp e And an array of right-hand sides: Fe[0].

Stokes Flow For multi-variable systems like Stokes flow, p ν u = f u = 0 Ω R 2 The element stiffness matrix concept can extended to include sub-matrices Ku e 1 u 1 Ku e 1 u 2 Ku e 1 p U Ku e 2 u 1 Ku e 2 u 2 Ku e u e 1 F 2 p U e u e 1 Kpu e 1 Kpu e 2 Kpp e u 2 F e Up e u 2 Fp e And an array of right-hand sides: Fe[1].

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

1 Introduction 2 Weighted Residuals 3 Poisson Equation 4 Other Examples 5 Essential BCs 6 Some Extensions

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 2 zeroing out the row entries 3 placing the Dirichlet value in the rhs vector 4 subtracting off the column entries from the rhs

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 2 zeroing out the row entries 3 placing the Dirichlet value in the rhs vector 4 subtracting off the column entries from the rhs

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 2 zeroing out the row entries 3 placing the Dirichlet value in the rhs vector 4 subtracting off the column entries from the rhs

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 2 zeroing out the row entries 3 placing the Dirichlet value in the rhs vector 4 subtracting off the column entries from the rhs

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 2 zeroing out the row entries 3 placing the Dirichlet value in the rhs vector 4 subtracting off the column entries from the rhs k 11 k 12 k 13. f 1 1 0 0 0 g 1 k 21 k 22 k 23. k 31 k 32 k 33., f 2 f 3 0 k 22 k 23. 0 k 32 k 33., f 2 k 21 g 1 f 3 k 31 g 1..... 0....

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 generic finite element basis at the element stiffness matrix level.

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 generic finite element basis at the element stiffness matrix level.

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 generic finite element basis at the element stiffness matrix level.

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 generic finite element basis at the element stiffness matrix level.

Penalty Formulation One solution is the penalty boundary formulation A term is added to the standard weighted residual statement (F(u), v) + 1 (u u D )v dx = 0 v V ɛ Ω } D {{} penalty term Here ɛ 1 is chosen so that, in floating point arithmetic, 1 ɛ + 1 = 1 ɛ. This weakly enforces u = u D on the Dirichlet boundary, and works for general finite element bases.

Penalty Formulation One solution is the penalty boundary formulation A term is added to the standard weighted residual statement (F(u), v) + 1 (u u D )v dx = 0 v V ɛ Ω } D {{} penalty term Here ɛ 1 is chosen so that, in floating point arithmetic, 1 ɛ + 1 = 1 ɛ. This weakly enforces u = u D on the Dirichlet boundary, and works for general finite element bases.

Penalty Formulation One solution is the penalty boundary formulation A term is added to the standard weighted residual statement (F(u), v) + 1 (u u D )v dx = 0 v V ɛ Ω } D {{} penalty term Here ɛ 1 is chosen so that, in floating point arithmetic, 1 ɛ + 1 = 1 ɛ. This weakly enforces u = u D on the Dirichlet boundary, and works for general finite element bases.

Penalty Formulation One solution is the penalty boundary formulation A term is added to the standard weighted residual statement (F(u), v) + 1 (u u D )v dx = 0 v V ɛ Ω } D {{} penalty term Here ɛ 1 is chosen so that, in floating point arithmetic, 1 ɛ + 1 = 1 ɛ. This weakly enforces u = u D on the Dirichlet boundary, and works for general finite element bases.

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

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

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

1 Introduction 2 Weighted Residuals 3 Poisson Equation 4 Other Examples 5 Essential BCs 6 Some Extensions

Time-Dependent Problems For linear problems, we have already seen how the weighted residual statement leads directly to a sparse linear system of equations KU = F

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 ( ) u n+1 u n, v h = ( F(u θ ), v h) v h V h t u θ := θu n+1 + (1 θ)u n Leads to KU = F at each timestep.

Nonlinear Problems For nonlinear problems, typically a sequence of linear problems must be solved, e.g. for Newton s method (F (u k )δu k+1, v) = (F(u k ), v) where F (u k ) is the linearized (Jacobian) operator associated with the PDE. Must solve KU = F (Inexact Newton method) at each iteration step.

B. Kirk, J. Peterson, R. Stogner and G. Carey, libmesh: a C++ library for parallel adaptive mesh refinement/coarsening simulations, Engineering with Computers, vol. 22, no. 3 4, p. 237 254, 2006. Public site, mailing lists, SVN tree, examples, etc.: http://libmesh.sf.net/