]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Fix high-order output for vtu in parallel 14276/head
authorPeter Munch <peterrmuench@gmail.com>
Sun, 18 Sep 2022 08:16:53 +0000 (10:16 +0200)
committerPeter Munch <peterrmuench@gmail.com>
Sun, 18 Sep 2022 19:52:55 +0000 (21:52 +0200)
doc/news/changes/incompatibilities/20220918Munch [new file with mode: 0644]
source/base/data_out_base.cc
tests/data_out/data_out_base_vtu_04.with_zlib=on.output
tests/data_out/data_out_base_vtu_05.with_zlib=on.output

diff --git a/doc/news/changes/incompatibilities/20220918Munch b/doc/news/changes/incompatibilities/20220918Munch
new file mode 100644 (file)
index 0000000..dad86fd
--- /dev/null
@@ -0,0 +1,5 @@
+Updated: The version of the vtu output has been increased to 2.2
+if high-order output is requested.
+This is necessary to fix visualization issues in Paraview.
+<br>
+(Peter Munch, Magdalena Schreter, 2022/09/18)
index 0ebfb4e285a2ba9aa155330b718028233658f0a7..6ff70bee332c8de0acfdd82314463403ce0b7fed 100644 (file)
@@ -921,7 +921,8 @@ namespace
   vtk_point_index_from_ijk(const unsigned i,
                            const unsigned j,
                            const unsigned,
-                           const std::array<unsigned, 2> &order)
+                           const std::array<unsigned, 2> &order,
+                           const bool)
   {
     const bool ibdy = (i == 0 || i == order[0]);
     const bool jbdy = (j == 0 || j == order[1]);
@@ -964,12 +965,19 @@ namespace
    *
    * Modified from
    * https://github.com/Kitware/VTK/blob/265ca48a/Common/DataModel/vtkLagrangeHexahedron.cxx#L734
+   * (legacy_format=true) and from
+   * https://github.com/Kitware/VTK/blob/256fe70de00e3441f126276ca4a8c5477d0bcb86/Common/DataModel/vtkHigherOrderHexahedron.cxx#L593
+   * (legacy_format=false). The two versions differ regarding the ordering of
+   * lines 10 and 11 (clockwise vs. anti-clockwise). See also:
+   * https://github.com/Kitware/VTK/blob/7a0b92864c96680b1f42ee84920df556fc6ebaa3/Documentation/release/dev/node-numbering-change-for-VTK_LAGRANGE_HEXAHEDRON.md
+   *
    */
   int
   vtk_point_index_from_ijk(const unsigned                 i,
                            const unsigned                 j,
                            const unsigned                 k,
-                           const std::array<unsigned, 3> &order)
+                           const std::array<unsigned, 3> &order,
+                           const bool                     legacy_format)
   {
     const bool ibdy = (i == 0 || i == order[0]);
     const bool jbdy = (j == 0 || j == order[1]);
@@ -1000,10 +1008,16 @@ namespace
           }
         // !kbdy, On k axis
         offset += 4 * (order[0] - 1) + 4 * (order[1] - 1);
-        return (k - 1) +
-               (order[2] - 1) *
-                 (i != 0u ? (j != 0u ? 3 : 1) : (j != 0u ? 2 : 0)) +
-               offset;
+        if (legacy_format)
+          return (k - 1) +
+                 (order[2] - 1) *
+                   (i != 0u ? (j != 0u ? 3 : 1) : (j != 0u ? 2 : 0)) +
+                 offset;
+        else
+          return (k - 1) +
+                 (order[2] - 1) *
+                   (i != 0u ? (j != 0u ? 2 : 1) : (j != 0u ? 3 : 0)) +
+                 offset;
       }
 
     offset += 4 * (order[0] - 1 + order[1] - 1 + order[2] - 1);
@@ -1040,7 +1054,8 @@ namespace
   vtk_point_index_from_ijk(const unsigned,
                            const unsigned,
                            const unsigned,
-                           const std::array<unsigned, 0> &)
+                           const std::array<unsigned, 0> &,
+                           const bool)
   {
     Assert(false, ExcNotImplemented());
     return 0;
@@ -1052,7 +1067,8 @@ namespace
   vtk_point_index_from_ijk(const unsigned,
                            const unsigned,
                            const unsigned,
-                           const std::array<unsigned, 1> &)
+                           const std::array<unsigned, 1> &,
+                           const bool)
   {
     Assert(false, ExcNotImplemented());
     return 0;
@@ -2965,7 +2981,8 @@ namespace DataOutBase
   template <int dim, int spacedim, typename StreamType>
   void
   write_high_order_cells(const std::vector<Patch<dim, spacedim>> &patches,
-                         StreamType &                             out)
+                         StreamType &                             out,
+                         const bool                               legacy_format)
   {
     Assert(dim <= 3 && dim > 1, ExcNotImplemented());
     unsigned int first_vertex_of_patch = 0;
@@ -3013,7 +3030,8 @@ namespace DataOutBase
                     const unsigned int local_index =
                       i3 * d3 + i2 * d2 + i1 * d1;
                     const unsigned int connectivity_index =
-                      vtk_point_index_from_ijk(i1, i2, i3, cell_order);
+                      vtk_point_index_from_ijk(
+                        i1, i2, i3, cell_order, legacy_format);
                     connectivity[connectivity_index] = local_index;
                   }
 
@@ -5653,7 +5671,7 @@ namespace DataOutBase
     // now for the cells
     out << "CELLS " << n_cells << ' ' << n_points_and_n_cells << '\n';
     if (flags.write_higher_order_cells)
-      write_high_order_cells(patches, vtk_out);
+      write_high_order_cells(patches, vtk_out, /* legacy_format = */ true);
     else
       write_cells(patches, vtk_out);
     out << '\n';
@@ -5802,7 +5820,11 @@ namespace DataOutBase
     else
       out << '.';
     out << "\n-->\n";
-    out << "<VTKFile type=\"UnstructuredGrid\" version=\"0.1\"";
+
+    if (flags.write_higher_order_cells)
+      out << "<VTKFile type=\"UnstructuredGrid\" version=\"2.2\"";
+    else
+      out << "<VTKFile type=\"UnstructuredGrid\" version=\"0.1\"";
 #ifdef DEAL_II_WITH_ZLIB
     out << " compressor=\"vtkZLibDataCompressor\"";
 #endif
@@ -6042,7 +6064,7 @@ namespace DataOutBase
     out << "    <DataArray type=\"Int32\" Name=\"connectivity\" format=\""
         << ascii_or_binary << "\">\n";
     if (flags.write_higher_order_cells)
-      write_high_order_cells(patches, vtu_out);
+      write_high_order_cells(patches, vtu_out, /* legacy_format = */ false);
     else
       write_cells(patches, vtu_out);
     out << "    </DataArray>\n";
index dfc381a0b8e7b43a03b07a985a9a6e2bd81a46ed..1f924321ad58028473fc2d05f97c85f7101b7af6 100644 (file)
@@ -4,7 +4,7 @@
 # vtk DataFile Version 3.0
 #This file was generated 
 -->
-<VTKFile type="UnstructuredGrid" version="0.1" compressor="vtkZLibDataCompressor" byte_order="LittleEndian">
+<VTKFile type="UnstructuredGrid" version="2.2" compressor="vtkZLibDataCompressor" byte_order="LittleEndian">
 <UnstructuredGrid>
 <Piece NumberOfPoints="384" NumberOfCells="24" >
   <Points>
index b22925431b754facdb3b42cac286285090df31f3..9da92020c9fdbe2b22d980d96f725233dcf0695c 100644 (file)
@@ -4,7 +4,7 @@
 # vtk DataFile Version 3.0
 #This file was generated 
 -->
-<VTKFile type="UnstructuredGrid" version="0.1" compressor="vtkZLibDataCompressor" byte_order="LittleEndian">
+<VTKFile type="UnstructuredGrid" version="2.2" compressor="vtkZLibDataCompressor" byte_order="LittleEndian">
 <UnstructuredGrid>
 <Piece NumberOfPoints="384" NumberOfCells="6" >
   <Points>
@@ -15,7 +15,7 @@ AQAAAAASAAAAEgAAOgQAAA==eNrVl19k1WEYx9kfOYrUFNEiRReZ6WaRzvcRi6aLionUJNnFLtau0lUl
 
   <Cells>
     <DataArray type="Int32" Name="connectivity" format="binary">
-AQAAAAAGAAAABgAARwIAAA==eNol02O7HgQAANB3xp1tm3e272zbtm3VbNRWs70aa0bNZs22VeN5nn04P+EEAoFAGKIThWByUYzChCI0EQgiKtEIS0RykJN8FKIIRclNfmKQgtikJglZSE524pCANGQgPolJT2ZiEouUpCIpychKNsIRnkhEJg95KUBB4hKPhCQiLenISCaKU4qqVKIbPRnKIEpQkrJUpDJVCKEc3elBXwYymCH0oh/VaEZNWtKITjSlK7WoRyvaUZeGtKUj1alBc1rQmCZ0pgulKUN5KtCbPvRnALWpQ30a0Jo2tKcDwxjJZCawgd/ZzQ6GM4IfGc9EJjGKMWzkN7byJzvZxSa2MYUFTGcxv7CG+axnBj+xhBXMZi7LWc1UprGQRfzKPNayjtH8wFjGsZktbOcPZjKLn5nDUpaxklXsYT8nOcYLXvOVT+xlH39zlOOc4ACHeMkr3vORz3zhDR84xQ3OcpsrPOE6zznHJe7wgIv8y30ec5oz3OQWV7nGU55xkL84zBHe8o7/+J/zXOAy/3CXezzkUeB78DBEJwrB5KIYhQlFaCIQRFSiEZaI5CAn+ShEEYqSm/zEIAWxSU0SspCc7MQhAWnIQHwSk57MxCQWKUlFUpKRlWyEIzyRiEwe8lKAgsQlHglJRFrSkZFMFKcUValEN3oylEGUoCRlqUhlqhBCObrTg74MZDBD6EU/qtGMmrSkEZ1oSldqUY9WtKMuDWlLR6pTg+a0oDFN6EwXSlOG8lSgN33ozwBqU4f6NKA1bWhPB74BhrqfwQ==
+AQAAAAAGAAAABgAARwIAAA==eNol02O7HgQAANB3xp1tm3e272zbtm3VbNRWs70aa0bNZs22VeN5nn04P+EEAoFAGKIThWByUYzChCI0EQgiKtEIS0RykJN8FKIIRclNfmKQgtikJjnZSUIW4pCANGQgPolJT2ZiEouUpCIpychKNsIRnkhEJg95KUBB4hKPhCQiLenISCaKU4qqVKIbPRnKIEpQkrJUpDJVCKEc3elBXwYymCH0oh/VaEZNWtKUrjSiE7WoRyvaUZeGtKUj1alBc1rQmCZ0pgulKUN5KtCbPvRnALWpQ30a0Jo2tKcDwxjJZCawgd/ZzQ6GM4IfGc9EJjGKMWzkN7byJzvZxSa2MYUFTGcx81nPL6xhBj+xhBXMZi7LWc1UprGQRfzKPNayjtH8wFjGsZktbOcPZjKLn5nDUpaxklXsYT8nOcYLXvOVT+xlH39zlOOc4ACHeMkr3vORz3zhDR84xQ3OcpvrPOcKTzjHJe7wgIv8y30ec5oz3OQWV7nGU55xkL84zBHe8o7/+J/zXOAy/3CXezzkUeB78DBEJwrB5KIYhQlFaCIQRFSiEZaI5CAn+ShEEYqSm/zEIAWxSU1yspOELMQhAWnIQHwSk57MxCQWKUlFUpKRlWyEIzyRiEwe8lKAgsQlHglJRFrSkZFMFKcUValEN3oylEGUoCRlqUhlqhBCObrTg74MZDBD6EU/qtGMmrSkKV1pRCdqUY9WtKMuDWlLR6pTg+a0oDFN6EwXSlOG8lSgN33ozwBqU4f6NKA1bWhPB74Bh9qfwQ==
     </DataArray>
     <DataArray type="Int32" Name="offsets" format="binary">
 AQAAABgAAAAYAAAAGgAAAA==eNpzYGBgaADiA0DMwMjA4ADEDUAMACAtAkQ=

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.