# Wrong result for mesh generation when using integers for mesh size

Can somebody explain me why this happens?

<< NDSolveFEM

L = 10;
r = RegionDifference[Rectangle[{-L, -L}, {L, L}], Disk[{0, 0}, 1]];

mesh = ToElementMesh[ r ];

mesh2 = ToElementMesh[
ImplicitRegion[
Abs[x] < L && Abs[y] < L && x^2 + y^2 > 1, {x, y}]];
GraphicsRow[{mesh2["Wireframe"], mesh["Wireframe"]}]

L = 10.;
r = RegionDifference[Rectangle[{-L, -L}, {L, L}], Disk[{0, 0}, 1]];

mesh = ToElementMesh[ r ];

mesh2 = ToElementMesh[
ImplicitRegion[
Abs[x] < L && Abs[y] < L && x^2 + y^2 > 1, {x, y}]];
GraphicsRow[{mesh2["Wireframe"], mesh["Wireframe"]}]


The only difference is that in one case L is an integer and on the other not. The error happens when L<10 but not as bad as in the example. If the radius of the disk in the implicit region is set to 1. the problem disappears.

Update: This is fixed in version 11.0:

<< NDSolveFEM
L = 10;
r = RegionDifference[Rectangle[{-L, -L}, {L, L}], Disk[{0, 0}, 1]];
ToElementMesh[r]["Wireframe"]


Old message:

That's a bug and I have reported it. You have one workaround in your question and here is another one:

ToElementMesh[
ImplicitRegion[-L < x <= L && -L <= y <= L && x^2 + y^2 >= 1, {x,
y}]];


What happens is that the default mesh generator for 2D gets into trouble with the Abs and then the mesh generation falls back to RegionPlot. That however can not deal with holes well, as can be seen.

Another workaround is to specify a larger region bound to ToElementMesh:

<< NDSolveFEM
L = 10;
r = RegionDifference[Rectangle[{-L, -L}, {L, L}], Disk[{0, 0}, 1]];
mesh2 = ToElementMesh[
ImplicitRegion[
Abs[x] < L && Abs[y] < L && x^2 + y^2 > 1, {x, y}], {{-L - 1/10,
L + 1/10}, {-L - 1/10, L + 1/10}}];
mesh2["Wireframe"]