ufl package¶
Subpackages¶
- ufl.algorithms package
- Submodules
- ufl.algorithms.ad module
- ufl.algorithms.analysis module
- ufl.algorithms.apply_algebra_lowering module
- ufl.algorithms.apply_derivatives module
- ufl.algorithms.apply_function_pullbacks module
- ufl.algorithms.apply_geometry_lowering module
- ufl.algorithms.apply_integral_scaling module
- ufl.algorithms.apply_restrictions module
- ufl.algorithms.balancing module
- ufl.algorithms.change_to_reference module
- ufl.algorithms.check_arities module
- ufl.algorithms.check_restrictions module
- ufl.algorithms.checks module
- ufl.algorithms.comparison_checker module
- ufl.algorithms.compute_form_data module
- ufl.algorithms.coordinate_derivative_helpers module
- ufl.algorithms.domain_analysis module
- ufl.algorithms.elementtransformations module
- ufl.algorithms.estimate_degrees module
- ufl.algorithms.expand_compounds module
- ufl.algorithms.expand_indices module
- ufl.algorithms.formdata module
- ufl.algorithms.formfiles module
- ufl.algorithms.formsplitter module
- ufl.algorithms.formtransformations module
- ufl.algorithms.map_integrands module
- ufl.algorithms.multifunction module
- ufl.algorithms.preprocess_expression module
- ufl.algorithms.remove_complex_nodes module
- ufl.algorithms.renumbering module
- ufl.algorithms.replace module
- ufl.algorithms.signature module
- ufl.algorithms.strip_terminal_data module
- ufl.algorithms.transformer module
- ufl.algorithms.traversal module
- Module contents
- ufl.core package
- ufl.corealg package
- ufl.finiteelement package
- Submodules
- ufl.finiteelement.brokenelement module
- ufl.finiteelement.elementlist module
- ufl.finiteelement.enrichedelement module
- ufl.finiteelement.facetelement module
- ufl.finiteelement.finiteelement module
- ufl.finiteelement.finiteelementbase module
- ufl.finiteelement.hdivcurl module
- ufl.finiteelement.interiorelement module
- ufl.finiteelement.mixedelement module
- ufl.finiteelement.restrictedelement module
- ufl.finiteelement.tensorproductelement module
- Module contents
- ufl.formatting package
- ufl.utils package
Submodules¶
ufl.algebra module¶
Basic algebra operations.
- class ufl.algebra.Abs(a)[source]¶
Bases:
Operator
- evaluate(x, mapping, component, index_values)[source]¶
Evaluate expression at given coordinate with given values for terminals.
- property ufl_free_indices¶
- property ufl_index_dimensions¶
- property ufl_shape¶
- class ufl.algebra.Conj(a)[source]¶
Bases:
Operator
- evaluate(x, mapping, component, index_values)[source]¶
Evaluate expression at given coordinate with given values for terminals.
- property ufl_free_indices¶
- property ufl_index_dimensions¶
- property ufl_shape¶
- class ufl.algebra.Division(a, b)[source]¶
Bases:
Operator
- evaluate(x, mapping, component, index_values)[source]¶
Evaluate expression at given coordinate with given values for terminals.
- property ufl_free_indices¶
- property ufl_index_dimensions¶
- ufl_shape = ()¶
- class ufl.algebra.Imag(a)[source]¶
Bases:
Operator
- evaluate(x, mapping, component, index_values)[source]¶
Evaluate expression at given coordinate with given values for terminals.
- property ufl_free_indices¶
- property ufl_index_dimensions¶
- property ufl_shape¶
- class ufl.algebra.Power(a, b)[source]¶
Bases:
Operator
- evaluate(x, mapping, component, index_values)[source]¶
Evaluate expression at given coordinate with given values for terminals.
- property ufl_free_indices¶
- property ufl_index_dimensions¶
- ufl_shape = ()¶
- class ufl.algebra.Product(a, b)[source]¶
Bases:
Operator
The product of two or more UFL objects.
- evaluate(x, mapping, component, index_values)[source]¶
Evaluate expression at given coordinate with given values for terminals.
- ufl_free_indices¶
- ufl_index_dimensions¶
- ufl_shape = ()¶
ufl.argument module¶
This module defines the class Argument and a number of related classes (functions), including TestFunction and TrialFunction.
- class ufl.argument.Argument(function_space, number, part=None)[source]¶
Bases:
FormArgument
UFL value: Representation of an argument to a form.
- is_cellwise_constant()[source]¶
Return whether this expression is spatially constant over each cell.
- property ufl_shape¶
Return the associated UFL shape.
- ufl.argument.Arguments(function_space, number)[source]¶
UFL value: Create an Argument in a mixed space, and return a tuple with the function components corresponding to the subelements.
- ufl.argument.TestFunction(function_space, part=None)[source]¶
UFL value: Create a test function argument to a form.
- ufl.argument.TestFunctions(function_space)[source]¶
UFL value: Create a TestFunction in a mixed space, and return a tuple with the function components corresponding to the subelements.
ufl.assertions module¶
This module provides assertion functions used by the UFL implementation.
ufl.averaging module¶
Averaging operations.
ufl.cell module¶
Types for representing a cell.
- class ufl.cell.AbstractCell(topological_dimension, geometric_dimension)[source]¶
Bases:
object
Representation of an abstract finite element cell with only the dimensions known.
- class ufl.cell.Cell(cellname, geometric_dimension=None)[source]¶
Bases:
AbstractCell
Representation of a named finite element cell with known structure.
- class ufl.cell.TensorProductCell(*cells, **kwargs)[source]¶
Bases:
AbstractCell
- ufl.cell.as_cell(cell)[source]¶
Convert any valid object to a Cell or return cell if it is already a Cell.
Allows an already valid cell, a known cellname string, or a tuple of cells for a product cell.
ufl.checks module¶
Utility functions for checking properties of expressions.
- ufl.checks.is_cellwise_constant(expr)[source]¶
Return whether expression is constant over a single cell.
- ufl.checks.is_globally_constant(expr)[source]¶
Check if an expression is globally constant, which includes spatially independent constant coefficients that are not known before assembly time.
- ufl.checks.is_python_scalar(expression)[source]¶
Return True iff expression is of a Python scalar type.
- ufl.checks.is_scalar_constant_expression(expr)[source]¶
Check if an expression is a globally constant scalar expression.
ufl.classes module¶
This file is useful for external code like tests and form compilers, since it enables the syntax “from ufl.classes import CellFacetooBar” for getting implementation details not exposed through the default ufl namespace. It also contains functionality used by algorithms for dealing with groups of classes, and for mapping types to different handler functions.
- class ufl.classes.Abs(a)[source]¶
Bases:
Operator
- evaluate(x, mapping, component, index_values)[source]¶
Evaluate expression at given coordinate with given values for terminals.
- property ufl_free_indices¶
- property ufl_index_dimensions¶
- property ufl_shape¶
- class ufl.classes.AbstractCell(topological_dimension, geometric_dimension)[source]¶
Bases:
object
Representation of an abstract finite element cell with only the dimensions known.
- class ufl.classes.AbstractDomain(topological_dimension, geometric_dimension)[source]¶
Bases:
object
Symbolic representation of a geometric domain with only a geometric and topological dimension.
- class ufl.classes.Acos(argument)[source]¶
Bases:
MathFunction
- class ufl.classes.AndCondition(left, right)[source]¶
Bases:
BinaryCondition
- class ufl.classes.Argument(function_space, number, part=None)[source]¶
Bases:
FormArgument
UFL value: Representation of an argument to a form.
- is_cellwise_constant()[source]¶
Return whether this expression is spatially constant over each cell.
- property ufl_shape¶
Return the associated UFL shape.
- class ufl.classes.Asin(argument)[source]¶
Bases:
MathFunction
- class ufl.classes.Atan(argument)[source]¶
Bases:
MathFunction
- class ufl.classes.Atan2(arg1, arg2)[source]¶
Bases:
Operator
- evaluate(x, mapping, component, index_values)[source]¶
Evaluate expression at given coordinate with given values for terminals.
- ufl_free_indices = ()¶
- ufl_index_dimensions = ()¶
- ufl_shape = ()¶
- class ufl.classes.BesselFunction(name, classname, nu, argument)[source]¶
Bases:
Operator
Base class for all bessel functions
- evaluate(x, mapping, component, index_values)[source]¶
Evaluate expression at given coordinate with given values for terminals.
- ufl_free_indices = ()¶
- ufl_index_dimensions = ()¶
- ufl_shape = ()¶
- class ufl.classes.BesselI(nu, argument)[source]¶
Bases:
BesselFunction
- class ufl.classes.BesselJ(nu, argument)[source]¶
Bases:
BesselFunction
- class ufl.classes.BesselK(nu, argument)[source]¶
Bases:
BesselFunction
- class ufl.classes.BesselY(nu, argument)[source]¶
Bases:
BesselFunction
- class ufl.classes.BrokenElement(element)[source]¶
Bases:
FiniteElementBase
The discontinuous version of an existing Finite Element space.
- class ufl.classes.Cell(cellname, geometric_dimension=None)[source]¶
Bases:
AbstractCell
Representation of a named finite element cell with known structure.
- class ufl.classes.CellAvg(f)[source]¶
Bases:
Operator
- evaluate(x, mapping, component, index_values)[source]¶
Performs an approximate symbolic evaluation, since we dont have a cell.
- property ufl_free_indices¶
- property ufl_index_dimensions¶
- property ufl_shape¶
- class ufl.classes.CellCoordinate(domain)[source]¶
Bases:
GeometricCellQuantity
UFL geometry representation: The coordinate in a reference cell.
In the context of expression integration, represents the reference cell coordinate of each quadrature point.
In the context of expression evaluation in a point in a cell, represents that point in the reference coordinate system of the cell.
- is_cellwise_constant()[source]¶
Return whether this expression is spatially constant over each cell.
- name = 'X'¶
- property ufl_shape¶
Built-in immutable sequence.
If no argument is given, the constructor returns an empty tuple. If iterable is specified the tuple is initialized from iterable’s items.
If the argument is a tuple, the return value is the same object.
- class ufl.classes.CellDiameter(domain)[source]¶
Bases:
GeometricCellQuantity
UFL geometry representation: The diameter of the cell, i.e., maximal distance of two points in the cell.
- name = 'diameter'¶
- class ufl.classes.CellEdgeVectors(domain)[source]¶
Bases:
GeometricCellQuantity
UFL geometry representation: The vectors between physical cell vertices for each edge in cell.
- is_cellwise_constant()[source]¶
Return whether this expression is spatially constant over each cell.
- name = 'CEV'¶
- property ufl_shape¶
Built-in immutable sequence.
If no argument is given, the constructor returns an empty tuple. If iterable is specified the tuple is initialized from iterable’s items.
If the argument is a tuple, the return value is the same object.
- class ufl.classes.CellFacetJacobian(domain)[source]¶
Bases:
GeometricFacetQuantity
UFL geometry representation: The Jacobian of the mapping from reference facet to reference cell coordinates.
CFJ_ij = dX_i/dXf_j
- is_cellwise_constant()[source]¶
Return whether this expression is spatially constant over each cell.
- name = 'CFJ'¶
- property ufl_shape¶
Built-in immutable sequence.
If no argument is given, the constructor returns an empty tuple. If iterable is specified the tuple is initialized from iterable’s items.
If the argument is a tuple, the return value is the same object.
- class ufl.classes.CellFacetJacobianDeterminant(domain)[source]¶
Bases:
GeometricFacetQuantity
UFL geometry representation: The pseudo-determinant of the CellFacetJacobian.
- is_cellwise_constant()[source]¶
Return whether this expression is spatially constant over each cell.
- name = 'detCFJ'¶
- class ufl.classes.CellFacetJacobianInverse(domain)[source]¶
Bases:
GeometricFacetQuantity
UFL geometry representation: The pseudo-inverse of the CellFacetJacobian.
- is_cellwise_constant()[source]¶
Return whether this expression is spatially constant over each cell.
- name = 'CFK'¶
- property ufl_shape¶
Built-in immutable sequence.
If no argument is given, the constructor returns an empty tuple. If iterable is specified the tuple is initialized from iterable’s items.
If the argument is a tuple, the return value is the same object.
- class ufl.classes.CellFacetOrigin(domain)[source]¶
Bases:
GeometricFacetQuantity
UFL geometry representation: The reference cell coordinate corresponding to origin of a reference facet.
- name = 'X0f'¶
- property ufl_shape¶
Built-in immutable sequence.
If no argument is given, the constructor returns an empty tuple. If iterable is specified the tuple is initialized from iterable’s items.
If the argument is a tuple, the return value is the same object.
- class ufl.classes.CellNormal(domain)[source]¶
Bases:
GeometricCellQuantity
UFL geometry representation: The upwards pointing normal vector of the current manifold cell.
- name = 'cell_normal'¶
- property ufl_shape¶
Return the number of coordinates defined (i.e. the geometric dimension of the domain).
- class ufl.classes.CellOrientation(domain)[source]¶
Bases:
GeometricCellQuantity
UFL geometry representation: The orientation (+1/-1) of the current cell.
For non-manifold cells (tdim == gdim), this equals the sign of the Jacobian determinant, i.e. +1 if the physical cell is oriented the same way as the reference cell and -1 otherwise.
For manifold cells of tdim==gdim-1 this is input data belonging to the mesh, used to distinguish between the sides of the manifold.
- name = 'cell_orientation'¶
- class ufl.classes.CellOrigin(domain)[source]¶
Bases:
GeometricCellQuantity
UFL geometry representation: The spatial coordinate corresponding to origin of a reference cell.
- is_cellwise_constant()[source]¶
Return whether this expression is spatially constant over each cell (or over each facet for facet quantities).
- name = 'x0'¶
- property ufl_shape¶
Built-in immutable sequence.
If no argument is given, the constructor returns an empty tuple. If iterable is specified the tuple is initialized from iterable’s items.
If the argument is a tuple, the return value is the same object.
- class ufl.classes.CellVertices(domain)[source]¶
Bases:
GeometricCellQuantity
UFL geometry representation: Physical cell vertices.
- is_cellwise_constant()[source]¶
Return whether this expression is spatially constant over each cell.
- name = 'CV'¶
- property ufl_shape¶
Built-in immutable sequence.
If no argument is given, the constructor returns an empty tuple. If iterable is specified the tuple is initialized from iterable’s items.
If the argument is a tuple, the return value is the same object.
- class ufl.classes.CellVolume(domain)[source]¶
Bases:
GeometricCellQuantity
UFL geometry representation: The volume of the cell.
- name = 'volume'¶
- class ufl.classes.Circumradius(domain)[source]¶
Bases:
GeometricCellQuantity
UFL geometry representation: The circumradius of the cell.
- name = 'circumradius'¶
- class ufl.classes.Coefficient(function_space, count=None)[source]¶
Bases:
FormArgument
UFL form argument type: Representation of a form coefficient.
- is_cellwise_constant()[source]¶
Return whether this expression is spatially constant over each cell.
- ufl_element()[source]¶
Shortcut to get the finite element of the function space of this coefficient.
- property ufl_shape¶
Return the associated UFL shape.
- class ufl.classes.CoefficientDerivative(integrand, coefficients, arguments, coefficient_derivatives)[source]¶
Bases:
Derivative
Derivative of the integrand of a form w.r.t. the degrees of freedom in a discrete Coefficient.
- property ufl_free_indices¶
- property ufl_index_dimensions¶
- property ufl_shape¶
- class ufl.classes.Cofactor(A)[source]¶
Bases:
CompoundTensorOperator
- ufl_free_indices = ()¶
- ufl_index_dimensions = ()¶
- property ufl_shape¶
- class ufl.classes.ComplexValue(value)[source]¶
Bases:
ScalarValue
UFL literal type: Representation of a constant, complex scalar
- class ufl.classes.ComponentTensor(expression, indices)[source]¶
Bases:
Operator
UFL operator type: Maps the free indices of a scalar valued expression to tensor axes.
- evaluate(x, mapping, component, index_values)[source]¶
Evaluate expression at given coordinate with given values for terminals.
- ufl_free_indices¶
- ufl_index_dimensions¶
- ufl_shape¶
- class ufl.classes.CompoundDerivative(operands)[source]¶
Bases:
Derivative
Base class for all compound derivative types.
- class ufl.classes.Condition(operands)[source]¶
Bases:
Operator
- ufl_free_indices = ()¶
- ufl_index_dimensions = ()¶
- ufl_shape = ()¶
- class ufl.classes.Conditional(condition, true_value, false_value)[source]¶
Bases:
Operator
- evaluate(x, mapping, component, index_values)[source]¶
Evaluate expression at given coordinate with given values for terminals.
- property ufl_free_indices¶
- property ufl_index_dimensions¶
- property ufl_shape¶
- class ufl.classes.Conj(a)[source]¶
Bases:
Operator
- evaluate(x, mapping, component, index_values)[source]¶
Evaluate expression at given coordinate with given values for terminals.
- property ufl_free_indices¶
- property ufl_index_dimensions¶
- property ufl_shape¶
- class ufl.classes.Constant(domain, shape=(), count=None)[source]¶
Bases:
Terminal
- ufl_domain()[source]¶
Return the single unique domain this expression is defined on, or throw an error.
- property ufl_shape¶
- class ufl.classes.ConstantValue[source]¶
Bases:
Terminal
- class ufl.classes.CoordinateDerivative(integrand, coefficients, arguments, coefficient_derivatives)[source]¶
Bases:
CoefficientDerivative
Derivative of the integrand of a form w.r.t. the SpatialCoordinates.
- property ufl_free_indices¶
- property ufl_index_dimensions¶
- property ufl_shape¶
- class ufl.classes.Cos(argument)[source]¶
Bases:
MathFunction
- class ufl.classes.Cosh(argument)[source]¶
Bases:
MathFunction
- class ufl.classes.Cross(a, b)[source]¶
Bases:
CompoundTensorOperator
- ufl_free_indices¶
- ufl_index_dimensions¶
- ufl_shape = (3,)¶
- class ufl.classes.Curl(f)[source]¶
Bases:
CompoundDerivative
- property ufl_free_indices¶
- property ufl_index_dimensions¶
- ufl_shape¶
- class ufl.classes.Derivative(operands)[source]¶
Bases:
Operator
Base class for all derivative types.
- class ufl.classes.Determinant(A)[source]¶
Bases:
CompoundTensorOperator
- ufl_free_indices = ()¶
- ufl_index_dimensions = ()¶
- ufl_shape = ()¶
- class ufl.classes.Deviatoric(A)[source]¶
Bases:
CompoundTensorOperator
- property ufl_free_indices¶
- property ufl_index_dimensions¶
- property ufl_shape¶
- class ufl.classes.Div(f)[source]¶
Bases:
CompoundDerivative
- property ufl_free_indices¶
- property ufl_index_dimensions¶
- property ufl_shape¶
- class ufl.classes.Division(a, b)[source]¶
Bases:
Operator
- evaluate(x, mapping, component, index_values)[source]¶
Evaluate expression at given coordinate with given values for terminals.
- property ufl_free_indices¶
- property ufl_index_dimensions¶
- ufl_shape = ()¶
- class ufl.classes.Dot(a, b)[source]¶
Bases:
CompoundTensorOperator
- ufl_free_indices¶
- ufl_index_dimensions¶
- property ufl_shape¶
- class ufl.classes.EQ(left, right)[source]¶
Bases:
BinaryCondition
- class ufl.classes.EnrichedElement(*elements)[source]¶
Bases:
EnrichedElementBase
The vector sum of several finite element spaces:
\[\textrm{EnrichedElement}(V, Q) = \{v + q | v \in V, q \in Q\}.\]Dual basis is a concatenation of subelements dual bases; primal basis is a concatenation of subelements primal bases; resulting element is not nodal even when subelements are. Structured basis may be exploited in form compilers.
- class ufl.classes.Equation(lhs, rhs)[source]¶
Bases:
object
This class is used to represent equations expressed by the “==” operator. Examples include a == L and F == 0 where a, L and F are Form objects.
- class ufl.classes.Erf(argument)[source]¶
Bases:
MathFunction
- class ufl.classes.Exp(argument)[source]¶
Bases:
MathFunction
- class ufl.classes.Expr[source]¶
Bases:
object
Base class for all UFL expression types.
- Instance properties
Every
Expr
instance will have certain properties. The most important ones areufl_operands
,ufl_shape
,ufl_free_indices
, andufl_index_dimensions
properties. Expressions are immutable and hashable.- Type traits
The
Expr
API defines a number of type traits that each subclass needs to provide. Most of these are specified indirectly via the arguments to theufl_type
class decorator, allowing UFL to do some consistency checks and automate most of the traits for most types. Type traits are accessed via a class or instance object of the formobj._ufl_traitname_
. See the source code for description of each type trait.- Operators
Some Python special functions are implemented in this class, some are implemented in subclasses, and some are attached to this class in the
ufl_type
class decorator.- Defining subclasses
To define a new expression class, inherit from either
Terminal
orOperator
, and apply theufl_type
class decorator with suitable arguments. See the docstring ofufl_type
for details on its arguments. Looking at existing classes similar to the one you wish to add is a good idea. Looking through the comments in theExpr
class andufl_type
to understand all the properties that may need to be specified is also a good idea. Note that many algorithms in UFL and form compilers will need handlers implemented for each new type::.@ufl_type() class MyOperator(Operator): pass
- Type collections
All
Expr
subclasses are collected byufl_type
in global variables available viaExpr
.- Profiling
Object creation statistics can be collected by doing
Expr.ufl_enable_profiling() # ... run some code initstats, delstats = Expr.ufl_disable_profiling()
Giving a list of creation and deletion counts for each typecode.
- property T¶
Transpose a rank-2 tensor expression. For more general transpose operations of higher order tensor expressions, use indexing and Tensor.
- dx(*ii)¶
Return the partial derivative with respect to spatial variable number ii.
- evaluate(x, mapping, component, index_values)[source]¶
Evaluate expression at given coordinate with given values for terminals.
- static ufl_disable_profiling()[source]¶
Turn off the object counting mechanism. Return object init and del counts.
- class ufl.classes.ExprList(*operands)[source]¶
Bases:
Operator
List of Expr objects. For internal use, never to be created by end users.
- property ufl_free_indices¶
- property ufl_index_dimensions¶
- property ufl_shape¶
- class ufl.classes.ExprMapping(*operands)[source]¶
Bases:
Operator
Mapping of Expr objects. For internal use, never to be created by end users.
- property ufl_free_indices¶
- property ufl_index_dimensions¶
- property ufl_shape¶
- class ufl.classes.FacetArea(domain)[source]¶
Bases:
GeometricFacetQuantity
UFL geometry representation: The area of the facet.
- name = 'facetarea'¶
- class ufl.classes.FacetAvg(f)[source]¶
Bases:
Operator
- evaluate(x, mapping, component, index_values)[source]¶
Performs an approximate symbolic evaluation, since we dont have a cell.
- property ufl_free_indices¶
- property ufl_index_dimensions¶
- property ufl_shape¶
- class ufl.classes.FacetCoordinate(domain)[source]¶
Bases:
GeometricFacetQuantity
UFL geometry representation: The coordinate in a reference cell of a facet.
In the context of expression integration over a facet, represents the reference facet coordinate of each quadrature point.
In the context of expression evaluation in a point on a facet, represents that point in the reference coordinate system of the facet.
- is_cellwise_constant()[source]¶
Return whether this expression is spatially constant over each cell.
- name = 'Xf'¶
- property ufl_shape¶
Built-in immutable sequence.
If no argument is given, the constructor returns an empty tuple. If iterable is specified the tuple is initialized from iterable’s items.
If the argument is a tuple, the return value is the same object.
- class ufl.classes.FacetEdgeVectors(domain)[source]¶
Bases:
GeometricFacetQuantity
UFL geometry representation: The vectors between physical cell vertices for each edge in current facet.
- is_cellwise_constant()[source]¶
Return whether this expression is spatially constant over each cell.
- name = 'FEV'¶
- property ufl_shape¶
Built-in immutable sequence.
If no argument is given, the constructor returns an empty tuple. If iterable is specified the tuple is initialized from iterable’s items.
If the argument is a tuple, the return value is the same object.
- ufl.classes.FacetElement(element)[source]¶
Constructs the restriction of a finite element to the facets of the cell.
- class ufl.classes.FacetJacobian(domain)[source]¶
Bases:
GeometricFacetQuantity
UFL geometry representation: The Jacobian of the mapping from reference facet to spatial coordinates.
FJ_ij = dx_i/dXf_j
The FacetJacobian is the product of the Jacobian and CellFacetJacobian:
FJ = dx/dXf = dx/dX dX/dXf = J * CFJ
- is_cellwise_constant()[source]¶
Return whether this expression is spatially constant over each cell.
- name = 'FJ'¶
- property ufl_shape¶
Built-in immutable sequence.
If no argument is given, the constructor returns an empty tuple. If iterable is specified the tuple is initialized from iterable’s items.
If the argument is a tuple, the return value is the same object.
- class ufl.classes.FacetJacobianDeterminant(domain)[source]¶
Bases:
GeometricFacetQuantity
UFL geometry representation: The pseudo-determinant of the FacetJacobian.
- is_cellwise_constant()[source]¶
Return whether this expression is spatially constant over each cell.
- name = 'detFJ'¶
- class ufl.classes.FacetJacobianInverse(domain)[source]¶
Bases:
GeometricFacetQuantity
UFL geometry representation: The pseudo-inverse of the FacetJacobian.
- is_cellwise_constant()[source]¶
Return whether this expression is spatially constant over each cell.
- name = 'FK'¶
- property ufl_shape¶
Built-in immutable sequence.
If no argument is given, the constructor returns an empty tuple. If iterable is specified the tuple is initialized from iterable’s items.
If the argument is a tuple, the return value is the same object.
- class ufl.classes.FacetNormal(domain)[source]¶
Bases:
GeometricFacetQuantity
UFL geometry representation: The outwards pointing normal vector of the current facet.
- is_cellwise_constant()[source]¶
Return whether this expression is spatially constant over each cell.
- name = 'n'¶
- property ufl_shape¶
Return the number of coordinates defined (i.e. the geometric dimension of the domain).
- class ufl.classes.FacetOrientation(domain)[source]¶
Bases:
GeometricFacetQuantity
UFL geometry representation: The orientation (+1/-1) of the current facet relative to the reference cell.
- name = 'facet_orientation'¶
- class ufl.classes.FacetOrigin(domain)[source]¶
Bases:
GeometricFacetQuantity
UFL geometry representation: The spatial coordinate corresponding to origin of a reference facet.
- name = 'x0f'¶
- property ufl_shape¶
Built-in immutable sequence.
If no argument is given, the constructor returns an empty tuple. If iterable is specified the tuple is initialized from iterable’s items.
If the argument is a tuple, the return value is the same object.
- class ufl.classes.FiniteElement(family, cell=None, degree=None, form_degree=None, quad_scheme=None, variant=None)[source]¶
Bases:
FiniteElementBase
The basic finite element class for all simple finite elements.
- class ufl.classes.FiniteElementBase(family, cell, degree, quad_scheme, value_shape, reference_value_shape)[source]¶
Bases:
object
Base class for all finite elements.
- extract_component(i)[source]¶
Recursively extract component index relative to a (simple) element and that element for given value component index.
- extract_reference_component(i)[source]¶
Recursively extract reference component index relative to a (simple) element and that element for given reference value component index.
- extract_subelement_component(i)[source]¶
Extract direct subelement index and subelement relative component index for a given component index.
- extract_subelement_reference_component(i)[source]¶
Extract direct subelement index and subelement relative reference component index for a given reference component index.
- is_cellwise_constant(component=None)[source]¶
Return whether the basis functions of this element is spatially constant over each cell.
- class ufl.classes.FixedIndex(value)[source]¶
Bases:
IndexBase
UFL value: An index with a specific value assigned.
- class ufl.classes.FloatValue(value)[source]¶
Bases:
RealValue
UFL literal type: Representation of a constant scalar floating point value.
- class ufl.classes.Form(integrals)[source]¶
Bases:
object
Description of a weak form consisting of a sum of integrals over subdomains.
- coefficient_numbering()[source]¶
Return a contiguous numbering of coefficients in a mapping
{coefficient:number}
.
- constant_numbering()[source]¶
Return a contiguous numbering of constants in a mapping
{constant:number}
.
- geometric_dimension()[source]¶
Return the geometric dimension shared by all domains and functions in this form.
- integrals_by_domain(domain)[source]¶
Return a sequence of all integrals with a particular integration domain.
- integrals_by_type(integral_type)[source]¶
Return a sequence of all integrals with a particular domain type.
- max_subdomain_ids()[source]¶
Returns a mapping on the form
{domain:{integral_type:max_subdomain_id}}
.
- signature()[source]¶
Signature for use with jit cache (independent of incidental numbering of indices etc.)
- ufl_cell()[source]¶
Return the single cell this form is defined on, fails if multiple cells are found.
- class ufl.classes.FunctionSpace(domain, element)[source]¶
Bases:
AbstractFunctionSpace
- class ufl.classes.GE(left, right)[source]¶
Bases:
BinaryCondition
- class ufl.classes.GT(left, right)[source]¶
Bases:
BinaryCondition
- class ufl.classes.GeometricCellQuantity(domain)[source]¶
Bases:
GeometricQuantity
- class ufl.classes.GeometricFacetQuantity(domain)[source]¶
Bases:
GeometricQuantity
- class ufl.classes.GeometricQuantity(domain)[source]¶
Bases:
Terminal
- is_cellwise_constant()[source]¶
Return whether this expression is spatially constant over each cell (or over each facet for facet quantities).
- ufl_shape = ()¶
- class ufl.classes.Grad(f)[source]¶
Bases:
CompoundDerivative
- evaluate(x, mapping, component, index_values, derivatives=())[source]¶
Get child from mapping and return the component asked for.
- property ufl_free_indices¶
- property ufl_index_dimensions¶
- property ufl_shape¶
- class ufl.classes.HCurlElement(element)[source]¶
Bases:
FiniteElementBase
A curl-conforming version of an outer product element, assuming this makes mathematical sense.
- class ufl.classes.HDivElement(element)[source]¶
Bases:
FiniteElementBase
A div-conforming version of an outer product element, assuming this makes mathematical sense.
- class ufl.classes.Identity(dim)[source]¶
Bases:
ConstantValue
UFL literal type: Representation of an identity matrix.
- evaluate(x, mapping, component, index_values)[source]¶
Evaluates the identity matrix on the given components.
- ufl_shape¶
- class ufl.classes.Imag(a)[source]¶
Bases:
Operator
- evaluate(x, mapping, component, index_values)[source]¶
Evaluate expression at given coordinate with given values for terminals.
- property ufl_free_indices¶
- property ufl_index_dimensions¶
- property ufl_shape¶
- class ufl.classes.Index(count=None)[source]¶
Bases:
IndexBase
UFL value: An index with no value assigned.
Used to represent free indices in Einstein indexing notation.
- class ufl.classes.IndexSum(summand, index)[source]¶
Bases:
Operator
- evaluate(x, mapping, component, index_values)[source]¶
Evaluate expression at given coordinate with given values for terminals.
- ufl_free_indices¶
- ufl_index_dimensions¶
- property ufl_shape¶
- class ufl.classes.Indexed(expression, multiindex)[source]¶
Bases:
Operator
- evaluate(x, mapping, component, index_values, derivatives=())[source]¶
Evaluate expression at given coordinate with given values for terminals.
- ufl_free_indices¶
- ufl_index_dimensions¶
- ufl_shape = ()¶
- class ufl.classes.Inner(a, b)[source]¶
Bases:
CompoundTensorOperator
- ufl_free_indices¶
- ufl_index_dimensions¶
- ufl_shape = ()¶
- class ufl.classes.IntValue(value)[source]¶
Bases:
RealValue
UFL literal type: Representation of a constant scalar integer value.
- class ufl.classes.Integral(integrand, integral_type, domain, subdomain_id, metadata, subdomain_data)[source]¶
Bases:
object
An integral over a single domain.
- 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.
<a = Integral instance> b = a.reconstruct(expand_compounds(a.integrand())) c = a.reconstruct(metadata={‘quadrature_degree’:2})
- ufl.classes.InteriorElement(element)[source]¶
Constructs the restriction of a finite element to the interior of the cell.
- class ufl.classes.Inverse(A)[source]¶
Bases:
CompoundTensorOperator
- ufl_free_indices = ()¶
- ufl_index_dimensions = ()¶
- property ufl_shape¶
- class ufl.classes.Jacobian(domain)[source]¶
Bases:
GeometricCellQuantity
UFL geometry representation: The Jacobian of the mapping from reference cell to spatial coordinates.
\[J_{ij} = \frac{dx_i}{dX_j}\]- is_cellwise_constant()[source]¶
Return whether this expression is spatially constant over each cell.
- name = 'J'¶
- property ufl_shape¶
Return the number of coordinates defined (i.e. the geometric dimension of the domain).
- class ufl.classes.JacobianDeterminant(domain)[source]¶
Bases:
GeometricCellQuantity
UFL geometry representation: The determinant of the Jacobian.
Represents the signed determinant of a square Jacobian or the pseudo-determinant of a non-square Jacobian.
- is_cellwise_constant()[source]¶
Return whether this expression is spatially constant over each cell.
- name = 'detJ'¶
- class ufl.classes.JacobianInverse(domain)[source]¶
Bases:
GeometricCellQuantity
UFL geometry representation: The inverse of the Jacobian.
Represents the inverse of a square Jacobian or the pseudo-inverse of a non-square Jacobian.
- is_cellwise_constant()[source]¶
Return whether this expression is spatially constant over each cell.
- name = 'K'¶
- property ufl_shape¶
Return the number of coordinates defined (i.e. the geometric dimension of the domain).
- class ufl.classes.LE(left, right)[source]¶
Bases:
BinaryCondition
- class ufl.classes.LT(left, right)[source]¶
Bases:
BinaryCondition
- class ufl.classes.Label(count=None)[source]¶
Bases:
Terminal
- property ufl_free_indices¶
Built-in immutable sequence.
If no argument is given, the constructor returns an empty tuple. If iterable is specified the tuple is initialized from iterable’s items.
If the argument is a tuple, the return value is the same object.
- property ufl_index_dimensions¶
Built-in immutable sequence.
If no argument is given, the constructor returns an empty tuple. If iterable is specified the tuple is initialized from iterable’s items.
If the argument is a tuple, the return value is the same object.
- property ufl_shape¶
- class ufl.classes.ListTensor(*expressions)[source]¶
Bases:
Operator
UFL operator type: Wraps a list of expressions into a tensor valued expression of one higher rank.
- evaluate(x, mapping, component, index_values, derivatives=())[source]¶
Evaluate expression at given coordinate with given values for terminals.
- property ufl_free_indices¶
- property ufl_index_dimensions¶
- property ufl_shape¶
- class ufl.classes.Ln(argument)[source]¶
Bases:
MathFunction
- class ufl.classes.MathFunction(name, argument)[source]¶
Bases:
Operator
Base class for all unary scalar math functions.
- evaluate(x, mapping, component, index_values)[source]¶
Evaluate expression at given coordinate with given values for terminals.
- ufl_free_indices = ()¶
- ufl_index_dimensions = ()¶
- ufl_shape = ()¶
- class ufl.classes.MaxCellEdgeLength(domain)[source]¶
Bases:
GeometricCellQuantity
UFL geometry representation: The maximum edge length of the cell.
- name = 'maxcelledgelength'¶
- class ufl.classes.MaxFacetEdgeLength(domain)[source]¶
Bases:
GeometricFacetQuantity
UFL geometry representation: The maximum edge length of the facet.
- name = 'maxfacetedgelength'¶
- class ufl.classes.MaxValue(left, right)[source]¶
Bases:
Operator
UFL operator: Take the maximum of two values.
- evaluate(x, mapping, component, index_values)[source]¶
Evaluate expression at given coordinate with given values for terminals.
- ufl_free_indices = ()¶
- ufl_index_dimensions = ()¶
- ufl_shape = ()¶
- class ufl.classes.Measure(integral_type, domain=None, subdomain_id='everywhere', metadata=None, subdomain_data=None)[source]¶
Bases:
object
- integral_type()[source]¶
Return the domain type.
Valid domain types are “cell”, “exterior_facet”, “interior_facet”, etc.
- metadata()[source]¶
Return the integral metadata. This data is not interpreted by UFL. It is passed to the form compiler which can ignore it or use it to compile each integral of a form in a different way.
- reconstruct(integral_type=None, subdomain_id=None, domain=None, metadata=None, subdomain_data=None)[source]¶
Construct a new Measure object with some properties replaced with new values.
<dm = Measure instance> b = dm.reconstruct(subdomain_id=2) c = dm.reconstruct(metadata={ “quadrature_degree”: 3 })
- Used by the call operator, so this is equivalent:
b = dm(2) c = dm(0, { “quadrature_degree”: 3 })
- class ufl.classes.MeasureProduct(*measures)[source]¶
Bases:
object
Represents a product of measures.
This is a notational intermediate object to handle the notation
f*(dm1*dm2)
This is work in progress and not functional. It needs support in other parts of ufl and the rest of the code generation chain.
- class ufl.classes.MeasureSum(*measures)[source]¶
Bases:
object
Represents a sum of measures.
This is a notational intermediate object to translate the notation
f*(ds(1)+ds(3))
into
f*ds(1) + f*ds(3)
- class ufl.classes.Mesh(coordinate_element, ufl_id=None, cargo=None)[source]¶
Bases:
AbstractDomain
Symbolic representation of a mesh.
- ufl_id()¶
Return the ufl_id of this object.
- class ufl.classes.MeshView(mesh, topological_dimension, ufl_id=None)[source]¶
Bases:
AbstractDomain
Symbolic representation of a mesh.
- ufl_id()¶
Return the ufl_id of this object.
- class ufl.classes.MinCellEdgeLength(domain)[source]¶
Bases:
GeometricCellQuantity
UFL geometry representation: The minimum edge length of the cell.
- name = 'mincelledgelength'¶
- class ufl.classes.MinFacetEdgeLength(domain)[source]¶
Bases:
GeometricFacetQuantity
UFL geometry representation: The minimum edge length of the facet.
- name = 'minfacetedgelength'¶
- class ufl.classes.MinValue(left, right)[source]¶
Bases:
Operator
UFL operator: Take the minimum of two values.
- evaluate(x, mapping, component, index_values)[source]¶
Evaluate expression at given coordinate with given values for terminals.
- ufl_free_indices = ()¶
- ufl_index_dimensions = ()¶
- ufl_shape = ()¶
- class ufl.classes.MixedElement(*elements, **kwargs)[source]¶
Bases:
FiniteElementBase
A finite element composed of a nested hierarchy of mixed or simple elements.
- extract_component(i)[source]¶
Recursively extract component index relative to a (simple) element and that element for given value component index.
- extract_reference_component(i)[source]¶
Recursively extract reference_component index relative to a (simple) element and that element for given value reference_component index.
- extract_subelement_component(i)[source]¶
Extract direct subelement index and subelement relative component index for a given component index.
- extract_subelement_reference_component(i)[source]¶
Extract direct subelement index and subelement relative reference_component index for a given reference_component index.
- class ufl.classes.MixedFunctionSpace(*args)[source]¶
Bases:
AbstractFunctionSpace
- class ufl.classes.MultiIndex(indices)[source]¶
Bases:
Terminal
Represents a sequence of indices, either fixed or free.
- property ufl_free_indices¶
This shall not be used.
- property ufl_index_dimensions¶
This shall not be used.
- property ufl_shape¶
This shall not be used.
- class ufl.classes.NE(left, right)[source]¶
Bases:
BinaryCondition
- class ufl.classes.NablaDiv(f)[source]¶
Bases:
CompoundDerivative
- property ufl_free_indices¶
- property ufl_index_dimensions¶
- property ufl_shape¶
- class ufl.classes.NablaGrad(f)[source]¶
Bases:
CompoundDerivative
- property ufl_free_indices¶
- property ufl_index_dimensions¶
- property ufl_shape¶
- class ufl.classes.NegativeRestricted(f)[source]¶
Bases:
Restricted
- class ufl.classes.NodalEnrichedElement(*elements)[source]¶
Bases:
EnrichedElementBase
The vector sum of several finite element spaces:
\[\textrm{EnrichedElement}(V, Q) = \{v + q | v \in V, q \in Q\}.\]Primal basis is reorthogonalized to dual basis which is a concatenation of subelements dual bases; resulting element is nodal.
- class ufl.classes.Operator(operands=None)[source]¶
Bases:
Expr
Base class for all operators, i.e. non-terminal expression types.
- ufl_operands¶
- class ufl.classes.OrCondition(left, right)[source]¶
Bases:
BinaryCondition
- class ufl.classes.Outer(a, b)[source]¶
Bases:
CompoundTensorOperator
- ufl_free_indices¶
- ufl_index_dimensions¶
- property ufl_shape¶
- class ufl.classes.PermutationSymbol(dim)[source]¶
Bases:
ConstantValue
UFL literal type: Representation of a permutation symbol.
This is also known as the Levi-Civita symbol, antisymmetric symbol, or alternating symbol.
- ufl_shape¶
- class ufl.classes.PositiveRestricted(f)[source]¶
Bases:
Restricted
- class ufl.classes.Power(a, b)[source]¶
Bases:
Operator
- evaluate(x, mapping, component, index_values)[source]¶
Evaluate expression at given coordinate with given values for terminals.
- property ufl_free_indices¶
- property ufl_index_dimensions¶
- ufl_shape = ()¶
- class ufl.classes.Product(a, b)[source]¶
Bases:
Operator
The product of two or more UFL objects.
- evaluate(x, mapping, component, index_values)[source]¶
Evaluate expression at given coordinate with given values for terminals.
- ufl_free_indices¶
- ufl_index_dimensions¶
- ufl_shape = ()¶
- class ufl.classes.QuadratureWeight(domain)[source]¶
Bases:
GeometricQuantity
UFL geometry representation: The current quadrature weight.
Only used inside a quadrature context.
- is_cellwise_constant()[source]¶
Return whether this expression is spatially constant over each cell.
- name = 'weight'¶
- class ufl.classes.Real(a)[source]¶
Bases:
Operator
- evaluate(x, mapping, component, index_values)[source]¶
Evaluate expression at given coordinate with given values for terminals.
- property ufl_free_indices¶
- property ufl_index_dimensions¶
- property ufl_shape¶
- class ufl.classes.RealValue(value)[source]¶
Bases:
ScalarValue
Abstract class used to differentiate real values from complex ones
- ufl_free_indices = ()¶
- ufl_index_dimensions = ()¶
- ufl_shape = ()¶
- class ufl.classes.ReferenceCellEdgeVectors(domain)[source]¶
Bases:
GeometricCellQuantity
UFL geometry representation: The vectors between reference cell vertices for each edge in cell.
- is_cellwise_constant()[source]¶
Return whether this expression is spatially constant over each cell.
- name = 'RCEV'¶
- property ufl_shape¶
Built-in immutable sequence.
If no argument is given, the constructor returns an empty tuple. If iterable is specified the tuple is initialized from iterable’s items.
If the argument is a tuple, the return value is the same object.
- class ufl.classes.ReferenceCellVolume(domain)[source]¶
Bases:
GeometricCellQuantity
UFL geometry representation: The volume of the reference cell.
- name = 'reference_cell_volume'¶
- class ufl.classes.ReferenceCurl(f)[source]¶
Bases:
CompoundDerivative
- property ufl_free_indices¶
- property ufl_index_dimensions¶
- ufl_shape¶
- class ufl.classes.ReferenceDiv(f)[source]¶
Bases:
CompoundDerivative
- property ufl_free_indices¶
- property ufl_index_dimensions¶
- property ufl_shape¶
- class ufl.classes.ReferenceFacetEdgeVectors(domain)[source]¶
Bases:
GeometricFacetQuantity
UFL geometry representation: The vectors between reference cell vertices for each edge in current facet.
- is_cellwise_constant()[source]¶
Return whether this expression is spatially constant over each cell.
- name = 'RFEV'¶
- property ufl_shape¶
Built-in immutable sequence.
If no argument is given, the constructor returns an empty tuple. If iterable is specified the tuple is initialized from iterable’s items.
If the argument is a tuple, the return value is the same object.
- class ufl.classes.ReferenceFacetVolume(domain)[source]¶
Bases:
GeometricFacetQuantity
UFL geometry representation: The volume of the reference cell of the current facet.
- name = 'reference_facet_volume'¶
- class ufl.classes.ReferenceGrad(f)[source]¶
Bases:
CompoundDerivative
- evaluate(x, mapping, component, index_values, derivatives=())[source]¶
Get child from mapping and return the component asked for.
- property ufl_free_indices¶
- property ufl_index_dimensions¶
- property ufl_shape¶
- class ufl.classes.ReferenceNormal(domain)[source]¶
Bases:
GeometricFacetQuantity
UFL geometry representation: The outwards pointing normal vector of the current facet on the reference cell
- name = 'reference_normal'¶
- property ufl_shape¶
Built-in immutable sequence.
If no argument is given, the constructor returns an empty tuple. If iterable is specified the tuple is initialized from iterable’s items.
If the argument is a tuple, the return value is the same object.
- class ufl.classes.ReferenceValue(f)[source]¶
Bases:
Operator
Representation of the reference cell value of a form argument.
- evaluate(x, mapping, component, index_values, derivatives=())[source]¶
Get child from mapping and return the component asked for.
- ufl_free_indices = ()¶
- ufl_index_dimensions = ()¶
- property ufl_shape¶
- class ufl.classes.Restricted(f)[source]¶
Bases:
Operator
- evaluate(x, mapping, component, index_values)[source]¶
Evaluate expression at given coordinate with given values for terminals.
- property ufl_free_indices¶
- property ufl_index_dimensions¶
- property ufl_shape¶
- class ufl.classes.RestrictedElement(element, restriction_domain)[source]¶
Bases:
FiniteElementBase
Represents the restriction of a finite element to a type of cell entity.
- class ufl.classes.ScalarValue(value)[source]¶
Bases:
ConstantValue
A constant scalar value.
- evaluate(x, mapping, component, index_values)[source]¶
Get self from mapping and return the component asked for.
- ufl_free_indices = ()¶
- ufl_index_dimensions = ()¶
- ufl_shape = ()¶
- class ufl.classes.Sin(argument)[source]¶
Bases:
MathFunction
- class ufl.classes.Sinh(argument)[source]¶
Bases:
MathFunction
- class ufl.classes.Skew(A)[source]¶
Bases:
CompoundTensorOperator
- property ufl_free_indices¶
- property ufl_index_dimensions¶
- property ufl_shape¶
- class ufl.classes.SpatialCoordinate(domain)[source]¶
Bases:
GeometricCellQuantity
UFL geometry representation: The coordinate in a domain.
In the context of expression integration, represents the domain coordinate of each quadrature point.
In the context of expression evaluation in a point, represents the value of that point.
- is_cellwise_constant()[source]¶
Return whether this expression is spatially constant over each cell.
- name = 'x'¶
- property ufl_shape¶
Return the number of coordinates defined (i.e. the geometric dimension of the domain).
- class ufl.classes.Sqrt(argument)[source]¶
Bases:
MathFunction
- class ufl.classes.Sum(a, b)[source]¶
Bases:
Operator
- evaluate(x, mapping, component, index_values)[source]¶
Evaluate expression at given coordinate with given values for terminals.
- property ufl_free_indices¶
- property ufl_index_dimensions¶
- property ufl_shape¶
- class ufl.classes.Sym(A)[source]¶
Bases:
CompoundTensorOperator
- property ufl_free_indices¶
- property ufl_index_dimensions¶
- property ufl_shape¶
- class ufl.classes.Tan(argument)[source]¶
Bases:
MathFunction
- class ufl.classes.Tanh(argument)[source]¶
Bases:
MathFunction
- class ufl.classes.TensorElement(family, cell=None, degree=None, shape=None, symmetry=None, quad_scheme=None, variant=None)[source]¶
Bases:
MixedElement
A special case of a mixed finite element where all elements are equal.
- extract_subelement_component(i)[source]¶
Extract direct subelement index and subelement relative component index for a given component index.
- class ufl.classes.TensorProductCell(*cells, **kwargs)[source]¶
Bases:
AbstractCell
- class ufl.classes.TensorProductElement(*elements, **kwargs)[source]¶
Bases:
FiniteElementBase
The tensor product of \(d\) element spaces:
\[V = V_1 \otimes V_2 \otimes ... \otimes V_d\]Given bases \(\{\phi_{j_i}\}\) of the spaces \(V_i\) for \(i = 1, ...., d\), \(\{ \phi_{j_1} \otimes \phi_{j_2} \otimes \cdots \otimes \phi_{j_d} \}\) forms a basis for \(V\).
- class ufl.classes.TensorProductFunctionSpace(*function_spaces)[source]¶
Bases:
AbstractFunctionSpace
- class ufl.classes.TensorProductMesh(meshes, ufl_id=None)[source]¶
Bases:
AbstractDomain
Symbolic representation of a mesh.
- ufl_id()¶
Return the ufl_id of this object.
- class ufl.classes.Terminal[source]¶
Bases:
Expr
A terminal node in the UFL expression tree.
- evaluate(x, mapping, component, index_values, derivatives=())[source]¶
Get self from mapping and return the component asked for.
- ufl_free_indices = ()¶
- ufl_index_dimensions = ()¶
- ufl_operands = ()¶
- ufl.classes.TestFunction(function_space, part=None)[source]¶
UFL value: Create a test function argument to a form.
- ufl.classes.TestFunctions(function_space)[source]¶
UFL value: Create a TestFunction in a mixed space, and return a tuple with the function components corresponding to the subelements.
- class ufl.classes.Trace(A)[source]¶
Bases:
CompoundTensorOperator
- property ufl_free_indices¶
- property ufl_index_dimensions¶
- ufl_shape = ()¶
- class ufl.classes.Transposed(A)[source]¶
Bases:
CompoundTensorOperator
- property ufl_free_indices¶
- property ufl_index_dimensions¶
- property ufl_shape¶
- ufl.classes.TrialFunction(function_space, part=None)[source]¶
UFL value: Create a trial function argument to a form.
- ufl.classes.TrialFunctions(function_space)[source]¶
UFL value: Create a TrialFunction in a mixed space, and return a tuple with the function components corresponding to the subelements.
- class ufl.classes.Variable(expression, label=None)[source]¶
Bases:
Operator
A Variable is a representative for another expression.
It will be used by the end-user mainly for defining a quantity to differentiate w.r.t. using diff. Example:
e = <...> e = variable(e) f = exp(e**2) df = diff(f, e)
- evaluate(x, mapping, component, index_values)[source]¶
Evaluate expression at given coordinate with given values for terminals.
- ufl_free_indices = ()¶
- ufl_index_dimensions = ()¶
- property ufl_shape¶
- class ufl.classes.VariableDerivative(f, v)[source]¶
Bases:
Derivative
- ufl_free_indices¶
- ufl_index_dimensions¶
- ufl_shape¶
- class ufl.classes.VectorElement(family, cell=None, degree=None, dim=None, form_degree=None, quad_scheme=None, variant=None)[source]¶
Bases:
MixedElement
A special case of a mixed finite element where all elements are equal.
- class ufl.classes.WithMapping(wrapee, mapping)[source]¶
Bases:
FiniteElementBase
Specify an alternative mapping for the wrappee. For example, to use identity mapping instead of Piola map with an element E, write remapped = WithMapping(E, “identity”)
- class ufl.classes.Zero(shape=(), free_indices=(), index_dimensions=None)[source]¶
Bases:
ConstantValue
UFL literal type: Representation of a zero valued expression.
- evaluate(x, mapping, component, index_values)[source]¶
Get self from mapping and return the component asked for.
- ufl_free_indices¶
- ufl_index_dimensions¶
- ufl_shape¶
ufl.coefficient module¶
This module defines the Coefficient class and a number of related classes, including Constant.
- class ufl.coefficient.Coefficient(function_space, count=None)[source]¶
Bases:
FormArgument
UFL form argument type: Representation of a form coefficient.
- is_cellwise_constant()[source]¶
Return whether this expression is spatially constant over each cell.
- ufl_element()[source]¶
Shortcut to get the finite element of the function space of this coefficient.
- property ufl_shape¶
Return the associated UFL shape.
ufl.compound_expressions module¶
Functions implementing compound expressions as equivalent representations using basic operators.
- ufl.compound_expressions.generic_pseudo_determinant_expr(A)[source]¶
Compute the pseudo-determinant of A: sqrt(det(A.T*A)).
ufl.conditional module¶
This module defines classes for conditional expressions.
- class ufl.conditional.AndCondition(left, right)[source]¶
Bases:
BinaryCondition
- class ufl.conditional.Condition(operands)[source]¶
Bases:
Operator
- ufl_free_indices = ()¶
- ufl_index_dimensions = ()¶
- ufl_shape = ()¶
- class ufl.conditional.Conditional(condition, true_value, false_value)[source]¶
Bases:
Operator
- evaluate(x, mapping, component, index_values)[source]¶
Evaluate expression at given coordinate with given values for terminals.
- property ufl_free_indices¶
- property ufl_index_dimensions¶
- property ufl_shape¶
- class ufl.conditional.EQ(left, right)[source]¶
Bases:
BinaryCondition
- class ufl.conditional.GE(left, right)[source]¶
Bases:
BinaryCondition
- class ufl.conditional.GT(left, right)[source]¶
Bases:
BinaryCondition
- class ufl.conditional.LE(left, right)[source]¶
Bases:
BinaryCondition
- class ufl.conditional.LT(left, right)[source]¶
Bases:
BinaryCondition
- class ufl.conditional.MaxValue(left, right)[source]¶
Bases:
Operator
UFL operator: Take the maximum of two values.
- evaluate(x, mapping, component, index_values)[source]¶
Evaluate expression at given coordinate with given values for terminals.
- ufl_free_indices = ()¶
- ufl_index_dimensions = ()¶
- ufl_shape = ()¶
- class ufl.conditional.MinValue(left, right)[source]¶
Bases:
Operator
UFL operator: Take the minimum of two values.
- evaluate(x, mapping, component, index_values)[source]¶
Evaluate expression at given coordinate with given values for terminals.
- ufl_free_indices = ()¶
- ufl_index_dimensions = ()¶
- ufl_shape = ()¶
- class ufl.conditional.NE(left, right)[source]¶
Bases:
BinaryCondition
- class ufl.conditional.OrCondition(left, right)[source]¶
Bases:
BinaryCondition
ufl.constant module¶
This module defines classes representing non-literal values which are constant with respect to a domain.
ufl.constantvalue module¶
This module defines classes representing constant values.
- class ufl.constantvalue.ComplexValue(value)[source]¶
Bases:
ScalarValue
UFL literal type: Representation of a constant, complex scalar
- class ufl.constantvalue.ConstantValue[source]¶
Bases:
Terminal
- class ufl.constantvalue.FloatValue(value)[source]¶
Bases:
RealValue
UFL literal type: Representation of a constant scalar floating point value.
- class ufl.constantvalue.Identity(dim)[source]¶
Bases:
ConstantValue
UFL literal type: Representation of an identity matrix.
- evaluate(x, mapping, component, index_values)[source]¶
Evaluates the identity matrix on the given components.
- ufl_shape¶
- class ufl.constantvalue.IntValue(value)[source]¶
Bases:
RealValue
UFL literal type: Representation of a constant scalar integer value.
- class ufl.constantvalue.PermutationSymbol(dim)[source]¶
Bases:
ConstantValue
UFL literal type: Representation of a permutation symbol.
This is also known as the Levi-Civita symbol, antisymmetric symbol, or alternating symbol.
- ufl_shape¶
- class ufl.constantvalue.RealValue(value)[source]¶
Bases:
ScalarValue
Abstract class used to differentiate real values from complex ones
- ufl_free_indices = ()¶
- ufl_index_dimensions = ()¶
- ufl_shape = ()¶
- class ufl.constantvalue.ScalarValue(value)[source]¶
Bases:
ConstantValue
A constant scalar value.
- evaluate(x, mapping, component, index_values)[source]¶
Get self from mapping and return the component asked for.
- ufl_free_indices = ()¶
- ufl_index_dimensions = ()¶
- ufl_shape = ()¶
- class ufl.constantvalue.Zero(shape=(), free_indices=(), index_dimensions=None)[source]¶
Bases:
ConstantValue
UFL literal type: Representation of a zero valued expression.
- evaluate(x, mapping, component, index_values)[source]¶
Get self from mapping and return the component asked for.
- ufl_free_indices¶
- ufl_index_dimensions¶
- ufl_shape¶
ufl.differentiation module¶
Differential operators.
- class ufl.differentiation.CoefficientDerivative(integrand, coefficients, arguments, coefficient_derivatives)[source]¶
Bases:
Derivative
Derivative of the integrand of a form w.r.t. the degrees of freedom in a discrete Coefficient.
- property ufl_free_indices¶
- property ufl_index_dimensions¶
- property ufl_shape¶
- class ufl.differentiation.CompoundDerivative(operands)[source]¶
Bases:
Derivative
Base class for all compound derivative types.
- class ufl.differentiation.CoordinateDerivative(integrand, coefficients, arguments, coefficient_derivatives)[source]¶
Bases:
CoefficientDerivative
Derivative of the integrand of a form w.r.t. the SpatialCoordinates.
- property ufl_free_indices¶
- property ufl_index_dimensions¶
- property ufl_shape¶
- class ufl.differentiation.Curl(f)[source]¶
Bases:
CompoundDerivative
- property ufl_free_indices¶
- property ufl_index_dimensions¶
- ufl_shape¶
- class ufl.differentiation.Derivative(operands)[source]¶
Bases:
Operator
Base class for all derivative types.
- class ufl.differentiation.Div(f)[source]¶
Bases:
CompoundDerivative
- property ufl_free_indices¶
- property ufl_index_dimensions¶
- property ufl_shape¶
- class ufl.differentiation.Grad(f)[source]¶
Bases:
CompoundDerivative
- evaluate(x, mapping, component, index_values, derivatives=())[source]¶
Get child from mapping and return the component asked for.
- property ufl_free_indices¶
- property ufl_index_dimensions¶
- property ufl_shape¶
- class ufl.differentiation.NablaDiv(f)[source]¶
Bases:
CompoundDerivative
- property ufl_free_indices¶
- property ufl_index_dimensions¶
- property ufl_shape¶
- class ufl.differentiation.NablaGrad(f)[source]¶
Bases:
CompoundDerivative
- property ufl_free_indices¶
- property ufl_index_dimensions¶
- property ufl_shape¶
- class ufl.differentiation.ReferenceCurl(f)[source]¶
Bases:
CompoundDerivative
- property ufl_free_indices¶
- property ufl_index_dimensions¶
- ufl_shape¶
- class ufl.differentiation.ReferenceDiv(f)[source]¶
Bases:
CompoundDerivative
- property ufl_free_indices¶
- property ufl_index_dimensions¶
- property ufl_shape¶
ufl.domain module¶
Types for representing a geometric domain.
- class ufl.domain.AbstractDomain(topological_dimension, geometric_dimension)[source]¶
Bases:
object
Symbolic representation of a geometric domain with only a geometric and topological dimension.
- class ufl.domain.Mesh(coordinate_element, ufl_id=None, cargo=None)[source]¶
Bases:
AbstractDomain
Symbolic representation of a mesh.
- ufl_id()¶
Return the ufl_id of this object.
- class ufl.domain.MeshView(mesh, topological_dimension, ufl_id=None)[source]¶
Bases:
AbstractDomain
Symbolic representation of a mesh.
- ufl_id()¶
Return the ufl_id of this object.
- class ufl.domain.TensorProductMesh(meshes, ufl_id=None)[source]¶
Bases:
AbstractDomain
Symbolic representation of a mesh.
- ufl_id()¶
Return the ufl_id of this object.
- ufl.domain.affine_mesh(cell, ufl_id=None)[source]¶
Create a Mesh over a given cell type with an affine geometric parameterization.
- ufl.domain.default_domain(cell)[source]¶
Create a singular default Mesh from a cell, always returning the same Mesh object for the same cell.
- ufl.domain.extract_unique_domain(expr)[source]¶
Return the single unique domain expression is defined on or throw an error.
ufl.equation module¶
The Equation class, used to express equations like a == L.
ufl.exprcontainers module¶
This module defines special types for representing mapping of expressions to expressions.
- class ufl.exprcontainers.ExprList(*operands)[source]¶
Bases:
Operator
List of Expr objects. For internal use, never to be created by end users.
- property ufl_free_indices¶
- property ufl_index_dimensions¶
- property ufl_shape¶
ufl.exprequals module¶
- ufl.exprequals.expr_equals(self, other)¶
Checks whether the two expressions are represented the exact same way. This does not check if the expressions are mathematically equal or equivalent! Used by sets and dicts.
ufl.exproperators module¶
This module attaches special functions to Expr. This way we avoid circular dependencies between e.g. Sum and its superclass Expr.
- ufl.exproperators.analyse_key(ii, rank)[source]¶
Takes something the user might input as an index tuple inside [], which could include complete slices (:) and ellipsis (…), and returns tuples of actual UFL index objects.
The return value is a tuple (indices, axis_indices), each being a tuple of IndexBase instances.
The return value ‘indices’ corresponds to all input objects of these types: - Index - FixedIndex - int => Wrapped in FixedIndex
The return value ‘axis_indices’ corresponds to all input objects of these types: - Complete slice (:) => Replaced by a single new index - Ellipsis (…) => Replaced by multiple new indices
ufl.form module¶
The Form class.
- class ufl.form.Form(integrals)[source]¶
Bases:
object
Description of a weak form consisting of a sum of integrals over subdomains.
- coefficient_numbering()[source]¶
Return a contiguous numbering of coefficients in a mapping
{coefficient:number}
.
- constant_numbering()[source]¶
Return a contiguous numbering of constants in a mapping
{constant:number}
.
- geometric_dimension()[source]¶
Return the geometric dimension shared by all domains and functions in this form.
- integrals_by_domain(domain)[source]¶
Return a sequence of all integrals with a particular integration domain.
- integrals_by_type(integral_type)[source]¶
Return a sequence of all integrals with a particular domain type.
- max_subdomain_ids()[source]¶
Returns a mapping on the form
{domain:{integral_type:max_subdomain_id}}
.
- signature()[source]¶
Signature for use with jit cache (independent of incidental numbering of indices etc.)
- ufl_cell()[source]¶
Return the single cell this form is defined on, fails if multiple cells are found.
- ufl.form.replace_integral_domains(form, common_domain)[source]¶
Given a form and a domain, assign a common integration domain to all integrals.
Does not modify the input form (
Form
should always be immutable). This is to support ill formed forms with no domain specified, sometimes occurring in pydolfin, e.g. assemble(1*dx, mesh=mesh).
ufl.formoperators module¶
Various high level ways to transform a complete Form into a new Form.
- ufl.formoperators.action(form, coefficient=None)[source]¶
UFL form operator: Given a bilinear form, return a linear form with an additional coefficient, representing the action of the form on the coefficient. This can be used for matrix-free methods.
- ufl.formoperators.adjoint(form, reordered_arguments=None)[source]¶
UFL form operator: Given a combined bilinear form, compute the adjoint form by changing the ordering (count) of the test and trial functions, and taking the complex conjugate of the result.
By default, new
Argument
objects will be created with opposite ordering. However, if the adjoint form is to be added to other forms later, their arguments must match. In that case, the user must provide a tuple *reordered_arguments*=(u2,v2).
- ufl.formoperators.derivative(form, coefficient, argument=None, coefficient_derivatives=None)[source]¶
UFL form operator: Compute the Gateaux derivative of form w.r.t. coefficient in direction of argument.
If the argument is omitted, a new
Argument
is created in the same space as the coefficient, with argument number one higher than the highest one in the form.The resulting form has one additional
Argument
in the same finite element space as the coefficient.A tuple of
Coefficient
s may be provided in place of a singleCoefficient
, in which case the newArgument
argument is based on aMixedElement
created from this tuple.An indexed
Coefficient
from a mixed space may be provided, in which case the argument should be in the corresponding subspace of the coefficient space.If provided, coefficient_derivatives should be a mapping from
Coefficient
instances to their derivatives w.r.t. coefficient.
- ufl.formoperators.energy_norm(form, coefficient=None)[source]¶
UFL form operator: Given a bilinear form a and a coefficient f, return the functional \(a(f,f)\).
- ufl.formoperators.extract_blocks(form, i=None, j=None)[source]¶
UFL form operator: Given a linear or bilinear form on a mixed space, extract the block corresponding to the indices ix, iy.
a = inner(grad(u), grad(v))*dx + div(u)*q*dx + div(v)*p*dx extract_blocks(a, 0, 0) -> inner(grad(u), grad(v))*dx extract_blocks(a) -> [inner(grad(u), grad(v))*dx, div(v)*p*dx, div(u)*q*dx, 0]
- ufl.formoperators.lhs(form)[source]¶
UFL form operator: Given a combined bilinear and linear form, extract the left hand side (bilinear form part).
a = u*v*dx + f*v*dx a = lhs(a) -> u*v*dx
- ufl.formoperators.rhs(form)[source]¶
UFL form operator: Given a combined bilinear and linear form, extract the right hand side (negated linear form part).
a = u*v*dx + f*v*dx L = rhs(a) -> -f*v*dx
- ufl.formoperators.sensitivity_rhs(a, u, L, v)[source]¶
UFL form operator: Compute the right hand side for a sensitivity calculation system.
The derivation behind this computation is as follows. Assume a, L to be bilinear and linear forms corresponding to the assembled linear system
\[Ax = b.\]Where x is the vector of the discrete function corresponding to u. Let v be some scalar variable this equation depends on. Then we can write
\[ \begin{align}\begin{aligned}0 = \frac{d}{dv}(Ax-b) = \frac{dA}{dv} x + A \frac{dx}{dv} - \frac{db}{dv},\\A \frac{dx}{dv} = \frac{db}{dv} - \frac{dA}{dv} x,\end{aligned}\end{align} \]and solve this system for \(\frac{dx}{dv}\), using the same bilinear form a and matrix A from the original system. Assume the forms are written
v = variable(v_expression) L = IL(v)*dx a = Ia(v)*dx
where
IL
andIa
are integrand expressions. Define aCoefficient u
representing the solution to the equations. Then we can compute \(\frac{db}{dv}\) and \(\frac{dA}{dv}\) from the formsda = diff(a, v) dL = diff(L, v)
and the action of
da
onu
bydau = action(da, u)
In total, we can build the right hand side of the system to compute \(\frac{du}{dv}\) with the single line
dL = diff(L, v) - action(diff(a, v), u)
or, using this function,
dL = sensitivity_rhs(a, u, L, v)
ufl.functionspace module¶
Types for representing function spaces.
- class ufl.functionspace.FunctionSpace(domain, element)[source]¶
Bases:
AbstractFunctionSpace
- class ufl.functionspace.MixedFunctionSpace(*args)[source]¶
Bases:
AbstractFunctionSpace
- class ufl.functionspace.TensorProductFunctionSpace(*function_spaces)[source]¶
Bases:
AbstractFunctionSpace
ufl.geometry module¶
Types for representing symbolic expressions for geometric quantities.
- class ufl.geometry.CellCoordinate(domain)[source]¶
Bases:
GeometricCellQuantity
UFL geometry representation: The coordinate in a reference cell.
In the context of expression integration, represents the reference cell coordinate of each quadrature point.
In the context of expression evaluation in a point in a cell, represents that point in the reference coordinate system of the cell.
- is_cellwise_constant()[source]¶
Return whether this expression is spatially constant over each cell.
- name = 'X'¶
- property ufl_shape¶
Built-in immutable sequence.
If no argument is given, the constructor returns an empty tuple. If iterable is specified the tuple is initialized from iterable’s items.
If the argument is a tuple, the return value is the same object.
- class ufl.geometry.CellDiameter(domain)[source]¶
Bases:
GeometricCellQuantity
UFL geometry representation: The diameter of the cell, i.e., maximal distance of two points in the cell.
- name = 'diameter'¶
- class ufl.geometry.CellEdgeVectors(domain)[source]¶
Bases:
GeometricCellQuantity
UFL geometry representation: The vectors between physical cell vertices for each edge in cell.
- is_cellwise_constant()[source]¶
Return whether this expression is spatially constant over each cell.
- name = 'CEV'¶
- property ufl_shape¶
Built-in immutable sequence.
If no argument is given, the constructor returns an empty tuple. If iterable is specified the tuple is initialized from iterable’s items.
If the argument is a tuple, the return value is the same object.
- class ufl.geometry.CellFacetJacobian(domain)[source]¶
Bases:
GeometricFacetQuantity
UFL geometry representation: The Jacobian of the mapping from reference facet to reference cell coordinates.
CFJ_ij = dX_i/dXf_j
- is_cellwise_constant()[source]¶
Return whether this expression is spatially constant over each cell.
- name = 'CFJ'¶
- property ufl_shape¶
Built-in immutable sequence.
If no argument is given, the constructor returns an empty tuple. If iterable is specified the tuple is initialized from iterable’s items.
If the argument is a tuple, the return value is the same object.
- class ufl.geometry.CellFacetJacobianDeterminant(domain)[source]¶
Bases:
GeometricFacetQuantity
UFL geometry representation: The pseudo-determinant of the CellFacetJacobian.
- is_cellwise_constant()[source]¶
Return whether this expression is spatially constant over each cell.
- name = 'detCFJ'¶
- class ufl.geometry.CellFacetJacobianInverse(domain)[source]¶
Bases:
GeometricFacetQuantity
UFL geometry representation: The pseudo-inverse of the CellFacetJacobian.
- is_cellwise_constant()[source]¶
Return whether this expression is spatially constant over each cell.
- name = 'CFK'¶
- property ufl_shape¶
Built-in immutable sequence.
If no argument is given, the constructor returns an empty tuple. If iterable is specified the tuple is initialized from iterable’s items.
If the argument is a tuple, the return value is the same object.
- class ufl.geometry.CellFacetOrigin(domain)[source]¶
Bases:
GeometricFacetQuantity
UFL geometry representation: The reference cell coordinate corresponding to origin of a reference facet.
- name = 'X0f'¶
- property ufl_shape¶
Built-in immutable sequence.
If no argument is given, the constructor returns an empty tuple. If iterable is specified the tuple is initialized from iterable’s items.
If the argument is a tuple, the return value is the same object.
- class ufl.geometry.CellNormal(domain)[source]¶
Bases:
GeometricCellQuantity
UFL geometry representation: The upwards pointing normal vector of the current manifold cell.
- name = 'cell_normal'¶
- property ufl_shape¶
Return the number of coordinates defined (i.e. the geometric dimension of the domain).
- class ufl.geometry.CellOrientation(domain)[source]¶
Bases:
GeometricCellQuantity
UFL geometry representation: The orientation (+1/-1) of the current cell.
For non-manifold cells (tdim == gdim), this equals the sign of the Jacobian determinant, i.e. +1 if the physical cell is oriented the same way as the reference cell and -1 otherwise.
For manifold cells of tdim==gdim-1 this is input data belonging to the mesh, used to distinguish between the sides of the manifold.
- name = 'cell_orientation'¶
- class ufl.geometry.CellOrigin(domain)[source]¶
Bases:
GeometricCellQuantity
UFL geometry representation: The spatial coordinate corresponding to origin of a reference cell.
- is_cellwise_constant()[source]¶
Return whether this expression is spatially constant over each cell (or over each facet for facet quantities).
- name = 'x0'¶
- property ufl_shape¶
Built-in immutable sequence.
If no argument is given, the constructor returns an empty tuple. If iterable is specified the tuple is initialized from iterable’s items.
If the argument is a tuple, the return value is the same object.
- class ufl.geometry.CellVertices(domain)[source]¶
Bases:
GeometricCellQuantity
UFL geometry representation: Physical cell vertices.
- is_cellwise_constant()[source]¶
Return whether this expression is spatially constant over each cell.
- name = 'CV'¶
- property ufl_shape¶
Built-in immutable sequence.
If no argument is given, the constructor returns an empty tuple. If iterable is specified the tuple is initialized from iterable’s items.
If the argument is a tuple, the return value is the same object.
- class ufl.geometry.CellVolume(domain)[source]¶
Bases:
GeometricCellQuantity
UFL geometry representation: The volume of the cell.
- name = 'volume'¶
- class ufl.geometry.Circumradius(domain)[source]¶
Bases:
GeometricCellQuantity
UFL geometry representation: The circumradius of the cell.
- name = 'circumradius'¶
- class ufl.geometry.FacetArea(domain)[source]¶
Bases:
GeometricFacetQuantity
UFL geometry representation: The area of the facet.
- name = 'facetarea'¶
- class ufl.geometry.FacetCoordinate(domain)[source]¶
Bases:
GeometricFacetQuantity
UFL geometry representation: The coordinate in a reference cell of a facet.
In the context of expression integration over a facet, represents the reference facet coordinate of each quadrature point.
In the context of expression evaluation in a point on a facet, represents that point in the reference coordinate system of the facet.
- is_cellwise_constant()[source]¶
Return whether this expression is spatially constant over each cell.
- name = 'Xf'¶
- property ufl_shape¶
Built-in immutable sequence.
If no argument is given, the constructor returns an empty tuple. If iterable is specified the tuple is initialized from iterable’s items.
If the argument is a tuple, the return value is the same object.
- class ufl.geometry.FacetEdgeVectors(domain)[source]¶
Bases:
GeometricFacetQuantity
UFL geometry representation: The vectors between physical cell vertices for each edge in current facet.
- is_cellwise_constant()[source]¶
Return whether this expression is spatially constant over each cell.
- name = 'FEV'¶
- property ufl_shape¶
Built-in immutable sequence.
If no argument is given, the constructor returns an empty tuple. If iterable is specified the tuple is initialized from iterable’s items.
If the argument is a tuple, the return value is the same object.
- class ufl.geometry.FacetJacobian(domain)[source]¶
Bases:
GeometricFacetQuantity
UFL geometry representation: The Jacobian of the mapping from reference facet to spatial coordinates.
FJ_ij = dx_i/dXf_j
The FacetJacobian is the product of the Jacobian and CellFacetJacobian:
FJ = dx/dXf = dx/dX dX/dXf = J * CFJ
- is_cellwise_constant()[source]¶
Return whether this expression is spatially constant over each cell.
- name = 'FJ'¶
- property ufl_shape¶
Built-in immutable sequence.
If no argument is given, the constructor returns an empty tuple. If iterable is specified the tuple is initialized from iterable’s items.
If the argument is a tuple, the return value is the same object.
- class ufl.geometry.FacetJacobianDeterminant(domain)[source]¶
Bases:
GeometricFacetQuantity
UFL geometry representation: The pseudo-determinant of the FacetJacobian.
- is_cellwise_constant()[source]¶
Return whether this expression is spatially constant over each cell.
- name = 'detFJ'¶
- class ufl.geometry.FacetJacobianInverse(domain)[source]¶
Bases:
GeometricFacetQuantity
UFL geometry representation: The pseudo-inverse of the FacetJacobian.
- is_cellwise_constant()[source]¶
Return whether this expression is spatially constant over each cell.
- name = 'FK'¶
- property ufl_shape¶
Built-in immutable sequence.
If no argument is given, the constructor returns an empty tuple. If iterable is specified the tuple is initialized from iterable’s items.
If the argument is a tuple, the return value is the same object.
- class ufl.geometry.FacetNormal(domain)[source]¶
Bases:
GeometricFacetQuantity
UFL geometry representation: The outwards pointing normal vector of the current facet.
- is_cellwise_constant()[source]¶
Return whether this expression is spatially constant over each cell.
- name = 'n'¶
- property ufl_shape¶
Return the number of coordinates defined (i.e. the geometric dimension of the domain).
- class ufl.geometry.FacetOrientation(domain)[source]¶
Bases:
GeometricFacetQuantity
UFL geometry representation: The orientation (+1/-1) of the current facet relative to the reference cell.
- name = 'facet_orientation'¶
- class ufl.geometry.FacetOrigin(domain)[source]¶
Bases:
GeometricFacetQuantity
UFL geometry representation: The spatial coordinate corresponding to origin of a reference facet.
- name = 'x0f'¶
- property ufl_shape¶
Built-in immutable sequence.
If no argument is given, the constructor returns an empty tuple. If iterable is specified the tuple is initialized from iterable’s items.
If the argument is a tuple, the return value is the same object.
- class ufl.geometry.GeometricCellQuantity(domain)[source]¶
Bases:
GeometricQuantity
- class ufl.geometry.GeometricFacetQuantity(domain)[source]¶
Bases:
GeometricQuantity
- class ufl.geometry.GeometricQuantity(domain)[source]¶
Bases:
Terminal
- is_cellwise_constant()[source]¶
Return whether this expression is spatially constant over each cell (or over each facet for facet quantities).
- ufl_shape = ()¶
- class ufl.geometry.Jacobian(domain)[source]¶
Bases:
GeometricCellQuantity
UFL geometry representation: The Jacobian of the mapping from reference cell to spatial coordinates.
\[J_{ij} = \frac{dx_i}{dX_j}\]- is_cellwise_constant()[source]¶
Return whether this expression is spatially constant over each cell.
- name = 'J'¶
- property ufl_shape¶
Return the number of coordinates defined (i.e. the geometric dimension of the domain).
- class ufl.geometry.JacobianDeterminant(domain)[source]¶
Bases:
GeometricCellQuantity
UFL geometry representation: The determinant of the Jacobian.
Represents the signed determinant of a square Jacobian or the pseudo-determinant of a non-square Jacobian.
- is_cellwise_constant()[source]¶
Return whether this expression is spatially constant over each cell.
- name = 'detJ'¶
- class ufl.geometry.JacobianInverse(domain)[source]¶
Bases:
GeometricCellQuantity
UFL geometry representation: The inverse of the Jacobian.
Represents the inverse of a square Jacobian or the pseudo-inverse of a non-square Jacobian.
- is_cellwise_constant()[source]¶
Return whether this expression is spatially constant over each cell.
- name = 'K'¶
- property ufl_shape¶
Return the number of coordinates defined (i.e. the geometric dimension of the domain).
- class ufl.geometry.MaxCellEdgeLength(domain)[source]¶
Bases:
GeometricCellQuantity
UFL geometry representation: The maximum edge length of the cell.
- name = 'maxcelledgelength'¶
- class ufl.geometry.MaxFacetEdgeLength(domain)[source]¶
Bases:
GeometricFacetQuantity
UFL geometry representation: The maximum edge length of the facet.
- name = 'maxfacetedgelength'¶
- class ufl.geometry.MinCellEdgeLength(domain)[source]¶
Bases:
GeometricCellQuantity
UFL geometry representation: The minimum edge length of the cell.
- name = 'mincelledgelength'¶
- class ufl.geometry.MinFacetEdgeLength(domain)[source]¶
Bases:
GeometricFacetQuantity
UFL geometry representation: The minimum edge length of the facet.
- name = 'minfacetedgelength'¶
- class ufl.geometry.QuadratureWeight(domain)[source]¶
Bases:
GeometricQuantity
UFL geometry representation: The current quadrature weight.
Only used inside a quadrature context.
- is_cellwise_constant()[source]¶
Return whether this expression is spatially constant over each cell.
- name = 'weight'¶
- class ufl.geometry.ReferenceCellEdgeVectors(domain)[source]¶
Bases:
GeometricCellQuantity
UFL geometry representation: The vectors between reference cell vertices for each edge in cell.
- is_cellwise_constant()[source]¶
Return whether this expression is spatially constant over each cell.
- name = 'RCEV'¶
- property ufl_shape¶
Built-in immutable sequence.
If no argument is given, the constructor returns an empty tuple. If iterable is specified the tuple is initialized from iterable’s items.
If the argument is a tuple, the return value is the same object.
- class ufl.geometry.ReferenceCellVolume(domain)[source]¶
Bases:
GeometricCellQuantity
UFL geometry representation: The volume of the reference cell.
- name = 'reference_cell_volume'¶
- class ufl.geometry.ReferenceFacetEdgeVectors(domain)[source]¶
Bases:
GeometricFacetQuantity
UFL geometry representation: The vectors between reference cell vertices for each edge in current facet.
- is_cellwise_constant()[source]¶
Return whether this expression is spatially constant over each cell.
- name = 'RFEV'¶
- property ufl_shape¶
Built-in immutable sequence.
If no argument is given, the constructor returns an empty tuple. If iterable is specified the tuple is initialized from iterable’s items.
If the argument is a tuple, the return value is the same object.
- class ufl.geometry.ReferenceFacetVolume(domain)[source]¶
Bases:
GeometricFacetQuantity
UFL geometry representation: The volume of the reference cell of the current facet.
- name = 'reference_facet_volume'¶
- class ufl.geometry.ReferenceNormal(domain)[source]¶
Bases:
GeometricFacetQuantity
UFL geometry representation: The outwards pointing normal vector of the current facet on the reference cell
- name = 'reference_normal'¶
- property ufl_shape¶
Built-in immutable sequence.
If no argument is given, the constructor returns an empty tuple. If iterable is specified the tuple is initialized from iterable’s items.
If the argument is a tuple, the return value is the same object.
- class ufl.geometry.SpatialCoordinate(domain)[source]¶
Bases:
GeometricCellQuantity
UFL geometry representation: The coordinate in a domain.
In the context of expression integration, represents the domain coordinate of each quadrature point.
In the context of expression evaluation in a point, represents the value of that point.
- is_cellwise_constant()[source]¶
Return whether this expression is spatially constant over each cell.
- name = 'x'¶
- property ufl_shape¶
Return the number of coordinates defined (i.e. the geometric dimension of the domain).
ufl.index_combination_utils module¶
Utilities for analysing and manipulating free index tuples
- ufl.index_combination_utils.merge_nonoverlapping_indices(a, b)[source]¶
Merge non-overlapping free indices into one representation.
C[i,j,r,s] = outer(A[i,s], B[j,r]) A, B -> (i,j,r,s), (idim,jdim,rdim,sdim)
- ufl.index_combination_utils.merge_overlapping_indices(afi, afid, bfi, bfid)[source]¶
Merge overlapping free indices into one free and one repeated representation.
C[j,r] := A[i,j,k] * B[i,r,k] A, B -> (j,r), (jdim,rdim), (i,k), (idim,kdim)
- ufl.index_combination_utils.merge_unique_indices(afi, afid, bfi, bfid)[source]¶
Merge two pairs of (index ids, index dimensions) sequences into one pair without duplicates.
The id tuples afi, bfi are assumed already sorted by id. Given a list of (id, dim) tuples already sorted by id, return a unique list with duplicates removed. Also checks that the dimensions of duplicates are matching.
ufl.indexed module¶
This module defines the Indexed class.
ufl.indexsum module¶
This module defines the IndexSum class.
ufl.integral module¶
The Integral class.
- class ufl.integral.Integral(integrand, integral_type, domain, subdomain_id, metadata, subdomain_data)[source]¶
Bases:
object
An integral over a single domain.
- 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.
<a = Integral instance> b = a.reconstruct(expand_compounds(a.integrand())) c = a.reconstruct(metadata={‘quadrature_degree’:2})
ufl.log module¶
This module provides functions used by the UFL implementation to output messages. These may be redirected by the user of UFL.
- class ufl.log.Logger(name, exception_type=<class 'Exception'>)[source]¶
Bases:
object
- get_logfile_handler(filename)[source]¶
Gets the handler to the file identified by the given file name.
- ufl.log.add_indent(increment=1)¶
Add to indentation level.
- ufl.log.add_logfile(filename=None, mode='a', level=10)¶
Add a log file.
- ufl.log.begin(*message)¶
Begin task: write message and increase indentation level.
- ufl.log.debug(*message)¶
Write debug message.
- ufl.log.deprecate(*message)¶
Write deprecation message.
- ufl.log.end()¶
End task: write a newline and decrease indentation level.
- ufl.log.error(*message)¶
Write error message and raise an exception.
- ufl.log.get_handler()¶
Get handler for logging.
- ufl.log.get_logger()¶
Return message logger.
- ufl.log.info(*message)¶
Write info message.
- ufl.log.info_blue(*message)¶
Write info message in blue.
- ufl.log.info_green(*message)¶
Write info message in green.
- ufl.log.info_red(*message)¶
Write info message in red.
- ufl.log.log(level, *message)¶
Write a log message on given log level.
- ufl.log.pop_level()¶
Pop log level from the level stack, reverting to before the last push_level.
- ufl.log.push_level(level)¶
Push a log level on the level stack.
- ufl.log.set_handler(handler)¶
Replace handler for logging. To add additional handlers instead of replacing the existing one, use log.get_logger().addHandler(myhandler). See the logging module for more details.
- ufl.log.set_indent(level)¶
Set indentation level.
- ufl.log.set_level(level)¶
Set log level.
- ufl.log.set_prefix(prefix)¶
Set prefix for log messages.
- ufl.log.warning(*message)¶
Write warning message.
- ufl.log.warning_blue(*message)¶
Write warning message in blue.
- ufl.log.warning_green(*message)¶
Write warning message in green.
- ufl.log.warning_red(*message)¶
Write warning message in red.
ufl.mathfunctions module¶
This module provides basic mathematical functions.
- class ufl.mathfunctions.Acos(argument)[source]¶
Bases:
MathFunction
- class ufl.mathfunctions.Asin(argument)[source]¶
Bases:
MathFunction
- class ufl.mathfunctions.Atan(argument)[source]¶
Bases:
MathFunction
- class ufl.mathfunctions.Atan2(arg1, arg2)[source]¶
Bases:
Operator
- evaluate(x, mapping, component, index_values)[source]¶
Evaluate expression at given coordinate with given values for terminals.
- ufl_free_indices = ()¶
- ufl_index_dimensions = ()¶
- ufl_shape = ()¶
- class ufl.mathfunctions.BesselFunction(name, classname, nu, argument)[source]¶
Bases:
Operator
Base class for all bessel functions
- evaluate(x, mapping, component, index_values)[source]¶
Evaluate expression at given coordinate with given values for terminals.
- ufl_free_indices = ()¶
- ufl_index_dimensions = ()¶
- ufl_shape = ()¶
- class ufl.mathfunctions.BesselI(nu, argument)[source]¶
Bases:
BesselFunction
- class ufl.mathfunctions.BesselJ(nu, argument)[source]¶
Bases:
BesselFunction
- class ufl.mathfunctions.BesselK(nu, argument)[source]¶
Bases:
BesselFunction
- class ufl.mathfunctions.BesselY(nu, argument)[source]¶
Bases:
BesselFunction
- class ufl.mathfunctions.Cos(argument)[source]¶
Bases:
MathFunction
- class ufl.mathfunctions.Cosh(argument)[source]¶
Bases:
MathFunction
- class ufl.mathfunctions.Erf(argument)[source]¶
Bases:
MathFunction
- class ufl.mathfunctions.Exp(argument)[source]¶
Bases:
MathFunction
- class ufl.mathfunctions.Ln(argument)[source]¶
Bases:
MathFunction
- class ufl.mathfunctions.MathFunction(name, argument)[source]¶
Bases:
Operator
Base class for all unary scalar math functions.
- evaluate(x, mapping, component, index_values)[source]¶
Evaluate expression at given coordinate with given values for terminals.
- ufl_free_indices = ()¶
- ufl_index_dimensions = ()¶
- ufl_shape = ()¶
- class ufl.mathfunctions.Sin(argument)[source]¶
Bases:
MathFunction
- class ufl.mathfunctions.Sinh(argument)[source]¶
Bases:
MathFunction
- class ufl.mathfunctions.Sqrt(argument)[source]¶
Bases:
MathFunction
- class ufl.mathfunctions.Tan(argument)[source]¶
Bases:
MathFunction
- class ufl.mathfunctions.Tanh(argument)[source]¶
Bases:
MathFunction
ufl.measure module¶
The Measure class.
- class ufl.measure.Measure(integral_type, domain=None, subdomain_id='everywhere', metadata=None, subdomain_data=None)[source]¶
Bases:
object
- integral_type()[source]¶
Return the domain type.
Valid domain types are “cell”, “exterior_facet”, “interior_facet”, etc.
- metadata()[source]¶
Return the integral metadata. This data is not interpreted by UFL. It is passed to the form compiler which can ignore it or use it to compile each integral of a form in a different way.
- reconstruct(integral_type=None, subdomain_id=None, domain=None, metadata=None, subdomain_data=None)[source]¶
Construct a new Measure object with some properties replaced with new values.
<dm = Measure instance> b = dm.reconstruct(subdomain_id=2) c = dm.reconstruct(metadata={ “quadrature_degree”: 3 })
- Used by the call operator, so this is equivalent:
b = dm(2) c = dm(0, { “quadrature_degree”: 3 })
- class ufl.measure.MeasureProduct(*measures)[source]¶
Bases:
object
Represents a product of measures.
This is a notational intermediate object to handle the notation
f*(dm1*dm2)
This is work in progress and not functional. It needs support in other parts of ufl and the rest of the code generation chain.
- class ufl.measure.MeasureSum(*measures)[source]¶
Bases:
object
Represents a sum of measures.
This is a notational intermediate object to translate the notation
f*(ds(1)+ds(3))
into
f*ds(1) + f*ds(3)
ufl.measureoperators module¶
ufl.objects module¶
Utility objects for pretty syntax in user code.
ufl.operators module¶
This module extends the form language with free function operators, which are either already available as member functions on UFL objects or defined as compound operators involving basic operations on the UFL objects.
- ufl.operators.And(left, right)[source]¶
UFL operator: A boolean expression (left and right) for use with
conditional
.
- ufl.operators.Dn(f)[source]¶
UFL operator: Take the directional derivative of f in the facet normal direction, Dn(f) := dot(grad(f), n).
- ufl.operators.Dt(f)[source]¶
UFL operator: <Not implemented yet!> The partial derivative of f with respect to time.
- ufl.operators.Dx(f, *i)[source]¶
UFL operator: Take the partial derivative of f with respect to spatial variable number i. Equivalent to
f.dx(*i)
.
- ufl.operators.Not(condition)[source]¶
UFL operator: A boolean expression (not condition) for use with
conditional
.
- ufl.operators.Or(left, right)[source]¶
UFL operator: A boolean expression (left or right) for use with
conditional
.
- ufl.operators.atan_2(f1, f2)[source]¶
UFL operator: Take the inverse tangent with two the arguments f1 and f2.
- ufl.operators.bessel_K(nu, f)[source]¶
UFL operator: irregular modified cylindrical Bessel function.
- ufl.operators.bessel_Y(nu, f)[source]¶
UFL operator: cylindrical Bessel function of the second kind.
- ufl.operators.conditional(condition, true_value, false_value)[source]¶
UFL operator: A conditional expression, taking the value of true_value when condition evaluates to
true
and false_value otherwise.
- ufl.operators.conjugate(f)¶
UFL operator: The complex conjugate of f
- ufl.operators.contraction(a, a_axes, b, b_axes)[source]¶
UFL operator: Take the contraction of a and b over given axes.
- ufl.operators.diag(A)[source]¶
UFL operator: Take the diagonal part of rank 2 tensor A or make a diagonal rank 2 tensor from a rank 1 tensor.
Always returns a rank 2 tensor. See also
diag_vector
.
- ufl.operators.diag_vector(A)[source]¶
UFL operator: Take the diagonal part of rank 2 tensor A and return as a vector.
See also
diag
.
- ufl.operators.diff(f, v)[source]¶
UFL operator: Take the derivative of f with respect to the variable v.
If f is a form,
diff
is applied to each integrand.
- ufl.operators.div(f)[source]¶
UFL operator: Take the divergence of f.
This operator follows the div convention where
div(v) = v[i].dx(i)
div(T)[:] = T[:,i].dx(i)
for vector expressions v, and arbitrary rank tensor expressions T.
See also:
nabla_div()
- ufl.operators.dot(a, b)[source]¶
UFL operator: Take the dot product of a and b. This won’t take the complex conjugate of the second argument.
- ufl.operators.elem_div(A, B)[source]¶
UFL operator: Take the elementwise division of tensors A and B with the same shape.
- ufl.operators.elem_mult(A, B)[source]¶
UFL operator: Take the elementwise multiplication of tensors A and B with the same shape.
- ufl.operators.elem_op(op, *args)[source]¶
UFL operator: Take the elementwise application of operator op on scalar values from one or more tensor arguments.
- ufl.operators.elem_pow(A, B)[source]¶
UFL operator: Take the elementwise power of tensors A and B with the same shape.
- ufl.operators.eq(left, right)[source]¶
UFL operator: A boolean expression (left == right) for use with
conditional
.
- ufl.operators.exterior_derivative(f)[source]¶
UFL operator: Take the exterior derivative of f.
The exterior derivative uses the element family to determine whether
id
,grad
,curl
ordiv
should be used.Note that this uses the
grad
anddiv
operators, as opposed tonabla_grad
andnabla_div
.
- ufl.operators.ge(left, right)[source]¶
UFL operator: A boolean expression (left >= right) for use with
conditional
.
- ufl.operators.grad(f)[source]¶
UFL operator: Take the gradient of f.
This operator follows the grad convention where
grad(s)[i] = s.dx(i)
grad(v)[i,j] = v[i].dx(j)
grad(T)[:,i] = T[:].dx(i)
for scalar expressions s, vector expressions v, and arbitrary rank tensor expressions T.
See also:
nabla_grad()
- ufl.operators.gt(left, right)[source]¶
UFL operator: A boolean expression (left > right) for use with
conditional
.
- ufl.operators.inner(a, b)[source]¶
UFL operator: Take the inner product of a and b. The complex conjugate of the second argument is taken.
- ufl.operators.le(left, right)[source]¶
UFL operator: A boolean expression (left <= right) for use with
conditional
.
- ufl.operators.lt(left, right)[source]¶
UFL operator: A boolean expression (left < right) for use with
conditional
.
- ufl.operators.nabla_div(f)[source]¶
UFL operator: Take the divergence of f.
This operator follows the div convention where
nabla_div(v) = v[i].dx(i)
nabla_div(T)[:] = T[i,:].dx(i)
for vector expressions v, and arbitrary rank tensor expressions T.
See also:
div()
- ufl.operators.nabla_grad(f)[source]¶
UFL operator: Take the gradient of f.
This operator follows the grad convention where
nabla_grad(s)[i] = s.dx(i)
nabla_grad(v)[i,j] = v[j].dx(i)
nabla_grad(T)[i,:] = T[:].dx(i)
for scalar expressions s, vector expressions v, and arbitrary rank tensor expressions T.
See also:
grad()
- ufl.operators.ne(left, right)[source]¶
UFL operator: A boolean expression (left != right) for use with
conditional
.
- ufl.operators.outer(*operands)[source]¶
UFL operator: Take the outer product of two or more operands. The complex conjugate of the first argument is taken.
- ufl.operators.rot(f)¶
UFL operator: Take the curl of f.
ufl.permutation module¶
This module provides utility functions for computing permutations and generating index lists.
- ufl.permutation.build_component_numbering(shape, symmetry)[source]¶
Build a numbering of components within the given value shape, taking into consideration a symmetry mapping which leaves the mapping noncontiguous. Returns a dict { component -> numbering } and an ordered list of components [ numbering -> component ]. The dict contains all components while the list only contains the ones not mapped by the symmetry mapping.
- ufl.permutation.compute_order_tuples(k, n)[source]¶
Compute all tuples of n integers such that the sum is k
- ufl.permutation.compute_permutation_pairs(j, k)[source]¶
Compute all permutations of j + k elements from (0, j + k) in rising order within (0, j) and (j, j + k) respectively.
ufl.precedence module¶
Precedence handling.
- ufl.precedence.assign_precedences(precedence_list)[source]¶
Given a precedence list, assign ints to class._precedence.
ufl.protocols module¶
ufl.referencevalue module¶
Representation of the reference value of a function.
- class ufl.referencevalue.ReferenceValue(f)[source]¶
Bases:
Operator
Representation of the reference cell value of a form argument.
- evaluate(x, mapping, component, index_values, derivatives=())[source]¶
Get child from mapping and return the component asked for.
- ufl_free_indices = ()¶
- ufl_index_dimensions = ()¶
- property ufl_shape¶
ufl.restriction module¶
Restriction operations.
- class ufl.restriction.NegativeRestricted(f)[source]¶
Bases:
Restricted
- class ufl.restriction.PositiveRestricted(f)[source]¶
Bases:
Restricted
ufl.sobolevspace module¶
This module defines a symbolic heirarchy of Sobolev spaces to enable symbolic reasoning about the spaces in which finite elements lie.
- class ufl.sobolevspace.DirectionalSobolevSpace(orders)[source]¶
Bases:
SobolevSpace
Symbolic representation of a Sobolev space with varying smoothness in differerent spatial directions.
ufl.sorting module¶
This module contains a sorting rule for expr objects that is more robust w.r.t. argument numbering than using repr.
- ufl.sorting.cmp_expr(a, b)[source]¶
Replacement for cmp(a, b), removed in Python 3, for Expr objects.
ufl.split_functions module¶
Algorithm for splitting a Coefficient or Argument into subfunctions.
ufl.tensoralgebra module¶
Compound tensor algebra operations.
- class ufl.tensoralgebra.Cofactor(A)[source]¶
Bases:
CompoundTensorOperator
- ufl_free_indices = ()¶
- ufl_index_dimensions = ()¶
- property ufl_shape¶
-
class ufl.tensoralgebra.