A FEniCS Tutorial - FEniCS Project
A FEniCS Tutorial - FEniCS Project
A FEniCS Tutorial - FEniCS Project
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
A = assemble(a, exterior_facet_domains=boundary_parts)<br />
b = assemble(L, exterior_facet_domains=boundary_parts)<br />
Then essential boundary conditions are enforced, and the system can be solved<br />
in the usual way:<br />
for bc in bcs:<br />
bc.apply(A, b)<br />
u = Function(V)<br />
U = u.vector()<br />
solve(A, U, b)<br />
The complete code is in the dnr_p2D.py file in the stationary/poisson directory.<br />
6 More Examples<br />
Many more topics could be treated in a <strong>FEniCS</strong> tutorial, e.g., how to solve systems<br />
of PDEs, how to work with mixed finite element methods, how to create<br />
more complicated meshes and mark boundaries, and how to create more advanced<br />
visualizations. However, to limit the size of this tutorial, the examples<br />
end here. There are, fortunately, a rich set of <strong>FEniCS</strong> demos. The <strong>FEniCS</strong> documentation<br />
explains a collection of PDE solvers in detail: the Poisson equation,<br />
the mixed formulation for the Poission equation, the Biharmonic equation, the<br />
equations of hyperelasticity, the Cahn-Hilliard equation, and the incompressible<br />
Navier-Stokes equations. Both Python and C++ versions of these solvers<br />
are explained. An eigenvalue solver is also documented. In the dolfin/demo<br />
directory of the DOLFIN source code tree you can find programs for these and<br />
many other examples, including the advection-diffusion equation, the equations<br />
of elastodynamics, a reaction-diffusion equation, various finite element methods<br />
for the Stokes problem, discontinuous Galerkin methods for the Poisson and<br />
advection-diffusion equations, and an eigenvalue problem arising from electromagnetic<br />
waveguide problem with Nedelec elements. There are also numerous<br />
demos on how to apply various functionality in <strong>FEniCS</strong>, e.g., mesh refinement<br />
and error control, moving meshes (for ALE methods), computing functionals<br />
over subsets of the mesh (such as lift and drag on bodies in flow), and creating<br />
separate subdomain meshes from a parent mesh.<br />
Theprojectcbc.solve(https://launchpad.net/cbc.solve)offersmorecomplete<br />
PDE solvers for the Navier-Stokes equations, the equations of hyperelasticity,<br />
fluid-structure interaction, viscous mantle flow, and the bidomain<br />
model of electrophysiology. Most of these solvers are described in the ”<strong>FEniCS</strong><br />
book”[14](https://launchpad.net/fenics-book). Anotherproject,cbc.rans<br />
(https://launchpad.net/cbc.rans), offers an environment for very flexible<br />
and easy implementation of Navier-Stokes solvers and turbulence [20, 19]. For<br />
example, cbc.rans contains an elliptic relaxation model for turbulent flow involving<br />
18 nonlinear PDEs. <strong>FEniCS</strong> proved to be an ideal environment for<br />
implementing such complicated PDE models. The easy construction of systems<br />
81