// 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 <code>long double</code> and give it a number of extra digits:
- const long double pi = 3.141592653589793238462643;
+ const long double pi = 3.141592653589793238462643L;
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
- // <code>refinement</code> 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
- // <code>std::istringstream</code> 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)
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
{
fe_values.reinit (cell);
for (unsigned int i=0; i<fe_values.n_quadrature_points; ++i)
- area += fe_values.JxW (i);
+ area += static_cast<long double>(fe_values.JxW (i));
}
// ...and store the resulting area values and the errors in the
// iterator and the number of the face.
fe_face_values.reinit (cell, face_no);
for (unsigned int i=0; i<fe_face_values.n_quadrature_points; ++i)
- perimeter += fe_face_values.JxW (i);
+ perimeter += static_cast<long double>(fe_face_values.JxW (i));
}
// Then store the evaluated values in the table...
- table.add_value("eval.pi", static_cast<double> (perimeter/2.));
- table.add_value("error", static_cast<double> (std::fabs(perimeter/2.-pi)));
+ table.add_value("eval.pi", static_cast<double> (perimeter/2.0L));
+ table.add_value("error", static_cast<double> (std::fabs(perimeter/2.0L-pi)));
}
// ...and end this function as we did in the previous one: