The Gradient3D class#

class pylife.mesh.Gradient3D(pandas_obj)[source]#

Calculate element-shape based gradients for 3D solid elements.

The gradient_3D accessor computes derivatives of a scalar nodal quantity on tetrahedral and hexahedral solid elements. This is a key preprocessing step for stress-gradient based FKM support-factor inputs: stress in MPa on coordinates in mm produces gradients in MPa/mm.

Parameters:

pandas_obj (pandas.DataFrame) – Mesh DataFrame with coordinate columns x, y and z in mm, a scalar value column, and a pandas.MultiIndex containing element_id and node_id. Rows within each element must be in the node order exported by Ansys or Abaqus.

Raises:
  • AttributeError – If at least one of the coordinate columns x or y is missing.

  • AttributeError – If the index of the DataFrame does not contain the levels node_id and element_id.

Warns:

UserWarning – If an element contains a number of nodes that is not recognized as a supported tetrahedral or hexahedral 3D element.

See also

pylife.mesh.gradient.Gradient

Estimate gradients from neighboring nodes without relying on element node order.

pylife.mesh.surface.Surface3D

Determine surface nodes and normal vectors used together with stress gradients in FKM assessments.

Notes

Linear tetrahedral elements with 4 nodes and hexahedral elements with 8 nodes are evaluated with their finite-element shape functions. Quadratic tetrahedral elements with 10 nodes and hexahedral elements with 16 or 20 nodes are accepted, but only their first-order corner nodes contribute to the gradient. Additional midside nodes receive zero gradient values in the per-element computation and are dropped if a duplicated node_id already occurred earlier.

For a scalar field v and shape functions N_a, the gradient is evaluated as

\[\nabla v = \sum_a v_a \nabla N_a\]

after mapping derivatives from the reference element to coordinates in mm. Mixed tetrahedral and hexahedral meshes are supported.

This accessor only supports 3D solid elements. It assumes Ansys/Abaqus node ordering inside each element_id group and does not average gradients across duplicated node_id rows; the first occurrence is kept.

gradient_of(value_key)[source]#

Calculate the 3D gradient of a scalar mesh value.

Parameters:

value_key (str) – Name of the column containing the scalar values. If the column contains stress in MPa and coordinates are in mm, the returned gradient is given in MPa/mm.

Returns:

Gradient components indexed by node_id. The columns are d{value_key}_dx, d{value_key}_dy and d{value_key}_dz and carry the unit of value_key divided by mm.

Return type:

pandas.DataFrame