From: Timo Heister Date: Fri, 1 Dec 2023 21:14:11 +0000 (-0500) Subject: unify some example output X-Git-Tag: relicensing~266^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F16315%2Fhead;p=dealii.git unify some example output --- diff --git a/examples/step-14/doc/results.dox b/examples/step-14/doc/results.dox index 68ff071a1a..41e85b3975 100644 --- a/examples/step-14/doc/results.dox +++ b/examples/step-14/doc/results.dox @@ -10,40 +10,40 @@ it out, by changing the settings in the main program. Here, we start by simply letting it run, unmodified: @code Refinement cycle: 0 - Number of degrees of freedom=72 - Point value=0.03243 - Estimated error=0.000702385 + Number of degrees of freedom: 72 + Point value: 0.03243 + Estimated error: 0.000702385 Refinement cycle: 1 - Number of degrees of freedom=67 - Point value=0.0324827 - Estimated error=0.000888953 + Number of degrees of freedom: 67 + Point value: 0.0324827 + Estimated error: 0.000888953 Refinement cycle: 2 - Number of degrees of freedom=130 - Point value=0.0329619 - Estimated error=0.000454606 + Number of degrees of freedom: 130 + Point value: 0.0329619 + Estimated error: 0.000454606 Refinement cycle: 3 - Number of degrees of freedom=307 - Point value=0.0331934 - Estimated error=0.000241254 + Number of degrees of freedom: 307 + Point value: 0.0331934 + Estimated error: 0.000241254 Refinement cycle: 4 - Number of degrees of freedom=718 - Point value=0.0333675 - Estimated error=7.4912e-05 + Number of degrees of freedom: 718 + Point value: 0.0333675 + Estimated error: 7.4912e-05 Refinement cycle: 5 - Number of degrees of freedom=1665 - Point value=0.0334083 - Estimated error=3.69111e-05 + Number of degrees of freedom: 1665 + Point value: 0.0334083 + Estimated error: 3.69111e-05 Refinement cycle: 6 - Number of degrees of freedom=3975 - Point value=0.033431 - Estimated error=1.54218e-05 + Number of degrees of freedom: 3975 + Point value: 0.033431 + Estimated error: 1.54218e-05 Refinement cycle: 7 - Number of degrees of freedom=8934 - Point value=0.0334406 - Estimated error=6.28359e-06 + Number of degrees of freedom: 8934 + Point value: 0.0334406 + Estimated error: 6.28359e-06 Refinement cycle: 8 - Number of degrees of freedom=21799 - Point value=0.0334444 + Number of degrees of freedom: 21799 + Point value: 0.0334444 @endcode @@ -183,44 +183,44 @@ program compute these quantities, simply replace the two occurrences of PointXDerivativeEvaluation, and let the program run: @code Refinement cycle: 0 - Number of degrees of freedom=72 - Point x-derivative=-0.0719397 - Estimated error=-0.0126173 + Number of degrees of freedom: 72 + Point x-derivative: -0.0719397 + Estimated error: -0.0126173 Refinement cycle: 1 - Number of degrees of freedom=61 - Point x-derivative=-0.0707956 - Estimated error=-0.00774316 + Number of degrees of freedom: 61 + Point x-derivative: -0.0707956 + Estimated error: -0.00774316 Refinement cycle: 2 - Number of degrees of freedom=131 - Point x-derivative=-0.0568671 - Estimated error=-0.00313426 + Number of degrees of freedom: 131 + Point x-derivative: -0.0568671 + Estimated error: -0.00313426 Refinement cycle: 3 - Number of degrees of freedom=247 - Point x-derivative=-0.053033 - Estimated error=-0.00136114 + Number of degrees of freedom: 247 + Point x-derivative: -0.053033 + Estimated error: -0.00136114 Refinement cycle: 4 - Number of degrees of freedom=532 - Point x-derivative=-0.0526429 - Estimated error=-0.000558868 + Number of degrees of freedom: 532 + Point x-derivative: -0.0526429 + Estimated error: -0.000558868 Refinement cycle: 5 - Number of degrees of freedom=1267 - Point x-derivative=-0.0526955 - Estimated error=-0.000220116 + Number of degrees of freedom: 1267 + Point x-derivative: -0.0526955 + Estimated error: -0.000220116 Refinement cycle: 6 - Number of degrees of freedom=2864 - Point x-derivative=-0.0527495 - Estimated error=-9.46731e-05 + Number of degrees of freedom: 2864 + Point x-derivative: -0.0527495 + Estimated error: -9.46731e-05 Refinement cycle: 7 - Number of degrees of freedom=6409 - Point x-derivative=-0.052785 - Estimated error=-4.21543e-05 + Number of degrees of freedom: 6409 + Point x-derivative: -0.052785 + Estimated error: -4.21543e-05 Refinement cycle: 8 - Number of degrees of freedom=14183 - Point x-derivative=-0.0528028 - Estimated error=-2.04241e-05 + Number of degrees of freedom: 14183 + Point x-derivative: -0.0528028 + Estimated error: -2.04241e-05 Refinement cycle: 9 - Number of degrees of freedom=29902 - Point x-derivative=-0.052814 + Number of degrees of freedom: 29902 + Point x-derivative: -0.052814 @endcode diff --git a/examples/step-14/step-14.cc b/examples/step-14/step-14.cc index 5693f758d3..6dd5e54a51 100644 --- a/examples/step-14/step-14.cc +++ b/examples/step-14/step-14.cc @@ -145,7 +145,7 @@ namespace Step14 AssertThrow(evaluation_point_found, ExcEvaluationPointNotFound(evaluation_point)); - std::cout << " Point value=" << point_value << std::endl; + std::cout << " Point value: " << point_value << std::endl; } @@ -2238,7 +2238,7 @@ namespace Step14 } ++present_cell; } - std::cout << " Estimated error=" + std::cout << " Estimated error: " << std::accumulate(error_indicators.begin(), error_indicators.end(), 0.) @@ -2778,7 +2778,7 @@ namespace Step14 solver->solve_problem(); solver->output_solution(); - std::cout << " Number of degrees of freedom=" << solver->n_dofs() + std::cout << " Number of degrees of freedom: " << solver->n_dofs() << std::endl; for (const auto &evaluator : descriptor.evaluator_list) diff --git a/examples/step-3/doc/results.dox b/examples/step-3/doc/results.dox index 488d7d12ce..d556b31d11 100644 --- a/examples/step-3/doc/results.dox +++ b/examples/step-3/doc/results.dox @@ -6,9 +6,10 @@ Number of active cells: 1024 Number of degrees of freedom: 1089 DEAL:cg::Starting value 0.121094 DEAL:cg::Convergence step 36 value 7.07761e-08 +Output written to solution.vtk @endcode -The first two lines is what we wrote to std::cout. The last +The first two lines is what we wrote to std::cout. The next two lines were generated by the CG solver because we called `deallog.depth_console(2);` in the `main()` function -- see the lengthy discussion there. These two lines prefixed by `DEAL:cg:` state @@ -21,7 +22,8 @@ norm of the right hand side vector; the starting value is (here) this norm of the right hand side vector, and there is indeed more than a factor of $10^{-6}$ between the two values shown. -Apart from the output shown above, the program generated the file +The last line is the output we generated at the bottom of the +`output_results()` function. The program also generated the file solution.vtk, which is in the VTK format that is widely used by many visualization programs today -- including the two heavy-weights VisIt and diff --git a/examples/step-3/step-3.cc b/examples/step-3/step-3.cc index 7f8a7d68dc..35a21f2ac2 100644 --- a/examples/step-3/step-3.cc +++ b/examples/step-3/step-3.cc @@ -594,8 +594,10 @@ void Step3::output_results() const // functions in the DataOut class we are using here that can write the // data in postscript, AVS, GMV, Gnuplot, or some other file // formats): - std::ofstream output("solution.vtk"); + const std::string filename = "solution.vtk"; + std::ofstream output(filename); data_out.write_vtk(output); + std::cout << "Output written to " << filename << std::endl; } diff --git a/examples/step-9/step-9.cc b/examples/step-9/step-9.cc index eb9ecb5248..27a06b2227 100644 --- a/examples/step-9/step-9.cc +++ b/examples/step-9/step-9.cc @@ -828,9 +828,11 @@ namespace Step9 void AdvectionProblem::output_results(const unsigned int cycle) const { { - GridOut grid_out; - std::ofstream output("grid-" + std::to_string(cycle) + ".vtu"); + GridOut grid_out; + const std::string filename = "grid-" + std::to_string(cycle) + ".vtu"; + std::ofstream output(filename); grid_out.write_vtu(triangulation, output); + std::cout << "Grid written to " << filename << std::endl; } { @@ -846,8 +848,10 @@ namespace Step9 vtk_flags.compression_level = DataOutBase::CompressionLevel::best_speed; data_out.set_flags(vtk_flags); - std::ofstream output("solution-" + std::to_string(cycle) + ".vtu"); + const std::string filename = "solution-" + std::to_string(cycle) + ".vtu"; + std::ofstream output(filename); data_out.write_vtu(output); + std::cout << "Solution written to " << filename << std::endl; } }