ufl Package¶
ufl
Package¶
The Unified Form Language is an embedded domain specific language for definition of variational forms intended for finite element discretization. More precisely, it defines a fixed interface for choosing finite element spaces and defining expressions for weak forms in a notation close to mathematical notation.
This Python module contains the language as well as algorithms to work with it.
To import the language, type:
from ufl import *
To import the underlying classes an UFL expression tree is built from, type:
from ufl.classes import *
Various algorithms for working with UFL expression trees can be found in:
from ufl.algorithms import *
The classes and algorithms are considered implementation details and should not be used in form definitions.
For more details on the language, see
and
The development version can be found in the repository at
A very brief overview of the language contents follows:
Domains:
Domain, ProductDomain
Cells:
Cell, ProductCell, OuterProductCell, interval, triangle, tetrahedron, quadrilateral, hexahedron, cell2D, cell3D,
Sobolev spaces:
L2, H1, H2, HDiv, HCurl
Elements:
FiniteElement, MixedElement, VectorElement, TensorElement EnrichedElement, RestrictedElement, TensorProductElement, OuterProductElement, OuterProductVectorElement, HDiv, HCurl
Arguments:
Argument, TestFunction, TrialFunction
Coefficients:
Coefficient, Constant, VectorConstant, TensorConstant
Splitting form arguments in mixed spaces:
split
Literal constants:
Identity, PermutationSymbol
Geometric quantities:
SpatialCoordinate, FacetNormal, CellNormal, CellVolume, Circumradius, MinCellEdgeLength, MaxCellEdgeLength, FacetArea, MinFacetEdgeLength, MaxFacetEdgeLength,
Indices:
Index, indices, i, j, k, l, p, q, r, s
Scalar to tensor expression conversion:
as_tensor, as_vector, as_matrix
Unit vectors and matrices:
unit_vector, unit_vectors, unit_matrix, unit_matrices
Tensor algebra operators:
outer, inner, dot, cross, perp, det, inv, cofac, transpose, tr, diag, diag_vector, dev, skew, sym
Elementwise tensor operators:
elem_mult, elem_div, elem_pow, elem_op
Differential operators:
variable, diff, grad, div, nabla_grad, nabla_div, Dx, Dn, curl, rot
Nonlinear functions:
max_value, min_value, abs, sign, sqrt, exp, ln, erf, cos, sin, tan, acos, asin, atan, atan_2, cosh, sinh, tanh, bessel_J, bessel_Y, bessel_I, bessel_K
- Discontinuous Galerkin operators:
jump, avg, v(‘+’), v(‘-‘), cell_avg, facet_avg
Conditional operators:
eq, ne, le, ge, lt, gt, <, >, <=, >=, And, Or, Not, conditional
Integral measures:
dx, ds, ds_b, ds_t, ds_tb, ds_v, dS, dS_h, dS_v, dP, dc, dE
Form transformations:
rhs, lhs, system, functional, replace, replace_integral_domains, adjoint, action, energy_norm, sensitivity_rhs, derivative
algebra
Module¶
Basic algebra operations.
-
class
ufl.algebra.
Abs
(a)¶ Bases:
ufl.core.operator.Operator
-
evaluate
(x, mapping, component, index_values)¶
-
free_indices
()¶
-
index_dimensions
()¶
-
shape
()¶
-
ufl_free_indices
¶
-
ufl_index_dimensions
¶
-
ufl_shape
¶
-
-
class
ufl.algebra.
Division
(a, b)¶ Bases:
ufl.core.operator.Operator
-
evaluate
(x, mapping, component, index_values)¶
-
free_indices
()¶
-
index_dimensions
()¶
-
ufl_free_indices
¶
-
ufl_index_dimensions
¶
-
ufl_shape
= ()¶
-
-
class
ufl.algebra.
Power
(a, b)¶ Bases:
ufl.core.operator.Operator
-
evaluate
(x, mapping, component, index_values)¶
-
free_indices
()¶
-
index_dimensions
()¶
-
ufl_free_indices
¶
-
ufl_index_dimensions
¶
-
ufl_shape
= ()¶
-
argument
Module¶
This module defines the class Argument and a number of related classes (functions), including TestFunction and TrialFunction.
-
class
ufl.argument.
Argument
(element, number, part=None)¶ Bases:
ufl.core.terminal.FormArgument
UFL value: Representation of an argument to a form.
-
count
()¶
-
domains
()¶ Return tuple of domains related to this terminal object.
-
element
()¶
-
is_cellwise_constant
()¶ Return whether this expression is spatially constant over each cell.
-
number
()¶
-
part
()¶
-
reconstruct
(element=None, number=None, part=None)¶
-
signature_data
(renumbering)¶ Signature data for form arguments depend on the global numbering of the form arguments and domains.
-
ufl_shape
¶
-
-
ufl.argument.
Arguments
(element, number)¶ UFL value: Create an Argument in a mixed space, and return a tuple with the function components corresponding to the subelements.
-
ufl.argument.
TestFunction
(element, part=None)¶ UFL value: Create a test function argument to a form.
-
ufl.argument.
TestFunctions
(element)¶ UFL value: Create a TestFunction in a mixed space, and return a tuple with the function components corresponding to the subelements.
-
ufl.argument.
TrialFunction
(element, part=None)¶ UFL value: Create a trial function argument to a form.
-
ufl.argument.
TrialFunctions
(element)¶ UFL value: Create a TrialFunction in a mixed space, and return a tuple with the function components corresponding to the subelements.
assertions
Module¶
This module provides assertion functions used by the UFL implementation.
-
ufl.assertions.
expecting_expr
(v)¶
-
ufl.assertions.
expecting_instance
(v, c)¶
-
ufl.assertions.
expecting_python_scalar
(v)¶
-
ufl.assertions.
expecting_terminal
(v)¶
-
ufl.assertions.
expecting_true_ufl_scalar
(v)¶
-
ufl.assertions.
ufl_assert
(condition, *message)¶ Assert that condition is true and otherwise issue an error with given message.
cell
Module¶
Types for representing a cell.
-
class
ufl.cell.
Cell
(cellname, geometric_dimension=None, topological_dimension=None)¶ Bases:
object
Representation of a finite element cell.
Initialize basic cell description.
-
cellname
()¶ Return the cellname of the cell.
-
circumradius
¶ UFL geometry value. Deprecated, please use the constructor types instead.
-
d
¶ The dimension of the cell.
Only valid if the geometric and topological dimensions are the same.
-
facet_area
¶ UFL geometry value. Deprecated, please use the constructor types instead.
-
facet_cellname
()¶ Return the cellname of the facet of this cell, or None if not available.
-
geometric_dimension
()¶ Return the dimension of the space this cell is embedded in.
-
n
¶ UFL geometry value. Deprecated, please use the constructor types instead.
-
num_edges
()¶ The number of cell edges.
-
num_entities
(dim=None)¶ The number of cell entities of given topological dimension.
-
num_facet_edges
()¶ The number of facet edges, or None if not available.
-
num_facet_entities
(dim)¶ Return the number of cell entities of given topological dimension, or None if not available.
-
num_facet_vertices
()¶ The number of cell vertices, or None if not available.
-
num_facets
()¶ The number of cell facets.
-
num_vertices
()¶ The number of cell vertices.
-
reference_facet_volume
()¶ The volume of a reference cell of the same type.
-
reference_volume
()¶ The volume of a reference cell of the same type.
-
topological_dimension
()¶ Return the dimension of the topology of this cell.
-
volume
¶ UFL geometry value. Deprecated, please use the constructor types instead.
-
x
¶ UFL geometry value. Deprecated, please use the constructor types instead.
-
-
class
ufl.cell.
OuterProductCell
(A, B)¶ Bases:
ufl.cell.Cell
Representation of a cell formed as the Cartesian product of two existing cells
-
facet_horiz
¶
-
facet_vert
¶
-
num_entities
(dim)¶ The number of cell entities of given topological dimension.
-
reference_volume
()¶ The volume of a reference cell of the same type.
-
-
class
ufl.cell.
ProductCell
(*cells)¶ Bases:
ufl.cell.Cell
-
sub_cells
()¶ Return list of cell factors.
-
-
ufl.cell.
as_cell
(cell)¶ Convert any valid object to a Cell (in particular, cellname string), or return cell if it is already a Cell.
-
ufl.cell.
cell2dim
(cell)¶ Maps from UFL cell or cell name to topological dimension
checks
Module¶
Utility functions for checking properties of expressions.
-
ufl.checks.
is_globally_constant
(expr)¶ 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)¶ Return True iff expression is of a Python scalar type.
-
ufl.checks.
is_scalar_constant_expression
(expr)¶ Check if an expression is a globally constant scalar expression.
-
ufl.checks.
is_true_ufl_scalar
(expression)¶ Return True iff expression is scalar-valued, with no free indices.
-
ufl.checks.
is_ufl_scalar
(expression)¶ Return True iff expression is scalar-valued, but possibly containing free indices.
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.
Expr
¶ Bases:
object
Base class for all UFL expression types.
- Instance properties
- Every expression instance will have certain properties.
Most important are the
ufl_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 the
ufl_type
class decorator, allowing UFL to do some consistency checks and automate most of the traits for most types. The type traits are accessed via a class or instance object on the form obj._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.
-
T
¶ Transposed a rank two tensor expression. For more general transpose operations of higher order tensor expressions, use indexing and Tensor.
-
cell
()¶ Return the cell this expression is defined on.
-
domain
()¶ Return the single unique domain this expression is defined on or throw an error.
-
domains
()¶
-
dx
(*ii)¶ Return the partial derivative with respect to spatial variable number i.
-
evaluate
(x, mapping, component, index_values)¶ Evaluate expression at given coordinate with given values for terminals.
-
free_indices
()¶ Return a tuple with the free indices (unassigned) of the expression.
-
geometric_dimension
()¶ Return the geometric dimension this expression lives in.
-
index_dimensions
()¶ Return a dict with the free or repeated indices in the expression as keys and the dimensions of those indices as values.
-
is_cellwise_constant
()¶ Return whether this expression is spatially constant over each cell.
-
operands
()¶ Return a sequence with all subtree nodes in expression tree.
-
rank
()¶ Return the tensor rank of the expression.
-
reconstruct
(*operands)¶ Return a new object of the same type with new operands.
-
shape
()¶ Return the tensor shape of the expression.
-
signature_data
()¶ Return data that uniquely identifies form compiler relevant aspects of this object.
-
static
ufl_disable_profiling
()¶ Turn off object counting mechanism. Returns object init and del counts.
-
static
ufl_enable_profiling
()¶ Turn on object counting mechanism and reset counts to zero.
-
class
ufl.classes.
Terminal
¶ Bases:
ufl.core.expr.Expr
A terminal node in the UFL expression tree.
-
domains
()¶ Return tuple of domains related to this terminal object.
-
evaluate
(x, mapping, component, index_values, derivatives=())¶ Get self from mapping and return the component asked for.
-
free_indices
()¶ A Terminal object never has free indices.
-
index_dimensions
()¶ A Terminal object never has free indices.
-
operands
()¶ A Terminal object never has operands.
-
reconstruct
(*operands)¶ Return self.
-
signature_data
(renumbering)¶ Default signature data for of terminals just return the repr string.
-
ufl_free_indices
= ()¶
-
ufl_index_dimensions
= ()¶
-
ufl_operands
= ()¶
-
-
class
ufl.classes.
FormArgument
¶ Bases:
ufl.core.terminal.Terminal
-
class
ufl.classes.
GeometricQuantity
(domain)¶ Bases:
ufl.core.terminal.Terminal
-
domains
()¶
-
is_cellwise_constant
()¶ Return whether this expression is spatially constant over each cell (or over each facet for facet quantities).
-
signature_data
(renumbering)¶ Signature data of geometric quantities depend on the domain numbering.
-
ufl_shape
= ()¶
-
-
class
ufl.classes.
GeometricCellQuantity
(domain)¶
-
class
ufl.classes.
GeometricFacetQuantity
(domain)¶
-
class
ufl.classes.
SpatialCoordinate
(domain)¶ Bases:
ufl.geometry.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.
-
evaluate
(x, mapping, component, index_values)¶
-
is_cellwise_constant
()¶ Return whether this expression is spatially constant over each cell.
-
name
= 'x'¶
-
ufl_shape
¶
-
-
class
ufl.classes.
CellCoordinate
(domain)¶ Bases:
ufl.geometry.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
()¶ Return whether this expression is spatially constant over each cell.
-
name
= 'X'¶
-
ufl_shape
¶
-
-
class
ufl.classes.
FacetCoordinate
(domain)¶ Bases:
ufl.geometry.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
()¶ Return whether this expression is spatially constant over each cell.
-
name
= 'Xf'¶
-
ufl_shape
¶
-
-
class
ufl.classes.
CellOrigin
(domain)¶ Bases:
ufl.geometry.GeometricCellQuantity
UFL geometry representation: The spatial coordinate corresponding to origin of a reference cell.
-
is_cellwise_constant
()¶
-
name
= 'x0'¶
-
ufl_shape
¶
-
-
class
ufl.classes.
FacetOrigin
(domain)¶ Bases:
ufl.geometry.GeometricFacetQuantity
UFL geometry representation: The spatial coordinate corresponding to origin of a reference facet.
-
name
= 'x0f'¶
-
ufl_shape
¶
-
-
class
ufl.classes.
CellFacetOrigin
(domain)¶ Bases:
ufl.geometry.GeometricFacetQuantity
UFL geometry representation: The reference cell coordinate corresponding to origin of a reference facet.
-
name
= 'X0f'¶
-
ufl_shape
¶
-
-
class
ufl.classes.
Jacobian
(domain)¶ Bases:
ufl.geometry.GeometricCellQuantity
UFL geometry representation: The Jacobian of the mapping from reference cell to spatial coordinates.
J_ij = dx_i/dX_j
-
is_cellwise_constant
()¶ Return whether this expression is spatially constant over each cell.
-
name
= 'J'¶
-
ufl_shape
¶
-
-
class
ufl.classes.
FacetJacobian
(domain)¶ Bases:
ufl.geometry.GeometricFacetQuantity
UFL geometry representation: The Jacobian of the mapping from reference facet to spatial coordinates.
FJ_ij = dx_i/dXf_jThe FacetJacobian is the product of the Jacobian and CellFacetJacobian:
FJ = dx/dXf = dx/dX dX/dXf = J * CFJ-
is_cellwise_constant
()¶ Return whether this expression is spatially constant over each cell.
-
name
= 'FJ'¶
-
ufl_shape
¶
-
-
class
ufl.classes.
CellFacetJacobian
(domain)¶ Bases:
ufl.geometry.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
()¶ Return whether this expression is spatially constant over each cell.
-
name
= 'CFJ'¶
-
ufl_shape
¶
-
-
class
ufl.classes.
CellEdgeVectors
(domain)¶ Bases:
ufl.geometry.GeometricCellQuantity
UFL geometry representation: The vectors between reference cell vertices for each edge in cell.
-
is_cellwise_constant
()¶ Return whether this expression is spatially constant over each cell.
-
name
= 'CEV'¶
-
ufl_shape
¶
-
-
class
ufl.classes.
FacetEdgeVectors
(domain)¶ Bases:
ufl.geometry.GeometricFacetQuantity
UFL geometry representation: The vectors between reference cell vertices for each edge in current facet.
-
is_cellwise_constant
()¶ Return whether this expression is spatially constant over each cell.
-
name
= 'FEV'¶
-
ufl_shape
¶
-
-
class
ufl.classes.
JacobianDeterminant
(domain)¶ Bases:
ufl.geometry.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
()¶ Return whether this expression is spatially constant over each cell.
-
name
= 'detJ'¶
-
-
class
ufl.classes.
FacetJacobianDeterminant
(domain)¶ Bases:
ufl.geometry.GeometricFacetQuantity
UFL geometry representation: The pseudo-determinant of the FacetJacobian.
-
is_cellwise_constant
()¶ Return whether this expression is spatially constant over each cell.
-
name
= 'detFJ'¶
-
-
class
ufl.classes.
CellFacetJacobianDeterminant
(domain)¶ Bases:
ufl.geometry.GeometricFacetQuantity
UFL geometry representation: The pseudo-determinant of the CellFacetJacobian.
-
is_cellwise_constant
()¶ Return whether this expression is spatially constant over each cell.
-
name
= 'detCFJ'¶
-
-
class
ufl.classes.
JacobianInverse
(domain)¶ Bases:
ufl.geometry.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
()¶ Return whether this expression is spatially constant over each cell.
-
name
= 'K'¶
-
ufl_shape
¶
-
-
class
ufl.classes.
FacetJacobianInverse
(domain)¶ Bases:
ufl.geometry.GeometricFacetQuantity
UFL geometry representation: The pseudo-inverse of the FacetJacobian.
-
is_cellwise_constant
()¶ Return whether this expression is spatially constant over each cell.
-
name
= 'FK'¶
-
ufl_shape
¶
-
-
class
ufl.classes.
CellFacetJacobianInverse
(domain)¶ Bases:
ufl.geometry.GeometricFacetQuantity
UFL geometry representation: The pseudo-inverse of the CellFacetJacobian.
-
is_cellwise_constant
()¶ Return whether this expression is spatially constant over each cell.
-
name
= 'CFK'¶
-
ufl_shape
¶
-
-
class
ufl.classes.
FacetNormal
(domain)¶ Bases:
ufl.geometry.GeometricFacetQuantity
UFL geometry representation: The outwards pointing normal vector of the current facet.
-
is_cellwise_constant
()¶ Return whether this expression is spatially constant over each cell.
-
name
= 'n'¶
-
ufl_shape
¶
-
-
class
ufl.classes.
CellNormal
(domain)¶ Bases:
ufl.geometry.GeometricCellQuantity
UFL geometry representation: The upwards pointing normal vector of the current manifold cell.
-
name
= 'cell_normal'¶
-
ufl_shape
¶
-
-
class
ufl.classes.
CellVolume
(domain)¶ Bases:
ufl.geometry.GeometricCellQuantity
UFL geometry representation: The volume of the cell.
-
name
= 'volume'¶
-
-
class
ufl.classes.
Circumradius
(domain)¶ Bases:
ufl.geometry.GeometricCellQuantity
UFL geometry representation: The circumradius of the cell.
-
name
= 'circumradius'¶
-
-
class
ufl.classes.
FacetArea
(domain)¶ Bases:
ufl.geometry.GeometricFacetQuantity
UFL geometry representation: The area of the facet.
-
name
= 'facetarea'¶
-
-
class
ufl.classes.
MinCellEdgeLength
(domain)¶ Bases:
ufl.geometry.GeometricCellQuantity
UFL geometry representation: The minimum edge length of the cell.
-
name
= 'mincelledgelength'¶
-
-
class
ufl.classes.
MaxCellEdgeLength
(domain)¶ Bases:
ufl.geometry.GeometricCellQuantity
UFL geometry representation: The maximum edge length of the cell.
-
name
= 'maxcelledgelength'¶
-
-
class
ufl.classes.
MinFacetEdgeLength
(domain)¶ Bases:
ufl.geometry.GeometricFacetQuantity
UFL geometry representation: The minimum edge length of the facet.
-
name
= 'minfacetedgelength'¶
-
-
class
ufl.classes.
MaxFacetEdgeLength
(domain)¶ Bases:
ufl.geometry.GeometricFacetQuantity
UFL geometry representation: The maximum edge length of the facet.
-
name
= 'maxfacetedgelength'¶
-
-
class
ufl.classes.
CellOrientation
(domain)¶ Bases:
ufl.geometry.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.
FacetOrientation
(domain)¶ Bases:
ufl.geometry.GeometricFacetQuantity
UFL geometry representation: The orientation (+1/-1) of the current facet relative to the reference cell.
-
name
= 'facet_orientation'¶
-
-
class
ufl.classes.
QuadratureWeight
(domain)¶ Bases:
ufl.geometry.GeometricQuantity
UFL geometry representation: The current quadrature weight.
Only used inside a quadrature context.
-
is_cellwise_constant
()¶ Return whether this expression is spatially constant over each cell.
-
name
= 'weight'¶
-
-
class
ufl.classes.
MultiIndex
(indices)¶ Bases:
ufl.core.terminal.Terminal
Represents a sequence of indices, either fixed or free.
-
domains
()¶ Return tuple of domains related to this terminal object.
-
evaluate
(x, mapping, component, index_values)¶
-
indices
()¶
-
is_cellwise_constant
()¶
-
ufl_free_indices
¶
-
ufl_index_dimensions
¶
-
ufl_shape
¶
-
-
class
ufl.classes.
Operator
(operands=None)¶ Bases:
ufl.core.expr.Expr
-
free_indices
()¶ Intermediate helper property getter to transition from .free_indices() to .ufl_free_indices.
-
index_dimensions
()¶ Intermediate helper property getter to transition from .index_dimensions() to .ufl_index_dimensions.
-
is_cellwise_constant
()¶ Return whether this expression is spatially constant over each cell.
-
operands
()¶
-
reconstruct
(*operands)¶ Return a new object of the same type with new operands.
-
signature_data
()¶
-
ufl_operands
¶
-
-
class
ufl.classes.
ConstantValue
¶ Bases:
ufl.core.terminal.Terminal
-
domains
()¶ Return tuple of domains related to this terminal object.
-
is_cellwise_constant
()¶ Return whether this expression is spatially constant over each cell.
-
-
class
ufl.classes.
Zero
(shape=(), free_indices=(), index_dimensions=None)¶ Bases:
ufl.constantvalue.ConstantValue
UFL literal type: Representation of a zero valued expression.
-
evaluate
(x, mapping, component, index_values)¶
-
free_indices
()¶ Intermediate helper property getter to transition from .free_indices() to .ufl_free_indices.
-
index_dimensions
()¶ Intermediate helper property getter to transition from .index_dimensions() to .ufl_index_dimensions.
-
reconstruct
(free_indices=None)¶
-
ufl_free_indices
¶
-
ufl_index_dimensions
¶
-
ufl_shape
¶
-
-
class
ufl.classes.
ScalarValue
(value)¶ Bases:
ufl.constantvalue.ConstantValue
A constant scalar value.
-
evaluate
(x, mapping, component, index_values)¶
-
free_indices
()¶
-
index_dimensions
()¶
-
shape
()¶
-
ufl_free_indices
= ()¶
-
ufl_index_dimensions
= ()¶
-
ufl_shape
= ()¶
-
value
()¶
-
-
class
ufl.classes.
FloatValue
(value)¶ Bases:
ufl.constantvalue.ScalarValue
UFL literal type: Representation of a constant scalar floating point value.
-
class
ufl.classes.
IntValue
(value)¶ Bases:
ufl.constantvalue.ScalarValue
UFL literal type: Representation of a constant scalar integer value.
-
class
ufl.classes.
Identity
(dim)¶ Bases:
ufl.constantvalue.ConstantValue
UFL literal type: Representation of an identity matrix.
-
evaluate
(x, mapping, component, index_values)¶
-
ufl_shape
¶
-
-
class
ufl.classes.
PermutationSymbol
(dim)¶ Bases:
ufl.constantvalue.ConstantValue
UFL literal type: Representation of a permutation symbol.
This is also known as the Levi-Civita symbol, antisymmetric symbol, or alternating symbol.
-
evaluate
(x, mapping, component, index_values)¶
-
ufl_shape
¶
-
-
class
ufl.classes.
Indexed
(expression, multiindex)¶ Bases:
ufl.core.operator.Operator
-
evaluate
(x, mapping, component, index_values, derivatives=())¶
-
is_cellwise_constant
()¶ Return whether this expression is spatially constant over each cell.
-
ufl_free_indices
¶
-
ufl_index_dimensions
¶
-
ufl_shape
= ()¶
-
-
class
ufl.classes.
ListTensor
(*expressions)¶ Bases:
ufl.core.operator.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=())¶
-
free_indices
()¶
-
index_dimensions
()¶
-
is_cellwise_constant
()¶ Return whether this expression is spatially constant over each cell.
-
ufl_free_indices
¶
-
ufl_index_dimensions
¶
-
ufl_shape
¶
-
-
class
ufl.classes.
ComponentTensor
(expression, indices)¶ Bases:
ufl.core.operator.Operator
UFL operator type: Maps the free indices of a scalar valued expression to tensor axes.
-
evaluate
(x, mapping, component, index_values)¶
-
indices
()¶
-
is_cellwise_constant
()¶ Return whether this expression is spatially constant over each cell.
-
reconstruct
(expressions, indices)¶
-
ufl_free_indices
¶
-
ufl_index_dimensions
¶
-
ufl_shape
¶
-
-
class
ufl.classes.
Argument
(element, number, part=None)¶ Bases:
ufl.core.terminal.FormArgument
UFL value: Representation of an argument to a form.
-
count
()¶
-
domains
()¶ Return tuple of domains related to this terminal object.
-
element
()¶
-
is_cellwise_constant
()¶ Return whether this expression is spatially constant over each cell.
-
number
()¶
-
part
()¶
-
reconstruct
(element=None, number=None, part=None)¶
-
signature_data
(renumbering)¶ Signature data for form arguments depend on the global numbering of the form arguments and domains.
-
ufl_shape
¶
-
-
class
ufl.classes.
Coefficient
(element, count=None)¶ Bases:
ufl.core.terminal.FormArgument
UFL form argument type: Representation of a form coefficient.
-
count
()¶
-
domains
()¶ Return tuple of domains related to this terminal object.
-
element
()¶
-
is_cellwise_constant
()¶ Return whether this expression is spatially constant over each cell.
-
reconstruct
(element=None, count=None)¶
-
signature_data
(renumbering)¶ Signature data for form arguments depend on the global numbering of the form arguments and domains.
-
ufl_shape
¶
-
-
class
ufl.classes.
Label
(count=None)¶ Bases:
ufl.core.terminal.Terminal
-
count
()¶
-
domains
()¶ Return tuple of domains related to this terminal object.
-
is_cellwise_constant
()¶
-
ufl_free_indices
¶
-
ufl_index_dimensions
¶
-
ufl_shape
¶
-
-
class
ufl.classes.
Variable
(expression, label=None)¶ Bases:
ufl.core.operator.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)
-
domains
()¶
-
evaluate
(x, mapping, component, index_values)¶
-
expression
()¶
-
free_indices
()¶
-
index_dimensions
()¶
-
is_cellwise_constant
()¶
-
label
()¶
-
shape
()¶
-
ufl_free_indices
= ()¶
-
ufl_index_dimensions
= ()¶
-
ufl_shape
¶
-
-
class
ufl.classes.
Sum
(a, b)¶ Bases:
ufl.core.operator.Operator
-
evaluate
(x, mapping, component, index_values)¶
-
free_indices
()¶
-
index_dimensions
()¶
-
shape
()¶
-
ufl_free_indices
¶
-
ufl_index_dimensions
¶
-
ufl_shape
¶
-
-
class
ufl.classes.
Product
(a, b)¶ Bases:
ufl.core.operator.Operator
The product of two or more UFL objects.
-
evaluate
(x, mapping, component, index_values)¶
-
ufl_free_indices
¶
-
ufl_index_dimensions
¶
-
ufl_shape
= ()¶
-
-
class
ufl.classes.
Division
(a, b)¶ Bases:
ufl.core.operator.Operator
-
evaluate
(x, mapping, component, index_values)¶
-
free_indices
()¶
-
index_dimensions
()¶
-
ufl_free_indices
¶
-
ufl_index_dimensions
¶
-
ufl_shape
= ()¶
-
-
class
ufl.classes.
Power
(a, b)¶ Bases:
ufl.core.operator.Operator
-
evaluate
(x, mapping, component, index_values)¶
-
free_indices
()¶
-
index_dimensions
()¶
-
ufl_free_indices
¶
-
ufl_index_dimensions
¶
-
ufl_shape
= ()¶
-
-
class
ufl.classes.
Abs
(a)¶ Bases:
ufl.core.operator.Operator
-
evaluate
(x, mapping, component, index_values)¶
-
free_indices
()¶
-
index_dimensions
()¶
-
shape
()¶
-
ufl_free_indices
¶
-
ufl_index_dimensions
¶
-
ufl_shape
¶
-
-
class
ufl.classes.
CompoundTensorOperator
(operands)¶ Bases:
ufl.core.operator.Operator
-
class
ufl.classes.
Transposed
(A)¶ Bases:
ufl.tensoralgebra.CompoundTensorOperator
-
free_indices
()¶
-
index_dimensions
()¶
-
ufl_free_indices
¶
-
ufl_index_dimensions
¶
-
ufl_shape
¶
-
-
class
ufl.classes.
Outer
(a, b)¶ Bases:
ufl.tensoralgebra.CompoundTensorOperator
-
ufl_free_indices
¶
-
ufl_index_dimensions
¶
-
ufl_shape
¶
-
-
class
ufl.classes.
Inner
(a, b)¶ Bases:
ufl.tensoralgebra.CompoundTensorOperator
-
ufl_free_indices
¶
-
ufl_index_dimensions
¶
-
ufl_shape
= ()¶
-
-
class
ufl.classes.
Dot
(a, b)¶ Bases:
ufl.tensoralgebra.CompoundTensorOperator
-
ufl_free_indices
¶
-
ufl_index_dimensions
¶
-
ufl_shape
¶
-
-
class
ufl.classes.
Cross
(a, b)¶ Bases:
ufl.tensoralgebra.CompoundTensorOperator
-
ufl_free_indices
¶
-
ufl_index_dimensions
¶
-
ufl_shape
= (3,)¶
-
-
class
ufl.classes.
Trace
(A)¶ Bases:
ufl.tensoralgebra.CompoundTensorOperator
-
free_indices
()¶
-
index_dimensions
()¶
-
ufl_free_indices
¶
-
ufl_index_dimensions
¶
-
ufl_shape
= ()¶
-
-
class
ufl.classes.
Determinant
(A)¶ Bases:
ufl.tensoralgebra.CompoundTensorOperator
-
free_indices
()¶
-
index_dimensions
()¶
-
shape
()¶
-
ufl_free_indices
= ()¶
-
ufl_index_dimensions
= ()¶
-
ufl_shape
= ()¶
-
-
class
ufl.classes.
Inverse
(A)¶ Bases:
ufl.tensoralgebra.CompoundTensorOperator
-
free_indices
()¶
-
index_dimensions
()¶
-
ufl_free_indices
= ()¶
-
ufl_index_dimensions
= ()¶
-
ufl_shape
¶
-
-
class
ufl.classes.
Cofactor
(A)¶ Bases:
ufl.tensoralgebra.CompoundTensorOperator
-
free_indices
()¶
-
index_dimensions
()¶
-
ufl_free_indices
= ()¶
-
ufl_index_dimensions
= ()¶
-
ufl_shape
¶
-
-
class
ufl.classes.
Deviatoric
(A)¶ Bases:
ufl.tensoralgebra.CompoundTensorOperator
-
free_indices
()¶
-
index_dimensions
()¶
-
shape
()¶
-
ufl_free_indices
¶
-
ufl_index_dimensions
¶
-
ufl_shape
¶
-
-
class
ufl.classes.
Skew
(A)¶ Bases:
ufl.tensoralgebra.CompoundTensorOperator
-
free_indices
()¶
-
index_dimensions
()¶
-
shape
()¶
-
ufl_free_indices
¶
-
ufl_index_dimensions
¶
-
ufl_shape
¶
-
-
class
ufl.classes.
Sym
(A)¶ Bases:
ufl.tensoralgebra.CompoundTensorOperator
-
free_indices
()¶
-
index_dimensions
()¶
-
shape
()¶
-
ufl_free_indices
¶
-
ufl_index_dimensions
¶
-
ufl_shape
¶
-
-
class
ufl.classes.
IndexSum
(summand, index)¶ Bases:
ufl.core.operator.Operator
-
dimension
()¶
-
evaluate
(x, mapping, component, index_values)¶
-
index
()¶
-
is_cellwise_constant
()¶ Return whether this expression is spatially constant over each cell.
-
ufl_free_indices
¶
-
ufl_index_dimensions
¶
-
ufl_shape
¶
-
-
class
ufl.classes.
Restricted
(f, side)¶ Bases:
ufl.core.operator.Operator
-
evaluate
(x, mapping, component, index_values)¶
-
free_indices
()¶
-
index_dimensions
()¶
-
shape
()¶
-
side
()¶
-
ufl_free_indices
¶
-
ufl_index_dimensions
¶
-
ufl_shape
¶
-
-
class
ufl.classes.
PositiveRestricted
(f)¶ Bases:
ufl.restriction.Restricted
-
class
ufl.classes.
NegativeRestricted
(f)¶ Bases:
ufl.restriction.Restricted
-
class
ufl.classes.
CellAvg
(f)¶ Bases:
ufl.core.operator.Operator
-
evaluate
(x, mapping, component, index_values)¶ Performs an approximate symbolic evaluation, since we dont have a cell.
-
free_indices
()¶
-
index_dimensions
()¶
-
ufl_free_indices
= ()¶
-
ufl_index_dimensions
= ()¶
-
ufl_shape
¶
-
-
class
ufl.classes.
FacetAvg
(f)¶ Bases:
ufl.core.operator.Operator
-
evaluate
(x, mapping, component, index_values)¶ Performs an approximate symbolic evaluation, since we dont have a cell.
-
free_indices
()¶
-
index_dimensions
()¶
-
ufl_free_indices
= ()¶
-
ufl_index_dimensions
= ()¶
-
ufl_shape
¶
-
-
class
ufl.classes.
ExprList
(*operands)¶ Bases:
ufl.core.operator.Operator
List of Expr objects. For internal use, never to be created by end users.
-
free_indices
()¶
-
index_dimensions
()¶
-
ufl_free_indices
¶
-
ufl_index_dimensions
¶
-
ufl_shape
¶
-
-
class
ufl.classes.
ExprMapping
(*operands)¶ Bases:
ufl.core.operator.Operator
Mapping of Expr objects. For internal use, never to be created by end users.
-
domains
()¶
-
free_indices
()¶
-
index_dimensions
()¶
-
ufl_free_indices
¶
-
ufl_index_dimensions
¶
-
ufl_shape
¶
-
-
class
ufl.classes.
Derivative
(operands)¶ Bases:
ufl.core.operator.Operator
Base class for all derivative types.
-
class
ufl.classes.
CoefficientDerivative
(integrand, coefficients, arguments, coefficient_derivatives)¶ Bases:
ufl.differentiation.Derivative
Derivative of the integrand of a form w.r.t. the degrees of freedom in a discrete Coefficient.
-
free_indices
()¶
-
index_dimensions
()¶
-
shape
()¶
-
ufl_free_indices
¶
-
ufl_index_dimensions
¶
-
ufl_shape
¶
-
-
class
ufl.classes.
VariableDerivative
(f, v)¶ Bases:
ufl.differentiation.Derivative
-
ufl_free_indices
¶
-
ufl_index_dimensions
¶
-
ufl_shape
¶
-
-
class
ufl.classes.
CompoundDerivative
(operands)¶ Bases:
ufl.differentiation.Derivative
Base class for all compound derivative types.
-
class
ufl.classes.
Grad
(f)¶ Bases:
ufl.differentiation.CompoundDerivative
-
evaluate
(x, mapping, component, index_values, derivatives=())¶ Get child from mapping and return the component asked for.
-
free_indices
()¶
-
index_dimensions
()¶
-
reconstruct
(op)¶ Return a new object of the same type with new operands.
-
ufl_free_indices
¶
-
ufl_index_dimensions
¶
-
ufl_shape
¶
-
-
class
ufl.classes.
ReferenceGrad
(f)¶ Bases:
ufl.differentiation.CompoundDerivative
-
evaluate
(x, mapping, component, index_values, derivatives=())¶ Get child from mapping and return the component asked for.
-
free_indices
()¶
-
index_dimensions
()¶
-
reconstruct
(op)¶ Return a new object of the same type with new operands.
-
ufl_free_indices
¶
-
ufl_index_dimensions
¶
-
ufl_shape
¶
-
-
class
ufl.classes.
Div
(f)¶ Bases:
ufl.differentiation.CompoundDerivative
-
free_indices
()¶
-
index_dimensions
()¶
-
ufl_free_indices
¶
-
ufl_index_dimensions
¶
-
ufl_shape
¶
-
-
class
ufl.classes.
NablaGrad
(f)¶ Bases:
ufl.differentiation.CompoundDerivative
-
free_indices
()¶
-
index_dimensions
()¶
-
reconstruct
(op)¶ Return a new object of the same type with new operands.
-
ufl_free_indices
¶
-
ufl_index_dimensions
¶
-
ufl_shape
¶
-
-
class
ufl.classes.
NablaDiv
(f)¶ Bases:
ufl.differentiation.CompoundDerivative
-
free_indices
()¶
-
index_dimensions
()¶
-
ufl_free_indices
¶
-
ufl_index_dimensions
¶
-
ufl_shape
¶
-
-
class
ufl.classes.
Curl
(f)¶ Bases:
ufl.differentiation.CompoundDerivative
-
free_indices
()¶
-
index_dimensions
()¶
-
ufl_free_indices
¶
-
ufl_index_dimensions
¶
-
ufl_shape
¶
-
-
class
ufl.classes.
Condition
(operands)¶ Bases:
ufl.core.operator.Operator
-
free_indices
()¶
-
index_dimensions
()¶
-
shape
()¶
-
ufl_free_indices
= ()¶
-
ufl_index_dimensions
= ()¶
-
ufl_shape
= ()¶
-
-
class
ufl.classes.
BinaryCondition
(name, left, right)¶ Bases:
ufl.conditional.Condition
-
class
ufl.classes.
EQ
(left, right)¶ Bases:
ufl.conditional.BinaryCondition
-
evaluate
(x, mapping, component, index_values)¶
-
-
class
ufl.classes.
NE
(left, right)¶ Bases:
ufl.conditional.BinaryCondition
-
evaluate
(x, mapping, component, index_values)¶
-
-
class
ufl.classes.
LE
(left, right)¶ Bases:
ufl.conditional.BinaryCondition
-
evaluate
(x, mapping, component, index_values)¶
-
-
class
ufl.classes.
GE
(left, right)¶ Bases:
ufl.conditional.BinaryCondition
-
evaluate
(x, mapping, component, index_values)¶
-
-
class
ufl.classes.
LT
(left, right)¶ Bases:
ufl.conditional.BinaryCondition
-
evaluate
(x, mapping, component, index_values)¶
-
-
class
ufl.classes.
GT
(left, right)¶ Bases:
ufl.conditional.BinaryCondition
-
evaluate
(x, mapping, component, index_values)¶
-
-
class
ufl.classes.
AndCondition
(left, right)¶ Bases:
ufl.conditional.BinaryCondition
-
evaluate
(x, mapping, component, index_values)¶
-
-
class
ufl.classes.
OrCondition
(left, right)¶ Bases:
ufl.conditional.BinaryCondition
-
evaluate
(x, mapping, component, index_values)¶
-
-
class
ufl.classes.
NotCondition
(condition)¶ Bases:
ufl.conditional.Condition
-
evaluate
(x, mapping, component, index_values)¶
-
-
class
ufl.classes.
Conditional
(condition, true_value, false_value)¶ Bases:
ufl.core.operator.Operator
-
evaluate
(x, mapping, component, index_values)¶
-
free_indices
()¶
-
index_dimensions
()¶
-
shape
()¶
-
ufl_free_indices
¶
-
ufl_index_dimensions
¶
-
ufl_shape
¶
-
-
class
ufl.classes.
MinValue
(left, right)¶ Bases:
ufl.core.operator.Operator
UFL operator: Take the minimum of two values.
-
evaluate
(x, mapping, component, index_values)¶
-
free_indices
()¶
-
index_dimensions
()¶
-
shape
()¶
-
ufl_free_indices
= ()¶
-
ufl_index_dimensions
= ()¶
-
ufl_shape
= ()¶
-
-
class
ufl.classes.
MaxValue
(left, right)¶ Bases:
ufl.core.operator.Operator
UFL operator: Take the maximum of two values.
-
evaluate
(x, mapping, component, index_values)¶
-
free_indices
()¶
-
index_dimensions
()¶
-
shape
()¶
-
ufl_free_indices
= ()¶
-
ufl_index_dimensions
= ()¶
-
ufl_shape
= ()¶
-
-
class
ufl.classes.
MathFunction
(name, argument)¶ Bases:
ufl.core.operator.Operator
Base class for all unary scalar math functions.
-
evaluate
(x, mapping, component, index_values)¶
-
free_indices
()¶
-
index_dimensions
()¶
-
shape
()¶
-
ufl_free_indices
= ()¶
-
ufl_index_dimensions
= ()¶
-
ufl_shape
= ()¶
-
-
class
ufl.classes.
Sqrt
(argument)¶
-
class
ufl.classes.
Exp
(argument)¶
-
class
ufl.classes.
Ln
(argument)¶ Bases:
ufl.mathfunctions.MathFunction
-
evaluate
(x, mapping, component, index_values)¶
-
-
class
ufl.classes.
Cos
(argument)¶
-
class
ufl.classes.
Sin
(argument)¶
-
class
ufl.classes.
Tan
(argument)¶
-
class
ufl.classes.
Cosh
(argument)¶
-
class
ufl.classes.
Sinh
(argument)¶
-
class
ufl.classes.
Tanh
(argument)¶
-
class
ufl.classes.
Acos
(argument)¶
-
class
ufl.classes.
Asin
(argument)¶
-
class
ufl.classes.
Atan
(argument)¶
-
class
ufl.classes.
Atan2
(arg1, arg2)¶ Bases:
ufl.core.operator.Operator
-
evaluate
(x, mapping, component, index_values)¶
-
free_indices
()¶
-
index_dimensions
()¶
-
shape
()¶
-
ufl_free_indices
= ()¶
-
ufl_index_dimensions
= ()¶
-
ufl_shape
= ()¶
-
-
class
ufl.classes.
Erf
(argument)¶ Bases:
ufl.mathfunctions.MathFunction
-
evaluate
(x, mapping, component, index_values)¶
-
-
class
ufl.classes.
BesselFunction
(name, classname, nu, argument)¶ Bases:
ufl.core.operator.Operator
Base class for all bessel functions
-
evaluate
(x, mapping, component, index_values)¶
-
free_indices
()¶
-
index_dimensions
()¶
-
shape
()¶
-
ufl_free_indices
= ()¶
-
ufl_index_dimensions
= ()¶
-
ufl_shape
= ()¶
-
-
class
ufl.classes.
BesselJ
(nu, argument)¶
-
class
ufl.classes.
BesselY
(nu, argument)¶
-
class
ufl.classes.
BesselI
(nu, argument)¶
-
class
ufl.classes.
BesselK
(nu, argument)¶
-
class
ufl.classes.
ReferenceValue
(f)¶ Bases:
ufl.core.operator.Operator
Representation of the reference cell value of a form argument.
-
evaluate
(x, mapping, component, index_values, derivatives=())¶ Get child from mapping and return the component asked for.
-
free_indices
()¶
-
index_dimensions
()¶
-
reconstruct
(op)¶ Return a new object of the same type with new operands.
-
ufl_free_indices
= ()¶
-
ufl_index_dimensions
= ()¶
-
ufl_shape
¶
-
-
class
ufl.classes.
Cell
(cellname, geometric_dimension=None, topological_dimension=None)¶ Bases:
object
Representation of a finite element cell.
Initialize basic cell description.
-
cellname
()¶ Return the cellname of the cell.
-
circumradius
¶ UFL geometry value. Deprecated, please use the constructor types instead.
-
d
¶ The dimension of the cell.
Only valid if the geometric and topological dimensions are the same.
-
facet_area
¶ UFL geometry value. Deprecated, please use the constructor types instead.
-
facet_cellname
()¶ Return the cellname of the facet of this cell, or None if not available.
-
geometric_dimension
()¶ Return the dimension of the space this cell is embedded in.
-
n
¶ UFL geometry value. Deprecated, please use the constructor types instead.
-
num_edges
()¶ The number of cell edges.
-
num_entities
(dim=None)¶ The number of cell entities of given topological dimension.
-
num_facet_edges
()¶ The number of facet edges, or None if not available.
-
num_facet_entities
(dim)¶ Return the number of cell entities of given topological dimension, or None if not available.
-
num_facet_vertices
()¶ The number of cell vertices, or None if not available.
-
num_facets
()¶ The number of cell facets.
-
num_vertices
()¶ The number of cell vertices.
-
reference_facet_volume
()¶ The volume of a reference cell of the same type.
-
reference_volume
()¶ The volume of a reference cell of the same type.
-
topological_dimension
()¶ Return the dimension of the topology of this cell.
-
volume
¶ UFL geometry value. Deprecated, please use the constructor types instead.
-
x
¶ UFL geometry value. Deprecated, please use the constructor types instead.
-
-
class
ufl.classes.
ProductCell
(*cells)¶ Bases:
ufl.cell.Cell
-
sub_cells
()¶ Return list of cell factors.
-
-
class
ufl.classes.
OuterProductCell
(A, B)¶ Bases:
ufl.cell.Cell
Representation of a cell formed as the Cartesian product of two existing cells
-
facet_horiz
¶
-
facet_vert
¶
-
num_entities
(dim)¶ The number of cell entities of given topological dimension.
-
reference_volume
()¶ The volume of a reference cell of the same type.
-
-
class
ufl.classes.
Domain
(*args, **kwargs)¶ Bases:
object
Symbolic representation of a geometrical domain.
Used in the definition of geometric terminal expressions, finite element spaces, and integration measures.
Takes a single positional argument which is either the cell of the underlying mesh
D = Domain(triangle)or the coordinate field which is a vector valued Coefficient.
P2 = VectorElement(“CG”, D, 2) x = Coefficient(P2) E = Domain(x)With the cell variant of the constructor, an optional label can be passed to distinguish two domains from each other.
Da = Domain(cell, label=”a”) Db = Domain(cell, label=”b”)an optional data argument can also be passed, for integration with problem solver environments (e.g. dolfin), this is typically the underlying mesh.
Da = Domain(cell, label=”a”, data=mesha) Db = Domain(cell, label=”b”, data=meshb)-
cell
()¶ Return the cell this domain is defined in terms of.
-
coordinate_element
()¶ Return the finite element of the coordinate vector field of this domain.
-
coordinates
()¶ Return the coordinate vector field this domain is defined in terms of.
-
data
()¶ Return attached data object.
-
geometric_dimension
()¶ Return the dimension of the space this domain is embedded in.
-
hash_data
()¶
-
is_piecewise_linear_simplex_domain
()¶
-
label
()¶ Return the label identifying this domain. None means no label has been set.
-
reconstruct
(cell=None, coordinates=None, label=None, data=None)¶ Create a new Domain object with possibly changed label or data.
-
reconstruction_signature
()¶ Format as string for evaluation as Python object.
For use with cross language frameworks, stored in generated code and evaluated later in Python to reconstruct this object.
This differs from repr in that it does not include domain label and data or coordinates, which must be reconstructed or supplied by other means.
-
signature_data
(renumbering)¶ Signature data of domain depend on the global domain numbering.
-
topological_dimension
()¶ Return the dimension of the topology of this domain.
-
-
class
ufl.classes.
ProductDomain
(domains, data=None)¶ Bases:
ufl.domain.Domain
WARNING: This is work in progress, design is in no way completed.
-
child_domains
()¶
-
-
class
ufl.classes.
FiniteElementBase
(family, domain, degree, quad_scheme, value_shape, reference_value_shape)¶ Bases:
object
Base class for all finite elements
Initialize basic finite element data
-
cell
()¶ Return cell of finite element
-
degree
(component=None)¶ Return polynomial degree of finite element
-
domain
(component=None)¶ Return the domain on which this element is defined.
-
domains
(component=None)¶ Return the domain on which this element is defined.
-
extract_component
(i)¶ Recursively extract component index relative to a (simple) element and that element for given value component index
-
extract_reference_component
(i)¶ Recursively extract reference component index relative to a (simple) element and that element for given reference value component index
-
extract_subelement_component
(i)¶ Extract direct subelement index and subelement relative component index for a given component index
-
extract_subelement_reference_component
(i)¶ Extract direct subelement index and subelement relative reference component index for a given reference component index
-
family
()¶ Return finite element family
-
is_cellwise_constant
(component=None)¶ Return whether the basis functions of this element is spatially constant over each cell.
-
mapping
()¶
-
num_sub_elements
()¶ Return number of sub elements
-
quadrature_scheme
()¶ Return quadrature scheme of finite element
-
reconstruction_signature
()¶ Format as string for evaluation as Python object.
For use with cross language frameworks, stored in generated code and evaluated later in Python to reconstruct this object.
This differs from repr in that it does not include domain label and data, which must be reconstructed or supplied by other means.
-
reference_value_shape
()¶ Return the shape of the value space on the reference cell.
-
signature_data
(renumbering)¶
-
sub_elements
()¶ Return list of sub elements
-
symmetry
()¶ Return the symmetry dict, which is a mapping c0 -> c1 meaning that component c0 is represented by component c1.
-
value_shape
()¶ Return the shape of the value space on the global domain.
-
-
class
ufl.classes.
FiniteElement
(family, domain=None, degree=None, form_degree=None, quad_scheme=None)¶ Bases:
ufl.finiteelement.finiteelementbase.FiniteElementBase
The basic finite element class for all simple finite elements
Create finite element.
- Arguments
- family (string)
- The finite element family
- domain
- The geometric domain
- degree (int)
- The polynomial degree (optional)
- form_degree (int)
- The form degree (FEEC notation, used when field is viewed as k-form)
- quad_scheme
- The quadrature scheme (optional)
-
mapping
()¶
-
reconstruct
(**kwargs)¶ Construct a new FiniteElement object with some properties replaced with new values.
-
reconstruction_signature
()¶ Format as string for evaluation as Python object.
For use with cross language frameworks, stored in generated code and evaluated later in Python to reconstruct this object.
This differs from repr in that it does not include domain label and data, which must be reconstructed or supplied by other means.
-
shortstr
()¶ Format as string for pretty printing.
-
signature_data
(renumbering)¶
-
sobolev_space
()¶
-
class
ufl.classes.
MixedElement
(*elements, **kwargs)¶ Bases:
ufl.finiteelement.finiteelementbase.FiniteElementBase
A finite element composed of a nested hierarchy of mixed or simple elements
Create mixed finite element from given list of elements
-
degree
(component=None)¶ Return polynomial degree of finite element
-
domains
(component=None)¶ Return the domain(s) on which this element is defined.
-
extract_component
(i)¶ Recursively extract component index relative to a (simple) element and that element for given value component index
-
extract_reference_component
(i)¶ Recursively extract reference_component index relative to a (simple) element and that element for given value reference_component index
-
extract_subelement_component
(i)¶ Extract direct subelement index and subelement relative component index for a given component index
-
extract_subelement_reference_component
(i)¶ Extract direct subelement index and subelement relative reference_component index for a given reference_component index
-
is_cellwise_constant
(component=None)¶ Return whether the basis functions of this element is spatially constant over each cell.
-
mapping
()¶
-
num_sub_elements
()¶ Return number of sub elements.
-
reconstruct
(**kwargs)¶ Construct a new MixedElement object with some properties replaced with new values.
-
reconstruct_from_elements
(*elements)¶ Reconstruct a mixed element from new subelements.
-
reconstruction_signature
()¶ Format as string for evaluation as Python object.
For use with cross language frameworks, stored in generated code and evaluated later in Python to reconstruct this object.
This differs from repr in that it does not include domain label and data, which must be reconstructed or supplied by other means.
-
shortstr
()¶ Format as string for pretty printing.
-
signature_data
(renumbering)¶
-
sub_elements
()¶ Return list of sub elements.
-
symmetry
()¶ Return the symmetry dict, which is a mapping c0 -> c1 meaning that component c0 is represented by component c1. A component is a tuple of one or more ints.
-
-
class
ufl.classes.
VectorElement
(family, domain, degree, dim=None, form_degree=None, quad_scheme=None)¶ Bases:
ufl.finiteelement.mixedelement.MixedElement
A special case of a mixed finite element where all elements are equal
Create vector element (repeated mixed element)
- Arguments
- family (string)
- The finite element family
- domain
- The geometric domain
- degree (int)
- The polynomial degree
- dim (int)
- The value dimension of the element (optional)
- form_degree (int)
- The form degree (FEEC notation, used when field is viewed as k-form)
- quad_scheme
- The quadrature scheme (optional)
-
mapping
()¶
-
reconstruct
(**kwargs)¶
-
reconstruction_signature
()¶ Format as string for evaluation as Python object.
For use with cross language frameworks, stored in generated code and evaluated later in Python to reconstruct this object.
This differs from repr in that it does not include domain label and data, which must be reconstructed or supplied by other means.
-
shortstr
()¶ Format as string for pretty printing.
-
signature_data
(renumbering)¶
-
class
ufl.classes.
TensorElement
(family, domain, degree, shape=None, symmetry=None, quad_scheme=None)¶ Bases:
ufl.finiteelement.mixedelement.MixedElement
A special case of a mixed finite element where all elements are equal
Create tensor element (repeated mixed element with optional symmetries)
-
extract_subelement_component
(i)¶ Extract direct subelement index and subelement relative component index for a given component index
-
mapping
()¶
-
reconstruct
(**kwargs)¶
-
reconstruction_signature
()¶ Format as string for evaluation as Python object.
For use with cross language frameworks, stored in generated code and evaluated later in Python to reconstruct this object.
This differs from repr in that it does not include domain label and data, which must be reconstructed or supplied by other means.
-
shortstr
()¶ Format as string for pretty printing.
-
signature_data
(renumbering)¶
-
symmetry
()¶ Return the symmetry dict, which is a mapping c0 -> c1 meaning that component c0 is represented by component c1.
-
-
class
ufl.classes.
EnrichedElement
(*elements)¶ Bases:
ufl.finiteelement.finiteelementbase.FiniteElementBase
The vector sum of two finite element spaces:
EnrichedElement(V, Q) = {v + q | v in V, q in Q}.
-
is_cellwise_constant
()¶ Return whether the basis functions of this element is spatially constant over each cell.
-
mapping
()¶
-
reconstruct
(**kwargs)¶ Construct a new EnrichedElement object with some properties replaced with new values.
-
reconstruction_signature
()¶ Format as string for evaluation as Python object.
For use with cross language frameworks, stored in generated code and evaluated later in Python to reconstruct this object.
This differs from repr in that it does not include domain label and data, which must be reconstructed or supplied by other means.
-
shortstr
()¶ Format as string for pretty printing.
-
signature_data
(renumbering)¶
-
-
class
ufl.classes.
RestrictedElement
(element, cell_restriction)¶ Bases:
ufl.finiteelement.finiteelementbase.FiniteElementBase
Represents the restriction of a finite element to a type of cell entity.
-
cell_restriction
()¶ Return the domain onto which the element is restricted.
-
element
()¶ Return the element which is restricted.
-
is_cellwise_constant
()¶ Return whether the basis functions of this element is spatially constant over each cell.
-
mapping
()¶
-
num_restricted_sub_elements
()¶ Return number of restricted sub elements.
-
num_sub_elements
()¶ Return number of sub elements
-
reconstruct
(**kwargs)¶ Construct a new RestrictedElement object with some properties replaced with new values.
-
reconstruction_signature
()¶ Format as string for evaluation as Python object.
For use with cross language frameworks, stored in generated code and evaluated later in Python to reconstruct this object.
This differs from repr in that it does not include domain label and data, which must be reconstructed or supplied by other means.
-
restricted_sub_elements
()¶ Return list of restricted sub elements.
-
shortstr
()¶ Format as string for pretty printing.
-
signature_data
(renumbering)¶
-
sub_elements
()¶ Return list of sub elements
-
symmetry
()¶ Return the symmetry dict, which is a mapping c0 -> c1 meaning that component c0 is represented by component c1.
-
-
class
ufl.classes.
TensorProductElement
(*elements)¶ Bases:
ufl.finiteelement.finiteelementbase.FiniteElementBase
The tensor product of d element spaces:
\[V = V_0 \otimes V_1 \otimes ... \otimes V_d\]Given bases {phi_i} for V_i for i = 1, ...., d, { phi_0 * phi_1 * ... * phi_d } forms a basis for V.
Create TensorProductElement from a given list of elements.
-
mapping
()¶
-
num_sub_elements
()¶ Return number of subelements.
-
reconstruction_signature
()¶ Format as string for evaluation as Python object.
For use with cross language frameworks, stored in generated code and evaluated later in Python to reconstruct this object.
This differs from repr in that it does not include domain label and data, which must be reconstructed or supplied by other means.
-
shortstr
()¶ Short pretty-print.
-
signature_data
(renumbering)¶
-
sub_elements
()¶ Return subelements (factors).
-
-
class
ufl.classes.
OuterProductElement
(A, B, domain=None, form_degree=None, quad_scheme=None)¶ Bases:
ufl.finiteelement.finiteelementbase.FiniteElementBase
The outer (tensor) product of 2 element spaces:
\[V = A \otimes B\]Given bases \({\phi_A, \phi_B}\) for \(A, B\), \({\phi_A * \phi_B}\) forms a basis for \(V\).
Create OuterProductElement from a given pair of elements.
-
mapping
()¶
-
reconstruct
(**kwargs)¶ Construct a new OuterProductElement with some properties replaced with new values.
-
reconstruction_signature
()¶ Format as string for evaluation as Python object.
For use with cross language frameworks, stored in generated code and evaluated later in Python to reconstruct this object.
This differs from repr in that it does not include domain label and data, which must be reconstructed or supplied by other means.
-
shortstr
()¶ Short pretty-print.
-
signature_data
(renumbering)¶
-
-
class
ufl.classes.
OuterProductVectorElement
(A, B, domain=None, dim=None, form_degree=None, quad_scheme=None)¶ Bases:
ufl.finiteelement.mixedelement.MixedElement
A special case of a mixed finite element where all elements are equal OuterProductElements
-
reconstruct
(**kwargs)¶ Construct a new OuterProductVectorElement with some properties replaced with new values.
-
reconstruction_signature
()¶ Format as string for evaluation as Python object.
For use with cross language frameworks, stored in generated code and evaluated later in Python to reconstruct this object.
This differs from repr in that it does not include domain label and data, which must be reconstructed or supplied by other means.
-
shortstr
()¶ Format as string for pretty printing.
-
signature_data
(domain_numbering)¶
-
-
ufl.classes.
TestFunction
(element, part=None)¶ UFL value: Create a test function argument to a form.
-
ufl.classes.
TrialFunction
(element, part=None)¶ UFL value: Create a trial function argument to a form.
-
ufl.classes.
TestFunctions
(element)¶ UFL value: Create a TestFunction in a mixed space, and return a tuple with the function components corresponding to the subelements.
-
ufl.classes.
TrialFunctions
(element)¶ UFL value: Create a TrialFunction in a mixed space, and return a tuple with the function components corresponding to the subelements.
-
class
ufl.classes.
FixedIndex
(value)¶ Bases:
ufl.core.multiindex.IndexBase
UFL value: An index with a specific value assigned.
-
class
ufl.classes.
Index
(count=None)¶ Bases:
ufl.core.multiindex.IndexBase
UFL value: An index with no value assigned.
Used to represent free indices in Einstein indexing notation.
-
count
()¶
-
-
class
ufl.classes.
Measure
(integral_type, domain=None, subdomain_id='everywhere', metadata=None, subdomain_data=None)¶ Bases:
object
- integral_type:
- str, one of “cell”, etc., or short form “dx”, etc.
- domain:
- a Domain object (includes cell, dims, label, domain data)
- subdomain_id:
- either string “everywhere”, a single subdomain id int, or tuple of ints
- metadata
- dict, with additional compiler-specific parameters affecting how code is generated, including parameters for optimization or debugging of generated code.
- subdomain_data
- object representing data to interpret subdomain_id with.
-
CELL
= 'cell'¶
-
EXTERIOR_FACET
= 'exterior_facet'¶
-
EXTERIOR_FACET_BOTTOM
= 'exterior_facet_bottom'¶
-
EXTERIOR_FACET_TOP
= 'exterior_facet_top'¶
-
EXTERIOR_FACET_VERT
= 'exterior_facet_vert'¶
-
INTERIOR_FACET
= 'interior_facet'¶
-
INTERIOR_FACET_HORIZ
= 'interior_facet_horiz'¶
-
INTERIOR_FACET_VERT
= 'interior_facet_vert'¶
-
MACRO_CELL
= 'macro_cell'¶
-
POINT
= 'point'¶
-
QUADRATURE
= 'quadrature'¶
-
SURFACE
= 'surface'¶
-
domain
()¶ Return the domain associated with this measure.
This may be None or a Domain object.
-
integral_type
()¶ Return the domain type.
Valid domain types are “cell”, “exterior_facet”, “interior_facet”, etc.
-
metadata
()¶ 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)¶ Construct a new Measure object with some properties replaced with new values.
- Example:
- <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 })
-
subdomain_data
()¶ Return the integral subdomain_data. This data is not interpreted by UFL. Its intension is to give a context in which the domain id is interpreted.
-
subdomain_id
()¶ Return the domain id of this measure (integer).
-
class
ufl.classes.
MeasureSum
(*measures)¶ 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.
MeasureProduct
(*measures)¶ 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.
Create MeasureProduct from given list of measures.
-
sub_measures
()¶ Return submeasures.
-
-
class
ufl.classes.
Integral
(integrand, integral_type, domain, subdomain_id, metadata, subdomain_data)¶ Bases:
object
An integral over a single domain.
-
domain
()¶ Return the integration domain of this integral.
-
integral_type
()¶ Return the domain type of this integral.
-
integrand
()¶ Return the integrand expression, which is an Expr instance.
-
metadata
()¶ Return the compiler metadata this integral has been annotated with.
-
reconstruct
(integrand=None, integral_type=None, domain=None, subdomain_id=None, metadata=None, subdomain_data=None)¶ Construct a new Integral object with some properties replaced with new values.
- Example:
- <a = Integral instance> b = a.reconstruct(expand_compounds(a.integrand())) c = a.reconstruct(metadata={‘quadrature_degree’:2})
-
subdomain_data
()¶ Return the domain data of this integral.
-
subdomain_id
()¶ Return the subdomain id of this integral.
-
-
class
ufl.classes.
Form
(integrals)¶ Bases:
object
Description of a weak form consisting of a sum of integrals over subdomains.
-
arguments
()¶ Return all Argument objects found in form.
-
cell
()¶ Return the single cell this form is defined on, fails if multiple cells are found.
-
coefficient_numbering
()¶ Return a contiguous numbering of coefficients in a mapping { coefficient: number }.
-
coefficients
()¶ Return all Coefficient objects found in form.
-
domain
()¶ Return the single geometric integration domain occuring in the form.
Fails if multiple domains are found.
NB! This does not include domains of coefficients defined on other meshes, look at form data for that additional information.
-
domain_numbering
()¶ Return a contiguous numbering of domains in a mapping { domain: number }.
-
domains
()¶ Return the geometric integration domains occuring in the form.
NB! This does not include domains of coefficients defined on other meshes.
The return type is a tuple even if only a single domain exists.
-
empty
()¶ Returns whether the form has no integrals.
-
equals
(other)¶ Evaluate ‘bool(lhs_form == rhs_form)’.
-
integrals
()¶ Return a sequence of all integrals in form.
-
integrals_by_type
(integral_type)¶ Return a sequence of all integrals with a particular domain type.
-
max_subdomain_ids
()¶ Returns a mapping on the form { domain: { integral_type: max_subdomain_id } }.
-
signature
()¶ Signature for use with jit cache (independent of incidental numbering of indices etc.)
-
subdomain_data
()¶ Returns a mapping on the form { domain: { integral_type: subdomain_data } }.
-
x_repr_latex_
()¶
-
x_repr_png_
()¶
-
-
class
ufl.classes.
Equation
(lhs, rhs)¶ 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.
Create equation lhs == rhs
coefficient
Module¶
This module defines the Coefficient class and a number of related classes, including Constant.
-
class
ufl.coefficient.
Coefficient
(element, count=None)¶ Bases:
ufl.core.terminal.FormArgument
UFL form argument type: Representation of a form coefficient.
-
count
()¶
-
domains
()¶ Return tuple of domains related to this terminal object.
-
element
()¶
-
is_cellwise_constant
()¶ Return whether this expression is spatially constant over each cell.
-
reconstruct
(element=None, count=None)¶
-
signature_data
(renumbering)¶ Signature data for form arguments depend on the global numbering of the form arguments and domains.
-
ufl_shape
¶
-
-
ufl.coefficient.
Coefficients
(element)¶ UFL value: Create a Coefficient in a mixed space, and return a tuple with the function components corresponding to the subelements.
-
ufl.coefficient.
Constant
(domain, count=None)¶ UFL value: Represents a globally constant scalar valued coefficient.
-
ufl.coefficient.
TensorConstant
(domain, shape=None, symmetry=None, count=None)¶ UFL value: Represents a globally constant tensor valued coefficient.
-
ufl.coefficient.
VectorConstant
(domain, dim=None, count=None)¶ UFL value: Represents a globally constant vector valued coefficient.
common
Module¶
This module contains a collection of common utilities.
compound_expressions
Module¶
Functions implementing compound expressions as equivalent representations using basic operators.
-
ufl.compound_expressions.
adj_expr
(A)¶
-
ufl.compound_expressions.
adj_expr_2x2
(A)¶
-
ufl.compound_expressions.
adj_expr_3x3
(A)¶
-
ufl.compound_expressions.
adj_expr_4x4
(A)¶
-
ufl.compound_expressions.
cofactor_expr
(A)¶
-
ufl.compound_expressions.
cofactor_expr_2x2
(A)¶
-
ufl.compound_expressions.
cofactor_expr_3x3
(A)¶
-
ufl.compound_expressions.
cofactor_expr_4x4
(A)¶
-
ufl.compound_expressions.
cross_expr
(a, b)¶
-
ufl.compound_expressions.
determinant_expr
(A)¶ Compute the determinant of A.
-
ufl.compound_expressions.
determinant_expr_2x2
(B)¶
-
ufl.compound_expressions.
determinant_expr_3x3
(A)¶
-
ufl.compound_expressions.
deviatoric_expr
(A)¶
-
ufl.compound_expressions.
deviatoric_expr_2x2
(A)¶
-
ufl.compound_expressions.
deviatoric_expr_3x3
(A)¶
-
ufl.compound_expressions.
inverse_expr
(A)¶ Compute the inverse of A.
-
ufl.compound_expressions.
pseudo_determinant_expr
(A)¶ Compute the pseudo-determinant of A: sqrt(det(A.T*A)).
-
ufl.compound_expressions.
pseudo_inverse_expr
(A)¶ Compute the Penrose-Moore pseudo-inverse of A: (A.T*A)^-1 * A.T.
conditional
Module¶
This module defines classes for conditional expressions.
-
class
ufl.conditional.
AndCondition
(left, right)¶ Bases:
ufl.conditional.BinaryCondition
-
evaluate
(x, mapping, component, index_values)¶
-
-
class
ufl.conditional.
BinaryCondition
(name, left, right)¶ Bases:
ufl.conditional.Condition
-
class
ufl.conditional.
Condition
(operands)¶ Bases:
ufl.core.operator.Operator
-
free_indices
()¶
-
index_dimensions
()¶
-
shape
()¶
-
ufl_free_indices
= ()¶
-
ufl_index_dimensions
= ()¶
-
ufl_shape
= ()¶
-
-
class
ufl.conditional.
Conditional
(condition, true_value, false_value)¶ Bases:
ufl.core.operator.Operator
-
evaluate
(x, mapping, component, index_values)¶
-
free_indices
()¶
-
index_dimensions
()¶
-
shape
()¶
-
ufl_free_indices
¶
-
ufl_index_dimensions
¶
-
ufl_shape
¶
-
-
class
ufl.conditional.
EQ
(left, right)¶ Bases:
ufl.conditional.BinaryCondition
-
evaluate
(x, mapping, component, index_values)¶
-
-
class
ufl.conditional.
GE
(left, right)¶ Bases:
ufl.conditional.BinaryCondition
-
evaluate
(x, mapping, component, index_values)¶
-
-
class
ufl.conditional.
GT
(left, right)¶ Bases:
ufl.conditional.BinaryCondition
-
evaluate
(x, mapping, component, index_values)¶
-
-
class
ufl.conditional.
LE
(left, right)¶ Bases:
ufl.conditional.BinaryCondition
-
evaluate
(x, mapping, component, index_values)¶
-
-
class
ufl.conditional.
LT
(left, right)¶ Bases:
ufl.conditional.BinaryCondition
-
evaluate
(x, mapping, component, index_values)¶
-
-
class
ufl.conditional.
MaxValue
(left, right)¶ Bases:
ufl.core.operator.Operator
UFL operator: Take the maximum of two values.
-
evaluate
(x, mapping, component, index_values)¶
-
free_indices
()¶
-
index_dimensions
()¶
-
shape
()¶
-
ufl_free_indices
= ()¶
-
ufl_index_dimensions
= ()¶
-
ufl_shape
= ()¶
-
-
class
ufl.conditional.
MinValue
(left, right)¶ Bases:
ufl.core.operator.Operator
UFL operator: Take the minimum of two values.
-
evaluate
(x, mapping, component, index_values)¶
-
free_indices
()¶
-
index_dimensions
()¶
-
shape
()¶
-
ufl_free_indices
= ()¶
-
ufl_index_dimensions
= ()¶
-
ufl_shape
= ()¶
-
-
class
ufl.conditional.
NE
(left, right)¶ Bases:
ufl.conditional.BinaryCondition
-
evaluate
(x, mapping, component, index_values)¶
-
-
class
ufl.conditional.
NotCondition
(condition)¶ Bases:
ufl.conditional.Condition
-
evaluate
(x, mapping, component, index_values)¶
-
-
class
ufl.conditional.
OrCondition
(left, right)¶ Bases:
ufl.conditional.BinaryCondition
-
evaluate
(x, mapping, component, index_values)¶
-
constantvalue
Module¶
This module defines classes representing constant values.
-
class
ufl.constantvalue.
ConstantValue
¶ Bases:
ufl.core.terminal.Terminal
-
domains
()¶ Return tuple of domains related to this terminal object.
-
is_cellwise_constant
()¶ Return whether this expression is spatially constant over each cell.
-
-
class
ufl.constantvalue.
FloatValue
(value)¶ Bases:
ufl.constantvalue.ScalarValue
UFL literal type: Representation of a constant scalar floating point value.
-
class
ufl.constantvalue.
Identity
(dim)¶ Bases:
ufl.constantvalue.ConstantValue
UFL literal type: Representation of an identity matrix.
-
evaluate
(x, mapping, component, index_values)¶
-
ufl_shape
¶
-
-
class
ufl.constantvalue.
IntValue
(value)¶ Bases:
ufl.constantvalue.ScalarValue
UFL literal type: Representation of a constant scalar integer value.
-
class
ufl.constantvalue.
PermutationSymbol
(dim)¶ Bases:
ufl.constantvalue.ConstantValue
UFL literal type: Representation of a permutation symbol.
This is also known as the Levi-Civita symbol, antisymmetric symbol, or alternating symbol.
-
evaluate
(x, mapping, component, index_values)¶
-
ufl_shape
¶
-
-
class
ufl.constantvalue.
ScalarValue
(value)¶ Bases:
ufl.constantvalue.ConstantValue
A constant scalar value.
-
evaluate
(x, mapping, component, index_values)¶
-
free_indices
()¶
-
index_dimensions
()¶
-
shape
()¶
-
ufl_free_indices
= ()¶
-
ufl_index_dimensions
= ()¶
-
ufl_shape
= ()¶
-
value
()¶
-
-
class
ufl.constantvalue.
Zero
(shape=(), free_indices=(), index_dimensions=None)¶ Bases:
ufl.constantvalue.ConstantValue
UFL literal type: Representation of a zero valued expression.
-
evaluate
(x, mapping, component, index_values)¶
-
free_indices
()¶ Intermediate helper property getter to transition from .free_indices() to .ufl_free_indices.
-
index_dimensions
()¶ Intermediate helper property getter to transition from .index_dimensions() to .ufl_index_dimensions.
-
reconstruct
(free_indices=None)¶
-
ufl_free_indices
¶
-
ufl_index_dimensions
¶
-
ufl_shape
¶
-
-
ufl.constantvalue.
as_ufl
(expression)¶ Converts expression to an Expr if possible.
-
ufl.constantvalue.
format_float
(x)¶ Format float value based on global UFL precision.
-
ufl.constantvalue.
zero
(*shape)¶ UFL literal constant: Return a zero tensor with the given shape.
differentiation
Module¶
Differential operators.
-
class
ufl.differentiation.
CoefficientDerivative
(integrand, coefficients, arguments, coefficient_derivatives)¶ Bases:
ufl.differentiation.Derivative
Derivative of the integrand of a form w.r.t. the degrees of freedom in a discrete Coefficient.
-
free_indices
()¶
-
index_dimensions
()¶
-
shape
()¶
-
ufl_free_indices
¶
-
ufl_index_dimensions
¶
-
ufl_shape
¶
-
-
class
ufl.differentiation.
CompoundDerivative
(operands)¶ Bases:
ufl.differentiation.Derivative
Base class for all compound derivative types.
-
class
ufl.differentiation.
Curl
(f)¶ Bases:
ufl.differentiation.CompoundDerivative
-
free_indices
()¶
-
index_dimensions
()¶
-
ufl_free_indices
¶
-
ufl_index_dimensions
¶
-
ufl_shape
¶
-
-
class
ufl.differentiation.
Derivative
(operands)¶ Bases:
ufl.core.operator.Operator
Base class for all derivative types.
-
class
ufl.differentiation.
Div
(f)¶ Bases:
ufl.differentiation.CompoundDerivative
-
free_indices
()¶
-
index_dimensions
()¶
-
ufl_free_indices
¶
-
ufl_index_dimensions
¶
-
ufl_shape
¶
-
-
class
ufl.differentiation.
Grad
(f)¶ Bases:
ufl.differentiation.CompoundDerivative
-
evaluate
(x, mapping, component, index_values, derivatives=())¶ Get child from mapping and return the component asked for.
-
free_indices
()¶
-
index_dimensions
()¶
-
reconstruct
(op)¶ Return a new object of the same type with new operands.
-
ufl_free_indices
¶
-
ufl_index_dimensions
¶
-
ufl_shape
¶
-
-
class
ufl.differentiation.
NablaDiv
(f)¶ Bases:
ufl.differentiation.CompoundDerivative
-
free_indices
()¶
-
index_dimensions
()¶
-
ufl_free_indices
¶
-
ufl_index_dimensions
¶
-
ufl_shape
¶
-
-
class
ufl.differentiation.
NablaGrad
(f)¶ Bases:
ufl.differentiation.CompoundDerivative
-
free_indices
()¶
-
index_dimensions
()¶
-
reconstruct
(op)¶ Return a new object of the same type with new operands.
-
ufl_free_indices
¶
-
ufl_index_dimensions
¶
-
ufl_shape
¶
-
-
class
ufl.differentiation.
ReferenceGrad
(f)¶ Bases:
ufl.differentiation.CompoundDerivative
-
evaluate
(x, mapping, component, index_values, derivatives=())¶ Get child from mapping and return the component asked for.
-
free_indices
()¶
-
index_dimensions
()¶
-
reconstruct
(op)¶ Return a new object of the same type with new operands.
-
ufl_free_indices
¶
-
ufl_index_dimensions
¶
-
ufl_shape
¶
-
-
class
ufl.differentiation.
VariableDerivative
(f, v)¶ Bases:
ufl.differentiation.Derivative
-
ufl_free_indices
¶
-
ufl_index_dimensions
¶
-
ufl_shape
¶
-
domain
Module¶
Types for representing a geometric domain.
-
class
ufl.domain.
Domain
(*args, **kwargs)¶ Bases:
object
Symbolic representation of a geometrical domain.
Used in the definition of geometric terminal expressions, finite element spaces, and integration measures.
Takes a single positional argument which is either the cell of the underlying mesh
D = Domain(triangle)or the coordinate field which is a vector valued Coefficient.
P2 = VectorElement(“CG”, D, 2) x = Coefficient(P2) E = Domain(x)With the cell variant of the constructor, an optional label can be passed to distinguish two domains from each other.
Da = Domain(cell, label=”a”) Db = Domain(cell, label=”b”)an optional data argument can also be passed, for integration with problem solver environments (e.g. dolfin), this is typically the underlying mesh.
Da = Domain(cell, label=”a”, data=mesha) Db = Domain(cell, label=”b”, data=meshb)-
cell
()¶ Return the cell this domain is defined in terms of.
-
coordinate_element
()¶ Return the finite element of the coordinate vector field of this domain.
-
coordinates
()¶ Return the coordinate vector field this domain is defined in terms of.
-
data
()¶ Return attached data object.
-
geometric_dimension
()¶ Return the dimension of the space this domain is embedded in.
-
hash_data
()¶
-
is_piecewise_linear_simplex_domain
()¶
-
label
()¶ Return the label identifying this domain. None means no label has been set.
-
reconstruct
(cell=None, coordinates=None, label=None, data=None)¶ Create a new Domain object with possibly changed label or data.
-
reconstruction_signature
()¶ Format as string for evaluation as Python object.
For use with cross language frameworks, stored in generated code and evaluated later in Python to reconstruct this object.
This differs from repr in that it does not include domain label and data or coordinates, which must be reconstructed or supplied by other means.
-
signature_data
(renumbering)¶ Signature data of domain depend on the global domain numbering.
-
topological_dimension
()¶ Return the dimension of the topology of this domain.
-
-
class
ufl.domain.
IntersectionDomain
(domain1, domain2, label=None, data=None)¶ Bases:
ufl.domain.Domain
WARNING: This is work in progress, design is in no way completed.
-
child_domains
()¶
-
-
class
ufl.domain.
OverlapDomain
(domain1, domain2, label=None, data=None)¶ Bases:
ufl.domain.Domain
WARNING: This is work in progress, design is in no way completed.
-
child_domains
()¶
-
-
class
ufl.domain.
ProductDomain
(domains, data=None)¶ Bases:
ufl.domain.Domain
WARNING: This is work in progress, design is in no way completed.
-
child_domains
()¶
-
-
ufl.domain.
as_domain
(domain)¶ Convert any valid object to a Domain (in particular, cell or cellname string), or return domain if it is already a Domain.
-
ufl.domain.
check_domain_compatibility
(domains)¶
-
ufl.domain.
extract_domains
(expr)¶
-
ufl.domain.
join_domains
(domains)¶ Take a list of Domains and return a list with only unique domain objects.
Checks that domains with the same label are compatible, and allows data to be None or
-
ufl.domain.
join_subdomain_data
(subdomain_datas)¶
equation
Module¶
The Equation class, used to express equations like a == L.
-
class
ufl.equation.
Equation
(lhs, rhs)¶ 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.
Create equation lhs == rhs
exprcontainers
Module¶
This module defines special types for representing mapping of expressions to expressions.
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.exprequals.
measure_collisions
(equals_func)¶
-
ufl.exprequals.
nonrecursive_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.exprequals.
print_collisions
()¶
-
ufl.exprequals.
recursive_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.
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)¶ 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
form
Module¶
The Form class.
-
class
ufl.form.
Form
(integrals)¶ Bases:
object
Description of a weak form consisting of a sum of integrals over subdomains.
-
arguments
()¶ Return all Argument objects found in form.
-
cell
()¶ Return the single cell this form is defined on, fails if multiple cells are found.
-
coefficient_numbering
()¶ Return a contiguous numbering of coefficients in a mapping { coefficient: number }.
-
coefficients
()¶ Return all Coefficient objects found in form.
-
domain
()¶ Return the single geometric integration domain occuring in the form.
Fails if multiple domains are found.
NB! This does not include domains of coefficients defined on other meshes, look at form data for that additional information.
-
domain_numbering
()¶ Return a contiguous numbering of domains in a mapping { domain: number }.
-
domains
()¶ Return the geometric integration domains occuring in the form.
NB! This does not include domains of coefficients defined on other meshes.
The return type is a tuple even if only a single domain exists.
-
empty
()¶ Returns whether the form has no integrals.
-
equals
(other)¶ Evaluate ‘bool(lhs_form == rhs_form)’.
-
integrals
()¶ Return a sequence of all integrals in form.
-
integrals_by_type
(integral_type)¶ Return a sequence of all integrals with a particular domain type.
-
max_subdomain_ids
()¶ Returns a mapping on the form { domain: { integral_type: max_subdomain_id } }.
-
signature
()¶ Signature for use with jit cache (independent of incidental numbering of indices etc.)
-
subdomain_data
()¶ Returns a mapping on the form { domain: { integral_type: subdomain_data } }.
-
x_repr_latex_
()¶
-
x_repr_png_
()¶
-
-
ufl.form.
as_form
(form)¶ Convert to form if not a form, otherwise return form.
-
ufl.form.
replace_integral_domains
(form, common_domain)¶ 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, some times occuring in pydolfin, e.g. assemble(1*dx, mesh=mesh).
formoperators
Module¶
Various high level ways to transform a complete Form into a new Form.
-
ufl.formoperators.
action
(form, coefficient=None)¶ 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)¶ UFL form operator: Given a combined bilinear form, compute the adjoint form by changing the ordering (count) of the test and trial functions.
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)¶ 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 Coefficients may be provided in place of a single Coefficient, in which case the new Argument argument is based on a MixedElement 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)¶ UFL form operator: Given a bilinear form a and a coefficient f, return the functional a(f,f).
-
ufl.formoperators.
functional
(form)¶ UFL form operator: Extract the functional part of form.
-
ufl.formoperators.
lhs
(form)¶ UFL form operator: Given a combined bilinear and linear form, extract the left hand side (bilinear form part).
Example:
a = u*v*dx + f*v*dx a = lhs(a) -> u*v*dx
-
ufl.formoperators.
rhs
(form)¶ UFL form operator: Given a combined bilinear and linear form, extract the right hand side (negated linear form part).
Example:
a = u*v*dx + f*v*dx L = rhs(a) -> -f*v*dx
-
ufl.formoperators.
sensitivity_rhs
(a, u, L, v)¶ 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
0 = d/dv[Ax-b] = dA/dv x + A dx/dv - db/dv, A dx/dv = db/dv - dA/dv x,and solve this system for 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)*dxwhere IL and Ia are integrand expressions. Define a Coefficient u representing the solution to the equations. Then we can compute db/dv and dA/dv from the forms
da = diff(a, v) dL = diff(L, v)and the action of da on u by
dau = action(da, u)In total, we can build the right hand side of the system to compute 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.formoperators.
set_list_item
(li, i, v)¶
-
ufl.formoperators.
system
(form)¶ UFL form operator: Split a form into the left hand side and right hand side, see lhs and rhs.
-
ufl.formoperators.
zero_lists
(shape)¶
geometry
Module¶
Types for representing symbolic expressions for geometric quantities.
-
class
ufl.geometry.
CellCoordinate
(domain)¶ Bases:
ufl.geometry.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
()¶ Return whether this expression is spatially constant over each cell.
-
name
= 'X'¶
-
ufl_shape
¶
-
-
class
ufl.geometry.
CellEdgeVectors
(domain)¶ Bases:
ufl.geometry.GeometricCellQuantity
UFL geometry representation: The vectors between reference cell vertices for each edge in cell.
-
is_cellwise_constant
()¶ Return whether this expression is spatially constant over each cell.
-
name
= 'CEV'¶
-
ufl_shape
¶
-
-
class
ufl.geometry.
CellFacetJacobian
(domain)¶ Bases:
ufl.geometry.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
()¶ Return whether this expression is spatially constant over each cell.
-
name
= 'CFJ'¶
-
ufl_shape
¶
-
-
class
ufl.geometry.
CellFacetJacobianDeterminant
(domain)¶ Bases:
ufl.geometry.GeometricFacetQuantity
UFL geometry representation: The pseudo-determinant of the CellFacetJacobian.
-
is_cellwise_constant
()¶ Return whether this expression is spatially constant over each cell.
-
name
= 'detCFJ'¶
-
-
class
ufl.geometry.
CellFacetJacobianInverse
(domain)¶ Bases:
ufl.geometry.GeometricFacetQuantity
UFL geometry representation: The pseudo-inverse of the CellFacetJacobian.
-
is_cellwise_constant
()¶ Return whether this expression is spatially constant over each cell.
-
name
= 'CFK'¶
-
ufl_shape
¶
-
-
class
ufl.geometry.
CellFacetOrigin
(domain)¶ Bases:
ufl.geometry.GeometricFacetQuantity
UFL geometry representation: The reference cell coordinate corresponding to origin of a reference facet.
-
name
= 'X0f'¶
-
ufl_shape
¶
-
-
class
ufl.geometry.
CellNormal
(domain)¶ Bases:
ufl.geometry.GeometricCellQuantity
UFL geometry representation: The upwards pointing normal vector of the current manifold cell.
-
name
= 'cell_normal'¶
-
ufl_shape
¶
-
-
class
ufl.geometry.
CellOrientation
(domain)¶ Bases:
ufl.geometry.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)¶ Bases:
ufl.geometry.GeometricCellQuantity
UFL geometry representation: The spatial coordinate corresponding to origin of a reference cell.
-
is_cellwise_constant
()¶
-
name
= 'x0'¶
-
ufl_shape
¶
-
-
class
ufl.geometry.
CellVolume
(domain)¶ Bases:
ufl.geometry.GeometricCellQuantity
UFL geometry representation: The volume of the cell.
-
name
= 'volume'¶
-
-
class
ufl.geometry.
Circumradius
(domain)¶ Bases:
ufl.geometry.GeometricCellQuantity
UFL geometry representation: The circumradius of the cell.
-
name
= 'circumradius'¶
-
-
class
ufl.geometry.
FacetArea
(domain)¶ Bases:
ufl.geometry.GeometricFacetQuantity
UFL geometry representation: The area of the facet.
-
name
= 'facetarea'¶
-
-
class
ufl.geometry.
FacetCoordinate
(domain)¶ Bases:
ufl.geometry.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
()¶ Return whether this expression is spatially constant over each cell.
-
name
= 'Xf'¶
-
ufl_shape
¶
-
-
class
ufl.geometry.
FacetEdgeVectors
(domain)¶ Bases:
ufl.geometry.GeometricFacetQuantity
UFL geometry representation: The vectors between reference cell vertices for each edge in current facet.
-
is_cellwise_constant
()¶ Return whether this expression is spatially constant over each cell.
-
name
= 'FEV'¶
-
ufl_shape
¶
-
-
class
ufl.geometry.
FacetJacobian
(domain)¶ Bases:
ufl.geometry.GeometricFacetQuantity
UFL geometry representation: The Jacobian of the mapping from reference facet to spatial coordinates.
FJ_ij = dx_i/dXf_jThe FacetJacobian is the product of the Jacobian and CellFacetJacobian:
FJ = dx/dXf = dx/dX dX/dXf = J * CFJ-
is_cellwise_constant
()¶ Return whether this expression is spatially constant over each cell.
-
name
= 'FJ'¶
-
ufl_shape
¶
-
-
class
ufl.geometry.
FacetJacobianDeterminant
(domain)¶ Bases:
ufl.geometry.GeometricFacetQuantity
UFL geometry representation: The pseudo-determinant of the FacetJacobian.
-
is_cellwise_constant
()¶ Return whether this expression is spatially constant over each cell.
-
name
= 'detFJ'¶
-
-
class
ufl.geometry.
FacetJacobianInverse
(domain)¶ Bases:
ufl.geometry.GeometricFacetQuantity
UFL geometry representation: The pseudo-inverse of the FacetJacobian.
-
is_cellwise_constant
()¶ Return whether this expression is spatially constant over each cell.
-
name
= 'FK'¶
-
ufl_shape
¶
-
-
class
ufl.geometry.
FacetNormal
(domain)¶ Bases:
ufl.geometry.GeometricFacetQuantity
UFL geometry representation: The outwards pointing normal vector of the current facet.
-
is_cellwise_constant
()¶ Return whether this expression is spatially constant over each cell.
-
name
= 'n'¶
-
ufl_shape
¶
-
-
class
ufl.geometry.
FacetOrientation
(domain)¶ Bases:
ufl.geometry.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)¶ Bases:
ufl.geometry.GeometricFacetQuantity
UFL geometry representation: The spatial coordinate corresponding to origin of a reference facet.
-
name
= 'x0f'¶
-
ufl_shape
¶
-
-
class
ufl.geometry.
GeometricCellQuantity
(domain)¶
-
class
ufl.geometry.
GeometricFacetQuantity
(domain)¶
-
class
ufl.geometry.
GeometricQuantity
(domain)¶ Bases:
ufl.core.terminal.Terminal
-
domains
()¶
-
is_cellwise_constant
()¶ Return whether this expression is spatially constant over each cell (or over each facet for facet quantities).
-
signature_data
(renumbering)¶ Signature data of geometric quantities depend on the domain numbering.
-
ufl_shape
= ()¶
-
-
class
ufl.geometry.
Jacobian
(domain)¶ Bases:
ufl.geometry.GeometricCellQuantity
UFL geometry representation: The Jacobian of the mapping from reference cell to spatial coordinates.
J_ij = dx_i/dX_j
-
is_cellwise_constant
()¶ Return whether this expression is spatially constant over each cell.
-
name
= 'J'¶
-
ufl_shape
¶
-
-
class
ufl.geometry.
JacobianDeterminant
(domain)¶ Bases:
ufl.geometry.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
()¶ Return whether this expression is spatially constant over each cell.
-
name
= 'detJ'¶
-
-
class
ufl.geometry.
JacobianInverse
(domain)¶ Bases:
ufl.geometry.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
()¶ Return whether this expression is spatially constant over each cell.
-
name
= 'K'¶
-
ufl_shape
¶
-
-
class
ufl.geometry.
MaxCellEdgeLength
(domain)¶ Bases:
ufl.geometry.GeometricCellQuantity
UFL geometry representation: The maximum edge length of the cell.
-
name
= 'maxcelledgelength'¶
-
-
class
ufl.geometry.
MaxFacetEdgeLength
(domain)¶ Bases:
ufl.geometry.GeometricFacetQuantity
UFL geometry representation: The maximum edge length of the facet.
-
name
= 'maxfacetedgelength'¶
-
-
class
ufl.geometry.
MinCellEdgeLength
(domain)¶ Bases:
ufl.geometry.GeometricCellQuantity
UFL geometry representation: The minimum edge length of the cell.
-
name
= 'mincelledgelength'¶
-
-
class
ufl.geometry.
MinFacetEdgeLength
(domain)¶ Bases:
ufl.geometry.GeometricFacetQuantity
UFL geometry representation: The minimum edge length of the facet.
-
name
= 'minfacetedgelength'¶
-
-
class
ufl.geometry.
QuadratureWeight
(domain)¶ Bases:
ufl.geometry.GeometricQuantity
UFL geometry representation: The current quadrature weight.
Only used inside a quadrature context.
-
is_cellwise_constant
()¶ Return whether this expression is spatially constant over each cell.
-
name
= 'weight'¶
-
-
class
ufl.geometry.
SpatialCoordinate
(domain)¶ Bases:
ufl.geometry.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.
-
evaluate
(x, mapping, component, index_values)¶
-
is_cellwise_constant
()¶ Return whether this expression is spatially constant over each cell.
-
name
= 'x'¶
-
ufl_shape
¶
-
index_combination_utils
Module¶
Utilities for analysing and manipulating free index tuples
-
ufl.index_combination_utils.
create_slice_indices
(component, shape, fi)¶
-
ufl.index_combination_utils.
merge_nonoverlapping_indices
(a, b)¶ Merge non-overlapping free indices into one representation.
- Example:
- 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)¶ Merge overlapping free indices into one free and one repeated representation.
- Example:
- 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)¶ 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.index_combination_utils.
remove_indices
(fi, fid, rfi)¶
-
ufl.index_combination_utils.
unique_sorted_indices
(indices)¶ 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.
indexed
Module¶
This module defines the Indexed class.
indexing
Module¶
This module defines the single index types and some internal index utilities.
indexsum
Module¶
This module defines the IndexSum class.
integral
Module¶
The Integral class.
-
class
ufl.integral.
Integral
(integrand, integral_type, domain, subdomain_id, metadata, subdomain_data)¶ Bases:
object
An integral over a single domain.
-
domain
()¶ Return the integration domain of this integral.
-
integral_type
()¶ Return the domain type of this integral.
-
integrand
()¶ Return the integrand expression, which is an Expr instance.
-
metadata
()¶ Return the compiler metadata this integral has been annotated with.
-
reconstruct
(integrand=None, integral_type=None, domain=None, subdomain_id=None, metadata=None, subdomain_data=None)¶ Construct a new Integral object with some properties replaced with new values.
- Example:
- <a = Integral instance> b = a.reconstruct(expand_compounds(a.integrand())) c = a.reconstruct(metadata={‘quadrature_degree’:2})
-
subdomain_data
()¶ Return the domain data of this integral.
-
subdomain_id
()¶ Return the subdomain id of this integral.
-
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=<type 'exceptions.Exception'>)¶ Create logger instance.
-
add_indent
(increment=1)¶ Add to indentation level.
-
add_logfile
(filename=None, mode='a', level=10)¶
-
begin
(*message)¶ Begin task: write message and increase indentation level.
-
debug
(*message)¶ Write debug message.
-
deprecate
(*message)¶ Write deprecation message.
-
end
()¶ End task: write a newline and decrease indentation level.
-
error
(*message)¶ Write error message and raise an exception.
-
get_handler
()¶ Get handler for logging.
-
get_logfile_handler
(filename)¶
-
get_logger
()¶ Return message logger.
-
info
(*message)¶ Write info message.
-
info_blue
(*message)¶ Write info message in blue.
-
info_green
(*message)¶ Write info message in green.
-
info_red
(*message)¶ Write info message in red.
-
log
(level, *message)¶ Write a log message on given log level
-
pop_level
()¶ Pop log level from the level stack, reverting to before the last push_level.
-
push_level
(level)¶ Push a log level on the level stack.
-
set_handler
(handler)¶ Replace handler for logging. To add additional handlers instead of replacing the existing, use log.get_logger().addHandler(myhandler). See the logging module for more details.
-
set_indent
(level)¶ Set indentation level.
-
set_level
(level)¶ Set log level.
-
set_prefix
(prefix)¶ Set prefix for log messages.
-
warning
(*message)¶ Write warning message.
-
warning_blue
(*message)¶ Write warning message in blue.
-
warning_green
(*message)¶ Write warning message in green.
-
warning_red
(*message)¶ Write warning message in red.
-
mathfunctions
Module¶
This module provides basic mathematical functions.
-
class
ufl.mathfunctions.
Acos
(argument)¶
-
class
ufl.mathfunctions.
Asin
(argument)¶
-
class
ufl.mathfunctions.
Atan
(argument)¶
-
class
ufl.mathfunctions.
Atan2
(arg1, arg2)¶ Bases:
ufl.core.operator.Operator
-
evaluate
(x, mapping, component, index_values)¶
-
free_indices
()¶
-
index_dimensions
()¶
-
shape
()¶
-
ufl_free_indices
= ()¶
-
ufl_index_dimensions
= ()¶
-
ufl_shape
= ()¶
-
-
class
ufl.mathfunctions.
BesselFunction
(name, classname, nu, argument)¶ Bases:
ufl.core.operator.Operator
Base class for all bessel functions
-
evaluate
(x, mapping, component, index_values)¶
-
free_indices
()¶
-
index_dimensions
()¶
-
shape
()¶
-
ufl_free_indices
= ()¶
-
ufl_index_dimensions
= ()¶
-
ufl_shape
= ()¶
-
-
class
ufl.mathfunctions.
BesselI
(nu, argument)¶
-
class
ufl.mathfunctions.
BesselJ
(nu, argument)¶
-
class
ufl.mathfunctions.
BesselK
(nu, argument)¶
-
class
ufl.mathfunctions.
BesselY
(nu, argument)¶
-
class
ufl.mathfunctions.
Cos
(argument)¶
-
class
ufl.mathfunctions.
Cosh
(argument)¶
-
class
ufl.mathfunctions.
Erf
(argument)¶ Bases:
ufl.mathfunctions.MathFunction
-
evaluate
(x, mapping, component, index_values)¶
-
-
class
ufl.mathfunctions.
Exp
(argument)¶
-
class
ufl.mathfunctions.
Ln
(argument)¶ Bases:
ufl.mathfunctions.MathFunction
-
evaluate
(x, mapping, component, index_values)¶
-
-
class
ufl.mathfunctions.
MathFunction
(name, argument)¶ Bases:
ufl.core.operator.Operator
Base class for all unary scalar math functions.
-
evaluate
(x, mapping, component, index_values)¶
-
free_indices
()¶
-
index_dimensions
()¶
-
shape
()¶
-
ufl_free_indices
= ()¶
-
ufl_index_dimensions
= ()¶
-
ufl_shape
= ()¶
-
-
class
ufl.mathfunctions.
Sin
(argument)¶
-
class
ufl.mathfunctions.
Sinh
(argument)¶
-
class
ufl.mathfunctions.
Sqrt
(argument)¶
-
class
ufl.mathfunctions.
Tan
(argument)¶
-
class
ufl.mathfunctions.
Tanh
(argument)¶
measure
Module¶
The Measure class.
-
class
ufl.measure.
Measure
(integral_type, domain=None, subdomain_id='everywhere', metadata=None, subdomain_data=None)¶ Bases:
object
- integral_type:
- str, one of “cell”, etc., or short form “dx”, etc.
- domain:
- a Domain object (includes cell, dims, label, domain data)
- subdomain_id:
- either string “everywhere”, a single subdomain id int, or tuple of ints
- metadata
- dict, with additional compiler-specific parameters affecting how code is generated, including parameters for optimization or debugging of generated code.
- subdomain_data
- object representing data to interpret subdomain_id with.
-
CELL
= 'cell'¶
-
EXTERIOR_FACET
= 'exterior_facet'¶
-
EXTERIOR_FACET_BOTTOM
= 'exterior_facet_bottom'¶
-
EXTERIOR_FACET_TOP
= 'exterior_facet_top'¶
-
EXTERIOR_FACET_VERT
= 'exterior_facet_vert'¶
-
INTERIOR_FACET
= 'interior_facet'¶
-
INTERIOR_FACET_HORIZ
= 'interior_facet_horiz'¶
-
INTERIOR_FACET_VERT
= 'interior_facet_vert'¶
-
MACRO_CELL
= 'macro_cell'¶
-
POINT
= 'point'¶
-
QUADRATURE
= 'quadrature'¶
-
SURFACE
= 'surface'¶
-
domain
()¶ Return the domain associated with this measure.
This may be None or a Domain object.
-
integral_type
()¶ Return the domain type.
Valid domain types are “cell”, “exterior_facet”, “interior_facet”, etc.
-
metadata
()¶ 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)¶ Construct a new Measure object with some properties replaced with new values.
- Example:
- <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 })
-
subdomain_data
()¶ Return the integral subdomain_data. This data is not interpreted by UFL. Its intension is to give a context in which the domain id is interpreted.
-
subdomain_id
()¶ Return the domain id of this measure (integer).
-
class
ufl.measure.
MeasureProduct
(*measures)¶ 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.
Create MeasureProduct from given list of measures.
-
sub_measures
()¶ Return submeasures.
-
-
class
ufl.measure.
MeasureSum
(*measures)¶ 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.measure.
as_integral_type
(integral_type)¶ Map short name to long name and require a valid one.
-
ufl.measure.
integral_types
()¶ Return a tuple of all domain type strings.
-
ufl.measure.
measure_names
()¶ Return a tuple of all measure name strings.
-
ufl.measure.
register_integral_type
(integral_type, measure_name)¶
objects
Module¶
Utility objects for pretty syntax in user code.
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)¶ UFL operator: A boolean expresion (left and right) for use with conditional.
-
ufl.operators.
Dn
(f)¶ UFL operator: Take the directional derivative of f in the facet normal direction, Dn(f) := dot(grad(f), n).
-
ufl.operators.
Dt
(f)¶ UFL operator: <Not implemented yet!> The partial derivative of f with respect to time.
-
ufl.operators.
Dx
(f, *i)¶ UFL operator: Take the partial derivative of f with respect to spatial variable number i. Equivalent to f.dx(*i).
-
ufl.operators.
Max
(x, y)¶ UFL operator: Take the maximum of x and y.
-
ufl.operators.
Min
(x, y)¶ UFL operator: Take the minimum of x and y.
-
ufl.operators.
Not
(condition)¶ UFL operator: A boolean expresion (not condition) for use with conditional.
-
ufl.operators.
Or
(left, right)¶ UFL operator: A boolean expresion (left or right) for use with conditional.
-
ufl.operators.
acos
(f)¶ UFL operator: Take the inverse cosinus of f.
-
ufl.operators.
asin
(f)¶ UFL operator: Take the inverse sinus of f.
-
ufl.operators.
atan
(f)¶ UFL operator: Take the inverse tangent of f.
-
ufl.operators.
atan_2
(f1, f2)¶ UFL operator: Take the inverse tangent of f.
-
ufl.operators.
avg
(v)¶ UFL operator: Take the average of v across a facet.
-
ufl.operators.
bessel_I
(nu, f)¶ UFL operator: regular modified cylindrical Bessel function.
-
ufl.operators.
bessel_J
(nu, f)¶ UFL operator: cylindrical Bessel function of the first kind.
-
ufl.operators.
bessel_K
(nu, f)¶ UFL operator: irregular modified cylindrical Bessel function.
-
ufl.operators.
bessel_Y
(nu, f)¶ UFL operator: cylindrical Bessel function of the second kind.
-
ufl.operators.
cell_avg
(f)¶ UFL operator: Take the average of v over a cell.
-
ufl.operators.
cofac
(A)¶ UFL operator: Take the cofactor of A.
-
ufl.operators.
conditional
(condition, true_value, false_value)¶ UFL operator: A conditional expression, taking the value of true_value when condition evaluates to true and false_value otherwise.
-
ufl.operators.
contraction
(a, a_axes, b, b_axes)¶ UFL operator: Take the contraction of a and b over given axes.
-
ufl.operators.
cos
(f)¶ UFL operator: Take the cosinus of f.
-
ufl.operators.
cosh
(f)¶ UFL operator: Take the cosinus hyperbolicus of f.
-
ufl.operators.
cross
(a, b)¶ UFL operator: Take the cross product of a and b.
-
ufl.operators.
curl
(f)¶ UFL operator: Take the curl of f.
-
ufl.operators.
det
(A)¶ UFL operator: Take the determinant of A.
-
ufl.operators.
dev
(A)¶ UFL operator: Take the deviatoric part of A.
-
ufl.operators.
diag
(A)¶ 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)¶ UFL operator: Take the diagonal part of rank 2 tensor A and return as a vector.
See also diag.
-
ufl.operators.
diff
(f, v)¶ 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)¶ 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)¶ UFL operator: Take the dot product of a and b.
-
ufl.operators.
elem_div
(A, B)¶ UFL operator: Take the elementwise division of the tensors A and B with the same shape.
-
ufl.operators.
elem_mult
(A, B)¶ UFL operator: Take the elementwise multiplication of the tensors A and B with the same shape.
-
ufl.operators.
elem_op
(op, *args)¶ UFL operator: Take the elementwise application of operator op on scalar values from one or more tensor arguments.
-
ufl.operators.
elem_op_items
(op_ind, indices, *args)¶
-
ufl.operators.
elem_pow
(A, B)¶ UFL operator: Take the elementwise power of the tensors A and B with the same shape.
-
ufl.operators.
eq
(left, right)¶ UFL operator: A boolean expresion (left == right) for use with conditional.
-
ufl.operators.
erf
(f)¶ UFL operator: Take the error function of f.
-
ufl.operators.
exp
(f)¶ UFL operator: Take the exponential of f.
-
ufl.operators.
exterior_derivative
(f)¶ UFL operator: Take the exterior derivative of f.
The exterior derivative uses the element family to determine whether id, grad, curl or div should be used.
Note that this uses the ‘grad’ and ‘div’ operators, as opposed to ‘nabla_grad’ and ‘nabla_div’.
-
ufl.operators.
facet_avg
(f)¶ UFL operator: Take the average of v over a facet.
-
ufl.operators.
ge
(left, right)¶ UFL operator: A boolean expresion (left >= right) for use with conditional.
-
ufl.operators.
grad
(f)¶ 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)¶ UFL operator: A boolean expresion (left > right) for use with conditional.
-
ufl.operators.
inner
(a, b)¶ UFL operator: Take the inner product of a and b.
-
ufl.operators.
inv
(A)¶ UFL operator: Take the inverse of A.
-
ufl.operators.
jump
(v, n=None)¶ UFL operator: Take the jump of v across a facet.
-
ufl.operators.
le
(left, right)¶ UFL operator: A boolean expresion (left <= right) for use with conditional.
-
ufl.operators.
ln
(f)¶ UFL operator: Take the natural logarithm of f.
-
ufl.operators.
lt
(left, right)¶ UFL operator: A boolean expresion (left < right) for use with conditional.
-
ufl.operators.
max_value
(x, y)¶ UFL operator: Take the maximum of x and y.
-
ufl.operators.
min_value
(x, y)¶ UFL operator: Take the minimum of x and y.
-
ufl.operators.
nabla_div
(f)¶ 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)¶ 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)¶ UFL operator: A boolean expresion (left != right) for use with conditional.
-
ufl.operators.
outer
(*operands)¶ UFL operator: Take the outer product of two or more operands.
-
ufl.operators.
perp
(v)¶ UFL operator: Take the perp of v, i.e. (-v1, +v0).
-
ufl.operators.
rank
(f)¶ UFL operator: The rank of f.
-
ufl.operators.
rot
(f)¶ UFL operator: Take the curl of f.
-
ufl.operators.
shape
(f)¶ UFL operator: The shape of f.
-
ufl.operators.
sign
(x)¶ UFL operator: Take the sign (+1 or -1) of x.
-
ufl.operators.
sin
(f)¶ UFL operator: Take the sinus of f.
-
ufl.operators.
sinh
(f)¶ UFL operator: Take the sinus hyperbolicus of f.
-
ufl.operators.
skew
(A)¶ UFL operator: Take the skew symmetric part of A.
-
ufl.operators.
sqrt
(f)¶ UFL operator: Take the square root of f.
-
ufl.operators.
sym
(A)¶ UFL operator: Take the symmetric part of A.
-
ufl.operators.
tan
(f)¶ UFL operator: Take the tangent of f.
-
ufl.operators.
tanh
(f)¶ UFL operator: Take the tangent hyperbolicus of f.
-
ufl.operators.
tr
(A)¶ UFL operator: Take the trace of A.
-
ufl.operators.
transpose
(A)¶ UFL operator: Take the transposed of tensor A.
-
ufl.operators.
variable
(e)¶ UFL operator: Define a variable representing the given expression, see also diff().
permutation
Module¶
This module provides utility functions for computing permutations and generating index lists.
-
ufl.permutation.
build_component_numbering
(shape, symmetry)¶ 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_indices
(shape)¶ Compute all index combinations for given shape
-
ufl.permutation.
compute_indices2
(shape)¶ Compute all index combinations for given shape
-
ufl.permutation.
compute_order_tuples
(k, n)¶ Compute all tuples of n integers such that the sum is k
-
ufl.permutation.
compute_permutation_pairs
(j, k)¶ Compute all permutations of j + k elements from (0, j + k) in rising order within (0, j) and (j, j + k) respectively.
-
ufl.permutation.
compute_permutations
(k, n, skip=None)¶ Compute all permutations of k elements from (0, n) in rising order. Any elements that are contained in the list skip are not included.
-
ufl.permutation.
compute_sign
(permutation)¶ Compute sign by sorting.
precedence
Module¶
Precedence handling.
-
ufl.precedence.
assign_precedences
(precedence_list)¶ Given a precedence list, assign ints to class._precedence.
-
ufl.precedence.
build_precedence_list
()¶
-
ufl.precedence.
build_precedence_mapping
(precedence_list)¶ Given a precedence list, build a dict with class->int mappings. Utility function used by some external code.
-
ufl.precedence.
parstr
(child, parent, pre='(', post=')', format=<type 'str'>)¶
protocols
Module¶
-
ufl.protocols.
id_or_none
(obj)¶ Returns None if the object is None, obj.ufl_id() if available, or id(obj) if not.
This allows external libraries to implement an alternative to id(obj) in the ufl_id() function, such that ufl can identify objects as the same without knowing about their types.
-
ufl.protocols.
metadata_equal
(a, b)¶
-
ufl.protocols.
metadata_hashdata
(md)¶
referencevalue
Module¶
Representation of the reference value of a function.
-
class
ufl.referencevalue.
ReferenceValue
(f)¶ Bases:
ufl.core.operator.Operator
Representation of the reference cell value of a form argument.
-
evaluate
(x, mapping, component, index_values, derivatives=())¶ Get child from mapping and return the component asked for.
-
free_indices
()¶
-
index_dimensions
()¶
-
reconstruct
(op)¶ Return a new object of the same type with new operands.
-
ufl_free_indices
= ()¶
-
ufl_index_dimensions
= ()¶
-
ufl_shape
¶
-
restriction
Module¶
Restriction operations.
-
class
ufl.restriction.
CellAvg
(f)¶ Bases:
ufl.core.operator.Operator
-
evaluate
(x, mapping, component, index_values)¶ Performs an approximate symbolic evaluation, since we dont have a cell.
-
free_indices
()¶
-
index_dimensions
()¶
-
ufl_free_indices
= ()¶
-
ufl_index_dimensions
= ()¶
-
ufl_shape
¶
-
-
class
ufl.restriction.
FacetAvg
(f)¶ Bases:
ufl.core.operator.Operator
-
evaluate
(x, mapping, component, index_values)¶ Performs an approximate symbolic evaluation, since we dont have a cell.
-
free_indices
()¶
-
index_dimensions
()¶
-
ufl_free_indices
= ()¶
-
ufl_index_dimensions
= ()¶
-
ufl_shape
¶
-
-
class
ufl.restriction.
NegativeRestricted
(f)¶ Bases:
ufl.restriction.Restricted
-
class
ufl.restriction.
PositiveRestricted
(f)¶ Bases:
ufl.restriction.Restricted
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.
SobolevSpace
(name, parents=None)¶ Bases:
object
Symbolic representation of a Sobolev space. This implements a subset of the methods of a Python set so that finite elements and other Sobolev spaces can be tested for inclusion.
Instantiate a SobolevSpace object.
Parameters: - name – The name of this space,
- parents – A set of Sobolev spaces of which this
space is a subspace.
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)¶
-
ufl.sorting.
cmp_expr2
(a, b)¶ Sorting rule for Expr objects. NB! Do not use to compare for equality!
-
ufl.sorting.
sorted_expr
(seq)¶
-
ufl.sorting.
sorted_expr_sum
(seq)¶
split_functions
Module¶
Algorithm for splitting a Coefficient or Argument into subfunctions.
-
ufl.split_functions.
split
(v)¶ UFL operator: If v is a Coefficient or Argument in a mixed space, returns a tuple with the function components corresponding to the subelements.
tensoralgebra
Module¶
Compound tensor algebra operations.
-
class
ufl.tensoralgebra.
Cofactor
(A)¶ Bases:
ufl.tensoralgebra.CompoundTensorOperator
-
free_indices
()¶
-
index_dimensions
()¶
-
ufl_free_indices
= ()¶
-
ufl_index_dimensions
= ()¶
-
ufl_shape
¶
-
-
class
ufl.tensoralgebra.
CompoundTensorOperator
(operands)¶ Bases:
ufl.core.operator.Operator
-
class
ufl.tensoralgebra.
Cross
(a, b)¶ Bases:
ufl.tensoralgebra.CompoundTensorOperator
-
ufl_free_indices
¶
-
ufl_index_dimensions
¶
-
ufl_shape
= (3,)¶
-
-
class
ufl.tensoralgebra.
Determinant
(A)¶ Bases:
ufl.tensoralgebra.CompoundTensorOperator
-
free_indices
()¶
-
index_dimensions
()¶
-
shape
()¶
-
ufl_free_indices
= ()¶
-
ufl_index_dimensions
= ()¶
-
ufl_shape
= ()¶
-
-
class
ufl.tensoralgebra.
Deviatoric
(A)¶ Bases:
ufl.tensoralgebra.CompoundTensorOperator
-
free_indices
()¶
-
index_dimensions
()¶
-
shape
()¶
-
ufl_free_indices
¶
-
ufl_index_dimensions
¶
-
ufl_shape
¶
-
-
class
ufl.tensoralgebra.
Dot
(a, b)¶ Bases:
ufl.tensoralgebra.CompoundTensorOperator
-
ufl_free_indices
¶
-
ufl_index_dimensions
¶
-
ufl_shape
¶
-
-
class
ufl.tensoralgebra.
Inner
(a, b)¶ Bases:
ufl.tensoralgebra.CompoundTensorOperator
-
ufl_free_indices
¶
-
ufl_index_dimensions
¶
-
ufl_shape
= ()¶
-
-
class
ufl.tensoralgebra.
Inverse
(A)¶ Bases:
ufl.tensoralgebra.CompoundTensorOperator
-
free_indices
()¶
-
index_dimensions
()¶
-
ufl_free_indices
= ()¶
-
ufl_index_dimensions
= ()¶
-
ufl_shape
¶
-
-
class
ufl.tensoralgebra.
Outer
(a, b)¶ Bases:
ufl.tensoralgebra.CompoundTensorOperator
-
ufl_free_indices
¶
-
ufl_index_dimensions
¶
-
ufl_shape
¶
-
-
class
ufl.tensoralgebra.
Skew
(A)¶ Bases:
ufl.tensoralgebra.CompoundTensorOperator
-
free_indices
()¶
-
index_dimensions
()¶
-
shape
()¶
-
ufl_free_indices
¶
-
ufl_index_dimensions
¶
-
ufl_shape
¶
-
-
class
ufl.tensoralgebra.
Sym
(A)¶ Bases:
ufl.tensoralgebra.CompoundTensorOperator
-
free_indices
()¶
-
index_dimensions
()¶
-
shape
()¶
-
ufl_free_indices
¶
-
ufl_index_dimensions
¶
-
ufl_shape
¶
-
tensors
Module¶
Classes used to group scalar expressions into expressions with rank > 0.
-
class
ufl.tensors.
ComponentTensor
(expression, indices)¶ Bases:
ufl.core.operator.Operator
UFL operator type: Maps the free indices of a scalar valued expression to tensor axes.
-
evaluate
(x, mapping, component, index_values)¶
-
indices
()¶
-
is_cellwise_constant
()¶ Return whether this expression is spatially constant over each cell.
-
reconstruct
(expressions, indices)¶
-
ufl_free_indices
¶
-
ufl_index_dimensions
¶
-
ufl_shape
¶
-
-
class
ufl.tensors.
ListTensor
(*expressions)¶ Bases:
ufl.core.operator.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=())¶
-
free_indices
()¶
-
index_dimensions
()¶
-
is_cellwise_constant
()¶ Return whether this expression is spatially constant over each cell.
-
ufl_free_indices
¶
-
ufl_index_dimensions
¶
-
ufl_shape
¶
-
-
ufl.tensors.
as_matrix
(expressions, indices=None)¶ UFL operator: As as_tensor(), but limited to rank 2 tensors.
-
ufl.tensors.
as_scalar
(expression)¶ Given a scalar or tensor valued expression A, returns either of the tuples:
(a,b) = (A, ()) (a,b) = (A[indices], indices)
such that a is always a scalar valued expression.
-
ufl.tensors.
as_scalars
(*expressions)¶ Given multiple scalar or tensor valued expressions A, returns either of the tuples:
(a,b) = (A, ()) (a,b) = ([A[0][indices], ..., A[-1][indices]], indices)
such that a is always a list of scalar valued expressions.
-
ufl.tensors.
as_tensor
(expressions, indices=None)¶ UFL operator: Make a tensor valued expression.
This works in two different ways, by using indices or lists.
1) Returns A such that A[indices] = expressions. If indices are provided, expressions must be a scalar valued expression with all the provided indices among its free indices. This operator will then map each of these indices to a tensor axis, thereby making a tensor valued expression from a scalar valued expression with free indices.
2) Returns A such that A[k,...] = expressions[k]. If no indices are provided, expressions must be a list or tuple of expressions. The expressions can also consist of recursively nested lists to build higher rank tensors.
-
ufl.tensors.
as_vector
(expressions, index=None)¶ UFL operator: As as_tensor(), but limited to rank 1 tensors.
-
ufl.tensors.
dyad
(d, *iota)¶ TODO: Develop this concept, can e.g. write A[i,j]*dyad(j,i) for the transpose.
-
ufl.tensors.
from_numpy_to_lists
(expressions)¶
-
ufl.tensors.
numpy2nestedlists
(arr)¶
-
ufl.tensors.
relabel
(A, indexmap)¶ UFL operator: Relabel free indices of A with new indices, using the given mapping.
-
ufl.tensors.
unit_indexed_tensor
(shape, component)¶
-
ufl.tensors.
unit_list
(i, n)¶
-
ufl.tensors.
unit_list2
(i, j, n)¶
-
ufl.tensors.
unit_matrices
(d)¶ UFL value: A tuple of constant unit matrices in all directions with dimension d.
-
ufl.tensors.
unit_matrix
(i, j, d)¶ UFL value: A constant unit matrix in direction i,j with dimension d.
-
ufl.tensors.
unit_vector
(i, d)¶ UFL value: A constant unit vector in direction i with dimension d.
-
ufl.tensors.
unit_vectors
(d)¶ UFL value: A tuple of constant unit vectors in all directions with dimension d.
-
ufl.tensors.
unwrap_list_tensor
(lt)¶
variable
Module¶
Defines the Variable and Label classes, used to label expressions as variables for differentiation.
-
class
ufl.variable.
Label
(count=None)¶ Bases:
ufl.core.terminal.Terminal
-
count
()¶
-
domains
()¶ Return tuple of domains related to this terminal object.
-
is_cellwise_constant
()¶
-
ufl_free_indices
¶
-
ufl_index_dimensions
¶
-
ufl_shape
¶
-
-
class
ufl.variable.
Variable
(expression, label=None)¶ Bases:
ufl.core.operator.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)
-
domains
()¶
-
evaluate
(x, mapping, component, index_values)¶
-
expression
()¶
-
free_indices
()¶
-
index_dimensions
()¶
-
is_cellwise_constant
()¶
-
label
()¶
-
shape
()¶
-
ufl_free_indices
= ()¶
-
ufl_index_dimensions
= ()¶
-
ufl_shape
¶
-
Subpackages¶
- algorithms Package
algorithms
Packagead
Moduleanalysis
Moduleapply_derivatives
Moduleapply_restrictions
Moduleargument_dependencies
Modulechange_to_reference
Modulecheck_arities
Modulechecks
Modulecompute_form_data
Moduledomain_analysis
Moduleelementtransformations
Moduleestimate_degrees
Moduleexpand_compounds
Moduleexpand_indices
Moduleformdata
Moduleformfiles
Moduleformtransformations
Moduleforward_ad
Modulegraph
Modulelatextools
Modulemap_integrands
Modulemultifunction
Modulepdiffs
Modulepredicates
Moduleprinting
Modulepropagate_restrictions
Modulerenumbering
Modulereplace
Modulesignature
Moduletransformer
Moduletraversal
Moduleufl2dot
Moduleufl2latex
Module
- core Package
- corealg Package
- finiteelement Package
- utils Package