# Total number of corner nodes and middle nodes in a given mesh with 2nd order triangular elements

I have created a mesh consisting of 2nd order triangular elements, on the domain as follows.

<< NDSolveFEM
m2 = ToElementMesh[Rectangle[{0, 0}, {254, 101.6}],
"MeshElementType" -> TriangleElement,
MaxCellMeasure -> {"Area" -> 2000/6}, "MeshOrder" -> 2];
Show[m2["Wireframe"],
m2["Wireframe"["MeshElement" -> "PointElements",
"MeshElementIDStyle" -> Red]]]


which outputs the following clumsy mesh with node numbers.

My question is

1. I want to know the total number of corner nodes & middle nodes in the above mesh. For the sake of clarity, by corner nodes I mean, nodes 1,2,3, and middle nodes are 4,5,6 in a 2nd order triangular element as shown in the below image.
• Why do you want to know this? Is this purely educational or does it have an application? Dec 26, 2022 at 10:45
• Yes, it has an application. If you need to interpolate two different fields each at the corner node and middle node. Please refer to this link. link.springer.com/article/10.1007/s00466-004-0564-2 Dec 27, 2022 at 7:17

All standard mesh generators, in general, number the corner nodes first and then the middle nodes in a mesh. The total number of corner nodes can be found in the first three columns of the matrix of incidents as follows.

In[1]:= Max[m2["MeshElements"][[1]][[1]][[All,1;;3]]]

Out[1]= 84


To cross-check if 84 is the last corner node, 85 should be the first middle node in the sequence of node numbering, which means the min of the last three columns in the incident matrix has to be 85.

In[2]:= Min[m2["MeshElements"][[1]][[1]][[All,4;;6]]]

Out[2]= 85


Therefore the total number of corner nodes is 84. The number of middle nodes would be

In[3]:= (m2["Coordinates"] // Length) - 84

Out[3]= 209