From 09f557f1b537dfd1c418d25769c41413add1df69 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Wed, 7 Aug 2013 21:01:03 +0000 Subject: [PATCH] Patch by Oleh Krehel: allow suppressing writing date and time in generating VTK and VTU output. git-svn-id: https://svn.dealii.org/trunk@30252 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/doc/news/changes.h | 10 ++++ deal.II/include/deal.II/base/data_out_base.h | 16 ++++-- deal.II/source/base/data_out_base.cc | 54 ++++++++++++-------- 3 files changed, 55 insertions(+), 25 deletions(-) diff --git a/deal.II/doc/news/changes.h b/deal.II/doc/news/changes.h index e87472eac8..bf3bd249ee 100644 --- a/deal.II/doc/news/changes.h +++ b/deal.II/doc/news/changes.h @@ -44,6 +44,16 @@ inconvenience this causes.

Specific improvements

    +
  1. + 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. +
    + (Oleh Krehel, 2013/08/06) +
  2. +
  3. Fixed: The various block matrix classes are all derived from BlockMatrixBase which had race conditions when the set() or add() functions were called from diff --git a/deal.II/include/deal.II/base/data_out_base.h b/deal.II/include/deal.II/base/data_out_base.h index b054a3a822..5463fb2762 100644 --- a/deal.II/include/deal.II/base/data_out_base.h +++ b/deal.II/include/deal.II/base/data_out_base.h @@ -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 true. + */ + bool print_date_and_time; + /** * Default constructor. */ - VtkFlags (const double time = std::numeric_limits::min(), - const unsigned int cycle = std::numeric_limits::min()); + VtkFlags (const double time = std::numeric_limits::min(), + const unsigned int cycle = std::numeric_limits::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 diff --git a/deal.II/source/base/data_out_base.cc b/deal.II/source/base/data_out_base.cc index 1638903344..7277a8520d 100644 --- a/deal.II/source/base/data_out_base.cc +++ b/deal.II/source/base/data_out_base.cc @@ -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 > &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 > &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"; - + << "#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 << " > &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::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(ss.str().c_str()), header_size, MPI_CHAR, NULL); } -- 2.39.5