ufl.formatting package¶
Submodules¶
ufl.formatting.graph module¶
Algorithms for working with linearized computational graphs.
-
class
ufl.formatting.graph.
Graph
(expression)¶ Graph class which computes connectivity on demand.
-
E
()¶
-
Ein
()¶
-
Eout
()¶
-
V
()¶
-
Vin
()¶
-
Vout
()¶
-
-
class
ufl.formatting.graph.
HeapItem
(incoming, outgoing, i)¶ Bases:
object
-
class
ufl.formatting.graph.
StringDependencyDefiner
(argument_deps=None, coefficient_deps=None)¶ Bases:
ufl.corealg.multifunction.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)¶
-
coefficient
(x)¶
-
expr
(o)¶
-
facet_normal
(o)¶
-
geometric_quantity
(x)¶
-
spatial_derivative
(o)¶
-
ufl.formatting.graph.
build_graph
(expr)¶ 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)¶
-
ufl.formatting.graph.
extract_incoming_edges
(G)¶ Build lists of incoming edges to each vertex in a linearized graph.
-
ufl.formatting.graph.
extract_incoming_vertex_connections
(G)¶ 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)¶ Build list of outgoing edges from each vertex in a linearized graph.
-
ufl.formatting.graph.
extract_outgoing_vertex_connections
(G)¶ 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)¶
-
ufl.formatting.graph.
lists
(n)¶
-
ufl.formatting.graph.
partition
(G, criteria=<function string_set_criteria>)¶
-
ufl.formatting.graph.
string_set_criteria
(v, keys)¶
ufl.formatting.latextools module¶
This module defines basic utilities for stitching together LaTeX documents.
-
ufl.formatting.latextools.
align
(lines)¶
-
ufl.formatting.latextools.
document
(title, sections)¶
-
ufl.formatting.latextools.
itemize
(items)¶
-
ufl.formatting.latextools.
section
(s)¶
-
ufl.formatting.latextools.
subsection
(s)¶
-
ufl.formatting.latextools.
subsubsection
(s)¶
-
ufl.formatting.latextools.
testdocument
()¶
-
ufl.formatting.latextools.
verbatim
(string)¶
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)¶
-
ufl.formatting.printing.
integral_info
(integral)¶
-
ufl.formatting.printing.
tree_format
(expression, indentation=0, parentheses=True)¶
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)¶ Bases:
ufl.formatting.ufl2dot.ReprLabeller
-
cell_avg
(e)¶
-
component_tensor
(e)¶
-
curl
(e)¶
-
determinant
(e)¶
-
dev
(e)¶
-
diff
(e)¶
-
div
(e)¶
-
division
(e)¶
-
dot
(e)¶
-
facet_avg
(e)¶
-
form_argument
(e)¶
-
geometric_quantity
(e)¶
-
grad
(e)¶
-
identity
(e)¶
-
index_sum
(e)¶
-
indexed
(e)¶
-
inner
(e)¶
-
math_function
(e)¶
-
multi_index
(e)¶
-
nabla_div
(e)¶
-
nabla_grad
(e)¶
-
negative_restricted
(e)¶
-
outer
(e)¶
-
positive_restricted
(e)¶
-
power
(e)¶
-
product
(e)¶
-
scalar_value
(e)¶
-
skew
(e)¶
-
sum
(e)¶
-
trace
(e)¶
-
transposed
(e)¶
-
zero
(e)¶
-
-
class
ufl.formatting.ufl2dot.
FancyLabeller
(function_mapping=None)¶
-
class
ufl.formatting.ufl2dot.
ReprLabeller
¶ Bases:
ufl.corealg.multifunction.MultiFunction
-
operator
(e)¶
-
terminal
(e)¶
-
-
ufl.formatting.ufl2dot.
build_entities
(e, nodes, edges, nodeoffset, prefix='', labeller=None)¶
-
ufl.formatting.ufl2dot.
format_entities
(nodes, edges)¶
-
ufl.formatting.ufl2dot.
ufl2dot
(expression, formname='a', nodeoffset=0, begin=True, end=True, labeling='repr', object_names=None)¶
ufl.formatting.ufl2latex module¶
This module defines expression transformation utilities, either converting UFL expressions to new UFL expressions or converting UFL expressions to other representations.
-
class
ufl.formatting.ufl2latex.
Expression2LatexHandler
(argument_names=None, coefficient_names=None)¶ Bases:
ufl.corealg.multifunction.MultiFunction
-
abs
(o, a)¶
-
acos
(o, f)¶
-
and_condition
(o, a, b)¶
-
argument
(o)¶
-
asin
(o, f)¶
-
atan
(o, f)¶
-
atan2
(o, f1, f2)¶
-
bessel_K
(o, nu, f)¶
-
bessel_i
(o, nu, f)¶
-
bessel_j
(o, nu, f)¶
-
bessel_y
(o, nu, f)¶
-
cell_avg
(o, f)¶
-
coefficient
(o)¶
-
coefficient_derivative
(o, f, w, v)¶
-
cofactor
(o, A)¶
-
component_tensor
(o, *ops)¶
-
conditional
(o, c, t, f)¶
-
constant
(o)¶
-
cos
(o, f)¶
-
cosh
(o, f)¶
-
cross
(o, a, b)¶
-
curl
(o, f)¶
-
determinant
(o, A)¶
-
deviatoric
(o, A)¶
-
div
(o, f)¶
-
division
(o, a, b)¶
-
dot
(o, a, b)¶
-
eq
(o, a, b)¶
-
erf
(o, f)¶
-
exp
(o, f)¶
-
expr
(o)¶
-
facet_normal
(o)¶
-
ge
(o, a, b)¶
-
grad
(o, f)¶
-
gt
(o, a, b)¶
-
identity
(o)¶
-
index_sum
(o, f, i)¶
-
indexed
(o, a, b)¶
-
inner
(o, a, b)¶
-
inverse
(o, A)¶
-
le
(o, a, b)¶
-
list_tensor
(o)¶
-
ln
(o, f)¶
-
lt
(o, a, b)¶
-
max_value
(o, a, b)¶
-
min_value
(o, a, b)¶
-
multi_index
(o)¶
-
nabla_div
(o, f)¶
-
nabla_grad
(o, f)¶
-
ne
(o, a, b)¶
-
negative_restricted
(o, f)¶
-
not_condition
(o, a)¶
-
or_condition
(o, a, b)¶
-
outer
(o, a, b)¶
-
permutation_symbol
(o)¶
-
positive_restricted
(o, f)¶
-
power
(o, a, b)¶
-
product
(o, *ops)¶
-
scalar_value
(o)¶
-
sin
(o, f)¶
-
sinh
(o, f)¶
-
skew
(o, A)¶
-
sqrt
(o, f)¶
-
sum
(o, *ops)¶
-
sym
(o, A)¶
-
tan
(o, f)¶
-
tanh
(o, f)¶
-
trace
(o, A)¶
-
transposed
(o, a)¶
-
variable
(o)¶
-
variable_derivative
(o, f, v)¶
-
zero
(o)¶
-
-
ufl.formatting.ufl2latex.
bfname
(i, p)¶
-
ufl.formatting.ufl2latex.
build_precedence_map
()¶
-
ufl.formatting.ufl2latex.
cfname
(i)¶
-
ufl.formatting.ufl2latex.
code2latex
(G, partitions, formdata)¶ TODO: Document me
-
ufl.formatting.ufl2latex.
dependency_sorting
(deplist, rank)¶
-
ufl.formatting.ufl2latex.
deps2latex
(deps)¶
-
ufl.formatting.ufl2latex.
element2latex
(element)¶
-
ufl.formatting.ufl2latex.
expression2latex
(expression, argument_names=None, coefficient_names=None)¶
-
ufl.formatting.ufl2latex.
form2code2latex
(formdata)¶
-
ufl.formatting.ufl2latex.
form2latex
(form, formdata)¶
-
ufl.formatting.ufl2latex.
format_index
(ii)¶
-
ufl.formatting.ufl2latex.
format_multi_index
(ii, formatstring='%s')¶
-
ufl.formatting.ufl2latex.
formdata2latex
(formdata)¶
-
ufl.formatting.ufl2latex.
forms2latexdocument
(forms, uflfilename, compile=False)¶ Render forms from a .ufl file as a LaTeX document.
-
ufl.formatting.ufl2latex.
integrand2code
(integrand, formdata)¶
-
ufl.formatting.ufl2latex.
par
(s, condition=True)¶
-
ufl.formatting.ufl2latex.
ufl2latex
(expression)¶ Generate LaTeX code for a UFL expression or form (wrapper for form2latex and expression2latex).
ufl.formatting.ufl2unicode module¶
-
class
ufl.formatting.ufl2unicode.
Expression2UnicodeHandler
(argument_names=None, coefficient_names=None, colorama_bold=False)¶ Bases:
ufl.corealg.multifunction.MultiFunction
-
abs
(o, a)¶
-
and_condition
(o, a, b)¶
-
argument
(o)¶
-
atan2
(o, f1, f2)¶
-
bessel_K
(o, nu, f)¶
-
bessel_i
(o, nu, f)¶
-
bessel_j
(o, nu, f)¶
-
bessel_y
(o, nu, f)¶
-
cell_avg
(o, f)¶
-
coefficient
(o)¶
-
coefficient_derivative
(o, f, w, v, cd)¶
-
cofactor
(o, A)¶
-
component_tensor
(o, A, ii)¶
-
conditional
(o, c, t, f)¶
-
cross
(o, a, b)¶
-
curl
(o, f)¶
-
determinant
(o, A)¶
-
deviatoric
(o, A)¶
-
div
(o, f)¶
-
division
(o, a, b)¶
-
dot
(o, a, b)¶
-
eq
(o, a, b)¶
-
exp
(o, f)¶
-
expr
(o)¶
-
expr_list
(o, *ops)¶
-
expr_mapping
(o, *ops)¶
-
facet_avg
(o, f)¶
-
facet_normal
(o)¶
-
ge
(o, a, b)¶
-
grad
(o, f)¶
-
gt
(o, a, b)¶
-
identity
(o)¶
-
index_sum
(o, f, i)¶
-
indexed
(o, A, ii)¶
-
inner
(o, a, b)¶
-
inverse
(o, A)¶
-
label
(o)¶
-
le
(o, a, b)¶
-
list_tensor
(o, *ops)¶
-
lt
(o, a, b)¶
-
math_function
(o, f)¶
-
max_value
(o, a, b)¶
-
min_value
(o, a, b)¶
-
multi_index
(o)¶
-
nabla_div
(o, f)¶
-
nabla_grad
(o, f)¶
-
ne
(o, a, b)¶
-
negative_restricted
(o, f)¶
-
not_condition
(o, a)¶
-
or_condition
(o, a, b)¶
-
outer
(o, a, b)¶
-
permutation_symbol
(o)¶
-
positive_restricted
(o, f)¶
-
power
(o, a, b)¶
-
product
(o, a, b)¶
-
scalar_value
(o)¶
-
skew
(o, A)¶
-
spatial_coordinate
(o)¶
-
sqrt
(o, f)¶
-
sum
(o, a, b)¶
-
sym
(o, A)¶
-
trace
(o, A)¶
-
transposed
(o, a)¶
-
variable
(o, f, l)¶
-
variable_derivative
(o, f, v)¶
-
zero
(o)¶
-
-
class
ufl.formatting.ufl2unicode.
PrecedenceRules
¶ Bases:
ufl.corealg.multifunction.MultiFunction
An enum-like class for C operator precedence levels.
-
add
(o)¶
-
and_condition
(o)¶
-
bessel_function
(o)¶
-
call
(o)¶
-
cell_avg
(o)¶
-
cofactor
(o)¶
-
component_tensor
(o)¶
-
conditional
(o)¶
-
cross
(o)¶
-
derivative
(o)¶
-
deviatoric
(o)¶
-
division
(o)¶
-
dot
(o)¶
-
eq
(o)¶
-
facet_avg
(o)¶
-
ge
(o)¶
-
gt
(o)¶
-
highest
(o)¶
-
index_sum
(o)¶
-
indexed
(o)¶
-
inner
(o)¶
-
le
(o)¶
-
list_tensor
(o)¶
-
lowest
(o)¶
-
lt
(o)¶
-
math_function
(o)¶
-
mathop
(o)¶
-
max_value
(o)¶
-
min_value
(o)¶
-
ne
(o)¶
-
not_condition
(o)¶
-
operator
(o)¶
-
or_condition
(o)¶
-
outer
(o)¶
-
power
(o)¶
-
product
(o)¶
-
restricted
(o)¶
-
skew
(o)¶
-
sym
(o)¶
-
terminal
(o)¶
-
trace
(o)¶
-
-
class
ufl.formatting.ufl2unicode.
UC
¶ An enum-like class for unicode characters.
-
Gamma
= u'\u0393'¶
-
Omega
= u'\u03a9'¶
-
bold_math_A
= u'\U0001d400'¶
-
bold_math_a
= u'\U0001d41a'¶
-
circled_times
= u'\u2297'¶
-
combining_overline
= u'\u0305'¶
-
combining_right_arrow_above
= u'\u20d7'¶
-
cross_product
= u'\u2a2f'¶
-
division_slash
= u'\u2215'¶
-
dot
= u'\u22c5'¶
-
element_of
= u'\u2208'¶
-
epsilon
= u'\u03b5'¶
-
for_all
= u'\u2200'¶
-
gamma
= u'\u03b3'¶
-
ge
= u'\u2265'¶
-
gt
= u'>'¶
-
integral
= u'\u222b'¶
-
integral_contour
= u'\u222e'¶
-
integral_double
= u'\u222c'¶
-
integral_surface
= u'\u222f'¶
-
integral_triple
= u'\u222d'¶
-
integral_volume
= u'\u2230'¶
-
le
= u'\u2264'¶
-
left_angled_bracket
= u'\u27e8'¶
-
left_double_angled_bracket
= u'\u27ea'¶
-
left_white_square_bracket
= u'\u27e6'¶
-
logical_and
= u'\u2227'¶
-
logical_not
= u'\xac'¶
-
logical_or
= u'\u2228'¶
-
lt
= u'<'¶
-
nabla
= u'\u2207'¶
-
nary_product
= u'\u220f'¶
-
ne
= u'\u2260'¶
-
not_element_of
= u'\u2209'¶
-
omega
= u'\u03c9'¶
-
partial
= u'\u2202'¶
-
right_angled_bracket
= u'\u27e9'¶
-
right_double_angled_bracket
= u'\u27eb'¶
-
right_white_squared_bracket
= u'\u27e7'¶
-
sqrt
= u'\u221a'¶
-
subscript_digits
= [u'\u2080', u'\u2081', u'\u2082', u'\u2083', u'\u2084', u'\u2085', u'\u2086', u'\u2087', u'\u2088', u'\u2089']¶
-
subscript_equals
= u'\u208c'¶
-
subscript_left_paren
= u'\u208d'¶
-
subscript_minus
= u'\u208b'¶
-
subscript_plus
= u'\u208a'¶
-
subscript_right_paren
= u'\u208e'¶
-
sum
= u'\u2211'¶
-
superscript_digits
= [u'\u2070', u'\xb9', u'\xb2', u'\xb3', u'\u2074', u'\u2075', u'\u2076', u'\u2077', u'\u2078', u'\u2079']¶
-
superscript_equals
= u'\u207c'¶
-
superscript_left_paren
= u'\u207d'¶
-
superscript_minus
= u'\u207b'¶
-
superscript_plus
= u'\u207a'¶
-
superscript_right_paren
= u'\u207e'¶
-
thin_space
= u'\u2009'¶
-
transpose
= u'\u1d40'¶
-
-
ufl.formatting.ufl2unicode.
binop
(expr, a, b, op, sep=u' ')¶
-
ufl.formatting.ufl2unicode.
bolden_letter
(c)¶
-
ufl.formatting.ufl2unicode.
bolden_string
(s)¶
-
ufl.formatting.ufl2unicode.
expression2unicode
(expression, argument_names=None, coefficient_names=None)¶
-
ufl.formatting.ufl2unicode.
form2unicode
(form, formdata)¶
-
ufl.formatting.ufl2unicode.
format_index
(ii)¶
-
ufl.formatting.ufl2unicode.
get_integral_symbol
(integral_type, domain, subdomain_id)¶
-
ufl.formatting.ufl2unicode.
is_int
(s)¶
-
ufl.formatting.ufl2unicode.
mathop
(expr, arg, opname)¶
-
ufl.formatting.ufl2unicode.
measure_font
(dx)¶
-
ufl.formatting.ufl2unicode.
opfont
(opname)¶
-
ufl.formatting.ufl2unicode.
overline_string
(f)¶
-
ufl.formatting.ufl2unicode.
par
(s)¶
-
ufl.formatting.ufl2unicode.
prec
(expr)¶
-
ufl.formatting.ufl2unicode.
precedence
(expr)¶
-
ufl.formatting.ufl2unicode.
subscript_digit
(digit)¶
-
ufl.formatting.ufl2unicode.
subscript_number
(number)¶
-
ufl.formatting.ufl2unicode.
superscript_digit
(digit)¶
-
ufl.formatting.ufl2unicode.
superscript_number
(number)¶
-
ufl.formatting.ufl2unicode.
ufl2unicode
(expression)¶ Generate Unicode string for a UFL expression or form.