On 4/15/19 8:46 AM, Robert Spartus wrote:
>
> > It is hard to imagine situations in which the mass matrix would be singular.
> > It is a positive definite form that gives rise to the mass matrix and so it
> > really shouldn't be singular at all. Can you show the code again with which
> > you build it?
>
> It seems that my mesh is neither singular nor degenerate. I wonder if the
> problem is that I am solving a vector valued problem. To build this mass
> matrix, I adapted the function Diffusion::assemble_system from step-52.
I don't think the function you have gives you what you want. You have this:
cell_mass_matrix(i, j) +=
fe_values.shape_value(i, q_point) *
fe_values.shape_value(j, q_point) *
fe_values.JxW(q_point);
If you read the documentation of FEValues::shape_value(), you will see that
for vector-valued elements, it returns the one nonzero component of the vector
shape function. So shape_value(i)*shape_value(j) will always return something
nonzero. But what you really mean to do in your case is to multiply the
*vector* shape function i times the vector shape function j. Both of these
vectors may have a nonzero entry, but their dot product will only be nonzero
if these components are the same.
You will want to write the mass matrix here with extractors (i.e.,
fe_values[...]) in the same way you would build any other matrix for
vector-valued problems.
> You will find the code attached, as well as the output of one run. If I
> isolate the mass matrix built and calculate its determinant in Python, the
> result is indeed zero.
Using the determinant is an unreliable technique for large matrices. Think
about the case where you have a 1000x1000 matrix with eigenvalues all equal to
0.1. This is a perfectly invertible matrix, but the determinant is 0.1^1000,
which is zero for all practical purposes. You really need to look at the
eigenvalues themselves.
But, seeing the issue I mentioned above, if you have two components, then you
currently are computing the matrix
[ M M ]
[ M M ]
instead of
[ M 0 ]
[ 0 M ]
The former is clearly singular, so I'm not surprised.
Best
W.