To generate 3D mesh TetGen can be easily used. Are there similar functions (or a way to use TetGen) to generate 2d mesh? I know that such functionality can be easily implemented but I would like to use a Mathematica provided function, as I need to experiment with number of nodes in elements and so on. I just want to solve PDE using FEM not really to play around with mesh generation.

  • 2
    $\begingroup$ DelaunayTriangulation might be of interest. $\endgroup$
    – jVincent
    Aug 26, 2013 at 21:11
  • 1
    $\begingroup$ I think the short answer is no, there is no intrinsic capability. Use one of the algorithms in the question you linked, or generate externally and import. If by "number of nodes" you mean "other than triangular" then external packages really are the way to go. $\endgroup$
    – george2079
    Aug 27, 2013 at 3:12

3 Answers 3


Since Mathematica 10.3 ToElementMesh[] function can be used, along with FEM solver. For details see this link


You can use TetGen and just make a z axis which is set to 0 (or any other constant). The issue with DelaunayTriangulation (if you want to generate a mesh from a list of points) is that it returns an adjacency list of the edges, which is very hard to turn into the polygons. This thread describes the issue with it.

Adding a z dimention of 0 is simply:

pts3d = Map[Append[#, 0]&, pts2d]

And then to turn the 3d points back into 2d:

newpts2d = pts3d[[All,1;;2]]
  • $\begingroup$ I'm not sure about using TetGen, as it returns non-zero code when plane is given to be meshed. $\endgroup$
    – Misery
    Aug 27, 2013 at 4:28
  • $\begingroup$ @Mark, I'd be very interested to see a more complete example, could you provide one? $\endgroup$
    – user21
    Aug 28, 2013 at 13:34
  • $\begingroup$ This fails TetGenDelaunay[{1, 1, 0} # & /@ RandomReal[{0, 1}, {100, 3}]] $\endgroup$ Jun 12, 2014 at 3:33

Another approach is to use Imtek's package. These deal with both 2 and 3D with interfaces to Shewchuck's triangle and Tetgen respectively.

Imtek can be had from the University of Freiburg. Documentation is extensive.


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.