3D mesh from surface meshes

Dear sir,

I need to simulate a complex 3D region.
I was able to produce the surface mesh, but I don’t know how to create 3D mesh (e.g. tetrahedrons) from it.
I tried tetgen (tetg) but it fails when the edge contains a point (gives “PLC Error: A vertex lies in a segment”).
Due to the geometry (see attached file) I am not able to prepare 2D mesh so that on the coincident edges of two adjacent surfaces the number of vertexes is the same.
I have been struggling on this for a while, also looked in the Documentation, Examples, tutorials, General discussion but no solution found…

Thank you very much in advance for your help!
Riccardo

meshtest2.edp (5.7 KB)

I sorry , I try you test , It seems to be good!

Dear Frédéric Hecht,

sorry I think I did not describe the problem clearly.
I attach a new file (meshtest3.edp), where I simply added few lines to show the meshes before glueing:

ThG = buildBdMesh(ThG);
medit(“First_mesh”,Th33,wait=1);
medit(“Second_mesh”,ThLat3,wait=1);
medit(“Union”,ThG,wait=1);
meshS ThGS = ThG.Gamma;
medit(“Surface_mesh”,ThGS,wait=1);
mesh3 Thfinal = tetg(ThGS,switch=“pqaAAYYQ”);

As you can see, the two meshes do not share the same nodes at the boundary, so they actually are not “glued”. To solve the problem (in my case, elasticity), I need to fuse the two meshes together.

I thought to use tetg to accomplish this task, by giving the surface mesh as an input; however tetg requires to have the same nodes on the common edge shared by two surfaces.

To show this, I also tried tetg on a simpler geometry: your example “cylinder-with-tetgen.edp”.
I attached a slightly modified version, where the lateral surface of the cylinder is composed of two surfaces (the first, Thcarre1, between [0, pi] and the other, Thcarre2, between [pi, 2pi]).

cylinder-with-tetgen.edp (2.1 KB)

The code does not work because the two lateral surfaces have a different number of nodes on the length (see line 25 and 26: nx versus nx/2). However if I put the same number of nodes (e.g., nx) the code works fine.

To sum up, I need either to merge together two 3D meshes, or create a unique 3D mesh from the boundary of several 2D meshes, but I was not successful (see meshtest3.edp) and I have not idea how to do it.

Thanks a lot for your help
Riccardo

meshtest3.edp (5.9 KB)

Dear sir,

I wonder if there is any method to glue together two adjacent 3D meshes having non-coincident nodes on the surface separating the two meshes, see my previous post.
Thanks in advance

Best regards
Riccardo

Remark, You error is the compatibly mesh in angle ( you have to set in line 103à)

mesh ThLat=buildmesh(B600(MaxLayersT) + B601(MaxLayersT) + B602(MaxLayersT) + B603(8*nn) + B604(MaxLayersT) + B605(8*nn),fixedborder=1);

and the vertical number are only wrong !!!