# Resolving of internal boundaries when using DistMesh generator

Mesh generator ToElementMesh allows to resolve internal boundaries of the domain to be tesselated:

<< NDSolveFEM
bmesh = ToBoundaryMesh[
"Coordinates" -> {{0, 0.5}, {0., 0.}, {1., 0.}, {1., 1}, {0,
1.}, {0., 0.5}, {1, 0.5}},
"BoundaryElements" -> {LineElement[{{1, 2}, {2, 3}, {3, 4}, {4,
5}, {5, 6}, {6, 7}}]}
];
mesh = ToElementMesh[bmesh];
bmesh["Wireframe"]
mesh["Wireframe"]


I tried to do the same by means of DistMesh generator from FEMAddOns package:

Needs["FEMAddOns"]
DistMesh[bmesh]


Is it possible to resolve internal boundaries when using DistMesh generator? Thanks in advance for any effort to overcome this issue.

No, DistMesh can not resolve internal boundaries. The implementation of DistMesh follows the original paper pretty closely.

That being said, the FEMAddOns have a mesh smoothing function called ElementMeshSmoothing. DistMesh is popular for two reasons. It is a very simple mesh generator and it produces extremely smooth meshes. Now, ElementMeshSmoothing does not reach to 'smoothness' level DistMesh does, mainly because the DistMesh algorithm is very slow. Never the less it may come in handy in some cases. Assuming you are after smooth meshes, then here is an example:

Needs["FEMAddOns"]
mesh = ToElementMesh[
ImplicitRegion[Abs[ 0.7 - Sqrt[ x^2 + y^2 ] ] - 0.3 <= 0, {x, y}],
"RegionHoles" -> None];
mesh["Wireframe"]


Histogram[mesh["Quality"]]


smoothedMesh = ElementMeshSmoothing[mesh]

Show[mesh[
"Wireframe"["MeshElementStyle" -> Directive[EdgeForm[LightGray]]]],
smoothedMesh["Wireframe"]]


Note, that the internal boundary has been preserved.

Histogram[{Join @@ mesh["Quality"], Join @@ smoothedMesh["Quality"]}]


Again, ElementMeshSmoothing is not a silver bullet, but it can help in some cases. Try it out.