# Form¶

class dolfin.cpp.fem.Form(*args)

Base class for UFC code generated by FFC for DOLFIN with option -l.

A note on the order of trial and test spaces: FEniCS numbers argument spaces starting with the leading dimension of the corresponding tensor (matrix). In other words, the test space is numbered 0 and the trial space is numbered 1. However, in order to have a notation that agrees with most existing finite element literature, in particular

a = a(u, v)

the spaces are numbered from right to

a: V_1 x V_0 -> R

Note

Figure out how to write this in math mode without it getting messed up in the Python version.

This is reflected in the ordering of the spaces that should be supplied to generated subclasses. In particular, when a bilinear form is initialized, it should be initialized as

a(V_1, V_0) = ...


where V_1 is the trial space and V_0 is the test space. However, when a form is initialized by a list of argument spaces (the variable function_spaces in the constructors below, the list of spaces should start with space number 0 (the test space) and then space number 1 (the trial space).

• Form(rank, num_coefficients)

Create form of given rank with given number of coefficients

Arguments
rank (int)

The rank.

num_coefficients (int)

The number of coefficients.

• Form(ufc_form, function_spaces)

Create form (shared data)

Arguments
ufc_form (ufc::form)

The UFC form.

function_spaces (list of FunctionSpace)

Vector of function spaces.

cell_domains()

Return cell domains (zero pointer if no domains have been specified)

Returns
MeshFunction
The cell domains.
check()

Check function spaces and coefficients

coefficient()

• coefficient(i)

Return coefficient with given number

Arguments
i (int)

Index

Returns
GenericFunction

The coefficient.

• coefficient(name)

Return coefficient with given name

Arguments
name (str)

The name.

Returns
GenericFunction

The coefficient.

coefficient_name()

Return the name of the coefficient with this number

Arguments
i (int)
The number
Returns
str
The name of the coefficient with the given number.
coefficient_number()

Return the number of the coefficient with this name

Arguments
name (str)
The name.
Returns
int
The number of the coefficient with the given name.
coefficients()

Return all coefficients

Returns
list of GenericFunction
All coefficients.
coloring()

Return coloring type for colored (multi-threaded) assembly of form over a mesh entity of a given dimension

Arguments
entity_dim (int)
Dimension.
Returns
numpy.array(int)
Coloring type.
exterior_facet_domains()

Return exterior facet domains (zero pointer if no domains have been specified)

Returns
MeshFunction
The exterior facet domains.
function_space(i)

Return function space for given argument

Arguments
i (std::size_t)
Index
Returns
_FunctionSpace_
Function space shared pointer.
function_spaces()

Return function spaces for arguments

Returns
list of FunctionSpace
Vector of function space shared pointers.
interior_facet_domains()

Return interior facet domains (zero pointer if no domains have been specified)

Returns
MeshFunction
The interior facet domains.
mesh()

Extract common mesh from form

Returns
Mesh
Shared pointer to the mesh.
num_coefficients()

Return number of coefficients

Returns
int
The number of coefficients.
original_coefficient_position()

Return original coefficient position for each coefficient (0 <= i < n)

Returns
int
The position of coefficient i in original ufl form coefficients.
rank()

Return rank of form (bilinear form = 2, linear form = 1, functional = 0, etc)

Returns
int
The rank of the form.
set_cell_domains()

Set cell domains

Arguments
cell_domains (MeshFunction)
The cell domains.
set_coefficient()

• set_coefficient(i, coefficient)

Set coefficient with given number (shared pointer version)

Arguments
i (int)

The given number.

coefficient (GenericFunction)

The coefficient.

• set_coefficient(name, coefficient)

Set coefficient with given name (shared pointer version)

Arguments
name (str)

The name.

coefficient (GenericFunction)

The coefficient.

set_coefficients()

Set all coefficients in given map. All coefficients in the given map, which may contain only a subset of the coefficients of the form, will be set.

Arguments
coefficients (GenericFunction)
The map of coefficients.
set_exterior_facet_domains()

Set exterior facet domains

Arguments
exterior_facet_domains (MeshFunction)
The exterior facet domains.
set_interior_facet_domains()

Set interior facet domains

Arguments
interior_facet_domains (MeshFunction)
The interior facet domains.
set_mesh()

Set mesh, necessary for functionals when there are no function spaces

Arguments
mesh (Mesh)
The mesh.
set_some_coefficients()

Set some coefficients in given map. Each coefficient in the given map will be set, if the name of the coefficient matches the name of a coefficient in the form.

This is useful when reusing the same coefficient map for several forms, or when some part of the form has been outcommented (for testing) in the UFL file, which means that the coefficient and attaching it to the form does not need to be outcommented in a C++ program using code from the generated UFL file.

Arguments
coefficients (GenericFunction)
The map of coefficients.
set_vertex_domains()

Set vertex domains

Arguments
vertex_domains (MeshFunction)
The vertex domains.
thisown

The membership flag

ufc_form()

Return UFC form shared pointer

Returns
ufc::form
The UFC form.
vertex_domains()

Return vertex domains (zero pointer if no domains have been specified)

Returns
MeshFunction
The vertex domains.