const VtkFlags &flags);
/**
- * This writes the footer for the xml based vtu file format. This routine is
+ * This function writes the footer for the xml based vtu file format. This routine is
* used internally together with DataOutInterface::write_vtu_header() and
* DataOutInterface::write_vtu_main() by DataOutBase::write_vtu().
*/
void write_vtu_footer (std::ostream &out);
/**
- * This writes the main part for the xml based vtu file format. This routine
+ * This function writes the main part for the xml based vtu file format. This routine
* is used internally together with DataOutInterface::write_vtu_header() and
* DataOutInterface::write_vtu_footer() by DataOutBase::write_vtu().
*/
const VtkFlags &flags,
std::ostream &out);
+ /**
+ * Some visualization programs, such as ParaView, can read several separate
+ * VTU files that all form part of the same simulation, in order to
+ * parallelize visualization. In that case, you need a
+ * <code>.pvtu</code> file that describes which VTU files (written, for
+ * example, through the DataOutInterface::write_vtu() function) form a group.
+ * The current function can generate such a master record.
+ *
+ * This function is typically not called by itself from user space, but
+ * you may want to call it through DataOutInterface::write_pvtu_record()
+ * since the DataOutInterface class has access to information that you
+ * would have to provide to the current function by hand.
+ *
+ * In any case, whether this function is called directly or via
+ * DataOutInterface::write_pvtu_record(), the master record file so
+ * written contains a list of (scalar or vector) fields that describes which
+ * fields can actually be found in the individual files that comprise the set of
+ * parallel VTU files along with the names of these files. This function
+ * gets the names and types of fields through the third and fourth
+ * argument; you can determine these by hand, but in practice, this function
+ * is most easily called by calling DataOutInterfaces::write_pvtu_record(),
+ * which determines the last two arguments by calling
+ * DataOutInterface::get_dataset_names() and
+ * DataOutInterface::get_vector_data_ranges() functions. The second argument
+ * to this function specifies the names of the files that form the parallel
+ * set.
+ *
+ * @note Use DataOutBase::write_vtu() and DataOutInterface::write_vtu()
+ * for writing each piece. Also note that
+ * only one parallel process needs to call the current function, listing the
+ * names of the files written by all parallel processes.
+ *
+ * @note In order to tell Paraview to group together multiple
+ * <code>pvtu</code> files that each describe one time step of a time
+ * dependent simulation, see the DataOutBase::write_pvd_record()
+ * function.
+ *
+ * @note Older versions of VisIt (before 2.5.1), can not read
+ * <code>pvtu</code> records. However, it can read visit records as written
+ * by the write_visit_record() function.
+ */
+ void
+ write_pvtu_record (std::ostream &out,
+ const std::vector<std::string> &piece_names,
+ const std::vector<std::string> &data_names,
+ const std::vector<std_cxx11::tuple<unsigned int, unsigned int, std::string> > &vector_data_ranges);
+
/**
* In ParaView it is possible to visualize time-dependent data tagged with
* the current integration time of a time dependent simulation. To use this
* }
* @endcode
*
- * @note See DataOutInterface::write_vtu or DataOutInterface::write_pvtu_record
+ * @note See DataOutInterface::write_vtu, DataOutInterface::write_pvtu_record,
+ * and DataOutInterface::write_vtu_in_parallel
* for writing solutions at each timestep.
*
* @note The second element of each pair, i.e., the file in which the
* performance on parallel filesystems. Also see
* DataOutInterface::write_vtu().
*/
- void write_vtu_in_parallel (const char *filename, MPI_Comm comm) const;
+ void write_vtu_in_parallel (const char *filename,
+ MPI_Comm comm) const;
/**
* Some visualization programs, such as ParaView, can read several separate
- * VTU files to parallelize visualization. In that case, you need a
+ * VTU files that all form part of the same simulation, in order to
+ * parallelize visualization. In that case, you need a
* <code>.pvtu</code> file that describes which VTU files (written, for
- * example, through the write_vtu() function) form a group. The current
- * function can generate such a master record.
+ * example, through the DataOutInterface::write_vtu() function) form a group.
+ * The current function can generate such a master record.
*
- * The file so written contains a list of (scalar or vector) fields whose
- * values are described by the individual files that comprise the set of
+ * The master record file generated by this function
+ * contains a list of (scalar or vector) fields that describes which
+ * fields can actually be found in the individual files that comprise the set of
* parallel VTU files along with the names of these files. This function
- * gets the names and types of fields through the get_patches() function of
- * this class like all the other write_xxx() functions. The second argument
+ * gets the names and types of fields through the get_dataset_names() and
+ * get_vector_data_ranges() functions of this class. The second argument
* to this function specifies the names of the files that form the parallel
* set.
*
- * @note See DataOutBase::write_vtu for writing each piece. Also note that
+ * @note Use DataOutBase::write_vtu() and DataOutInterface::write_vtu()
+ * for writing each piece. Also note that
* only one parallel process needs to call the current function, listing the
* names of the files written by all parallel processes.
*
*
* @note In order to tell Paraview to group together multiple
* <code>pvtu</code> files that each describe one time step of a time
- * dependent simulation, see the DataOutInterface::write_pvd_record()
+ * dependent simulation, see the DataOutBase::write_pvd_record()
* function.
*
* @note Older versions of VisIt (before 2.5.1), can not read
}
+
+ void
+ write_pvtu_record (std::ostream &out,
+ const std::vector<std::string> &piece_names,
+ const std::vector<std::string> &data_names,
+ const std::vector<std_cxx11::tuple<unsigned int, unsigned int, std::string> > &vector_data_ranges)
+ {
+ AssertThrow (out, ExcIO());
+
+ const unsigned int n_data_sets = data_names.size();
+
+ 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=\"PUnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\">\n";
+ out << " <PUnstructuredGrid GhostLevel=\"0\">\n";
+ out << " <PPointData Scalars=\"scalars\">\n";
+
+ // We need to output in the same order as
+ // the write_vtu function does:
+ std::vector<bool> data_set_written (n_data_sets, false);
+ for (unsigned int n_th_vector=0; n_th_vector<vector_data_ranges.size(); ++n_th_vector)
+ {
+ AssertThrow (std_cxx11::get<1>(vector_data_ranges[n_th_vector]) >=
+ std_cxx11::get<0>(vector_data_ranges[n_th_vector]),
+ ExcLowerRange (std_cxx11::get<1>(vector_data_ranges[n_th_vector]),
+ std_cxx11::get<0>(vector_data_ranges[n_th_vector])));
+ AssertThrow (std_cxx11::get<1>(vector_data_ranges[n_th_vector]) < n_data_sets,
+ ExcIndexRange (std_cxx11::get<1>(vector_data_ranges[n_th_vector]),
+ 0, n_data_sets));
+ AssertThrow (std_cxx11::get<1>(vector_data_ranges[n_th_vector]) + 1
+ - std_cxx11::get<0>(vector_data_ranges[n_th_vector]) <= 3,
+ ExcMessage ("Can't declare a vector with more than 3 components "
+ "in VTK"));
+
+ // mark these components as already
+ // written:
+ for (unsigned int i=std_cxx11::get<0>(vector_data_ranges[n_th_vector]);
+ i<=std_cxx11::get<1>(vector_data_ranges[n_th_vector]);
+ ++i)
+ data_set_written[i] = true;
+
+ // write the
+ // header. concatenate all the
+ // component names with double
+ // underscores unless a vector
+ // name has been specified
+ out << " <PDataArray type=\"Float64\" Name=\"";
+
+ if (std_cxx11::get<2>(vector_data_ranges[n_th_vector]) != "")
+ out << std_cxx11::get<2>(vector_data_ranges[n_th_vector]);
+ else
+ {
+ for (unsigned int i=std_cxx11::get<0>(vector_data_ranges[n_th_vector]);
+ i<std_cxx11::get<1>(vector_data_ranges[n_th_vector]);
+ ++i)
+ out << data_names[i] << "__";
+ out << data_names[std_cxx11::get<1>(vector_data_ranges[n_th_vector])];
+ }
+
+ out << "\" NumberOfComponents=\"3\" format=\"ascii\"/>\n";
+ }
+
+ for (unsigned int data_set=0; data_set<n_data_sets; ++data_set)
+ if (data_set_written[data_set] == false)
+ {
+ out << " <PDataArray type=\"Float64\" Name=\""
+ << data_names[data_set]
+ << "\" format=\"ascii\"/>\n";
+ }
+
+ out << " </PPointData>\n";
+
+ out << " <PPoints>\n";
+ out << " <PDataArray type=\"Float64\" NumberOfComponents=\"3\"/>\n";
+ out << " </PPoints>\n";
+
+ for (unsigned int i=0; i<piece_names.size(); ++i)
+ out << " <Piece Source=\"" << piece_names[i] << "\"/>\n";
+
+ out << " </PUnstructuredGrid>\n";
+ out << "</VTKFile>\n";
+
+ out.flush();
+
+ // assert the stream is still ok
+ AssertThrow (out, ExcIO());
+ }
+
+
+
void
write_pvd_record (std::ostream &out,
const std::vector<std::pair<double,std::string> > ×_and_names)
DataOutInterface<dim,spacedim>::write_pvtu_record (std::ostream &out,
const std::vector<std::string> &piece_names) const
{
- AssertThrow (out, ExcIO());
-
- const std::vector<std::string> data_names = get_dataset_names();
- const std::vector<std_cxx11::tuple<unsigned int, unsigned int, std::string> > vector_data_ranges
- = get_vector_data_ranges();
-
- const unsigned int n_data_sets = data_names.size();
-
- 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=\"PUnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\">\n";
- out << " <PUnstructuredGrid GhostLevel=\"0\">\n";
- out << " <PPointData Scalars=\"scalars\">\n";
-
- // We need to output in the same order as
- // the write_vtu function does:
- std::vector<bool> data_set_written (n_data_sets, false);
- for (unsigned int n_th_vector=0; n_th_vector<vector_data_ranges.size(); ++n_th_vector)
- {
- AssertThrow (std_cxx11::get<1>(vector_data_ranges[n_th_vector]) >=
- std_cxx11::get<0>(vector_data_ranges[n_th_vector]),
- ExcLowerRange (std_cxx11::get<1>(vector_data_ranges[n_th_vector]),
- std_cxx11::get<0>(vector_data_ranges[n_th_vector])));
- AssertThrow (std_cxx11::get<1>(vector_data_ranges[n_th_vector]) < n_data_sets,
- ExcIndexRange (std_cxx11::get<1>(vector_data_ranges[n_th_vector]),
- 0, n_data_sets));
- AssertThrow (std_cxx11::get<1>(vector_data_ranges[n_th_vector]) + 1
- - std_cxx11::get<0>(vector_data_ranges[n_th_vector]) <= 3,
- ExcMessage ("Can't declare a vector with more than 3 components "
- "in VTK"));
-
- // mark these components as already
- // written:
- for (unsigned int i=std_cxx11::get<0>(vector_data_ranges[n_th_vector]);
- i<=std_cxx11::get<1>(vector_data_ranges[n_th_vector]);
- ++i)
- data_set_written[i] = true;
-
- // write the
- // header. concatenate all the
- // component names with double
- // underscores unless a vector
- // name has been specified
- out << " <PDataArray type=\"Float64\" Name=\"";
-
- if (std_cxx11::get<2>(vector_data_ranges[n_th_vector]) != "")
- out << std_cxx11::get<2>(vector_data_ranges[n_th_vector]);
- else
- {
- for (unsigned int i=std_cxx11::get<0>(vector_data_ranges[n_th_vector]);
- i<std_cxx11::get<1>(vector_data_ranges[n_th_vector]);
- ++i)
- out << data_names[i] << "__";
- out << data_names[std_cxx11::get<1>(vector_data_ranges[n_th_vector])];
- }
-
- out << "\" NumberOfComponents=\"3\" format=\"ascii\"/>\n";
- }
-
- for (unsigned int data_set=0; data_set<n_data_sets; ++data_set)
- if (data_set_written[data_set] == false)
- {
- out << " <PDataArray type=\"Float64\" Name=\""
- << data_names[data_set]
- << "\" format=\"ascii\"/>\n";
- }
-
- out << " </PPointData>\n";
-
- out << " <PPoints>\n";
- out << " <PDataArray type=\"Float64\" NumberOfComponents=\"3\"/>\n";
- out << " </PPoints>\n";
-
- for (unsigned int i=0; i<piece_names.size(); ++i)
- out << " <Piece Source=\"" << piece_names[i] << "\"/>\n";
-
- out << " </PUnstructuredGrid>\n";
- out << "</VTKFile>\n";
-
- out.flush();
-
- // assert the stream is still ok
- AssertThrow (out, ExcIO());
+ DataOutBase::write_pvtu_record(out,
+ piece_names,
+ get_dataset_names(),
+ get_vector_data_ranges());
}