FFC: The FEniCS Form Compiler

FFC is a compiler for finite element variational forms. From a high-level description of the form, it generates efficient low-level C++ code that can be used to assemble the corresponding discrete operator (tensor). In particular, a bilinear form may be assembled into a matrix and a linear form may be assembled into a vector. FFC may be used either from the command line (by invoking the ffc command) or as a Python module (import ffc).

FFC is part of the FEniCS Project.

For more information, visit http://www.fenicsproject.org

Documentation

Installation

FFC is normally installed as part of an installation of FEniCS. If you are using FFC as part of the FEniCS software suite, it is recommended that you follow the installation instructions for FEniCS.

To install FFC itself, read on below for a list of requirements and installation instructions.

Requirements and dependencies

FFC requires Python version 3.5 or later and depends on the following Python packages:

  • NumPy
  • six

FFC also depends on the following FEniCS Python packages:

  • FIAT
  • UFL
  • dijitso

These packages will be automatically installed as part of the installation of FFC, if not already present on your system.

TSFC requirements

To use experimental tsfc representation, additional dependencies are needed:

and in turn their additional dependencies:

Note

TSFC requirements are not installed in FEniCS Docker images by default yet but they can be easilly installed on demand:

docker pull quay.io/fenicsproject/stable
docker run -ti --rm quay.io/fenicsproject/stable
  pip3 install --prefix=${FENICS_PREFIX} --no-cache-dir \
  git+https://github.com/blechta/tsfc.git@2018.1.0 \
  git+https://github.com/blechta/COFFEE.git@2018.1.0 \
  git+https://github.com/blechta/FInAT.git@2018.1.0 \
  singledispatch networkx pulp && \
  sudo rm -rf /tmp/* /var/tmp/*

The first two commands (or their modification, or fenicsproject helper script) are to be run on a host, while the last command, to be run in the container, actually installs all the TSFC requirements. For further reading, see FEniCS Docker reference.

[1](1, 2, 3) These are forks of the original packages tested to be compatible with FFC and updated frequently from upstream.
[2](1, 2, 3) Pip-installable.

Installation instructions

To install FFC, download the source code from the FFC Bitbucket repository, and run the following command:

pip3 install .

To install to a specific location, add the --prefix flag to the installation command:

pip3 install --prefix=<some directory> .

User manual

Note

This page is work in progress.

ffc package

Subpackages

ffc.errorcontrol package
Submodules
ffc.errorcontrol.errorcontrol module

This module provides compilation of forms required for goal-oriented error control

ffc.errorcontrol.errorcontrol.compile_with_error_control(forms, object_names, reserved_objects, prefix, parameters)[source]

Compile forms and additionally generate and compile forms required for performing goal-oriented error control

For linear problems, the input forms should be a bilinear form (a) and a linear form (L) specifying the variational problem and additionally a linear form (M) specifying the goal functional.

For nonlinear problems, the input should be linear form (F) and a functional (M) specifying the goal functional.

Arguments

forms (tuple)
Three (linear case) or two (nonlinear case) forms specifying the primal problem and the goal
object_names (dict)
Map from object ids to object names
reserved_names (dict)
Map from reserved object names to object ids
prefix (string)
Basename of header file
parameters (dict)
Parameters for form compilation
ffc.errorcontrol.errorcontrolgenerators module

This module provides an abstract ErrorControlGenerator class for generating forms required for goal-oriented error control and a realization of this: UFLErrorControlGenerator for handling pure UFL forms.

class ffc.errorcontrol.errorcontrolgenerators.ErrorControlGenerator(module, F, M, u)[source]

Bases: object

cell_residual()[source]

Generate and return (bilinear, linear) forms defining linear variational problem for the strong cell residual

dual_forms()[source]

Generate and return (bilinear, linear) forms defining linear dual variational problem

error_estimate()[source]

Generate and return functional defining error estimate

error_indicators()[source]

Generate and return linear form defining error indicators

facet_residual()[source]

Generate and return (bilinear, linear) forms defining linear variational problem for the strong facet residual(s)

generate_all_error_control_forms()[source]

Utility function for generating all (8) forms required for error control in addition to the primal forms

initialize_data()[source]

Initialize specific data

primal_forms()[source]

Return primal forms in order (bilinear, linear, functional)

class ffc.errorcontrol.errorcontrolgenerators.UFLErrorControlGenerator(F, M, u)[source]

Bases: ffc.errorcontrol.errorcontrolgenerators.ErrorControlGenerator

This class provides a realization of ErrorControlGenerator for use with pure UFL forms

initialize_data()[source]

Extract required objects for defining error control forms. This will be stored, reused and in particular named.

Module contents

This module contains functionality for working with automated goal-oriented error control. In particular it offers the following function:

compile_with_error_control - Compile forms and generate error control forms
ffc.quadrature package
Submodules
ffc.quadrature.codesnippets module

Code snippets for code generation.

ffc.quadrature.cpp module

This module defines rules and algorithms for generating C++ code.

ffc.quadrature.cpp.count_ops(code)[source]

Count the number of operations in code (multiply-add pairs).

ffc.quadrature.cpp.indent(block, num_spaces)[source]

Indent each row of the given string block with n spaces.

ffc.quadrature.cpp.make_classname(prefix, basename, signature)[source]
ffc.quadrature.cpp.make_integral_classname(prefix, integral_type, form_id, subdomain_id)[source]
ffc.quadrature.cpp.remove_unused(code, used_set=set())[source]

Remove unused variables from a given C++ code. This is useful when generating code that will be compiled with gcc and parameters -Wall -Werror, in which case gcc returns an error when seeing a variable declaration for a variable that is never used.

Optionally, a set may be specified to indicate a set of variables names that are known to be used a priori.

ffc.quadrature.cpp.set_exception_handling(convert_exceptions_to_warnings)[source]

Set handling of exceptions.

ffc.quadrature.cpp.set_float_formatting(precision)[source]

Set floating point formatting based on precision.

ffc.quadrature.deprecation module
exception ffc.quadrature.deprecation.QuadratureRepresentationDeprecationWarning[source]

Bases: DeprecationWarning

Warning about deprecation of quadrature representation

ffc.quadrature.deprecation.issue_deprecation_warning()[source]

Issue warning about quadrature deprecation

ffc.quadrature.expr module

This file implements a base class to represent an expression.

class ffc.quadrature.expr.Expr[source]

Bases: object

expand()[source]

Expand the expression. (FloatValue and Symbol are expanded by construction).

get_unique_vars(var_type)[source]

Get unique variables (Symbols) as a set.

get_var_occurrences()[source]

Determine the number of times all variables occurs in the expression. Returns a dictionary of variables and the number of times they occur. Works for FloatValue and Symbol.

ops()[source]

Return number of operations to compute the expression. This is always zero for a FloatValue.

reduce_ops()[source]

Reduce number of operations to evaluate the expression. There is nothing to be done for FloatValue and Symbol.

reduce_var(var)[source]

Reduce the expression by another variable by using division. This works for FloatValue, Symbol and Product.

reduce_vartype(var_type)[source]

Reduce expression with given var_type. It returns a tuple (found, remain), where ‘found’ is an expression that only has variables of type == var_type. If no variables are found, found=(). The ‘remain’ part contains the leftover after division by ‘found’ such that: self = found*remain. Works for FloatValue and Symbol.

t
val
ffc.quadrature.floatvalue module

This file implements a class to represent a float.

class ffc.quadrature.floatvalue.FloatValue(value)[source]

Bases: ffc.quadrature.expr.Expr

ffc.quadrature.fraction module

This file implements a class to represent a fraction.

class ffc.quadrature.fraction.Fraction(numerator, denominator)[source]

Bases: ffc.quadrature.expr.Expr

denom
expand()[source]

Expand the fraction expression.

get_unique_vars(var_type)[source]

Get unique variables (Symbols) as a set.

get_var_occurrences()[source]

Determine the number of minimum number of times all variables occurs in the expression simply by calling the function on the numerator.

num
ops()[source]

Return number of operations needed to evaluate fraction.

reduce_ops()[source]

Reduce number of operations to evaluate the expression. There is nothing to be done for FloatValue and Symbol.

reduce_var(var)[source]

Reduce the fraction by another variable through division of numerator.

reduce_vartype(var_type)[source]

Reduce expression with given var_type. It returns a tuple (found, remain), where ‘found’ is an expression that only has variables of type == var_type. If no variables are found, found=(). The ‘remain’ part contains the leftover after division by ‘found’ such that: self = found*remain.

ffc.quadrature.optimisedquadraturetransformer module

QuadratureTransformer (optimised) for quadrature code generation to translate UFL expressions.

class ffc.quadrature.optimisedquadraturetransformer.QuadratureTransformerOpt(*args)[source]

Bases: ffc.quadrature.quadraturetransformerbase.QuadratureTransformerBase

Transform UFL representation to quadrature code.

abs(o, *operands)[source]
binary_condition(o, *operands)[source]
cell_coordinate(o)[source]
cell_facet_jacobian(o)[source]
cell_facet_jacobian_determinant(o)[source]
cell_facet_jacobian_inverse(o)[source]
cell_facet_origin(o)[source]
cell_normal(o)[source]
cell_orientation(o)[source]
cell_origin(o)[source]
cell_volume(o)[source]
circumradius(o)[source]
conditional(o, *operands)[source]
create_argument(ufl_argument, derivatives, component, local_comp, local_offset, ffc_element, transformation, multiindices, tdim, gdim, avg)[source]

Create code for basis functions, and update relevant tables of used basis.

create_function(ufl_function, derivatives, component, local_comp, local_offset, ffc_element, is_quad_element, transformation, multiindices, tdim, gdim, avg)[source]

Create code for basis functions, and update relevant tables of used basis.

division(o, *operands)[source]
facet_area(o)[source]
facet_coordinate(o)[source]
facet_jacobian(o)[source]
facet_jacobian_determinant(o)[source]
facet_jacobian_inverse(o)[source]
facet_normal(o)[source]
facet_origin(o)[source]
jacobian(o)[source]
jacobian_determinant(o)[source]
jacobian_inverse(o)[source]
max_facet_edge_length(o)[source]
max_value(o, *operands)[source]
min_facet_edge_length(o)[source]
min_value(o, *operands)[source]
not_condition(o, *operands)[source]
power(o)[source]
product(o, *operands)[source]
quadrature_weight(o)[source]
sum(o, *operands)[source]
ffc.quadrature.optimisedquadraturetransformer.firstkey(d)[source]
ffc.quadrature.parameters module

Quadrature representation class for UFL

ffc.quadrature.parameters.default_optimize_parameters()[source]
ffc.quadrature.parameters.parse_optimise_parameters(parameters, itg_data)[source]
ffc.quadrature.product module

This file implements a class to represent a product.

class ffc.quadrature.product.Product(variables)[source]

Bases: ffc.quadrature.expr.Expr

expand()[source]

Expand all members of the product.

get_unique_vars(var_type)[source]

Get unique variables (Symbols) as a set.

get_var_occurrences()[source]

Determine the number of times all variables occurs in the expression. Returns a dictionary of variables and the number of times they occur.

get_vrs()[source]

Return all ‘real’ variables.

ops()[source]

Get the number of operations to compute product.

reduce_ops()[source]

Reduce the number of operations to evaluate the product.

reduce_vartype(var_type)[source]

Reduce expression with given var_type. It returns a tuple (found, remain), where ‘found’ is an expression that only has variables of type == var_type. If no variables are found, found=(). The ‘remain’ part contains the leftover after division by ‘found’ such that: self = found*remain.

vrs
ffc.quadrature.quadraturegenerator module

Code generator for quadrature representation.

ffc.quadrature.quadraturegenerator.generate_integral_code(ir, prefix, parameters)[source]

Generate code for integral from intermediate representation.

ffc.quadrature.quadratureoptimization module
ffc.quadrature.quadratureoptimization.optimize_integral_ir(ir, parameters)[source]

Compute optimized intermediate representation of integral.

ffc.quadrature.quadraturerepresentation module

Quadrature representation class for UFL

ffc.quadrature.quadraturerepresentation.compute_integral_ir(itg_data, form_data, form_id, element_numbers, classnames, parameters)[source]

Compute intermediate represention of integral.

ffc.quadrature.quadraturerepresentation.sort_integrals(integrals, default_scheme, default_degree)[source]

Sort and accumulate integrals according to the number of quadrature points needed per axis.

All integrals should be over the same (sub)domain.

ffc.quadrature.quadraturetransformer module

QuadratureTransformer for quadrature code generation to translate UFL expressions.

class ffc.quadrature.quadraturetransformer.QuadratureTransformer(*args)[source]

Bases: ffc.quadrature.quadraturetransformerbase.QuadratureTransformerBase

Transform UFL representation to quadrature code.

abs(o, *operands)[source]
binary_condition(o, *operands)[source]
cell_coordinate(o)[source]
cell_facet_jacobian(o)[source]
cell_facet_jacobian_determinant(o)[source]
cell_facet_jacobian_inverse(o)[source]
cell_facet_origin(o)[source]
cell_normal(o)[source]
cell_orientation(o)[source]
cell_origin(o)[source]
cell_volume(o)[source]
circumradius(o)[source]
conditional(o, *operands)[source]
create_argument(ufl_argument, derivatives, component, local_comp, local_offset, ffc_element, transformation, multiindices, tdim, gdim, avg)[source]

Create code for basis functions, and update relevant tables of used basis.

create_function(ufl_function, derivatives, component, local_comp, local_offset, ffc_element, is_quad_element, transformation, multiindices, tdim, gdim, avg)[source]

Create code for basis functions, and update relevant tables of used basis.

division(o, *operands)[source]
facet_area(o)[source]
facet_coordinate(o)[source]
facet_jacobian(o)[source]
facet_jacobian_determinant(o)[source]
facet_jacobian_inverse(o)[source]
facet_normal(o)[source]
facet_origin(o)[source]
jacobian(o)[source]
jacobian_determinant(o)[source]
jacobian_inverse(o)[source]
max_facet_edge_length(o)[source]
max_value(o, *operands)[source]
min_facet_edge_length(o)[source]
min_value(o, *operands)[source]
not_condition(o, *operands)[source]
power(o)[source]
product(o, *operands)[source]
quadrature_weight(o)[source]
sum(o, *operands)[source]
ffc.quadrature.quadraturetransformer.firstkey(d)[source]
ffc.quadrature.quadraturetransformerbase module

QuadratureTransformerBase, a common class for quadrature transformers to translate UFL expressions.

class ffc.quadrature.quadraturetransformerbase.FFCMultiIndex(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
class ffc.quadrature.quadraturetransformerbase.QuadratureTransformerBase(psi_tables, quad_weights, gdim, tdim, entity_type, function_replace_map, optimise_parameters)[source]

Bases: ufl.algorithms.transformer.Transformer

Transform UFL representation to quadrature code.

abs(o, *operands)[source]
acos(o, *operands)[source]
argument(o)[source]
asin(o, *operands)[source]
atan(o, *operands)[source]
atan_2(o, *operands)[source]
atan_2_function(o)[source]
bessel_function(o)[source]
bessel_i(o, *operands)[source]
bessel_j(o, *operands)[source]
bessel_k(o, *operands)[source]
bessel_y(o, *operands)[source]
cell_avg(o)[source]
cell_coordinate(o)[source]
cell_facet_jacobian(o)[source]
cell_facet_jacobian_determinant(o)[source]
cell_facet_jacobian_inverse(o)[source]
cell_facet_origin(o)[source]
cell_normal(o)[source]
cell_orientation(o)[source]
cell_origin(o)[source]
cell_volume(o)[source]
circumradius(o)[source]
coefficient(o)[source]
component()[source]

Return current component tuple.

component_tensor(o)[source]
compound_tensor_operator(o)[source]
condition(o)[source]
constant_value(o)[source]
cos(o, *operands)[source]
cosh(o, *operands)[source]
derivative(o, *operands)[source]
derivatives()[source]

Return all derivatives tuple.

disp()[source]
division(o, *operands)[source]
erf(o, *operands)[source]
exp(o, *operands)[source]
expr(o)[source]

Trigger error.

facet_area(o)[source]
facet_avg(o)[source]
facet_coordinate(o)[source]
facet_jacobian(o)[source]
facet_jacobian_determinant(o)[source]
facet_jacobian_inverse(o)[source]
facet_normal(o)[source]
facet_origin(o)[source]
generate_terms(integrand, integral_type)[source]

Generate terms for code generation.

geometric_quantity(o)[source]
grad(o)[source]
identity(o)[source]
index_sum(o)[source]
indexed(o)[source]
jacobian(o)[source]
jacobian_determinant(o)[source]
jacobian_inverse(o)[source]
label(o)[source]
list_tensor(o)[source]
ln(o, *operands)[source]
math_function(o)[source]
max_facet_edge_length(o)[source]
min_facet_edge_length(o)[source]
multi_index(o)[source]
negative_restricted(o)[source]
positive_restricted(o)[source]
power(o)[source]
product(o, *operands)[source]
quadrature_weight(o)[source]
restricted(o)[source]
scalar_value(o)[source]

ScalarValue covers IntValue and FloatValue

sin(o, *operands)[source]
sinh(o, *operands)[source]
spatial_coordinate(o)[source]
sqrt(o, *operands)[source]
sum(o, *operands)[source]
tan(o, *operands)[source]
tanh(o, *operands)[source]
terminal(o)[source]

Always reuse Expr (ignore children)

update_cell()[source]
update_facets(facet0, facet1)[source]
update_points(points)[source]
update_vertex(vertex)[source]
variable(o)[source]
zero(o)[source]
ffc.quadrature.quadratureutils module

Utility functions for quadrature representation.

ffc.quadrature.quadratureutils.contains_zeros(tables)[source]

Checks if any tables contains only zeros.

ffc.quadrature.quadratureutils.create_permutations(expr)[source]
ffc.quadrature.quadratureutils.create_psi_tables(tables, eliminate_zeros, entity_type)[source]

Create names and maps for tables and non-zero entries if appropriate.

ffc.quadrature.quadratureutils.flatten_psi_tables(tables, entity_type)[source]

Create a ‘flat’ dictionary of tables with unique names and a name map that maps number of quadrature points and element name to a unique element number.

Input tables on the format for scalar and non-scalar elements respectively:
tables[num_points][element][entity][derivs][ip][dof] tables[num_points][element][entity][derivs][ip][component][dof]
Planning to change this into:
tables[num_points][element][avg][entity][derivs][ip][dof] tables[num_points][element][avg][entity][derivs][ip][component][dof]
Returns:
element_map - { num_quad_points: {ufl_element: element_number} }. flat_tables - { unique_table_name: values[ip,dof] }.
ffc.quadrature.quadratureutils.get_ones(tables)[source]

Return names of tables for which all values are 1.0.

ffc.quadrature.quadratureutils.unique_psi_tables(tables, eliminate_zeros)[source]

Returns a name map and a dictionary of unique tables. The function checks if values in the tables are equal, if this is the case it creates a name mapping. It also create additional information (depending on which parameters are set) such as if the table contains all ones, or only zeros, and a list on non-zero columns. unique_tables - {name:values,}. name_map - {original_name:[new_name, non-zero-columns (list), is zero (bool), is ones (bool)],}.

ffc.quadrature.quadratureutils.unique_tables(tables)[source]

Removes tables with redundant values and returns a name_map and a inverse_name_map. E.g.,

tables = {a:[0,1,2], b:[0,2,3], c:[0,1,2], d:[0,1,2]} results in: tables = {a:[0,1,2], b:[0,2,3]} name_map = {a:[c,d]} inverse_name_map = {a:a, b:b, c:a, d:a}.

ffc.quadrature.reduce_operations module

Some simple functions for manipulating expressions symbolically

ffc.quadrature.reduce_operations.expand_operations(expression, format)[source]

This function expands an expression and returns the value. E.g., ((x + y)) –> x + y 2*(x + y) –> 2*x + 2*y (x + y)*(x + y) –> x*x + y*y + 2*x*y z*(x*(y + 3) + 2) + 1 –> 1 + 2*z + x*y*z + x*z*3 z*((y + 3)*x + 2) + 1 –> 1 + 2*z + x*y*z + x*z*3

ffc.quadrature.reduce_operations.get_constants(expression, const_terms, format, constants=[])[source]

This function returns a new expression where all geometry terms have been substituted with geometry declarations, these declarations are added to the const_terms dictionary.

ffc.quadrature.reduce_operations.get_geo_terms(expression, geo_terms, offset, format)[source]

This function returns a new expression where all geometry terms have been substituted with geometry declarations, these declarations are added to the geo_terms dictionary.

ffc.quadrature.reduce_operations.get_indices(variable, format, from_get_indices=False)[source]

This function returns the indices of a given variable. E.g., P[0][j], returns [‘j’] P[ip][k], returns [‘ip’,’k’] P[ip][nzc0[j] + 3], returns [‘ip’,’j’] w[0][j + 2] , returns [j]

ffc.quadrature.reduce_operations.get_simple_variables(expression, format)[source]
This function takes as argument an expression (preferably expanded):
expression = “x*x + y*x + x*y*z”

returns a list of products and a dictionary:

prods = [“x*x”, “y*x”, “x*y*z”] variables = {variable: [num_occurences, [pos_in_prods]]} variables = {“x”:[3, [0,1,2]], “y”:[2, [1,2]], “z”:[1, [2]]}
ffc.quadrature.reduce_operations.get_variables(expression, variables, format, constants=[])[source]

This function returns a new expression where all geometry terms have been substituted with geometry declarations, these declarations are added to the const_terms dictionary.

ffc.quadrature.reduce_operations.group_vars(expr, format)[source]

Group variables in an expression, such that: “x + y + z + 2*y + 6*z” = “x + 3*y + 7*z” “x*x + x*x + 2*x + 3*x + 5” = “2.0*x*x + 5.0*x + 5” “x*y + y*x + 2*x*y + 3*x + 0*x + 5” = “5.0*x*y + 3.0*x + 5” “(y + z)*x + 5*(y + z)*x” = “6.0*(y + z)*x” “1/(x*x) + 2*1/(x*x) + std::sqrt(x) + 6*std::sqrt(x)” = “3*1/(x*x) + 7*std::sqrt(x)”

ffc.quadrature.reduce_operations.is_constant(variable, format, constants=[], from_is_constant=False)[source]

Determine if a variable is constant or not. The function accepts an optional list of variables (loop indices) that will be regarded as constants for the given variable. If none are supplied it is assumed that all array accesses will result in a non-constant variable.

v = 2.0, is constant v = Jinv_00*det, is constant v = w[0][1], is constant v = 2*w[0][1], is constant v = W0[ip], is constant if constants = [‘ip’] else not v = P_t0[ip][j], is constant if constants = [‘j’,’ip’] else not

ffc.quadrature.reduce_operations.operation_count(expression, format)[source]

This function returns the number of double operations in an expression. We do split () but not [] as we only have unsigned integer operations in [].

ffc.quadrature.reduce_operations.reduce_operations(expression, format)[source]

This function reduces the number of opertions needed to compute a given expression. It looks for the variable that appears the most and groups terms containing this variable inside parenthesis. The function is called recursively until no further reductions are possible.

“x + y + x” = 2*x + y “x*x + 2.0*x*y + y*y” = y*y + (2.0*y + x)*x, not (x + y)*(x + y) as it should be!! z*x*y + z*x*3 + 2*z + 1” = z*(x*(y + 3) + 2) + 1

ffc.quadrature.reduce_operations.reduction_possible(variables)[source]

Find the variable that occurs in the most products, if more variables occur the same number of times and in the same products add them to list.

ffc.quadrature.reduce_operations.split_expression(expression, format, operator, allow_split=False)[source]

Split the expression at the given operator, return list. Do not split () or [] unless told to split (). This is to enable easy count of double operations which can be in (), but in [] we only have integer operations.

ffc.quadrature.sumobj module

This file implements a class to represent a sum.

class ffc.quadrature.sumobj.Sum(variables)[source]

Bases: ffc.quadrature.expr.Expr

expand()[source]

Expand all members of the sum.

get_unique_vars(var_type)[source]

Get unique variables (Symbols) as a set.

get_var_occurrences()[source]

Determine the number of minimum number of times all variables occurs in the expression. Returns a dictionary of variables and the number of times they occur. x*x + x returns {x:1}, x + y returns {}.

ops()[source]

Return number of operations to compute value of sum.

reduce_ops()[source]

Reduce the number of operations needed to evaluate the sum.

reduce_vartype(var_type)[source]

Reduce expression with given var_type. It returns a list of tuples [(found, remain)], where ‘found’ is an expression that only has variables of type == var_type. If no variables are found, found=(). The ‘remain’ part contains the leftover after division by ‘found’ such that: self = Sum([f*r for f,r in self.reduce_vartype(Type)]).

vrs
ffc.quadrature.symbol module

This file implements a class to represent a symbol.

class ffc.quadrature.symbol.Symbol(variable, symbol_type, base_expr=None, base_op=0)[source]

Bases: ffc.quadrature.expr.Expr

base_expr
base_op
cond
exp
get_unique_vars(var_type)[source]

Get unique variables (Symbols) as a set.

get_var_occurrences()[source]

Determine the number of times all variables occurs in the expression. Returns a dictionary of variables and the number of times they occur.

ops()[source]

Returning the number of floating point operation for symbol.

v
ffc.quadrature.symbolics module

This file contains functions to optimise the code generated for quadrature representation.

ffc.quadrature.symbolics.create_float(val)[source]
ffc.quadrature.symbolics.create_fraction(num, denom)[source]
ffc.quadrature.symbolics.create_product(variables)[source]
ffc.quadrature.symbolics.create_sum(variables)[source]
ffc.quadrature.symbolics.create_symbol(variable, symbol_type, base_expr=None, base_op=0)[source]
ffc.quadrature.symbolics.generate_aux_constants(constant_decl, name, var_type, print_ops=False)[source]

A helper tool to generate code for constant declarations.

ffc.quadrature.symbolics.optimise_code(expr, ip_consts, geo_consts, trans_set)[source]

Optimise a given expression with respect to, basis functions, integration points variables and geometric constants. The function will update the dictionaries ip_const and geo_consts with new declarations and update the trans_set (used transformations).

ffc.quadrature.tabulate_basis module

Quadrature representation class.

ffc.quadrature.tabulate_basis.tabulate_basis(sorted_integrals, form_data, itg_data)[source]

Tabulate the basisfunctions and derivatives.

Module contents
ffc.tsfc package
Submodules
ffc.tsfc.tsfcgenerator module
ffc.tsfc.tsfcoptimization module
ffc.tsfc.tsfcoptimization.optimize_integral_ir(ir, parameters)[source]
ffc.tsfc.tsfcrepresentation module
ffc.tsfc.tsfcrepresentation.compute_integral_ir(integral_data, form_data, form_id, element_numbers, classnames, parameters)[source]

Compute intermediate represention of integral.

Module contents
ffc.uflacs package
Subpackages
ffc.uflacs.analysis package
Submodules
ffc.uflacs.analysis.balancing module

Algorithms for the representation phase of the form compilation.

class ffc.uflacs.analysis.balancing.BalanceModifiers[source]

Bases: ufl.corealg.multifunction.MultiFunction

cell_avg(expr, *ops)
expr(expr, *ops)[source]

Trigger error for types with missing handlers.

facet_avg(expr, *ops)
grad(expr, *ops)
negative_restricted(expr, *ops)
positive_restricted(expr, *ops)
reference_grad(expr, *ops)
reference_value(expr, *ops)
terminal(expr)[source]
ffc.uflacs.analysis.balancing.balance_modified_terminal(expr)[source]
ffc.uflacs.analysis.balancing.balance_modifiers(expr)[source]
ffc.uflacs.analysis.crsarray module

Compressed row storage ‘matrix’ (actually just a non-rectangular 2d array).

class ffc.uflacs.analysis.crsarray.CRSArray(row_capacity, element_capacity, dtype)[source]

Bases: object

An array of variable length dense arrays.

Stored efficiently with simple compressed row storage. This CRS array variant doesn’t have a sparsity pattern, as each row is simply a dense vector.

Values are stored in one flat array ‘data[]’, and ‘row_offsets[i]’ contains the index to the first element on row i for 0<=i<=num_rows. There is no column index.

classmethod from_rows(rows, num_rows, num_elements, dtype)[source]

Construct a CRSArray from a list of row element lists.

num_elements
push_row(elements)[source]
ffc.uflacs.analysis.crsarray.sufficient_int(maxval)[source]
ffc.uflacs.analysis.dependencies module

Tools for analysing dependencies within expression graphs.

ffc.uflacs.analysis.dependencies.compute_dependencies(e2i, V, ignore_terminal_modifiers=True)[source]
ffc.uflacs.analysis.dependencies.mark_active(dependencies, targets)[source]

Return an array marking the recursive dependencies of targets.

Input: - dependencies - CRSArray of ints, a mapping from a symbol to the symbols of its dependencies. - targets - Sequence of symbols to mark the dependencies of.

Output: - active - Truth value for each symbol. - num_used - Number of true values in active array.

ffc.uflacs.analysis.dependencies.mark_image(inverse_dependencies, sources)[source]

Return an array marking the set of symbols dependent on the sources.

Input: - dependencies - CRSArray of ints, a mapping from a symbol to the symbols of its dependencies. - sources - Sequence of symbols to mark the dependants of.

Output: - image - Truth value for each symbol. - num_used - Number of true values in active array.

ffc.uflacs.analysis.expr_shapes module

Tools for computing various shapes of ufl expressions.

The total shape is the regular shape tuple plus the index shape tuple. The index shape tuple is the tuple of index dimensions of the free indices of the expression, sorted by the count of the free indices.

The total shape of a tensor valued expression A and A[*indices(len(A.ufl_shape))] is therefore the same.

ffc.uflacs.analysis.expr_shapes.compute_all_shapes(v)[source]

Compute the tensor-, index-, and total shape of an expr.

Returns (shape, size, index_shape, index_size, total_shape, total_size).

ffc.uflacs.analysis.expr_shapes.compute_index_shape(v)[source]

Compute the ‘index shape’ of v.

ffc.uflacs.analysis.expr_shapes.total_shape(v)[source]

Compute the total shape of an expr.

ffc.uflacs.analysis.factorization module

Algorithms for factorizing argument dependent monomials.

class ffc.uflacs.analysis.factorization.Factors[source]

Bases: object

add(expr)[source]
ffc.uflacs.analysis.factorization.add_to_fv(expr, FV, e2fi)[source]

Add expression expr to factor vector FV and expr->FVindex mapping e2fi.

ffc.uflacs.analysis.factorization.build_argument_dependencies(dependencies, arg_indices)[source]

Preliminary algorithm: build list of argument vertex indices each vertex (indirectly) depends on.

ffc.uflacs.analysis.factorization.build_argument_indices(V)[source]

Build ordered list of indices to modified arguments.

ffc.uflacs.analysis.factorization.compute_argument_factorization(SV, SV_deps, SV_targets, rank)[source]

Factorizes a scalar expression graph w.r.t. scalar Argument components.

The result is a triplet (AV, FV, IM):

  • The scalar argument component subgraph:

    AV[ai] = v

    with the property

    SV[arg_indices] == AV[:]

  • An expression graph vertex list with all non-argument factors:

    FV[fi] = f

    with the property that none of the expressions depend on Arguments.

  • A dict representation of the final integrand of rank r:

    IM = { (ai1_1, …, ai1_r): fi1, (ai2_1, …, ai2_r): fi2, }

    This mapping represents the factorization of SV[-1] w.r.t. Arguments s.t.:

    SV[-1] := sum(FV[fik] * product(AV[ai] for ai in aik) for aik, fik in IM.items())

    where := means equivalence in the mathematical sense, of course in a different technical representation.

ffc.uflacs.analysis.factorization.handle_conditional(v, si, deps, SV_factors, FV, sv2fv, e2fi)[source]
ffc.uflacs.analysis.factorization.handle_division(v, si, deps, SV_factors, FV, sv2fv, e2fi)[source]
ffc.uflacs.analysis.factorization.handle_operator(v, si, deps, SV_factors, FV, sv2fv, e2fi)[source]
ffc.uflacs.analysis.factorization.handle_product(v, si, deps, SV_factors, FV, sv2fv, e2fi)[source]
ffc.uflacs.analysis.factorization.handle_sum(v, si, deps, SV_factors, FV, sv2fv, e2fi)[source]
ffc.uflacs.analysis.factorization.rebuild_scalar_graph_from_factorization(AV, FV, IM)[source]
ffc.uflacs.analysis.graph module

Linearized data structure for the computational graph.

class ffc.uflacs.analysis.graph.Graph2[source]

Bases: object

ffc.uflacs.analysis.graph.build_graph(expressions, DEBUG=False)[source]
ffc.uflacs.analysis.graph_rebuild module

Rebuilding UFL expressions from linearized representation of computational graph.

class ffc.uflacs.analysis.graph_rebuild.ReconstructScalarSubexpressions[source]

Bases: ufl.corealg.multifunction.MultiFunction

abs(o, ops)
atan_2(o, ops)
bessel_function(o, ops)
component_tensor(o, *args, **kwargs)
condition(o, ops)[source]
conditional(o, ops)[source]
division(o, ops)[source]
expr(o, *args, **kwargs)[source]

Trigger error for types with missing handlers.

expr_list(o, *args, **kwargs)
expr_mapping(o, *args, **kwargs)
index_sum(o, ops)[source]
label(o, *args, **kwargs)
list_tensor(o, *args, **kwargs)
math_function(o, ops)
max_value(o, ops)
min_value(o, ops)
multi_index(o, *args, **kwargs)
power(o, ops)
product(o, ops)[source]
scalar_nary(o, ops)[source]
sum(o, ops)[source]
terminal(o)[source]
transposed(o, *args, **kwargs)
unexpected(o, *args, **kwargs)[source]
utility_type(o, *args, **kwargs)
variable(o, *args, **kwargs)
ffc.uflacs.analysis.graph_rebuild.rebuild_expression_from_graph(G)[source]

This is currently only used by tests.

ffc.uflacs.analysis.graph_rebuild.rebuild_with_scalar_subexpressions(G, targets=None)[source]

Build a new expression2index mapping where each subexpression is scalar valued.

Input: - G.e2i - G.V - G.V_symbols - G.total_unique_symbols

Output: - NV - Array with reverse mapping from index to expression - nvs - Tuple of ne2i indices corresponding to the last vertex of G.V

Old output now no longer returned but possible to restore if needed: - ne2i - Mapping from scalar subexpressions to a contiguous unique index - W - Array with reconstructed scalar subexpressions for each original symbol

ffc.uflacs.analysis.graph_ssa module

Algorithms for working with computational graphs.

ffc.uflacs.analysis.graph_ssa.allocate_registers(active, partitions, targets, scores, max_registers, score_threshold)[source]

FIXME: Cover with tests.

TODO: Allow reuse of registers, reducing memory usage.

TODO: Probably want to sort within partitions.

ffc.uflacs.analysis.graph_ssa.compute_cache_scores(V, active, dependencies, inverse_dependencies, partitions, cache_score_policy=<function default_cache_score_policy>)[source]

FIXME: Cover with tests.

TODO: Experiment with heuristics later when we have functional code generation.

ffc.uflacs.analysis.graph_ssa.compute_dependency_count(dependencies)[source]

FIXME: Test

ffc.uflacs.analysis.graph_ssa.default_cache_score_policy(vtype, ndeps, ninvdeps, partition)[source]
ffc.uflacs.analysis.graph_ssa.default_partition_seed(expr, rank)[source]

Partition 0: Piecewise constant on each cell (including Real and DG0 coefficients) Partition 1: Depends on x Partition 2: Depends on x and coefficients Partitions [3,3+rank): depend on argument with count partition-3

ffc.uflacs.analysis.graph_ssa.invert_dependencies(dependencies, depcount)[source]

FIXME: Test

ffc.uflacs.analysis.graph_ssa.mark_partitions(V, active, dependencies, rank, partition_seed=<function default_partition_seed>, partition_combiner=<built-in function max>)[source]

FIXME: Cover this with tests.

Input: - V - Array of expressions. - active - Boolish array. - dependencies - CRSArray with V dependencies. - partition_seed - Policy for determining the partition of a terminalish. - partition_combiner - Policy for determinging the partition of an operator.

Output: - partitions - Array of partition int ids.

ffc.uflacs.analysis.graph_symbols module

Assigning symbols to computational graph nodes.

ffc.uflacs.analysis.graph_symbols.build_graph_symbols(V, e2i, DEBUG)[source]

Tabulate scalar value numbering of all nodes in a a list based representation of an expression graph.

Returns: V_shapes - CRSArray of the total shapes of nodes in V. V_symbols - CRSArray of symbols (value numbers) of each component of each node in V. total_unique_symbols - The number of symbol values assigned to unique scalar components of the nodes in V.

ffc.uflacs.analysis.graph_symbols.build_node_shapes(V)[source]

Build total shapes for each node in list representation of expression graph.

V is an array of ufl expressions, possibly nonscalar and with free indices.

Returning a CRSArray where row i is the total shape of V[i].

ffc.uflacs.analysis.graph_symbols.build_node_sizes(V_shapes)[source]

Compute all the products of a sequence of shapes.

ffc.uflacs.analysis.graph_symbols.build_node_symbols(V, e2i, V_shapes, V_sizes)[source]

Tabulate scalar value numbering of all nodes in a a list based representation of an expression graph.

Returns: V_symbols - CRSArray of symbols (value numbers) of each component of each node in V. total_unique_symbols - The number of symbol values assigned to unique scalar components of the nodes in V.

ffc.uflacs.analysis.graph_vertices module

Algorithms for working with graphs.

ffc.uflacs.analysis.graph_vertices.build_array_from_counts(e2i)[source]
ffc.uflacs.analysis.graph_vertices.build_graph_vertices(expressions)[source]
ffc.uflacs.analysis.graph_vertices.build_node_counts(expressions)[source]
ffc.uflacs.analysis.graph_vertices.build_scalar_graph_vertices(expressions)[source]
ffc.uflacs.analysis.graph_vertices.build_scalar_node_counts(expressions)[source]
ffc.uflacs.analysis.graph_vertices.count_nodes_with_unique_post_traversal(expr, e2i=None, skip_terminal_modifiers=False)[source]

Yields o for each node o in expr, child before parent. Never visits a node twice.

ffc.uflacs.analysis.indexing module

Algorithms for working with multiindices.

ffc.uflacs.analysis.indexing.map_component_tensor_arg_components(tensor)[source]

Build integer list mapping between flattended components of tensor and its underlying indexed subexpression.

ffc.uflacs.analysis.indexing.map_indexed_arg_components(indexed)[source]

Build integer list mapping between flattended components of indexed expression and its underlying tensor-valued subexpression.

ffc.uflacs.analysis.modified_terminals module

Definitions of ‘modified terminals’, a core concept in uflacs.

class ffc.uflacs.analysis.modified_terminals.ModifiedTerminal(expr, terminal, reference_value, base_shape, base_symmetry, component, flat_component, global_derivatives, local_derivatives, averaged, restriction)[source]

Bases: object

A modified terminal expression is an object of a Terminal subtype, wrapped in terminal modifier types.

The variables of this class are:

expr - The original UFL expression terminal - the underlying Terminal object

global_derivatives - tuple of ints, each meaning derivative in that global direction local_derivatives - tuple of ints, each meaning derivative in that local direction reference_value - bool, whether this is represented in reference frame averaged - None, ‘facet’ or ‘cell’ restriction - None, ‘+’ or ‘-‘

component - tuple of ints, the global component of the Terminal flat_component - single int, flattened local component of the Terminal, considering symmetry

Possibly other component model: - global_component - reference_component - flat_component

argument_ordering_key()[source]

Return a key for deterministic sorting of argument vertex indices based on the properties of the modified terminal. Used in factorization but moved here for closeness with ModifiedTerminal attributes.

as_tuple()[source]

Return a tuple with hashable values that uniquely identifies this modified terminal.

Some of the derived variables can be omitted here as long as they are fully determined from the variables that are included here.

ffc.uflacs.analysis.modified_terminals.analyse_modified_terminal(expr)[source]

Analyse a so-called ‘modified terminal’ expression.

Return its properties in more compact form as a ModifiedTerminal object.

A modified terminal expression is an object of a Terminal subtype, wrapped in terminal modifier types.

The wrapper types can include 0-* Grad or ReferenceGrad objects, and 0-1 ReferenceValue, 0-1 Restricted, 0-1 Indexed, and 0-1 FacetAvg or CellAvg objects.

ffc.uflacs.analysis.modified_terminals.is_modified_terminal(v)[source]

Check if v is a terminal or a terminal wrapped in terminal modifier types.

ffc.uflacs.analysis.modified_terminals.strip_modified_terminal(v)[source]

Extract core Terminal from a modified terminal or return None.

ffc.uflacs.analysis.valuenumbering module

Algorithms for value numbering within computational graphs.

class ffc.uflacs.analysis.valuenumbering.ValueNumberer(e2i, V_sizes, V_symbols)[source]

Bases: ufl.corealg.multifunction.MultiFunction

An algorithm to map the scalar components of an expression node to unique value numbers, with fallthrough for types that can be mapped to the value numbers of their operands.

cell_avg(v, i)

Modifiers: terminal - the underlying Terminal object global_derivatives - tuple of ints, each meaning derivative in that global direction local_derivatives - tuple of ints, each meaning derivative in that local direction reference_value - bool, whether this is represented in reference frame averaged - None, ‘facet’ or ‘cell’ restriction - None, ‘+’ or ‘-‘ component - tuple of ints, the global component of the Terminal flat_component - single int, flattened local component of the Terminal, considering symmetry

component_tensor(A, i)[source]
expr(v, i)[source]

Create new symbols for expressions that represent new values.

facet_avg(v, i)

Modifiers: terminal - the underlying Terminal object global_derivatives - tuple of ints, each meaning derivative in that global direction local_derivatives - tuple of ints, each meaning derivative in that local direction reference_value - bool, whether this is represented in reference frame averaged - None, ‘facet’ or ‘cell’ restriction - None, ‘+’ or ‘-‘ component - tuple of ints, the global component of the Terminal flat_component - single int, flattened local component of the Terminal, considering symmetry

form_argument(v, i)[source]

Create new symbols for expressions that represent new values.

get_node_symbols(expr)[source]
grad(v, i)

Modifiers: terminal - the underlying Terminal object global_derivatives - tuple of ints, each meaning derivative in that global direction local_derivatives - tuple of ints, each meaning derivative in that local direction reference_value - bool, whether this is represented in reference frame averaged - None, ‘facet’ or ‘cell’ restriction - None, ‘+’ or ‘-‘ component - tuple of ints, the global component of the Terminal flat_component - single int, flattened local component of the Terminal, considering symmetry

indexed(Aii, i)[source]
list_tensor(v, i)[source]
new_symbol()[source]

Generator for new symbols with a running counter.

new_symbols(n)[source]

Generator for new symbols with a running counter.

reference_grad(v, i)

Modifiers: terminal - the underlying Terminal object global_derivatives - tuple of ints, each meaning derivative in that global direction local_derivatives - tuple of ints, each meaning derivative in that local direction reference_value - bool, whether this is represented in reference frame averaged - None, ‘facet’ or ‘cell’ restriction - None, ‘+’ or ‘-‘ component - tuple of ints, the global component of the Terminal flat_component - single int, flattened local component of the Terminal, considering symmetry

reference_value(v, i)

Modifiers: terminal - the underlying Terminal object global_derivatives - tuple of ints, each meaning derivative in that global direction local_derivatives - tuple of ints, each meaning derivative in that local direction reference_value - bool, whether this is represented in reference frame averaged - None, ‘facet’ or ‘cell’ restriction - None, ‘+’ or ‘-‘ component - tuple of ints, the global component of the Terminal flat_component - single int, flattened local component of the Terminal, considering symmetry

restricted(v, i)

Modifiers: terminal - the underlying Terminal object global_derivatives - tuple of ints, each meaning derivative in that global direction local_derivatives - tuple of ints, each meaning derivative in that local direction reference_value - bool, whether this is represented in reference frame averaged - None, ‘facet’ or ‘cell’ restriction - None, ‘+’ or ‘-‘ component - tuple of ints, the global component of the Terminal flat_component - single int, flattened local component of the Terminal, considering symmetry

variable(v, i)[source]

Direct reuse of all symbols.

Module contents

Algorithms for the analysis phase of the form compilation.

ffc.uflacs.backends package
Subpackages
ffc.uflacs.backends.ffc package
Submodules
ffc.uflacs.backends.ffc.access module

FFC/UFC specific variable access.

class ffc.uflacs.backends.ffc.access.FFCBackendAccess(ir, language, symbols, parameters)[source]

Bases: ufl.corealg.multifunction.MultiFunction

FFC specific cpp formatter class.

cell_coordinate(e, mt, tabledata, num_points)[source]
cell_edge_vectors(e, mt, tabledata, num_points)[source]
cell_facet_jacobian(e, mt, tabledata, num_points)[source]
cell_normal(e, mt, tabledata, num_points)
cell_orientation(e, mt, tabledata, num_points)[source]
cell_vertices(e, mt, tabledata, num_points)[source]
coefficient(e, mt, tabledata, num_points)[source]
expr(e, mt, tabledata, num_points)[source]

Trigger error for types with missing handlers.

facet_coordinate(e, mt, tabledata, num_points)[source]
facet_edge_vectors(e, mt, tabledata, num_points)[source]
facet_jacobian(e, mt, tabledata, num_points)
facet_jacobian_determinant(e, mt, tabledata, num_points)
facet_jacobian_inverse(e, mt, tabledata, num_points)
facet_normal(e, mt, tabledata, num_points)
facet_orientation(e, mt, tabledata, num_points)[source]
float_value(e, mt, tabledata, num_points)[source]
int_value(e, mt, tabledata, num_points)[source]
jacobian(e, mt, tabledata, num_points)[source]
jacobian_determinant(e, mt, tabledata, num_points)
jacobian_inverse(e, mt, tabledata, num_points)
reference_cell_edge_vectors(e, mt, tabledata, num_points)[source]
reference_cell_volume(e, mt, tabledata, access)[source]
reference_facet_edge_vectors(e, mt, tabledata, num_points)[source]
reference_facet_volume(e, mt, tabledata, access)[source]
reference_normal(e, mt, tabledata, access)[source]
spatial_coordinate(e, mt, tabledata, num_points)[source]
zero(e, mt, tabledata, num_points)[source]
ffc.uflacs.backends.ffc.backend module

Collection of FFC specific pieces for the code generation phase.

class ffc.uflacs.backends.ffc.backend.FFCBackend(ir, parameters)[source]

Bases: object

Class collecting all aspects of the FFC backend.

ffc.uflacs.backends.ffc.common module

FFC/UFC specific symbol naming.

ffc.uflacs.backends.ffc.common.num_coordinate_component_dofs(coordinate_element)[source]

Get the number of dofs for a coordinate component for this degree.

This is a local hack that works for Lagrange 1-3, better would be to get this passed by ffc from fiat through the ir. The table data is to messy to figure out a clean design for that quickly.

ffc.uflacs.backends.ffc.common.ufc_restriction_offset(restriction, length)[source]
ffc.uflacs.backends.ffc.definitions module

FFC/UFC specific variable definitions.

class ffc.uflacs.backends.ffc.definitions.FFCBackendDefinitions(ir, language, symbols, parameters)[source]

Bases: ufl.corealg.multifunction.MultiFunction

FFC specific code definitions.

argument(t, mt, tabledata, num_points, access)[source]

Arguments are accessed through element tables.

cell_coordinate(e, mt, tabledata, num_points, access)[source]

Return definition code for the reference spatial coordinates.

If reference coordinates are given:

No definition needed.

If physical coordinates are given and domain is affine:

X = K*(x-x0)

This is inserted symbolically.

If physical coordinates are given and domain is non- affine:

Not currently supported.
cell_edge_vectors(e, mt, tabledata, num_points, access)

These quantities refer to coordinate_dofs

cell_facet_jacobian(e, mt, tabledata, num_points, access)

These quantities refer to constant tables defined in ufc_geometry.h.

cell_normal(e, mt, tabledata, num_points, access)

These quantities are expected to be replaced in symbolic preprocessing.

cell_orientation(e, mt, tabledata, num_points, access)[source]
cell_vertices(e, mt, tabledata, num_points, access)

These quantities refer to coordinate_dofs

coefficient(t, mt, tabledata, num_points, access)[source]

Return definition code for coefficients.

constant_value(e, mt, tabledata, num_points, access)[source]

Constants simply use literals in the target language.

expr(t, mt, tabledata, num_points, access)[source]

Trigger error for types with missing handlers.

facet_edge_vectors(e, mt, tabledata, num_points, access)

These quantities refer to coordinate_dofs

facet_jacobian(e, mt, tabledata, num_points, access)

These quantities are expected to be replaced in symbolic preprocessing.

facet_jacobian_determinant(e, mt, tabledata, num_points, access)

These quantities are expected to be replaced in symbolic preprocessing.

facet_jacobian_inverse(e, mt, tabledata, num_points, access)

These quantities are expected to be replaced in symbolic preprocessing.

facet_normal(e, mt, tabledata, num_points, access)

These quantities are expected to be replaced in symbolic preprocessing.

facet_orientation(e, mt, tabledata, num_points, access)

These quantities refer to constant tables defined in ufc_geometry.h.

jacobian(e, mt, tabledata, num_points, access)[source]

Return definition code for the Jacobian of x(X).

J = sum_k xdof_k grad_X xphi_k(X)

jacobian_determinant(e, mt, tabledata, num_points, access)

These quantities are expected to be replaced in symbolic preprocessing.

jacobian_inverse(e, mt, tabledata, num_points, access)

These quantities are expected to be replaced in symbolic preprocessing.

reference_cell_edge_vectors(e, mt, tabledata, num_points, access)

These quantities refer to constant tables defined in ufc_geometry.h.

reference_cell_volume(e, mt, tabledata, num_points, access)

These quantities refer to constant tables defined in ufc_geometry.h.

reference_facet_edge_vectors(e, mt, tabledata, num_points, access)

These quantities refer to constant tables defined in ufc_geometry.h.

reference_facet_volume(e, mt, tabledata, num_points, access)

These quantities refer to constant tables defined in ufc_geometry.h.

reference_normal(e, mt, tabledata, num_points, access)

These quantities refer to constant tables defined in ufc_geometry.h.

spatial_coordinate(e, mt, tabledata, num_points, access)[source]

Return definition code for the physical spatial coordinates.

If physical coordinates are given:
No definition needed.
If reference coordinates are given:
x = sum_k xdof_k xphi_k(X)
If reference facet coordinates are given:
x = sum_k xdof_k xphi_k(Xf)
ffc.uflacs.backends.ffc.symbols module

FFC/UFC specific symbol naming.

class ffc.uflacs.backends.ffc.symbols.FFCBackendSymbols(language, coefficient_numbering)[source]

Bases: object

FFC specific symbol definitions. Provides non-ufl symbols.

J_component(mt)[source]

Jacobian component.

X_component(mt)[source]

Reference coordinate component.

argument_loop_index(iarg)[source]

Loop index for argument #iarg.

cell_orientation_argument(restriction)[source]

Cell orientation argument in ufc. Not same as cell orientation in generated code.

cell_orientation_internal(restriction)[source]

Internal value for cell orientation in generated code.

coefficient_dof_access(coefficient, dof_number)[source]
coefficient_dof_sum_index()[source]

Index for loops over coefficient dofs, assumed to never be used in two nested loops.

coefficient_value(mt)[source]

Symbol for variable holding value or derivative component of coefficient.

custom_points_table()[source]

Table for chunk of custom quadrature points (physical coordinates).

custom_quadrature_points()[source]

Physical quadrature points, argument to custom integrals.

custom_quadrature_weights()[source]

Quadrature weights including cell measure scaling, argument to custom integrals.

custom_weights_table()[source]

Table for chunk of custom quadrature weights (including cell measure scaling).

domain_dof_access(dof, component, gdim, num_scalar_dofs, restriction)[source]
domain_dofs_access(gdim, num_scalar_dofs, restriction)[source]
element_table(tabledata, entitytype, restriction)[source]
element_tensor()[source]

Symbol for the element tensor itself.

entity(entitytype, restriction)[source]

Entity index for lookup in element tables.

num_custom_quadrature_points()[source]

Number of quadrature points, argument to custom integrals.

points_table(num_points)[source]

Table of quadrature points (points on the reference integration entity).

quadrature_loop_index()[source]

Reusing a single index name for all quadrature loops, assumed not to be nested.

weights_table(num_points)[source]

Table of quadrature weights.

x_component(mt)[source]

Physical coordinate component.

ffc.uflacs.backends.ffc.symbols.format_mt_name(basename, mt)[source]

Format variable name for modified terminal.

ffc.uflacs.backends.ffc.symbols.ufc_restriction_postfix(restriction)[source]
Module contents

The FFC specific backend to the UFLACS form compiler algorithms.

ffc.uflacs.backends.ufc package
Submodules
ffc.uflacs.backends.ufc.apply_mappings module
ffc.uflacs.backends.ufc.coordinate_mapping module
ffc.uflacs.backends.ufc.coordinate_mapping.adj_expr_2x2(A)[source]
ffc.uflacs.backends.ufc.coordinate_mapping.adj_expr_3x3(A)[source]
ffc.uflacs.backends.ufc.coordinate_mapping.codet_nn(A, rows, cols)[source]
ffc.uflacs.backends.ufc.coordinate_mapping.cross_expr(a, b)[source]
ffc.uflacs.backends.ufc.coordinate_mapping.det_22(B, i, j, k, l)[source]
ffc.uflacs.backends.ufc.coordinate_mapping.det_nn(A, n)[source]
ffc.uflacs.backends.ufc.coordinate_mapping.generate_assign_inverse(L, K, J, detJ, gdim, tdim)[source]
ffc.uflacs.backends.ufc.coordinate_mapping.generate_compute_ATA(L, ATA, A, m, n, index_prefix='')[source]

Generate code to declare and compute ATA[i,j] = sum_k A[k,i]*A[k,j] with given A shaped (m,n).

ffc.uflacs.backends.ufc.coordinate_mapping.generate_cross_decl(c, a, b)[source]
ffc.uflacs.backends.ufc.coordinate_mapping.pdet_m1(L, A, m)[source]
class ffc.uflacs.backends.ufc.coordinate_mapping.ufc_coordinate_mapping[source]

Bases: ffc.uflacs.backends.ufc.generator.ufc_generator

Each function maps to a keyword in the template. See documentation of ufc_generator.

cell_shape(L, ir)[source]
compute_geometry(L, ir)[source]
compute_jacobian_determinants(L, ir)[source]
compute_jacobian_inverses(L, ir)[source]
compute_jacobians(L, ir)[source]
compute_midpoint_geometry(L, ir)[source]
compute_physical_coordinates(L, ir)[source]
compute_reference_coordinates(L, ir)[source]
compute_reference_geometry(L, ir)[source]
create_coordinate_dofmap(L, ir)[source]
create_coordinate_finite_element(L, ir)[source]
geometric_dimension(L, geometric_dimension)[source]
topological_dimension(L, topological_dimension)[source]
ffc.uflacs.backends.ufc.dofmap module
class ffc.uflacs.backends.ufc.dofmap.ufc_dofmap[source]

Bases: ffc.uflacs.backends.ufc.generator.ufc_generator

Each function maps to a keyword in the template. See documentation of ufc_generator.

create_sub_dofmap(L, ir)[source]
global_dimension(L, ir)[source]
needs_mesh_entities(L, needs_mesh_entities)[source]

needs_mesh_entities is a list of num dofs per entity.

num_element_dofs(L, num_element_dofs)[source]
num_element_support_dofs(L, num_element_support_dofs)[source]
num_entity_closure_dofs(L, num_entity_closure_dofs)[source]
num_entity_dofs(L, num_entity_dofs)[source]
num_facet_dofs(L, num_facet_dofs)[source]
num_global_support_dofs(L, num_global_support_dofs)[source]
num_sub_dofmaps(L, num_sub_dofmaps)[source]
tabulate_dofs(L, ir)[source]
tabulate_entity_closure_dofs(L, ir)[source]
tabulate_entity_dofs(L, ir)[source]
tabulate_facet_dofs(L, ir)[source]
topological_dimension(L, topological_dimension)[source]
ffc.uflacs.backends.ufc.evalderivs module

Work in progress translation of FFC evaluatebasis code to uflacs CNodes format.

ffc.uflacs.backends.ufc.evalderivs.generate_evaluate_reference_basis_derivatives(L, data, parameters)[source]
ffc.uflacs.backends.ufc.evalderivs.generate_tabulate_dmats(L, dofs_data)[source]

Tabulate the derivatives of the polynomial base

ffc.uflacs.backends.ufc.evaluatebasis module

Work in progress translation of FFC evaluatebasis code to uflacs CNodes format.

ffc.uflacs.backends.ufc.evaluatebasis.generate_compute_basisvalues(L, dofs_data, element_cellname, tdim, X, ip)[source]
ffc.uflacs.backends.ufc.evaluatebasis.generate_evaluate_reference_basis(L, data, parameters)[source]

Generate code to evaluate element basisfunctions at an arbitrary point on the reference element.

The value(s) of the basisfunction is/are computed as in FIAT as the dot product of the coefficients (computed at compile time) and basisvalues which are dependent on the coordinate and thus have to be computed at run time.

The function should work for all elements supported by FIAT, but it remains untested for tensor valued elements.

This code is adapted from code in FFC which computed the basis from physical coordinates, and also to use UFLACS utilities.

The FFC code has a comment “From FIAT_NEW.polynomial_set.tabulate()”.

ffc.uflacs.backends.ufc.evaluatebasis.generate_expansion_coefficients(L, dofs_data)[source]
ffc.uflacs.backends.ufc.evaluatebasis.tabulate_coefficients(L, dof_data)[source]

This function tabulates the element coefficients that are generated by FIAT at compile time.

ffc.uflacs.backends.ufc.evaluatebasisderivatives module

Work in progress translation of FFC evaluatebasisderivatives code to uflacs CNodes format.

ffc.uflacs.backends.ufc.evaluatebasisderivatives.generate_evaluate_basis_derivatives(L, data)[source]

Evaluate the derivatives of an element basisfunction at a point. The values are computed as in FIAT as the matrix product of the coefficients (computed at compile time), basisvalues which are dependent on the coordinate and thus have to be computed at run time and combinations (depending on the order of derivative) of dmats tables which hold the derivatives of the expansion coefficients.

ffc.uflacs.backends.ufc.evaluatebasisderivatives.generate_evaluate_basis_derivatives_all(L, data)[source]

Like evaluate_basis, but return the values of all basis functions (dofs).

ffc.uflacs.backends.ufc.evaluatedof module
ffc.uflacs.backends.ufc.evaluatedof.generate_evaluate_dof(L, ir)[source]

Generate code for evaluate_dof.

ffc.uflacs.backends.ufc.evaluatedof.generate_evaluate_dofs(L, ir)[source]

Generate code for evaluate_dofs.

ffc.uflacs.backends.ufc.evaluatedof.reference_to_physical_map(cellname)[source]

Returns a map from reference coordinates to physical element coordinates

ffc.uflacs.backends.ufc.finite_element module
ffc.uflacs.backends.ufc.finite_element.compute_basis_values(L, data, dof_data)[source]
ffc.uflacs.backends.ufc.finite_element.compute_values(L, data, dof_data)[source]

This function computes the value of the basisfunction as the dot product of the coefficients and basisvalues.

ffc.uflacs.backends.ufc.finite_element.generate_element_mapping(mapping, i, num_reference_components, tdim, gdim, J, detJ, K)[source]
class ffc.uflacs.backends.ufc.finite_element.ufc_finite_element[source]

Bases: ffc.uflacs.backends.ufc.generator.ufc_generator

Each function maps to a keyword in the template. See documentation of ufc_generator.

cell_shape(L, cell_shape)[source]
create_sub_element(L, ir)[source]
degree(L, degree)[source]
evaluate_basis(L, ir, parameters)[source]
evaluate_basis_all(L, ir, parameters)[source]
evaluate_basis_derivatives(L, ir, parameters)[source]
evaluate_basis_derivatives_all(L, ir, parameters)[source]
evaluate_dof(L, ir, parameters)[source]
evaluate_dofs(L, ir, parameters)[source]

Generate code for evaluate_dofs.

evaluate_reference_basis(L, ir, parameters)[source]
evaluate_reference_basis_derivatives(L, ir, parameters)[source]
family(L, family)[source]
geometric_dimension(L, geometric_dimension)[source]
interpolate_vertex_values(L, ir, parameters)[source]
num_sub_elements(L, num_sub_elements)[source]
reference_value_dimension(L, reference_value_shape)[source]
reference_value_rank(L, reference_value_shape)[source]
reference_value_size(L, reference_value_shape)[source]
space_dimension(L, space_dimension)[source]
tabulate_dof_coordinates(L, ir, parameters)[source]
tabulate_reference_dof_coordinates(L, ir, parameters)[source]
topological_dimension(L, topological_dimension)[source]
transform_reference_basis_derivatives(L, ir, parameters)[source]
value_dimension(L, value_shape)[source]
value_rank(L, value_shape)[source]
value_size(L, value_shape)[source]
ffc.uflacs.backends.ufc.form module
ffc.uflacs.backends.ufc.form.add_ufc_form_integral_methods(cls)[source]

This function generates methods on the class it decorates, for each integral name template and for each integral type.

This allows implementing e.g. create_###_integrals once in the decorated class as ‘_create_foo_integrals’, and this function will expand that implementation into ‘create_cell_integrals’, ‘create_exterior_facet_integrals’, etc.

Name templates are taken from ‘integral_name_templates’ and ‘ufc_integral_types’.

ffc.uflacs.backends.ufc.form.create_delegate(integral_type, declname, impl)[source]
class ffc.uflacs.backends.ufc.form.ufc_form[source]

Bases: ffc.uflacs.backends.ufc.generator.ufc_generator

Each function maps to a keyword in the template. See documentation of ufc_generator.

The exceptions are functions on the form
def _*_foo_*(self, L, ir, parameters, integral_type, declname)

which add_ufc_form_integral_methods will duplicate for foo = each integral type.

create_cell_integral(L, ir, parameters)

Return implementation of ufc::form::create_cell_integral().

create_coordinate_dofmap(L, ir)[source]
create_coordinate_finite_element(L, ir)[source]
create_coordinate_mapping(L, ir)[source]
create_custom_integral(L, ir, parameters)

Return implementation of ufc::form::create_custom_integral().

create_cutcell_integral(L, ir, parameters)

Return implementation of ufc::form::create_cutcell_integral().

create_default_cell_integral(L, ir, parameters)

Return implementation of ufc::form::create_default_cell_integral().

create_default_custom_integral(L, ir, parameters)

Return implementation of ufc::form::create_default_custom_integral().

create_default_cutcell_integral(L, ir, parameters)

Return implementation of ufc::form::create_default_cutcell_integral().

create_default_exterior_facet_integral(L, ir, parameters)

Return implementation of ufc::form::create_default_exterior_facet_integral().

create_default_interface_integral(L, ir, parameters)

Return implementation of ufc::form::create_default_interface_integral().

create_default_interior_facet_integral(L, ir, parameters)

Return implementation of ufc::form::create_default_interior_facet_integral().

create_default_overlap_integral(L, ir, parameters)

Return implementation of ufc::form::create_default_overlap_integral().

create_default_vertex_integral(L, ir, parameters)

Return implementation of ufc::form::create_default_vertex_integral().

create_dofmap(L, ir)[source]
create_exterior_facet_integral(L, ir, parameters)

Return implementation of ufc::form::create_exterior_facet_integral().

create_finite_element(L, ir)[source]
create_interface_integral(L, ir, parameters)

Return implementation of ufc::form::create_interface_integral().

create_interior_facet_integral(L, ir, parameters)

Return implementation of ufc::form::create_interior_facet_integral().

create_overlap_integral(L, ir, parameters)

Return implementation of ufc::form::create_overlap_integral().

create_vertex_integral(L, ir, parameters)

Return implementation of ufc::form::create_vertex_integral().

has_cell_integrals(L, ir, parameters)

Return implementation of ufc::form::has_cell_integrals().

has_custom_integrals(L, ir, parameters)

Return implementation of ufc::form::has_custom_integrals().

has_cutcell_integrals(L, ir, parameters)

Return implementation of ufc::form::has_cutcell_integrals().

has_exterior_facet_integrals(L, ir, parameters)

Return implementation of ufc::form::has_exterior_facet_integrals().

has_interface_integrals(L, ir, parameters)

Return implementation of ufc::form::has_interface_integrals().

has_interior_facet_integrals(L, ir, parameters)

Return implementation of ufc::form::has_interior_facet_integrals().

has_overlap_integrals(L, ir, parameters)

Return implementation of ufc::form::has_overlap_integrals().

has_vertex_integrals(L, ir, parameters)

Return implementation of ufc::form::has_vertex_integrals().

max_cell_subdomain_id(L, ir, parameters)

Return implementation of ufc::form::max_cell_subdomain_id().

max_custom_subdomain_id(L, ir, parameters)

Return implementation of ufc::form::max_custom_subdomain_id().

max_cutcell_subdomain_id(L, ir, parameters)

Return implementation of ufc::form::max_cutcell_subdomain_id().

max_exterior_facet_subdomain_id(L, ir, parameters)

Return implementation of ufc::form::max_exterior_facet_subdomain_id().

max_interface_subdomain_id(L, ir, parameters)

Return implementation of ufc::form::max_interface_subdomain_id().

max_interior_facet_subdomain_id(L, ir, parameters)

Return implementation of ufc::form::max_interior_facet_subdomain_id().

max_overlap_subdomain_id(L, ir, parameters)

Return implementation of ufc::form::max_overlap_subdomain_id().

max_vertex_subdomain_id(L, ir, parameters)

Return implementation of ufc::form::max_vertex_subdomain_id().

num_coefficients(L, num_coefficients)[source]
original_coefficient_position(L, ir)[source]
rank(L, rank)[source]
ffc.uflacs.backends.ufc.generator module
class ffc.uflacs.backends.ufc.generator.ufc_generator(basename)[source]

Bases: object

Common functionality for code generators producing ufc classes.

The generate function is the driver for generating code for a class. It automatically extracts each template keyword %(foo)s and calls self.foo(…) to define the code snippet for that keyword.

The standard arguments to every self.foo(…) function are: - L (the language module reference) - ir (the full ir dict) - parameters (the parameters dict, can be omitted) If the second argument is not named “ir”, it must be a valid key in ir, and the value of ir[keyname] is passed instead of the full ir dict. Invalid keynames result in attempts at informative errors, meaning errors will often be caught early when making changes.

classname(L, ir)[source]

Return classname.

constructor(L, ir)[source]

Return empty string. Override in classes that need constructor.

constructor_arguments(L, ir)[source]

Return empty string. Override in classes that need constructor.

create(L, ir)[source]

Default implementation of creating a new object of the same type.

destructor(L, ir)[source]

Return empty string. Override in classes that need destructor.

generate(L, ir, parameters=None, snippets=None, jit=False)[source]

Return composition of templates with generated snippets.

generate_snippets(L, ir, parameters)[source]

Generate code snippets for each keyword found in templates.

initializer_list(L, ir)[source]

Return empty string. Override in classes that need constructor.

members(L, ir)[source]

Return empty string. Override in classes that need members.

signature(L, ir)[source]

Default implementation of returning signature string fetched from ir.

ffc.uflacs.backends.ufc.generators module
ffc.uflacs.backends.ufc.integrals module
class ffc.uflacs.backends.ufc.integrals.ufc_cell_integral[source]

Bases: ffc.uflacs.backends.ufc.integrals.ufc_integral

class ffc.uflacs.backends.ufc.integrals.ufc_custom_integral[source]

Bases: ffc.uflacs.backends.ufc.integrals.ufc_integral

num_cells(L, ir)[source]
class ffc.uflacs.backends.ufc.integrals.ufc_cutcell_integral[source]

Bases: ffc.uflacs.backends.ufc.integrals.ufc_integral

class ffc.uflacs.backends.ufc.integrals.ufc_exterior_facet_integral[source]

Bases: ffc.uflacs.backends.ufc.integrals.ufc_integral

class ffc.uflacs.backends.ufc.integrals.ufc_integral(integral_type)[source]

Bases: ffc.uflacs.backends.ufc.generator.ufc_generator

Each function maps to a keyword in the template. See documentation of ufc_generator.

enabled_coefficients(L, ir)[source]
tabulate_tensor(L, ir)[source]
tabulate_tensor_comment(L, ir)[source]

Generate comment for tabulate_tensor.

class ffc.uflacs.backends.ufc.integrals.ufc_interface_integral[source]

Bases: ffc.uflacs.backends.ufc.integrals.ufc_integral

class ffc.uflacs.backends.ufc.integrals.ufc_interior_facet_integral[source]

Bases: ffc.uflacs.backends.ufc.integrals.ufc_integral

class ffc.uflacs.backends.ufc.integrals.ufc_overlap_integral[source]

Bases: ffc.uflacs.backends.ufc.integrals.ufc_integral

class ffc.uflacs.backends.ufc.integrals.ufc_vertex_integral[source]

Bases: ffc.uflacs.backends.ufc.integrals.ufc_integral

ffc.uflacs.backends.ufc.jacobian module
ffc.uflacs.backends.ufc.jacobian.fiat_coordinate_mapping(L, cellname, gdim, ref_coord_symbol='Y')[source]
ffc.uflacs.backends.ufc.jacobian.inverse_jacobian(L, gdim, tdim, element_cellname)[source]
ffc.uflacs.backends.ufc.jacobian.jacobian(L, gdim, tdim, element_cellname)[source]
ffc.uflacs.backends.ufc.jacobian.orientation(L)[source]
ffc.uflacs.backends.ufc.templates module
ffc.uflacs.backends.ufc.templates.extract_keywords(template)[source]
ffc.uflacs.backends.ufc.utils module
ffc.uflacs.backends.ufc.utils.generate_error(L, msg, emit_warning)[source]
ffc.uflacs.backends.ufc.utils.generate_return_bool_switch(L, i, values, default)[source]
ffc.uflacs.backends.ufc.utils.generate_return_int_switch(L, i, values, default)[source]
ffc.uflacs.backends.ufc.utils.generate_return_literal_switch(L, i, values, default, literal_type, typename=None)[source]
ffc.uflacs.backends.ufc.utils.generate_return_new(L, classname, factory)[source]
ffc.uflacs.backends.ufc.utils.generate_return_new_switch(L, i, classnames, args=None, factory=False)[source]
ffc.uflacs.backends.ufc.utils.generate_return_sizet_switch(L, i, values, default)[source]
Module contents

Backend for generating UFC code.

Module contents

Collection of backends to UFLACS form compiler algorithms.

In the end we want to specify a clean and mature API here.

We may or may not want to move e.g. the FFC backend to FFC instead of having it here.

ffc.uflacs.language package
Submodules
ffc.uflacs.language.cnodes module
class ffc.uflacs.language.cnodes.Add(lhs, rhs)[source]

Bases: ffc.uflacs.language.cnodes.BinOp

op = '+'
precedence = 5
class ffc.uflacs.language.cnodes.AddressOf(arg)[source]

Bases: ffc.uflacs.language.cnodes.PrefixUnaryOp

op = '&'
precedence = 3
class ffc.uflacs.language.cnodes.And(lhs, rhs)[source]

Bases: ffc.uflacs.language.cnodes.BinOp

op = '&&'
precedence = 11
class ffc.uflacs.language.cnodes.ArrayAccess(array, indices)[source]

Bases: ffc.uflacs.language.cnodes.CExprOperator

array
ce_format(precision=None)[source]
indices
precedence = 2
class ffc.uflacs.language.cnodes.ArrayDecl(typename, symbol, sizes=None, values=None, alignas=None, padlen=0)[source]

Bases: ffc.uflacs.language.cnodes.CStatement

A declaration or definition of an array.

Note that just setting values=0 is sufficient to initialize the entire array to zero.

Otherwise use nested lists of lists to represent multidimensional array values to initialize to.

alignas
cs_format(precision=None)[source]

Return S: string | list(S) | Indented(S).

is_scoped = False
padlen
sizes
symbol
typename
values
class ffc.uflacs.language.cnodes.Assign(lhs, rhs)[source]

Bases: ffc.uflacs.language.cnodes.AssignOp

op = '='
class ffc.uflacs.language.cnodes.AssignAdd(lhs, rhs)[source]

Bases: ffc.uflacs.language.cnodes.AssignOp

op = '+='
class ffc.uflacs.language.cnodes.AssignAnd(lhs, rhs)[source]

Bases: ffc.uflacs.language.cnodes.AssignOp

op = '&&='
class ffc.uflacs.language.cnodes.AssignBitAnd(lhs, rhs)[source]

Bases: ffc.uflacs.language.cnodes.AssignOp

op = '&='
class ffc.uflacs.language.cnodes.AssignBitOr(lhs, rhs)[source]

Bases: ffc.uflacs.language.cnodes.AssignOp

op = '|='
class ffc.uflacs.language.cnodes.AssignBitXor(lhs, rhs)[source]

Bases: ffc.uflacs.language.cnodes.AssignOp

op = '^='
class ffc.uflacs.language.cnodes.AssignDiv(lhs, rhs)[source]

Bases: ffc.uflacs.language.cnodes.AssignOp

op = '/='
class ffc.uflacs.language.cnodes.AssignLShift(lhs, rhs)[source]

Bases: ffc.uflacs.language.cnodes.AssignOp

op = '<<='
class ffc.uflacs.language.cnodes.AssignMod(lhs, rhs)[source]

Bases: ffc.uflacs.language.cnodes.AssignOp

op = '%='
class ffc.uflacs.language.cnodes.AssignMul(lhs, rhs)[source]

Bases: ffc.uflacs.language.cnodes.AssignOp

op = '*='
class ffc.uflacs.language.cnodes.AssignOp(lhs, rhs)[source]

Bases: ffc.uflacs.language.cnodes.BinOp

Base class for assignment operators.

precedence = 13
sideeffect = True
class ffc.uflacs.language.cnodes.AssignOr(lhs, rhs)[source]

Bases: ffc.uflacs.language.cnodes.AssignOp

op = '||='
class ffc.uflacs.language.cnodes.AssignRShift(lhs, rhs)[source]

Bases: ffc.uflacs.language.cnodes.AssignOp

op = '>>='
class ffc.uflacs.language.cnodes.AssignSub(lhs, rhs)[source]

Bases: ffc.uflacs.language.cnodes.AssignOp

op = '-='
class ffc.uflacs.language.cnodes.BinOp(lhs, rhs)[source]

Bases: ffc.uflacs.language.cnodes.CExprOperator

ce_format(precision=None)[source]
lhs
rhs
class ffc.uflacs.language.cnodes.BitAnd(lhs, rhs)[source]

Bases: ffc.uflacs.language.cnodes.BinOp

op = '&'
precedence = 8
class ffc.uflacs.language.cnodes.BitNot(arg)[source]

Bases: ffc.uflacs.language.cnodes.PrefixUnaryOp

op = '~'
precedence = 3
class ffc.uflacs.language.cnodes.BitOr(lhs, rhs)[source]

Bases: ffc.uflacs.language.cnodes.BinOp

op = '|'
precedence = 10
class ffc.uflacs.language.cnodes.BitXor(lhs, rhs)[source]

Bases: ffc.uflacs.language.cnodes.BinOp

op = '^'
precedence = 9
class ffc.uflacs.language.cnodes.Break[source]

Bases: ffc.uflacs.language.cnodes.CStatement

cs_format(precision=None)[source]

Return S: string | list(S) | Indented(S).

is_scoped = True
class ffc.uflacs.language.cnodes.CExpr[source]

Bases: ffc.uflacs.language.cnodes.CNode

Base class for all C expressions.

All subtypes should define a ‘precedence’ class attribute.

ce_format(precision=None)[source]
class ffc.uflacs.language.cnodes.CExprLiteral[source]

Bases: ffc.uflacs.language.cnodes.CExprTerminal

A float or int literal value.

precedence = 0
class ffc.uflacs.language.cnodes.CExprOperator[source]

Bases: ffc.uflacs.language.cnodes.CExpr

Base class for all C expression operator.

sideeffect = False
class ffc.uflacs.language.cnodes.CExprTerminal[source]

Bases: ffc.uflacs.language.cnodes.CExpr

Base class for all C expression terminals.

sideeffect = False
class ffc.uflacs.language.cnodes.CNode[source]

Bases: object

Base class for all C AST nodes.

debug = False
class ffc.uflacs.language.cnodes.CStatement[source]

Bases: ffc.uflacs.language.cnodes.CNode

Base class for all C statements.

Subtypes do _not_ define a ‘precedence’ class attribute.

cs_format(precision=None)[source]

Return S: string | list(S) | Indented(S).

is_scoped = False
class ffc.uflacs.language.cnodes.Call(function, arguments=None)[source]

Bases: ffc.uflacs.language.cnodes.CExprOperator

arguments
ce_format(precision=None)[source]
function
precedence = 2
sideeffect = True
class ffc.uflacs.language.cnodes.Case(value)[source]

Bases: ffc.uflacs.language.cnodes.CStatement

cs_format(precision=None)[source]

Return S: string | list(S) | Indented(S).

is_scoped = False
value
class ffc.uflacs.language.cnodes.Comment(comment)[source]

Bases: ffc.uflacs.language.cnodes.CStatement

Line comment(s) used for annotating the generated code with human readable remarks.

comment
cs_format(precision=None)[source]

Return S: string | list(S) | Indented(S).

is_scoped = True
class ffc.uflacs.language.cnodes.Conditional(condition, true, false)[source]

Bases: ffc.uflacs.language.cnodes.CExprOperator

ce_format(precision=None)[source]
condition
false
precedence = 13
true
class ffc.uflacs.language.cnodes.Continue[source]

Bases: ffc.uflacs.language.cnodes.CStatement

cs_format(precision=None)[source]

Return S: string | list(S) | Indented(S).

is_scoped = True
class ffc.uflacs.language.cnodes.Default[source]

Bases: ffc.uflacs.language.cnodes.CStatement

cs_format(precision=None)[source]

Return S: string | list(S) | Indented(S).

is_scoped = False
class ffc.uflacs.language.cnodes.Dereference(arg)[source]

Bases: ffc.uflacs.language.cnodes.PrefixUnaryOp

op = '*'
precedence = 3
class ffc.uflacs.language.cnodes.Div(lhs, rhs)[source]

Bases: ffc.uflacs.language.cnodes.BinOp

op = '/'
precedence = 4
class ffc.uflacs.language.cnodes.Do(condition, body)[source]

Bases: ffc.uflacs.language.cnodes.CStatement

body
condition
cs_format(precision=None)[source]

Return S: string | list(S) | Indented(S).

is_scoped = True
class ffc.uflacs.language.cnodes.EQ(lhs, rhs)[source]

Bases: ffc.uflacs.language.cnodes.BinOp

op = '=='
precedence = 7
class ffc.uflacs.language.cnodes.Else(body)[source]

Bases: ffc.uflacs.language.cnodes.CStatement

body
cs_format(precision=None)[source]

Return S: string | list(S) | Indented(S).

is_scoped = True
class ffc.uflacs.language.cnodes.ElseIf(condition, body)[source]

Bases: ffc.uflacs.language.cnodes.CStatement

body
condition
cs_format(precision=None)[source]

Return S: string | list(S) | Indented(S).

is_scoped = True
class ffc.uflacs.language.cnodes.FlattenedArray(array, dummy=None, dims=None, strides=None, offset=None)[source]

Bases: object

Syntax carrying object only, will get translated on __getitem__ to ArrayAccess.

array
dims
offset
strides
class ffc.uflacs.language.cnodes.For(init, check, update, body, pragma=None)[source]

Bases: ffc.uflacs.language.cnodes.CStatement

body
check
cs_format(precision=None)[source]

Return S: string | list(S) | Indented(S).

init
is_scoped = True
pragma
update
class ffc.uflacs.language.cnodes.ForRange(index, begin, end, body, index_type='int', vectorize=None)[source]

Bases: ffc.uflacs.language.cnodes.CStatement

Slightly higher-level for loop assuming incrementing an index over a range.

begin
body
cs_format(precision=None)[source]

Return S: string | list(S) | Indented(S).

end
index
index_type
is_scoped = True
pragma
ffc.uflacs.language.cnodes.ForRanges(*ranges, **kwargs)[source]
class ffc.uflacs.language.cnodes.GE(lhs, rhs)[source]

Bases: ffc.uflacs.language.cnodes.BinOp

op = '>='
precedence = 6
class ffc.uflacs.language.cnodes.GT(lhs, rhs)[source]

Bases: ffc.uflacs.language.cnodes.BinOp

op = '>'
precedence = 6
class ffc.uflacs.language.cnodes.If(condition, body)[source]

Bases: ffc.uflacs.language.cnodes.CStatement

body
condition
cs_format(precision=None)[source]

Return S: string | list(S) | Indented(S).

is_scoped = True
class ffc.uflacs.language.cnodes.LE(lhs, rhs)[source]

Bases: ffc.uflacs.language.cnodes.BinOp

op = '<='
precedence = 6
class ffc.uflacs.language.cnodes.LT(lhs, rhs)[source]

Bases: ffc.uflacs.language.cnodes.BinOp

op = '<'
precedence = 6
class ffc.uflacs.language.cnodes.LiteralBool(value)[source]

Bases: ffc.uflacs.language.cnodes.CExprLiteral

A boolean literal value.

ce_format(precision=None)[source]
precedence = 0
value
class ffc.uflacs.language.cnodes.LiteralFloat(value)[source]

Bases: ffc.uflacs.language.cnodes.CExprLiteral

A floating point literal value.

ce_format(precision=None)[source]
precedence = 0
value
class ffc.uflacs.language.cnodes.LiteralInt(value)[source]

Bases: ffc.uflacs.language.cnodes.CExprLiteral

An integer literal value.

ce_format(precision=None)[source]
precedence = 0
value
class ffc.uflacs.language.cnodes.LiteralString(value)[source]

Bases: ffc.uflacs.language.cnodes.CExprLiteral

A boolean literal value.

ce_format(precision=None)[source]
precedence = 0
value
ffc.uflacs.language.cnodes.MemCopy(src, dst, size)[source]
ffc.uflacs.language.cnodes.MemZero(name, size)[source]
ffc.uflacs.language.cnodes.MemZeroRange(name, begin, end)[source]
class ffc.uflacs.language.cnodes.Mod(lhs, rhs)[source]

Bases: ffc.uflacs.language.cnodes.BinOp

op = '%'
precedence = 4
class ffc.uflacs.language.cnodes.Mul(lhs, rhs)[source]

Bases: ffc.uflacs.language.cnodes.BinOp

op = '*'
precedence = 4
class ffc.uflacs.language.cnodes.NE(lhs, rhs)[source]

Bases: ffc.uflacs.language.cnodes.BinOp

op = '!='
precedence = 7
class ffc.uflacs.language.cnodes.Namespace(name, body)[source]

Bases: ffc.uflacs.language.cnodes.CStatement

body
cs_format(precision=None)[source]

Return S: string | list(S) | Indented(S).

is_scoped = True
name
class ffc.uflacs.language.cnodes.NaryOp(args)[source]

Bases: ffc.uflacs.language.cnodes.CExprOperator

Base class for special n-ary operators.

args
ce_format(precision=None)[source]
class ffc.uflacs.language.cnodes.Neg(arg)[source]

Bases: ffc.uflacs.language.cnodes.PrefixUnaryOp

op = '-'
precedence = 3
class ffc.uflacs.language.cnodes.New(typename)[source]

Bases: ffc.uflacs.language.cnodes.CExpr

ce_format(precision=None)[source]
typename
ffc.uflacs.language.cnodes.NoOp()[source]
class ffc.uflacs.language.cnodes.Not(arg)[source]

Bases: ffc.uflacs.language.cnodes.PrefixUnaryOp

op = '!'
precedence = 3
class ffc.uflacs.language.cnodes.Null[source]

Bases: ffc.uflacs.language.cnodes.CExprLiteral

A null pointer literal.

ce_format(precision=None)[source]
precedence = 0
class ffc.uflacs.language.cnodes.Or(lhs, rhs)[source]

Bases: ffc.uflacs.language.cnodes.BinOp

op = '||'
precedence = 12
class ffc.uflacs.language.cnodes.Pos(arg)[source]

Bases: ffc.uflacs.language.cnodes.PrefixUnaryOp

op = '+'
precedence = 3
class ffc.uflacs.language.cnodes.PostDecrement(arg)[source]

Bases: ffc.uflacs.language.cnodes.PostfixUnaryOp

op = '--'
precedence = 2
sideeffect = True
class ffc.uflacs.language.cnodes.PostIncrement(arg)[source]

Bases: ffc.uflacs.language.cnodes.PostfixUnaryOp

op = '++'
precedence = 2
sideeffect = True
class ffc.uflacs.language.cnodes.PostfixUnaryOp(arg)[source]

Bases: ffc.uflacs.language.cnodes.UnaryOp

Base class for postfix unary operators.

ce_format(precision=None)[source]
class ffc.uflacs.language.cnodes.Pragma(comment)[source]

Bases: ffc.uflacs.language.cnodes.CStatement

Pragma comments used for compiler-specific annotations.

comment
cs_format(precision=None)[source]

Return S: string | list(S) | Indented(S).

is_scoped = True
class ffc.uflacs.language.cnodes.PreDecrement(arg)[source]

Bases: ffc.uflacs.language.cnodes.PrefixUnaryOp

op = '--'
precedence = 3
sideeffect = True
class ffc.uflacs.language.cnodes.PreIncrement(arg)[source]

Bases: ffc.uflacs.language.cnodes.PrefixUnaryOp

op = '++'
precedence = 3
sideeffect = True
class ffc.uflacs.language.cnodes.PrefixUnaryOp(arg)[source]

Bases: ffc.uflacs.language.cnodes.UnaryOp

Base class for prefix unary operators.

ce_format(precision=None)[source]
class ffc.uflacs.language.cnodes.Product(args)[source]

Bases: ffc.uflacs.language.cnodes.NaryOp

Product of any number of operands.

op = '*'
precedence = 4
class ffc.uflacs.language.cnodes.Return(value=None)[source]

Bases: ffc.uflacs.language.cnodes.CStatement

cs_format(precision=None)[source]

Return S: string | list(S) | Indented(S).

is_scoped = True
value
class ffc.uflacs.language.cnodes.Scope(body)[source]

Bases: ffc.uflacs.language.cnodes.CStatement

body
cs_format(precision=None)[source]

Return S: string | list(S) | Indented(S).

is_scoped = True
class ffc.uflacs.language.cnodes.SizeOf(arg)[source]

Bases: ffc.uflacs.language.cnodes.PrefixUnaryOp

op = 'sizeof'
precedence = 3
ffc.uflacs.language.cnodes.Sqrt(x)[source]
class ffc.uflacs.language.cnodes.Statement(expr)[source]

Bases: ffc.uflacs.language.cnodes.CStatement

Make an expression into a statement.

cs_format(precision=None)[source]

Return S: string | list(S) | Indented(S).

expr
is_scoped = False
class ffc.uflacs.language.cnodes.StatementList(statements)[source]

Bases: ffc.uflacs.language.cnodes.CStatement

A simple sequence of statements. No new scopes are introduced.

cs_format(precision=None)[source]

Return S: string | list(S) | Indented(S).

is_scoped

bool(x) -> bool

Returns True when the argument x is true, False otherwise. The builtins True and False are the only two instances of the class bool. The class bool is a subclass of the class int, and cannot be subclassed.

statements
class ffc.uflacs.language.cnodes.Sub(lhs, rhs)[source]

Bases: ffc.uflacs.language.cnodes.BinOp

op = '-'
precedence = 5
class ffc.uflacs.language.cnodes.Sum(args)[source]

Bases: ffc.uflacs.language.cnodes.NaryOp

Sum of any number of operands.

op = '+'
precedence = 5
class ffc.uflacs.language.cnodes.Switch(arg, cases, default=None, autobreak=True, autoscope=True)[source]

Bases: ffc.uflacs.language.cnodes.CStatement

arg
autobreak
autoscope
cases
cs_format(precision=None)[source]

Return S: string | list(S) | Indented(S).

default
is_scoped = True
class ffc.uflacs.language.cnodes.Symbol(name)[source]

Bases: ffc.uflacs.language.cnodes.CExprTerminal

A named symbol.

ce_format(precision=None)[source]
name
precedence = 0
class ffc.uflacs.language.cnodes.Throw(exception, message)[source]

Bases: ffc.uflacs.language.cnodes.CStatement

cs_format(precision=None)[source]

Return S: string | list(S) | Indented(S).

exception
is_scoped = True
message
class ffc.uflacs.language.cnodes.UnaryOp(arg)[source]

Bases: ffc.uflacs.language.cnodes.CExprOperator

Base class for unary operators.

arg
class ffc.uflacs.language.cnodes.Using(name)[source]

Bases: ffc.uflacs.language.cnodes.CStatement

cs_format(precision=None)[source]

Return S: string | list(S) | Indented(S).

is_scoped = True
name
class ffc.uflacs.language.cnodes.VariableDecl(typename, symbol, value=None)[source]

Bases: ffc.uflacs.language.cnodes.CStatement

Declare a variable, optionally define initial value.

cs_format(precision=None)[source]

Return S: string | list(S) | Indented(S).

is_scoped = False
symbol
typename
value
class ffc.uflacs.language.cnodes.VerbatimExpr(codestring)[source]

Bases: ffc.uflacs.language.cnodes.CExprTerminal

A verbatim copy of an expression source string.

Handled as having the lowest precedence which will introduce parentheses around it most of the time.

ce_format(precision=None)[source]
codestring
precedence = 15
class ffc.uflacs.language.cnodes.VerbatimStatement(codestring)[source]

Bases: ffc.uflacs.language.cnodes.CStatement

Wraps a source code string to be pasted verbatim into the source code.

codestring
cs_format(precision=None)[source]

Return S: string | list(S) | Indented(S).

is_scoped = False
class ffc.uflacs.language.cnodes.While(condition, body)[source]

Bases: ffc.uflacs.language.cnodes.CStatement

body
condition
cs_format(precision=None)[source]

Return S: string | list(S) | Indented(S).

is_scoped = True
ffc.uflacs.language.cnodes.accumulate_loop(dst, src, ranges)[source]

Generate a nested loop over a list of ranges, adding src to dst in the innermost loop.

Ranges is a list on the format [(index, begin, end),…].

ffc.uflacs.language.cnodes.as_cexpr(node)[source]

Typechecks and wraps an object as a valid CExpr.

Accepts CExpr nodes, treats int and float as literals, and treats a string as a symbol.

ffc.uflacs.language.cnodes.as_cexpr_or_literal(node)[source]
ffc.uflacs.language.cnodes.as_cexpr_or_string_symbol(node)[source]
ffc.uflacs.language.cnodes.as_cexpr_or_verbatim(node)[source]
ffc.uflacs.language.cnodes.as_cstatement(node)[source]

Perform type checking on node and wrap in a suitable statement type if necessary.

ffc.uflacs.language.cnodes.as_pragma(pragma)[source]
ffc.uflacs.language.cnodes.as_symbol(symbol)[source]
ffc.uflacs.language.cnodes.assign_loop(dst, src, ranges)[source]

Generate a nested loop over a list of ranges, assigning src to dst in the innermost loop.

Ranges is a list on the format [(index, begin, end),…].

ffc.uflacs.language.cnodes.build_1d_initializer_list(values, formatter, padlen=0, precision=None)[source]

Return a list containing a single line formatted like “{ 0.0, 1.0, 2.0 }”

ffc.uflacs.language.cnodes.build_initializer_lists(values, sizes, level, formatter, padlen=0, precision=None)[source]

Return a list of lines with initializer lists for a multidimensional array.

Example output:

{ { 0.0, 0.1 },
  { 1.0, 1.1 } }
ffc.uflacs.language.cnodes.commented_code_list(code, comments)[source]

Convenience wrapper for adding comment to code list if the list is not empty.

ffc.uflacs.language.cnodes.flattened_indices(indices, shape)[source]

Given a tuple of indices and a shape tuple, return CNode expression for flattened indexing into multidimensional array.

Indices and shape entries can be int values, str symbol names, or CNode expressions.

ffc.uflacs.language.cnodes.float_product(factors)[source]

Build product of float factors, simplifying ones and zeros and returning 1.0 if empty sequence.

ffc.uflacs.language.cnodes.is_negative_one_cexpr(cexpr)[source]
ffc.uflacs.language.cnodes.is_one_cexpr(cexpr)[source]
ffc.uflacs.language.cnodes.is_simple_inner_loop(code)[source]
ffc.uflacs.language.cnodes.is_zero_cexpr(cexpr)[source]
ffc.uflacs.language.cnodes.leftover(size, padlen)[source]

Return minimum integer to add to size to make it divisible by padlen.

ffc.uflacs.language.cnodes.pad_dim(dim, padlen)[source]

Make dim divisible by padlen.

ffc.uflacs.language.cnodes.pad_innermost_dim(shape, padlen)[source]

Make the last dimension in shape divisible by padlen.

ffc.uflacs.language.cnodes.scale_loop(dst, factor, ranges)[source]

Generate a nested loop over a list of ranges, multiplying dst with factor in the innermost loop.

Ranges is a list on the format [(index, begin, end),…].

ffc.uflacs.language.format_lines module

Tools for indentation-aware code string stitching.

When formatting an AST into a string, it’s better to collect lists of snippets and then join them than adding the pieces continually, which gives O(n^2) behaviour w.r.t. AST size n.

class ffc.uflacs.language.format_lines.Indented(body)[source]

Bases: object

Class to mark a collection of snippets for indentation.

This way nested indentations can be handled by adding the prefix spaces only once to each line instead of splitting and indenting substrings repeatedly.

body
ffc.uflacs.language.format_lines.format_indented_lines(snippets, level=0)[source]

Format recursive sequences of indented lines as one string.

ffc.uflacs.language.format_lines.iter_indented_lines(snippets, level=0)[source]

Iterate over indented string lines from a snippets data structure.

The snippets object can be built recursively using the following types:

  • str: Split and yield as one line at a time indented to the appropriate level.
  • Indented: Yield the lines within this object indented by one level.
  • tuple,list: Yield lines from recursive application of this function to list items.
ffc.uflacs.language.format_value module
ffc.uflacs.language.format_value.format_float(x, precision=None)[source]

Format a float value according to given precision.

ffc.uflacs.language.format_value.format_int(x, precision=None)[source]
ffc.uflacs.language.format_value.format_value(value, precision=None)[source]

Format a literal value as s tring.

  • float: Formatted according to current precision configuration.
  • int: Formatted as regular base 10 int literal.
  • str: Wrapped in “quotes”.
ffc.uflacs.language.precedence module
class ffc.uflacs.language.precedence.PRECEDENCE[source]

Bases: object

An enum-like class for C operator precedence levels.

ADD = 5
ADDRESSOF = 3
AND = 11
ASSIGN = 13
BIT_AND = 8
BIT_NOT = 3
BIT_OR = 10
BIT_XOR = 9
CALL = 2
CONDITIONAL = 13
DEREFERENCE = 3
DIV = 4
EQ = 7
GE = 6
GT = 6
HIGHEST = 0
LE = 6
LITERAL = 0
LOWEST = 15
LT = 6
MOD = 4
MUL = 4
NE = 7
NEG = 3
NOT = 3
OR = 12
POS = 3
POST_DEC = 2
POST_INC = 2
PRE_DEC = 3
PRE_INC = 3
SIZEOF = 3
SUB = 5
SUBSCRIPT = 2
SYMBOL = 0
ffc.uflacs.language.ufl_to_cnodes module

Tools for C/C++ expression formatting.

class ffc.uflacs.language.ufl_to_cnodes.RulesForC[source]

Bases: object

abs(o, op)[source]
max_value(o, a, b)[source]
min_value(o, a, b)[source]
power(o, a, b)[source]
class ffc.uflacs.language.ufl_to_cnodes.RulesForCpp[source]

Bases: object

abs(o, op)[source]
bessel_i(o, n, v)[source]
bessel_j(o, n, v)[source]
bessel_k(o, n, v)[source]
bessel_y(o, n, v)[source]
max_value(o, a, b)[source]
min_value(o, a, b)[source]
power(o, a, b)[source]
class ffc.uflacs.language.ufl_to_cnodes.UFL2CNodesMixin(language)[source]

Bases: object

Rules collection mixin for a UFL to CNodes translator class.

acos(o, op)[source]
and_condition(o, a, b)[source]
asin(o, op)[source]
atan(o, op)[source]
atan_2(o, y, x)[source]
conditional(o, c, t, f)[source]
cos(o, op)[source]
cosh(o, op)[source]
division(o, a, b)[source]
eq(o, a, b)[source]
erf(o, op)[source]
exp(o, op)[source]
expr(o)[source]

Generic fallback with error message for missing rules.

float_value(o)[source]
ge(o, a, b)[source]
gt(o, a, b)[source]
int_value(o)[source]
le(o, a, b)[source]
ln(o, op)[source]
lt(o, a, b)[source]
math_function(o, op)[source]
ne(o, a, b)[source]
not_condition(o, a)[source]
or_condition(o, a, b)[source]
product(o, a, b)[source]
sin(o, op)[source]
sinh(o, op)[source]
sqrt(o, op)[source]
sum(o, a, b)[source]
tan(o, op)[source]
tanh(o, op)[source]
zero(o)[source]
class ffc.uflacs.language.ufl_to_cnodes.UFL2CNodesTranslatorC(language)[source]

Bases: ufl.corealg.multifunction.MultiFunction, ffc.uflacs.language.ufl_to_cnodes.UFL2CNodesMixin, ffc.uflacs.language.ufl_to_cnodes.RulesForC

UFL to CNodes translator class.

class ffc.uflacs.language.ufl_to_cnodes.UFL2CNodesTranslatorCpp(language)[source]

Bases: ufl.corealg.multifunction.MultiFunction, ffc.uflacs.language.ufl_to_cnodes.UFL2CNodesMixin, ffc.uflacs.language.ufl_to_cnodes.RulesForCpp

UFL to CNodes translator class.

Module contents
Submodules
ffc.uflacs.build_uflacs_ir module

Main algorithm for building the uflacs intermediate representation.

ffc.uflacs.build_uflacs_ir.analyse_dependencies(V, V_deps, V_targets, modified_terminal_indices, modified_terminals, mt_unique_table_reference)[source]
ffc.uflacs.build_uflacs_ir.build_scalar_graph(expressions)[source]

Build list representation of expression graph covering the given expressions.

TODO: Renaming, refactoring and cleanup of the graph building algorithms used in here

ffc.uflacs.build_uflacs_ir.build_uflacs_ir(cell, integral_type, entitytype, integrands, tensor_shape, coefficient_numbering, quadrature_rules, parameters)[source]
class ffc.uflacs.build_uflacs_ir.common_block_data_t(block_mode, ttypes, factor_index, factor_is_piecewise, unames, restrictions, transposed)

Bases: tuple

block_mode

Alias for field number 0

factor_index

Alias for field number 2

factor_is_piecewise

Alias for field number 3

restrictions

Alias for field number 5

transposed

Alias for field number 6

ttypes

Alias for field number 1

unames

Alias for field number 4

ffc.uflacs.build_uflacs_ir.empty_expr_ir()[source]
class ffc.uflacs.build_uflacs_ir.full_block_data_t(block_mode, ttypes, factor_index, factor_is_piecewise, unames, restrictions, transposed, ma_data)

Bases: tuple

block_mode

Alias for field number 0

factor_index

Alias for field number 2

factor_is_piecewise

Alias for field number 3

ma_data

Alias for field number 7

restrictions

Alias for field number 5

transposed

Alias for field number 6

ttypes

Alias for field number 1

unames

Alias for field number 4

ffc.uflacs.build_uflacs_ir.get_common_block_data(blockdata)[source]
ffc.uflacs.build_uflacs_ir.integrate_block(weights, unames, ttypes, unique_tables, unique_table_num_dofs)[source]
ffc.uflacs.build_uflacs_ir.integrate_block_interior_facets(weights, unames, ttypes, unique_tables, unique_table_num_dofs)[source]
class ffc.uflacs.build_uflacs_ir.ma_data_t(ma_index, tabledata)

Bases: tuple

ma_index

Alias for field number 0

tabledata

Alias for field number 1

ffc.uflacs.build_uflacs_ir.multiply_block(point_index, unames, ttypes, unique_tables, unique_table_num_dofs)[source]
ffc.uflacs.build_uflacs_ir.multiply_block_interior_facets(point_index, unames, ttypes, unique_tables, unique_table_num_dofs)[source]
ffc.uflacs.build_uflacs_ir.parse_uflacs_optimization_parameters(parameters, integral_type)[source]

Following model from quadrature representation, extracting uflacs specific parameters from the global parameters dict.

class ffc.uflacs.build_uflacs_ir.partial_block_data_t(block_mode, ttypes, factor_index, factor_is_piecewise, unames, restrictions, transposed, ma_data, piecewise_ma_index)

Bases: tuple

block_mode

Alias for field number 0

factor_index

Alias for field number 2

factor_is_piecewise

Alias for field number 3

ma_data

Alias for field number 7

piecewise_ma_index

Alias for field number 8

restrictions

Alias for field number 5

transposed

Alias for field number 6

ttypes

Alias for field number 1

unames

Alias for field number 4

class ffc.uflacs.build_uflacs_ir.preintegrated_block_data_t(block_mode, ttypes, factor_index, factor_is_piecewise, unames, restrictions, transposed, is_uniform, name)

Bases: tuple

block_mode

Alias for field number 0

factor_index

Alias for field number 2

factor_is_piecewise

Alias for field number 3

is_uniform

Alias for field number 7

name

Alias for field number 8

restrictions

Alias for field number 5

transposed

Alias for field number 6

ttypes

Alias for field number 1

unames

Alias for field number 4

class ffc.uflacs.build_uflacs_ir.premultiplied_block_data_t(block_mode, ttypes, factor_index, factor_is_piecewise, unames, restrictions, transposed, is_uniform, name)

Bases: tuple

block_mode

Alias for field number 0

factor_index

Alias for field number 2

factor_is_piecewise

Alias for field number 3

is_uniform

Alias for field number 7

name

Alias for field number 8

restrictions

Alias for field number 5

transposed

Alias for field number 6

ttypes

Alias for field number 1

unames

Alias for field number 4

ffc.uflacs.build_uflacs_ir.uflacs_default_parameters(optimize)[source]

Default parameters for tuning of uflacs code generation.

These are considered experimental and may change without deprecation mechanism at any time.

ffc.uflacs.elementtables module

Tools for precomputed tables of terminal values.

ffc.uflacs.elementtables.analyse_table_type(table, rtol=1e-05, atol=1e-08)[source]
ffc.uflacs.elementtables.analyse_table_types(unique_tables, rtol=1e-05, atol=1e-08)[source]
ffc.uflacs.elementtables.build_element_tables(num_points, quadrature_rules, cell, integral_type, entitytype, modified_terminals, rtol=1e-05, atol=1e-08)[source]

Build the element tables needed for a list of modified terminals.

Input:
entitytype - str modified_terminals - ordered sequence of unique modified terminals FIXME: Document
Output:
tables - dict(name: table) mt_table_names - dict(ModifiedTerminal: name)
ffc.uflacs.elementtables.build_optimized_tables(num_points, quadrature_rules, cell, integral_type, entitytype, modified_terminals, existing_tables, compress_zeros, rtol=1e-05, atol=1e-08)[source]
ffc.uflacs.elementtables.build_unique_tables(tables, rtol=1e-05, atol=1e-08)[source]

Given a list or dict of tables, return a list of unique tables and a dict of unique table indices for each input table key.

ffc.uflacs.elementtables.clamp_table_small_numbers(table, rtol=1e-05, atol=1e-08, numbers=(-1.0, -0.5, 0.0, 0.5, 1.0))[source]

Clamp almost 0,1,-1 values to integers. Returns new table.

ffc.uflacs.elementtables.equal_tables(a, b, rtol=1e-05, atol=1e-08)[source]
ffc.uflacs.elementtables.generate_psi_table_name(num_points, element_counter, averaged, entitytype, derivative_counts, flat_component)[source]

Generate a name for the psi table of the form: FE#_C#_D###[_AC|_AF|][_F|V][_Q#], where ‘#’ will be an integer value.

FE - is a simple counter to distinguish the various bases, it will be
assigned in an arbitrary fashion.
C - is the component number if any (this does not yet take into account
tensor valued functions)
D - is the number of derivatives in each spatial direction if any.
If the element is defined in 3D, then D012 means d^3(*)/dydz^2.

AC - marks that the element values are averaged over the cell

AF - marks that the element values are averaged over the facet

F - marks that the first array dimension enumerates facets on the cell

V - marks that the first array dimension enumerates vertices on the cell

Q - number of quadrature points, to distinguish between tables in a mixed quadrature degree setting

ffc.uflacs.elementtables.get_ffc_table_values(points, cell, integral_type, ufl_element, avg, entitytype, derivative_counts, flat_component)[source]

Extract values from ffc element table.

Returns a 3D numpy array with axes (entity number, quadrature point number, dof number)

ffc.uflacs.elementtables.get_modified_terminal_element(mt)[source]
ffc.uflacs.elementtables.is_ones_table(table, rtol=1e-05, atol=1e-08)[source]
ffc.uflacs.elementtables.is_piecewise_table(table, rtol=1e-05, atol=1e-08)[source]
ffc.uflacs.elementtables.is_quadrature_table(table, rtol=1e-05, atol=1e-08)[source]
ffc.uflacs.elementtables.is_uniform_table(table, rtol=1e-05, atol=1e-08)[source]
ffc.uflacs.elementtables.is_zeros_table(table, rtol=1e-05, atol=1e-08)[source]
ffc.uflacs.elementtables.optimize_element_tables(tables, table_origins, compress_zeros, rtol=1e-05, atol=1e-08)[source]

Optimize tables and make unique set.

Steps taken:

  • clamp values that are very close to -1, 0, +1 to those values
  • remove dofs from beginning and end of tables where values are all zero
  • for each modified terminal, provide the dof range that a given table corresponds to
Terminology:

name - str, name used in input arguments here table - numpy array of float values stripped_table - numpy array of float values with zeroes

removed from each end of dofrange
Input:
tables - { name: table } table_origins - FIXME
Output:
unique_tables - { unique_name: stripped_table } unique_table_origins - FIXME
ffc.uflacs.elementtables.strip_table_zeros(table, compress_zeros, rtol=1e-05, atol=1e-08)[source]

Strip zero columns from table. Returns column range (begin, end) and the new compact table.

ffc.uflacs.elementtables.table_origin_t

alias of ffc.uflacs.elementtables.table_origin

ffc.uflacs.elementtables.unique_table_reference_t

alias of ffc.uflacs.elementtables.unique_table_reference

ffc.uflacs.integralgenerator module

Controlling algorithm for building the tabulate_tensor source structure from factorized representation.

class ffc.uflacs.integralgenerator.IntegralGenerator(ir, backend, precision)[source]

Bases: object

generate()[source]

Generate entire tabulate_tensor body.

Assumes that the code returned from here will be wrapped in a context that matches a suitable version of the UFC tabulate_tensor signatures.

generate_block_parts(num_points, blockmap, blockdata)[source]

Generate and return code parts for a given block.

Returns parts occuring before, inside, and after the quadrature loop identified by num_points.

Should be called with num_points=None for quadloop-independent blocks.

generate_copyout_statements()[source]

Generate statements copying results to output array.

generate_dofblock_partition(num_points)[source]
generate_element_tables()[source]

Generate static tables with precomputed element basis function values in quadrature points.

generate_expr_copyout_statements()[source]
generate_partition(symbol, V, V_active, V_mts, mt_tabledata, num_points)[source]
generate_preintegrated_dofblock_partition()[source]
generate_quadrature_loop(num_points)[source]

Generate quadrature loop with for this num_points.

generate_quadrature_tables()[source]

Generate static tables of quadrature points and weights.

generate_runtime_quadrature_loop()[source]

Generate quadrature loop for custom integrals, with physical points given runtime.

generate_tensor_copyout_statements()[source]
generate_tensor_reset()[source]

Generate statements for resetting the element tensor to zero.

generate_tensor_value_initialization(A_values)[source]
generate_unstructured_piecewise_partition()[source]
generate_unstructured_varying_partition(num_points)[source]
get_arg_factors(blockdata, block_rank, num_points, iq, indices)[source]
get_entities(blockdata)[source]
get_includes()[source]

Return list of include statements needed to support generated code.

get_temp_symbol(tempname, key)[source]
get_var(num_points, v)[source]

“Lookup ufl expression v in variable scope dicts.

Scope is determined by num_points which identifies the quadrature loop scope or None if outside quadrature loops.

If v is not found in quadrature loop scope, the piecewise scope (None) is checked.

Returns the CNodes expression to access the value in the code.

has_var(num_points, v)[source]

“Check if variable exists in variable scope dicts.

Return True if ufl expression v exists in the num_points scope.

NB! Does not fall back to piecewise scope.

init_scopes()[source]

Initialize variable scope dicts.

new_temp_symbol(basename)[source]

Create a new code symbol named basename + running counter.

set_var(num_points, v, vaccess)[source]

“Set a new variable in variable scope dicts.

Scope is determined by num_points which identifies the quadrature loop scope or None if outside quadrature loops.

v is the ufl expression and vaccess is the CNodes expression to access the value in the code.

ffc.uflacs.params module

Collection of exposed parameters available to tune form compiler algorithms.

ffc.uflacs.params.default_parameters()[source]
ffc.uflacs.tools module
ffc.uflacs.tools.accumulate_integrals(itg_data, quadrature_rule_sizes)[source]

Group and accumulate integrals according to the number of quadrature points in their rules.

ffc.uflacs.tools.collect_quadrature_rules(integrals, default_scheme, default_degree)[source]

Collect quadrature rules found in list of integrals.

ffc.uflacs.tools.compute_quadrature_rules(rules, integral_type, cell)[source]

Compute points and weights for a set of quadrature rules.

ffc.uflacs.uflacsgenerator module

Controlling algorithm for building the tabulate_tensor source structure from factorized representation.

ffc.uflacs.uflacsgenerator.generate_integral_code(ir, prefix, parameters)[source]

Generate code for integral from intermediate representation.

ffc.uflacs.uflacsoptimization module
ffc.uflacs.uflacsoptimization.optimize_integral_ir(ir, parameters)[source]

Compute optimized intermediate representation of integral.

ffc.uflacs.uflacsrepresentation module
ffc.uflacs.uflacsrepresentation.compute_integral_ir(itg_data, form_data, form_id, element_numbers, classnames, parameters)[source]

Compute intermediate represention of integral.

Module contents

This is UFLACS, the UFL Analyser and Compiler System.

Submodules

ffc.analysis module

Compiler stage 1: Analysis

This module implements the analysis/preprocessing of variational forms, including automatic selection of elements, degrees and form representation type.

ffc.analysis.analyze_coordinate_mappings(coordinate_elements, parameters)[source]
ffc.analysis.analyze_elements(elements, parameters)[source]
ffc.analysis.analyze_forms(forms, parameters)[source]

Analyze form(s), returning

form_datas - a tuple of form_data objects unique_elements - a tuple of unique elements across all forms element_numbers - a mapping to unique numbers for all elements
ffc.analysis.analyze_ufl_objects(ufl_objects, kind, parameters)[source]

Analyze ufl object(s), either forms, elements, or coordinate mappings, returning:

form_datas - a tuple of form_data objects unique_elements - a tuple of unique elements across all forms element_numbers - a mapping to unique numbers for all elements

ffc.classname module

This module defines some basics for generating C++ code.

ffc.classname.make_classname(prefix, basename, signature)[source]
ffc.classname.make_integral_classname(prefix, integral_type, form_id, subdomain_id)[source]

ffc.codegeneration module

Compiler stage 4: Code generation

This module implements the generation of C++ code for the body of each UFC function from an (optimized) intermediate representation (OIR).

ffc.codegeneration.generate_code(ir, parameters)[source]

Generate code from intermediate representation.

ffc.compiler module

This is the compiler, acting as the main interface for compilation of forms and breaking the compilation into several sequential stages. The output of each stage is the input of the next stage.

Compiler stage 0: Language, parsing

Input: Python code or .ufl file Output: UFL form

This stage consists of parsing and expressing a form in the UFL form language.

This stage is completely handled by UFL.

Compiler stage 1: Analysis

Input: UFL form Output: Preprocessed UFL form and FormData (metadata)

This stage preprocesses the UFL form and extracts form metadata. It may also perform simplifications on the form.

Compiler stage 2: Code representation

Input: Preprocessed UFL form and FormData (metadata) Output: Intermediate Representation (IR)

This stage examines the input and generates all data needed for code generation. This includes generation of finite element basis functions, extraction of data for mapping of degrees of freedom and possible precomputation of integrals.

Most of the complexity of compilation is handled in this stage.

The IR is stored as a dictionary, mapping names of UFC functions to data needed for generation of the corresponding code.

Compiler stage 3: Optimization

Input: Intermediate Representation (IR) Output: Optimized Intermediate Representation (OIR)

This stage examines the IR and performs optimizations.

Optimization is currently disabled as a separate stage but is implemented as part of the code generation for quadrature representation.

Compiler stage 4: Code generation

Input: Optimized Intermediate Representation (OIR) Output: C++ code

This stage examines the OIR and generates the actual C++ code for the body of each UFC function.

The code is stored as a dictionary, mapping names of UFC functions to strings containing the C++ code of the body of each function.

Compiler stage 5: Code formatting

Input: C++ code Output: C++ code files

This stage examines the generated C++ code and formats it according to the UFC format, generating as output one or more .h/.cpp files conforming to the UFC format.

The main interface is defined by the following two functions:

compile_form compile_element

The compiler stages are implemented by the following functions:

analyze_forms or analyze_elements (stage 1) compute_ir (stage 2) optimize_ir (stage 3) generate_code (stage 4) format_code (stage 5)
ffc.compiler.compile_form(forms, object_names=None, prefix='Form', parameters=None, jit=False)[source]

This function generates UFC code for a given UFL form or list of UFL forms.

ffc.compiler.compile_element(elements, object_names=None, prefix='Element', parameters=None, jit=False)[source]

This function generates UFC code for a given UFL element or list of UFL elements.

ffc.fiatinterface module

class ffc.fiatinterface.SpaceOfReals[source]

Bases: object

Constant over the entire domain, rather than just cellwise.

ffc.fiatinterface.create_element(ufl_element)[source]
ffc.fiatinterface.create_quadrature(shape, degree, scheme='default')[source]

Generate quadrature rule (points, weights) for given shape that will integrate an polynomial of order ‘degree’ exactly.

ffc.fiatinterface.map_facet_points(points, facet, cellname)[source]

Map points from the e (UFC) reference simplex of dimension d - 1 to a given facet on the (UFC) reference simplex of dimension d. This may be used to transform points tabulated for example on the 2D reference triangle to points on a given facet of the reference tetrahedron.

ffc.fiatinterface.reference_cell(cellname)[source]

Return FIAT reference cell

ffc.fiatinterface.reference_cell_vertices(cellname)[source]

Return dict of coordinates of reference cell vertices for this ‘cellname’.

ffc.formatting module

Compiler stage 5: Code formatting

This module implements the formatting of UFC code from a given dictionary of generated C++ code for the body of each UFC function.

It relies on templates for UFC code available as part of the module ufc_utils.

ffc.formatting.format_code(code, wrapper_code, prefix, parameters, jit=False)[source]

Format given code in UFC format. Returns two strings with header and source file contents.

ffc.formatting.generate_factory_functions(prefix, kind, classname)[source]
ffc.formatting.generate_jit_factory_functions(code, prefix)[source]
ffc.formatting.write_code(code_h, code_c, prefix, parameters)[source]

ffc.git_commit_hash module

ffc.git_commit_hash.git_commit_hash()[source]

Return git changeset hash (returns “unknown” if changeset is not known)

ffc.jitcompiler module

This module provides a just-in-time (JIT) form compiler. It uses dijitso to wrap the generated code into a Python module.

exception ffc.jitcompiler.FFCError[source]

Bases: Exception

exception ffc.jitcompiler.FFCJitError[source]

Bases: ffc.jitcompiler.FFCError

ffc.jitcompiler.compute_jit_prefix(ufl_object, parameters, kind=None)[source]

Compute the prefix (module name) for jit modules.

ffc.jitcompiler.jit(ufl_object, parameters=None, indirect=False)[source]

Just-in-time compile the given form or element

Parameters:

ufl_object : The UFL object to be compiled parameters : A set of parameters
ffc.jitcompiler.jit_build(ufl_object, module_name, parameters)[source]

Wraps dijitso jit with some parameter conversion etc.

ffc.jitcompiler.jit_generate(ufl_object, module_name, signature, parameters)[source]

Callback function passed to dijitso.jit: generate code and return as strings.

ffc.log module

This module provides functions used by the FFC implementation to output messages. These may be redirected by the user of FFC.

This module reuses the corresponding log.py module from UFL which is a wrapper for the standard Python logging module.

ffc.log.add_indent(*message)
ffc.log.add_logfile(*message)
ffc.log.begin(*message)
ffc.log.debug(*message)
ffc.log.debug_code(code, name='')[source]

Debug generated code.

ffc.log.debug_dict(d, title='')[source]

Pretty-print dictionary.

ffc.log.debug_ir(ir, name='')[source]

Debug intermediate representation.

ffc.log.deprecate(*message)
ffc.log.end(*message)
ffc.log.error(*message)
ffc.log.ffc_assert(condition, *message)[source]

Assert that condition is true and otherwise issue an error with given message.

ffc.log.get_handler(*message)
ffc.log.get_logger(*message)
ffc.log.info(*message)
ffc.log.info_blue(*message)
ffc.log.info_green(*message)
ffc.log.info_red(*message)
ffc.log.log(*message)
ffc.log.pop_level(*message)
ffc.log.push_level(*message)
ffc.log.set_handler(*message)
ffc.log.set_indent(*message)
ffc.log.set_level(*message)
ffc.log.set_prefix(*message)
ffc.log.warning(*message)
ffc.log.warning_blue(*message)
ffc.log.warning_green(*message)
ffc.log.warning_red(*message)

ffc.main module

This script is the command-line interface to FFC.

It parses command-line arguments and generates code from input UFL form files.

ffc.main.compile_ufl_data(ufd, prefix, parameters)[source]
ffc.main.info_usage()[source]

Print usage information.

ffc.main.info_version()[source]

Print version number.

ffc.main.main(args=None)[source]

This is the commandline tool for the python module ffc.

ffc.main.print_error(msg)[source]

Print error message (cannot use log system at top level).

ffc.optimization module

Compiler stage 5: optimization

This module implements the optimization of an intermediate code representation.

ffc.optimization.optimize_ir(ir, parameters)[source]

Optimize intermediate form representation.

ffc.parameters module

ffc.parameters.compilation_relevant_parameters(parameters)[source]
ffc.parameters.compute_jit_parameters_signature(parameters)[source]

Return parameters signature (some parameters must be ignored).

ffc.parameters.default_jit_parameters()[source]
ffc.parameters.default_parameters()[source]

Return (a copy of) the default parameter values for FFC.

ffc.parameters.split_parameters(parameters)[source]

Split a parameters dict into groups based on what parameters are used for.

ffc.parameters.validate_jit_parameters(parameters)[source]

Check parameters and add any missing parameters

ffc.parameters.validate_parameters(parameters)[source]

Initial check of parameters.

ffc.plot module

This module provides functionality for plotting finite elements.

ffc.plot.plot(element, rotate=True)[source]

Plot finite element.

ffc.representation module

Compiler stage 2: Code representation

This module computes intermediate representations of forms, elements and dofmaps. For each UFC function, we extract the data needed for code generation at a later stage.

The representation should conform strictly to the naming and order of functions in UFC. Thus, for code generation of the function “foo”, one should only need to use the data stored in the intermediate representation under the key “foo”.

ffc.representation.all_elements(fiat_element)[source]
ffc.representation.cell_midpoint(cell)[source]
ffc.representation.compute_ir(analysis, prefix, parameters, jit=False)[source]

Compute intermediate representation.

ffc.representation.make_all_element_classnames(prefix, elements, coordinate_elements, element_numbers, parameters, jit)[source]
ffc.representation.make_coordinate_mapping_jit_classname(ufl_mesh, parameters)[source]
ffc.representation.make_dofmap_jit_classname(ufl_element, parameters)[source]
ffc.representation.make_finite_element_jit_classname(ufl_element, parameters)[source]
ffc.representation.needs_oriented_jacobian(fiat_element)[source]
ffc.representation.pick_representation(representation)[source]

Return one of the specialized code generation modules from a representation string.

ffc.representation.uses_integral_moments(fiat_element)[source]

True if element uses integral moments for its degrees of freedom.

ffc.representationutils module

This module contains utility functions for some code shared between quadrature and tensor representation.

ffc.representationutils.create_quadrature_points_and_weights(integral_type, cell, degree, rule)[source]

Create quadrature rule and return points and weights.

ffc.representationutils.entity_type_from_integral_type(integral_type)[source]
ffc.representationutils.generate_enabled_coefficients(enabled_coefficients)[source]
ffc.representationutils.initialize_integral_code(ir, prefix, parameters)[source]

Representation independent default initialization of code dict for integral from intermediate representation.

ffc.representationutils.initialize_integral_ir(representation, itg_data, form_data, form_id)[source]

Initialize a representation dict with common information that is expected independently of which representation is chosen.

ffc.representationutils.integral_type_to_entity_dim(integral_type, tdim)[source]

Given integral_type and domain tdim, return the tdim of the integration entity.

ffc.representationutils.map_integral_points(points, integral_type, cell, entity)[source]

Map points from reference entity to its parent reference cell.

ffc.representationutils.needs_oriented_jacobian(form_data)[source]
ffc.representationutils.transform_component(component, offset, ufl_element)[source]

This function accounts for the fact that if the geometrical and topological dimension does not match, then for native vector elements, in particular the Piola-mapped ones, the physical value dimensions and the reference value dimensions are not the same. This has certain consequences for mixed elements, aka ‘fun with offsets’.

ffc.utils module

ffc.utils.all_equal(sequence)[source]

Check that all items in list are equal.

ffc.utils.compute_permutations(k, n, skip=[])[source]

Compute all permutations of k elements from (0, n) in rising order. Any elements that are contained in the list skip are not included.

ffc.utils.insert_nested_dict(root, keys, value)[source]

Set root[keys[0]][…][keys[-1]] = value, creating subdicts on the way if missing.

ffc.utils.listcopy(sequence)[source]

Create a copy of the list, calling the copy constructor on each object in the list (problems when using copy.deepcopy).

ffc.utils.pick_first(sequence)[source]

Check that all values are equal and return the value.

ffc.wrappers module

ffc.wrappers.generate_wrapper_code(analysis, prefix, object_names, parameters)[source]

Generate code for additional wrappers.

Module contents

FEniCS Form Compiler (FFC)

FFC compiles finite element variational forms into C++ code.

The interface consists of the following functions:

compile_form - Compilation of forms compile_element - Compilation of finite elements jit - Just-In-Time compilation of forms and elements default_parameters - Default parameter values for FFC ufc_signature - Signature of UFC interface (SHA-1 hash of ufc.h)

Release notes

Changes in the next release

Summary of changes

Note

Developers should use this page to track and list changes during development. At the time of release, this page should be published (and renamed) to list the most important changes in the new release.

Detailed changes

Note

At the time of release, make a verbatim copy of the ChangeLog here (and remove this note).

Changes in version 2019.1.0

Summary of changes
  • Support NodalEnrichedElement
Detailed changes
  • Support NodalEnrichedElement see demo/NodalMini.ufl.

Changes in version 2018.1.0

FFC 2018.1.0 was released on 2018-06-14.

Summary of changes
  • Remove python2 support.

Changes in version 2017.2.0

FFC 2017.2.0 was released on 2017-12-05.

Summary of changes
  • Some fixes for ufc::eval for esoteric element combinations
  • Reimplement code generation for all ufc classes with new class ufc::coordinate_mapping which can map between coordinates, compute jacobians, etc. for a coordinate mapping parameterized by a specific finite element.
  • New functions in ufc::finite_element: - evaluate_reference_basis - evaluate_reference_basis_derivatives - transform_reference_basis_derivatives - tabulate_reference_dof_coordinates
  • New functions in ufc::dofmap: - num_global_support_dofs - num_element_support_dofs
  • Improved docstrings for parts of ufc.h
  • FFC now accepts Q and DQ finite element families defined on quadrilaterals and hexahedrons
  • Some fixes for ufc_geometry.h for quadrilateral and hexahedron cells

Changes in version 2017.1.0

FFC 2017.1.0.post2 was released on 2017-09-12.

Summary of changes
  • Change PyPI package name to fenics-ffc.

Changes in version 2017.1.0

FFC 2017.1.0 was released on 2017-05-09.

Summary of changes
Detailed changes
  • Let ffc -O parameter take an optional integer level like -O2, -O0
  • Implement blockwise optimizations in uflacs code generation
  • Expose uflacs optimization parameters through parameter system

Changes in version 2016.2.0

FFC 2016.2.0 was released on 2016-11-30.

Summary of changes
  • Generalize ufc interface to non-affine parameterized coordinates
  • Add ufc::coordinate_mapping class
  • Make ufc interface depend on C++11 features requiring gcc version >= 4.8
  • Change the mapping pullback as metric to double covariant piola (this preserves tangential-tangential trace).
  • Added Hellan-Herrmann-Johnson element as supported element
  • Add mapping double contravariant piola (this preserves normal-normal trace).
  • Include comment with effective representation and integral metadata to generated tabulate_tensor code
Detailed changes
  • Jit compiler now compiles elements separately from forms to avoid duplicate work
  • Add parameter max_signature_length to optionally shorten signatures in the jit cache
  • Move uflacs module into ffc.uflacs
  • Remove installation of pkg-config and CMake files (UFC path and compiler flags are available from ffc module)
  • Add dependency on dijitso and remove dependency on instant
  • Add experimental Bitbucket pipelines
  • Tidy the repo after UFC and UFLACS merge, and general spring cleanup. This includes removal of instructions how to merge two repos, commit hash c8389032268041fe94682790cb773663bdf27286.

Changes in version 2016.1.0

FFC 2016.1.0 was released on 2016-06-23.

  • Add function get_ufc_include to get path to ufc.h
  • Merge UFLACS into FFC
  • Generalize ufc interface to non-affine parameterized coordinates
  • Add ufc::coordinate_mapping class
  • Make ufc interface depend on C++11 features requiring gcc version >= 4.8
  • Add function ufc_signature() to the form compiler interface
  • Add function git_commit_hash()

Changes in version 1.6.0

FFC 1.6.0 was released on 2015-07-28.

  • Rename and modify a number of UFC interface functions. See docstrings in ufc.h for details.
  • Bump required SWIG version to 3.0.3
  • Disable dual basis (tabulate_coordinates and evaluate_dofs) for enriched elements until correct implementation is brought up

[FIXME: These links don’t belong here, should go under API reference somehow.]