This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

Mass lumping in current versions

+1 vote

As I understand mass lumping is supposed to work like this:

lm = assemble(action(p*q*dx, Constant(1)))

For linear Lagrange elements this should give a vector lm with a the elements of a lumped mass matrix. However, I get

Invalid number of indices (1) for tensor expression of rank 0:
    Coefficient(FiniteElement('Real', None, 0, quad_scheme=None), 60)


FAILURE in reuse_if_possible:
type(o) = <class 'ufl.indexed.Indexed'>
operands =

f_60

2

stack =
////////////////////////////////////////////////////////////////////////////////
Visit stack in Transformer:
<class 'ufl.algebra.Product'> ; ((v_0)[2]) * ((v_1)[2])
<class 'ufl.indexed.Indexed'> ; (v_1)[2]
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

Any idea what I am doing wrong here?

asked Dec 17, 2014 by Christian Waluga FEniCS Expert (12,310 points)

1 Answer

+2 votes
 
Best answer

Okay, my mistake... I hesitated to ask this question for an hour or so and then I figured it out only seconds after posting :-) . The trial and test functions p and q were reused and they came from a mixed function space. Redefining them solved the problem:

p, q = TrialFunction(Q), TestFunction(Q)
lm = assemble(action(p*q*dx, Constant(1)))
answered Dec 17, 2014 by Christian Waluga FEniCS Expert (12,310 points)
selected Dec 17, 2014 by Christian Waluga
...