]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Fix vtu data output with 0 own cells. Before we wrote an empty file, but then the...
authorheister <heister@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 2 Mar 2012 21:06:32 +0000 (21:06 +0000)
committerheister <heister@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 2 Mar 2012 21:06:32 +0000 (21:06 +0000)
git-svn-id: https://svn.dealii.org/trunk@25198 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/source/base/data_out_base.cc

index ebbf91020feb0bde9e74cf053881c23a4048cd71..52fc8725fe69ee861c1b2a178f7bb1b75a0900e4 100644 (file)
@@ -4791,7 +4791,61 @@ void DataOutBase::write_vtu_main (const std::vector<Patch<dim,spacedim> > &patch
   Assert (patches.size() > 0, ExcNoPatches());
 #else
   if (patches.size() == 0)
-    return;
+    {
+      // we still need to output a valid vtu file, because other CPUs
+      // might output data. This is the minimal file that is accepted by paraview and visit.
+      // if we remove the field definitions, visit is complaining.
+      out << "<Piece NumberOfPoints=\"0\" NumberOfCells=\"0\" >\n"
+          << "<Cells>\n"
+          << "<DataArray type=\"UInt8\" Name=\"types\"></DataArray>\n"
+          << "</Cells>\n"
+          << "  <PointData Scalars=\"scalars\">\n";
+      std::vector<bool> data_set_written (data_names.size(), false);
+      for (unsigned int n_th_vector=0; n_th_vector<vector_data_ranges.size(); ++n_th_vector)
+        {
+                                           // mark these components as already
+                                           // written:
+          for (unsigned int i=std_cxx1x::get<0>(vector_data_ranges[n_th_vector]);
+               i<=std_cxx1x::get<1>(vector_data_ranges[n_th_vector]);
+               ++i)
+            data_set_written[i] = true;
+
+                                           // write the
+                                           // header. concatenate all the
+                                           // component names with double
+                                           // underscores unless a vector
+                                           // name has been specified
+          out << "    <DataArray type=\"Float64\" Name=\"";
+
+          if (std_cxx1x::get<2>(vector_data_ranges[n_th_vector]) != "")
+            out << std_cxx1x::get<2>(vector_data_ranges[n_th_vector]);
+          else
+            {
+              for (unsigned int i=std_cxx1x::get<0>(vector_data_ranges[n_th_vector]);
+                   i<std_cxx1x::get<1>(vector_data_ranges[n_th_vector]);
+                   ++i)
+                out << data_names[i] << "__";
+              out << data_names[std_cxx1x::get<1>(vector_data_ranges[n_th_vector])];
+            }
+
+          out << "\" NumberOfComponents=\"3\"></DataArray>\n";
+        }
+
+      for (unsigned int data_set=0; data_set<data_names.size(); ++data_set)
+        if (data_set_written[data_set] == false)
+          {
+            out << "    <DataArray type=\"Float64\" Name=\""
+                << data_names[data_set]
+                << "\"></DataArray>\n";
+          }
+
+      out << "</PointData>\n";
+
+      out
+          << "</Piece>" << std::endl;
+
+      return;
+    }
 #endif
 
   VtuStream vtu_out(out, flags);

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.