]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Move DataOutInterface::write_pvd/visit_record() to namespace DataOutBase.
authorWolfgang Bangerth <bangerth@colostate.edu>
Sat, 3 Dec 2016 23:03:08 +0000 (16:03 -0700)
committerWolfgang Bangerth <bangerth@colostate.edu>
Sat, 3 Dec 2016 23:03:08 +0000 (16:03 -0700)
These functions did not depend on the state of the DataOutInterface object and could therefore
be made 'static'. On the other hand, we have traditionally kept such functions in namespace
DataOutBase. Move them there, and deprecate the old versions of these functions.

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

index 4aeeeed31f826658d833691c1507831ffab57cb8..401747de2768059361679f02406177ac4d047a67 100644 (file)
@@ -38,6 +38,18 @@ inconvenience this causes.
 </p>
 
 <ol>
+ <li> Deprecated: The DataOutInterface::write_pvd_record() and
+ DataOutInterface::write_visit_record() functions were actually
+ independent of any kind of data being written. As a consequence,
+ they did not depend on the state of the DataOutInterface object
+ to which they belonged (or any object of a derived class). Such
+ functions typically reside in the DataOutBase namespace instead
+ where they have now been moved. The functions in DataOutInterface
+ are now deprecated.
+ <br>
+ (Wolfgang Bangerth, 2016/12/03)
+ </li>
+
  <li> Changed: VectorTools::create_right_hand_side and
  VectorTools::create_boundary_right_hand_side now take an additional template
  parameter VectorType.
index 2ca81c49f2035006ba5e0d8949e9779af152ee5b..2796d5df9290a112c2c9407e6fc2f39d5a65699d 100644 (file)
@@ -1726,6 +1726,136 @@ namespace DataOutBase
                        const VtkFlags                          &flags,
                        std::ostream                            &out);
 
+  /**
+   * In ParaView it is possible to visualize time-dependent data tagged with
+   * the current integration time of a time dependent simulation. To use this
+   * feature you need a <code>.pvd</code> file that describes which VTU or
+   * PVTU file belongs to which timestep. This function writes a file that
+   * provides this mapping, i.e., it takes a list of pairs each of which
+   * indicates a particular time instant and the corresponding file that
+   * contains the graphical data for this time instant.
+   *
+   * A typical use case, in program that computes a time dependent solution,
+   * would be the following (<code>time</code> and <code>time_step</code> are
+   * member variables of the class with types <code>double</code> and
+   * <code>unsigned int</code>, respectively; the variable
+   * <code>times_and_names</code> is of type
+   * <code>std::vector@<std::pair@<double,std::string@> @></code>):
+   *
+   * @code
+   *  template <int dim>
+   *  void MyEquation<dim>::output_results () const
+   *  {
+   *    DataOut<dim> data_out;
+   *
+   *    data_out.attach_dof_handler (dof_handler);
+   *    data_out.add_data_vector (solution, "U");
+   *    data_out.build_patches ();
+   *
+   *    const std::string filename = "solution-" +
+   *                                 Utilities::int_to_string (timestep_number, 3) +
+   *                                 ".vtu";
+   *    std::ofstream output (filename.c_str());
+   *    data_out.write_vtu (output);
+   *
+   *    times_and_names.push_back (std::pair<double,std::string> (time, filename));
+   *    std::ofstream pvd_output ("solution.pvd");
+   *    DataOutBase::write_pvd_record (pvd_output, times_and_names);
+   *  }
+   * @endcode
+   *
+   * @note See DataOutInterface::write_vtu or DataOutInterface::write_pvtu_record
+   * for writing solutions at each timestep.
+   *
+   * @note The second element of each pair, i.e., the file in which the
+   * graphical data for each time is stored, may itself be again a file that
+   * references other files. For example, it could be the name for a
+   * <code>.pvtu</code> file that references multiple parts of a parallel
+   * computation.
+   *
+   * @author Marco Engelhard, 2012
+   */
+  void write_pvd_record (std::ostream &out,
+                         const std::vector<std::pair<double,std::string> >  &times_and_names);
+
+  /**
+   * This function is the exact equivalent of the write_pvtu_record() function
+   * but for older versions of 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" 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<std::string> &piece_names);
+
+  /**
+   * 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
+   *  const unsigned int number_of_time_steps = 3;
+   *  std::vector<std::vector<std::string > > 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");
+   *
+   *  DataOutBase::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<std::vector<std::string> > &piece_names);
+
+  /**
+   * 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
+   *  const unsigned int number_of_time_steps = 3;
+   *  std::vector<std::pair<double,std::vector<std::string > > > 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");
+   *
+   *  DataOutBase::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<std::pair<double,std::vector<std::string> > > &times_and_piece_names);
+
   /**
    * Write the given list of patches to the output stream in SVG format.
    *
@@ -2177,138 +2307,34 @@ public:
                           const std::vector<std::string> &piece_names) const;
 
   /**
-   * In ParaView it is possible to visualize time-dependent data tagged with
-   * the current integration time of a time dependent simulation. To use this
-   * feature you need a <code>.pvd</code> file that describes which VTU or
-   * PVTU file belongs to which timestep. This function writes a file that
-   * provides this mapping, i.e., it takes a list of pairs each of which
-   * indicates a particular time instant and the corresponding file that
-   * contains the graphical data for this time instant.
-   *
-   * A typical use case, in program that computes a time dependent solution,
-   * would be the following (<code>time</code> and <code>time_step</code> are
-   * member variables of the class with types <code>double</code> and
-   * <code>unsigned int</code>, respectively; the variable
-   * <code>times_and_names</code> is of type
-   * <code>std::vector@<std::pair@<double,std::string@> @></code>):
-   *
-   * @code
-   *  template <int dim>
-   *  void MyEquation<dim>::output_results () const
-   *  {
-   *    DataOut<dim> data_out;
-   *
-   *    data_out.attach_dof_handler (dof_handler);
-   *    data_out.add_data_vector (solution, "U");
-   *    data_out.build_patches ();
-   *
-   *    const std::string filename = "solution-" +
-   *                                 Utilities::int_to_string (timestep_number, 3) +
-   *                                 ".vtu";
-   *    std::ofstream output (filename.c_str());
-   *    data_out.write_vtu (output);
-   *
-   *    times_and_names.push_back (std::pair<double,std::string> (time, filename));
-   *    std::ofstream pvd_output ("solution.pvd");
-   *    data_out.write_pvd_record (pvd_output, times_and_names);
-   *  }
-   * @endcode
-   *
-   * @note See DataOutBase::write_vtu or DataOutInterface::write_pvtu_record
-   * for writing solutions at each timestep.
-   *
-   * @note The second element of each pair, i.e., the file in which the
-   * graphical data for each time is stored, may itself be again a file that
-   * references other files. For example, it could be the name for a
-   * <code>.pvtu</code> file that references multiple parts of a parallel
-   * computation.
-   *
-   * @author Marco Engelhard, 2012
+   * @deprecated Use DataOutBase::write_pvd_record() instead
    */
-  void write_pvd_record (std::ostream &out,
-                         const std::vector<std::pair<double,std::string> >  &times_and_names) const;
+  static void write_pvd_record (std::ostream &out,
+                                const std::vector<std::pair<double,std::string> >  &times_and_names) DEAL_II_DEPRECATED;
 
   /**
-   * This function is the exact equivalent of the write_pvtu_record() function
-   * but for older versions of 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" report that can be
-   * found here:
-   * https://wci.llnl.gov/codes/visit/2.0.0/GettingDataIntoVisIt2.0.0.pdf
+   * @deprecated Use DataOutBase::write_visit_record() instead
    */
-  void write_visit_record (std::ostream &out,
-                           const std::vector<std::string> &piece_names) const;
+  static
+  void
+  write_visit_record (std::ostream &out,
+                      const std::vector<std::string> &piece_names) DEAL_II_DEPRECATED;
 
   /**
-   * 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<dim> data_out;
-   *
-   *  const unsigned int number_of_time_steps = 3;
-   *  std::vector<std::vector<std::string > > 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
+   * @deprecated Use DataOutBase::write_visit_record() instead
    */
-  void write_visit_record (std::ostream &out,
-                           const std::vector<std::vector<std::string> > &piece_names) const;
+  static
+  void
+  write_visit_record (std::ostream &out,
+                      const std::vector<std::vector<std::string> > &piece_names) DEAL_II_DEPRECATED;
 
   /**
-   * 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<dim> data_out;
-   *
-   *  const unsigned int number_of_time_steps = 3;
-   *  std::vector<std::pair<double,std::vector<std::string > > > 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
+   * @deprecated Use DataOutBase::write_visit_record() instead
    */
-  void write_visit_record (std::ostream &out,
-                           const std::vector<std::pair<double,std::vector<std::string> > > &times_and_piece_names) const;
+  static
+  void
+  write_visit_record (std::ostream &out,
+                      const std::vector<std::pair<double,std::vector<std::string> > > &times_and_piece_names) DEAL_II_DEPRECATED;
 
   /**
    * Obtain data through get_patches() and write it to <tt>out</tt> in SVG
index f137ec11c7d34bc5683aa701dd1e2601207ae57c..53ba05fc3cce6eb7116db9cc1a59a543358a41c6 100644 (file)
@@ -5318,6 +5318,110 @@ namespace DataOutBase
   }
 
 
+  void
+  write_pvd_record (std::ostream &out,
+                    const std::vector<std::pair<double,std::string> >  &times_and_names)
+  {
+    AssertThrow (out, ExcIO());
+
+    out << "<?xml version=\"1.0\"?>\n";
+
+    out << "<!--\n";
+    out << "#This file was generated by the deal.II library"
+        << " on " << Utilities::System::get_date()
+        << " at " << Utilities::System::get_time()
+        << "\n-->\n";
+
+    out << "<VTKFile type=\"Collection\" version=\"0.1\" ByteOrder=\"LittleEndian\">\n";
+    out << "  <Collection>\n";
+
+    std::streamsize ss = out.precision();
+    out.precision(12);
+
+    for (unsigned int i=0; i<times_and_names.size(); ++i)
+      out << "    <DataSet timestep=\"" << times_and_names[i].first
+          << "\" group=\"\" part=\"0\" file=\"" << times_and_names[i].second
+          << "\"/>\n";
+
+    out << "  </Collection>\n";
+    out << "</VTKFile>\n";
+
+    out.flush();
+    out.precision(ss);
+
+    AssertThrow (out, ExcIO());
+  }
+
+
+
+  void
+  write_visit_record (std::ostream &out,
+                      const std::vector<std::string> &piece_names)
+  {
+    out << "!NBLOCKS " << piece_names.size() << '\n';
+    for (unsigned int i=0; i<piece_names.size(); ++i)
+      out << piece_names[i] << '\n';
+
+    out << std::flush;
+  }
+
+
+
+  void
+  write_visit_record (std::ostream &out,
+                      const std::vector<std::vector<std::string> > &piece_names)
+  {
+    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<std::vector<std::string> >::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<std::string>::const_iterator subdomain = domain->begin(); subdomain != domain->end(); ++subdomain)
+          out << *subdomain << '\n';
+      }
+
+    out << std::flush;
+  }
+
+
+
+  void
+  write_visit_record (std::ostream &out,
+                      const std::vector<std::pair<double,std::vector<std::string> > > &times_and_piece_names)
+  {
+    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<std::pair<double,std::vector<std::string> > >::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<std::pair<double,std::vector<std::string> > >::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<std::string>::const_iterator subdomain = domain->second.begin(); subdomain != domain->second.end(); ++subdomain)
+          out << *subdomain << '\n';
+      }
+
+    out << std::flush;
+  }
+
+
+
   template <int dim, int spacedim>
   void write_svg (const std::vector<Patch<dim,spacedim> > &,
                   const std::vector<std::string> &,
@@ -6223,43 +6327,6 @@ void DataOutInterface<dim,spacedim>::write_vtu_in_parallel (const char *filename
 }
 
 
-template <int dim, int spacedim>
-void
-DataOutInterface<dim,spacedim>::
-write_pvd_record (std::ostream &out,
-                  const std::vector<std::pair<double,std::string> >  &times_and_names) const
-{
-  AssertThrow (out, ExcIO());
-
-  out << "<?xml version=\"1.0\"?>\n";
-
-  out << "<!--\n";
-  out << "#This file was generated by the deal.II library"
-      << " on " << Utilities::System::get_date()
-      << " at " << Utilities::System::get_time()
-      << "\n-->\n";
-
-  out << "<VTKFile type=\"Collection\" version=\"0.1\" ByteOrder=\"LittleEndian\">\n";
-  out << "  <Collection>\n";
-
-  std::streamsize ss = out.precision();
-  out.precision(12);
-
-  for (unsigned int i=0; i<times_and_names.size(); ++i)
-    out << "    <DataSet timestep=\"" << times_and_names[i].first
-        << "\" group=\"\" part=\"0\" file=\"" << times_and_names[i].second
-        << "\"/>\n";
-
-  out << "  </Collection>\n";
-  out << "</VTKFile>\n";
-
-  out.flush();
-  out.precision(ss);
-
-  AssertThrow (out, ExcIO());
-}
-
-
 template <int dim, int spacedim>
 void
 DataOutInterface<dim,spacedim>::write_pvtu_record (std::ostream &out,
@@ -6360,40 +6427,20 @@ DataOutInterface<dim,spacedim>::write_pvtu_record (std::ostream &out,
 
 template <int dim, int spacedim>
 void
-DataOutInterface<dim,spacedim>::write_visit_record (std::ostream &out,
-                                                    const std::vector<std::string> &piece_names) const
+DataOutInterface<dim,spacedim>::
+write_pvd_record (std::ostream &out,
+                  const std::vector<std::pair<double,std::string> >  &times_and_names)
 {
-  out << "!NBLOCKS " << piece_names.size() << '\n';
-  for (unsigned int i=0; i<piece_names.size(); ++i)
-    out << piece_names[i] << '\n';
-
-  out << std::flush;
+  DataOutBase::write_pvd_record(out, times_and_names);
 }
 
 
-
 template <int dim, int spacedim>
 void
 DataOutInterface<dim,spacedim>::write_visit_record (std::ostream &out,
-                                                    const std::vector<std::vector<std::string> > &piece_names) const
+                                                    const std::vector<std::string> &piece_names)
 {
-  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<std::vector<std::string> >::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<std::string>::const_iterator subdomain = domain->begin(); subdomain != domain->end(); ++subdomain)
-        out << *subdomain << '\n';
-    }
-
-  out << std::flush;
+  DataOutBase::write_visit_record (out, piece_names);
 }
 
 
@@ -6401,30 +6448,19 @@ DataOutInterface<dim,spacedim>::write_visit_record (std::ostream &out,
 template <int dim, int spacedim>
 void
 DataOutInterface<dim,spacedim>::write_visit_record (std::ostream &out,
-                                                    const std::vector<std::pair<double,std::vector<std::string> > > &times_and_piece_names) const
+                                                    const std::vector<std::vector<std::string> > &piece_names)
 {
-  AssertThrow (out, ExcIO());
-
-  if (times_and_piece_names.size() == 0)
-    return;
+  DataOutBase::write_visit_record (out, piece_names);
+}
 
-  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<std::pair<double,std::vector<std::string> > >::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<std::pair<double,std::vector<std::string> > >::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<std::string>::const_iterator subdomain = domain->second.begin(); subdomain != domain->second.end(); ++subdomain)
-        out << *subdomain << '\n';
-    }
-
-  out << std::flush;
+template <int dim, int spacedim>
+void
+DataOutInterface<dim,spacedim>::write_visit_record (std::ostream &out,
+                                                    const std::vector<std::pair<double,std::vector<std::string> > > &times_and_piece_names)
+{
+  DataOutBase::write_visit_record (out, times_and_piece_names);
 }
 
 

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.