ffc.uflacs package

Subpackages

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.