7
$\begingroup$

Can somebody explain me why this happens?

<< NDSolve`FEM`


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"]}]

enter image description here

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.

$\endgroup$

1 Answer 1

7
$\begingroup$

Update: This is fixed in version 11.0:

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

enter image description here

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:

<< NDSolve`FEM`
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"]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.