To your example
Note that there are kwargs element
, degree
for Expression
constructor. By default, CG element of degree 1 is used to interpolate expression in UFC/DOLFIN evaluation chain to obtain finite element representation of expression in form. This representation is then really evaluated at Gauss quadrature points. To do different interpolation you can do
elem = FiniteElement('DG', tetrahedron, 0)
pot = Pot(element=elem)
so that expression is regarded as cell-wise constant. Or you can do
elem = FiniteElement('Q', tetrahedron, 4)
pot = Pot(element=elem)
but you must be able to determine a degree of guadrature element needed which is, I guess, here 4 as u*v
term in the form is of polynomial degree 4. But you should check this precisely.
Other way
You may be able to define your singular potentials directly with UFL language avoiding usage of Expression
. For example
x = V.cell().x
# Spherical coordinates
r = x[0]
theta = x[1]
phi = x[2]
# Singular potential
Phi = 1./r
# Now use Phi in some forms.
# But note that polynomial degree of Phi estimated to 1 by UFL
# so you may want to increase quadrature degree manually.
But this approach may not be of any use for you if you have many singular potentials seeded through whole domain. It is of use when formulating equations in cylindrical/spherical coordinates and 1/r
term in Jacobian rises. The term is never evaluated in singularity (with properly aligned mesh).