Skip to content

anim_to_vtk: 3DELEM/SPHELEM TENSORS blocks transpose the YZ and XZ shear components #116

Description

@pmquang87

Summary

anim_to_vtk writes the symmetric 3×3 matrix of every TENSORS 3DELEM_* and TENSORS SPHELEM_* block with the YZ and XZ shear components transposed: SYZ lands at positions (0,2)/(2,0) and SXZ at (1,2)/(2,1), which is the reverse of the standard symmetric-tensor layout. The 2D (shell) tensor path is correct; only the 6-component 3D and SPH paths are affected.

Evidence

1. Component order of the A-file tensor record is XX, YY, ZZ, XY, YZ, XZ.
The engine documents it in engine/source/output/anim/generate/srota6.F (lines 193–205):

C    1     SX
C    2     SY
C    3     SZ
C    4     SXY
C    5     SYZ
C    6     SXZ
        L12    =TENS(4)
        L23    =TENS(5)
        L13    =TENS(6)

tensor6.F then writes the six values straight through (R4(1)=TENS(1,N)R4(6)=TENS(6,N), CALL WRITE_R_C(R4,6)), and anim_to_vtk reads them flat with no permutation (Ufread(tensVal3DA, sizeof(float), nbElts3D*6*nbTens3D, inf)). So in the tool's 0-based indexing: +3 = SXY, +4 = SYZ, +5 = SXZ.

2. The 3D emit loop places index 4 (SYZ) in row 0 and index 5 (SXZ) in row 1src/anim_to_vtk.cpp lines 1473–1475:

cout << tensVal3DA[(iel * 6) + ...] << " " << tensVal3DA[(iel * 6) + 3 + ...] << " " << tensVal3DA[(iel * 6) + 4 + ...] << "\n";
cout << tensVal3DA[(iel * 6) + 3 + ...] << " " << tensVal3DA[(iel * 6) + 1 + ...] << " " << tensVal3DA[(iel * 6) + 5 + ...] << "\n";
cout << tensVal3DA[(iel * 6) + 4 + ...] << " " << tensVal3DA[(iel * 6) + 5 + ...] << " " << tensVal3DA[(iel * 6) + 2 + ...] << "\n";

The emitted matrix is therefore

XX  XY  YZ
XY  YY  XZ
YZ  XZ  ZZ

whereas the standard symmetric layout (what VTK consumers such as ParaView assume when computing eigenvalues/eigenvectors) is

XX  XY  XZ
XY  YY  YZ
XZ  YZ  ZZ

3. The SPH loop has the identical patternlines 1575–1577 (tensValSPH, same 0,3,4 / 3,1,5 / 4,5,2 offsets).

4. The 2D shell path is correct for contrast — plane stress [s0 s2 0 / s2 s1 0 / 0 0 0], textbook.

Impact

  • Von Mises computed from the emitted tensor is unaffected (the swap permutes the off-diagonal squares).
  • Principal stresses and principal directions are wrong whenever SYZ ≠ SXZ, since the swap changes the third invariant (det). Any downstream eigen-analysis — ParaView's Principal Stress filters, tensor glyphs, user scripts — silently produces incorrect results for solid and SPH tensors.
  • Downstream converters that have hard-coded the transposed layout to compensate will need to track this fix if applied.

Suggested fix

Emit row 0 as indices 0, 3, 5, row 1 as 3, 1, 4, row 2 as 5, 4, 2 in both loops (3D at lines 1473–1475 and SPH at 1575–1577).

Observed in main @ 4e52942 and in the shipped anim_to_vtk_win64.exe from the 2026-05-20 binary bundle.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions