ffcx.ir.representation

Compiler stage 2: Code representation.

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”.

Functions

compute_ir(analysis, object_names, prefix, ...)

Compute intermediate representation.

Classes

CustomElementIR(cell_type, value_shape, ...)

Create new instance of CustomElementIR(cell_type, value_shape, wcoeffs, x, M, map_type, sobolev_space, interpolation_nderivs, discontinuous, embedded_subdegree, embedded_superdegree, polyset_type)

DataIR(elements, dofmaps, integrals, forms, ...)

Create new instance of DataIR(elements, dofmaps, integrals, forms, expressions)

DofMapIR(id, name, signature, ...)

Create new instance of DofMapIR(id, name, signature, num_global_support_dofs, num_element_support_dofs, entity_dofs, num_entity_dofs, entity_closure_dofs, num_entity_closure_dofs, num_sub_dofmaps, sub_dofmaps, block_size)

ElementIR(id, name, signature, cell_shape, ...)

Create new instance of ElementIR(id, name, signature, cell_shape, topological_dimension, geometric_dimension, space_dimension, value_shape, reference_value_shape, degree, num_sub_elements, block_size, sub_elements, element_type, entity_dofs, lagrange_variant, dpc_variant, basix_family, basix_cell, discontinuous, custom_element, custom_quadrature)

ExpressionIR(name, element_dimensions, ...)

Create new instance of ExpressionIR(name, element_dimensions, options, unique_tables, unique_table_types, integrand, coefficient_numbering, coefficient_offsets, integral_type, entitytype, tensor_shape, expression_shape, original_constant_offsets, points, coefficient_names, constant_names, needs_facet_permutations, function_spaces, name_from_uflfile, original_coefficient_positions)

FormIR(id, name, signature, rank, ...)

Create new instance of FormIR(id, name, signature, rank, num_coefficients, num_constants, name_from_uflfile, function_spaces, original_coefficient_position, coefficient_names, constant_names, finite_elements, dofmaps, integral_names, subdomain_ids)

IntegralIR(integral_type, subdomain_id, ...)

Create new instance of IntegralIR(integral_type, subdomain_id, rank, geometric_dimension, topological_dimension, entitytype, num_facets, num_vertices, enabled_coefficients, element_dimensions, element_ids, tensor_shape, coefficient_numbering, coefficient_offsets, original_constant_offsets, options, cell_shape, unique_tables, unique_table_types, integrand, name, needs_facet_permutations, coordinate_element, sum_factorization)

QuadratureIR(cell_shape, points, weights)

Create new instance of QuadratureIR(cell_shape, points, weights)

class ffcx.ir.representation.CustomElementIR(cell_type, value_shape, wcoeffs, x, M, map_type, sobolev_space, interpolation_nderivs, discontinuous, embedded_subdegree, embedded_superdegree, polyset_type)[source]

Bases: tuple

Create new instance of CustomElementIR(cell_type, value_shape, wcoeffs, x, M, map_type, sobolev_space, interpolation_nderivs, discontinuous, embedded_subdegree, embedded_superdegree, polyset_type)

M: List[List[ndarray[Any, dtype[float64]]]]

Alias for field number 4

cell_type: CellType

Alias for field number 0

discontinuous: bool

Alias for field number 8

embedded_subdegree: int

Alias for field number 9

embedded_superdegree: int

Alias for field number 10

interpolation_nderivs: int

Alias for field number 7

map_type: MapType

Alias for field number 5

polyset_type: PolysetType

Alias for field number 11

sobolev_space: SobolevSpace

Alias for field number 6

value_shape: Tuple[int, ...]

Alias for field number 1

wcoeffs: ndarray[Any, dtype[float64]]

Alias for field number 2

x: List[List[ndarray[Any, dtype[float64]]]]

Alias for field number 3

class ffcx.ir.representation.DataIR(elements, dofmaps, integrals, forms, expressions)[source]

Bases: tuple

Create new instance of DataIR(elements, dofmaps, integrals, forms, expressions)

dofmaps: List[DofMapIR]

Alias for field number 1

elements: List[ElementIR]

Alias for field number 0

expressions: List[ExpressionIR]

Alias for field number 4

forms: List[FormIR]

Alias for field number 3

integrals: List[IntegralIR]

Alias for field number 2

class ffcx.ir.representation.DofMapIR(id, name, signature, num_global_support_dofs, num_element_support_dofs, entity_dofs, num_entity_dofs, entity_closure_dofs, num_entity_closure_dofs, num_sub_dofmaps, sub_dofmaps, block_size)[source]

Bases: tuple

Create new instance of DofMapIR(id, name, signature, num_global_support_dofs, num_element_support_dofs, entity_dofs, num_entity_dofs, entity_closure_dofs, num_entity_closure_dofs, num_sub_dofmaps, sub_dofmaps, block_size)

block_size: int

Alias for field number 11

entity_closure_dofs: List[List[List[int]]]

Alias for field number 7

entity_dofs: List[List[List[int]]]

Alias for field number 5

id: int

Alias for field number 0

name: str

Alias for field number 1

num_element_support_dofs: int

Alias for field number 4

num_entity_closure_dofs: List[List[int]]

Alias for field number 8

num_entity_dofs: List[List[int]]

Alias for field number 6

num_global_support_dofs: int

Alias for field number 3

num_sub_dofmaps: int

Alias for field number 9

signature: str

Alias for field number 2

sub_dofmaps: List[str]

Alias for field number 10

class ffcx.ir.representation.ElementIR(id, name, signature, cell_shape, topological_dimension, geometric_dimension, space_dimension, value_shape, reference_value_shape, degree, num_sub_elements, block_size, sub_elements, element_type, entity_dofs, lagrange_variant, dpc_variant, basix_family, basix_cell, discontinuous, custom_element, custom_quadrature)[source]

Bases: tuple

Create new instance of ElementIR(id, name, signature, cell_shape, topological_dimension, geometric_dimension, space_dimension, value_shape, reference_value_shape, degree, num_sub_elements, block_size, sub_elements, element_type, entity_dofs, lagrange_variant, dpc_variant, basix_family, basix_cell, discontinuous, custom_element, custom_quadrature)

basix_cell: CellType

Alias for field number 18

basix_family: ElementFamily

Alias for field number 17

block_size: int

Alias for field number 11

cell_shape: str

Alias for field number 3

custom_element: CustomElementIR

Alias for field number 20

custom_quadrature: QuadratureIR

Alias for field number 21

degree: int

Alias for field number 9

discontinuous: bool

Alias for field number 19

dpc_variant: DPCVariant

Alias for field number 16

element_type: str

Alias for field number 13

entity_dofs: List[List[List[int]]]

Alias for field number 14

geometric_dimension: int

Alias for field number 5

id: int

Alias for field number 0

lagrange_variant: LagrangeVariant

Alias for field number 15

name: str

Alias for field number 1

num_sub_elements: int

Alias for field number 10

reference_value_shape: Tuple[int, ...]

Alias for field number 8

signature: str

Alias for field number 2

space_dimension: int

Alias for field number 6

sub_elements: List[str]

Alias for field number 12

topological_dimension: int

Alias for field number 4

value_shape: Tuple[int, ...]

Alias for field number 7

class ffcx.ir.representation.ExpressionIR(name, element_dimensions, options, unique_tables, unique_table_types, integrand, coefficient_numbering, coefficient_offsets, integral_type, entitytype, tensor_shape, expression_shape, original_constant_offsets, points, coefficient_names, constant_names, needs_facet_permutations, function_spaces, name_from_uflfile, original_coefficient_positions)[source]

Bases: tuple

Create new instance of ExpressionIR(name, element_dimensions, options, unique_tables, unique_table_types, integrand, coefficient_numbering, coefficient_offsets, integral_type, entitytype, tensor_shape, expression_shape, original_constant_offsets, points, coefficient_names, constant_names, needs_facet_permutations, function_spaces, name_from_uflfile, original_coefficient_positions)

coefficient_names: List[str]

Alias for field number 14

coefficient_numbering: Dict[Coefficient, int]

Alias for field number 6

coefficient_offsets: Dict[Coefficient, int]

Alias for field number 7

constant_names: List[str]

Alias for field number 15

element_dimensions: Dict[_ElementBase, int]

Alias for field number 1

entitytype: str

Alias for field number 9

expression_shape: List[int]

Alias for field number 11

function_spaces: Dict[str, Tuple[str, str, str, int, CellType, LagrangeVariant]]

Alias for field number 17

integral_type: str

Alias for field number 8

integrand: Dict[QuadratureRule, dict]

Alias for field number 5

name: str

Alias for field number 0

name_from_uflfile: str

Alias for field number 18

needs_facet_permutations: bool

Alias for field number 16

options: dict

Alias for field number 2

original_coefficient_positions: List[int]

Alias for field number 19

original_constant_offsets: Dict[Constant, int]

Alias for field number 12

points: ndarray[Any, dtype[float64]]

Alias for field number 13

tensor_shape: List[int]

Alias for field number 10

unique_table_types: Dict[str, str]

Alias for field number 4

unique_tables: Dict[str, ndarray[Any, dtype[float64]]]

Alias for field number 3

class ffcx.ir.representation.FormIR(id, name, signature, rank, num_coefficients, num_constants, name_from_uflfile, function_spaces, original_coefficient_position, coefficient_names, constant_names, finite_elements, dofmaps, integral_names, subdomain_ids)[source]

Bases: tuple

Create new instance of FormIR(id, name, signature, rank, num_coefficients, num_constants, name_from_uflfile, function_spaces, original_coefficient_position, coefficient_names, constant_names, finite_elements, dofmaps, integral_names, subdomain_ids)

coefficient_names: List[str]

Alias for field number 9

constant_names: List[str]

Alias for field number 10

dofmaps: List[str]

Alias for field number 12

finite_elements: List[str]

Alias for field number 11

function_spaces: Dict[str, Tuple[str, str, str, int, CellType, LagrangeVariant]]

Alias for field number 7

id: int

Alias for field number 0

integral_names: Dict[str, List[str]]

Alias for field number 13

name: str

Alias for field number 1

name_from_uflfile: str

Alias for field number 6

num_coefficients: int

Alias for field number 4

num_constants: int

Alias for field number 5

original_coefficient_position: List[int]

Alias for field number 8

rank: int

Alias for field number 3

signature: str

Alias for field number 2

subdomain_ids: Dict[str, List[int]]

Alias for field number 14

class ffcx.ir.representation.Integral(integrand, integral_type, domain, subdomain_id, metadata, subdomain_data)[source]

Bases: object

An integral over a single domain.

Initialise.

integral_type()[source]

Return the domain type of this integral.

integrand()[source]

Return the integrand expression, which is an Expr instance.

metadata()[source]

Return the compiler metadata this integral has been annotated with.

reconstruct(integrand=None, integral_type=None, domain=None, subdomain_id=None, metadata=None, subdomain_data=None)[source]

Construct a new Integral object with some properties replaced with new values.

Example

<a = Integral instance> b = a.reconstruct(expand_compounds(a.integrand())) c = a.reconstruct(metadata={‘quadrature_degree’:2})

subdomain_data()[source]

Return the domain data of this integral.

subdomain_id()[source]

Return the subdomain id of this integral.

ufl_domain()[source]

Return the integration domain of this integral.

class ffcx.ir.representation.IntegralIR(integral_type, subdomain_id, rank, geometric_dimension, topological_dimension, entitytype, num_facets, num_vertices, enabled_coefficients, element_dimensions, element_ids, tensor_shape, coefficient_numbering, coefficient_offsets, original_constant_offsets, options, cell_shape, unique_tables, unique_table_types, integrand, name, needs_facet_permutations, coordinate_element, sum_factorization)[source]

Bases: tuple

Create new instance of IntegralIR(integral_type, subdomain_id, rank, geometric_dimension, topological_dimension, entitytype, num_facets, num_vertices, enabled_coefficients, element_dimensions, element_ids, tensor_shape, coefficient_numbering, coefficient_offsets, original_constant_offsets, options, cell_shape, unique_tables, unique_table_types, integrand, name, needs_facet_permutations, coordinate_element, sum_factorization)

cell_shape: str

Alias for field number 16

coefficient_numbering: Dict[Coefficient, int]

Alias for field number 12

coefficient_offsets: Dict[Coefficient, int]

Alias for field number 13

coordinate_element: str

Alias for field number 22

element_dimensions: Dict[_ElementBase, int]

Alias for field number 9

element_ids: Dict[_ElementBase, int]

Alias for field number 10

enabled_coefficients: List[bool]

Alias for field number 8

entitytype: str

Alias for field number 5

geometric_dimension: int

Alias for field number 3

integral_type: str

Alias for field number 0

integrand: Dict[QuadratureRule, dict]

Alias for field number 19

name: str

Alias for field number 20

needs_facet_permutations: bool

Alias for field number 21

num_facets: int

Alias for field number 6

num_vertices: int

Alias for field number 7

options: dict

Alias for field number 15

original_constant_offsets: Dict[Constant, int]

Alias for field number 14

rank: int

Alias for field number 2

subdomain_id: str | Tuple[int, ...] | int

Alias for field number 1

sum_factorization: bool

Alias for field number 23

tensor_shape: List[int]

Alias for field number 11

topological_dimension: int

Alias for field number 4

unique_table_types: Dict[str, str]

Alias for field number 18

unique_tables: Dict[str, ndarray[Any, dtype[float64]]]

Alias for field number 17

class ffcx.ir.representation.QuadratureIR(cell_shape, points, weights)[source]

Bases: tuple

Create new instance of QuadratureIR(cell_shape, points, weights)

cell_shape: str

Alias for field number 0

points: ndarray[Any, dtype[float64]]

Alias for field number 1

weights: ndarray[Any, dtype[float64]]

Alias for field number 2

class ffcx.ir.representation.QuadratureRule(points, weights, tensor_factors=None)[source]

Bases: object

id()[source]

Return unique deterministic identifier.

Note

This identifier is used to provide unique names to tables and symbols in generated code.

class ffcx.ir.representation.UFLData(form_data, unique_elements, element_numbers, unique_coordinate_elements, expressions)[source]

Bases: tuple

Create new instance of UFLData(form_data, unique_elements, element_numbers, unique_coordinate_elements, expressions)

element_numbers: Dict[_ElementBase, int]

Alias for field number 2

expressions: List[Tuple[Expr, ndarray[Any, dtype[float64]], Expr]]

Alias for field number 4

form_data: Tuple[FormData, ...]

Alias for field number 0

unique_coordinate_elements: List[_ElementBase]

Alias for field number 3

unique_elements: List[_ElementBase]

Alias for field number 1

ffcx.ir.representation.compute_integral_ir(cell, integral_type, entitytype, integrands, argument_shape, p, visualise)[source]
ffcx.ir.representation.compute_ir(analysis: UFLData, object_names, prefix, options, visualise)[source]

Compute intermediate representation.

ffcx.ir.representation.create_quadrature_points_and_weights(integral_type, cell, degree, rule, elements, use_tensor_product=False)[source]

Create quadrature rule and return points and weights.

ffcx.ir.representation.sorted_expr_sum(seq)[source]

Sorted expr sum.