variational and geometric aspects of compatible ... · interoperable tools for rapid development of...
TRANSCRIPT
Computational mathematics and algorithms
Pavel Bochev
Applied Mathematics and Applications
Sandia National Laboratories
Sandia is a multiprogram laboratory operated by Sandia Corporation, a Lockheed Martin Company,for the United States Department of Energy!s National Nuclear Security Administration
under contract DE-AC04-94AL85000.
Variational and Geometric Aspects of
Compatible Discretizations
Part III
Supported in part by
EU Regional School Part 2: Short Courses 11 and 12
October 1-2, 2009
Computational mathematics and algorithms
• Part 3: Software for compatible discretizations
– The evolving scope of the Trilinos project: the capability areas.
– Intrepid: interoperable tools for compatible discretizations
– Examples
• Part 2: Geometric Compatibility
– What it is
– What it buys you
– How it relates to variational compatibility
Overview
• Part 1: Variational Compatibility
– Crash course in variational methods
– Variational compatibility of FEM and what it means
– Alternatives to variationally compatible FEM
Computational mathematics and algorithms
Sandia Physics Simulation Codes
• Element-based
– Finite element, finite volume,finite difference, network,etc…
• Large-scale
– Billions of unknowns
• Parallel
– MPI-based SPMD
– Distributed memory
• C++
– Object oriented
– Some coupling to legacyFortran libraries
Fluids Combustion
Structures
Circuits
Plasmas
MEMS
Computational mathematics and algorithms
Motivation For Trilinos
• Sandia does LOTS of solver work.
• 10 years ago …
– Aztec was a mature package. Used in many codes.
– FETI, PETSc, DSCPack, Spooles, ARPACK, DASPK, and many
other codes were (and are) in use.
– New projects were underway or planned in multi-level
preconditioners, eigensolvers, non-linear solvers, etc…
• The challenges:
– Little or no coordination was in place to:
• Efficiently reuse existing solver technology.
• Leverage new development across various projects.
• Support solver software processes.
• Provide consistent solver APIs for applications.
– ASCI was forming software quality assurance/engineering
(SQA/SQE) requirements:
• Daunting requirements for any single solver effort to address alone.
Computational mathematics and algorithms
Evolving Trilinos Solution: Package Concept
• Trilinos1 is an evolving framework to address these challenges:
– Fundamental atomic unit is a package.
– Includes core set of vector, graph and matrix classes (Epetra/Tpetra packages).
– Provides a common abstract solver API (Thyra package).
– Provides a ready-made package infrastructure (new_package package):
• Source code management (cvs, bonsai).
• Build tools: CMake.
• Automated regression testing (queue directories within repository).
• Communication tools (mailman mail lists).
– Specifies requirements and suggested practices for package SQA.
• In general allows us to categorize efforts:
– Efforts best done at the Trilinos level (useful to most or all packages).
– Efforts best done at a package level (peculiar or important to a package).
! Allows package developers to focus only on things that are unique to
their package.
1. Trilinos loose translation: “A string of pearls”
Computational mathematics and algorithms
Evolving Trilinos Solution
Numerical mathConvert to models thatcan be solved on digital
computers
AlgorithmsFind faster and moreefficient ways to solve
numerical models
L(u)=fMath. model
Lh(uh)=fhNumerical model
uh=Lh-1•fh
Algorithms
physics
computation
Linear
Nonlinear
Eigenvalues
Optimization
Automatic diff.
Domain dec.
Mortar methods
Time domain
Space domain
Petra
Utilities
Interfaces
Load Balancing
solvers
discretizations methods
core
• Trilinos grew beyond a “solvers” framework
• Natural expansion of capabilities to satisfy
application and research needs
• Functionality types mapped into capability areas
• Interoperable tools for scientific computing
• Enables rapid development of production codes
Computational mathematics and algorithms
Evolving Trilinos Solution: Capability Areas
1. Framework & Tools - Jim Willenbring
2. Software Engineering Technologies and Integration - Roscoe Bartlett
3. Discretizations - Pavel Bochev
4. Meshes, Geometry, & Load Balancing - Karen Devine
5. Scalable Linear Algebra - Michael Heroux
6. Linear & Eigen Solvers - Jonathan Hu
7. Embedded Nonlinear Analysis Tools - Andy Salinger
Current Capability areas of Trilinos:
http://trilinos.sandia.gov/capability_areas.html
Computational mathematics and algorithms
Discretization Capability Area
3 related categories of discretization tools:
• Global tools: FEI (A. Williams)
– Interfaces for assembling local (cell-wise) data into global representations of
discrete differential operators and functionals by matrices and vectors
• Model tools: PHALANX (R. Pawlowski)
– Manage discrete representations of physical fields in the PDE model and their
relationships necessary to form Jacobians, residuals, operator matrices, etc.
• Local tools: INTREPID, SHARDS (P. Bochev, D. Ridzal, K. Peterson, C.
Edwards)
– Provide basic building blocks for numerical PDEs such as reconstruction operators
(bases) for FE, FV and FD methods on a single cell, pullback (transformation of
bases), cell and subcell integration.
A collection of packages and interfaces for rapid development of application codes
for the numerical solution of PDE and related problems: e.g., optimal control and
design, inverse problems,… using Embedded Tools from Capability area 7.
http://trilinos.sandia.gov/CapabilityWebpages/Discretizations/index.html
Computational mathematics and algorithms
Trilinos Package Summary
SacadoAutomatic DifferentiationMethods
MoertelMortar Methods
Intrepid, FEI, PAMGENSpatial Discretizations/Assembly/grid
DiscretizationsShardsCell topology & Arrays
PhalanxPhysics kernels
RythmosTime Integration
Amesos/Epetra, Teuchos, PlirisDirect linear solvers: sparse/dense
AnasaziIterative eigenvalue solvers
Epetra, Jpetra, TpetraLinear algebra objects
Core
Thyra, Stratimikos, RTOpAbstract interfaces
Zoltan, IsorropiaLoad Balancing
PyTrilinos, WebTrilinos, Star-P, ForTrilinos“Skins”
Teuchos, EpetraExt, Kokkos, TriutilsC++ utilities, (some) I/O
MOOCHO, AristosOptimization (SAND)
NOX, LOCANonlinear system solvers
AztecOO, IFPACK/ ML, CLAPS/ MerosPreconditioners : ILU-type/ML/Block
AztecOO, Belos, KomplexIterative (Krylov) linear solvers
Solvers
Package(s)ObjectiveType
http://trilinos.sandia.gov/packages/
Computational mathematics and algorithms
Trilinos Availability / Information
• Trilinos and related packages are available via LGPL.
• Current release (9.0) is “click release”. Unlimited availability.
– 3100+ Downloads (not including internal Sandia users).
– 3880 registered users:
• 61% university, 11% industry, 15% gov’t.
• 38% European, 33% US, 15% Asian.
• Trilinos Release 10: September 2008.
• Trilinos Awards:
– 2004 R&D 100 Award.
– SC2004 HPC Software Challenge Award.
– Sandia Team Employee Recognition Award.
– Lockheed-Martin Nova Award Nominee.
• More information:– http://trilinos.sandia.gov
• 7th Annual Trilinos User Group Meeting in November 2009 @ SNL
– talks available for download
Computational mathematics and algorithms
Trilinos Contributors
Chris BakerDeveloper of Anasazi, RBGen, Tpetra
Ross BartlettLead Developer of Thyra and StratimikosDeveloper of Rythmos
Pavel BochevProject Lead and Developer of Intrepid
Paul BoggsDeveloper of Thyra
Eric BomanLead Developer of IsorropiaDeveloper of Zoltan
Todd CoffeyLead Developer of Rythmos
David DayDeveloper of Komplex and Intrepid
Karen DevineLead Developer of Zoltan
Clark DohrmannDeveloper of CLAPS
Michael GeeDeveloper of ML, NOX
Bob HeaphyLead Developer of Trilinos SQA
Mike HerouxTrilinos Project LeaderLead Developer of Epetra, AztecOO,Kokkos, Komplex, IFPACK, Thyra, TpetraDeveloper of Amesos, Belos, EpetraExt,Jpetra
Ulrich HetmaniukDeveloper of Anasazi
Robert Hoekstra Lead Developer of EpetraExtDeveloper of Epetra, Thyra, Tpetra
Russell HooperDeveloper of NOX
Vicki Howle Lead Developer of MerosDeveloper of Belos and Thyra
Jonathan Hu Developer of ML
Sarah KnepperDeveloper of Komplex
Tammy Kolda Lead Developer of NOX
Joe KotulskiLead Developer of Pliris
Rich Lehoucq Developer of Anasazi and Belos
Kevin Long Lead Developer of Thyra, Developer of Teuchos
Roger Pawlowski Lead Developer of NOX
Eric Phipps Developer of LOCA, NOX, and Sacado
Denis RidzalLead Developer of Aristos and Intrepid
Marzio SalaLead Developer of Didasko and IFPACKDeveloper of ML, Amesos
Andrew Salinger Lead Developer of LOCA
Paul Sexton Developer of Epetra and Tpetra
Bill SpotzLead Developer of PyTrilinosDeveloper of Epetra, New_Package
Ken Stanley Lead Developer of Amesos and New_Package
Heidi Thornquist Lead Developer of Anasazi, Belos, RBGen, and Teuchos
Ray Tuminaro Lead Developer of ML and Meros
Jim Willenbring Developer of Epetra and New_Package. Trilinos library manager
Alan Williams Lead Developer of Isorropia Developer of Epetra, EpetraExt, AztecOO, Tpetra
Computational mathematics and algorithms
Motivation For Intrepid (looks familiar…)
• Sandia does LOTS of numerical PDEs work.
• 10 years ago …
– MPSalsa was first-of-its kind massively parallel FEM code for chemicallyreacting flows: stabilized Q1-Q1 formulation (hardwired), spurred theAztec solver
– Many other code development efforts: FEM: Alegra (shock-hydro), FV:Premo,...
– New projects for FEM/FV/FD codes were underway or planned incompressible flows, solids, fluids, combustion, e.g., Sierra framework
• The challenges:
– Improve coordination to:
• Efficiently reuse existing discretization technology.
• Leverage new development across various projects.
• Support discretization software processes.
• Provide consistent discretization APIs for applications using FEM, FV or FD.
– Meeting ASC software quality assurance/engineering (SQA/SQE)requirements
Computational mathematics and algorithms
Intrepid
INteroperable Tools for Rapid dEveloPment of compatIble Discretizations
A Trilinos package for compatible discretizations:
! Limited release as Trilinos 9.0 package in 2008
! Full release with Trilinos 10.0 in 2009 of the “expert” FEM interface
! Up to order 10 H(grad), H(curl) and H(div) FE bases on Quad,
Triangle,Tetrahedron, Hexahedron, and Wedge cell topologies
! High quality cubature, e.g., positive weights only on Tri and Tet cells
When fully deployed (~2011) will provide
! support for hybrid discretizations (FEM, FV and FD)
! support for FV and FD on polygons and polyhedra
! optimized multi-core kernels
! optimized assembly (R. Kirby)
! Access to FEM, FV and FD methods using a common “user friendly” API
Developers: P. Bochev, D. Ridzal, K. Peterson, R. Kirby
http://trilinos.sandia.gov/packages/intrepid/
Computational mathematics and algorithms
Why Focus on Compatible Discretizations?
Ck
Direct - FV/D
"k
Forms (fields)
{C0,C1,C2,C3}
Chains
{C0,C1,C2,C3}
Cochains
!
R "( ) = "# jdxCi
$
!
I
!Domain
{Ci}Pullback - FEM
Recall: all discrete structures in our mimetic framework are induced by 2 basic operations
Reduction
Reconstruction
d,d*,!,#,(,)
Operations
D,D*,W,M
Discrete ops.
Nodes,edges,faces, cells
Matrices
natural
derived!
" h
Structure-preserving
translation
Analytic
!
˙ E +"#1$ %µ#1
$ %E = 0
!
M1e1+D
1
*D1e1
= f
Discrete
Algebraicsystem
Information loss controlled
Because they mitigate information loss inherent to discretization!
Value
Circulation
Flux…
Computational mathematics and algorithms
Reconstruction
Cell Data
Reduction
Direct: FV/DPullback: FEM
Higher order General cells
FEM, FV and FD methods are defined by choosing a specific reconstruction operator I:
Direct: I is low order, easily extendable to arbitrary cells
Pullback: I is defined on standard cells, easily extendable to high orders
Mimetic framework guides the software design for compatible discretizations:
! common API provides simultaneous access to FEM, FV and FD methods
! supports hybrid discretizations (FEM, FV and FD) on unstructured grids
"k
Forms
d,d*,!,#,(,)
Operations
{C0,C1,C2,C3}
Discrete forms
D,D*,W,MDiscrete ops.
Mapping Math to Software Design
Computational mathematics and algorithms
Current Status of Intrepid
• Cell topology– Topology type (base vs. extended), cell type (standard = has reference cell vs. non-
standard), adjacency queries, permutations,…
• Cell geometry
– Jacobians, maps to and from reference cells (if applicable), surface normal, line
tangent, subcell measure,…
• Cell integration– cubature points on standard cells, direct integration on non-standard cells
• Discrete spaces on a cell workset
– Definition of finite dimensional approximation spaces, reconstruction (interpolation)
operators, transformation rules,…
• Discrete operators on a cell workset– Basic differential operators acting on scalar, vector and tensor fields
• Discrete functionals on a cell workset
– Basic linear functionals acting on scalar, vector and tensor fields
• Utilities
– Everything else you may need but that does not fit in neither one of the above
categories
Released with Trilinos 10.0: a suite of “mathematical” (stateless) tools for
Computational mathematics and algorithms
Mapping Functionality to Software
Cell Topology
Cell Integration
Cell Geometry
Discrete Spaces
Discrete Operators
Discrete Functionals
Utilities
CellTools
Basis
FunctionSpaceTools
ArrayTools
RealSpaceTools
FieldContainer
Polylib
Integration
src/Cell
src/Discretization
src/Shared
Shards::CellTopology
Computational mathematics and algorithms
Finding Your Way Around
intrepid
src
example
test
doc
Shared
Discretization
CellBasis
FunctionSpaceTools
Integration
HGRAD_KeyHCURL_KeyHDIV_KeyHVOL_KeyHGRAD_Vector_KeyHGRAD_Tensor_Key… … … BasisFactory
CubatureDirectCubatureGenSparseCubatureSparseCubatureTensor… … … CubatureFactory
ArrayToolsFieldContainerPolylibRealSpaceToolsTypesUtils
Computational mathematics and algorithms
The Basis Nomenclature
name = Space + Cell Name + Discrete Space + Order + Basis Type
TRITETQUADHEXWEDGEPYRAMID
C(omplete)I(ncomplete)B(roken)
123…
FEMFEM_FIATFEM_HIERARCHICALFVDFVD_COVOLUME…
Example
HGRAD_QUAD_C1_FEM
HCURL_HEX_I1_FEM
HCURL_HEX_C1_FEM
HGRAD_TRI_C1_FEM Linear (C1) Lagrange elements on Triangles
Biinear (C1) Lagrange elements on a Quad
Lowest-order Nedelec element of the 1st kind (I1) on a Hex
Lowest-order Nedelec element of the 2nd kind (C1) on a Hex
HGRADHCURLHDIVHVOLHGRADVECHGRADTEN
Computational mathematics and algorithms
Basic Principles
• Multi-indexed Scalar value is the “only” data type in Intrepid. Implemented as multi-
dimensional array (MDA): contiguous data layout with multi-index access.
• Intrepid methods are templated on Scalar and one or more Array types
• Users can retain their data arrays as long as they provide minimal interface
– My_array.rank()
– My_array.dimension(dim_i)
– My_array.size()
– My_array(i),…, My_array(i,j,k,l,m)
– My_array[i]
• Intrepid provides its own implementation of a runtime, lexicographical multi-
dimensional array FieldContainer:
– similar to std::vector but with multi-index access and “view” option
– Can be resized at runtime
– Can be re-shaped at runtime
• Shards provides compile time MD Arrays using template meta-programming, for
both lexicographical and “FORTRAN” style arrays.
Uses simple data structures!
const and non-const}
Computational mathematics and algorithms
Multi-dimensional Array (MDA) Conventions
I/O arguments in Intrepid are typically of the following two kinds
• Data arrays: multi-indexed Scalar without a Field index
• Field arrays: multi-indexed Scalar with a Field index
MDA index notation used in Intrepid:
[0,N), [0,V)node and vertexn,v
[0,|Dk|)multiset (Dk operators)k
[0,P)pointp
[0,D)spatial coordinatei,j,d1,d2…
[0,R)right fieldr
[0,L)left fieldl
[0,F)fieldf
[0,C)cellc
rangeRefers toIndex
Multi-index examples:
(c,p)(c,p,f)(c,p,r,i)
(p,f)(p,l,i)(p,f,i,j)
(c,f,p,k)
Computational mathematics and algorithms
Multi-dimensional Arrays (cont’d)
(C,F,P,D,D)Tensor field
(C,F,P,D)Vector field
(C,F,P)Scalar field
containerrepresentsMulti-index field
!
ufi,ul
i,ur
i
!
uf ,ul ,ur
!
ufij,ul
ij,ur
ij
(C,P,D,D)Tensor data (full)
(C,P,D)Tensor data (diagonal)
(C,P,D)Vector data
(C,P)Scalar data
containerrepresentsMulti-index data
!
"
!
ai,b
i
!
Ki
!
Kij
!
diag(",K,")
Field arrays
Data arrays
Computational mathematics and algorithms
Some Examples
|-------------------------------------------------------------------------------------------------| | Rank and multi-dimensions of the output MD array in getValues methods | |--------------------|-------------------------|-------------------------|------------------------| |operator/field rank | rank 0 | rank 1 2D/3D | rank 2 2D/3D | |--------------------|-------------------------|-------------------------|------------------------| | VALUE | (F,P) | (F,P,D) | (F,P,D,D) | |--------------------|-------------------------|-------------------------|------------------------| | GRAD, D1 | (F,P,D) | (F,P,D,D) | (F,P,D,D,D) | |--------------------|-------------------------|-------------------------|------------------------| | CURL | (F,P,D) (undef. in 3D) | (F,P)/(F,P,D) | (F,P,D)/(F,P,D,D) | |--------------------|-------------------------|-------------------------|------------------------| | DIV | (F,P,D) (only in 1D) | (F,P) | (F,P,D) | |--------------------|-------------------------|-------------------------|------------------------| | D1,D2,..,D10 | (F,P,K) | (F,P,D,K) | (F,P,D,D,K) | |-------------------------------------------------------------------------------------------------|
Array types returned by getValues method of the Basis class
template<class ArrayScalar>
static void setJacobian(ArrayScalar& jacobian, $ (C,P,D,D) or (P,D,D)
const ArrayScalar& points, $ (P,D)
const ArrayScalar& nodes, $ (C,N,D)
const shards::CellTopology& cellTopo,
const int& whichCell = -1);
Jacobian computation by CellTools methods:
Computational mathematics and algorithms
Working With all Types of Finite Element
Spaces is Very Easy!
• Implementation follows the canonical Ciarlet definition:
– Finite element =
• " - element or cell
• P - discrete space, not necessarily polynomial
• # - set of unisolvent DoF (linear functionals P$ R)
– is defined by pullback from
! Basis is defined on a reference cell and is dual to a DoF set
! Basis on a physical cell is defined by pullback
! Require cell topology with a reference cell
!
ˆ " , ˆ P , ˆ # { }
!
"*
: ˆ P ( ˆ # )$ P(#)
!
",P,#{ }
!
",P,#{ }
Computational mathematics and algorithms
Reference Cell Basis Example
=================================================================================================== | | degree-of-freedom-tag table | | | DoF |----------------------------------------------------------| DoF definition | | ordinal | subc dim | subc ordinal | subc DoF ord |subc num DoF | | |=========|==============|==============|==============|=============|============================| | 0 | 1 | 0 | 0 | 1 | L_0(u) = (u.t)(0.5,0,0) | |---------|--------------|--------------|--------------|-------------|----------------------------| | 1 | 1 | 1 | 0 | 1 | L_1(u) = (u.t)(0.5,0.5,0) | |---------|--------------|--------------|--------------|-------------|----------------------------| | 2 | 1 | 2 | 0 | 1 | L_2(u) = (u.t)(0,0.5,0) | |---------|--------------|--------------|--------------|-------------|----------------------------| | 3 | 1 | 3 | 0 | 1 | L_3(u) = (u.t)(0,0,0.5) | |---------|--------------|--------------|--------------|-------------|----------------------------| | 4 | 1 | 4 | 0 | 1 | L_4(u) = (u.t)(0.5,0,0.5) | |---------|--------------|--------------|--------------|-------------|----------------------------| | 5 | 1 | 5 | 0 | 1 | L_5(u) = (u.t)(0,0.5,0.5) | |=========|==============|==============|==============|=============|============================| | MAX | maxScDim=1 | maxScOrd=5 | maxDfOrd=0 | - | | |=========|==============|==============|==============|=============|============================|
template<class Scalar, class ArrayScalar>
class Basis_HCURL_TET_I1_FEM : public Basis<Scalar, ArrayScalar>
What kind of basis is this?
Every basis function and its dual DoF functional are assigned a
• Unique DoF ordinal
• Unique 4-field DoF tag that associates the DoF with a subcell
Computational mathematics and algorithms
Pullback Definitions
!
"G
*: G( ˆ # )$G(#) "
G
*( ˆ u ) = ˆ u o F#
%1
"C
*: C( ˆ # )$C(#) "
C
*( ˆ u ) = DF#
%T& ˆ u ( ) o F#
%1
"D
*: D( ˆ # )$D(#) "
D
*( ˆ u ) = J#
%1DF# & ˆ u ( ) o F#
%1
"V
*:V ( ˆ # )$V (#) "
V
*( ˆ u ) = J#
%1 ˆ u ( ) o F#
%1
Why do I care? “Change of variables” that commutes with grad, curl and div
!
"#G
*( ˆ u ) =#
C
*( ˆ " ̂ u ) = DF$
%T& ( ˆ " ̂ u )( ) o F$
%1
" '#C
*( ˆ u ) =#
D
* ˆ " ' ˆ u ( ) = J$%1
DF$ & (ˆ " ' ˆ u )( ) o F$
%1
" &#D
*( ˆ u ) =#
V
* ˆ " & ˆ u ( ) = J$%1
( ˆ " & ˆ u )( ) o F$
%1
Basis basis values at ref. cell
CellTools pullback ingredients
FunctionSpaceTools application of pullback
Where do I find the pieces to put together finite element spaces?
!
ˆ u ( ˆ x p ), ˆ u ( ˆ x p ), ˆ d ̂ u ( ˆ x p )K
DF" ( ˆ x p ),J" ( ˆ x p )
u(F"
#1( ˆ x p )),u(F"
#1( ˆ x p )),du(F"
#1( ˆ x p ))
!
ˆ u " ˆ # ̂ u
$G
*% % $
C
*
u " #u
Grad
Curl
Div
Volume
- conforming
Computational mathematics and algorithms
Intrepid Example: Compatible LSFEM for
div-curl Systems
!
" #H = J in $
" %µH = 0 in $
n#H = 0 on &$
'
( )
* )
Magnetostatics is a div-curl system
H magnetic field intensity
B magnetic flux density
µ magnetic permeability
!
" #µ$1B = J in %
" &B = 0 in %
n &B = 0 on '%
(
) *
+ *
Diffusion is a div-curl system
!
" #u = 0 in $
" %u = g in $
n#u = 0 on &$
'
( )
* )
Div-curl systems are everywhere, but direct Galerkin methods lead to linear systems
that are hard to solve by iterative methods. Better systems can be obtained by LSFEM.
This (nontrivial) example builds an LSFEM code for div-curl systems
with tangential B.C.
!
" #u = 0$ u = %"p in &
n#u = 0$ p = 0 on '&
!
"#$ %$p = g in &
p = 0 on '&
( ) *
The incompressible Stokes equations are 2 coupled div-curl systems:
!
" #$ +"p = 0 in %
" &$ = 0 in %
n#$ = 0 on '%
(
) *
+ *
,
" #u =$ in %
" &u = 0 in %
n &u = 0 on '%
(
) *
+ *
% vorticity
u velocity
p pressure
Computational mathematics and algorithms
A continuous least-squares principle
!
J u;f,g( ) = " #u$ f0,% 2
2+ " &u$ g
0,% 3
2
X = H0curl,'( )(H div,'( )
)
* +
, +
!
minXJ u;f,g( )
A Least-Squares Principle
A model Div-Curl System
!
" #u = f in $
" %µu = g in $
n#u = 0 on &$
'
( )
* )
&'R3 ! bounded contractible domain
(& ! Lipschitz continuous
Norm-equivalence (Friedrichs Inequality)
!
uDC" C # $u
0,% 2
+ # &u0,% 3
( ) 'u( H0curl,)( )*H div,)( )
Lax-Milgram + norm-equivalence ! coercivity ! unique least-squares solution.
Moreover, that solution coincides with the solution of the original div-curl system.
Computational mathematics and algorithms
A straightforward conforming discrete least-squares principle
!
J uh;f,g( ) = " #uh $ f 0,% 2
2+ " &uh $ g 0,% 3
2
Xh ' H0curl,(( ))H div,(( )
*
+ ,
- ,
Xh
H1% H0(curl)
H0(curl)% H(div)
The trouble with this LSFEM
!
Xh" H
0curl,#( )$
Xh" H div,#( ) $
% & '
( '
Tangential continuity
Normal continuityC0 continuity
!
Xh" H
1#( )$H
0curl,#( )
!
"
!
"
Why is this bad?
Costabel (1991) shows that unless & has smooth boundary or is a
convex polyhedron, H1% H0(curl) may have
infinite co-dimension in H0(curl)%H(div)
! a C0 (nodal) finite element space may lose approximabilityproperty in H0(curl)%H(div), i.e., solution will not converge.
! Mixed methods can solve this, but we have another approach…
Why not Conforming LSFEM?
Computational mathematics and algorithms
Everybody knows how to define a weak divergence:
!
J uh;f,g( ) = " #uh $ f 0,% 2
2+ "h
* &uh $ g0,% 0
2
Xh ' H0curl,(( ))H div,(( )
*
+ ,
- ,
We gain some and loose some:
• curl-conforming FE: natural for the tangential boundary condition
• curl-conforming FE: not in the domain of div - need discrete approximation!
A remedy: Give up on being div-conforming and define “semi-conforming” LSFEM
!
Xh
=C0
h"1( ) is curl-conforming FE, e.g., Nedelec
!
"h
* #C0
h $1( )%G
0
h $0( ); ph ="h
* #uh & ph,qh( )0,$ 0
= ' uh ,"qh( )0,$1
(qh ) G0
h
Norm-equivalence of the semi-conforming LSFEM (Discrete Friedrichs Inequality)
!
uh D
*C" C # $u
h 0,% 2
+ #h
* &uh0,% 0
( ) 'uh( C
0
h
Error estimates
!
" # (u$uh)0
+ " %uh$"
h
*%u
h0& Ch
r" #u
r+ " %u
r( )
(effect of compatibility)
“Semi-Conforming” LSFEM
Computational mathematics and algorithms
!
" #uh ," # vh( )0,$ 2
+ "h
* %uh ,"h
* % vh( )0,$ 0
= f," # vh( )0,$ 2
+ g,"h
* % vh( )0,$ 0
&vh ' C0
h
curl-curl + grad-div matrices
!
K "2( ) +M
C"1( )DVE
MG
#1"0( )DVE
TM
C"1( ) = b
For clarity we now focus on the lowest-order case
Discrete least-squares problem
!
C0
h"1( )#
G0
h"0( )#
the lowest-order Nedelec space of the 1st kind
the lowest-order nodal C0 space
!
MC"1( )
!
MG"0( )
!
DVE
curl-conforming mass matrix
grad-conforming mass matrix
vertex-to-edge incidence matrix
where
! We already have an AMG solver for this system in Trilinos - a subsolver of the eddycurrent solver developed in Bochev, Hu, Tuminaro and Siefert, SISC 2008.
! The ML solver requires 4 matrices: , , , and
Note: Can use any O(h)
approximation for
We will use mass lumping.G
M
and
!
"0
= µ#1; "
1=1; "
0= µ
From Discretization to Linear System
!
MC"1( )
!
MG"0( )
!
DVE
!
K "2( )
!
"
# $
% $
Computational mathematics and algorithms
Using Intrepid to Assemble the System
Procedure
1. Set up: define cell, integration method (cubature), and reference cell basis
a. Choose cell type: Hexahedron<8> and generate grid (PAMGEN)
b. Define Cubature on reference cell and on a typical face (for B.C.)
c. Define & evaluate reference cell H(curl) basis: Basis_HCURL_HEX_I1_FEM
d. Define & evaluate reference cell H(grad) basis: Basis_HGRAD_HEX_C1_FEM
2. Set up: get transformation data
a. Define a physical cell workset
b. Define multi-dimensional arrays for cell data (FieldContainer<double>)
c. Get pullback data at cubature points (Jacobians, determinants, face area…)
d. Get basis signs (=edge permutations) for H(curl) basis
3. Assemble
a. Assemble the H(grad) mass matrix
b. Assemble the H(curl) mass matrix
c. Assemble the H(curl) stiffness matrix
d. Generate the incidence matrix
e. Assemble right-hand side
4. Solve: using ML
5. Have a beer or two
Computational mathematics and algorithms
Step 1: define cell, cubature, and basis
typedef shards::CellTopology CellTopology;
CellTopology hex_8(shards::getCellTopologyData<Hexahedron<8> >() );
int numNodesPerCell = hex_8.getNodeCount();
int numEdgesPerCell = hex_8.getEdgeCount();
int spaceDim = hex_8.getDimension();
Define Cell Topology with Shards
DefaultCubatureFactory<double> cubFactory;
int cubDegree = 2;
Teuchos::RCP<Cubature<double> > hexCub = cubFactory.create(hex_8, cubDegree);
int cubDim = hexCub->getDimension();
int numCubPoints = hexCub->getNumPoints();
FieldContainer<double> cubPoints(numCubPoints, cubDim);
FieldContainer<double> cubWeights(numCubPoints);
hexCub->getCubature(cubPoints, cubWeights);
Get Cubature Points and Weights
Computational mathematics and algorithms
Step 1: define cell, cubature, and basis
Basis_HCURL_HEX_I1_FEM<double, FieldContainer<double> > hexHCurlBasis;
Basis_HGRAD_HEX_C1_FEM<double, FieldContainer<double> > hexHGradBasis;
int numFieldsC = hexHCurlBasis.getCardinality();
int numFieldsG = hexHGradBasis.getCardinality();
Define Basis on reference cell
FieldContainer<double> hexGVals(numFieldsG, numCubPoints);
FieldContainer<double> hexCVals(numFieldsC, numCubPoints, spaceDim);
FieldContainer<double> hexCurls(numFieldsC, numCubPoints, spaceDim);
hexHGradBasis.getValues(hexGVals, cubPoints, OPERATOR_VALUE);
hexHCurlBasis.getValues(hexCVals, cubPoints, OPERATOR_VALUE);
hexHCurlBasis.getValues(hexCurls, cubPoints, OPERATOR_CURL);
Evaluate Basis at Cubature Points
Computational mathematics and algorithms
Step 2: pullback data: Jacobians
CellTools::setJacobian(hexJacobian, cubPoints, hexWorkset, hex_8);
CellTools::setJacobianInv(hexJacobInv, hexJacobian );
CellTools::setJacobianDet(hexJacobDet, hexJacobian );
Compute Jacobians of cell workset
FieldContainer<double> hexJacobian(numCells, numCubPoints, spaceDim, spaceDim);
FieldContainer<double> hexJacobInv(numCells, numCubPoints, spaceDim, spaceDim);
FieldContainer<double> hexJacobDet(numCells, numCubPoints);
Physical coordinates of cell nodes
Define physical cell workset
!
F : ˆ " #"
!
detDF
int numCells = 100;
FieldContainer<double> hexWorkset(numCells,
numNodesPerCell,
spaceDim);
…
!
DF
!
DF"1
!
ˆ "
!
"
// Intialize hexWorkset from mesh data
Computational mathematics and algorithms
Step 2: pullback data: H(curl) basis signs
Global (physical) cell
Local (reference) cell
+
+
-
-
Orientations Basis functions
!
ui "
=#i(" )$
*( ˆ u
i(" ))
!
ui "
L
= +#*( ˆ u
1)
!
ui "
R
= #$*( ˆ u
3)
0
1
2
3!
ˆ u 3
!
ˆ u 0
!
ˆ u 1
!
ˆ u 2
FieldContainer<double> hexBasisSigns(numCells, numFieldsC);
Computational mathematics and algorithms
Step 3: Assembly
!
MG( )ij
= "i(x)" j (x)dx#
$ = (%* ˆ " i)(x)(%* ˆ " j )(x)dxˆ #
$ = ˆ " i( ˆ x ) ˆ " j ( ˆ x )J( ˆ x )dˆ x #
$ & ˆ " i( ˆ x p ) ˆ " j ( ˆ x p )J( ˆ x p )' p
p=1
numPt
(
!
MC( )ij
= ui(x) "u j (x)dx#
$ = (%* ˆ u i)(x) " (%* ˆ u j )(x)dx#
$
= & i& j DF'T ˆ u i( ˆ x )( ) " DF
'T ˆ u j ( ˆ x )( )J( ˆ x )dˆ x ˆ #
$ ( & i& j DF'T ˆ u i( ˆ x p )( ) " DF
'T ˆ u j ( ˆ x p )( )J( ˆ x p )) p
p=1
numPt
*
!
KC( )ij
= " #ui(x) $ " #u j (x)dx%
& = '*( ˆ " # ˆ u i)( )(x) $ '*
( ˆ " # ˆ u j )( )(x)dx%
&
= ( i( j J)1
DF( ˆ " # ˆ u i)( ˆ x )( ) $ J)1
DF( ˆ " # ˆ u j )( ˆ x )( )J( ˆ x )dˆ x ˆ %
&
* ( i( j J)1
DF( ˆ " # ˆ u i)( ˆ x p )( ) $ J)1
DF( ˆ " # ˆ u j )( ˆ x p )( )J( ˆ x p )+ p
p=1
numPt
,
H(grad) mass matrix
H(curl) mass matrix
H(curl) stiffness matrix
Computational mathematics and algorithms
Generic Intrepid Assembly Procedure(symmetric operators)
!
A X( )ij
= Lui(x)Lu j (x)dx"
# = $ i$ j (%* ˆ L ̂ u i)(x)(%* ˆ L ̂ u j )(x)dx
"
# = $ i$ j T(DF) ˆ L ̂ u i( ˆ x )( ) T(DF) ˆ L ̂ u j ( ˆ x )( )J( ˆ x )dˆ x ˆ "
#
& $ i$ j T(DF( ˆ x p )) ˆ L ̂ u i( ˆ x p )( ) T(DF( ˆ x p )) ˆ L ̂ u j ( ˆ x p )( )J( ˆ x p )' p
p=1
numPt
(
!
" i" j T(DF( ˆ x p )) ˆ L ̂ u i( ˆ x p )( ) T(DF( ˆ x p )) ˆ L ̂ u j ( ˆ x p )( )J( ˆ x p )# p
p=1
numPt
$
!
ˆ L ̂ u j ( ˆ x p )
!
J( ˆ x p )" p
!
T(DF( ˆ x p )) ˆ L ̂ u j ( ˆ x p )
Basis$getValue
FST::applyTransform
FST::computeCellMeasure
FST::multiplyMeasure
FST::integrate
FST::applyL/RFieldSigns
!
T(DF( ˆ x p )) ˆ L ̂ u i( ˆ x p )( ) T(DF( ˆ x p )) ˆ L ̂ u j ( ˆ x p )( )J( ˆ x p )" p
p=1
numPt
#
!
T(DF( ˆ x p )) ˆ L ̂ u j ( ˆ x p )J( ˆ x p )" p
!
T(DF( ˆ x p )) ˆ L ̂ u j ( ˆ x p )
!
T(DF( ˆ x p )) ˆ L ̂ u j ( ˆ x p )J( ˆ x p )" p
Computational mathematics and algorithms
Step 3: declare arrays
// Containers for element HGRAD mass matrix
FieldContainer<double> massMatrixG(numCells, numFieldsG, numFieldsG);
FieldContainer<double> weightedMeasure(numCells, numCubPoints);
FieldContainer<double> weightedMeasureMuInv(numCells, numCubPoints);
FieldContainer<double> hexGValsTrans(numCells, numFieldsG, numCubPoints);
FieldContainer<double> hexGValsTransWeighted(numCells, numFieldsG, numCubPoints);
// Containers for element HCURL mass matrix
FieldContainer<double> massMatrixC(numCells, numFieldsC, numFieldsC);
FieldContainer<double> hexCValsTrans(numCells, numFieldsC, numCubPoints, spaceDim);
FieldContainer<double> hexCValsTransWeighted(numCells, numFieldsC, numCubPoints, spaceDim);
// Containers for element HCURL stiffness matrix
FieldContainer<double> stiffMatrixC(numCells, numFieldsC, numFieldsC);
FieldContainer<double> weightedMeasureMu(numCells, numCubPoints);
FieldContainer<double> hexCurlsTrans(numCells, numFieldsC, numCubPoints, spaceDim);
FieldContainer<double> hexCurlsTransWeighted(numCells, numFieldsC, numCubPoints, spaceDim);
// Global arrays in Epetra format
Epetra_FECrsMatrix MassG(Copy, globalMapG, numFieldsG);
Epetra_FECrsMatrix MassC(Copy, globalMapC, numFieldsC);
Epetra_FECrsMatrix StiffC(Copy, globalMapC, numFieldsC);
Epetra_FEVector rhsC(globalMapC);
Computational mathematics and algorithms
Step 3: Assemble H(grad) mass matrix
fst::HGRADtransformVALUE<double>(hexGValsTrans,
hexGVals);
Transform to
physical
coordinates
Compute
cell
measure
Multiply basis
and cell
measure
Integrate to
compute
element mass
matrix
fst::computeCellMeasure<double>(cellMeasure,
hexJacobDet,
cubWeights);
fst::multiplyMeasure<double>(hexGValsTransWeighted,
cellMeasure,
hexGValsTrans);
Note that for H(Grad) basis valuestransformation is formal - simplyreplicates values in rank-3 array
fst::integrate<double>(massMatrixG,
hexGValsTrans,
hexGValsTransWeighted,
COMP_BLAS);
!
MG( )ij" ˆ # i( ˆ x p ) ˆ # j ( ˆ x p )J( ˆ x p )$ p
p=1
numPt
%
!
ˆ " i( ˆ x p ) ˆ " j ( ˆ x p )J( ˆ x p )# p
p=1
numPt
$
!
ˆ " j ( ˆ x p )J( ˆ x p )# p
!
J( ˆ x p )" p
!
ˆ " i( ˆ x p )
!
" p
!
J( ˆ x p )
!
ˆ " i( ˆ x p )
!
J( ˆ x p )" p
!
ˆ " i( ˆ x p )
!
ˆ " i( ˆ x p )
!
ˆ " j ( ˆ x p )J( ˆ x p )# p
Computational mathematics and algorithms
Step 3: assemble H(curl) mass matrix
fst::HCURLtransformVALUE<double>(hexCValsTrans,
hexJacobInv,
hexCVals);
fst::multiplyMeasure<double>(hexCValsTransWeighted,
cellMeasure,
hexCValsTrans);
fst::integrate<double>(massMatrixC,
hexCValsTrans,
hexCValsTransWeighted,
COMP_BLAS);
!
J( ˆ x p )" p
fst::applyLeftFieldSigns<double>(massMatrixC,
hexBasisSigns);
fst::applyRightFieldSigns<double>(massMatrixC,
hexBasisSigns);
!
MC( )ij" # i# j DF
$T ˆ u i( ˆ x p )( ) % DF$T ˆ u j ( ˆ x p )( )J( ˆ x p )& p
p=1
numPt
'
!
DF"T
( ˆ x p )ˆ u i( ˆ x p )
!
DF"T
( ˆ x p )
!
ˆ u i( ˆ x p )
!
DF"T
( ˆ x p )ˆ u i( ˆ x p )!
DF"T
( ˆ x p )ˆ u i( ˆ x p )J( ˆ x p )# p
!
DF"T
( ˆ x p )ˆ u i( ˆ x p )J( ˆ x p )# p
!
DF"T
( ˆ x p )ˆ u i( ˆ x p )
!
DF"T ˆ u i( ˆ x p )( ) # DF
"T ˆ u j ( ˆ x p )( )J( ˆ x p )$ p
p=1
numPt
%
!
" i DF#T ˆ u i( ˆ x p )( ) $ DF
#T ˆ u j ( ˆ x p )( )J( ˆ x p )% p
p=1
numPt
&
!
" i" j DF#T ˆ u i( ˆ x p )( ) $ DF
#T ˆ u j ( ˆ x p )( )J( ˆ x p )% p
p=1
numPt
&
!
"i
!
" j
reuse $
Computational mathematics and algorithms
Step 3: assemble H(curl) stiffness matrix
fst::HCURLtransformCURL<double>(hexCurlsTrans,
hexJacob,
hexJacobianDet,
hexCVals);
fst::multiplyMeasure<double>(hexCurlsTransWght,
cellMeasure,
hexCurlsTrans);
fst::integrate<double>(stiffMatrixC,
hexCurlsTrans,
hexCurlsTransWght,
COMP_BLAS);
fst::applyLeftFieldSigns<double>(stiffMatrixC,
hexBasisSigns);
fst::applyRightFieldSigns<double>(stiffMatrixC,
hexBasisSigns);!
"i
!
" j
!
KC( )ij" # i# j J
$1DF( ˆ % & ˆ u i)( ˆ x p )( ) ' J
$1DF( ˆ % & ˆ u j )( ˆ x p )( )J( ˆ x p )( p
p=1
numPt
)
!
J"1
( ˆ x p )DF( ˆ x p )( ˆ # $ ˆ u j )( ˆ x p )
!
DF( ˆ x p )
!
J( ˆ x p )
!
( ˆ " # ˆ u j )( ˆ x p )
!
J( ˆ x p )" p
!
J"1
( ˆ x p )DF( ˆ x p )( ˆ # $ ˆ u j ( ˆ x p ))!
J"1
( ˆ x p )DF( ˆ x p )( ˆ # $ ˆ u j )( ˆ x p ) (J( ˆ x p )% p )
!
J"1
( ˆ x p )DF( ˆ x p )( ˆ # $ ˆ u j ( ˆ x p ))
!
J"1
( ˆ x p )DF( ˆ x p )( ˆ # $ ˆ u j )( ˆ x p ) (J( ˆ x p )% p )
!
J"1
DF( ˆ # $ ˆ u i)( ˆ x p )( ) % J"1
DF( ˆ # $ ˆ u j )( ˆ x p )( )J( ˆ x p )& p
p=1
numPt
'
!
" i J#1
DF( ˆ $ % ˆ u i)( ˆ x p )( ) & J#1
DF( ˆ $ % ˆ u j )( ˆ x p )( )J( ˆ x p )' p
p=1
numPt
(
!
" i" j J#1
DF( ˆ $ % ˆ u i)( ˆ x p )( ) & J#1
DF( ˆ $ % ˆ u j )( ˆ x p )( )J( ˆ x p )' p
p=1
numPt
(
reuse $
Computational mathematics and algorithms
Solve!
2D (x-y) projection of the 3D model
distorted mesh problem at the
coarsest grid resolution.
0.80930
0.98466
Order
1.55896
0.212596
40x40x16
2.73187
0.420695
20x20x810x10x4
4.89925H(curl)
0.89131L2
Mesh sizeError
3D Hex Mesh generated by PAMGEN (Trilinos package)
•Trilinos/packages/trilinoscouplings/examples/scaling
•Trilinos/packages/intrepid/example/DriversFurther examples:
L2 is optimal but H(curl) - suboptimal for non-affine Hex; see Falk et al. 2009
Computational mathematics and algorithms
" Trilinos is rapidly evolving into a powerful tool for parallel scientific computing
" Trilinos capabilities are organized in 7 areas::
– Frameworks and tool
– Software engineering technologies and integration
– Discretizations
– Meshes, geometry and load balancing
– Scalable linear algebra
– Linear and eigensolvers
– Embedded nonlinear analysis tools
" Intrepid is part of Trilinos and belongs in the discretization capability area
– A suite of tools for compatible discretizations
– Can be used in your code as an “element” library
– Can be used to develop new finite element codes
– Uses simple, yet powerful and efficient data structures (MD Array)
– Focus on correctness - extensive unit test suite
" Coming soon:
– Finite Volume and Finite difference functionality
– Polygons and polyhedra
– “user friendly” interface
Summary