Personal tools
You are here: Home Forum Use Filter on nodes

Filter on nodes

Up to Use
  • Filter on nodes

    Posted by Jayant SEN GUPTA at October 25. 2007
    Hi everybody,

    I'd like to set a filter on nodes whose distance from a point is less than a tolerance. I tried it, and looked for help in the TUI documentation but found nothing.
    I've tried to make a programm in python to do that but as I am not familiar with the objects, I don't know what method to call.

    The algorithm would be as follows (very simple indeed) :

    set a tolerance
    for each index in the index of nodes of a mesh
        get the coordinates of the nodes
        compute the distance between this node and a point
        if d < tol
           add index in vector

    Make a group with the index selected previously


    The real difficulty (for me) is to define the indices of nodes of a mesh... (mesh.GetNodeIds() ? )

    Thanks for your help.

    JSG
    • Re: Filter on nodes

      Posted by Dan Popov at January 15. 2008
      Hi,

      I am not very familiar with Salome, but some times ago I had to get the ID's of all mesh nodes lying on
      the first (geometrical) face of a meshed geometry. I did this with a python script:

      # Get all nodes on first face (face_0):
      nodes_on_face_0 = Mesh_1.GetMesh().CreateGroupFromGEOM(SMESH.NODE, 'nodes_on_face_0', faces_0)

      # Number of nodes
      NbNodesOnFace0 = len( nodes_on_face0.GetListOfID() )
      # Get the ID's of nodes on first face:
      print "List of node IDs which lay on first face:", nodes_on_face0.GetListOfID()
      # Print coordinates of the nodes:
      for i in range ( 0, NbNodesOnFace0 ) :
          print "Coordinates of", [i], ".th node:", Mesh_1.GetNodeXYZ(nodes_on_face0.GetListOfID()[i])

      Hope that helps a little bit. Regards,

      Dan
    • Re: Filter on nodes

      Posted by JMB at September 02. 2008
      Jayant SEN GUPTA wrote:
      Hi everybody,

      I'd like to set a filter on nodes whose distance from a point is less than a tolerance. The algorithm would be as follows (very simple indeed) :

      set a tolerance
      for each index in the index of nodes of a mesh
          get the coordinates of the nodes
          compute the distance between this node and a point
          if d < tol
             add index in vector

      Make a group with the index selected previously

      JSG

      Hello Jayant SEN GUPTA,

      Did you get something like this working?  If so would you be willing to share it here, since I have been looking to doing something similar.  Thank you.

      Regards
      JMB
      • Re: Filter on nodes

        Posted by Jayant SEN GUPTA at December 18. 2008
        JMB wrote:
        Jayant SEN GUPTA wrote:
        Hi everybody,

        I'd like to set a filter on nodes whose distance from a point is less than a tolerance. The algorithm would be as follows (very simple indeed) :

        set a tolerance
        for each index in the index of nodes of a mesh
            get the coordinates of the nodes
            compute the distance between this node and a point
            if d < tol
               add index in vector

        Make a group with the index selected previously

        JSG

        Hello Jayant SEN GUPTA,

        Did you get something like this working?  If so would you be willing to share it here, since I have been looking to doing something similar.  Thank you.

        Regards
        JMB

        I'm sorry JMB, I've just seen your message today.
        I have not solved this problem and made a simple link. If you had found something working well, I'm sure you would have shared it with us.

        If someone else can help, it would be appreciated. 

        thanks
        • Re: Filter on nodes

          Posted by Nicolas Geimer at December 19. 2008
          Dear All,

          You can use FindCoincidentNodes function from smesh Python interface. This function, based on an Octree algorithm, can find coincident nodes with a tolerance. Then the solution for you is to create a node and use this function with the distance as parameter.

          Cheers,

          Nicolas
          • Re: Filter on nodes

            Posted by Erwan ADAM at December 19. 2008

            The script http://erwan.adam.free.fr/salome/scripts/box_and_sphere_on_tolerance.py
            meshes a 100x100x100 box with tetrahedron then create a group "inside" with
            nodes which are in a sphere centered at 50, 50, 50 of radius 50 and a group
            "outside" with the remaining nodes. At the end, it saves a study called
            box_and_sphere_on_tolerance.hdf ...

            To launch this script, load the salome environement and just type :
            python box_and_sphere_on_tolerance.py

            At the end, you should be able to run :
            runSalome box_and_sphere_on_tolerance.hdf

            and display the groups ...

            Does it answer the question ?

            Regards,

                                   E.A.
            • Re: Filter on nodes

              Posted by JMB at December 20. 2008
              ADAM Erwan wrote:

              Does it answer the question ?

              Regards,

                                     E.A.


              Hello Erwan ADAM,

              Thank you for the good suggestion!  I will try it.  I am not a Python programmer so I was hoping that somebody would have incorporated such a script (especially GUI) in the new 4.1.4 version.  In fact, it would be nice to have a selection tool that works in cylindrical and spherical co-ordinates!

              Regards,
              JMB
              • Re: Filter on nodes

                Posted by Erwan ADAM at December 22. 2008
                JMB wrote:
                ADAM Erwan wrote:

                Does it answer the question ?

                Regards,

                                       E.A.



                Hello Erwan ADAM,

                Thank you for the good suggestion!  I will try it.  I am not a Python programmer so I was hoping that somebody would have incorporated such a script (especially GUI) in the new 4.1.4 version.  In fact, it would be nice to have a selection tool that works in cylindrical and spherical co-ordinates!

                Regards,
                JMB


                There is the "set filter" option in "create group" in the MESH module but
                it seems not to work as it should, I look at that. In my opinion, the only way to
                do the required job in 4.1.4 is to write it in python, sorry !

                In a more general way, I found Salome more efficient using python scripts.
                If you are not familiar with python, you can try a new feature of salome 4.1.4,
                the "Dump study" which write the python script corresponding to your study.
                You can modify the scripts and then replay them with the "--execute="
                option of runSalome. OK, it is not perfect but it's work and we will happy
                to have feedback on this feature ...

                Regards,

                                      E.A.

Powered by Ploneboard
Document Actions