The surface to which an element belongs

Options
Akane Ito
Akane Ito Member Posts: 25
First Comment Name Dropper

Is it possible to obtain the faceId to which a certain element belongs?

Answers

  • Pernelle Marone-Hitz
    Pernelle Marone-Hitz Member, Moderator, Employee Posts: 831
    First Comment First Anniversary Ansys Employee Solution Developer Community of Practice Member
    Options

    Please clarify your question: what tool are you using ? Mechanical, MAPDL, PyMechanical, PyMAPDL?

  • Akane Ito
    Akane Ito Member Posts: 25
    First Comment Name Dropper
    Options

    It's Mechanical.

  • Pernelle Marone-Hitz
    Pernelle Marone-Hitz Member, Moderator, Employee Posts: 831
    First Comment First Anniversary Ansys Employee Solution Developer Community of Practice Member
    Options

    This should help: https://discuss.ansys.com/discussion/comment/3689#Comment_3689?utm_source=community-search&utm_medium=organic-search&utm_term=MeshData You would have to adapt it to get the face in geobody, instead of the entire body, but the principle stays the same.

  • Akane Ito
    Akane Ito Member Posts: 25
    First Comment Name Dropper
    Options

    Dear Pernelle Marone-Hitz
    I tried it using the method I was taught, but it didn't work out. If possible, please provide specific instructions.

  • Pernelle Marone-Hitz
    Pernelle Marone-Hitz Member, Moderator, Employee Posts: 831
    First Comment First Anniversary Ansys Employee Solution Developer Community of Practice Member
    edited March 12
    Options

    The only thing to add from the previous script is to loop on the faces of the geobody.

    element_id  = 25
    mesh_data = ExtAPI.DataModel.Project.Model.Analyses[0].MeshData
    bodies = ExtAPI.DataModel.Project.Model.Geometry.GetChildren(DataModelObjectCategory.Body, True)
    for body in bodies:
        geobody = body.GetGeoBody()
        for face in geobody.Faces:
            mesh_for_face = mesh_data.MeshRegionById(face.Id)
            if element_id in mesh_for_face.ElementIds:
                print('Element ' + str(element_id) + ' is in face : ' + str(face.Id))
    
  • Akane Ito
    Akane Ito Member Posts: 25
    First Comment Name Dropper
    Options

    Dear Pernelle Marone-Hitz
    Thank you for teaching me. It was very helpful!