Building a .msh file with Matlab

Hello,

I’m trying to build a volume mesh starting from points on a surface.
The points are calculated by surface_evolver, a free tool for fluidic calculations, and lie on the upper surface of a drop.
To build a solid drop underneath, I add some interior points, down to the bottom (z=0) of the drop.
Then, I have the entire grid meshed with Matlab’s delaunayTriangulation.
Still, with Matlab I find the surface triangles and label them.
I write all of this in a .msh format file…

…but when I try to read it with ff++ (readmesh3) it keeps telling me that:


read mesh ok 1Mesh3, num Tetra:= 0, num Vertice:= 0 num boundary Triangles:= 0
Mesh3::readmsh : sorry bad mesh. Number of negative Tet 72
current line = 3
Assertion fail : (0)
line :1137, in file …/femlib/Mesh3dn.cpp
Assertion fail : (0)
line :1137, in file …/femlib/Mesh3dn.cpp
err code 6 , mpirank 0


The number of negative Tets varies according to the initial grid, of course, but negative Tets always exist, and that’s where things get stuck.

I suppose the issue is in the ordering of quadruples where tetrahedra are defined. However, when I tried to calculate the orientation of tetrahedra I obtained confusing results.

Can anybody tell me how to check that a tetrahedron is oriented properly, to possibly correct it?

Thanks in advance,

Paulie

PS if it can be of any help. In a first attempt of mine, I just fed a grid of point to FreeFem and tried to mesh it with tetgconvexhull, but it kept telling me that the point set was trivial. delaunayTriangulation in Matlab works, instead…

PPS working with FreeFem++ 4.5 on Mac Os X (Catalina)

The orientation on a tet with vertices A,B,C,D is

det(AB,AC,AD) >0
where a AB = B-A, …

Frederic Hecht

Dear Frederic, thanks for your reply.
Unfortunately, while the determinants calculated that way are all positive, FreeFem++ still detects negative Tets. However, the (AB,AC,AD) matrices are often ill-conditioned. I guess that’s the issue.
Any suggestions?
Best,
Paulie