Reading Geometry data

Querying Geometry information is similar way to querying particles.

 

# This time we query a specific timestep index
timestep_index = 6
# Geometry can also be referred to either by name or by its index
geom_name = "Geometry Box 1"
geom = deck.timestep[timestep_index][geom_name]

Geometries are described by two lists -

  • A list of the coordinates of each vertex
  • A list of groups of vertices (expressed as indices) that form each triangle

coords = geom.getCoords()
triangles = geom.getTriangleNodes()

 

Example

The following example creates an interactive 3D plot all of the geometries in a given Time Step using Matplotlib:

import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
from edempy import Deck
with Deck('RockBox_Example.dem') as deck:
    timestep = deck.timestep[3]
    geometries = timestep.geometry
    ax = plt.axes(projection='3d')
    for i in range(timestep.numGeoms):
        coords = geometries[i].getCoords()
        tri = geometries[i].getTriangleNodes()
        ax.plot_trisurf(
            coords[:,0], # x-coordinates
            coords[:,1], # y-coordinates
            coords[:,2], # z-coordinates
            triangles=tri,
            alpha=0.2,
            color='lightgrey'
        )
plt.show()

Geometry sections also provide access to other information, such as forces, torques and transformations. See the EDEMpy API reference help for more information.

(c) 2023 Altair Engineering Inc. All Rights Reserved.

Intellectual Property Rights Notice | Technical Support