ffc package¶
Subpackages¶
- ffc.errorcontrol package
- ffc.quadrature package
- Submodules
- ffc.quadrature.codesnippets module
- ffc.quadrature.cpp module
- ffc.quadrature.deprecation module
- ffc.quadrature.expr module
- ffc.quadrature.floatvalue module
- ffc.quadrature.fraction module
- ffc.quadrature.optimisedquadraturetransformer module
- ffc.quadrature.parameters module
- ffc.quadrature.product module
- ffc.quadrature.quadraturegenerator module
- ffc.quadrature.quadratureoptimization module
- ffc.quadrature.quadraturerepresentation module
- ffc.quadrature.quadraturetransformer module
- ffc.quadrature.quadraturetransformerbase module
- ffc.quadrature.quadratureutils module
- ffc.quadrature.reduce_operations module
- ffc.quadrature.sumobj module
- ffc.quadrature.symbol module
- ffc.quadrature.symbolics module
- ffc.quadrature.tabulate_basis module
- Module contents
- ffc.tsfc package
- ffc.uflacs package
- Subpackages
- ffc.uflacs.analysis package
- Submodules
- ffc.uflacs.analysis.balancing module
- ffc.uflacs.analysis.crsarray module
- ffc.uflacs.analysis.dependencies module
- ffc.uflacs.analysis.expr_shapes module
- ffc.uflacs.analysis.factorization module
- ffc.uflacs.analysis.graph module
- ffc.uflacs.analysis.graph_rebuild module
- ffc.uflacs.analysis.graph_ssa module
- ffc.uflacs.analysis.graph_symbols module
- ffc.uflacs.analysis.graph_vertices module
- ffc.uflacs.analysis.indexing module
- ffc.uflacs.analysis.modified_terminals module
- ffc.uflacs.analysis.valuenumbering module
- Module contents
- ffc.uflacs.backends package
- Subpackages
- ffc.uflacs.backends.ffc package
- ffc.uflacs.backends.ufc package
- Submodules
- ffc.uflacs.backends.ufc.apply_mappings module
- ffc.uflacs.backends.ufc.coordinate_mapping module
- ffc.uflacs.backends.ufc.dofmap module
- ffc.uflacs.backends.ufc.evalderivs module
- ffc.uflacs.backends.ufc.evaluatebasis module
- ffc.uflacs.backends.ufc.evaluatebasisderivatives module
- ffc.uflacs.backends.ufc.evaluatedof module
- ffc.uflacs.backends.ufc.finite_element module
- ffc.uflacs.backends.ufc.form module
- ffc.uflacs.backends.ufc.generator module
- ffc.uflacs.backends.ufc.generators module
- ffc.uflacs.backends.ufc.integrals module
- ffc.uflacs.backends.ufc.jacobian module
- ffc.uflacs.backends.ufc.templates module
- ffc.uflacs.backends.ufc.utils module
- Module contents
- Module contents
- Subpackages
- ffc.uflacs.language package
- ffc.uflacs.analysis package
- Submodules
- ffc.uflacs.build_uflacs_ir module
- ffc.uflacs.elementtables module
- ffc.uflacs.integralgenerator module
- ffc.uflacs.params module
- ffc.uflacs.tools module
- ffc.uflacs.uflacsgenerator module
- ffc.uflacs.uflacsoptimization module
- ffc.uflacs.uflacsrepresentation module
- Module contents
- Subpackages
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_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.codegeneration module¶
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.fiatinterface module¶
-
class
ffc.fiatinterface.
SpaceOfReals
[source]¶ Bases:
object
Constant over the entire domain, rather than just cellwise.
-
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.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.git_commit_hash module¶
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.
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.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.
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.optimization module¶
ffc.parameters module¶
-
ffc.parameters.
compute_jit_parameters_signature
(parameters)[source]¶ Return parameters signature (some parameters must be ignored).
-
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.plot module¶
This module provides functionality for plotting finite elements.
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.
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.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.
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.
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.
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.wrappers module¶
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)