From f5135623c1b23ed9769f8072d1e5ca3a6af5194c Mon Sep 17 00:00:00 2001 From: "fahad.alrashed" Date: Sat, 21 Sep 2013 15:52:05 +0000 Subject: [PATCH] added write_visit_record that allows for multiple blocks and more than one time step git-svn-id: https://svn.dealii.org/trunk@30886 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/include/deal.II/base/data_out_base.h | 35 ++++++++++++++++++-- deal.II/source/base/data_out_base.cc | 26 +++++++++++++++ 2 files changed, 59 insertions(+), 2 deletions(-) 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 082e98bb39..9693e21c6f 100644 --- a/deal.II/include/deal.II/base/data_out_base.h +++ b/deal.II/include/deal.II/base/data_out_base.h @@ -2314,8 +2314,8 @@ public: /** * This function is the exact equivalent of the write_pvtu_record() - * function but for the VisIt visualization program. See there for - * the purpose of this function. + * function but for the VisIt visualization program and for one visualization graph + * (or one time step only). See there for the purpose of this function. * * This function is documented in the "Creating a master file for * parallel" section (section 5.7) of the "Getting data into VisIt" @@ -2325,6 +2325,37 @@ 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. 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 > piece_names(number_of_time_steps); + * + * piece_names[0].push_back("subdomain_01.time_step_0.vtk"); + * piece_names[0].push_back("subdomain_02.time_step_0.vtk"); + * + * piece_names[1].push_back("subdomain_01.time_step_1.vtk"); + * piece_names[1].push_back("subdomain_02.time_step_1.vtk"); + * + * piece_names[2].push_back("subdomain_01.time_step_2.vtk"); + * piece_names[2].push_back("subdomain_02.time_step_2.vtk"); + * + * std::ofstream visit_output ("master_file.visit"); + * + * data_out.write_visit_record(visit_output, 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 > &piece_names) const; + /** * Obtain data through get_patches() and write it to out in * SVG format. See DataOutBase::write_svg. diff --git a/deal.II/source/base/data_out_base.cc b/deal.II/source/base/data_out_base.cc index e1238da38b..edb10d95e5 100644 --- a/deal.II/source/base/data_out_base.cc +++ b/deal.II/source/base/data_out_base.cc @@ -6698,6 +6698,32 @@ DataOutInterface::write_visit_record (std::ostream &out, +template +void +DataOutInterface::write_visit_record (std::ostream &out, + const std::vector > &piece_names) const +{ + AssertThrow (out, ExcIO()); + + if (piece_names.size() == 0) + return; + + const double nblocks = piece_names[0].size(); + Assert(nblocks > 0, ExcMessage("piece_names should be a vector of nonempty vectors.") ) + + out << "!NBLOCKS " << nblocks << '\n'; + for (std::vector >::const_iterator domain = piece_names.begin(); domain != piece_names.end(); ++domain) + { + Assert(domain->size() == nblocks, ExcMessage("piece_names should be a vector of equal sized vectors.") ) + for (std::vector::const_iterator subdomain = domain->begin(); subdomain != domain->end(); ++subdomain) + out << *subdomain << '\n'; + } + + out << std::flush; +} + + + template void DataOutInterface:: write_deal_II_intermediate (std::ostream &out) const -- 2.39.5