dolfin.function

Collection of functions and function spaces

Functions

TensorFunctionSpace(mesh, element[, shape, …])

Create tensor finite element (composition of scalar elements) function space.

VectorFunctionSpace(mesh, element[, dim, …])

Create vector finite element (composition of scalar elements) function space.

Classes

Constant(domain, c)

A constant with respect to a domain.

ElementMetaData

Data for representing a finite element

Function(V[, x, name])

A finite element function that is represented by a function space (domain, element and dofmap) and a vector holding the degrees-of-freedom

FunctionSpace(mesh, element[, cppV])

A space on which Functions (fields) can be defined.

class dolfin.function.Constant(domain, c: Union[numpy.ndarray, Sequence, float])[source]

Bases: ufl.constant.Constant

A constant with respect to a domain.

Parameters
  • domain (DOLFIN or UFL mesh) –

  • c – Value of the constant.

property value

Returns value of the constant.

class dolfin.function.ElementMetaData[source]

Bases: tuple

Data for representing a finite element

Create new instance of ElementMetaData(family, degree, form_degree)

property degree

Alias for field number 1

property family

Alias for field number 0

property form_degree

Alias for field number 2

class dolfin.function.Function(V: dolfin.function.FunctionSpace, x: Optional[petsc4py.PETSc.Vec] = None, name: Optional[str] = None)[source]

Bases: ufl.coefficient.Coefficient

A finite element function that is represented by a function space (domain, element and dofmap) and a vector holding the degrees-of-freedom

Initialize finite element Function.

copy()[source]

Return a copy of the Function. The FunctionSpace is shared and the degree-of-freedom vector is copied.

eval(x: numpy.ndarray, cells: numpy.ndarray, u=None) → numpy.ndarray[source]

Evaluate Function at points x, where x has shape (num_points, 3), and cells has shape (num_points,) and cell[i] is the index of the cell containing point x[i]. If the cell index is negative the point is ignored.

property function_space

Return the FunctionSpace

property id

Return object id index.

interpolate(u) → None[source]

Interpolate an expression

property name

Name of the Function.

split()[source]

Extract any sub functions.

A sub function can be extracted from a discrete function that is in a mixed, vector, or tensor FunctionSpace. The sub function resides in the subspace of the mixed space.

sub(i: int)[source]

Return a sub function.

The sub functions are numbered from i = 0..N-1, where N is the total number of sub spaces.

ufl_evaluate(x, component, derivatives)[source]

Function used by ufl to evaluate the Expression

property vector

Return the vector holding Function degrees-of-freedom.

class dolfin.function.FunctionSpace(mesh: dolfin.cpp.mesh.Mesh, element: Union[ufl.finiteelement.finiteelementbase.FiniteElementBase, dolfin.function.ElementMetaData], cppV: Optional[dolfin.cpp.function.FunctionSpace] = None)[source]

Bases: ufl.functionspace.FunctionSpace

A space on which Functions (fields) can be defined.

Create a finite element function space.

clone() → dolfin.function.FunctionSpace[source]

Return a new FunctionSpace \(W\) which shares data with this FunctionSpace \(V\), but with a different unique integer ID.

This function is helpful for defining mixed problems and using blocked linear algebra. For example, a matrix block defined on the spaces \(V \times W\) where, \(V\) and \(W\) are defined on the same finite element and mesh can be identified as an off-diagonal block whereas the \(V \times V\) and \(V \times V\) matrices can be identified as diagonal blocks. This is relevant for the handling of boundary conditions.

collapse(collapsed_dofs: bool = False)[source]
Collapse a subspace and return a new function space and a map from

new to old dofs.

Arguments
collapsed_dofs

Return the map from new to old dofs

Returns
FunctionSpace

The new function space.

dict

The map from new to old dofs (optional)

component()[source]

Return the component relative to the parent space.

contains(V) → bool[source]

Check whether a FunctionSpace is in this FunctionSpace, or is the same as this FunctionSpace.

property dofmap

Return the degree-of-freedom map associated with the function space.

dolfin_element()[source]

Return the DOLFIN element.

property id

The unique identifier

property mesh

Return the mesh on which the function space is defined.

num_sub_spaces() → int[source]

Return the number of sub spaces.

sub(i: int) → dolfin.function.FunctionSpace[source]

Return the i-th sub space.

ufl_function_space() → ufl.functionspace.FunctionSpace[source]

Return the UFL function space

dolfin.function.TensorFunctionSpace(mesh: dolfin.cpp.mesh.Mesh, element: dolfin.function.ElementMetaData, shape=None, symmetry: bool = None, restriction=None) → dolfin.function.FunctionSpace[source]

Create tensor finite element (composition of scalar elements) function space.

dolfin.function.VectorFunctionSpace(mesh: dolfin.cpp.mesh.Mesh, element: dolfin.function.ElementMetaData, dim=None, restriction=None) → dolfin.function.FunctionSpace[source]

Create vector finite element (composition of scalar elements) function space.