FEM example in Python
M. M. Sussman
sussmanm@math.pitt.edu
Ofce Hours: 11:10AM-12:10PM, Thack 622
May 12 June 19, 2014
1 / 45
Topics
Introduction
Code
Verify and run
2 / 45
Purpose
Practice with Python
Illustrate FEM in 1D in detail
Coding strategies
3 /
FEniCS: Discontinuous Galerkin Example
M. M. Sussman
sussmanm@math.pitt.edu
Ofce Hours: 11:10AM-12:10PM, Thack 622
May 12 June 19, 2014
1/8
Discontinuous Galerkin Methods
Beatrice Riviere, Discontinuous Galerkin Methods for Solving
Elliptic and Parabolic
FEniCS, part IV: Generating a model
M. M. Sussman
sussmanm@math.pitt.edu
Ofce Hours: 11:10AM-12:10PM, Thack 622
May 12 June 19, 2014
1 / 54
Topics
Vortex shedding
Background
Implementation
2 / 54
Topics
Vortex shedding
Background
Implementation
3 / 54
von
1
Python language exercises
1. (5 points) Consider the following expression, intended to print the square
root of 16:
pow(16,(1/2)
What is the result of this expression? How should it be changed, still
using pow, to yield the correct answer?
2. (5 points)
Math 3040 Wrapup
M. M. Sussman
sussmanm@math.pitt.edu
Ofce Hours: 11:10AM-12:10PM, Thack 622
June 19, 2014
1/9
Course topics
1. Background and basics
2. FEM1D.py
3. FEniCS
4. FreeFem+
2/9
Background and basics
VirtualBox and VMs
Spyder and Python language
Introduction to the nite element method
M. M. Sussman
sussmanm@math.pitt.edu
Ofce Hours: 11:10AM-12:10PM, Thack 622
May 12 June 19, 2014
1 / 34
Resources
Strang, G., Fix, G., An Analysis of the Finite Element Method 2nd
Edition, Wellesley-Cambridge Press,
Exercises on numpy, scipy, and
matplotlib
1
Exercise 7: Numpy practice (5 points)
Start up Python (best to use Spyder) and use it to answer the following questions. Use the following imports:
import numpy as np
import scipy.linalg as la
import matplotlib.
FreeFem+, part IV
M. M. Sussman
sussmanm@math.pitt.edu
Ofce Hours: 11:10AM-12:10PM, Thack 622
May 12 June 19, 2014
1 / 41
Topics
3D
TetGen
Layer meshes
Mesh adaptation
2 / 41
Topics
3D
TetGen
Layer meshes
Mesh adaptation
3 / 41
Using TetGen inside FreeFem
FEniCS, part II
M. M. Sussman
sussmanm@math.pitt.edu
Ofce Hours: 11:10AM-12:10PM, Thack 622
May 12 June 19, 2014
1 / 56
Topics
Parameters
Projections and spaces
MeshFunctions and SubDomains
Parallel execution
2 / 56
FEniCS parameters
Parameters in a hiera
Math 3040: Topics in Scientic Computing
Introduction to nite element simulations
using FEniCS and FreeFem+
M. M. Sussman
sussmanm@math.pitt.edu
Ofce Hours: 11:10AM-12:10PM, Thack 622
May 12, 2014
1 / 35
Topics
Introduction
Course topics
An example
The sof
Math 3040: Introduction to Python
M. M. Sussman
sussmanm@math.pitt.edu
Ofce Hours: M-Th 11:10-12:10, Thack 622
May 12, 2014
1 / 32
Contents
Introduction to Python
Running python
File structure and line syntax
Python language syntax
Classes and inheritance
Resources
M. Scott Shell,
http:/www.engr.ucsb.edu/%7eshell/che210d/numpy.pdf
http:/wiki.scipy.org/NumPy_for_Matlab_Users
http:/mathesaurus.sourceforge.net/matlab-numpy.html
1 / 12
Numpy arrays
import numpy as np
Numpy provides class ndarray, called array
FEniCS, part III
M. M. Sussman
sussmanm@math.pitt.edu
Ofce Hours: 11:10AM-12:10PM, Thack 622
May 12 June 19, 2014
1 / 67
Topics
Geometry
Elements
Nonlinear problems
Transient problems
Eigenvalue problems
2 / 67
How do I generate complicated meshes?
UnitIn
FEniCS, part I
M. M. Sussman
sussmanm@math.pitt.edu
Ofce Hours: 11:10AM-12:10PM, Thack 622
May 12 June 19, 2014
1 / 79
Topics
Introduction
Tutorial examples
Solvers and preconditioners
Direct solvers
Conjugate Gradients
Parallel computing
Preconditioning
FreeFem+, part III
M. M. Sussman
sussmanm@math.pitt.edu
Ofce Hours: 11:10AM-12:10PM, Thack 622
May 12 June 19, 2014
1 / 76
Topics
Exercise 21 discussion
Elements
Tutorial examples from Chapter 3
Section 3.10 Newtons method for NSE
MPI and Schwarz method
N
FreeFem+, part I
M. M. Sussman
sussmanm@math.pitt.edu
Ofce Hours: 11:10AM-12:10PM, Thack 622
May 12 June 19, 2014
1 / 76
Topics
Example 18
Continuous Equations
Mesh
Weak form
Convect
Timesteps
Example 19
Syntax from Chapter 4
Tutorial examples from Chapte