Download DOLFIN User Manual

Transcript
DOLFIN User Manual
Hoffman, Jansson, Logg, Wells
Usually, the FiniteElement is given by the BilinearForm defining the problem. Considering the Poisson example in Chapter 2, a Function u representing the solution can be initialized as follows:
Vector x;
Mesh mesh;
Function f(x, mesh);
Poisson::BilinearForm a;
FiniteElement& element = a.trial();
f.attach(element);
In this example, the Function f represents a function in the trial space for
the BilinearForm a.
5.3
User-defined functions
In the simplest case, a user-defined Function is just an expression in terms
of the coordinates and is typically used for defining source terms and initial
conditions. For example, a source term could be given by
f = f (x, y, z) = xy sin(z/π).
(5.2)
There are two ways to create a user-defined Function; either by creating
a sub class of Function or by creating a Function from a given function
pointer.
5.3.1
Creating a sub class
A user-defined Function may be defined by creating a sub class of Function
and overloading the eval() function. The following example illustrates how
to create a Function representing the function in (5.2):
39