12.07.2015 Views

DOLFIN User Manual - FEniCS Project

DOLFIN User Manual - FEniCS Project

DOLFIN User Manual - FEniCS Project

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>DOLFIN</strong> <strong>User</strong> <strong>Manual</strong>Hoffman, Jansson, Logg, WellsUsually, the FiniteElement is given by the BilinearForm defining the problem.Considering the Poisson example in Chapter 2, a Function u representingthe 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 forthe BilinearForm a.5.3 <strong>User</strong>-defined functionsIn the simplest case, a user-defined Function is just an expression in termsof the coordinates and is typically used for defining source terms and initialconditions. For example, a source term could be given byf = f(x, y, z) = xy sin(z/π). (5.2)There are two ways to create a user-defined Function; either by creatinga sub class of Function or by creating a Function from a given functionpointer.5.3.1 Creating a sub classA user-defined Function may be defined by creating a sub class of Functionand overloading the eval() function. The following example illustrates howto create a Function representing the function in (5.2):39

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!