DOLFIN User Manual - FEniCS Project

DOLFIN User Manual - FEniCS Project DOLFIN User Manual - FEniCS Project

fenicsproject.org
from fenicsproject.org More from this publisher
12.07.2015 Views

DOLFIN User ManualHoffman, Jansson, Logg, WellsIn general however, a discrete Function must be initialized from a givenVector, a Mesh and a FiniteElement:Vector x;Mesh mesh;FiniteElement element;Function f(x, mesh, element);5.2.2 Accessing discrete function dataIt is possible to access the data of a discrete Function, including the associatedVector, Mesh and FiniteElement:Vector& x= u.vector();Mesh& mesh= u.mesh();FiniteElement& element = u.element();5.2.3 Attaching discrete function dataAfter a discrete Function has been initialized, it is possible to associate orreassociate data with the Function:Vector x;Mesh mesh;FiniteElement element;Function f(x);f.attach(mesh);f.attach(element);38

DOLFIN User ManualHoffman, 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 User-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

<strong>DOLFIN</strong> <strong>User</strong> <strong>Manual</strong>Hoffman, Jansson, Logg, WellsIn general however, a discrete Function must be initialized from a givenVector, a Mesh and a FiniteElement:Vector x;Mesh mesh;FiniteElement element;Function f(x, mesh, element);5.2.2 Accessing discrete function dataIt is possible to access the data of a discrete Function, including the associatedVector, Mesh and FiniteElement:Vector& x= u.vector();Mesh& mesh= u.mesh();FiniteElement& element = u.element();5.2.3 Attaching discrete function dataAfter a discrete Function has been initialized, it is possible to associate orreassociate data with the Function:Vector x;Mesh mesh;FiniteElement element;Function f(x);f.attach(mesh);f.attach(element);38

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

Saved successfully!

Ooh no, something went wrong!