# Why isn't ToElementMesh figuring out what my boundary is in 3D?

Bug introduced in 10.2 or earlier, and fixed in 11.0.0

I am trying to change the element mesh for a FEA application I'm doing. I thought I understood it, when I did it in 2D. Here's my shape:

Needs["NDSolveFEM"];
myrect = Rectangle[{0, 0}, {5, 8}];
mydisk = Disk[{2, 4}, 1];
rectcirc = RegionDifference[myrect, mydisk];
rmesh = NDSolveFEMToElementMesh[rectcirc,
MaxCellMeasure -> {"Length" -> .5}]
rmesh["Wireframe"]


If I set the MaxBoundaryCellMeasure to 0.1, it figures out that the boundary is around the inner edge of the rectangle, and outside of the circle, and the mesh is adjusted accordingly:

rmesh2 = NDSolveFEMToElementMesh[rectcirc,
MaxCellMeasure -> {"Length" -> .5}, "MaxBoundaryCellMeasure" -> .1]
rmesh2["Wireframe"]


Now I am trying to do a very similar thing for a 3 dimensional setup:

mycub = Cuboid[{0, 0, 0}, {10, 10, 10}];
mysmallcube = Cuboid[{4, 4, 4}, {6, 6, 6}];
Graphics3D[{Opacity[.1], mycub, Opacity[.4], mysmallcube}]
myreg = RegionDifference[mycub, mysmallcube];
mcm = 1;
cubmesh = NDSolveFEMToElementMesh[myreg, MaxCellMeasure -> mcm]
cubmesh2 =
NDSolveFEMToElementMesh[myreg, "MaxBoundaryCellMeasure" -> .2,
MaxCellMeasure -> mcm]
Print@"only MCM:";
cubmesh["Wireframe"]
cubmesh["Wireframe"[PlotRange -> {All, {4, 6}, All}]]
cubmesh["Wireframe"["MeshElement" -> "MeshElements",
PlotRange -> {All, {4, 6}, All}]]
Print@"MCM and MBCM:";
cubmesh2["Wireframe"[PlotRange -> {All, {4, 6}, All}]]
cubmesh2["Wireframe"["MeshElement" -> "MeshElements",
PlotRange -> {All, {4, 6}, All}]]


Now, it seems like it should behave similarly to the 2D case. It seems like because cubmesh2 has a smaller MaxBoundaryCellMeasure, it should have a finer mesh along its boundaries (inner surface of big cuboid, outer surface of small one), but I'm not seeing that in the output. Both cubmesh and cubmesh2 look exactly the same, but you can tell that this isn't right for cubmesh2, because with its MaxBoundaryCellMeasure of 0.2 and cuboid wall size of 10, there should theoretically be $10/0.2=50$ cells, and there are obviously far fewer than that (I've taken a slice of the graphic and tilted it, to see it easier):

I've read this page but I feel like I'm missing something. I suspect it has something to do with using a BoundaryMesh instead, but I don't really know why. Why isn't this working?

• This is a bug. I'll work on a fix and have that in one of the next releases. Commented Jun 4, 2016 at 1:35
• @user21, whoa, are you a dev for the Mathematica FEM stuff? That would explain why you know so much about it. Commented Jun 4, 2016 at 19:35
• Yes I am one of the developers for the FEM stuff. Commented Jun 4, 2016 at 22:17
• @user21 ah, cool. Well thank you for all the help recently, it's very appreciated. Commented Jun 4, 2016 at 23:53
• @user21 can you elaborate in what the bug is? I can make 3d regions with holes using implicit region but the resolution of the geometry is crap, worst than the 3d example in the documentation. Commented Jun 9, 2016 at 20:26

This is fixed in V11.0:

mycub = Cuboid[{0, 0, 0}, {10, 10, 10}];
mysmallcube = Cuboid[{4, 4, 4}, {6, 6, 6}];
myreg = RegionDifference[mycub, mysmallcube];
mcm = 1;
cubmesh2 =
NDSolveFEMToElementMesh[myreg, "MaxBoundaryCellMeasure" -> .2,
MaxCellMeasure -> mcm];
cubmesh2["Wireframe"[PlotRange -> {All, {4, 6}, All}]]
cubmesh2["Wireframe"["MeshElement" -> "MeshElements",
PlotRange -> {All, {4, 6}, All}]]