I fear this post is poor even for my low standards, but for the life of me I could not find a solution after quite a search.
I would like to understand a bit more about UFL, for one how to translate a function to an UFL expression.
Looking for example at the Poisson Tutorial v4.0, I see this code snipped
import ufl
from petsc4py.PETSc import ScalarType
x = ufl.SpatialCoordinate(domain)
beta = fem.Constant(domain, ScalarType(12))
R0 = fem.Constant(domain, ScalarType(0.3))
p = 4 * ufl.exp(-beta**2 * (x[0]**2 + (x[1] - R0)**2))
to to define a Gaussian f source term.
What to do if I wanted my source term to be say a polynomial?
I search for an UFL
method, could find all sorts of methods ufl.asin
, ufl.bessel
but not anything I could use.
I fear even the cheap hack of using for example
ufl.ln(ufl.exp(x[0]**2))
does not work, as the type of the latter expression is different from the one of theufl.exp()
expression above (also mysterios to me yet).
Any hints please to go from a python function to UFL, thanks a lot for your patience