]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Avoid C-style cast in fe
authorDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Thu, 29 Nov 2018 15:32:44 +0000 (16:32 +0100)
committerDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Thu, 29 Nov 2018 15:32:44 +0000 (16:32 +0100)
include/deal.II/fe/fe_tools_extrapolate.templates.h
source/fe/fe_abf.cc
source/fe/fe_dgq.cc
source/fe/fe_nedelec.cc
source/fe/fe_nedelec_sz.cc
source/fe/fe_poly.cc
source/fe/fe_q.cc
source/fe/fe_q_base.cc
source/fe/fe_q_bubbles.cc
source/fe/fe_q_dg0.cc
source/fe/fe_q_hierarchical.cc

index 6f073f5ffdd52ff479f86c5fef1d3f77aa2dac0d..6c1f3bd857f60d137d2faf4deece223d3f4a8df5 100644 (file)
@@ -1259,9 +1259,9 @@ namespace FETools
         std::lower_bound(cells_list.begin(), cells_list.end(), cell_data);
 
       if ((bound != cells_list.end()) && !(cell_data < *bound))
-        return (int)(bound - cells_list.begin());
+        return static_cast<int>(bound - cells_list.begin());
 
-      return (-1);
+      return -1;
     }
 
 
index 4339c745e9842b7e92badff33f7faa754688eb47..5e91fa7157007699463cfc9c7e7bd53017f64f2f 100644 (file)
@@ -584,8 +584,7 @@ FE_ABF<dim>::convert_generalized_support_point_values_to_dof_values(
   // Face integral of ABF terms
   for (unsigned int face = 0; face < GeometryInfo<dim>::faces_per_cell; ++face)
     {
-      double n_orient =
-        (double)GeometryInfo<dim>::unit_normal_orientation[face];
+      const double n_orient = GeometryInfo<dim>::unit_normal_orientation[face];
       for (unsigned int fp = 0; fp < n_face_points; ++fp)
         {
           // TODO: Check what the face_orientation, face_flip and face_rotation
index 07ff80d9a3d28336c828d65cefdf6f8ffafdfdb0..0466eaa0e0ed5fa8d4fed0ed14841d3cc77caa76 100644 (file)
@@ -861,7 +861,7 @@ FE_DGQArbitraryNodes<dim, spacedim>::get_name() const
 
   // Check whether the support points are equidistant.
   for (unsigned int j = 0; j <= this->degree; j++)
-    if (std::abs(points[j] - (double)j / this->degree) > 1e-15)
+    if (std::abs(points[j] - static_cast<double>(j) / this->degree) > 1e-15)
       {
         equidistant = false;
         break;
index c37e8111ff99780ceca7f24e1339930aee703c80..d12afe8a953b1f84bbe21d21ecaf21c0d9c36037 100644 (file)
@@ -2475,7 +2475,7 @@ FE_Nedelec<dim>::get_face_interpolation_matrix(
 
       for (unsigned int i = 0; i < q; ++i)
         {
-          for (int j = 1; j < (int)GeometryInfo<dim>::lines_per_face; ++j)
+          for (unsigned int j = 1; j < GeometryInfo<dim>::lines_per_face; ++j)
             interpolation_matrix(j * p + i, j * q + i) = 1.0;
 
           for (unsigned int j = 0; j < q - 1; ++j)
@@ -3609,8 +3609,8 @@ FE_Nedelec<dim>::convert_generalized_support_point_values_to_dof_values(
                                                n_edge_points]
                                             [face_coordinates[face][1]];
 
-                      for (int i = 2;
-                           i < (int)GeometryInfo<dim>::lines_per_face;
+                      for (unsigned int i = 2;
+                           i < GeometryInfo<dim>::lines_per_face;
                            ++i)
                         for (unsigned int j = 0; j <= deg; ++j)
                           tmp -=
index b7832f3c23e35d1a5a6630e61956f2a38e5709be..0afb57d1535c52e05baf1cbe44e887fbc6e8d3b8 100644 (file)
@@ -256,7 +256,7 @@ FE_NedelecSZ<dim, spacedim>::get_data(
                   // component given: Note some i,j combinations will be
                   // incorrect, but only on invalid edges.
                   data->sigma_imj_grads[i][j][sigma_imj_component[i][j]] =
-                    2.0 * (double)sigma_imj_sign[i][j];
+                    2.0 * sigma_imj_sign[i][j];
                 }
             }
 
@@ -643,7 +643,7 @@ FE_NedelecSZ<dim, spacedim>::get_data(
                   // component given: Note some i,j combinations will be
                   // incorrect, but only on invalid edges.
                   data->sigma_imj_grads[i][j][sigma_imj_component[i][j]] =
-                    2.0 * (double)sigma_imj_sign[i][j];
+                    2.0 * sigma_imj_sign[i][j];
                 }
             }
           // Now compute the edge parameterisations for a single element
@@ -753,10 +753,10 @@ FE_NedelecSZ<dim, spacedim>::get_data(
             {
               data->edge_lambda_gradgrads_3d[m][edge_lambda_directions[m][0]]
                                             [edge_lambda_directions[m][1]] =
-                (double)edge_lambda_sign[m] * 1.0;
+                edge_lambda_sign[m];
               data->edge_lambda_gradgrads_3d[m][edge_lambda_directions[m][1]]
                                             [edge_lambda_directions[m][0]] =
-                (double)edge_lambda_sign[m] * 1.0;
+                edge_lambda_sign[m];
             }
           // Precomputation for higher order shape functions,
           // and the face parameterisation.
index 745b183eba20e347daf08a7277e354b2c394e629..e87658aacc89e4bf94730bc630ae51f1c2cb2bac 100644 (file)
@@ -43,13 +43,9 @@ FE_Poly<TensorProductPolynomials<1>, 1, 2>::fill_fe_values(
   dealii::internal::FEValuesImplementation::FiniteElementRelatedData<1, 2>
     &output_data) const
 {
-  // convert data object to internal
-  // data for this class. fails with
-  // an exception if that is not
-  // possible
-  Assert(dynamic_cast<const InternalData *>(&fe_internal) != nullptr,
-         ExcInternalError());
-  const InternalData &fe_data = static_cast<const InternalData &>(fe_internal);
+  // convert data object to internal data for this class. fails with an
+  // exception if that is not possible
+  const InternalData &fe_data = dynamic_cast<const InternalData &>(fe_internal);
 
   // transform gradients and higher derivatives. there is nothing to do
   // for values since we already emplaced them into output_data when
@@ -113,11 +109,9 @@ FE_Poly<TensorProductPolynomials<2>, 2, 3>::fill_fe_values(
   dealii::internal::FEValuesImplementation::FiniteElementRelatedData<2, 3>
     &output_data) const
 {
-  // assert that the following dynamics
-  // cast is really well-defined.
-  Assert(dynamic_cast<const InternalData *>(&fe_internal) != nullptr,
-         ExcInternalError());
-  const InternalData &fe_data = static_cast<const InternalData &>(fe_internal);
+  // convert data object to internal data for this class. fails with an
+  // exception if that is not possible
+  const InternalData &fe_data = dynamic_cast<const InternalData &>(fe_internal);
 
   // transform gradients and higher derivatives. there is nothing to do
   // for values since we already emplaced them into output_data when
@@ -180,14 +174,9 @@ FE_Poly<PolynomialSpace<1>, 1, 2>::fill_fe_values(
   dealii::internal::FEValuesImplementation::FiniteElementRelatedData<1, 2>
     &output_data) const
 {
-  // convert data object to internal
-  // data for this class. fails with
-  // an exception if that is not
-  // possible
-
-  Assert(dynamic_cast<const InternalData *>(&fe_internal) != nullptr,
-         ExcInternalError());
-  const InternalData &fe_data = static_cast<const InternalData &>(fe_internal);
+  // convert data object to internal data for this class. fails with an
+  // exception if that is not possible
+  const InternalData &fe_data = dynamic_cast<const InternalData &>(fe_internal);
 
   // transform gradients and higher derivatives. there is nothing to do
   // for values since we already emplaced them into output_data when
@@ -250,9 +239,9 @@ FE_Poly<PolynomialSpace<2>, 2, 3>::fill_fe_values(
   dealii::internal::FEValuesImplementation::FiniteElementRelatedData<2, 3>
     &output_data) const
 {
-  Assert(dynamic_cast<const InternalData *>(&fe_internal) != nullptr,
-         ExcInternalError());
-  const InternalData &fe_data = static_cast<const InternalData &>(fe_internal);
+  // convert data object to internal data for this class. fails with an
+  // exception if that is not possible
+  const InternalData &fe_data = dynamic_cast<const InternalData &>(fe_internal);
 
   // transform gradients and higher derivatives. there is nothing to do
   // for values since we already emplaced them into output_data when
index 2b5f2ee150ce486a6d6fe4d4f096187fedfceecb..99e35af13336c66668fe8966d59dc64617c1406c 100644 (file)
@@ -106,7 +106,7 @@ FE_Q<dim, spacedim>::get_name() const
 
   // Check whether the support points are equidistant.
   for (unsigned int j = 0; j <= this->degree; j++)
-    if (std::fabs(points[j] - (double)j / this->degree) > 1e-15)
+    if (std::fabs(points[j] - static_cast<double>(j) / this->degree) > 1e-15)
       {
         equidistant = false;
         break;
index 6d96202b1a8766af9f281064ab28097b1f2f72f4..79bdddd3e088c4a45e7ee1c5009425714315f599 100644 (file)
@@ -356,7 +356,7 @@ struct FE_Q_Base<PolynomialType, xdim, xspacedim>::Implementation
 
     for (unsigned int i = 0; i < constraint_points.size(); ++i)
       {
-        const double interval = (double)(q_deg * 2);
+        const double interval = static_cast<double>(q_deg * 2);
         bool         mirror[dim - 1];
         Point<dim>   constraint_point;
 
index ba8c36efa952d6e7ec535ed3ff515ad426ca6d0a..0b7d6180132f13fb5cf8fb9d96a8e7c17dc3d648 100644 (file)
@@ -301,7 +301,8 @@ FE_Q_Bubbles<dim, spacedim>::get_name() const
 
   // Check whether the support points are equidistant.
   for (unsigned int j = 0; j < n_points; j++)
-    if (std::fabs(points[j] - (double)j / (this->degree - 1)) > 1e-15)
+    if (std::fabs(points[j] - static_cast<double>(j) / (this->degree - 1)) >
+        1e-15)
       {
         type = false;
         break;
index 6cbc96a7cfeaa205885dfcb13b06d3238c95307b..c8beb6f7ef694f22194390195f26e288c411e393 100644 (file)
@@ -131,7 +131,7 @@ FE_Q_DG0<dim, spacedim>::get_name() const
 
   // Check whether the support points are equidistant.
   for (unsigned int j = 0; j < n_points; j++)
-    if (std::fabs(points[j] - (double)j / this->degree) > 1e-15)
+    if (std::fabs(points[j] - static_cast<double>(j) / this->degree) > 1e-15)
       {
         type = false;
         break;
index a46b0106b204292e57e4b4f19f934d90a14b10e2..928e996ed2b601d12d30859fc1e80fed24402354 100644 (file)
@@ -471,7 +471,8 @@ FE_Q_Hierarchical<dim>::build_dofs_cell(
             {
               double factor = 1.;
               for (unsigned int i = 1; i <= j; ++i)
-                factor *= ((double)(k - i + 1)) / ((double)i);
+                factor *=
+                  (static_cast<double>(k - i + 1)) / (static_cast<double>(i));
               // factor == k * (k-1) * ... * (k-j+1) / j! = k! / (k-j)! / j!
               if (c == 0)
                 {
@@ -1056,14 +1057,14 @@ FE_Q_Hierarchical<dim>::get_subface_interpolation_matrix(
 
                   int factorial_i = 1;
 
-                  for (int i = 2; i < (int)this->dofs_per_face; ++i)
+                  for (unsigned int i = 2; i < this->dofs_per_face; ++i)
                     {
                       interpolation_matrix(i, i) = std::pow(0.5, i);
                       factorial_i *= i;
                       int factorial_j  = factorial_i;
                       int factorial_ij = 1;
 
-                      for (int j = i + 1; j < (int)this->dofs_per_face; ++j)
+                      for (unsigned int j = i + 1; j < this->dofs_per_face; ++j)
                         {
                           factorial_ij *= j - i;
                           factorial_j *= j;
@@ -1098,14 +1099,14 @@ FE_Q_Hierarchical<dim>::get_subface_interpolation_matrix(
 
                   int factorial_i = 1;
 
-                  for (int i = 2; i < (int)this->dofs_per_face; ++i)
+                  for (unsigned int i = 2; i < this->dofs_per_face; ++i)
                     {
                       interpolation_matrix(i, i) = std::pow(0.5, i);
                       factorial_i *= i;
                       int factorial_j  = factorial_i;
                       int factorial_ij = 1;
 
-                      for (int j = i + 1; j < (int)this->dofs_per_face; ++j)
+                      for (unsigned int j = i + 1; j < this->dofs_per_face; ++j)
                         {
                           factorial_ij *= j - i;
                           factorial_j *= j;
@@ -1162,7 +1163,7 @@ FE_Q_Hierarchical<dim>::get_subface_interpolation_matrix(
 
                   int factorial_i = 1;
 
-                  for (int i = 2; i <= (int)this->degree; ++i)
+                  for (unsigned int i = 2; i <= this->degree; ++i)
                     {
                       double tmp                         = std::pow(0.5, i);
                       interpolation_matrix(i + 2, i + 2) = tmp;
@@ -1192,7 +1193,7 @@ FE_Q_Hierarchical<dim>::get_subface_interpolation_matrix(
 
                       int factorial_k = 1;
 
-                      for (int j = 2; j <= (int)this->degree; ++j)
+                      for (unsigned int j = 2; j <= this->degree; ++j)
                         {
                           interpolation_matrix(i + (j + 2) * source_fe.degree -
                                                  j,
@@ -1202,7 +1203,7 @@ FE_Q_Hierarchical<dim>::get_subface_interpolation_matrix(
                           int factorial_kl = 1;
                           int factorial_l  = factorial_k;
 
-                          for (int k = j + 1; k < (int)this->degree; ++k)
+                          for (unsigned int k = j + 1; k < this->degree; ++k)
                             {
                               factorial_kl *= k - j;
                               factorial_l *= k;
@@ -1227,7 +1228,7 @@ FE_Q_Hierarchical<dim>::get_subface_interpolation_matrix(
                       int factorial_j  = factorial_i;
                       int factorial_ij = 1;
 
-                      for (int j = i + 1; j <= (int)this->degree; ++j)
+                      for (unsigned int j = i + 1; j <= this->degree; ++j)
                         {
                           factorial_ij *= j - i;
                           factorial_j *= j;
@@ -1241,7 +1242,7 @@ FE_Q_Hierarchical<dim>::get_subface_interpolation_matrix(
                                                    j + 2 * this->degree) = tmp;
                               factorial_k                                = 1;
 
-                              for (int k = 2; k <= (int)this->degree; ++k)
+                              for (unsigned int k = 2; k <= this->degree; ++k)
                                 {
                                   interpolation_matrix(
                                     i + (k + 2) * source_fe.degree - k,
@@ -1251,7 +1252,8 @@ FE_Q_Hierarchical<dim>::get_subface_interpolation_matrix(
                                   int factorial_l  = factorial_k;
                                   int factorial_kl = 1;
 
-                                  for (int l = k + 1; l <= (int)this->degree;
+                                  for (unsigned int l = k + 1;
+                                       l <= this->degree;
                                        ++l)
                                     {
                                       factorial_kl *= l - k;
@@ -1306,7 +1308,7 @@ FE_Q_Hierarchical<dim>::get_subface_interpolation_matrix(
                                                    j + 2 * this->degree) = tmp;
                               factorial_k                                = 1;
 
-                              for (int k = 2; k <= (int)this->degree; ++k)
+                              for (unsigned int k = 2; k <= this->degree; ++k)
                                 {
                                   interpolation_matrix(
                                     i + (k + 2) * source_fe.degree - k,
@@ -1316,7 +1318,8 @@ FE_Q_Hierarchical<dim>::get_subface_interpolation_matrix(
                                   int factorial_l  = factorial_k;
                                   int factorial_kl = 1;
 
-                                  for (int l = k + 1; l <= (int)this->degree;
+                                  for (unsigned int l = k + 1;
+                                       l <= this->degree;
                                        ++l)
                                     {
                                       factorial_kl *= l - k;
@@ -1406,7 +1409,7 @@ FE_Q_Hierarchical<dim>::get_subface_interpolation_matrix(
 
                   int factorial_i = 1;
 
-                  for (int i = 2; i <= (int)this->degree; ++i)
+                  for (unsigned int i = 2; i <= this->degree; ++i)
                     {
                       double tmp                         = std::pow(0.5, i + 1);
                       interpolation_matrix(i + 2, i + 2) = tmp;
@@ -1437,7 +1440,7 @@ FE_Q_Hierarchical<dim>::get_subface_interpolation_matrix(
                       int factorial_j  = factorial_i;
                       int factorial_ij = 1;
 
-                      for (int j = i + 1; j <= (int)this->degree; ++j)
+                      for (unsigned int j = i + 1; j <= this->degree; ++j)
                         {
                           factorial_ij *= j - i;
                           factorial_j *= j;
@@ -1447,7 +1450,7 @@ FE_Q_Hierarchical<dim>::get_subface_interpolation_matrix(
                                                j + 2 * this->degree) = tmp;
                           int factorial_k                            = 1;
 
-                          for (int k = 2; k <= (int)this->degree; ++k)
+                          for (unsigned int k = 2; k <= this->degree; ++k)
                             {
                               interpolation_matrix(
                                 i + (k + 2) * source_fe.degree - k,
@@ -1457,7 +1460,8 @@ FE_Q_Hierarchical<dim>::get_subface_interpolation_matrix(
                               int factorial_l  = factorial_k;
                               int factorial_kl = 1;
 
-                              for (int l = k + 1; l <= (int)this->degree; ++l)
+                              for (unsigned int l = k + 1; l <= this->degree;
+                                   ++l)
                                 {
                                   factorial_kl *= l - k;
                                   factorial_l *= l;
@@ -1517,7 +1521,7 @@ FE_Q_Hierarchical<dim>::get_subface_interpolation_matrix(
 
                       int factorial_k = 1;
 
-                      for (int j = 2; j <= (int)this->degree; ++j)
+                      for (unsigned int j = 2; j <= this->degree; ++j)
                         {
                           interpolation_matrix(i + (j + 2) * source_fe.degree -
                                                  j,
@@ -1527,7 +1531,7 @@ FE_Q_Hierarchical<dim>::get_subface_interpolation_matrix(
                           int factorial_l  = factorial_k;
                           int factorial_kl = 1;
 
-                          for (int k = j + 1; k <= (int)this->degree; ++k)
+                          for (unsigned int k = j + 1; k <= this->degree; ++k)
                             {
                               factorial_kl *= k - j;
                               factorial_l *= k;
@@ -1589,7 +1593,7 @@ FE_Q_Hierarchical<dim>::get_subface_interpolation_matrix(
 
                   int factorial_i = 1;
 
-                  for (int i = 2; i <= (int)this->degree; ++i)
+                  for (unsigned int i = 2; i <= this->degree; ++i)
                     {
                       double tmp                         = std::pow(0.5, i);
                       interpolation_matrix(i + 2, i + 2) = tmp;
@@ -1619,7 +1623,7 @@ FE_Q_Hierarchical<dim>::get_subface_interpolation_matrix(
 
                       int factorial_k = 1;
 
-                      for (int j = 2; j <= (int)this->degree; ++j)
+                      for (unsigned int j = 2; j <= this->degree; ++j)
                         {
                           interpolation_matrix(i + (j + 2) * source_fe.degree -
                                                  j,
@@ -1629,7 +1633,7 @@ FE_Q_Hierarchical<dim>::get_subface_interpolation_matrix(
                           int factorial_kl = 1;
                           int factorial_l  = factorial_k;
 
-                          for (int k = j + 1; k <= (int)this->degree; ++k)
+                          for (unsigned int k = j + 1; k <= this->degree; ++k)
                             {
                               factorial_kl *= k - j;
                               factorial_l *= k;
@@ -1645,7 +1649,7 @@ FE_Q_Hierarchical<dim>::get_subface_interpolation_matrix(
                       int factorial_j  = factorial_i;
                       int factorial_ij = 1;
 
-                      for (int j = i + 1; j <= (int)this->degree; ++j)
+                      for (unsigned int j = i + 1; j <= this->degree; ++j)
                         {
                           factorial_ij *= j - i;
                           factorial_j *= j;
@@ -1680,7 +1684,7 @@ FE_Q_Hierarchical<dim>::get_subface_interpolation_matrix(
                                                j + 3 * this->degree - 1) = tmp;
                           int factorial_k                                = 1;
 
-                          for (int k = 2; k <= (int)this->degree; ++k)
+                          for (unsigned int k = 2; k <= this->degree; ++k)
                             {
                               interpolation_matrix(
                                 i + (k + 2) * source_fe.degree - k,
@@ -1690,7 +1694,8 @@ FE_Q_Hierarchical<dim>::get_subface_interpolation_matrix(
                               int factorial_l  = factorial_k;
                               int factorial_kl = 1;
 
-                              for (int l = k + 1; l <= (int)this->degree; ++l)
+                              for (unsigned int l = k + 1; l <= this->degree;
+                                   ++l)
                                 {
                                   factorial_kl *= l - k;
                                   factorial_l *= l;
@@ -1754,7 +1759,7 @@ FE_Q_Hierarchical<dim>::get_subface_interpolation_matrix(
 
                   int factorial_i = 1;
 
-                  for (int i = 2; i <= (int)this->degree; ++i)
+                  for (unsigned int i = 2; i <= this->degree; ++i)
                     {
                       double tmp                         = std::pow(0.5, i + 1);
                       interpolation_matrix(i + 2, i + 2) = tmp;
@@ -1783,7 +1788,7 @@ FE_Q_Hierarchical<dim>::get_subface_interpolation_matrix(
                                            i + 3 * this->degree - 1) = tmp;
                       int factorial_k                                = 1;
 
-                      for (int j = 2; j <= (int)this->degree; ++j)
+                      for (unsigned int j = 2; j <= this->degree; ++j)
                         {
                           interpolation_matrix(i + (j + 2) * source_fe.degree -
                                                  j,
@@ -1793,7 +1798,7 @@ FE_Q_Hierarchical<dim>::get_subface_interpolation_matrix(
                           int factorial_l  = factorial_k;
                           int factorial_kl = 1;
 
-                          for (int k = j + 1; k <= (int)this->degree; ++k)
+                          for (unsigned int k = j + 1; k <= this->degree; ++k)
                             {
                               factorial_kl *= k - j;
                               factorial_l *= k;
@@ -1809,7 +1814,7 @@ FE_Q_Hierarchical<dim>::get_subface_interpolation_matrix(
                       int factorial_j  = factorial_i;
                       int factorial_ij = 1;
 
-                      for (int j = i + 1; j <= (int)this->degree; ++j)
+                      for (unsigned int j = i + 1; j <= this->degree; ++j)
                         {
                           factorial_ij *= j - i;
                           factorial_j *= j;
@@ -1829,7 +1834,7 @@ FE_Q_Hierarchical<dim>::get_subface_interpolation_matrix(
                                                j + 3 * this->degree - 1) = tmp;
                           int factorial_k                                = 1;
 
-                          for (int k = 2; k <= (int)this->degree; ++k)
+                          for (unsigned int k = 2; k <= this->degree; ++k)
                             {
                               interpolation_matrix(
                                 i + (k + 2) * source_fe.degree - k,
@@ -1839,7 +1844,8 @@ FE_Q_Hierarchical<dim>::get_subface_interpolation_matrix(
                               int factorial_l  = factorial_k;
                               int factorial_kl = 1;
 
-                              for (int l = k + 1; l <= (int)this->degree; ++l)
+                              for (unsigned int l = k + 1; l <= this->degree;
+                                   ++l)
                                 {
                                   factorial_kl *= l - k;
                                   factorial_l *= l;

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.