ffc.tensor package


ffc.tensor.costestimation module

ffc.tensor.costestimation.estimate_cost(integral, function_replace_map)[source]

Estimate cost of tensor representation for integral. The cost is computed as the sum of the number of coefficients and derivatives, if the integrand can be represented as a monomial, and -1 if not.

ffc.tensor.geometrytensor module

class ffc.tensor.geometrytensor.GeometryTensor(monomial)[source]

Bases: object

This class represents the geometry tensor for a monomial term of a multilinear form.

ffc.tensor.monomialextraction module

Extraction of monomial representations of UFL forms.

class ffc.tensor.monomialextraction.Monomial(arg=None)[source]

Bases: object

This class represents a product of monomial factors.

exception ffc.tensor.monomialextraction.MonomialException(*args, **kwargs)[source]

Bases: Exception

Exception raised when monomial extraction fails.

class ffc.tensor.monomialextraction.MonomialFactor(arg=None)[source]

Bases: object

This class represents a monomial factor, that is, a derivative of a scalar component of a basis function.

replace_indices(old_indices, new_indices)[source]
class ffc.tensor.monomialextraction.MonomialForm[source]

Bases: object

This class represents a monomial form, that is, a sum of integrals, each represented as a MonomialSum.

class ffc.tensor.monomialextraction.MonomialSum(arg=None)[source]

Bases: object

This class represents a sum of monomials.

class ffc.tensor.monomialextraction.MonomialTransformer(function_replace_map=None)[source]

Bases: ufl.algorithms.transformer.ReuseTransformer

This class defines the transformation rules for extraction of a monomial form represented as a MonomialSum from a UFL integral.

component_tensor(o, s, indices)[source]
expr(o, *ops)[source]
grad(o, s)[source]
index_sum(o, s, index)[source]
indexed(o, s, indices)[source]
negative_restricted(o, s)[source]
positive_restricted(o, s)[source]
power(o, s, ignored_exponent_expressed_as_sum)[source]
product(o, s0, s1)[source]
sum(o, s0, s1)[source]
ffc.tensor.monomialextraction.extract_monomial_form(integrands, function_replace_map)[source]

Extract monomial representation of form (if possible). When successful, the form is represented as a sum of products of scalar components of basis functions or derivatives of basis functions. If unsuccessful, MonomialException is raised.

ffc.tensor.monomialextraction.extract_monomial_integrand(integrand, function_replace_map)[source]

Extract monomial integrand (if possible).

ffc.tensor.monomialintegration module

This module implements efficient integration of monomial forms.

ffc.tensor.monomialintegration.integrate(monomial, integral_type, facet0, facet1, quadrature_degree, quadrature_rule, cell)[source]

Compute the reference tensor for a given monomial term of a multilinear form

ffc.tensor.monomialtransformation module

Transformation of monomial representations of UFL forms.

class ffc.tensor.monomialtransformation.MonomialArgument(element, index, components, derivatives, restriction)[source]

Bases: object

This class represents a monomial argument, that is, a derivative of a scalar component of a basis function on the reference element.

class ffc.tensor.monomialtransformation.MonomialCoefficient(index, number)[source]

Bases: object

This class represents a coefficient in a monomial.

class ffc.tensor.monomialtransformation.MonomialDeterminant(power=None, restriction=None)[source]

Bases: object

This class representes a determinant factor in a monomial.

class ffc.tensor.monomialtransformation.MonomialIndex(index=None, index_type=None, index_range=None, index_id=None)[source]

Bases: object

This class represents a monomial index. Each index has a type, a range and a unique id. Valid index types are listed below.

EXTERNAL = 'external'
FIXED = 'fixed'
INTERNAL = 'internal'
PRIMARY = 'primary'
SECONDARY = 'secondary'
class ffc.tensor.monomialtransformation.MonomialTransform(index0, index1, transform_type, restriction, offset)[source]

Bases: object

This class represents a transform (mapping derivative) in a form.

J = 'J'
class ffc.tensor.monomialtransformation.TransformedMonomial(monomial)[source]

Bases: object

This class represents a monomial form after transformation to the reference element.


Return all unique indices for monomial w.r.t. type and id (not range).


Transform monomial form to reference element.

ffc.tensor.multiindex module

class ffc.tensor.multiindex.MultiIndex(dims)[source]

Bases: object

A MultiIndex represents a list of indices and holds the following data:

rank - rank of multiindex dims - a list of dimensions indices - a list of all possible multiindex values

Create a list of all index combinations.


Create multiindex for given list of indices.

ffc.tensor.multiindex.outer_join(a, b)[source]

Let a be a list of lists and b a list. We append each element of b to each list in a and return the resulting list of lists.

ffc.tensor.referencetensor module

class ffc.tensor.referencetensor.ReferenceTensor(monomial, integral_type, facet0, facet1, quadrature_order, quadrature_rule, cell)[source]

Bases: object

This class represents the reference tensor for a monomial term of a multilinear form.

ffc.tensor.tensorgenerator module

Code generator for tensor representation

ffc.tensor.tensorgenerator.generate_integral_code(ir, prefix, parameters)[source]

Generate code for integral from intermediate representation.

ffc.tensor.tensoroptimization module

ffc.tensor.tensoroptimization.optimize_integral_ir(ir, parameters)[source]

Compute optimized intermediate representation of integral.

ffc.tensor.tensorreordering module

Reordering of entries in reference tensor for interior facets.


Reorder entries to compute the reference tensor for an interior facet from the the reduced reference tensor.

ffc.tensor.tensorrepresentation module

This module implements the representation of a multilinear form as a sum of tensor contractions.

The following possible optimizations are currently not implemented but might be (re-)implemented in a future version of FFC

  1. Factorization of common reference tensors
ffc.tensor.tensorrepresentation.compute_integral_ir(itg_data, form_data, form_id, element_numbers, classnames, parameters)[source]

Compute intermediate represention of integral.

Module contents