instTetgen = TetGenCreate[]; 
pts = {{0., 0., 0.}, {2., 0., 0.}, {2., 0., 2.}, {0., 0., 2.}, {0., 
2., 0.}, {2., 2., 0.}, {2., 2., 2.}, {0., 2., 2.}}; 
TetGenSetPoints[instTetgen, pts]; 
instTetrahed = TetGenTetrahedralize[instTetgen, "-o2"]; 
elemPts = TetGenGetPoints[instTetrahed]; 
elemFaces = TetGenGetFaces[instTetrahed]; 
meshElements = TetGenGetElements[instTetrahed]; 
nElements = Length[meshElements]; 
nVertex = Length[elemPts]; 
Graphics3D[{Opacity[0.5], GraphicsComplex[elemPts, Polygon[elemFaces]]}, Boxed -> False]; 

(*Ten nodes of the first tetrahedral element are:*)

Is there a way to visualize the polyhedron such that all the ten nodes of the tetrahedral elements are considered and not only the primary four nodes of each tetrahedral element?

  • $\begingroup$ Can you explain which are the ten nodes? $\endgroup$
    – Szabolcs
    Sep 1, 2016 at 18:05
  • 1
    $\begingroup$ @Szabolcs In the above example, there are six tetrahedral elements in the cube. Each of these tetrahedral elements will have ten nodes. The first four nodes are the same as in the case of linear tetrahedral elements, the rest six are midpoints of each of the edges. meshElements[[1]] contains {7,6,1,5,9,10,11,12,13,14} these ten points. $\endgroup$
    – novice
    Sep 1, 2016 at 18:09
  • $\begingroup$ @Szabolcs I have edited the question and provided the ten nodes of the first tetrahedral element. $\endgroup$
    – novice
    Sep 1, 2016 at 18:31

1 Answer 1


here is one element:

Graphics3D[{Opacity[.5], GraphicsComplex[ elemPts , { 
      Polygon[#[[{1, 2, 3}]]],
      Polygon[#[[{1, 4, 3}]]],
      Polygon[#[[{1, 2, 4}]]],
      Polygon[#[[{2, 3, 4}]]],
      {Red, Opacity[1], PointSize[.02],Point[#]}
      }]}, Boxed -> False] &@ meshElements[[1]]

enter image description here

and all:

Show[Graphics3D[{Opacity[.5], GraphicsComplex[ elemPts , { 
       Polygon[#[[{1, 2, 3}]]],
        Polygon[#[[{1, 4, 3}]]] ,
       Polygon[#[[{1, 2, 4}]]],
       Polygon[#[[{2, 3, 4}]]] , {Red, Opacity[1], PointSize[.02], 
       }]}, Boxed -> False] & /@ meshElements]

enter image description here

note that your graphic is not composed to tetrahedrons, in fact all of the rendered polygons are on the faces of the cube. I'm not sure whats wrong though. The elemPts list has a point at the center of the cube {1,1,1}, yet in your figure there is no vertex or edge through that point.

  • $\begingroup$ Thanks. I think it is because I just used the faces which are at the boundary. If I used the -f flag also along with -o2 while using the TetGenTetrahedralize command. It will consider that point as well. $\endgroup$
    – novice
    Sep 1, 2016 at 22:23
  • $\begingroup$ i see. if you didnt use opacity it would look ok. Maybe the docs for TetGenGetFaces could say it just gives external faces. $\endgroup$
    – george2079
    Sep 2, 2016 at 0:52
  • $\begingroup$ Your suggestion takes care of the points but the tetrahedral faces do not change accordingly. Example if i change elemPts[[9]] = {2,2,1} to {2,2,3}, The point goes out of the cube but the cube does not change its shape. I am doing the dynamics where the vertex points evolve with time, I want to visualize the shape changes in the polygon as the values of the vertex point changes. $\endgroup$
    – novice
    Sep 2, 2016 at 14:53
  • 1
    $\begingroup$ If you move the edge nodes away from the mid-point of the tet edges the resulting object is no longer a tetrahedron, the faces no longer polyhedron. The edges become quadratic. At the very least this should be a new question. (BTW in my experience commercial FEM packages punt on the issue and treat second order tets as first order for redering purpose.) $\endgroup$
    – george2079
    Sep 2, 2016 at 15:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.