Named selection : node ids, position and node connectivity with DPF

Pernelle Marone-Hitz
Pernelle Marone-Hitz Member, Moderator, Employee Posts: 871
500 Comments Photogenic Name Dropper Solution Developer Community of Practice Member
✭✭✭✭
edited June 2023 in Structures

Using DPF in Mechanical how can I get:

  • the ids and position of the nodes of a named selection

  • know to which elements this node is attached to (node connectivity)

?

Tagged:

Best Answer

Answers

  • Adrien Vet
    Adrien Vet Member Posts: 10
    Photogenic First Comment Name Dropper
    **
    edited June 2023

    Hello,

    What is corresponding to "ns_op.inputs.requested_location.Connect('Nodal')" ?

    I mean, what have I to write inside Connect(...) ?

    If I want all the elements ids, it deosn't work when i write ns_op.inputs.requested_location.Connect('Element') or ns_op.inputs.requested_location.Connect('Elemental').

    Thanks,

    Adrien

  • Mike.Thompson
    Mike.Thompson Member, Employee Posts: 336
    25 Answers First Anniversary 100 Comments 25 Likes
    ✭✭✭✭

    This is also a helpful function to convert any selection type in Mechanical to Node Ids (does not need dpf). You can then use this line to make a dpf mesh scoping:

    dpf.MeshScopingFactory.NodalScoping(NodeIds)
    
    def ConvertToNodeIds(SelectionData, SelectionType=None):
        """
        Convert a given Selection Info, (or list of ent/id and Selection Type) to list of Node Ids
        Args:
            SelectionData
            SelectionType (Ansys.ACT.Interfaces.Common.SelectionTypeEnum)
                if SelectionType is used, then SelInfo arg is a list of Ids
        Returns:
            List of node ids
        """
        SelInfo=CreateSelInfo(SelectionData, SelectionType)
        Mesh = ExtAPI.DataModel.MeshDataByName("Global")
        SelTypeStr = str(SelInfo.SelectionType)
        if SelTypeStr == "GeometryEntities":
            Ids = set()
            for Id in SelInfo.Ids:
                MeshRegion = Mesh.MeshRegionById(Id)
                Ids.update(MeshRegion.NodeIds)
            Ids=list(Ids)
        elif SelTypeStr == "MeshNodes":
            Ids= list(SelInfo.Ids)
        elif SelTypeStr == "MeshElements":
            Ids= list(ExtAPI.DataModel.MeshDataByName("Global").NodeIdsFromElementIds(SelInfo.Ids))
        elif SelTypeStr == "MeshElementFaces":
            Ids = set()
            for id,index in zip(SelInfo.Ids, SelInfo.ElementFaceIndices):
                el_face = Ansys.ACT.Common.Mesh.ElementFaceWrapper(Mesh, Mesh.ElementById(id), index)
                Ids.update(el_face.NodeIds)
            Ids= list(Ids)
        return Ids