]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Fix all Wfloat-conversion warnings
authorDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Mon, 3 Dec 2018 17:34:04 +0000 (18:34 +0100)
committerDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Mon, 3 Dec 2018 17:47:03 +0000 (18:47 +0100)
13 files changed:
cmake/setup_compiler_flags_gnu.cmake
examples/step-44/step-44.cc
include/deal.II/lac/precondition.h
include/deal.II/lac/vector.templates.h
include/deal.II/matrix_free/mapping_info.templates.h
include/deal.II/numerics/vector_tools.templates.h
source/base/function_lib.cc
source/base/polynomials_bernardi_raugel.cc
source/base/process_grid.cc
source/grid/grid_generator.cc
source/grid/grid_in.cc
source/grid/grid_out.cc
source/lac/scalapack.cc

index b971b51edd5d59b27f4774807f1baafec915b4f1..ede5ec6e343ddc9aa3a1de5d0bdb0f521dffeac6 100644 (file)
@@ -56,13 +56,14 @@ ENABLE_IF_LINKS(DEAL_II_LINKER_FLAGS "-Wl,--as-needed")
 #
 ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS "-Wall")
 ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS "-Wextra")
+ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS "-Wfloat-conversion")
+ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS "-Woverloaded-virtual")
 ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS "-Wpointer-arith")
-ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS "-Wwrite-strings")
-ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS "-Wsynth")
 ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS "-Wsign-compare")
-ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS "-Wswitch")
-ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS "-Woverloaded-virtual")
 ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS "-Wsuggest-override")
+ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS "-Wswitch")
+ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS "-Wsynth")
+ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS "-Wwrite-strings")
 
 #
 # Disable Wplacement-new that will trigger a lot of warnings
index 6adad3e2812043872b65a9e5cfb1fb19c510db06..c40d4af574c5130cfdcf59a75375afe9527c7767 100644 (file)
@@ -3052,8 +3052,9 @@ namespace Step44
           std::cout << " SLV " << std::flush;
           if (parameters.type_lin == "CG")
             {
-              const int solver_its = tangent_matrix.block(u_dof, u_dof).m() *
-                                     parameters.max_iterations_lin;
+              const int solver_its =
+                static_cast<int>(tangent_matrix.block(u_dof, u_dof).m() *
+                                 parameters.max_iterations_lin);
               const double tol_sol =
                 parameters.tol_lin * system_rhs.block(u_dof).l2_norm();
 
@@ -3272,8 +3273,8 @@ namespace Step44
             preconditioner_K_Jp_inv.use_matrix(
               tangent_matrix.block(J_dof, p_dof));
             ReductionControl solver_control_K_Jp_inv(
-              tangent_matrix.block(J_dof, p_dof).m() *
-                parameters.max_iterations_lin,
+              static_cast<unsigned int>(tangent_matrix.block(J_dof, p_dof).m() *
+                                        parameters.max_iterations_lin),
               1.0e-30,
               parameters.tol_lin);
             SolverSelector<Vector<double>> solver_K_Jp_inv;
@@ -3315,8 +3316,8 @@ namespace Step44
             preconditioner_K_con_inv.use_matrix(
               tangent_matrix.block(u_dof, u_dof));
             ReductionControl solver_control_K_con_inv(
-              tangent_matrix.block(u_dof, u_dof).m() *
-                parameters.max_iterations_lin,
+              static_cast<unsigned int>(tangent_matrix.block(u_dof, u_dof).m() *
+                                        parameters.max_iterations_lin),
               1.0e-30,
               parameters.tol_lin);
             SolverSelector<Vector<double>> solver_K_con_inv;
index 45bdb20c1353fb2c8f0121c6e09250e0d745a344..e61138208aa6b2db19aef1cfa3a2a92513817a1b 100644 (file)
@@ -2206,8 +2206,10 @@ PreconditionChebyshev<MatrixType, VectorType, PreconditionerType>::
       const_cast<
         PreconditionChebyshev<MatrixType, VectorType, PreconditionerType> *>(
         this)
-        ->data.degree = 1 + std::log(1. / eps + std::sqrt(1. / eps / eps - 1)) /
-                              std::log(1. / sigma);
+        ->data.degree =
+        1 + static_cast<unsigned int>(
+              std::log(1. / eps + std::sqrt(1. / eps / eps - 1)) /
+              std::log(1. / sigma));
     }
 
   const_cast<
index c35616d88763ab14ed7c63ab9e5de66999897e64..d299a8f7f421504d048943b42ced3a7c1c0aa8d9 100644 (file)
@@ -565,7 +565,8 @@ Vector<Number>::l2_norm() const
     norm2, 0, vec_size, norm_square, thread_loop_partitioner);
   if (numbers::is_finite(norm_square) &&
       norm_square >= std::numeric_limits<real_type>::min())
-    return std::sqrt(norm_square);
+    return static_cast<typename Vector<Number>::real_type>(
+      std::sqrt(norm_square));
   else
     {
       real_type scale = 0.;
@@ -578,7 +579,7 @@ Vector<Number>::l2_norm() const
                 numbers::NumberTraits<Number>::abs(values[i]);
               if (scale < abs_x)
                 {
-                  sum   = 1. + sum * (scale / abs_x) * (scale / abs_x);
+                  sum   = 1 + sum * (scale / abs_x) * (scale / abs_x);
                   scale = abs_x;
                 }
               else
@@ -586,7 +587,8 @@ Vector<Number>::l2_norm() const
             }
         }
       AssertIsFinite(scale * std::sqrt(sum));
-      return scale * std::sqrt(sum);
+      return static_cast<typename Vector<Number>::real_type>(scale *
+                                                             std::sqrt(sum));
     }
 }
 
index 2a5f7f13541df39356d121c28549eabf0a7dbf97..e64815cd18245788951ad000bf5a790fda358bf7 100644 (file)
@@ -514,7 +514,7 @@ namespace internal
                     // compress out very small values
                     for (unsigned int d = 0; d < dim; ++d)
                       for (unsigned int e = 0; e < dim; ++e)
-                        if (std::fabs(jac_0[d][e]))
+                        if (std::fabs(jac_0[d][e]) != 0.)
                           cell_data.const_jac[d][e][j] = jac_0[d][e];
                     continue;
                   }
index 5fc5378e5202165965039f1c40a1da124e8329aa..6eac0117ad39d56cc6772e04217db019ee431b54 100644 (file)
@@ -1194,7 +1194,7 @@ namespace VectorTools
       // steps may not be sufficient, since roundoff errors may accumulate for
       // badly conditioned matrices. This behavior can be observed, e.g. for
       // FE_Q_Hierarchical for degree higher than three.
-      ReductionControl control(6. * rhs.size(), 0., 1e-12, false, false);
+      ReductionControl control(6 * rhs.size(), 0., 1e-12, false, false);
       SolverCG<LinearAlgebra::distributed::Vector<Number>> cg(control);
       PreconditionJacobi<MatrixType>                       preconditioner;
       preconditioner.initialize(mass_matrix, 1.);
@@ -1554,7 +1554,7 @@ namespace VectorTools
       // steps may not be sufficient, since roundoff errors may accumulate for
       // badly conditioned matrices. This behavior can be observed, e.g. for
       // FE_Q_Hierarchical for degree higher than three.
-      ReductionControl control(5. * rhs.size(), 0., 1e-12, false, false);
+      ReductionControl control(5 * rhs.size(), 0., 1e-12, false, false);
       SolverCG<LinearAlgebra::distributed::Vector<Number>>    cg(control);
       typename PreconditionJacobi<MatrixType>::AdditionalData data(0.8);
       PreconditionJacobi<MatrixType>                          preconditioner;
@@ -1647,7 +1647,7 @@ namespace VectorTools
       // steps may not be sufficient, since roundoff errors may accumulate for
       // badly conditioned matrices. This behavior can be observed, e.g. for
       // FE_Q_Hierarchical for degree higher than three.
-      ReductionControl control(5. * rhs.size(), 0., 1e-12, false, false);
+      ReductionControl control(5 * rhs.size(), 0., 1e-12, false, false);
       SolverCG<LinearAlgebra::distributed::Vector<Number>>    cg(control);
       typename PreconditionJacobi<MatrixType>::AdditionalData data(0.8);
       PreconditionJacobi<MatrixType>                          preconditioner;
@@ -3341,7 +3341,7 @@ namespace VectorTools
       // steps may not be sufficient, since roundoff errors may accumulate for
       // badly conditioned matrices. This behavior can be observed, e.g. for
       // FE_Q_Hierarchical for degree higher than three.
-      ReductionControl control(5. * rhs.size(), 0., 1.e-12, false, false);
+      ReductionControl control(5 * rhs.size(), 0., 1.e-12, false, false);
       GrowingVectorMemory<Vector<number>> memory;
       SolverCG<Vector<number>>            cg(control, memory);
 
index 400547f9b1951179bdb50a971af5a92018ccde4c..891cf67524d3cb178acd764f9ecac814ca2d0959 100644 (file)
@@ -2647,7 +2647,8 @@ namespace Functions
         else if (p[d] >= interval_endpoints[d].second - delta_x)
           ix[d] = n_subintervals[d] - 1;
         else
-          ix[d] = (p[d] - interval_endpoints[d].first) / delta_x;
+          ix[d] = static_cast<unsigned int>(
+            (p[d] - interval_endpoints[d].first) / delta_x);
       }
 
     // now compute the relative point within the interval/rectangle/box
index 67e581fcb955314ad6e529361e76eafcc4e21920..af1570d297422fad8b51bd1c3d40e3899ec0ed62 100644 (file)
@@ -97,8 +97,9 @@ PolynomialsBernardiRaugel<dim>::compute(
   std::vector<Tensor<3, dim>> bubble_third_derivatives;
   std::vector<Tensor<4, dim>> bubble_fourth_derivatives;
 
-  int n_bubbles = std::pow(3, dim); // size for create_polynomials_bubble
-  int n_q       = 1 << dim;         // size for create_polynomials_q
+  constexpr int n_bubbles =
+    Utilities::pow(3, dim);     // size for create_polynomials_bubble
+  constexpr int n_q = 1 << dim; // size for create_polynomials_q
 
   // don't resize if the provided vector has 0 length
   Q_values.resize((values.size() == 0) ? 0 : n_q);
index dcb77b7162df9e32eb93d1c7c616a25a78639424..b9cc3149d5279209aa055caa745cb75ae54411ba 100644 (file)
@@ -65,7 +65,7 @@ namespace
     // Np = Pc * Pc / ratio
     // for quadratic matrices the ratio equals 1
     const double ratio = double(n) / m;
-    int          Pc    = std::floor(std::sqrt(ratio * Np));
+    int          Pc    = static_cast<int>(std::sqrt(ratio * Np));
 
     // one could rounds up Pc to the number which has zero remainder from the
     // division of Np while ( Np % Pc != 0 )
index 392680e204485ae3ab0eff78fe3a56e7a1e722a5..0adc1855fac1ce0e09d9a6726488d892333d6380 100644 (file)
@@ -2004,7 +2004,7 @@ namespace GridGenerator
                         const double         h) -> void {
       // use std::round instead of std::ceil to improve aspect ratio
       // in case padding is only slightly larger than h.
-      const unsigned int rounded = std::round(padding / h);
+      const auto rounded = static_cast<unsigned int>(std::round(padding / h));
       // in case padding is much smaller than h, make sure we
       // have at least 1 element
       const unsigned int num = (padding > 0. && rounded == 0) ? 1 : rounded;
index 8e091d0a48e35b5cb8063119bd183b998fcdae72..46f105e3e44fecaf2ec12c3e8b2b8b03e951f045 100644 (file)
@@ -412,7 +412,7 @@ GridIn<dim, spacedim>::read_vtk(std::istream &in)
                       // the order used in the following blocks makes sense
                       for (unsigned int i = 0; i < cells.size(); i++)
                         {
-                          double id;
+                          types::manifold_id id;
                           in >> id;
                           if (set == "MaterialID")
                             cells[i].material_id = id;
@@ -428,7 +428,7 @@ GridIn<dim, spacedim>::read_vtk(std::istream &in)
                                i < subcelldata.boundary_quads.size();
                                i++)
                             {
-                              double id;
+                              types::manifold_id id;
                               in >> id;
                               if (set == "MaterialID")
                                 subcelldata.boundary_quads[i].material_id = id;
@@ -441,7 +441,7 @@ GridIn<dim, spacedim>::read_vtk(std::istream &in)
                                i < subcelldata.boundary_lines.size();
                                i++)
                             {
-                              double id;
+                              types::manifold_id id;
                               in >> id;
                               if (set == "MaterialID")
                                 subcelldata.boundary_lines[i].material_id = id;
@@ -457,7 +457,7 @@ GridIn<dim, spacedim>::read_vtk(std::istream &in)
                                i < subcelldata.boundary_lines.size();
                                i++)
                             {
-                              double id;
+                              types::manifold_id id;
                               in >> id;
                               if (set == "MaterialID")
                                 subcelldata.boundary_lines[i].material_id = id;
@@ -1437,7 +1437,7 @@ GridIn<dim, spacedim>::read_msh(std::istream &in)
       in >> version >> file_type >> data_size;
 
       Assert((version >= 2.0) && (version <= 4.0), ExcNotImplemented());
-      gmsh_file_format = version;
+      gmsh_file_format = static_cast<unsigned int>(version);
       Assert(file_type == 0, ExcNotImplemented());
       Assert(data_size == sizeof(double), ExcNotImplemented());
 
index 543f400ebd90c707d5e8b399a9c994788508a34e..325e78dbae2adb2faf42965fe9f690f15edaea58 100644 (file)
@@ -2330,9 +2330,10 @@ GridOut::write_svg(const Triangulation<2, 2> &tria, std::ostream &out) const
                                            camera_horizontal,
                                            camera_focus);
 
-              const unsigned int font_size_this_cell =
-                .5 + cell_label_font_size *
-                       std::pow(.5, cell->level() - 4. + 3.5 * distance_factor);
+              const auto font_size_this_cell = static_cast<unsigned int>(
+                .5 +
+                cell_label_font_size *
+                  std::pow(.5, cell->level() - 4. + 3.5 * distance_factor));
 
               out << "  <text"
                   << " x=\""
index 8a991335137606999917a2999db192c96024a3f3..65f3acd95d487c12a1471acad298e1c20d6226c3 100644 (file)
@@ -1397,7 +1397,7 @@ ScaLAPACKMatrix<NumberType>::invert()
 
               AssertThrow(info == 0,
                           LAPACKSupport::ExcErrorCode("pgetri", info));
-              lwork  = work[0];
+              lwork  = static_cast<int>(work[0]);
               liwork = iwork[0];
               work.resize(lwork);
               iwork.resize(liwork);
@@ -1655,7 +1655,7 @@ ScaLAPACKMatrix<NumberType>::eigenpairs_symmetric(
                  &info);
           AssertThrow(info == 0, LAPACKSupport::ExcErrorCode("psyevx", info));
         }
-      lwork = work[0];
+      lwork = static_cast<int>(work[0]);
       work.resize(lwork);
 
       if (all_eigenpairs)
@@ -1929,7 +1929,7 @@ ScaLAPACKMatrix<NumberType>::eigenpairs_symmetric_MRRR(
 
       AssertThrow(info == 0, LAPACKSupport::ExcErrorCode("psyevr", info));
 
-      lwork = work[0];
+      lwork = static_cast<int>(work[0]);
       work.resize(lwork);
       liwork = iwork[0];
       iwork.resize(liwork);
@@ -2091,7 +2091,7 @@ ScaLAPACKMatrix<NumberType>::compute_SVD(ScaLAPACKMatrix<NumberType> *U,
              &info);
       AssertThrow(info == 0, LAPACKSupport::ExcErrorCode("pgesvd", info));
 
-      lwork = work[0];
+      lwork = static_cast<int>(work[0]);
       work.resize(lwork);
 
       pgesvd(&jobu,
@@ -2197,7 +2197,7 @@ ScaLAPACKMatrix<NumberType>::least_squares(ScaLAPACKMatrix<NumberType> &B,
             &info);
       AssertThrow(info == 0, LAPACKSupport::ExcErrorCode("pgels", info));
 
-      lwork = work[0];
+      lwork = static_cast<int>(work[0]);
       work.resize(lwork);
 
       pgels(&trans,
@@ -2346,7 +2346,7 @@ ScaLAPACKMatrix<NumberType>::reciprocal_condition_number(
              &liwork,
              &info);
       AssertThrow(info == 0, LAPACKSupport::ExcErrorCode("pdpocon", info));
-      lwork = std::ceil(work[0]);
+      lwork = static_cast<int>(std::ceil(work[0]));
       work.resize(lwork);
 
       // now the actual run:
@@ -2846,7 +2846,8 @@ ScaLAPACKMatrix<NumberType>::save_parallel(
    * the minimum value for NB yields that only ceil(400/32)=13 processes will be
    * writing the matrix to disk.
    */
-  const int NB = std::max((int)std::ceil((double)n_columns / n_mpi_processes),
+  const int NB = std::max(static_cast<int>(std::ceil(
+                            static_cast<double>(n_columns) / n_mpi_processes)),
                           column_block_size);
 
   ScaLAPACKMatrix<NumberType> tmp(n_rows, n_columns, column_grid, MB, NB);
@@ -3268,8 +3269,10 @@ ScaLAPACKMatrix<NumberType>::load_parallel(const std::string &filename)
 
   const int MB = n_rows;
   // for the choice of NB see explanation in save_parallel()
-  const int NB = std::max((int)std::ceil((double)n_columns / n_mpi_processes),
+  const int NB = std::max(static_cast<int>(std::ceil(
+                            static_cast<double>(n_columns) / n_mpi_processes)),
                           column_block_size);
+
   ScaLAPACKMatrix<NumberType> tmp(n_rows, n_columns, column_grid, MB, NB);
 
   // get pointer to data held by the process

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.