Skip to content

Commit

Permalink
Fix padding of xdmf vector of len < 3 (#3095)
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgensd authored Mar 11, 2024
1 parent 1ccffb0 commit 786d38d
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cpp/dolfinx/io/xdmf_function.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ void xdmf_function::add_function(MPI_Comm comm, const fem::Function<T, U>& u,
std::span<const std::size_t> value_shape = u.function_space()->value_shape();
int num_components = std::reduce(value_shape.begin(), value_shape.end(), 1,
std::multiplies{});
// Pad to 3D if vector is 1 or 2D, to ensure that we can visualize them
// correctly in Paraview
if (value_shape.size() == 1 && value_shape.front() < 3)
num_components = 3;

// Get fem::Function data values and shape
std::vector<T> data_values;
Expand Down

0 comments on commit 786d38d

Please sign in to comment.