Skip to content

[BUG] crash when writing xdmf file with "line" cells #1462

@gpbonneau

Description

@gpbonneau

Describe the bug

meshio crashes when writing a mesh containing "line" cells in xdmf format.

To Reproduce

import meshio
import numpy as np

# three lines, two triangles and one quad
points = [
    [0.0, 0.0],
    [1.0, 0.0],
    [0.0, 1.0],
    [1.0, 1.0],
    [2.0, 0.0],
    [2.0, 1.0],
]
cells = [
    ("line", [[0,1], [1,2], [2,3]]),
    ("triangle", [[0, 1, 2], [1, 3, 2]]),
    ("quad", [[1, 4, 5, 3]]),
]

nPoint = len(points)
with meshio.xdmf.TimeSeriesWriter("foo.xdmf") as writer:
    writer.write_points_cells(points, cells)
    for t in [0.0, 0.1, 0.21]:
        data = np.full( nPoint, t)
        writer.write_data(t, point_data={"phi": data})

executing the above code produces a crash with the following error messages:

Traceback (most recent call last):
  File "[...]/meshioWriteXdmf.py", line 21, in <module>
    writer.write_points_cells(points, cells)
  File "[...]/site-packages/meshio/xdmf/time_series.py", line 291, in write_points_cells
    self.cells(cells, grid)
  File "/[...]/site-packages/meshio/xdmf/time_series.py", line 413, in cells
    c.data[:] = np.insert(c.data, 0, 2, axis=1)
    ~~~~~~^^^

Diagnose
I may ask you to cut and paste the output of the following command.

pip freeze | grep meshio
meshio @ file:///home/conda/feedstock_root/build_artifacts/meshio_1706720595231/work

Did I help?

Thank you in advance for your help. Vielen Dank im voraus.

If I was able to resolve your problem, consider sponsoring my work on meshio, or buy me a coffee to say thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions