The basic problem is that the mesh refinement function needs to be compiled (because it is being used as a LibraryLink callback function). When something goes wrong with this automatic compilation, the discretization will proceed but the refinement function will be ignored.
I realize this is not made clear by the documentation, and in any case, there should be at least a warning message. Thank you for bringing this to our attention.
I guess it would’ve been something related to compile, but the function does get evaluated at many points, see example below, so that made me second-guess… Is there a way around it? (slow is OK) I would like to call a nearestfunction generated by nearest (or a regiondistancefunction) (basically refine it more around some points). Basically writing a nearest function myself is possible of course…
ClearAll[meshRefine]
\[CurlyPhi] = 0;
p = {};
Dynamic[\[CurlyPhi]]
meshRefine[vertices_, area_] := (\[CurlyPhi]++;
AppendTo[p, Mean[vertices]]; area > 0.00001)
mesh = Polygon[{{1, 0}, {0, 2.2}, {-1, 0}}];
DiscretizeRegion[mesh, MeshRefinementFunction -> meshRefine]
p // Point // Graphics
Yeah, indeed a warning would’ve been nice well, I guess I have to refine it manually after it somehow… that’s unfortunate…