assemble(1 * dx) and similar don't work

Issue #127 duplicate
Nico Schlömer created an issue

I wanted to compute the area (volume) of a mesh, but found that it is not quite easy to do. None of the options below works, except for the last involved Expression. I thought this was easier at some point (but I can't remember exactly)

from dolfin import *

mesh = UnitSquareMesh(10, 10)

#area = assemble(1 * dx)
#area = assemble(1.0 * dx)
#area = assemble(Constant(1.0) * dx)
#area = assemble(Expression('1.0', cell=triangle) * dx)
area = assemble(Expression('1.0', cell=triangle) * dx, mesh=mesh)

print area

Comments (5)

  1. Jan Blechta

    The point to say is that 1.0 * dx should be faster than Constant and Expression because the value gets hardcoded into generated code.

  2. Johan Hake

    There are 2 problems to address to fix assemble(1*dx):

    1. What mesh should the assembler use to iterate over?
    2. For what spatial dimension or cell type should the form compiler generate code for?

    If we associate dx with a domain we have solved both these problems. That is addressed by issue 66.

  3. Log in to comment