Welcome to the community!
Your code shouldn’t compile. For one, there’s the missing closing square bracket in M[...
and you should need to supply the either the degree
or the element
argument to Expression
.
There’s a recent thread where @kamensky posted the most recent solution on how to pass a numpy array to an Expression
:
You may be able to circumvent the hassle by defining k
as a Function
and manually setting the values at the DOFs as described here:
http://home.simula.no/~hpl/homepage/fenics-tutorial/release-1.0-nonabla/webm/materials.html