UFL Formatting#

UFL to unicode.

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

Bases: DAGTraverser

Convert expressions to unicode.

Initialise.

process(o: Expr) str[source]#
process(o: ScalarValue) str
process(o: Zero) str
process(o: Identity) str
process(o: PermutationSymbol) str
process(o: FacetNormal) str
process(o: FacetArea) str
process(o: Circumradius) str
process(o: CellDiameter) str
process(o: CellVolume) str
process(o: SpatialCoordinate) str
process(o: Argument) str
process(o: Coefficient) str
process(o: Cofunction) str
process(o: BaseFormOperator) str
process(o: Constant) str
process(o: MultiIndex) str
process(o: Label) str
process(o: Action, a: str, b: str) str
process(o: Variable, f: str, a: str) str
process(o: IndexSum, f: str, i: str) str
process(o: Sum, a: str, b: str) str
process(o: Product, a: str, b: str) str
process(o: Division, a: str, b: str) str
process(o: Abs, a: str) str
process(o: Transposed, a: str) str
process(o: Indexed, A: str, ii: str) str
process(o: VariableDerivative, f: str, v: str) str
process(o: CoefficientDerivative, f: str, w: str, v: str, cd: str) str
process(o: Grad, f: str) str
process(o: Div, f: str) str
process(o: NablaGrad, f: str) str
process(o: NablaDiv, f: str) str
process(o: Curl, f: str) str
process(o: MathFunction, f: str) str
process(o: Sqrt, f: str) str
process(o: Exp, f: str) str
process(o: Atan2, f1: str, f2: str) str
process(o: BesselJ, nu: str, f: str) str
process(o: BesselY, nu: str, f: str) str
process(o: BesselI, nu: str, f: str) str
process(o: BesselK, nu: str, f: str) str
process(o: Power, a: str, b: str) str
process(o: Outer, a: str, b: str) str
process(o: Inner, a: str, b: str) str
process(o: Dot, a: str, b: str) str
process(o: Cross, a: str, b: str) str
process(o: Determinant, A: str) str
process(o: Inverse, A: str) str
process(o: Trace, A: str) str
process(o: Deviatoric, A: str) str
process(o: Cofactor, A: str) str
process(o: Skew, A: str) str
process(o: Sym, A: str) str
process(o: Conj, a: str) str
process(o: Real, a: str) str
process(o: Imag, a: str) str
process(o: ListTensor, *ops: str) str
process(o: ComponentTensor, A: str, ii: str) str
process(o: PositiveRestricted, f: str) str
process(o: NegativeRestricted, f: str) str
process(o: CellAvg, f: str) str
process(o: FacetAvg, f: str) str
process(o: EQ, a: str, b: str) str
process(o: NE, a: str, b: str) str
process(o: LE, a: str, b: str) str
process(o: GE, a: str, b: str) str
process(o: LT, a: str, b: str) str
process(o: GT, a: str, b: str) str
process(o: AndCondition, a: str, b: str) str
process(o: OrCondition, a: str, b: str) str
process(o: NotCondition, a: str, b: str) str
process(o: Conditional, c: str, t: str, f: str) str
process(o: MinValue, a: str, b: str) str
process(o: MaxValue, a: str, b: str) str
process(o: ExprList, *ops: str) str
process(o: ExprMapping, *ops: str) str

Process node by type.

class ufl.formatting.ufl2unicode.PrecedenceRules(compress: bool | None = True, visited_cache: dict[tuple, Expr] | None = None, result_cache: dict[Expr, Expr] | None = None)[source]#

Bases: DAGTraverser

An enum-like class for C operator precedence levels.

Initialise.

process(o: Expr) int[source]#
process(o: Any) int
process(o: Any) int
process(o: Any) int
process(o: Any) int
process(o: Any) int
process(o: Any) int
process(o: Any) int
process(o: Any) int
process(o: Any) int
process(o: Any) int
process(o: Any) int
process(o: Any) int
process(o: Any) int
process(o: Any) int
process(o: Any) int
process(o: Any) int
process(o: Any) int
process(o: Any) int
process(o: NotCondition) int
process(o: Any) int
process(o: Any) int
process(o: Any) int
process(o: Any) int
process(o: Any) int
process(o: Any) int
process(o: Any) int
process(o: Any) int
process(o: Any) int
process(o: Any) int
process(o: Any) int
process(o: Any) int
process(o: Any) int
process(o: Any) int
process(o: AndCondition) int
process(o: OrCondition) int
process(o: Conditional) int
process(o: Operator) int

Process node by type.

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.bolden_letter(c)[source]#

Bolden a letter.

ufl.formatting.ufl2unicode.bolden_string(s)[source]#

Bolden a string.

ufl.formatting.ufl2unicode.format_index(ii)[source]#

Format an index.

ufl.formatting.ufl2unicode.get_integral_symbol(integral_type, domain, subdomain_id)[source]#

Get the symbol for an integral.

ufl.formatting.ufl2unicode.is_int(s)[source]#

Check if a value is an integer.

ufl.formatting.ufl2unicode.measure_font(dx)[source]#

Use the font for measures.

ufl.formatting.ufl2unicode.opfont(opname)[source]#

Use the font for operators.

ufl.formatting.ufl2unicode.overline_string(f)[source]#

Overline a string.

ufl.formatting.ufl2unicode.par(s)[source]#

Wrap in parentheses.

ufl.formatting.ufl2unicode.precedence(expr)[source]#

Get the precedence of an expr.

ufl.formatting.ufl2unicode.subscript_digit(digit)[source]#

Make a digit subscript.

ufl.formatting.ufl2unicode.subscript_number(number)[source]#

Make a number subscript.

ufl.formatting.ufl2unicode.superscript_digit(digit)[source]#

Make a digit superscript.

ufl.formatting.ufl2unicode.superscript_number(number)[source]#

Make a number superscript.

ufl.formatting.ufl2unicode.ufl2unicode(expression)[source]#

Generate Unicode string for a UFL expression or form.