The meshsignal module¶
Helper to process mesh based data¶
Data that is distributed over a geometrical body, e.g. a stress tensor distribution on a component, is usually transported via a mesh. The meshes are a list of items (e.g. nodes or elements of a FEM mesh), each being described by the geometrical coordinates and the local data values, like for example the local stress tensor data.
In a plain mesh (see PlainMeshAccessor
) there is no further
relation between the items is known, whereas a complete FEM mesh (see
MeshAccessor
) there is also information on the connectivity
of the nodes and elements.
Examples
Read in a mesh from a vmap file:
>>> df = (vm = pylife.vmap.VMAPImport('demos/plate_with_hole.vmap')
.make_mesh('1', 'STATE-2')
.join_variable('STRESS_CAUCHY')
.join_variable('DISPLACEMENT')
.to_frame())
>>> df.head()
x y z S11 S22 S33 S12 S13 S23 dx dy dz
element_id node_id
1 1734 14.897208 5.269875 0.0 27.080811 6.927080 0.0 -13.687358 0.0 0.0 0.005345 0.000015 0.0
1582 14.555333 5.355806 0.0 28.319006 1.178649 0.0 -10.732705 0.0 0.0 0.005285 0.000003 0.0
1596 14.630658 4.908741 0.0 47.701195 5.512213 0.0 -17.866833 0.0 0.0 0.005376 0.000019 0.0
4923 14.726271 5.312840 0.0 27.699907 4.052865 0.0 -12.210032 0.0 0.0 0.005315 0.000009 0.0
4924 14.592996 5.132274 0.0 38.010101 3.345431 0.0 -14.299768 0.0 0.0 0.005326 0.000013 0.0
Get the coordinates of the mesh.
>>> df.plain_mesh.coordinates.head()
x y z
element_id node_id
1 1734 14.897208 5.269875 0.0
1582 14.555333 5.355806 0.0
1596 14.630658 4.908741 0.0
4923 14.726271 5.312840 0.0
4924 14.592996 5.132274 0.0
Now the same with a 2D mesh:
>>> df.drop(columns=['z']).plain_mesh.coordinates.head()
x y
element_id node_id
1 1734 14.897208 5.269875
1582 14.555333 5.355806
1596 14.630658 4.908741
4923 14.726271 5.312840
4924 14.592996 5.132274
-
class
pylife.mesh.meshsignal.
MeshAccessor
(pandas_obj)[source]¶ DataFrame accessor to access FEM mesh data (2D and 3D)
Raises: AttributeError
– if at least one of the columns x, y is missingAttributeError
– if the index of the DataFrame is not a two level MultiIndex with the names node_id and element_id
Notes
The MeshAccessor describes how we expect FEM data to look like. It consists of nodes identified by node_id and elements identified by element_id. A node playing a role in several elements and an element consists of several nodes. So in the DataFrame a node_id can appear multiple times (for each element, the node is playing a role in). Likewise each element_id appears multiple times (for each node the element consists of).
The combination node_id:element_id however, is unique. So the table is indexed by a
pandas.MultiIndex
with the level names node_id, element_id.See also
PlainMeshAccessor
: accesses meshes without connectivity informationpandas.api.extensions.register_dataframe_accessor()
: concept of DataFrame accessorsExamples
For an example see
meshplot
.-
coordinates
¶ Returns the coordinate colums of the accessed DataFrame
Returns: coordinates – The coordinates x, y and if 3D z of the accessed mesh Return type: pandas.DataFrame
-
class
pylife.mesh.meshsignal.
PlainMeshAccessor
(pandas_obj)[source]¶ DataFrame accessor to access plain 2D and 3D mesh data, i.e. without connectivity
Raises: AttributeError
– if at least one of the columns x, y is missingNotes
The PlainMeshAccessor describes meshes whose only geometrical information is the coordinates of the nodes or elements. Unlike
MeshAccessor
they don’t know about connectivity, not even about elements and nodes.See also
MeshAccessor
: accesses meshes with connectivity informationpandas.api.extensions.register_dataframe_accessor()
: concept of DataFrame accessors-
coordinates
¶ Returns the coordinate colums of the accessed DataFrame
Returns: coordinates – The coordinates x, y and if 3D z of the accessed mesh Return type: pandas.DataFrame
-