Provided by: python3-ffcx_0.4.2-2_all
NAME
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. │ └────────────────────────────┴──────────────────────────────────┘
FFCX
FEniCS Form Compiler (FFCx). FFCx compiles finite element variational forms into C code. ffcx.get_parameters(priority_parameters: Optional[dict] = None) -> dict Return (a copy of) the merged parameter values for FFCX. Parameters priority_parameters – take priority over all other parameter values (see notes) Returns dict Return type merged parameter values 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: • priority_parameters (API and command line parameters) • $PWD/ffcx_parameters.json (local parameters) • $XDG_CONFIG_HOME/ffcx/ffcx_parameters.json (user parameters) • FFCX_DEFAULT_PARAMETERS in ffcx.parameters XDG_CONFIG_HOME is ~/.config/ if the environment variable is not set. Example ffcx_parameters.json file: { “assume_aligned”: 32, “epsilon”: 1e-7 }
FFCX.__MAIN__
ffcx.__main__.main(args=None)
FFCX.ANALYSIS
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, │ Analyze ufl object(s). │ │parameters) │ │ └─────────────────────────────────┴────────────────────────┘ Classes ┌──────────────────────┬──────────────────────────────────┐ │ufl_data(form_data, │ Create new instance of │ │unique_elements, ...) │ ufl_data(form_data, │ │ │ unique_elements, │ │ │ element_numbers, │ │ │ unique_coordinate_elements, │ │ │ expressions) │ └──────────────────────┴──────────────────────────────────┘ ffcx.analysis.analyze_ufl_objects(ufl_objects: List, parameters: Dict) -> ffcx.analysis.ufl_data Analyze ufl object(s). Parameters • ufl_objects – • parameters – FFCx parameters. These parameters take priority over all other set parameters. Returns • form_datas – Form_data objects • unique_elements – Unique elements across all forms • element_numbers – Mapping to unique numbers for all elements • unique_coordinate_elements ffcx.analysis.namedtuple(typename, field_names, *, rename=False, defaults=None, module=None) Returns a new subclass of tuple with named fields. >>> Point = namedtuple('Point', ['x', 'y']) >>> Point.__doc__ # docstring for the new class 'Point(x, y)' >>> p = Point(11, y=22) # instantiate with positional args or keywords >>> p[0] + p[1] # indexable like a plain tuple 33 >>> x, y = p # unpack like a regular tuple >>> x, y (11, 22) >>> p.x + p.y # fields also accessible by name 33 >>> d = p._asdict() # convert to a dictionary >>> d['x'] 11 >>> Point(**d) # convert from a dictionary Point(x=11, y=22) >>> p._replace(x=100) # _replace() is like str.replace() but targets named fields Point(x=100, y=22) class ffcx.analysis.ufl_data(form_data, unique_elements, element_numbers, unique_coordinate_elements, expressions) Bases: tuple Create new instance of ufl_data(form_data, unique_elements, element_numbers, unique_coordinate_elements, expressions) element_numbers Alias for field number 2 expressions Alias for field number 4 form_data Alias for field number 0 unique_coordinate_elements Alias for field number 3 unique_elements Alias for field number 1
FFCX.COMPILER
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. Compiler stages 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 handled by UFL. 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. 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. 3. Code generation • Input: Intermediate Representation (IR) • Output: C 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. 4. 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/.c files conforming to the UFC format. Functions ┌──────────────────────────────────┬──────────────────────────────────┐ │compile_ufl_objects(ufl_objects[, │ Generate UFC code for a given │ │...]) │ UFL objects. │ └──────────────────────────────────┴──────────────────────────────────┘ ffcx.compiler.analyze_ufl_objects(ufl_objects: List, parameters: Dict) -> ffcx.analysis.ufl_data Analyze ufl object(s). Parameters • ufl_objects – • parameters – FFCx parameters. These parameters take priority over all other set parameters. Returns • form_datas – Form_data objects • unique_elements – Unique elements across all forms • element_numbers – Mapping to unique numbers for all elements • unique_coordinate_elements ffcx.compiler.compile_ufl_objects(ufl_objects: List[Any], object_names: Dict = {}, prefix: Optional[str] = None, parameters: Dict = {}, visualise: bool = False) Generate UFC code for a given UFL objects. Parameters ufl_objects (@param) – Objects to be compiled. Accepts elements, forms, integrals or coordinate mappings. ffcx.compiler.compute_ir(analysis, object_names, prefix, parameters, visualise) Compute intermediate representation. ffcx.compiler.format_code(code, parameters) Format given code in UFC format. Returns two strings with header and source file contents. ffcx.compiler.generate_code(ir, parameters) Generate code blocks from intermediate representation. ffcx.compiler.time() -> floating point number Return the current time in seconds since the Epoch. Fractions of a second may be present if the system clock provides them.
FFCX.ELEMENT_INTERFACE
Finite element interface. Functions ┌──────────────────────────────────┬──────────────────────────────────┐ │basix_index(*args) │ Get the Basix index of a │ │ │ derivative. │ ├──────────────────────────────────┼──────────────────────────────────┤ │create_basix_element(family_type, │ Create a basix element. │ │cell_type, ...) │ │ ├──────────────────────────────────┼──────────────────────────────────┤ │create_element(element) │ Create an FFCx element from a │ │ │ UFL element. │ ├──────────────────────────────────┼──────────────────────────────────┤ │create_quadrature(cellname, │ Create a quadrature rule. │ │degree, rule) │ │ ├──────────────────────────────────┼──────────────────────────────────┤ │map_facet_points(points, facet, │ Map points from a reference │ │cellname) │ facet to a physical facet. │ ├──────────────────────────────────┼──────────────────────────────────┤ │reference_cell_vertices(cellname) │ Get the vertices of a reference │ │ │ cell. │ └──────────────────────────────────┴──────────────────────────────────┘ Classes ┌───────────────────────────────┬──────────────────────────────────┐ │BaseElement() │ An abstract element class. │ ├───────────────────────────────┼──────────────────────────────────┤ │BasixElement(element) │ An element defined by Basix. │ ├───────────────────────────────┼──────────────────────────────────┤ │BlockedElement(sub_element, │ An element with a block size │ │block_size[, ...]) │ that contains multiple copies of │ │ │ a sub element. │ ├───────────────────────────────┼──────────────────────────────────┤ │ComponentElement(element, │ An element representing one │ │component) │ component of a BasixElement. │ ├───────────────────────────────┼──────────────────────────────────┤ │MixedElement(sub_elements) │ A mixed element that combines │ │ │ two or more elements. │ ├───────────────────────────────┼──────────────────────────────────┤ │QuadratureElement(ufl_element) │ A quadrature element. │ └───────────────────────────────┴──────────────────────────────────┘ class ffcx.element_interface.ABC Bases: object Helper class that provides a standard way to create an ABC using inheritance. class ffcx.element_interface.BaseElement Bases: abc.ABC An abstract element class. abstract property cell_type Basix cell type used to initialise the element. abstract property dim: int Number of DOFs the element has. abstract property discontinuous: bool True if the discontinuous version of the element is used. abstract property dpc_variant Basix DPC variant used to initialise the element. abstract property element_family Basix element family used to initialise the element. property element_type Element type. abstract property entity_closure_dofs DOF numbers associated with the closure of each entity. abstract property entity_dofs DOF numbers associated with each entity. abstract property family_name: str Family name of the element. abstract get_component_element(flat_component: int) -> tuple[‐ ffcx.element_interface.BaseElement, int, int] Get element that represents a component of the element, and the offset and stride of the component. For example, for a MixedElement, this will return the sub-element that represents the given component, the offset of that sub-element, and a stride of 1. For a BlockedElement, this will return the sub-element, an offset equal to the component number, and a stride equal to the block size. For vector-valued element (eg H(curl) and H(div) elements), this returns a ComponentElement (and as offset of 0 and a stride of 1). When tabulate is called on the ComponentElement, only the part of the table for the given component is returned. Parameters flat_component – The component Returns component element, offset of the component, stride of the component property is_custom_element: bool True if the element is a custom Basix element. abstract property lagrange_variant Basix Lagrange variant used to initialise the element. abstract property num_entity_closure_dofs Number of DOFs associated with the closure of each entity. abstract property num_entity_dofs Number of DOFs associated with each entity. abstract property num_global_support_dofs abstract property reference_geometry Geometry of the reference element. abstract property reference_topology Topology of the reference element. abstract tabulate(nderivs: int, points: numpy.ndarray) Tabulate the basis functions of the element. Parameters • nderivs – Number of derivatives to tabulate. • points – Points to tabulate at Returns Tabulated basis functions abstract property value_shape: Tuple[int, ...] Value shape of the element basis function. NOTE: For scalar elements, (1,) is returned. This is different from Basix where the value shape for scalar elements is (,). abstract property value_size: int Value size of the element. Equal to numpy.prod(value_shape). class ffcx.element_interface.BasixElement(element) Bases: ffcx.element_interface.BaseElement An element defined by Basix. property cell_type Basix cell type used to initialise the element. property dim Number of DOFs the element has. property discontinuous True if the discontinuous version of the element is used. property dpc_variant Basix DPC variant used to initialise the element. property element_family Basix element family used to initialise the element. property element_type: str Element type. property entity_closure_dofs DOF numbers associated with the closure of each entity. property entity_dofs DOF numbers associated with each entity. property family_name Family name of the element. get_component_element(flat_component) Get element that represents a component of the element, and the offset and stride of the component. For example, for a MixedElement, this will return the sub-element that represents the given component, the offset of that sub-element, and a stride of 1. For a BlockedElement, this will return the sub-element, an offset equal to the component number, and a stride equal to the block size. For vector-valued element (eg H(curl) and H(div) elements), this returns a ComponentElement (and as offset of 0 and a stride of 1). When tabulate is called on the ComponentElement, only the part of the table for the given component is returned. Parameters flat_component – The component Returns component element, offset of the component, stride of the component property is_custom_element: bool True if the element is a custom Basix element. property lagrange_variant Basix Lagrange variant used to initialise the element. property num_entity_closure_dofs Number of DOFs associated with the closure of each entity. property num_entity_dofs Number of DOFs associated with each entity. property num_global_support_dofs property reference_geometry Geometry of the reference element. property reference_topology Topology of the reference element. tabulate(nderivs, points) Tabulate the basis functions of the element. Parameters • nderivs – Number of derivatives to tabulate. • points – Points to tabulate at Returns Tabulated basis functions property value_shape Get the value shape of the element. property value_size Value size of the element. Equal to numpy.prod(value_shape). class ffcx.element_interface.BlockedElement(sub_element, block_size, block_shape=None) Bases: ffcx.element_interface.BaseElement An element with a block size that contains multiple copies of a sub element. property cell_type Basix cell type used to initialise the element. property dim Number of DOFs the element has. property discontinuous True if the discontinuous version of the element is used. property dpc_variant Basix DPC variant used to initialise the element. property element_family Basix element family used to initialise the element. property element_type Element type. property entity_closure_dofs DOF numbers associated with the closure of each entity. property entity_dofs DOF numbers associated with each entity. property family_name Family name of the element. get_component_element(flat_component) Get element that represents a component of the element, and the offset and stride of the component. For example, for a MixedElement, this will return the sub-element that represents the given component, the offset of that sub-element, and a stride of 1. For a BlockedElement, this will return the sub-element, an offset equal to the component number, and a stride equal to the block size. For vector-valued element (eg H(curl) and H(div) elements), this returns a ComponentElement (and as offset of 0 and a stride of 1). When tabulate is called on the ComponentElement, only the part of the table for the given component is returned. Parameters flat_component – The component Returns component element, offset of the component, stride of the component property lagrange_variant Basix Lagrange variant used to initialise the element. property num_entity_closure_dofs Number of DOFs associated with the closure of each entity. property num_entity_dofs Number of DOFs associated with each entity. property num_global_support_dofs property reference_geometry Geometry of the reference element. property reference_topology Topology of the reference element. tabulate(nderivs, points) Tabulate the basis functions of the element. Parameters • nderivs – Number of derivatives to tabulate. • points – Points to tabulate at Returns Tabulated basis functions property value_shape Value shape of the element basis function. NOTE: For scalar elements, (1,) is returned. This is different from Basix where the value shape for scalar elements is (,). property value_size Value size of the element. Equal to numpy.prod(value_shape). class ffcx.element_interface.ComponentElement(element, component) Bases: ffcx.element_interface.BaseElement An element representing one component of a BasixElement. property cell_type Basix cell type used to initialise the element. property dim Number of DOFs the element has. property discontinuous True if the discontinuous version of the element is used. property dpc_variant Basix DPC variant used to initialise the element. property element_family Basix element family used to initialise the element. property entity_closure_dofs DOF numbers associated with the closure of each entity. property entity_dofs DOF numbers associated with each entity. property family_name: str Family name of the element. get_component_element(flat_component) Get element that represents a component of the element, and the offset and stride of the component. For example, for a MixedElement, this will return the sub-element that represents the given component, the offset of that sub-element, and a stride of 1. For a BlockedElement, this will return the sub-element, an offset equal to the component number, and a stride equal to the block size. For vector-valued element (eg H(curl) and H(div) elements), this returns a ComponentElement (and as offset of 0 and a stride of 1). When tabulate is called on the ComponentElement, only the part of the table for the given component is returned. Parameters flat_component – The component Returns component element, offset of the component, stride of the component property lagrange_variant Basix Lagrange variant used to initialise the element. property num_entity_closure_dofs Number of DOFs associated with the closure of each entity. property num_entity_dofs Number of DOFs associated with each entity. property num_global_support_dofs property reference_geometry Geometry of the reference element. property reference_topology Topology of the reference element. tabulate(nderivs, points) Tabulate the basis functions of the element. Parameters • nderivs – Number of derivatives to tabulate. • points – Points to tabulate at Returns Tabulated basis functions property value_shape Value shape of the element basis function. NOTE: For scalar elements, (1,) is returned. This is different from Basix where the value shape for scalar elements is (,). property value_size Value size of the element. Equal to numpy.prod(value_shape). class ffcx.element_interface.MixedElement(sub_elements) Bases: ffcx.element_interface.BaseElement A mixed element that combines two or more elements. property cell_type Basix cell type used to initialise the element. property dim Number of DOFs the element has. property discontinuous True if the discontinuous version of the element is used. property dpc_variant Basix DPC variant used to initialise the element. property element_family Basix element family used to initialise the element. property element_type: str Get the element type. property entity_closure_dofs DOF numbers associated with the closure of each entity. property entity_dofs DOF numbers associated with each entity. property family_name Family name of the element. get_component_element(flat_component) Get element that represents a component of the element, and the offset and stride of the component. For example, for a MixedElement, this will return the sub-element that represents the given component, the offset of that sub-element, and a stride of 1. For a BlockedElement, this will return the sub-element, an offset equal to the component number, and a stride equal to the block size. For vector-valued element (eg H(curl) and H(div) elements), this returns a ComponentElement (and as offset of 0 and a stride of 1). When tabulate is called on the ComponentElement, only the part of the table for the given component is returned. Parameters flat_component – The component Returns component element, offset of the component, stride of the component property lagrange_variant Basix Lagrange variant used to initialise the element. property num_entity_closure_dofs Number of DOFs associated with the closure of each entity. property num_entity_dofs Number of DOFs associated with each entity. property num_global_support_dofs property reference_geometry Geometry of the reference element. property reference_topology Topology of the reference element. tabulate(nderivs, points) Tabulate the basis functions of the element. Parameters • nderivs – Number of derivatives to tabulate. • points – Points to tabulate at Returns Tabulated basis functions property value_shape Value shape of the element basis function. NOTE: For scalar elements, (1,) is returned. This is different from Basix where the value shape for scalar elements is (,). property value_size Value size of the element. Equal to numpy.prod(value_shape). class ffcx.element_interface.QuadratureElement(ufl_element) Bases: ffcx.element_interface.BaseElement A quadrature element. property cell_type: None Basix cell type used to initialise the element. property dim Number of DOFs the element has. property discontinuous True if the discontinuous version of the element is used. property dpc_variant Basix DPC variant used to initialise the element. property element_family Basix element family used to initialise the element. property element_type: str Element type. property entity_closure_dofs DOF numbers associated with the closure of each entity. property entity_dofs DOF numbers associated with each entity. property family_name Family name of the element. get_component_element(flat_component) Get element that represents a component of the element, and the offset and stride of the component. For example, for a MixedElement, this will return the sub-element that represents the given component, the offset of that sub-element, and a stride of 1. For a BlockedElement, this will return the sub-element, an offset equal to the component number, and a stride equal to the block size. For vector-valued element (eg H(curl) and H(div) elements), this returns a ComponentElement (and as offset of 0 and a stride of 1). When tabulate is called on the ComponentElement, only the part of the table for the given component is returned. Parameters flat_component – The component Returns component element, offset of the component, stride of the component property lagrange_variant Basix Lagrange variant used to initialise the element. property num_entity_closure_dofs Number of DOFs associated with the closure of each entity. property num_entity_dofs Number of DOFs associated with each entity. property num_global_support_dofs property reference_geometry Geometry of the reference element. property reference_topology Topology of the reference element. tabulate(nderivs, points) Tabulate the basis functions of the element. Parameters • nderivs – Number of derivatives to tabulate. • points – Points to tabulate at Returns Tabulated basis functions property value_shape Value shape of the element basis function. NOTE: For scalar elements, (1,) is returned. This is different from Basix where the value shape for scalar elements is (,). property value_size Value size of the element. Equal to numpy.prod(value_shape). ffcx.element_interface.abstractmethod(funcobj) A decorator indicating abstract methods. Requires that the metaclass is ABCMeta or derived from it. A class that has a metaclass derived from ABCMeta cannot be instantiated unless all of its abstract methods are overridden. The abstract methods can be called using any of the normal ‘super’ call mechanisms. abstractmethod() may be used to declare abstract methods for properties and descriptors. Usage: class C(metaclass=ABCMeta): @abstractmethod def my_abstract_method(self, …): … ffcx.element_interface.basix_index(*args) Get the Basix index of a derivative. ffcx.element_interface.create_basix_element(family_type, cell_type, degree, variant_info, discontinuous) Create a basix element. ffcx.element_interface.create_element(element: ufl.finiteelement.finiteelementbase.FiniteElementBase) -> ffcx.element_interface.BaseElement Create an FFCx element from a UFL element. Parameters element – A UFL finite element Returns A FFCx finite element ffcx.element_interface.create_quadrature(cellname, degree, rule) Create a quadrature rule. ffcx.element_interface.map_facet_points(points, facet, cellname) Map points from a reference facet to a physical facet. ffcx.element_interface.reference_cell_vertices(cellname) Get the vertices of a reference cell.
FFCX.FORMATTING
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) │ │ └─────────────────────────────────┴──────────────────────────────────┘ ffcx.formatting.format_code(code, parameters) Format given code in UFC format. Returns two strings with header and source file contents. ffcx.formatting.write_code(code_h, code_c, prefix, output_dir)
FFCX.MAIN
Command-line interface to FFCx. Parse command-line arguments and generate code from input UFL form files. Functions ┌─────────────┬───┐ │main([args]) │ │ └─────────────┴───┘ ffcx.main.get_parameters(priority_parameters: Optional[dict] = None) -> dict Return (a copy of) the merged parameter values for FFCX. Parameters priority_parameters – take priority over all other parameter values (see notes) Returns dict Return type merged parameter values 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: • priority_parameters (API and command line parameters) • $PWD/ffcx_parameters.json (local parameters) • $XDG_CONFIG_HOME/ffcx/ffcx_parameters.json (user parameters) • FFCX_DEFAULT_PARAMETERS in ffcx.parameters XDG_CONFIG_HOME is ~/.config/ if the environment variable is not set. Example ffcx_parameters.json file: { “assume_aligned”: 32, “epsilon”: 1e-7 } ffcx.main.main(args=None)
FFCX.NAMING
Functions ┌─────────────────────────────────┬──────────────────────────────────┐ │cdtype_to_numpy(cdtype) │ Map a C data type string NumPy │ │ │ datatype string. │ ├─────────────────────────────────┼──────────────────────────────────┤ │compute_signature(ufl_objects, │ Compute the signature hash. │ │tag) │ │ ├─────────────────────────────────┼──────────────────────────────────┤ │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, ...) │ │ └─────────────────────────────────┴──────────────────────────────────┘ ffcx.naming.cdtype_to_numpy(cdtype) Map a C data type string NumPy datatype string. ffcx.naming.compute_signature(ufl_objects, tag) Compute the signature hash. Based on the UFL type of the objects and an additional optional ‘tag’. ffcx.naming.dofmap_name(ufl_element, prefix) ffcx.naming.expression_name(expression, prefix) ffcx.naming.finite_element_name(ufl_element, prefix) ffcx.naming.form_name(original_form, form_id, prefix) ffcx.naming.integral_name(original_form, integral_type, form_id, subdomain_id, prefix)
FFCX.CODEGENERATION
Functions ┌───────────────────┬──────────────────────────────────┐ │get_include_path() │ Return location of UFC header │ │ │ files. │ ├───────────────────┼──────────────────────────────────┤ │get_signature() │ Return SHA-1 hash of the │ │ │ contents of ufcx.h. │ └───────────────────┴──────────────────────────────────┘ ffcx.codegeneration.get_include_path() Return location of UFC header files. ffcx.codegeneration.get_signature() Return SHA-1 hash of the contents of ufcx.h. In this implementation, the value is computed on import.
FFCX.PARAMETERS
Functions ┌──────────────────────────────────────┬──────────────────────────────────┐ │get_parameters([priority_parameters]) │ Return (a copy of) the merged │ │ │ parameter values for FFCX. │ └──────────────────────────────────────┴──────────────────────────────────┘ class ffcx.parameters.Path(*args, **kwargs) Bases: pathlib.PurePath 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. absolute() Return an absolute version of this path. This function works even if the path doesn’t point to anything. No normalization is done, i.e. all ‘.’ and ‘..’ will be kept along. Use resolve() to get the canonical path to a file. chmod(mode, *, follow_symlinks=True) Change the permissions of the path, like os.chmod(). classmethod cwd() Return a new path pointing to the current working directory (as returned by os.getcwd()). exists() Whether this path exists. expanduser() Return a new path with expanded ~ and ~user constructs (as returned by os.path.expanduser) glob(pattern) Iterate over this subtree and yield all existing files (of any kind, including directories) matching the given relative pattern. group() Return the group name of the file gid. hardlink_to(target) Make this path a hard link pointing to the same file as target. Note the order of arguments (self, target) is the reverse of os.link’s. classmethod home() Return a new path pointing to the user’s home directory (as returned by os.path.expanduser(‘~’)). is_block_device() Whether this path is a block device. is_char_device() Whether this path is a character device. is_dir() Whether this path is a directory. is_fifo() Whether this path is a FIFO. is_file() Whether this path is a regular file (also True for symlinks pointing to regular files). is_mount() Check if this path is a POSIX mount point is_socket() Whether this path is a socket. is_symlink() Whether this path is a symbolic link. iterdir() Iterate over the files in this directory. Does not yield any result for the special paths ‘.’ and ‘..’. lchmod(mode) Like chmod(), except if the path points to a symlink, the symlink’s permissions are changed, rather than its target’s. link_to(target) Make the target path a hard link pointing to this path. 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. lstat() Like stat(), except if the path points to a symlink, the symlink’s status information is returned, rather than its target’s. mkdir(mode=511, parents=False, exist_ok=False) Create a new directory at this given path. open(mode='r', buffering=- 1, encoding=None, errors=None, newline=None) Open the file pointed by this path and return a file object, as the built-in open() function does. owner() Return the login name of the file owner. read_bytes() Open the file in bytes mode, read it, and close the file. read_text(encoding=None, errors=None) Open the file in text mode, read it, and close the file. readlink() Return the path to which the symbolic link points. rename(target) Rename this path 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. replace(target) Rename this path to the target path, overwriting if that path exists. 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. resolve(strict=False) Make the path absolute, resolving all symlinks on the way and also normalizing it (for example turning slashes into backslashes under Windows). rglob(pattern) Recursively yield all existing files (of any kind, including directories) matching the given relative pattern, anywhere in this subtree. rmdir() Remove this directory. The directory must be empty. samefile(other_path) Return whether other_path is the same or not as this file (as returned by os.path.samefile()). stat(*, follow_symlinks=True) Return the result of the stat() system call on this path, like os.stat() does. symlink_to(target, target_is_directory=False) Make this path a symlink pointing to the target path. Note the order of arguments (link, target) is the reverse of os.symlink. touch(mode=438, exist_ok=True) Create this file with the given access mode, if it doesn’t exist. unlink(missing_ok=False) Remove this file or link. If the path is a directory, use rmdir() instead. write_bytes(data) Open the file in bytes mode, write to it, and close the file. write_text(data, encoding=None, errors=None, newline=None) Open the file in text mode, write to it, and close the file. ffcx.parameters.get_parameters(priority_parameters: Optional[dict] = None) -> dict Return (a copy of) the merged parameter values for FFCX. Parameters priority_parameters – take priority over all other parameter values (see notes) Returns dict Return type merged parameter values 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: • priority_parameters (API and command line parameters) • $PWD/ffcx_parameters.json (local parameters) • $XDG_CONFIG_HOME/ffcx/ffcx_parameters.json (user parameters) • FFCX_DEFAULT_PARAMETERS in ffcx.parameters XDG_CONFIG_HOME is ~/.config/ if the environment variable is not set. Example ffcx_parameters.json file: { “assume_aligned”: 32, “epsilon”: 1e-7 }
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, │ Compute intermediate │ │object_names, prefix, ...) │ representation. │ └───────────────────────────┴──────────────────────────────────┘ Classes ┌─────────────────────────────────┬──────────────────────────────────┐ │ir_custom_element(cell_type, │ Create new instance of │ │value_shape, ...) │ ir_custom_element(cell_type, │ │ │ value_shape, wcoeffs, x, M, │ │ │ map_type, discontinuous, │ │ │ highest_complete_degree, │ │ │ highest_degree) │ ├─────────────────────────────────┼──────────────────────────────────┤ │ir_data(elements, dofmaps, │ Create new instance of │ │integrals, forms, ...) │ ir_data(elements, dofmaps, │ │ │ integrals, forms, expressions) │ ├─────────────────────────────────┼──────────────────────────────────┤ │ir_dofmap(id, name, signature, │ Create new instance of │ │...) │ ir_dofmap(id, name, signature, │ │ │ num_global_support_dofs, │ │ │ num_element_support_dofs, │ │ │ num_entity_dofs, │ │ │ tabulate_entity_dofs, │ │ │ num_entity_closure_dofs, │ │ │ tabulate_entity_closure_dofs, │ │ │ num_sub_dofmaps, sub_dofmaps, │ │ │ block_size) │ └─────────────────────────────────┴──────────────────────────────────┘ │ir_element(id, name, signature, │ Create new instance of │ │cell_shape, ...) │ ir_element(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) │ ├─────────────────────────────────┼──────────────────────────────────┤ │ir_expression(name, │ Create new instance of │ │element_dimensions, ...) │ ir_expression(name, │ │ │ element_dimensions, params, │ │ │ unique_tables, │ │ │ unique_table_types, integrand, │ │ │ table_dofmaps, │ │ │ coefficient_numbering, │ │ │ coefficient_offsets, │ │ │ integral_type, entitytype, │ │ │ tensor_shape, expression_shape, │ │ │ original_constant_offsets, │ │ │ original_coefficient_positions, │ │ │ points, coefficient_names, │ │ │ constant_names, │ │ │ needs_facet_permutations, │ │ │ function_spaces, │ │ │ name_from_uflfile) │ ├─────────────────────────────────┼──────────────────────────────────┤ │ir_form(id, name, signature, │ Create new instance of │ │rank, ...) │ ir_form(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) │ ├─────────────────────────────────┼──────────────────────────────────┤ │ir_integral(integral_type, │ Create new instance of │ │subdomain_id, ...) │ ir_integral(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, │ │ │ table_dofmaps, integrand, name, │ │ │ precision, │ │ │ needs_facet_permutations, │ │ │ coordinate_element) │ └─────────────────────────────────┴──────────────────────────────────┘ class ffcx.ir.representation.Integral(integrand, integral_type, domain, subdomain_id, metadata, subdomain_data) Bases: object An integral over a single domain. integral_type() Return the domain type of this integral. integrand() Return the integrand expression, which is an Expr instance. metadata() 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) Construct a new Integral object with some properties replaced with new values. <a = Integral instance> b = a.reconstruct(expand_compounds(a.integrand())) c = a.reconstruct(metadata={‘quadrature_degree’:2}) subdomain_data() Return the domain data of this integral. subdomain_id() Return the subdomain id of this integral. ufl_domain() Return the integration domain of this integral. class ffcx.ir.representation.QuadratureRule(points, weights) Bases: object id() Return unique deterministic identifier. NOTE: This identifier is used to provide unique names to tables and symbols in generated code. ffcx.ir.representation.compute_integral_ir(cell, integral_type, entitytype, integrands, argument_shape, p, visualise) ffcx.ir.representation.compute_ir(analysis, object_names, prefix, parameters, visualise) Compute intermediate representation. ffcx.ir.representation.create_element(element: ufl.finiteelement.finiteelementbase.FiniteElementBase) -> ffcx.element_interface.BaseElement Create an FFCx element from a UFL element. Parameters element – A UFL finite element Returns A FFCx finite element ffcx.ir.representation.create_quadrature_points_and_weights(integral_type, cell, degree, rule) Create quadrature rule and return points and weights. class ffcx.ir.representation.ir_custom_element(cell_type, value_shape, wcoeffs, x, M, map_type, discontinuous, highest_complete_degree, highest_degree) Bases: tuple Create new instance of ir_custom_element(cell_type, value_shape, wcoeffs, x, M, map_type, discontinuous, highest_complete_degree, highest_degree) M Alias for field number 4 cell_type Alias for field number 0 discontinuous Alias for field number 6 highest_complete_degree Alias for field number 7 highest_degree Alias for field number 8 map_type Alias for field number 5 value_shape Alias for field number 1 wcoeffs Alias for field number 2 x Alias for field number 3 class ffcx.ir.representation.ir_data(elements, dofmaps, integrals, forms, expressions) Bases: tuple Create new instance of ir_data(elements, dofmaps, integrals, forms, expressions) dofmaps Alias for field number 1 elements Alias for field number 0 expressions Alias for field number 4 forms Alias for field number 3 integrals Alias for field number 2 class ffcx.ir.representation.ir_dofmap(id, name, signature, num_global_support_dofs, num_element_support_dofs, num_entity_dofs, tabulate_entity_dofs, num_entity_closure_dofs, tabulate_entity_closure_dofs, num_sub_dofmaps, sub_dofmaps, block_size) Bases: tuple Create new instance of ir_dofmap(id, name, signature, num_global_support_dofs, num_element_support_dofs, num_entity_dofs, tabulate_entity_dofs, num_entity_closure_dofs, tabulate_entity_closure_dofs, num_sub_dofmaps, sub_dofmaps, block_size) block_size Alias for field number 11 id Alias for field number 0 name Alias for field number 1 num_element_support_dofs Alias for field number 4 num_entity_closure_dofs Alias for field number 7 num_entity_dofs Alias for field number 5 num_global_support_dofs Alias for field number 3 num_sub_dofmaps Alias for field number 9 signature Alias for field number 2 sub_dofmaps Alias for field number 10 tabulate_entity_closure_dofs Alias for field number 8 tabulate_entity_dofs Alias for field number 6 class ffcx.ir.representation.ir_element(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) Bases: tuple Create new instance of ir_element(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) basix_cell Alias for field number 19 basix_family Alias for field number 18 block_size Alias for field number 12 cell_shape Alias for field number 3 custom_element Alias for field number 21 degree Alias for field number 9 discontinuous Alias for field number 20 dpc_variant Alias for field number 17 element_type Alias for field number 14 entity_dofs Alias for field number 15 family Alias for field number 10 geometric_dimension Alias for field number 5 id Alias for field number 0 lagrange_variant Alias for field number 16 name Alias for field number 1 num_sub_elements Alias for field number 11 reference_value_shape Alias for field number 8 signature Alias for field number 2 space_dimension Alias for field number 6 sub_elements Alias for field number 13 topological_dimension Alias for field number 4 value_shape Alias for field number 7 class ffcx.ir.representation.ir_expression(name, element_dimensions, params, unique_tables, unique_table_types, integrand, table_dofmaps, coefficient_numbering, coefficient_offsets, integral_type, entitytype, tensor_shape, expression_shape, original_constant_offsets, original_coefficient_positions, points, coefficient_names, constant_names, needs_facet_permutations, function_spaces, name_from_uflfile) Bases: tuple Create new instance of ir_expression(name, element_dimensions, params, unique_tables, unique_table_types, integrand, table_dofmaps, coefficient_numbering, coefficient_offsets, integral_type, entitytype, tensor_shape, expression_shape, original_constant_offsets, original_coefficient_positions, points, coefficient_names, constant_names, needs_facet_permutations, function_spaces, name_from_uflfile) coefficient_names Alias for field number 16 coefficient_numbering Alias for field number 7 coefficient_offsets Alias for field number 8 constant_names Alias for field number 17 element_dimensions Alias for field number 1 entitytype Alias for field number 10 expression_shape Alias for field number 12 function_spaces Alias for field number 19 integral_type Alias for field number 9 integrand Alias for field number 5 name Alias for field number 0 name_from_uflfile Alias for field number 20 needs_facet_permutations Alias for field number 18 original_coefficient_positions Alias for field number 14 original_constant_offsets Alias for field number 13 params Alias for field number 2 points Alias for field number 15 table_dofmaps Alias for field number 6 tensor_shape Alias for field number 11 unique_table_types Alias for field number 4 unique_tables Alias for field number 3 class ffcx.ir.representation.ir_form(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) Bases: tuple Create new instance of ir_form(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 Alias for field number 9 constant_names Alias for field number 10 dofmaps Alias for field number 12 finite_elements Alias for field number 11 function_spaces Alias for field number 7 id Alias for field number 0 integral_names Alias for field number 13 name Alias for field number 1 name_from_uflfile Alias for field number 6 num_coefficients Alias for field number 4 num_constants Alias for field number 5 original_coefficient_position Alias for field number 8 rank Alias for field number 3 signature Alias for field number 2 subdomain_ids Alias for field number 14 class ffcx.ir.representation.ir_integral(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, table_dofmaps, integrand, name, precision, needs_facet_permutations, coordinate_element) Bases: tuple Create new instance of ir_integral(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, table_dofmaps, integrand, name, precision, needs_facet_permutations, coordinate_element) cell_shape Alias for field number 16 coefficient_numbering Alias for field number 12 coefficient_offsets Alias for field number 13 coordinate_element Alias for field number 24 element_dimensions Alias for field number 9 element_ids Alias for field number 10 enabled_coefficients Alias for field number 8 entitytype Alias for field number 5 geometric_dimension Alias for field number 3 integral_type Alias for field number 0 integrand Alias for field number 20 name Alias for field number 21 needs_facet_permutations Alias for field number 23 num_facets Alias for field number 6 num_vertices Alias for field number 7 original_constant_offsets Alias for field number 14 params Alias for field number 15 precision Alias for field number 22 rank Alias for field number 2 subdomain_id Alias for field number 1 table_dofmaps Alias for field number 19 tensor_shape Alias for field number 11 topological_dimension Alias for field number 4 unique_table_types Alias for field number 18 unique_tables Alias for field number 17 ffcx.ir.representation.namedtuple(typename, field_names, *, rename=False, defaults=None, module=None) Returns a new subclass of tuple with named fields. >>> Point = namedtuple('Point', ['x', 'y']) >>> Point.__doc__ # docstring for the new class 'Point(x, y)' >>> p = Point(11, y=22) # instantiate with positional args or keywords >>> p[0] + p[1] # indexable like a plain tuple 33 >>> x, y = p # unpack like a regular tuple >>> x, y (11, 22) >>> p.x + p.y # fields also accessible by name 33 >>> d = p._asdict() # convert to a dictionary >>> d['x'] 11 >>> Point(**d) # convert from a dictionary Point(x=11, y=22) >>> p._replace(x=100) # _replace() is like str.replace() but targets named fields Point(x=100, y=22) ffcx.ir.representation.sorted_expr_sum(seq)
FFCX.IR.REPRESENTATIONUTILS
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, │ Given integral_type and domain │ │tdim) │ 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) │ │ └────────────────────────────────┴───┘ class ffcx.ir.representationutils.QuadratureRule(points, weights) Bases: object id() Return unique deterministic identifier. NOTE: This identifier is used to provide unique names to tables and symbols in generated code. ffcx.ir.representationutils.create_quadrature(cellname, degree, rule) Create a quadrature rule. ffcx.ir.representationutils.create_quadrature_points_and_weights(integral_type, cell, degree, rule) Create quadrature rule and return points and weights. ffcx.ir.representationutils.integral_type_to_entity_dim(integral_type, tdim) Given integral_type and domain tdim, return the tdim of the integration entity. ffcx.ir.representationutils.map_facet_points(points, facet, cellname) Map points from a reference facet to a physical facet. ffcx.ir.representationutils.map_integral_points(points, integral_type, cell, entity) Map points from reference entity to its parent reference cell. ffcx.ir.representationutils.reference_cell_vertices(cellname) Get the vertices of a reference cell. • Index • Module Index • Search Page
AUTHOR
FEniCS Project
COPYRIGHT
2022, FEniCS Project