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.
7.2 Overview of Objects and Functions<br />
Most classes in <strong>FEniCS</strong> have an explanation of the purpose and usage that can<br />
beseenbyusingthegeneraldocumentationcommandpydocforPythonobjects.<br />
You can type<br />
pydoc dolfin.X<br />
Terminal<br />
to look up documentation of a Python class X from the DOLFIN library (X<br />
can be UnitSquare, Function, Viper, etc.). Below is an overview of the most<br />
important classes and functions in <strong>FEniCS</strong> programs, in the order they typically<br />
appear within programs.<br />
UnitSquare(nx, ny): generate mesh over the unit square [0,1]×[0,1] using<br />
nx divisions in x direction and ny divisions in y direction. Each of the nx*ny<br />
squares are divided into two cells of triangular shape.<br />
UnitInterval, UnitCube, UnitCircle, UnitSphere, Interval, Rectangle,<br />
and Box: generate mesh over domains of simple geometric shape, see Section 4.<br />
FunctionSpace(mesh, element_type, degree): a function space defined<br />
over a mesh, with a given element type (e.g., ’Lagrange’ or ’DG’), with basis<br />
functions as polynomials of a specified degree.<br />
Expression(formula, p1=v1, p2=v2, ...): ascalar-orvector-valuedfunction,<br />
given as a mathematical expression formula (string) written in C++ syntax.<br />
The spatial coordinates in the expression are named x[0], x[1], and x[2],<br />
while time and other physical parameters can be represented as symbols p1,<br />
p2, etc., with corresponding values v1, v2, etc., initialized through keyword arguments.<br />
These parameters become attributes, whose values can be modified<br />
when desired.<br />
Function(V): a scalar- or vector-valued finite element field in the function<br />
space V. If V is a FunctionSpace object, Function(V) becomes a scalar field,<br />
and with V as a VectorFunctionSpace object, Function(V) becomes a vector<br />
field.<br />
SubDomain: class for defining a subdomain, either a part of the boundary,<br />
an internal boundary, or a part of the domain. The programmer must subclass<br />
SubDomain and implement the inside(self, x, on_boundary) function (see<br />
Section 1.3) for telling whether a point x is inside the subdomain or not.<br />
Mesh: classforrepresentingafiniteelementmesh, consistingofcells, vertices,<br />
and optionally faces, edges, and facets.<br />
MeshFunction: tool for marking parts of the domain or the boundary. Used<br />
for variable coefficients (”material properties”, see Section 5.1) or for boundary<br />
conditions (see Section 5.3).<br />
DirichletBC(V, value, where): specificationofDirichlet(essential)boundary<br />
conditions via a function space V, a function value(x) for computing the<br />
value of the condition at a point x, and a specification where of the boundary,<br />
either as a SubDomain subclass instance, a plain function, or as a MeshFunction<br />
83