assemble(1 * dx) and similar don't work
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)
-
-
The point to say is that
1.0 * dx
should be faster thanConstant
andExpression
because the value gets hardcoded into generated code. -
There are 2 problems to address to fix
assemble(1*dx)
:- What mesh should the assembler use to iterate over?
- 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.
-
-
User definitely needs to supply mesh as an argument to assemble or pass mesh function to measure before (which is checked from commit https://bitbucket.org/fenics-project/dolfin/commits/c9cccc2d5d3bd72d5267b9ada11ccf2580d88028).
-
That's why
1.0*dx
does not work still (even ifdx
contains mesh function).
-
-
- changed status to duplicate
Duplicate of
#66. - Log in to comment
I could get it to work with