Products with Measures

Issue #159 wontfix
Nico Schlömer created an issue

When doing calculations in a cylindrically symmetric context, the measure 2*pi*r*dx is often used. This is easily implemented in any form as

r = Expression('x[0]')
a = f * 2*pi*r*dx

For code cleanliness, I would like to have certain functions oblivious of the exact measure that is applied, so I thought I just pass in 2*pi*r*dx as an argument. This fails, unfortunately. The code below highlights some of the most basic reasons for failure.

from dolfin import *

# Fails with
# TypeError: unsupported operand type(s) for *: 'float' and 'Measure'
dx1 = 2*pi*dx

# Appears to work alright...
r = Expression('x[0]')
dx2 = (2*pi*r) * dx
dx3 = Constant(2*pi) * dx
# however:
mesh = UnitSquareMesh(20, 20)
V = FunctionSpace(mesh, 'CG', 1)
v = TestFunction(V)
# both of these lines fail with
# TypeError: unsupported operand type(s) for *: 'Argument' and 'Form'
L = 1.0 * v * dx2
L = 1.0 * v * dx3

Are there strong reasons why this functionality does not exist? What would be required to add it?

Comments (3)

  1. Martin Sandve Alnæs

    Based on the definition that (fdx) means (\int_\Omega f dx), interpreting v(fdx) as (\int_\Omega vf dx) is not strictly correct, that's why it has been disallowed. But I see your use case. The Measure design is currently under heavy refactoring for improved multidomain support in some branches, and there is some ongoing work on tensor product domains that may also affect the future Measure design. I'll have to keep this in mind for later.

  2. Log in to comment