# Expression¶

class dolfin.cpp.function.Expression(*args)

This class represents a user-defined expression. Expressions can be used as coefficients in variational forms or interpolated into finite element spaces.

An expression is defined by overloading the eval() method. Users may choose to overload either a simple version of eval(), in the case of expressions only depending on the coordinate x, or an optional version for expressions depending on x and mesh data like cell indices or facet normals.

The geometric dimension (the size of x) and the value rank and dimensions of an expression must supplied as arguments to the constructor.

• Expression()

Create scalar expression.

• Expression(dim)

Create vector-valued expression with given dimension.

Arguments
dim (int)

Dimension of the vector-valued expression.

• Expression(dim0, dim1)

Create matrix-valued expression with given dimensions.

Arguments
dim0 (int)

Dimension (rows).

dim1 (int)

Dimension (columns).

• Expression(value_shape)

Create tensor-valued expression with given shape.

Arguments
value_shape (numpy.array(int))

Shape of expression.

• Expression(expression)

Copy constructor

Arguments
expression (Expression)

Object to be copied.

eval()

• eval(values, x, cell)

Note: The reimplementation of eval is needed for the Python interface. Evaluate at given point in given cell.

Arguments
values (numpy.array(float))

The values at the point.

x (numpy.array(float))

The coordinates of the point.

cell (ufc::cell)

The cell which contains the given point.

• eval(values, x)

Evaluate at given point.

Arguments
values (numpy.array(float))

The values at the point.

x (numpy.array(float))

The coordinates of the point.

eval_cell()

• eval(values, x, cell)

Note: The reimplementation of eval is needed for the Python interface. Evaluate at given point in given cell.

Arguments
values (numpy.array(float))

The values at the point.

x (numpy.array(float))

The coordinates of the point.

cell (ufc::cell)

The cell which contains the given point.

• eval(values, x)

Evaluate at given point.

Arguments
values (numpy.array(float))

The values at the point.

x (numpy.array(float))

The coordinates of the point.

thisown

The membership flag