]> https://gitweb.dealii.org/ - dealii.git/commitdiff
fix hdf5 output for dimension 0 and 1 12171/head
authorMatthias Maier <tamiko@43-1.org>
Mon, 10 May 2021 16:25:03 +0000 (11:25 -0500)
committerMatthias Maier <tamiko@43-1.org>
Mon, 10 May 2021 16:25:03 +0000 (11:25 -0500)
source/base/data_out_base.cc

index 1bc13689b546b88a3a797c451863627da12ad7d4..a8f3d607fc841a344704c40745949d7843a873e2 100644 (file)
@@ -8730,39 +8730,33 @@ XDMFEntry::get_xdmf_content(const unsigned int   indent_level,
   ss << indent(indent_level + 3) << h5_mesh_filename << ":/nodes\n";
   ss << indent(indent_level + 2) << "</DataItem>\n";
   ss << indent(indent_level + 1) << "</Geometry>\n";
+
   // If we have cells defined, use the topology corresponding to the dimension
   if (num_cells > 0)
     {
+      ss << indent(indent_level + 1) << "<Topology TopologyType=\"";
+
       if (dimension == 0)
-        ss << indent(indent_level + 1) << "<Topology TopologyType=\""
-           << "Polyvertex"
-           << "\" NumberOfElements=\"" << num_cells
-           << "\" NodesPerElement=\"1\">\n";
+        {
+          ss << "Polyvertex";
+        }
       else if (dimension == 1)
-        ss << indent(indent_level + 1) << "<Topology TopologyType=\""
-           << "Polyline"
-           << "\" NumberOfElements=\"" << num_cells
-           << "\" NodesPerElement=\"2\">\n";
+        {
+          ss << "Polyline";
+        }
       else if (dimension == 2)
         {
           Assert(reference_cell == ReferenceCells::Quadrilateral ||
                    reference_cell == ReferenceCells::Triangle,
                  ExcNotImplemented());
 
-          ss << indent(indent_level + 1) << "<Topology TopologyType=\"";
           if (reference_cell == ReferenceCells::Quadrilateral)
             {
-              ss << "Quadrilateral"
-                 << "\" NumberOfElements=\"" << num_cells << "\">\n"
-                 << indent(indent_level + 2) << "<DataItem Dimensions=\""
-                 << num_cells << " " << (1 << dimension);
+              ss << "Quadrilateral";
             }
           else // if (reference_cell == ReferenceCells::Triangle)
             {
-              ss << "Triangle"
-                 << "\" NumberOfElements=\"" << num_cells << "\">\n"
-                 << indent(indent_level + 2) << "<DataItem Dimensions=\""
-                 << num_cells << " " << 3;
+              ss << "Triangle";
             }
         }
       else if (dimension == 3)
@@ -8771,24 +8765,29 @@ XDMFEntry::get_xdmf_content(const unsigned int   indent_level,
                    reference_cell == ReferenceCells::Tetrahedron,
                  ExcNotImplemented());
 
-          ss << indent(indent_level + 1) << "<Topology TopologyType=\"";
           if (reference_cell == ReferenceCells::Hexahedron)
             {
-              ss << "Hexahedron"
-                 << "\" NumberOfElements=\"" << num_cells << "\">\n"
-                 << indent(indent_level + 2) << "<DataItem Dimensions=\""
-                 << num_cells << " " << (1 << dimension);
+              ss << "Hexahedron";
             }
           else // if (reference_cell == ReferenceCells::Tetrahedron)
             {
-              ss << "Tetrahedron"
-                 << "\" NumberOfElements=\"" << num_cells << "\">\n"
-                 << indent(indent_level + 2) << "<DataItem Dimensions=\""
-                 << num_cells << " " << 4;
+              ss << "Tetrahedron";
             }
         }
 
-      ss << "\" NumberType=\"UInt\" Format=\"HDF\">\n";
+      ss << "\" NumberOfElements=\"" << num_cells;
+      if (dimension == 0)
+        ss << "\" NodesPerElement=\"1\">\n";
+      else if (dimension == 1)
+        ss << "\" NodesPerElement=\"2\">\n";
+      else
+        // no "NodesPerElement" for dimension 2 and higher
+        ss << "\">\n";
+
+      ss << indent(indent_level + 2) << "<DataItem Dimensions=\"" << num_cells
+         << " " << reference_cell.n_vertices()
+         << "\" NumberType=\"UInt\" Format=\"HDF\">\n";
+
       ss << indent(indent_level + 3) << h5_mesh_filename << ":/cells\n";
       ss << indent(indent_level + 2) << "</DataItem>\n";
       ss << indent(indent_level + 1) << "</Topology>\n";

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.