Sometimes Region can't build right region

This is a bug and you should report it to [email protected]. Here is why - simply because DiscretizeRegion has the same problem and does not give a message about it:

a = 600;
reg1 = Rectangle[{0, 0}, {6 a, a}];
hole1 = Disk[{3 a, 0.75 a}, a/8];
hole2 = Disk[{3 a, 0.25 a}, a/8];
hole3 = Disk[{2.5 a, 0.5 a}, a/8];
resreg = RegionDifference[reg1, RegionUnion[hole1, hole2, hole3]];

enter image description here

The finite element functions have the same problem, but they give a message about what is going on. Start with a fresh kernel:

Quit

And then:

a = 600;
reg1 = Rectangle[{0, 0}, {6 a, a}];
hole1 = Disk[{3 a, 0.75 a}, a/8];
hole2 = Disk[{3 a, 0.25 a}, a/8];
hole3 = Disk[{2.5 a, 0.5 a}, a/8];
resreg = RegionDifference[reg1, RegionUnion[hole1, hole2, hole3]];
NDSolve`FEM`ToElementMesh[resreg]

This gives a message:

enter image description here

So now we know that the RegionBounds computation either timed out or was not able to compute the bounds. However, when you call

RegionBounds[resreg]

You will get the bounds. Once the bounds are computed they are cached. That's why we needed the Quit above to make sure that we start from the same state.

As a workaround you can compute the RegionBounds before calling Region, or, if you happen to already have a FEM mesh just use:

 Region[MeshRegion[myFEMMesh]]

or

MeshRegion[myFEMMesh]

If Region cannot do it alone, you try BoundaryDiscretizeRegion with the option MaxCellMeasure to control the resolution of the discretization. In this case, it helps.

length = 0.5;
R = BoundaryDiscretizeRegion[resreg, MaxCellMeasure -> {1 -> length}]

enter image description here

You can obtain a mesh with DiscretizeRegion:

S = DiscretizeRegion[R]

enter image description here

Tags:

Mesh

Regions

Bugs