From 71544dd6f1cca132fa3a56ebd50150643d5f456b Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Thu, 1 Mar 2018 10:09:12 -0700 Subject: [PATCH] Simplify the creation of filenames in step-12. --- examples/step-12/step-12.cc | 45 +++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 25 deletions(-) diff --git a/examples/step-12/step-12.cc b/examples/step-12/step-12.cc index ab59e5a21b..21e9a68359 100644 --- a/examples/step-12/step-12.cc +++ b/examples/step-12/step-12.cc @@ -553,39 +553,34 @@ namespace Step12 // The output of this program consists of eps-files of the adaptively - // refined grids and the numerical solutions given in gnuplot format. This - // was covered in previous examples and will not be further commented on. + // refined grids and the numerical solutions given in gnuplot format. template void AdvectionProblem::output_results (const unsigned int cycle) const { - // Write the grid in eps format. - std::string filename = "grid-"; - filename += ('0' + cycle); - Assert (cycle < 10, ExcInternalError()); - - filename += ".eps"; - deallog << "Writing grid to <" << filename << ">" << std::endl; - std::ofstream eps_output (filename.c_str()); - - GridOut grid_out; - grid_out.write_eps (triangulation, eps_output); + // First write the grid in eps format. + { + const std::string filename = "grid-" + std::to_string(cycle) + ".eps"; + deallog << "Writing grid to <" << filename << ">" << std::endl; + std::ofstream eps_output (filename.c_str()); - // Output of the solution in gnuplot format. - filename = "sol-"; - filename += ('0' + cycle); - Assert (cycle < 10, ExcInternalError()); + GridOut grid_out; + grid_out.write_eps (triangulation, eps_output); + } - filename += ".gnuplot"; - deallog << "Writing solution to <" << filename << ">" << std::endl; - std::ofstream gnuplot_output (filename.c_str()); + // Then output the solution in gnuplot format. + { + const std::string filename = "sol-" + std::to_string(cycle) + ".gnuplot"; + deallog << "Writing solution to <" << filename << ">" << std::endl; + std::ofstream gnuplot_output (filename.c_str()); - DataOut data_out; - data_out.attach_dof_handler (dof_handler); - data_out.add_data_vector (solution, "u"); + DataOut data_out; + data_out.attach_dof_handler (dof_handler); + data_out.add_data_vector (solution, "u"); - data_out.build_patches (); + data_out.build_patches (); - data_out.write_gnuplot(gnuplot_output); + data_out.write_gnuplot(gnuplot_output); + } } -- 2.39.5