ffc.tensor package

Submodules

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.

apply_derivative(indices)[source]
apply_indices(indices)[source]
apply_restriction(restriction)[source]
apply_tensor(indices)[source]
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.

apply_derivative(indices)[source]
apply_restriction(restriction)[source]
element()[source]
index()[source]
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.

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

Bases: object

This class represents a sum of monomials.

apply_derivative(indices)[source]
apply_indices(indices)[source]
apply_restriction(restriction)[source]
apply_tensor(indices)[source]
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.

argument(v)[source]
coefficient(v)[source]
component_tensor(o, s, indices)[source]
division(o)[source]
expr(o, *ops)[source]
grad(o, s)[source]
index_sum(o, s, index)[source]
indexed(o, s, indices)[source]
multi_index(multi_index)[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]
scalar_value(x)[source]
sum(o, s0, s1)[source]
terminal(o)[source]
variable(o)[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'
JINV = 'JINV'
class ffc.tensor.monomialtransformation.TransformedMonomial(monomial)[source]

Bases: object

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

extract_unique_indices(index_type=None)[source]

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

ffc.tensor.monomialtransformation.transform_monomial_form(monomial_form)[source]

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
ffc.tensor.multiindex.build_indices(dims)[source]

Create a list of all index combinations.

ffc.tensor.multiindex.create_multiindex(indices)[source]

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.

ffc.tensor.tensorreordering.reorder_entries(terms)[source]

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