From: Wolfgang Bangerth Date: Fri, 13 Jan 2023 20:12:26 +0000 (-0700) Subject: Minor cleanup in the VTU writer. X-Git-Tag: v9.5.0-rc1~645^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F14679%2Fhead;p=dealii.git Minor cleanup in the VTU writer. --- diff --git a/source/base/data_out_base.cc b/source/base/data_out_base.cc index d661106371..2cceadfa09 100644 --- a/source/base/data_out_base.cc +++ b/source/base/data_out_base.cc @@ -5811,23 +5811,17 @@ namespace DataOutBase const std::vector> node_positions = get_node_positions(patches); - // note that according to the standard, we have to print d=1..3 - // dimensions, even if we are in reality in 2d, for example + // VTK/VTU always wants to see three coordinates, even if we are + // in 1d or 2d. So pad node positions with zeros as appropriate. std::vector node_coordinates_3d; node_coordinates_3d.reserve(node_positions.size() * 3); for (const auto &node_position : node_positions) { - node_coordinates_3d.emplace_back(node_position[0]); - - if (spacedim >= 2) - node_coordinates_3d.emplace_back(node_position[1]); - else - node_coordinates_3d.emplace_back(0.0f); - - if (spacedim >= 3) - node_coordinates_3d.emplace_back(node_position[2]); - else - node_coordinates_3d.emplace_back(0.0f); + for (unsigned int d = 0; d < 3; ++d) + if (d < spacedim) + node_coordinates_3d.emplace_back(node_position[d]); + else + node_coordinates_3d.emplace_back(0.0f); } o << vtu_stringize_array(node_coordinates_3d, flags.compression_level,