I’m working with axisymmetric problems and I’m looking for a compact and less error prone way to write integrals in the form:
\int_\Omega (\cdot) 2\pi r\, dx
by defining a Measure:
dm = 2\pi r\, dx
Does UFL support this kind of definition?
As I did not find how to do it with UFL, I thought of defining the following class:
from ufl import Measure
class CompoundMeasure(Measure):
def __init__(self,
integral_type,
detJ,
domain=None,
subdomain_id='everywhere',
metadata=None,
subdomain_data=None):
super().__init__(integral_type,
domain=domain,
subdomain_id=subdomain_id,
metadata=metadata,
subdomain_data=subdomain_data)
self.detJ = detJ
def __rmul__(self, integrand):
return super().__rmul__(integrand * self.detJ)
And then use it to define the Measure dm as follows:
(r, z) = SpatialCoordinate(mesh)
detJ = 2*pi*r
dm = CompoundMeasure('cell', detJ)
Would it work or would it break any FEniCS feature?