Skip to content

anim_to_vtk: yz and zx stress components swapped in VTK tensor output (solid & SPH) #106

Description

@pxiaohui2022-crypto

Bug

In output_converters/anim_to_vtk/src/anim_to_vtk.cpp, the 3×3 tensor
matrix written to the legacy VTK TENSORS block places the yz and zx
components in the wrong off-diagonal positions.

The 6 tensor values read from the anim file are ordered xx,yy,zz,xy,yz,zx
(indices 0..5), as the comment at line 576 correctly states.

A symmetric tensor must be written as:

| xx  xy  zx |   indices  | 0  3  5 |
| xy  yy  yz |     -->    | 3  1  4 |
| zx  yz  zz |            | 5  4  2 |

But the current code writes index 4 (yz) at position (1,3)/(3,1) and
index 5 (zx) at position (2,3)/(3,2) — they are swapped.

Affected lines

  • Solid elementsanim_to_vtk.cpp:1473-1475
  • SPH elementsanim_to_vtk.cpp:1575-1577 (identical bug)

The 2D shell block (lines 1366-1369) is correct (only 3 components).

Ground truth

The component order is confirmed by the engine's stress-rotation routine
engine/source/output/anim/generate/srota6.F:200-205:

L11=TENS(1) L22=TENS(2) L33=TENS(3)  -> xx yy zz
L12=TENS(4) L23=TENS(5) L13=TENS(6)  -> xy yz zx

tensor6.F writes TENS(1..6) verbatim into the anim file, so index 4 is
yz and index 5 is zx (= xz).

Suggested fix

In both blocks, swap offsets + 4 and + 5 so the matrix becomes:

// row 1: idx 0, 3, 5
// row 2: idx 3, 1, 4
// row 3: idx 5, 4, 2

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