finite element method – Looking for direct neighbors in a trianglemesh

You can use a FEM mesh for that:

Needs["NDSolve`FEM`"]

netz = netz["MakeRepresentation"["ElementMesh"]];

The connectivity is encoded:

{{{0, 3, 6}, {4, 10, 3}, {2, 1, 5}, {0, 2, 5}, {4, 3, 0}, {12, 1, 
   15}, {9, 14, 15}, {9, 10, 0}, {8, 11, 7}, {8, 15, 2}, {0, 18, 
   9}, {0, 6, 17}, {16, 18, 0}, {7, 16, 17}, {10, 7, 6}, {0, 14, 
   13}, {14, 0, 12}, {19, 13, 11}, {0, 18, 0}}}

And documented here.

If you are looking for the point element connectivity, that can also be had:

netz["VertexElementConnectivity"]

This give a sparse array representation and is documented here.

MatrixPlot[netz["VertexElementConnectivity"]]

enter image description here

So node 6 is connected to elements:

temp = netz["VertexElementConnectivity"][[6]]["NonzeroPositions"]
{{2}, {3}, {4}, {5}}

You can then use:

Union[Flatten[
  Extract[Join @@ ElementIncidents[netz["MeshElements"]], 
  temp]]]

{2, 4, 5, 6, 9}

Various other connectivity information is also available.

Read more here: Source link