Given a generic region, for example:
Ω =
ImplicitRegion[
2 x^2 + 3 y^2 + 2 x y - 2 <= 0 ∧ x^2 + y^2 > .1, {x, y}];
and a non-uniform grid, for example:
Ωb = RegionBounds[Ω];
{xg, yg} =
N@Map[bound \[Function]
Range[bound[[1]],
bound[[2]], (bound[[2]] - bound[[1]])/20], Ωb];
{xg, yg} =
Map[g \[Function] {g[[1]],
Sequence @@ (g[[2 ;; -2]] RandomReal[{1 - .04, 1 + .04},
Length[g] - 2]), g[[-1]]}, {xg, yg}];
which, together, can be shown with:
Ωg =
RegionPlot[Ω, AspectRatio -> Automatic];
gg = Graphics[{LightGray,
Table[
Line[{{x, Ωb[[2, 1]]}, {x, Ωb[[2,
2]]}}], {x, xg}],
Table[
Line[{{Ωb[[1, 1]], y}, {Ωb[[1, 2]],
y}}], {y, yg}]
}];
Show[gg, Ωg]
I'm searching a way to discretize the region to a MeshRegion
or ElementMesh
in such a way that all vertices (MeshCoordinates
or incidents) are placed on at least one gridline.
At present I'm working on a routine that discretize the region with BoundaryDiscretizeRegion
with a reasonable MaxCellMeasure
. Then I'm trying to split all Line
mesh cells crossing any gridline into two or more Line
such that at least one end is on a gridline. Then I plan to delete vertices not on a grid line and properly reconnect the sourronding vertices.
This is the only way I could think to, but it appear difficult, because there are many branches tho examine.
A more elegant and simple approach would be helpful. For example, there is a way to use ToElementMesh
and ToBoundaryMesh
to accomplish this task? In the end, the routine should work with thousand of vertices and hundred of gridlines in a reasonable time.
Comments
Post a Comment