# Region Holes outer surface

I have a following code:

    bmesh = ToBoundaryMesh[
"Coordinates" -> {{-1, -1}, {1, -1}, {1, 1}, {-1,
1}, {-1/2, -1/2}, {1/2, -1/2}, {1/2, 1/2}, {-1/2, 1/2}},
"BoundaryElements" -> {LineElement[{{1, 2}, {2, 3}, {3, 4}, {4,
1},{5, 6}, {6, 7}, {7, 8}, {8, 5}}]},
"RegionHoles" -> {{0, 0}}];
bmesh["Wireframe"]

ToElementMesh[bmesh]["Wireframe"]


the output is:

How can we create mesh in the inner region and holes/empty at the exterior?

I need something like the following,

==================== Update ==================

How to have regionholes in the smaller rectangular region?

    bmesh = ToBoundaryMesh[
"Coordinates" -> {{1, 1}, {2, 1}, {2, 2}, {1, 2}, {0.5, 1.1}, {1,
1.1}, {1, 1.6}, {0.5, 1.6}},
"BoundaryElements" -> {LineElement[{{1, 2}, {2, 3}, {3, 4}, {4,
1}, {5, 6}, {6, 7}, {7, 8}, {8, 5}}]}];
bmesh["Wireframe"]


You can use "RegionHoles"->None :

bmesh = ToBoundaryMesh[
"Coordinates" -> {{-1, -1}, {1, -1}, {1, 1}, {-1,
1}, {-1/2, -1/2}, {1/2, -1/2}, {1/2, 1/2}, {-1/2, 1/2}},
"BoundaryElements" -> {LineElement[{{1, 2}, {2, 3}, {3, 4}, {4,
1}, {5, 6}, {6, 7}, {7, 8}, {8, 5}}]},
"RegionHoles" -> None];
(*bmesh["Wireframe"]*)
ToElementMesh[bmesh]["Wireframe"]


If you want to remove the outer part, you should start with a smaller boundary mesh region. Having a boundary line and a fully meshed inner region does not work with an ElementMesh. You might be able to do this with a MeshRegion - but you will not be able to use that for a finite element analysis.

Here is an example of a material region and a region hole:

Needs["NDSolveFEM"]
bmesh = ToBoundaryMesh[
"Coordinates" -> {{-1, -1}, {1, -1}, {1, 1}, {-1,
1}, {-1/2, -1/2}, {1/2, -1/2}, {1/2, 1/2}, {-1/2,
1/2}, {-4/5, -4/5}, {-3/5, -4/5}, {-3/5, -3/5}, {-4/5, -3/5}},
"BoundaryElements" -> {LineElement[{{1, 2}, {2, 3}, {3, 4}, {4,
1}, {5, 6}, {6, 7}, {7, 8}, {8, 5}, {9, 10}, {10, 11}, {11,
12}, {12, 9}}]}, "RegionHoles" -> {{-7/10, -7/10}}];
(*bmesh["Wireframe"]*)
ToElementMesh[bmesh, MaxCellMeasure -> 0.005]["Wireframe"]


Here the region touches the boundary and is correctly removed:

Needs["NDSolveFEM"]
ToElementMesh[
RegionDifference[
RegionDifference[Rectangle[{-1, -1}, {1, 1}],
Rectangle[{-1, -4/5}, {-3/5, -3/5}]],
Rectangle[{-1/2, -1/2}, {1/2, 1/2}]], MaxCellMeasure -> 0.005,
"RegionHoles" -> None]["Wireframe"]


The mesh you want to use, if that's for finite element analysis then it's not valid. You can get very close to the boundary but not touch it.

Needs["NDSolveFEM"]
ToElementMesh[
RegionDifference[Rectangle[{-1, -1}, {1, 1}],
RegionUnion[Rectangle[{-99/100, -4/5}, {-3/5, -3/5}],
Rectangle[{-1/2, -1/2}, {1/2, 1/2}]]], MaxCellMeasure -> 0.005,
"RegionHoles" -> None]["Wireframe"]


• In the original problem, I need to have a fully meshed inner region and within a boundary line I have boundary conditions/ boundary contact lets say a small rectangle at right top and left bottom. So, that's why I want to have an empty boundary region, which has boundary conditions and inner fully meshed region. will I be able to use that for finite element analysis.
– a019
Jan 31 at 14:04
• @MuhammadAli, I have trouble understanding what you need. Can you make a drawing? Jan 31 at 16:36
• I edited the question, can we have this? if not that's fine as well.
– a019
Feb 1 at 8:42
• @MuhammadAli, we can have something like as a MeshRegion this but not as finite element mesh. What do you want to do with this? Also, the boundary conditions are not in contact with the domain - there are not really a boundary. I think what you really want is a full mesh in each region but different material coefficients in them. Feb 1 at 9:26
• @MuhammadAli, you'd need to mesh all of the domain. See for example this Feb 1 at 12:01