It seems something with the automatic MaxCellMeasure
computation is not quite right. Here is a workaround with a manually specified MaxCellMeasure
mr = DiscretizeGraphics[gr];
(*ToElementMesh[mr]*)
ToElementMesh[mr, MaxCellMeasure -> .1]
Update:
This is a bug in TetGen, the mesh generator used.
(bmesh = ToBoundaryMesh[mr]);
pts = bmesh["Coordinates"];
facets = Partition[
Join @@ ElementIncidents[bmesh["BoundaryElements"]], 1];
Graphics3D[GraphicsComplex[pts, Map[Polygon, facets]]]
In the below code, if you change the 0.06 to 0.05, TetGen will fail.
Needs["TetGenLink`"]
inInst = TetGenCreate[];
TetGenSetPoints[inInst, pts];
TetGenSetFacets[inInst, facets];
(* changing "pqa0.006" to "pqa0.005" *)
outInst = TetGenTetrahedralize[inInst, "pqa0.006"];
coords = TetGenGetPoints[outInst];
surface = TetGenGetFaces[outInst];
Graphics3D[GraphicsComplex[coords, Polygon[surface]]]
Since TetGen is software that Wolfram Research purchased for inclusion there is little hope that this bug in TetGen will be fixed by myself or other people at Wolfram Research. Since the workaround is easy:
ToElementMesh[Cuboid[{-h/2, 0, -h/2}, {h/2, L, h/2}],
"MeshElementType" -> TetrahedronElement]
I do not think this is a critical bug. If you deeply care about this, you could try to make use of the TetGenLink that ships with Wolfram products and compile a newer version of TetGen and link and see if the bug has been fixed. Wolfram Products use TetGen version 1.4.3 and the current version is 1.5.1.
Graphics3D[...]
andDiscretizeGraphics[...]
. Remove these andmesh["Wireframe"]
works. $\endgroup$