How to save neighbour list of mesh nodes

  • Debabrata Deb
    Debabrata Deb

    Hello there,

    I want to distribute (~ equidistant) some points over different types of surfaces. For that I would generate a mesh over the surface and take the nodes of the mesh as my desired points.

    Now after generating the mesh points (nodes), I need to know the nearest neighbours of each of the nodes. So, What I need to know is that is there any standard way to get the nearest neighbour list from NetGen as an output from a generated mesh?

    Thanks in advance


    • Hi DD,

      Netgen stores the surfaceelement to vertex table.
      You can transpose it, to get the vertex-to-surfaceelement table.
      Then you can implment simple graph algorithms to find (topologically) close neighbours.

      good luck,


    • Hello DD,

      Sorry for the delay in replying to your query....

      I have been thinking about your requirement, and I think the best way to go, is to use the "nglib" netgen core library.

      What you need to do, is to create a customised top-level code which uses the netgen library to load a mesh which you save from the graphical version of Netgen (in the vol format).... extract vertex neighbour data and save it into a file.

      As Joachim has pointed out, Netgen maintains a topology tree, and internally, also provides functions to go from a vertex to a surface element (Joachim.... GetVertexSurfaceElements in the topology.h file).

      So basically, you can iterate over the points of the mesh... for each point, get the surface elements it belongs to, and from the surface elements, get the remaining points.... Each point which belongs to a surface element to which your point of interest belongs, would be a "neighbouring point" right?

      Now... for the basic problem :-)! The "nglib" library does not yet provide access to the mesh topology extraction utility functions...... after a first look, I dont think implementing that functionality into nglib is a big issue....

      How urgent is your requirement?

      Have a nice day!


    • Debabrata Deb
      Debabrata Deb

      hello there,

      I just have been busy with some of my other works (of course including exploring netgen).  So here is a late reply.

      I just have successfully managed to create a neighbour list from a the mesh. If any one wants then I can share the code (written in c) too!!! and I implemented the idea of Philippose. thanks for the help.

      Now I just happened to have another question. is there any way to extract the information like volume and surface area included by the meshed surface??