FENICSFORMCOMPILERX(1) | FEniCS Form Compiler X | FENICSFORMCOMPILERX(1) |
fenicsformcompilerx - FEniCS Form Compiler X Documentation
The is an experimental version of the FEniCS Form Compiler. It is developed at https://github.com/FEniCS/ffcx.
ffcx | FEniCS Form Compiler (FFCx). |
ffcx.__main__ | |
ffcx.analysis | Compiler stage 1: Analysis. |
ffcx.compiler | Main interface for compilation of forms. |
ffcx.element_interface | Finite element interface. |
ffcx.formatting | Compiler stage 5: Code formatting. |
ffcx.main | Command-line interface to FFCx. |
ffcx.naming | |
ffcx.codegeneration | |
ffcx.parameters | |
ffcx.ir.representation | Compiler stage 2: Code representation. |
ffcx.ir.representationutils | Utility functions for some code shared between representations. |
FEniCS Form Compiler (FFCx).
FFCx compiles finite element variational forms into C code.
Notes
This function sets the log level from the merged parameter values prior to returning.
The ffcx_parameters.json files are cached on the first call. Subsequent calls to this function use this cache.
Priority ordering of parameters from highest to lowest is:
XDG_CONFIG_HOME is ~/.config/ if the environment variable is not set.
Example ffcx_parameters.json file:
Compiler stage 1: Analysis.
This module implements the analysis/preprocessing of variational forms, including automatic selection of elements, degrees and form representation type.
Functions
analyze_ufl_objects(ufl_objects, parameters) | Analyze ufl object(s). |
Classes
UFLData(form_data, unique_elements, ...) | Create new instance of UFLData(form_data, unique_elements, element_numbers, unique_coordinate_elements, expressions) |
Create new instance of UFLData(form_data, unique_elements, element_numbers, unique_coordinate_elements, expressions)
Main interface for compilation of forms.
Breaks the compilation into several sequential stages. The output of each stage is the input of the next stage.
This stage consists of parsing and expressing a form in the UFL form language. This stage is handled by UFL.
This stage preprocesses the UFL form and extracts form metadata. It may also perform simplifications on the form.
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.
This stage examines the IR 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.
This stage examines the generated C++ code and formats it according to the UFC format, generating as output one or more .h/.c files conforming to the UFC format.
Functions
compile_ufl_objects(ufl_objects[, ...]) | Generate UFC code for a given UFL objects. |
Finite element interface.
Functions
basix_index(indices) | Get the Basix index of a derivative. |
convert_element(element) | Convert and element to a FFCx element. |
create_element(element) | Create an FFCx element from a UFL element. |
create_quadrature(cellname, degree, rule) | Create a quadrature rule. |
map_facet_points(points, facet, cellname) | Map points from a reference facet to a physical facet. |
reference_cell_vertices(cellname) | Get the vertices of a reference cell. |
Classes
QuadratureElement(element) | A quadrature element. |
A quadrature element.
Initialise the element.
If maxsize is set to None, the LRU features are disabled and the cache can grow without bound.
If typed is True, arguments of different types will be cached separately. For example, f(3.0) and f(3) will be treated as distinct calls with distinct results.
Arguments to the cached function must be hashable.
View the cache statistics named tuple (hits, misses, maxsize, currsize) with f.cache_info(). Clear the cache and statistics with f.cache_clear(). Access the underlying function with f.__wrapped__.
See: https://en.wikipedia.org/wiki/Cache_replacement_policies#Least_recently_used_(LRU)
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 ufcx_utils.
Functions
format_code(code, parameters) | Format given code in UFC format. |
write_code(code_h, code_c, prefix, output_dir) |
Command-line interface to FFCx.
Parse command-line arguments and generate code from input UFL form files.
Functions
main([args]) |
Notes
This function sets the log level from the merged parameter values prior to returning.
The ffcx_parameters.json files are cached on the first call. Subsequent calls to this function use this cache.
Priority ordering of parameters from highest to lowest is:
XDG_CONFIG_HOME is ~/.config/ if the environment variable is not set.
Example ffcx_parameters.json file:
Functions
cdtype_to_numpy(cdtype) | Map a C data type string NumPy datatype string. |
compute_signature(ufl_objects, tag) | Compute the signature hash. |
dofmap_name(ufl_element, prefix) | |
expression_name(expression, prefix) | |
finite_element_name(ufl_element, prefix) | |
form_name(original_form, form_id, prefix) | |
integral_name(original_form, integral_type, ...) | |
scalar_to_value_type(scalar_type) | The C value type associated with a C scalar type. |
Based on the UFL type of the objects and an additional optional ‘tag’.
Functions
get_include_path() | Return location of UFC header files. |
get_signature() | Return SHA-1 hash of the contents of ufcx.h. |
In this implementation, the value is computed on import.
Functions
get_parameters([priority_parameters]) | Return (a copy of) the merged parameter values for FFCX. |
Special type indicating an unconstrained type.
Note that all the above statements are true from the point of view of static type checkers. At runtime, Any should not be used with instance checks.
PurePath subclass that can make system calls.
Path represents a filesystem path but unlike PurePath, also offers methods to do system calls on path objects. Depending on your system, instantiating a Path will return either a PosixPath or a WindowsPath object. You can also instantiate a PosixPath or WindowsPath directly, but cannot instantiate a WindowsPath on a POSIX system or vice versa.
Construct a PurePath from one or several strings and or existing PurePath objects. The strings and path objects are combined so as to yield a canonicalized path, which is incorporated into the new PurePath object.
Use resolve() to get the canonical path to a file.
Note the order of arguments (self, target) is the reverse of os.link’s.
Note this function does not make this path a hard link to target, despite the implication of the function and argument names. The order of arguments (target, link) is the reverse of Path.symlink_to, but matches that of os.link.
Deprecated since Python 3.10 and scheduled for removal in Python 3.12. Use hardlink_to() instead.
The target path may be absolute or relative. Relative paths are interpreted relative to the current working directory, not the directory of the Path object.
Returns the new Path instance pointing to the target path.
The target path may be absolute or relative. Relative paths are interpreted relative to the current working directory, not the directory of the Path object.
Returns the new Path instance pointing to the target path.
Notes
This function sets the log level from the merged parameter values prior to returning.
The ffcx_parameters.json files are cached on the first call. Subsequent calls to this function use this cache.
Priority ordering of parameters from highest to lowest is:
XDG_CONFIG_HOME is ~/.config/ if the environment variable is not set.
Example ffcx_parameters.json file:
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, interpolation_nderivs, discontinuous, highest_complete_degree, highest_degree) |
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, family, num_sub_elements, block_size, sub_elements, element_type, entity_dofs, lagrange_variant, dpc_variant, basix_family, basix_cell, discontinuous, custom_element) |
ExpressionIR(name, element_dimensions, ...) | Create new instance of ExpressionIR(name, element_dimensions, params, 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, params, cell_shape, unique_tables, unique_table_types, integrand, name, precision, needs_facet_permutations, coordinate_element) |
Create new instance of CustomElementIR(cell_type, value_shape, wcoeffs, x, M, map_type, interpolation_nderivs, discontinuous, highest_complete_degree, highest_degree)
Create new instance of DataIR(elements, dofmaps, integrals, forms, expressions)
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)
Create new instance of ElementIR(id, name, signature, cell_shape, topological_dimension, geometric_dimension, space_dimension, value_shape, reference_value_shape, degree, family, num_sub_elements, block_size, sub_elements, element_type, entity_dofs, lagrange_variant, dpc_variant, basix_family, basix_cell, discontinuous, custom_element)
Create new instance of ExpressionIR(name, element_dimensions, params, 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)
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)
An integral over a single domain.
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, params, cell_shape, unique_tables, unique_table_types, integrand, name, precision, needs_facet_permutations, coordinate_element)
NOTE:
Create new instance of UFLData(form_data, unique_elements, element_numbers, unique_coordinate_elements, expressions)
Utility functions for some code shared between representations.
Functions
create_quadrature_points_and_weights(...) | Create quadrature rule and return points and weights. |
integral_type_to_entity_dim(integral_type, tdim) | Given integral_type and domain tdim, return the tdim of the integration entity. |
map_integral_points(points, integral_type, ...) | Map points from reference entity to its parent reference cell. |
Classes
QuadratureRule(points, weights) |
NOTE:
FEniCS Project
2023, FEniCS Project
February 15, 2023 | 0.5.0 |