From 7470673245c0fe4b17d01ef1a7084ed164263d1d Mon Sep 17 00:00:00 2001 From: Timo Heister Date: Wed, 6 Sep 2017 17:15:03 -0400 Subject: [PATCH] fix warnings in step-10 The clang code model in qtcreator was showing me these warnings. While here, remove weird '0'+integer hack. --- examples/step-10/step-10.cc | 34 +++++++++++++--------------------- 1 file changed, 13 insertions(+), 21 deletions(-) diff --git a/examples/step-10/step-10.cc b/examples/step-10/step-10.cc index 9e4edf920e..a73bd2feaf 100644 --- a/examples/step-10/step-10.cc +++ b/examples/step-10/step-10.cc @@ -54,7 +54,7 @@ namespace Step10 // computed approximation to $\pi$ being in the range of the number of // digits which a double variable can hold, we rather declare the reference // value as a long double and give it a number of extra digits: - const long double pi = 3.141592653589793238462643; + const long double pi = 3.141592653589793238462643L; @@ -95,17 +95,9 @@ namespace Step10 std::cout << "Refinement level: " << refinement << std::endl; // Then have a string which denotes the base part of the names of the - // files into which we write the output. Note that in the parentheses - // in the initializer we do arithmetic on characters, which assumes - // that first the characters denoting numbers are placed consecutively - // (which is probably true for all reasonable character sets - // nowadays), but also assumes that the increment - // refinement is less than ten. This is therefore more a - // quick hack if we know exactly the values which the increment can - // assume. A better implementation would use the - // std::istringstream class to generate a name. - std::string filename_base = "ball"; - filename_base += '0'+refinement; + // files into which we write the output (ending with the refinement + // level). + std::string filename_base = "ball" + Utilities::to_string(refinement); // Then output the present grid for $Q_1$, $Q_2$, and $Q_3$ mappings: for (unsigned int degree=1; degree<4; ++degree) @@ -145,11 +137,11 @@ namespace Step10 GridOutFlags::Gnuplot gnuplot_flags(false, 30); grid_out.set_flags(gnuplot_flags); - // Finally, generate a filename and a file for output using the - // same evil hack as above: - std::string filename = filename_base+"_mapping_q"; - filename += ('0'+degree); - filename += ".dat"; + // Finally, generate a filename and a file for output: + std::string filename = filename_base + + "_mapping_q" + + Utilities::to_string(degree) + + ".dat"; std::ofstream gnuplot_file (filename.c_str()); // Then write out the triangulation to this file. The last @@ -291,7 +283,7 @@ namespace Step10 { fe_values.reinit (cell); for (unsigned int i=0; i(fe_values.JxW (i)); } // ...and store the resulting area values and the errors in the @@ -390,11 +382,11 @@ namespace Step10 // iterator and the number of the face. fe_face_values.reinit (cell, face_no); for (unsigned int i=0; i(fe_face_values.JxW (i)); } // Then store the evaluated values in the table... - table.add_value("eval.pi", static_cast (perimeter/2.)); - table.add_value("error", static_cast (std::fabs(perimeter/2.-pi))); + table.add_value("eval.pi", static_cast (perimeter/2.0L)); + table.add_value("error", static_cast (std::fabs(perimeter/2.0L-pi))); } // ...and end this function as we did in the previous one: -- 2.39.5