FEniCS / dolfinx

Next generation FEniCS problem solving environment
https://fenicsproject.org
GNU Lesser General Public License v3.0
776 stars 181 forks source link

Writing tensor DG0 to VTK is broken #2298

Closed massimiliano-leoni closed 5 months ago

massimiliano-leoni commented 2 years ago

I noticed that the hyperelasticity demo saves the Cauchy stress tensor to XDMF as a continuous function while it should in fact be a [tensor-valued] DG0 function. I tried to achieve that by saving to VTK but it complains that [dolfinx/cpp/dolfinx/io/cells.cpp:162]

throw std::runtime_error("Unknown tetrahedron layout");

in function vtk_tetrahedron which is called with num_nodes equal to 1 [which is very suspicious]. This number comes from dolfinx/cpp/dolfinx/io/vtk_utils.cpp:166 which is

const std::uint32_t num_nodes = V.element()->space_dimension() / element_block_size;

with V.element()->space_dimension() and element_block_size both being equal to 9. Saving only one component to a scalar DG0 VTK file seems to work as expected and the function above is called with num_nodes equal to 4.

The final, and most suspicious, thing I noticed is that at dolfinx/cpp/dolfinx/io/VTKFile.cpp:420, when saving the full tensor-valued sigma, the test if (is_cellwise(*V0)), which I expect should pass for a DG0 function, fails.

garth-wells commented 1 year ago

Is this still an issue?

garth-wells commented 5 months ago

No activity, so closing.