Você está na página 1de 9

Introduction to FEniCS

Noemi Petra

Institute for Computational Engineering and Sciences


The University of Texas at Austin

GEO 384F
Computational Methods for Geophysics
February 17, 2013

N. Petra (ICES, UT Austin) Intro to FEniCS February 17, 2013 1/9


What is FEniCS?

I FEniCS - is an acronym with FE representing Finite Element, CS


representing Computational Software, and according to Anders Logg,
a Senior Research Scientist with the FEniCS Project, “ni sits nicely in
the middle”. Andy Terrel also notes that the FEniCS software package
was originally compiled at the University of Chicago, whose mascot is
a phoenix, which likely inspired the name. (source: http://en.
wikiversity.org/wiki/Introduction_to_Python_for_FEniCS)

I The FEniCS Project is a collection of open-source software


components aimed at the numerical solution of partial differential
equations using finite element methods.
http://fenicsproject.org/

N. Petra (ICES, UT Austin) Intro to FEniCS February 17, 2013 2/9


FEniCS: a user friendly tool for solving PDEs

FEniCS has an extensive list of features for automated, efficient solution of


differential equations:
I Automated solution of variational problems
I Automated error control and adaptivity
I An extensive library of finite elements
I High performance linear algebra
I Postprocessing
I FEniCS can be used from both Python and C++
I Extensive documentation

N. Petra (ICES, UT Austin) Intro to FEniCS February 17, 2013 3/9


FEniCS software components
FEniCS is organized as a collection of interoperable components that
together form the FEniCS Project.

N. Petra (ICES, UT Austin) Intro to FEniCS February 17, 2013 4/9


Important/useful links
I FEniCS tutorial (Python):
http://fenicsproject.org/documentation/tutorial/
I You can download the FEniCS book from:
https://launchpadlibrarian.net/83776282/
fenics-book-2011-10-27-final.pdf
I The FEniCS Manual:
https://launchpadlibrarian.net/84116499/
fenics-manual-2011-10-31.pdf
I Examples:
http://fenicsproject.org/_static/tutorial/fenics_
tutorial_examples.tar.gz
I FEniCS presentations:
http://fenicsproject.org/pub/presentations/
I FEniCS course:
http://fenicsproject.org/pub/course/lectures/
N. Petra (ICES, UT Austin) Intro to FEniCS February 17, 2013 5/9
Important/useful links
I Documented DOLFIN demos (Python):
note: the demos are already installed on your system, see fo ex:
/Applications/FEniCS.app/Contents/Resources/share/
dolfin/demo
http://fenicsproject.org/documentation/dolfin/1.1.0/
python/demo/index.html
I Basic classes and functions in DOLFIN (Python):
http://fenicsproject.org/documentation/dolfin/1.1.0/
python/quick_reference.html
I All classes and functions in DOLFIN (Python):
http://fenicsproject.org/documentation/dolfin/1.1.0/
python/genindex.html
I Getting answers:
http://fenicsproject.org/support/
https://answers.launchpad.net/fenics
N. Petra (ICES, UT Austin) Intro to FEniCS February 17, 2013 6/9
Solving a boundary value problem with FEniCS

Solving a physical problem in FEniCS consists of the following steps:

1. identify the PDE and its boundary conditions;


2. reformulate the PDE problem as a variational problem;
3. write a Phyton program to:
I create geometry and mesh;
I code the formulas in the variational problem, along with definitions of
input data such as right hand sides, coefficients, boundary conditions;
3. solve the linear system to compute the fem solution;
4. output solution, compute derived quantities such as flux, etc.

N. Petra (ICES, UT Austin) Intro to FEniCS February 17, 2013 7/9


Boundary value problem
The boundary value problem that is to be solved has the form:

 
d du(x)
− k(x) + b(x)u(x) = f (x), in Ω
dx dx
u(x) = g(x), on Γ

Example: Poisson problem with constant coefficient k and homogenous


Dirichlet BCs:
I unknown: u(x)
I coefficients: k(x) = 1; b(x) = 0
I volume and boundary source terms: f (x) = 1; g(x) = 0
I domain and boundary: Ω = (0, 1); Γ = {0, 1}
I exact solution: u = 12 x(1 − x)

N. Petra (ICES, UT Austin) Intro to FEniCS February 17, 2013 8/9


Reformulate the PDE problem as a variational problem
1D Poisson problem

I Strong form:
−u00 = 1, in (0, 1)
u(0) = 0
u(1) = 0

I Variational (weak) form:


Z 1 Z 1
0 0
Find u ∈ V
|{z} such that u v dx = vdx ∀v ∈ |{z}
V
0 0 test space
trial space | {z } | {z }
:=a(u,v) :=f (v)

I Note: in higher dimmension u0 v 0 translates to ∇u · ∇v

N. Petra (ICES, UT Austin) Intro to FEniCS February 17, 2013 9/9

Você também pode gostar