I have a slight problem with pairing up boundary points of BoundaryMesh with appropriate BoundaryNormals. Let's work with a simple domain for now:
Needs["NDSolve`FEM`"]
box = ToBoundaryMesh[Rectangle[], "MeshOrder" -> 1];
Now the problem is, that box["BoundaryNormals"]
is nested: this will be important later. However, we can unnest it and show the normals:
boxCoords = box["Coordinates"];
normals = Partition[Flatten@box["BoundaryNormals"],2];
Graphics@MapThread[Arrow[{#1, #2}] &, {boxCoords, normals/15 + boxCoords}]
And this shows the problem:
Normals are not appropriately oriented and some of them are messed up on the same side!
My favorite domain is the following:
dom = ImplicitRegion[(x - 1/2)^2 + (y - 1/2)^2 >= (1/4)^2, {{x, 0, 1}, {y, 0, 1}}];
boundary = ToBoundaryMesh[dom, "MeshOrder" -> 1];
bndry = Partition[Flatten[boundary["Coordinates"]], 2];
normals = Partition[Flatten[boundary["BoundaryNormals"]], 2];
Graphics@MapThread[Arrow[{#1, #2}] &, {bndry, normals/15 + bndry}]
Now this is a huge turn off here - what is up with those messed up normals?
My main question is: how can I get for one boundary of the domain the list of correctly paired data?
coordinates = {{x1,y1}, {x2,y2}, ..., {xn, yn}}
normals = {{nx1, ny1}, {nx2, ny2}, ..., {nxn, nyn}};
P.S.: you can check manually for examaple (just to show it's not an issue with the graphic projection):
bndry[[60]]
normals[[60]]
{0., 0.225806}
{0., 1.}
So the "normal" is actually a tangential vector in that point!