# Mesh definition in 3d is size dependent

Can somebody tell me if this is a bug?

<< NDSolveFEM
Table[
x0 = 2.5;
cords = {{-x0, 0, 0}, {x0, 0, 0}};
r =
RegionDifference[
Cuboid[{- L, -L, -L}, {L, L, L}],
RegionUnion[Ball[#, 1] & /@ cords]];
mesh2 = ToElementMesh[ r, "RegionHoles" -> cords];
mesh2["Wireframe"],
{L, 4, 10, 2}]


As you can see the holes in the middle loose their shape as the outer cube becomes larger.

I've tried two different ways of fixing the problem: defining a MeshRefinementFunction and using implicit region instead of region unions. Neither work. A similar problem I faced with a previous version of Mathematica in 2D is documented here.

If you look carefully at the documentation you can see the same problem:

The inner ellipse has a really bad resolution even though the elements are quite small.

Running 10.3.1 in macosx 10.8.5

It's not a bug this is what is expected. Here is what I get in 10.4.1

<< NDSolveFEM
GraphicsRow[Table[x0 = 2.5;
cords = {{-x0, 0, 0}, {x0, 0, 0}};
r = RegionDifference[Cuboid[{-L, -L, -L}, {L, L, L}],
RegionUnion[Ball[#, 1] & /@ cords]];
mesh2 = ToElementMesh[r, "RegionHoles" -> cords];
mesh2["Wireframe"[PlotRange -> {{-L, L}, {0, L}, {-L, L}}]], {L, 4,
10, 2}], ImageSize -> Full]


You can use "MaxBoundaryCellSize" to resolve the smaller features:

<< NDSolveFEM
GraphicsRow[Table[x0 = 2.5;
cords = {{-x0, 0, 0}, {x0, 0, 0}};
r = RegionDifference[Cuboid[{-L, -L, -L}, {L, L, L}],
RegionUnion[Ball[#, 1] & /@ cords]];
mesh2 =
ToElementMesh[r, "RegionHoles" -> cords,
"MaxBoundaryCellMeasure" -> 1];
mesh2["Wireframe"[PlotRange -> {{-L, L}, {0, L}, {-L, L}}]], {L, 4,
10, 2}], ImageSize -> Full]


• not working in 10.3.1 :( but nice to know it will work when I get my new computer :) Jun 10, 2016 at 0:49
• @tsuresuregusa, that this is not working in 10.3.1 is expected. In 10.4 a new boundary mesh generator for 3D was connected. You might get this to work in 10.3.1 if you use BoundaryDiscretizeRegion and set the option MaxCellMeasure -> {"Length" -> ....}. You can then convert that with ToBoundaryMesh[bmr]. Give that a shot. Jun 10, 2016 at 0:58
• great! Thanks a lot, works as a charm. Jun 10, 2016 at 1:39