From: Rene Gassmoeller
Date: Wed, 24 Aug 2016 23:11:34 +0000 (-0600)
Subject: Add .visit time information
X-Git-Tag: v8.5.0-rc1~735^2
X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9b74d16931bfabe8eddd3c2fcd7c0cc678aa6e81;p=dealii.git
Add .visit time information
---
diff --git a/doc/news/changes.h b/doc/news/changes.h
index d255170027..690883db30 100644
--- a/doc/news/changes.h
+++ b/doc/news/changes.h
@@ -38,6 +38,13 @@ inconvenience this causes.
+ - New: There is now the possibility to store information about the
+ time of an output time step within the .visit file created by
+ the DataOutInterface::write_visit_record function.
+
+ (Rene Gassmoeller, Juliane Dannberg, 2016/08/24)
+
+
- New: deal.II now requires at least BOOST version 1.56, rather than the
previous minimal version of 1.54. This is because 1.54 does not support
serializing objects of type std::unique_ptr if C++11 is used, but we now
diff --git a/include/deal.II/base/data_out_base.h b/include/deal.II/base/data_out_base.h
index 0157e5e41f..78eb6e6619 100644
--- a/include/deal.II/base/data_out_base.h
+++ b/include/deal.II/base/data_out_base.h
@@ -2225,6 +2225,42 @@ public:
void write_visit_record (std::ostream &out,
const std::vector > &piece_names) const;
+ /**
+ * This function is equivalent to the write_visit_record() above but for
+ * multiple time steps and with additional information about the time for
+ * each timestep. Here is an example of how the function would be
+ * used:
+ * @code
+ * DataOut data_out;
+ *
+ * const unsigned int number_of_time_steps = 3;
+ * std::vector > > times_and_piece_names(number_of_time_steps);
+ *
+ * times_and_piece_names[0].first = 0.0;
+ * times_and_piece_names[0].second.push_back("subdomain_01.time_step_0.vtk");
+ * times_and_piece_names[0].second.push_back("subdomain_02.time_step_0.vtk");
+ *
+ * times_and_piece_names[1].first = 0.5;
+ * times_and_piece_names[1].second.push_back("subdomain_01.time_step_1.vtk");
+ * times_and_piece_names[1].second.push_back("subdomain_02.time_step_1.vtk");
+ *
+ * times_and_piece_names[2].first = 1.0;
+ * times_and_piece_names[2].second.push_back("subdomain_01.time_step_2.vtk");
+ * times_and_piece_names[2].second.push_back("subdomain_02.time_step_2.vtk");
+ *
+ * std::ofstream visit_output ("master_file.visit");
+ *
+ * data_out.write_visit_record(visit_output, times_and_piece_names);
+ * @endcode
+ *
+ * This function is documented in the "Creating a master file for parallel"
+ * section (section 5.7) of the "Getting data into VisIt" report that can be
+ * found here:
+ * https://wci.llnl.gov/codes/visit/2.0.0/GettingDataIntoVisIt2.0.0.pdf
+ */
+ void write_visit_record (std::ostream &out,
+ const std::vector > > ×_and_piece_names) const;
+
/**
* Obtain data through get_patches() and write it to out in SVG
* format. See DataOutBase::write_svg.
diff --git a/source/base/data_out_base.cc b/source/base/data_out_base.cc
index 3fbe0e9837..43d0829517 100644
--- a/source/base/data_out_base.cc
+++ b/source/base/data_out_base.cc
@@ -6384,6 +6384,37 @@ DataOutInterface::write_visit_record (std::ostream &out,
+template
+void
+DataOutInterface::write_visit_record (std::ostream &out,
+ const std::vector > > ×_and_piece_names) const
+{
+ AssertThrow (out, ExcIO());
+
+ if (times_and_piece_names.size() == 0)
+ return;
+
+ const double nblocks = times_and_piece_names[0].second.size();
+ Assert(nblocks > 0, ExcMessage("time_and_piece_names should contain nonempty vectors of filenames for every timestep.") )
+
+ for (std::vector > >::const_iterator domain = times_and_piece_names.begin();
+ domain != times_and_piece_names.end(); ++domain)
+ out << "!TIME " << domain->first << '\n';
+
+ out << "!NBLOCKS " << nblocks << '\n';
+ for (std::vector > >::const_iterator domain = times_and_piece_names.begin();
+ domain != times_and_piece_names.end(); ++domain)
+ {
+ Assert(domain->second.size() == nblocks, ExcMessage("piece_names should be a vector of equal sized vectors.") )
+ for (std::vector::const_iterator subdomain = domain->second.begin(); subdomain != domain->second.end(); ++subdomain)
+ out << *subdomain << '\n';
+ }
+
+ out << std::flush;
+}
+
+
+
template
void DataOutInterface::
write_deal_II_intermediate (std::ostream &out) const
diff --git a/tests/numerics/data_out_10.cc b/tests/numerics/data_out_10.cc
new file mode 100644
index 0000000000..b45bb696f2
--- /dev/null
+++ b/tests/numerics/data_out_10.cc
@@ -0,0 +1,70 @@
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2016 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+
+// Check that adding time information to a .visit file works as intended
+
+
+#include "../tests.h"
+#include
+#include
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+
+
+
+void test()
+{
+ DataOut<2> data_out;
+
+ const unsigned int number_of_time_steps = 3;
+ std::vector > > times_and_piece_names(number_of_time_steps);
+
+ times_and_piece_names[0].first = 0.0;
+ times_and_piece_names[0].second.push_back("subdomain-01.time_step_0.vtk");
+ times_and_piece_names[0].second.push_back("subdomain-02.time_step_0.vtk");
+
+ times_and_piece_names[1].first = 0.5;
+ times_and_piece_names[1].second.push_back("subdomain-01.time_step_1.vtk");
+ times_and_piece_names[1].second.push_back("subdomain-02.time_step_1.vtk");
+
+ times_and_piece_names[2].first = 1.0;
+ times_and_piece_names[2].second.push_back("subdomain-01.time_step_2.vtk");
+ times_and_piece_names[2].second.push_back("subdomain-02.time_step_2.vtk");
+ data_out.write_visit_record(deallog.get_file_stream(), times_and_piece_names);
+
+ deallog << "OK" << std::endl;
+
+}
+
+
+int main()
+{
+ deal_II_exceptions::disable_abort_on_exception();
+ initlog();
+ test();
+
+}
+
diff --git a/tests/numerics/data_out_10.output b/tests/numerics/data_out_10.output
new file mode 100644
index 0000000000..25888a4bf3
--- /dev/null
+++ b/tests/numerics/data_out_10.output
@@ -0,0 +1,12 @@
+
+!TIME 0.00000
+!TIME 0.500000
+!TIME 1.00000
+!NBLOCKS 2.00000
+subdomain-01.time_step_0.vtk
+subdomain-02.time_step_0.vtk
+subdomain-01.time_step_1.vtk
+subdomain-02.time_step_1.vtk
+subdomain-01.time_step_2.vtk
+subdomain-02.time_step_2.vtk
+DEAL::OK