Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix padding of xdmf vector of len < 3 #3095

Merged
merged 1 commit into from
Mar 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading