FENICS Examples
Speaking as a frustrated amateur user, FENICS is plagued by skimpy
documentation, which is available online for multiple obsolescent
and incompatible versions. Moreover, numerous features of the language
appear and disappear with no notice. It is the wise programmer who
asserts "This FENICS code worked in 2013" since there seems to be
no guarantee that any FENICS code will be legal and correct for
any length of time. I have just given up on trying to understand
why 3D meshes suddenly can not be displayed with the Plot() command,
but this is an experience that is all too familiar to me when working
with FENICS.
-
annulus_flow,
a FENICS code which
simulates flow in an annulus, goverened by the time-dependent
Navier Stokes equations.
-
burgers_steady_viscous,
a FENICS code which
solves the steady viscous Burgers equation in 1D.
-
burgers_time_viscous,
a FENICS code which
solves the time-dependent viscous Burgers equation in 1D.
-
bvp,
FENICS codes which
solve two-point boundary value problems (BVP) in 1D.
-
convection_diffusion,
a FENICS code which
simulates a 1D convection diffusion problem.
-
convection_diffusion_stabilized,
a FENICS code which
simulates a 1D convection diffusion problem, using a stabilization scheme.
-
dg_advection_diffusion,
a FENICS code which
uses the Discontinuous Galerking (DG) method to set up and solve
an advection diffusion problem.
-
domain,
a FENICS code which
creates a region starting with a circle,
and then "subtracting" a rectangle and smaller circle.
-
dpg_bvp,
a FENICS code which
uses the Discontinuous Petrov Galerkin (DPG) method to solve
a boundary value problem over an interval,
by Jay Gopalakrishnan.
-
dpg_laplace,
a FENICS code which
uses the Discontinuous Petrov Galerkin (DPG) method to solve
a Poisson problem over the unit square,
by Jay Gopalakrishnan.
-
dpg_laplace_adapt,
a FENICS code which
uses the Discontinuous Petrov Galerkin (DPG) method to solve
a Poisson problem over the unit square, with adaptivity,
by Jay Gopalakrishnan.
-
ell,
a FENICS code which
solves the Poisson equation on the L-shaped region.
-
expression_test,
a FENICS code which
demonstrates some properties of the objects created by the
FEniCS Expression() function.
-
fenics_to_fem,
a FENICS code which
illustrate how a mesh or scalar function computed by a FENICS program
can be written to FEM files, which can then be used to create
images, or as input to meshing programs or other analysis tools.
-
fenics_to_txyv,
a FENICS code which
illustrates how a mesh or scalar function computed by a FENICS program
can be written to a triangulation file ("t.txt"), a coordinate
file ("xy.txt", and a value file ("v.txt").
-
fenics_to_txyz,
a FENICS code which
illustrates how a mesh or scalar function computed by a FENICS program
can be written to a triangulation file ("t.txt") and a coordinate
and value file ("xyz.txt").
-
glacier,
a FENICS code which
sets up the 2D steady Stokes equations
to model the movement of a glacier, by William Mitchell.
Sadly, this USED to work with a previous version of FENICS...
-
heat_explicit,
a FENICS code which
uses the finite element method to solve a version of the time dependent
heat equation over a rectangular region with a circular hole.
Time steps are handled using an explicit method.
-
heat_implicit,
a FENICS code which
uses the finite element method to solve a version of the time dependent
heat equation over a rectangular region with a circular hole.
Time steps are handled using an implicit solver.
-
heat_steady,
FENICS codes which
set up the 2D steady heat equation in a rectangle.
-
interpolant,
a FENICS code which
shows how to define a function in FENICS by supplying a mesh and
the function values at the nodes of that mesh, so that FENICS
works with the finite element interpolant of that data.
-
membrane,
a FENICS code which
models the deflection of a circular elastic
membrane subject to a perpendicular pressure modeled as a Gaussian
function.
-
mesh_test,
a FENICS code which
demonstrates some properties of the objects created
by the various FEniCS meshing functions.
-
meshes,
a FENICS code which
generates and plots the simple built-in mesh
types that FENICS provides.
-
nan_bug,
a FENICS code which
investigates a bug involving a NaN result.
-
navier_stokes_demo,
a FENICS code which
solves a simple Navier Stokes problem in the L-shaped domain.
-
neumann,
a FENICS code which
solves a boundary value problem in the unit square,
for which homogeneous Neumann conditions are imposed,
adapted from a program by Doug Arnold.
-
p_laplacian,
a FENICS code which
sets up and solves the nonlinear p-Laplacian PDE in the unit square.
-
poisson,
a FENICS code which
solves the Poisson equation on the unit square,
adapted from the FENICS tutorial by Langtangen and Logg.
-
poisson_mixed,
a FENICS code which
solves the Poisson equation using a mixed formulation.
-
poisson_nonlinear,
a FENICS code which
uses the finite element method to solve a version of the nonlinear
Poisson equation over the unit square.
-
poisson_source_symbolic,
a FENICS code which
shows how the symbolic package can be used to determine the
right hand side f(x,y) of a Poisson equation, given the desired exact
solution u(x,y).
-
quadrilateral,
a FENICS code which
solves the Poisson equation on the unit square,
using a quadrilateral mesh.
-
step1,
a FENICS code which
solves a Poisson equation with constant diffusivity kappa(x,y).
-
step2,
a FENICS code which
solves a Poisson equation with piecewise constant diffusivity kappa(x,y).
-
step3,
a FENICS code which
solves a Poisson equation with piecewise constant diffusivity kappa(x,y),
and computes and plots |grad(u)|.
-
step4,
a FENICS code which
shows how to generate the right hand side of a Poisson problem,
using the symbolic mathematics package and an exact solution formula.
-
step5,
a FENICS code which
solves a Poisson equation whose diffusivity kappa(x,y) is defined
as |grad(w)| for a given scalar field w(x,y).
-
step6,
a FENICS code which
solves the nonlinear p-Laplacian problem directly.
-
step7,
a FENICS code which
compares error norm and DPG error indicators for a Poisson problem.
-
step8,
a FENICS code which
uses DPG error indicators for adaptive mesh refinement.
-
step9,
a FENICS code which
uses the Discontinuous Petrov Galerkin (DPG) method to solve
a Poisson problem, and repeatedly refines the mesh, guided by
DPG error indicators. On each refinement step, the top fifty percent
of the cells are refined, as ordered by size of local error estimates.
It then plots the decay of the estimated error as a function of the
number of mesh elements.
-
step10,
a FENICS code which
uses the Discontinuous Petrov Galerkin (DPG) method to solve
a Poisson problem, and repeatedly refines the mesh, guided by
DPG error indicators. On each refinement step, cells are ordered by
size of the local error estimates, and then enough "top" cells are
refined to represent the proportion THETA of the total error estimate.
It then plots the decay of the estimated error as a function of the
number of mesh elements.
-
step11,
a FENICS code which
uses the Discontinuous Petrov Galerkin (DPG) method to solve
a Poisson problem, and repeatedly refines the mesh, guided by
DPG error indicators. Two methods of adaptive refinement are
compared, one of which refines cells which represent a fixed percentage
of the error (case 0), and one of which refines a fixed percentage
of the cells (case1). The problem uses a discontinuous diffusivity
function kappa(x,y).
-
tester,
a BASH code which runs the test programs.
Last revised on 29 April 2020.