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

Member, Moderator, Employee Posts: 873
100 Answers 500 Comments 250 Likes Second Anniversary
✭✭✭✭
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

  • Member Posts: 10
    Name Dropper Photogenic First Comment
    **
    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

  • Member, Employee Posts: 385
    25 Answers 100 Comments Second Anniversary 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:

    1. dpf.MeshScopingFactory.NodalScoping(NodeIds)
    2.  
    3. def ConvertToNodeIds(SelectionData, SelectionType=None):
    4.     """
    5.     Convert a given Selection Info, (or list of ent/id and Selection Type) to list of Node Ids
    6.     Args:
    7.         SelectionData
    8.         SelectionType (Ansys.ACT.Interfaces.Common.SelectionTypeEnum)
    9.             if SelectionType is used, then SelInfo arg is a list of Ids
    10.     Returns:
    11.         List of node ids
    12.     """
    13.     SelInfo=CreateSelInfo(SelectionData, SelectionType)
    14.     Mesh = ExtAPI.DataModel.MeshDataByName("Global")
    15.     SelTypeStr = str(SelInfo.SelectionType)
    16.     if SelTypeStr == "GeometryEntities":
    17.         Ids = set()
    18.         for Id in SelInfo.Ids:
    19.             MeshRegion = Mesh.MeshRegionById(Id)
    20.             Ids.update(MeshRegion.NodeIds)
    21.         Ids=list(Ids)
    22.     elif SelTypeStr == "MeshNodes":
    23.         Ids= list(SelInfo.Ids)
    24.     elif SelTypeStr == "MeshElements":
    25.         Ids= list(ExtAPI.DataModel.MeshDataByName("Global").NodeIdsFromElementIds(SelInfo.Ids))
    26.     elif SelTypeStr == "MeshElementFaces":
    27.         Ids = set()
    28.         for id,index in zip(SelInfo.Ids, SelInfo.ElementFaceIndices):
    29.             el_face = Ansys.ACT.Common.Mesh.ElementFaceWrapper(Mesh, Mesh.ElementById(id), index)
    30.             Ids.update(el_face.NodeIds)
    31.         Ids= list(Ids)
    32.     return Ids

Welcome!

It looks like you're new here. Sign in or register to get started.