The Gradient3D class#
- class pylife.mesh.Gradient3D(pandas_obj)[source]#
Calculate element-shape based gradients for 3D solid elements.
The
gradient_3Daccessor 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,yandzin mm, a scalar value column, and apandas.MultiIndexcontainingelement_idandnode_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
xoryis missing.AttributeError – If the index of the DataFrame does not contain the levels
node_idandelement_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.GradientEstimate gradients from neighboring nodes without relying on element node order.
pylife.mesh.surface.Surface3DDetermine 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_idalready occurred earlier.For a scalar field
vand shape functionsN_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_idgroup and does not average gradients across duplicatednode_idrows; 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 ared{value_key}_dx,d{value_key}_dyandd{value_key}_dzand carry the unit ofvalue_keydivided by mm.- Return type: