# FEM Method in 2D with Triangular Elements

• I
• bob012345

#### bob012345

Gold Member
TL;DR Summary
I have worked through the basics of the FEM method in 2D with rectangular elements and now am trying to learn triangular elements but need a simple enough numerical example.
I have worked through the basics of the FEM method in 2D with rectangular elements and now am trying to learn triangular elements but need a simple enough numerical example. It seems triangular elements are far more complicated and also depend on the global coordinates thus each local stiffness matrix is different. At least that's my current understanding. If anyone can point me to a simple enough 2D problem worked out with triangular elements for a temperature problem I would be grateful. Simple is defined by a handful of elements and basically just involving temperature, not things like stress and strain. Also, it's mainly the assembly process I am struggling with especially when triangular elements are in different orientations or different sizes. Thanks.

Last edited:
iamanegg
Did you really mean to post this in the DiffEq forum, or did you mean to post in ME or another forum? I can move it if you meant to post in a different forum.

Did you really mean to post this in the DiffEq forum, or did you mean to post in ME or another forum? I can move it if you meant to post in a different forum.
Sorry, I thought since FEM is used to solve differential equations that this is the right place and also I started some threads in the past here on FEM but anywhere you think is best is fine. Thanks.

No need to be sorry. I just wanted to be sure to place this thread start in the best forum. We'll see how things shake out by tomorrow.

bob012345
Maybe this helps:
https://www.unm.edu/~bgreen/ME360/2D Triangular Elements.pdf

But I just want to note that in general also for quadrilateral elements the stiffness matrix depends on the orientation and shape of the element and are thus different for each element. Only if you have a grid of perfectly equal quads which sides are aligned with the coordinate system this part might be omitted.

bob012345
Maybe this helps:
https://www.unm.edu/~bgreen/ME360/2D Triangular Elements.pdf

But I just want to note that in general also for quadrilateral elements the stiffness matrix depends on the orientation and shape of the element and are thus different for each element. Only if you have a grid of perfectly equal quads which sides are aligned with the coordinate system this part might be omitted.
Thanks. I actually have seen that before and it helps a little but is still confusing because it solves for stress and strain not temperature which just adds a layer of unfamiliar material. I can do this for one element but the assembly process where triangular elements are in different orientations confounds me still. If I compute each local stiffness matrix separately based on its global coordinates, would that account for each elements orientation? I can only think of computing a simple case of a few elements and see if things make sense.

Also, triangular elements don't have to be equilateral do they? I assume they can be any kind of triangle

Thanks. I actually have seen that before and it helps a little but is still confusing because it solves for stress and strain not temperature which just adds a layer of unfamiliar material. I can do this for one element but the assembly process where triangular elements are in different orientations confounds me still. If I compute each local stiffness matrix separately based on its global coordinates, would that account for each elements orientation? I can only think of computing a simple case of a few elements and see if things make sense.

The local stiffness matrix is in global coordinates. So this indeed accounts for its orientation. You then need to number all degrees of freedom. With this you can define the global stiffness matrix. If a degree of freedom of a certain node is shared between two or more elements you just add all the values of their respective local stiffness matrices.

Also, triangular elements don't have to be equilateral do they? I assume they can be any kind of triangle

True, they do not have to be equilateral, as long as you don't go overboard with it. If the element is too severely deformed you get numerical issues.

bob012345
Suppose I have a simple two element problem like the reference you sent me with nodes labeled counterclockwise and the element number inside;

Then suppose the local stiffness matrix for element 1 is

$$k_1 = \begin{bmatrix} a_{1,1} & a_{1,2} & a_{1,3}\\ a_{2,1} & a_{2,2} & a_{2,3}\\ a_{3,1} & a_{3,2} & a_{3,3} \end{bmatrix}$$

And for element 2 is;

$$k_2 = \begin{bmatrix} b_{1,1} & b_{1,2} & b_{1,3}\\ b_{2,1} & b_{2,2} & b_{2,3}\\ b_{3,1} & b_{3,2} & b_{3,3} \end{bmatrix}$$

I believe the local stiffness matrix for element 1 will go into the global stiffness matrix like this;

$$K_1 = \begin{bmatrix} a_{1,1} & a_{1,2} & a_{1,3}&0\\ a_{2,1} & a_{2,2} & a_{2,3}&0\\ a_{3,1} & a_{3,2} & a_{3,3} &0\\ 0 & 0 & 0 & 0 \end{bmatrix}$$

but I am confused as to how to add the second one.

Last edited:
bob012345
Suppose I have a simple two element problem like the reference you sent me with nodes labeled counterclockwise and the element number inside;
View attachment 305603

Then suppose the local stiffness matrix for element 1 is

$$k_1 = \begin{bmatrix} a_{1,1} & a_{1,2} & a_{1,3}\\ a_{2,1} & a_{2,2} & a_{2,3}\\ a_{3,1} & a_{3,2} & a_{3,3} \end{bmatrix}$$

And for element 2 is;

$$k_2 = \begin{bmatrix} b_{1,1} & b_{1,2} & b_{1,3}\\ b_{2,1} & b_{2,2} & b_{2,3}\\ b_{3,1} & b_{3,2} & b_{3,3} \end{bmatrix}$$

I believe the local stiffness matrix for element 1 will go into the global stiffness matrix like this;

$$K_1 = \begin{bmatrix} a_{1,1} & a_{1,2} & a_{1,3}&0\\ a_{2,1} & a_{2,2} & a_{2,3}&0\\ a_{3,1} & a_{3,2} & a_{3,3} &0\\ 0 & 0 & 0 & 0 \end{bmatrix}$$

but I am confused as to how to add the second one.
Ok, I think the contribution of element #2 to the global stiffness matrix will go like this;

$$K_2 = \begin{bmatrix} b_{3,3} & 0 & b_{3,1}&b_{3,2}\\ 0 & 0 & 0 & 0\\ b_{1,3} &0& b_{1,1} & b_{1,2}\\ b_{2,3} &0& b_{2,1} & b_{2,2} \end{bmatrix}$$

I used an ordering like this since the counterclockwise sense of nodes for element #2 goes as {3,4,1};

 3 4 1 b_{1,1} b_{1,2} b_{1,3} 3 b_{2,1} b_{2,2} b_{2,3} 4 b_{3,1} b_{3,2} b_{3,3} 1

I'm fairly sure this is correct.

Last edited:
Ok, now I've got it. Thanks for your help!

Arjan82 and berkeman
If you want examples involving heat transfer, check "A First Course in Finite Elements" by J. Fish and T. Belytschko and "A First Course in the Finite Element Method" by D.L. Logan. Other books with examples of 2D element calculations focus on solid mechanics problems. Including my favorite collection of 2D FEA examples - "Finite Element Analysis" by U. Borker.

bob012345 and Arjan82
For code examples, you can have a look at the online database of John Burkhardt:
https://people.sc.fsu.edu/~jburkardt/
Just go to your favorite language and scroll down to the examples fem*

jim mcnamara