# Help with basic Triangular Finite Elements, constructing stiffness/mass matrices

I am going through this example problem (picture below) and working it out myself. The problem is that I do not get the same mass matrix (M) as the example problem. I am able to get the same stiffness matrix (K). I used the same process of obtaining the stiffness matrix, which uses the connectivity array, but do not end up with the same mass matrix provided in the example. Can someone help me confirm whether the mass matrix in the given example is correct or incorrect?

This is what I obtain:

{
{4, 1, 0, 1, 2, 0, 0, 0, 0, 0, 0, 0},
{1, 6, 1, 0, 2, 2, 0, 0, 0, 0, 0, 0},
{0, 1, 2, 0, 0, 1, 0, 0, 0, 0, 0, 0},
{1, 0, 0, 6, 2, 0, 1, 2, 0, 0, 0, 0},
{2, 2, 0, 2, 12,2, 0, 2, 2, 0, 0, 0},
{0, 2, 1, 0, 2, 6, 0, 0, 1, 0, 0, 0},
{0, 0, 0, 1, 0, 0, 6, 2, 0, 1, 2, 0},
{0, 0, 0, 2, 2, 0, 2, 12,2, 0, 2, 2},
{0, 0, 0, 0, 2, 1, 0, 2, 6, 0, 0, 1},
{0, 0, 0, 0, 0, 0, 1, 0, 0, 2, 1, 0},
{0, 0, 0, 0, 0, 0, 2, 2, 0, 1, 6, 1},
{0, 0, 0, 0, 0, 0, 0, 2, 1, 0, 1, 4}
}

• What do you get? Commented Apr 28, 2014 at 17:17
• The assembly process for global K and global M is the same so presumably you have that working. For a single element, you should get equation (b). Commented Apr 28, 2014 at 18:18
• @BillGreene I used the same assembly process for global K to solve for global M, and that is the global M that I got. It is different from the one from the example. So am I doing it wrong? or is the answer from the example wrong? Commented Apr 28, 2014 at 18:46
• Did anybody notice that the mass matrix is called stiffness matrix in equation (b) ? :) Commented Apr 29, 2014 at 18:36
• Yes, it calls both K and M the stiffness matrix. I am guessing the second is just a typo. Commented Apr 29, 2014 at 19:52

Equation (b) from the example is correct assuming that m is the mass/area. However, when I create the global mass matrix for the model in Figure 9.21, I get the one you show rather than the one in the text (equation e).

One thing you have to be aware of is that integrating the mass matrix terms over the triangle requires a higher-order integration formula than the stiffness matrix terms. For the stiffness terms a single integration point gives an exact value of the integral; for the mass terms, three integration points are needed.

• Ok, thanks. I just wanted to see if I was doing it right or not. I guess I am doing it wrong. So I will try to figure out what I am doing wrong. Commented Apr 28, 2014 at 19:45

I didn't check both mass matrices (yours and the one from the picture) element-by-element, but your matrix seems more correct. It can be easily estimated by diagonal elements: since local mass matrix is constant for each element and has only 2 on its diagonal (regardless the matrix coefficient), the diagonal elements of global matrix divided by 2 should give the number of triangles to which the corresponding mesh vertex belongs. Say, the vertex 1 belongs to 2 triangles, so the diagonal element 1 of the global matrix should have 2*2 = 4. Vertex 2 belongs to 3 triangles, so we should have 2*3=6 for the diagonal of the second row of the global matrix. In your matrix it's 6, but in the matrix from the picture it's 4.

Edit:

As a request to check the whole matrix again to make sure that your matrix is correct, and the matrix from the text is not, I wrote this simple matrix assembling function in Octave. It doesn't take into account the coefficient, since it's the same for the local and the global matrices, and the question is about assembling only:

globalM = zeros(12, 12);
localM = [ [2 1 1]; [1 2 1]; [1 1 2] ];
connect = [ [1 4 5]; [1 5 2]; [2 5 6]; [2 6 3]; [4 7 8]; [4 8 5]; [5 8 9]; [5 9 6]; [7 10 11]; [7 11 8]; [8 11 12]; [8 12 9] ];
for el = 1:12
for i = 1:3
ii = connect(el, i);
for j = 1:3
jj = connect(el, j);
globalM(ii, jj) = globalM(ii, jj) + localM(i, j);
end
end
end


The result clearly shows your matrix is correct:

4    1    0    1    2    0    0    0    0    0    0    0
1    6    1    0    2    2    0    0    0    0    0    0
0    1    2    0    0    1    0    0    0    0    0    0
1    0    0    6    2    0    1    2    0    0    0    0
2    2    0    2   12    2    0    2    2    0    0    0
0    2    1    0    2    6    0    0    1    0    0    0
0    0    0    1    0    0    6    2    0    1    2    0
0    0    0    2    2    0    2   12    2    0    2    2
0    0    0    0    2    1    0    2    6    0    0    1
0    0    0    0    0    0    1    0    0    2    1    0
0    0    0    0    0    0    2    2    0    1    6    1
0    0    0    0    0    0    0    2    1    0    1    4