Holes in ElementMesh with ToElementMesh of ImplicitRegion
I hope I interpreted your question correctly that you want a more accurate ElementMesh
representation of the region.
First we create a high quality Graphics
of the region of interest.
isovalue = 1.29897233417072;
(* Add some margins to plot range to get connected region. *)
tolerance = 0.05;
plot = ContourPlot[
f[x, y, 4],
{x, y} ∈ Cuboid[{-0.5, -0.5} - tolerance, {0.5, 0.5} + tolerance],
Contours -> {isovalue},
ColorFunction -> GrayLevel,
(* We need high quality plot for ImageMesh later. *)
PlotPoints -> 200,
Frame -> None
]
Create MeshRegion
from Graphics
object.
mreg = ImageMesh[ColorNegate[plot]]
And convert it to ElementMesh
.
Needs["NDSolve`FEM`"]
mesh = ToElementMesh[mreg,"MeshOrder"->1]
(* ElementMesh[{{7., 353.}, {7., 353.}}, {TriangleElement["<" 1057 ">"]}] *)
mesh["Wireframe"]
Another approach is:
reg = ToElementMesh[
ImplicitRegion[
f[x, y, 4] < isovalue && {x, y} \[Element] cell, {x, y}],
"MaxBoundaryCellMeasure" -> 0.01, MeshQualityGoal -> 1,
PerformanceGoal -> "Quality", MaxCellMeasure -> 0.01,
"BoundaryMeshGenerator" -> {"RegionPlot", "SamplePoints" -> 41}];
reg["Wireframe"]
One thing to be a bit careful about is the question if the holes intersect the boundary. From the mesh it does not look like it but the math might say it.