From 2a68ed193fb40fc868b3a9236c7bfa950a48847e Mon Sep 17 00:00:00 2001 From: kanschat Date: Thu, 22 May 2014 22:05:31 +0000 Subject: [PATCH] enable filename selection git-svn-id: https://svn.dealii.org/trunk@32970 0785d39b-7218-0410-832d-ea1e28bc413d --- .../deal.II/numerics/dof_output_operator.h | 21 +++++++++++++- .../numerics/dof_output_operator.templates.h | 28 +++++++++++++++---- 2 files changed, 43 insertions(+), 6 deletions(-) diff --git a/deal.II/include/deal.II/numerics/dof_output_operator.h b/deal.II/include/deal.II/numerics/dof_output_operator.h index 70f89b5467..b9f55a04a2 100644 --- a/deal.II/include/deal.II/numerics/dof_output_operator.h +++ b/deal.II/include/deal.II/numerics/dof_output_operator.h @@ -30,18 +30,37 @@ DEAL_II_NAMESPACE_OPEN namespace Algorithms { + /** + * An output operator writing a separate file in each step and + * writing the vectors as finite element functions with respect to a + * given DoFHandler. + */ template class DoFOutputOperator : public OutputOperator { public: + /* + * Constructor. The filename is the common base name of all + * files and the argument digits should be the number of digits + * of the highest number in the sequence. File names by default + * have the form "outputNN" with NNN the number set by the last + * step command. Numbers with less digits are filled with zeros + * from the left. + */ + DoFOutputOperator (const std::string filename_base = std::string("output"), + const unsigned int digits = 3); + void initialize (DoFHandler &dof_handler); virtual OutputOperator & - operator<<(const NamedData &vectors); + operator << (const AnyData &vectors); private: SmartPointer, DoFOutputOperator > dof; + + const std::string filename_base; + const unsigned int digits; }; template diff --git a/deal.II/include/deal.II/numerics/dof_output_operator.templates.h b/deal.II/include/deal.II/numerics/dof_output_operator.templates.h index b9529a01c4..2bdb0f72e3 100644 --- a/deal.II/include/deal.II/numerics/dof_output_operator.templates.h +++ b/deal.II/include/deal.II/numerics/dof_output_operator.templates.h @@ -22,19 +22,37 @@ DEAL_II_NAMESPACE_OPEN namespace Algorithms { + template + DoFOutputOperator::DoFOutputOperator ( + const std::string filename_base, + const unsigned int digits) + : + filename_base(filename_base), + digits(digits) + {} + + template OutputOperator & DoFOutputOperator::operator<<( - const NamedData &vectors) + const AnyData &data) { Assert ((dof!=0), ExcNotInitialized()); DataOut out; + out.set_default_format(DataOutBase::gnuplot); out.attach_dof_handler (*dof); - out.add_data_vector (*vectors(vectors.find("solution")), "solution"); - out.add_data_vector (*vectors(vectors.find("update")), "update"); - out.add_data_vector (*vectors(vectors.find("residual")), "residual"); + for (unsigned int i=0;i(i); + if (p!=0) + { + out.add_data_vector (*p, data.name(i)); + } + } std::ostringstream streamOut; - streamOut << "Newton_" << std::setw(3) << std::setfill('0') << this->step; + streamOut << filename_base + << std::setw(digits) << std::setfill('0') << this->step + << out.default_suffix(); std::ofstream out_filename (streamOut.str().c_str()); out.build_patches (2); out.write_gnuplot (out_filename); -- 2.39.5