DPF model.metadata.meshed_region properties

Options

For a particular model I see the following:

model = dpf.Model(rstfile)
print(model.metadata.meshed_region.available_property_fields)

Returns:
['connectivity', 'elprops', 'eltype', 'apdl_element_type', 'section', 'mat']

Can you please explain the following:

  • The scheme by which the element connectivity is stored
  • What is stored in elprops
  • What eltype

I have not been able to find definitions for these in the API reference.

Tagged:

Answers

  • Paul Profizi
    Paul Profizi Member, Employee Posts: 11
    5 Likes First Comment First Anniversary First Answer
    edited April 2023
    Options

    Hello @cvaero,

    • The connectivity PropertyField is the element-to-nodes connectivity, giving for each element an ordered list of the indices of the nodes it is made of (the nodes' positions in the MeshedRegion nodes list, not the node IDs). You can see an example of it being defined here.
    • elpropsis a way of storing more efficiently some element properties (is_a_shell, is_a_contact_element...), only used on the Server side, and is for now not usable as is in the client Python API. You should be able to retrieve all the equivalent information using the other properties.
    • eltype gives you the element type ID based on this Enum
  • cvaero
    cvaero Member Posts: 8
    Name Dropper First Comment
    Options

    @Paul Profizi

    The connectivity list returned a 1D array. Different elements in the mesh can have different number of nodes so some additional information would be needed to get to the connectivity of the individual elements. How do I go from that 1D list to the connectivity of individual elements? I understand that there are methods that will return the connectivity of a single element. However if I want to get the connectivity of all elements in a large mesh looping over elements in Python is slow. I am looking for a "vectorized" way of getting the connectivity of all elements for example by getting a list of lists or a 2D array.

  • M
    M Member, Employee Posts: 230
    First Comment First Anniversary Ansys Employee Solution Developer Community of Practice Member
    edited November 2023
    Options

    Neither fast nor recommended, you can loop through the elements and use the property connectivity there to get the node indexes and convert them to a dictionary of the nodes.

    path2file = os.path.join(path2file)
    model = dpf.Model(path2file)
    metadata = model.metadata
    
    mesh = metadata.meshed_region
    
    element_connectivity = {}
    
    nodes = mesh.nodes.scoping.ids 
    elements = mesh.elements.scoping.ids
    
    element_connectivity = {}
    for element in elements:
        node_indexs = mesh.elements.element_by_id(element).connectivity
        element_connectivity[element] = nodes[node_indexs]