From: Wolfgang Bangerth Date: Thu, 1 Mar 2018 17:09:12 +0000 (-0700) Subject: Simplify the creation of filenames in step-12. X-Git-Tag: v9.0.0-rc1~371^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=71544dd6f1cca132fa3a56ebd50150643d5f456b;p=dealii.git Simplify the creation of filenames in step-12. --- 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); + } }