ufl.formatting package

Submodules

ufl.formatting.graph module

Algorithms for working with linearized computational graphs.

class ufl.formatting.graph.Graph(expression)[source]

Bases: object

Graph class which computes connectivity on demand.

E()[source]
Ein()[source]
Eout()[source]
V()[source]
Vin()[source]
Vout()[source]
class ufl.formatting.graph.HeapItem(incoming, outgoing, i)[source]

Bases: object

class ufl.formatting.graph.StringDependencyDefiner(argument_deps=None, coefficient_deps=None)[source]

Bases: MultiFunction

Given an expr, returns a frozenset of its dependencies.

Possible dependency values are:

“c” - depends on runtime information like the cell, local<->global coordinate mappings, facet normals, or coefficients “x” - depends on local coordinates “v%d” % i - depends on argument i, for i in [0,rank)

argument(x)[source]
coefficient(x)[source]
expr(o)[source]

Trigger error for types with missing handlers.

facet_normal(o)[source]
geometric_quantity(x)[source]
spatial_derivative(o)[source]
ufl.formatting.graph.build_graph(expr)[source]

Build a linearized graph from an UFL Expr.

Returns G = (V, E), with V being a list of graph nodes (Expr objects) in post traversal ordering and E being a list of edges. Each edge is represented as a (i, j) tuple where i and j are vertex indices into V.

ufl.formatting.graph.depth_first_ordering(G)[source]
ufl.formatting.graph.extract_incoming_edges(G)[source]

Build lists of incoming edges to each vertex in a linearized graph.

ufl.formatting.graph.extract_incoming_vertex_connections(G)[source]

Build lists of vertices in incoming and outgoing edges to and from each vertex in a linearized graph.

Returns lists Vin and Vout.

ufl.formatting.graph.extract_outgoing_edges(G)[source]

Build list of outgoing edges from each vertex in a linearized graph.

ufl.formatting.graph.extract_outgoing_vertex_connections(G)[source]

Build lists of vertices in incoming and outgoing edges to and from each vertex in a linearized graph.

Returns lists Vin and Vout.

ufl.formatting.graph.len_items(sequence)[source]
ufl.formatting.graph.lists(n)[source]
ufl.formatting.graph.partition(G, criteria=<function string_set_criteria>)[source]
ufl.formatting.graph.string_set_criteria(v, keys)[source]

ufl.formatting.printing module

A collection of utility algorithms for printing of UFL objects, mostly intended for debugging purposes.

ufl.formatting.printing.form_info(form)[source]
ufl.formatting.printing.integral_info(integral)[source]
ufl.formatting.printing.tree_format(expression, indentation=0, parentheses=True)[source]

ufl.formatting.ufl2dot module

A collection of utility algorithms for printing of UFL objects in the DOT graph visualization language, mostly intended for debugging purposers.

class ufl.formatting.ufl2dot.CompactLabeller(function_mapping=None)[source]

Bases: ReprLabeller

cell_avg(e)[source]
component_tensor(e)[source]
conj(e)[source]
curl(e)[source]
determinant(e)[source]
dev(e)[source]
diff(e)[source]
div(e)[source]
division(e)[source]
dot(e)[source]
facet_avg(e)[source]
form_argument(e)[source]
geometric_quantity(e)[source]
grad(e)[source]
identity(e)[source]
imag(e)[source]
index_sum(e)[source]
indexed(e)[source]
inner(e)[source]
math_function(e)[source]
multi_index(e)[source]
nabla_div(e)[source]
nabla_grad(e)[source]
negative_restricted(e)[source]
outer(e)[source]
positive_restricted(e)[source]
power(e)[source]
product(e)[source]
real(e)[source]
scalar_value(e)[source]
skew(e)[source]
sum(e)[source]
trace(e)[source]
transposed(e)[source]
zero(e)[source]
class ufl.formatting.ufl2dot.FancyLabeller(function_mapping=None)[source]

Bases: CompactLabeller

class ufl.formatting.ufl2dot.ReprLabeller[source]

Bases: MultiFunction

operator(e)[source]
terminal(e)[source]
ufl.formatting.ufl2dot.build_entities(e, nodes, edges, nodeoffset, prefix='', labeller=None)[source]
ufl.formatting.ufl2dot.format_entities(nodes, edges)[source]
ufl.formatting.ufl2dot.ufl2dot(expression, formname='a', nodeoffset=0, begin=True, end=True, labeling='repr', object_names=None)[source]

ufl.formatting.ufl2unicode module

class ufl.formatting.ufl2unicode.Expression2UnicodeHandler(argument_names=None, coefficient_names=None, colorama_bold=False)[source]

Bases: MultiFunction

abs(o, a)[source]
and_condition(o, a, b)[source]
argument(o)[source]
atan2(o, f1, f2)[source]
bessel_K(o, nu, f)[source]
bessel_i(o, nu, f)[source]
bessel_j(o, nu, f)[source]
bessel_y(o, nu, f)[source]
cell_avg(o, f)[source]
coefficient(o)[source]
coefficient_derivative(o, f, w, v, cd)[source]
cofactor(o, A)[source]
component_tensor(o, A, ii)[source]
conditional(o, c, t, f)[source]
conj(o, a)[source]
constant(o)[source]
cross(o, a, b)[source]
curl(o, f)[source]
determinant(o, A)[source]
deviatoric(o, A)[source]
div(o, f)[source]
division(o, a, b)[source]
dot(o, a, b)[source]
eq(o, a, b)[source]
exp(o, f)[source]
expr(o)[source]

Trigger error for types with missing handlers.

expr_list(o, *ops)[source]
expr_mapping(o, *ops)[source]
facet_avg(o, f)[source]
facet_normal(o)[source]
ge(o, a, b)[source]
grad(o, f)[source]
gt(o, a, b)[source]
identity(o)[source]
imag(o, a)[source]
index_sum(o, f, i)[source]
indexed(o, A, ii)[source]
inner(o, a, b)[source]
inverse(o, A)[source]
label(o)[source]
le(o, a, b)[source]
list_tensor(o, *ops)[source]
lt(o, a, b)[source]
math_function(o, f)[source]
max_value(o, a, b)[source]
min_value(o, a, b)[source]
multi_index(o)[source]
nabla_div(o, f)[source]
nabla_grad(o, f)[source]
ne(o, a, b)[source]
negative_restricted(o, f)[source]
not_condition(o, a)[source]
or_condition(o, a, b)[source]
outer(o, a, b)[source]
permutation_symbol(o)[source]
positive_restricted(o, f)[source]
power(o, a, b)[source]
product(o, a, b)[source]
real(o, a)[source]
scalar_value(o)[source]
skew(o, A)[source]
spatial_coordinate(o)[source]
sqrt(o, f)[source]
sum(o, a, b)[source]
sym(o, A)[source]
trace(o, A)[source]
transposed(o, a)[source]
variable(o, f, l)[source]
variable_derivative(o, f, v)[source]
zero(o)[source]
class ufl.formatting.ufl2unicode.PrecedenceRules[source]

Bases: MultiFunction

An enum-like class for C operator precedence levels.

add(o)[source]
and_condition(o)[source]
bessel_function(o)
call(o)[source]
cell_avg(o)
cofactor(o)
component_tensor(o)
conditional(o)[source]
cross(o)
derivative(o)
deviatoric(o)
division(o)
dot(o)
eq(o)[source]
facet_avg(o)
ge(o)
gt(o)
highest(o)[source]
index_sum(o)
indexed(o)
inner(o)
le(o)
list_tensor(o)
lowest(o)[source]
lt(o)[source]
math_function(o)
mathop(o)[source]
max_value(o)
min_value(o)
ne(o)
not_condition(o)[source]
operator(o)
or_condition(o)[source]
outer(o)
power(o)[source]
product(o)[source]
restricted(o)[source]
skew(o)
sym(o)
terminal(o)
trace(o)
class ufl.formatting.ufl2unicode.UC[source]

Bases: object

An enum-like class for unicode characters.

Gamma = 'Γ'
Omega = 'Ω'
bold_math_A = '𝐀'
bold_math_a = '𝐚'
circled_times = '⊗'
combining_overline = '̅'
combining_right_arrow_above = '⃗'
cross_product = '⨯'
division_slash = '∕'
dot = '⋅'
element_of = '∈'
epsilon = 'ε'
for_all = '∀'
gamma = 'γ'
ge = '≥'
gt = '>'
integral = '∫'
integral_contour = '∮'
integral_double = '∬'
integral_surface = '∯'
integral_triple = '∭'
integral_volume = '∰'
le = '≤'
left_angled_bracket = '⟨'
left_double_angled_bracket = '⟪'
left_white_square_bracket = '⟦'
logical_and = '∧'
logical_not = '¬'
logical_or = '∨'
lt = '<'
nabla = '∇'
nary_product = '∏'
ne = '≠'
not_element_of = '∉'
omega = 'ω'
partial = '∂'
right_angled_bracket = '⟩'
right_double_angled_bracket = '⟫'
right_white_squared_bracket = '⟧'
sqrt = '√'
subscript_digits = ['₀', '₁', '₂', '₃', '₄', '₅', '₆', '₇', '₈', '₉']
subscript_equals = '₌'
subscript_left_paren = '₍'
subscript_minus = '₋'
subscript_plus = '₊'
subscript_right_paren = '₎'
sum = '∑'
superscript_digits = ['⁰', '¹', '²', '³', '⁴', '⁵', '⁶', '⁷', '⁸', '⁹']
superscript_equals = '⁼'
superscript_left_paren = '⁽'
superscript_minus = '⁻'
superscript_plus = '⁺'
superscript_right_paren = '⁾'
thin_space = '\u2009'
transpose = 'ᵀ'
ufl.formatting.ufl2unicode.binop(expr, a, b, op, sep=' ')[source]
ufl.formatting.ufl2unicode.bolden_letter(c)[source]
ufl.formatting.ufl2unicode.bolden_string(s)[source]
ufl.formatting.ufl2unicode.expression2unicode(expression, argument_names=None, coefficient_names=None)[source]
ufl.formatting.ufl2unicode.form2unicode(form, formdata)[source]
ufl.formatting.ufl2unicode.format_index(ii)[source]
ufl.formatting.ufl2unicode.get_integral_symbol(integral_type, domain, subdomain_id)[source]
ufl.formatting.ufl2unicode.is_int(s)[source]
ufl.formatting.ufl2unicode.mathop(expr, arg, opname)[source]
ufl.formatting.ufl2unicode.measure_font(dx)[source]
ufl.formatting.ufl2unicode.opfont(opname)[source]
ufl.formatting.ufl2unicode.overline_string(f)[source]
ufl.formatting.ufl2unicode.par(s)[source]
ufl.formatting.ufl2unicode.prec(expr)[source]
ufl.formatting.ufl2unicode.precedence(expr)[source]
ufl.formatting.ufl2unicode.subscript_digit(digit)[source]
ufl.formatting.ufl2unicode.subscript_number(number)[source]
ufl.formatting.ufl2unicode.superscript_digit(digit)[source]
ufl.formatting.ufl2unicode.superscript_number(number)[source]
ufl.formatting.ufl2unicode.ufl2unicode(expression)[source]

Generate Unicode string for a UFL expression or form.

Module contents