]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Patch by Oleh Krehel: allow suppressing writing date and time in generating VTK and...
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Wed, 7 Aug 2013 21:01:03 +0000 (21:01 +0000)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Wed, 7 Aug 2013 21:01:03 +0000 (21:01 +0000)
git-svn-id: https://svn.dealii.org/trunk@30252 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/doc/news/changes.h
deal.II/include/deal.II/base/data_out_base.h
deal.II/source/base/data_out_base.cc

index e87472eac821aaf5b760856ae4671c140e3beea5..bf3bd249ee02de4c9147a4a3b9343380f13a20d4 100644 (file)
@@ -44,6 +44,16 @@ inconvenience this causes.
 <h3>Specific improvements</h3>
 
 <ol>
+  <li>
+  New: DataOutBase::VtkFlags now has a flag
+  DataOutBase::VtkFlags::print_date_and_time that can be used to suppress output
+  of date and time in output files. This is useful in test suites where a newer
+  run at a different time produces differences against previously stored files,
+  even though the actual data is exactly the same.
+  <br>
+  (Oleh Krehel, 2013/08/06)
+  </li>
+
   <li>
   Fixed: The various block matrix classes are all derived from BlockMatrixBase
   which had race conditions when the set() or add() functions were called from
index b054a3a822151596ec3a91bf1d646a6759c698b7..5463fb2762d81299d02e425c3641b24d1c718a35 100644 (file)
@@ -1222,11 +1222,21 @@ public:
      */
     unsigned int cycle;
 
+   /**
+     * Flag to determine whether the current
+     * date and time shall be printed as a comment
+     * in the file's second line.
+     *
+     * Default is <tt>true</tt>.
+     */
+    bool print_date_and_time;
+
     /**
      * Default constructor.
      */
-    VtkFlags (const double       time  = std::numeric_limits<double>::min(),
-              const unsigned int cycle = std::numeric_limits<unsigned int>::min());
+    VtkFlags (const double       time   = std::numeric_limits<double>::min(),
+              const unsigned int cycle  = std::numeric_limits<unsigned int>::min(),
+              const bool print_date_and_time = true);
 
     /**
      * Declare the flags with name
@@ -1848,7 +1858,7 @@ public:
    * DataOutInterface::write_vtu_footer() and DataOutInterface::write_vtu_main()
    * by DataOutBase::write_vtu().
    */
-  static void write_vtu_header (std::ostream &out);
+  static void write_vtu_header (std::ostream &out, const VtkFlags &flags);
 
   /**
    * This writes the footer for the xml based vtu file format. This
index 1638903344eea866ff185886b3121e59e3901d64..7277a8520d25fbe043e5c45de8b733b55019579b 100644 (file)
@@ -2194,10 +2194,12 @@ DataOutBase::TecplotFlags::memory_consumption () const
 
 
 DataOutBase::VtkFlags::VtkFlags (const double time,
-                                 const unsigned int cycle)
+                                 const unsigned int cycle,
+                                 const bool print_date_and_time)
   :
   time (time),
-  cycle (cycle)
+  cycle (cycle),
+  print_date_and_time (print_date_and_time)
 {}
 
 
@@ -4945,14 +4947,18 @@ DataOutBase::write_vtk (const std::vector<Patch<dim,spacedim> > &patches,
     std::tm     *time = std::localtime(&time1);
     out << "# vtk DataFile Version 3.0"
         << '\n'
-        << "#This file was generated by the deal.II library on "
-        << time->tm_year+1900 << "/"
-        << time->tm_mon+1 << "/"
-        << time->tm_mday << " at "
-        << time->tm_hour << ":"
-        << std::setw(2) << time->tm_min << ":"
-        << std::setw(2) << time->tm_sec
-        << '\n'
+        << "#This file was generated by the deal.II library";
+    if (flags.print_date_and_time)
+        out << " on "
+            << time->tm_year+1900 << "/"
+            << time->tm_mon+1 << "/"
+            << time->tm_mday << " at "
+            << time->tm_hour << ":"
+            << std::setw(2) << time->tm_min << ":"
+            << std::setw(2) << time->tm_sec;
+    else
+        out << ".";
+    out << '\n'
         << "ASCII"
         << '\n';
     // now output the data header
@@ -5162,7 +5168,8 @@ DataOutBase::write_vtk (const std::vector<Patch<dim,spacedim> > &patches,
 }
 
 
-void DataOutBase::write_vtu_header (std::ostream &out)
+void DataOutBase::write_vtu_header (std::ostream &out,
+                                    const VtkFlags &flags)
 {
   AssertThrow (out, ExcIO());
   std::time_t  time1= std::time (0);
@@ -5171,15 +5178,18 @@ void DataOutBase::write_vtu_header (std::ostream &out)
   out << "<!-- \n";
   out << "# vtk DataFile Version 3.0"
       << '\n'
-      << "#This file was generated by the deal.II library on "
-      << time->tm_year+1900 << "/"
-      << time->tm_mon+1 << "/"
-      << time->tm_mday << " at "
-      << time->tm_hour << ":"
-      << std::setw(2) << time->tm_min << ":"
-      << std::setw(2) << time->tm_sec
-      << "\n-->\n";
-
+      << "#This file was generated by the deal.II library";
+  if (flags.print_date_and_time)
+      out << " on "
+          << time->tm_year+1900 << "/"
+          << time->tm_mon+1 << "/"
+          << time->tm_mday << " at "
+          << time->tm_hour << ":"
+          << std::setw(2) << time->tm_min << ":"
+          << std::setw(2) << time->tm_sec;
+  else
+      out << ".";
+  out << "\n-->\n";
   out << "<VTKFile type=\"UnstructuredGrid\" version=\"0.1\"";
 #ifdef DEAL_II_WITH_ZLIB
   out << " compressor=\"vtkZLibDataCompressor\"";
@@ -5214,7 +5224,7 @@ DataOutBase::write_vtu (const std::vector<Patch<dim,spacedim> > &patches,
                         const VtkFlags                          &flags,
                         std::ostream                            &out)
 {
-  write_vtu_header(out);
+  write_vtu_header(out, flags);
   write_vtu_main (patches, data_names, vector_data_ranges, flags, out);
   write_vtu_footer(out);
 
@@ -6498,7 +6508,7 @@ void DataOutInterface<dim,spacedim>::write_vtu_in_parallel (const char *filename
   if (myrank==0)
     {
       std::stringstream ss;
-      DataOutBase::write_vtu_header(ss);
+      DataOutBase::write_vtu_header(ss, vtk_flags);
       header_size = ss.str().size();
       MPI_File_write(fh, const_cast<char *>(ss.str().c_str()), header_size, MPI_CHAR, NULL);
     }

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.