From 71e2cd2e6a2be59dfdd5fd76efd29ce338fe62e7 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Mon, 15 Nov 2021 21:02:11 -0700 Subject: [PATCH] Make dimension counters unsigned. --- .../deal.II/base/symmetric_tensor.templates.h | 20 +++++++++---------- include/deal.II/lac/tensor_product_matrix.h | 4 ++-- .../deal.II/matrix_free/cuda_fe_evaluation.h | 8 ++++---- .../deal.II/matrix_free/cuda_matrix_free.h | 2 +- .../matrix_free/cuda_matrix_free.templates.h | 2 +- .../matrix_free/mapping_info.templates.h | 4 ++-- .../matrix_free/shape_info.templates.h | 4 ++-- source/arborx/access_traits.cc | 2 +- source/base/function_restriction.cc | 8 ++++---- source/base/function_signed_distance.cc | 4 ++-- source/base/quadrature_lib.cc | 2 +- source/distributed/tria_base.cc | 2 +- source/dofs/dof_tools_constraints.cc | 4 ++-- source/fe/fe_abf.cc | 2 +- source/fe/fe_q_base.cc | 2 +- source/fe/mapping_q_cache.cc | 2 +- source/grid/grid_tools.cc | 2 +- source/grid/grid_tools_dof_handlers.cc | 4 ++-- source/non_matching/quadrature_generator.cc | 6 +++--- 19 files changed, 42 insertions(+), 42 deletions(-) diff --git a/include/deal.II/base/symmetric_tensor.templates.h b/include/deal.II/base/symmetric_tensor.templates.h index 80bb1252f4..11fd79bd06 100644 --- a/include/deal.II/base/symmetric_tensor.templates.h +++ b/include/deal.II/base/symmetric_tensor.templates.h @@ -225,7 +225,7 @@ namespace internal } else { - for (int i = 0; i < dim; ++i) + for (unsigned int i = 0; i < dim; ++i) d[i] = A[i][i]; // For dim = 3: @@ -339,7 +339,7 @@ namespace internal g = c * r - b; // Form the eigenvectors - for (int k = 0; k < dim; ++k) + for (unsigned int k = 0; k < dim; ++k) { t = Q[k][i + 1]; Q[k][i + 1] = s * Q[k][i] + c * t; @@ -399,7 +399,7 @@ namespace internal // The diagonal elements of the tridiagonal matrix; // this will ultimately store the eigenvalues std::array w; - for (int i = 0; i < dim; ++i) + for (unsigned int i = 0; i < dim; ++i) w[i] = A[i][i]; // Calculate (tr(A))^{2} @@ -412,7 +412,7 @@ namespace internal { // Test for convergence so = 0.0; - for (int p = 0; p < dim; ++p) + for (unsigned int p = 0; p < dim; ++p) for (int q = p + 1; q < dim; ++q) so += std::abs(A[p][q]); if (so == 0.0) @@ -438,8 +438,8 @@ namespace internal thresh = 0.0; // Perform sweep - for (int p = 0; p < dim; ++p) - for (int q = p + 1; q < dim; ++q) + for (unsigned int p = 0; p < dim; ++p) + for (unsigned int q = p + 1; q < dim; ++q) { g = 100.0 * std::abs(A[p][q]); @@ -486,19 +486,19 @@ namespace internal w[p] -= z; w[q] += z; // ... by executing the various rotations in sequence - for (int r = 0; r < p; ++r) + for (unsigned int r = 0; r < p; ++r) { t = A[r][p]; A[r][p] = c * t - s * A[r][q]; A[r][q] = s * t + c * A[r][q]; } - for (int r = p + 1; r < q; ++r) + for (unsigned int r = p + 1; r < q; ++r) { t = A[p][r]; A[p][r] = c * t - s * A[r][q]; A[r][q] = s * t + c * A[r][q]; } - for (int r = q + 1; r < dim; ++r) + for (unsigned int r = q + 1; r < dim; ++r) { t = A[p][r]; A[p][r] = c * t - s * A[q][r]; @@ -506,7 +506,7 @@ namespace internal } // Update the eigenvectors - for (int r = 0; r < dim; ++r) + for (unsigned int r = 0; r < dim; ++r) { t = Q[r][p]; Q[r][p] = c * t - s * Q[r][q]; diff --git a/include/deal.II/lac/tensor_product_matrix.h b/include/deal.II/lac/tensor_product_matrix.h index 4792722dd4..d091aae6ad 100644 --- a/include/deal.II/lac/tensor_product_matrix.h +++ b/include/deal.II/lac/tensor_product_matrix.h @@ -670,7 +670,7 @@ TensorProductMatrixSymmetricSum::reinit_impl( this->mass_matrix = mass_matrices; this->derivative_matrix = derivative_matrices; - for (int dir = 0; dir < dim; ++dir) + for (unsigned int dir = 0; dir < dim; ++dir) { Assert(n_rows_1d == -1 || (n_rows_1d > 0 && static_cast(n_rows_1d) == @@ -811,7 +811,7 @@ TensorProductMatrixSymmetricSum, n_rows_1d>:: eigenvectors_flat.resize(nm_flat_size_max); std::array offsets_nm; std::array offsets_n; - for (int dir = 0; dir < dim; ++dir) + for (unsigned int dir = 0; dir < dim; ++dir) { Assert(n_rows_1d == -1 || (n_rows_1d > 0 && static_cast(n_rows_1d) == diff --git a/include/deal.II/matrix_free/cuda_fe_evaluation.h b/include/deal.II/matrix_free/cuda_fe_evaluation.h index d913082f36..356479f59c 100644 --- a/include/deal.II/matrix_free/cuda_fe_evaluation.h +++ b/include/deal.II/matrix_free/cuda_fe_evaluation.h @@ -494,10 +494,10 @@ namespace CUDAWrappers const unsigned int q_point = internal::compute_index(); const Number * inv_jacobian = &inv_jac[q_point]; gradient_type grad; - for (int d_1 = 0; d_1 < dim; ++d_1) + for (unsigned int d_1 = 0; d_1 < dim; ++d_1) { Number tmp = 0.; - for (int d_2 = 0; d_2 < dim; ++d_2) + for (unsigned int d_2 = 0; d_2 < dim; ++d_2) tmp += inv_jacobian[padding_length * n_cells * (dim * d_2 + d_1)] * gradients[d_2][q_point]; grad[d_1] = tmp; @@ -520,10 +520,10 @@ namespace CUDAWrappers // TODO optimize if the mesh is uniform const unsigned int q_point = internal::compute_index(); const Number * inv_jacobian = &inv_jac[q_point]; - for (int d_1 = 0; d_1 < dim; ++d_1) + for (unsigned int d_1 = 0; d_1 < dim; ++d_1) { Number tmp = 0.; - for (int d_2 = 0; d_2 < dim; ++d_2) + for (unsigned int d_2 = 0; d_2 < dim; ++d_2) tmp += inv_jacobian[n_cells * padding_length * (dim * d_1 + d_2)] * grad_in[d_2]; gradients[d_1][q_point] = tmp * JxW[q_point]; diff --git a/include/deal.II/matrix_free/cuda_matrix_free.h b/include/deal.II/matrix_free/cuda_matrix_free.h index 31f322fa18..ce63e660b3 100644 --- a/include/deal.II/matrix_free/cuda_matrix_free.h +++ b/include/deal.II/matrix_free/cuda_matrix_free.h @@ -678,7 +678,7 @@ namespace CUDAWrappers SharedData(Number *vd, Number *gq[dim]) : values(vd) { - for (int d = 0; d < dim; ++d) + for (unsigned int d = 0; d < dim; ++d) gradients[d] = gq[d]; } diff --git a/include/deal.II/matrix_free/cuda_matrix_free.templates.h b/include/deal.II/matrix_free/cuda_matrix_free.templates.h index 4c64f02188..91ee7859a7 100644 --- a/include/deal.II/matrix_free/cuda_matrix_free.templates.h +++ b/include/deal.II/matrix_free/cuda_matrix_free.templates.h @@ -587,7 +587,7 @@ namespace CUDAWrappers local_cell + cells_per_block * (blockIdx.x + gridDim.x * blockIdx.y); Number *gq[dim]; - for (int d = 0; d < dim; ++d) + for (unsigned int d = 0; d < dim; ++d) gq[d] = &gradients[d][local_cell * Functor::n_q_points]; SharedData shared_data( diff --git a/include/deal.II/matrix_free/mapping_info.templates.h b/include/deal.II/matrix_free/mapping_info.templates.h index 2c3072008f..c17a0e561d 100644 --- a/include/deal.II/matrix_free/mapping_info.templates.h +++ b/include/deal.II/matrix_free/mapping_info.templates.h @@ -100,7 +100,7 @@ namespace internal for (unsigned int i = 0; i < n_q_points; ++i) quadrature_weights[i] = quadrature.weight(i); - for (int d = 0; d < structdim; ++d) + for (unsigned int d = 0; d < structdim; ++d) { tensor_quadrature_weights[d].resize(quadrature_1d.size()); for (unsigned int i = 0; i < quadrature_1d.size(); ++i) @@ -149,7 +149,7 @@ namespace internal std::size_t memory = sizeof(this) + quadrature.memory_consumption() + quadrature_weights.memory_consumption() + face_orientations.memory_consumption(); - for (int d = 0; d < structdim; ++d) + for (unsigned int d = 0; d < structdim; ++d) memory += tensor_quadrature_weights[d].memory_consumption(); return memory; } diff --git a/include/deal.II/matrix_free/shape_info.templates.h b/include/deal.II/matrix_free/shape_info.templates.h index e1643d51da..6a47ff1a42 100644 --- a/include/deal.II/matrix_free/shape_info.templates.h +++ b/include/deal.II/matrix_free/shape_info.templates.h @@ -332,7 +332,7 @@ namespace internal const auto grad = fe.shape_grad(i, quad.point(q)); - for (int d = 0; d < dim; ++d) + for (unsigned int d = 0; d < dim; ++d) shape_gradients[d * n_dofs * n_q_points + i * n_q_points + q] = grad[d]; } @@ -422,7 +422,7 @@ namespace internal const auto grad = fe.shape_grad(i, point); - for (int d = 0; d < dim; ++d) + for (unsigned int d = 0; d < dim; ++d) shape_gradients_face( f, o, d, i * n_q_points_face + q) = grad[d]; } diff --git a/source/arborx/access_traits.cc b/source/arborx/access_traits.cc index 08fbbc0a60..e94b058423 100644 --- a/source/arborx/access_traits.cc +++ b/source/arborx/access_traits.cc @@ -95,7 +95,7 @@ namespace ArborXWrappers auto boundary_points = bb[i].get_boundary_points(); dealii::Point min_corner = boundary_points.first; dealii::Point max_corner = boundary_points.second; - for (int d = 0; d < dim; ++d) + for (unsigned int d = 0; d < dim; ++d) { min_corner_arborx[d] = static_cast(min_corner[d]); max_corner_arborx[d] = static_cast(max_corner[d]); diff --git a/source/base/function_restriction.cc b/source/base/function_restriction.cc index bfdfff8154..a21e250983 100644 --- a/source/base/function_restriction.cc +++ b/source/base/function_restriction.cc @@ -29,7 +29,7 @@ namespace internal Point output; output(component_in_dim_plus_1) = coordinate_value; - for (int d = 0; d < dim; ++d) + for (unsigned int d = 0; d < dim; ++d) { const unsigned int component_to_write_to = dealii::internal::coordinate_to_one_dim_higher( @@ -91,7 +91,7 @@ namespace Functions // the derivatives with respect to this direction and copy the other // values. Tensor<1, dim> grad; - for (int d = 0; d < dim; ++d) + for (unsigned int d = 0; d < dim; ++d) { const unsigned int index_to_write_from = internal::coordinate_to_one_dim_higher(restricted_direction, d); @@ -119,11 +119,11 @@ namespace Functions // the derivatives with respect to this direction and copy the other // values. SymmetricTensor<2, dim> hess; - for (int i = 0; i < dim; ++i) + for (unsigned int i = 0; i < dim; ++i) { const unsigned int i_to_write_from = internal::coordinate_to_one_dim_higher(restricted_direction, i); - for (int j = 0; j < dim; ++j) + for (unsigned int j = 0; j < dim; ++j) { const unsigned int j_to_write_from = internal::coordinate_to_one_dim_higher(restricted_direction, diff --git a/source/base/function_signed_distance.cc b/source/base/function_signed_distance.cc index af14810e22..e1f28544e8 100644 --- a/source/base/function_signed_distance.cc +++ b/source/base/function_signed_distance.cc @@ -140,7 +140,7 @@ namespace Functions , tolerance(tolerance) , max_iter(max_iter) { - for (int d = 0; d < dim; ++d) + for (unsigned int d = 0; d < dim; ++d) Assert(radii[d] > 0, ExcMessage("All radii must be positive.")) } @@ -171,7 +171,7 @@ namespace Functions Ellipsoid::evaluate_ellipsoid(const Point &point) const { double val = 0.0; - for (int d = 0; d < dim; ++d) + for (unsigned int d = 0; d < dim; ++d) val += std::pow((point[d] - center[d]) / radii[d], 2); return val - 1.0; } diff --git a/source/base/quadrature_lib.cc b/source/base/quadrature_lib.cc index 368cd980fe..0245c5fb32 100644 --- a/source/base/quadrature_lib.cc +++ b/source/base/quadrature_lib.cc @@ -1214,7 +1214,7 @@ QSimplex::QSimplex(const Quadrature &quad) * around a wrong diagnostic in gcc-10.3.0 that warns about that the * comparison "d < dim" is always false in case of "dim == 0". * MM 2021 */ - for (int d = 0; d < dim; ++d) + for (unsigned int d = 0; d < dim; ++d) r += quad.point(i)[d]; if (r <= 1 + 1e-10) { diff --git a/source/distributed/tria_base.cc b/source/distributed/tria_base.cc index 971288f4b1..f8bddb90c0 100644 --- a/source/distributed/tria_base.cc +++ b/source/distributed/tria_base.cc @@ -597,7 +597,7 @@ namespace parallel #endif Point invalid_point; - for (int d = 0; d < spacedim; ++d) + for (unsigned int d = 0; d < spacedim; ++d) invalid_point[d] = std::numeric_limits::quiet_NaN(); const auto pack = [&](const auto &cell) { diff --git a/source/dofs/dof_tools_constraints.cc b/source/dofs/dof_tools_constraints.cc index d285de7841..7cd1aa34b1 100644 --- a/source/dofs/dof_tools_constraints.cc +++ b/source/dofs/dof_tools_constraints.cc @@ -2266,10 +2266,10 @@ namespace DoFTools // ... and rotate all dofs belonging to vector valued components // that are selected by first_vector_components: - for (int i = 0; i < spacedim; ++i) + for (unsigned int i = 0; i < spacedim; ++i) { transformation[vector_dofs[i]][vector_dofs[i]] = 0.; - for (int j = 0; j < spacedim; ++j) + for (unsigned int j = 0; j < spacedim; ++j) transformation[vector_dofs[i]][vector_dofs[j]] = matrix[i][j]; } diff --git a/source/fe/fe_abf.cc b/source/fe/fe_abf.cc index 4c6b68a133..e4f80156bf 100644 --- a/source/fe/fe_abf.cc +++ b/source/fe/fe_abf.cc @@ -500,7 +500,7 @@ FE_ABF::get_dpo_vector(const unsigned int rt_order) // Initiative...), and we have // (rt_order+1)^(dim-1) DoFs per face unsigned int dofs_per_face = 1; - for (int d = 0; d < dim - 1; ++d) + for (unsigned int d = 0; d < dim - 1; ++d) dofs_per_face *= rt_order + 1; // and then there are interior dofs diff --git a/source/fe/fe_q_base.cc b/source/fe/fe_q_base.cc index 77d129d7d4..281f698e41 100644 --- a/source/fe/fe_q_base.cc +++ b/source/fe/fe_q_base.cc @@ -67,7 +67,7 @@ namespace internal increment_indices(unsigned int (&indices)[dim], const unsigned int dofs1d) { ++indices[0]; - for (int d = 0; d < dim - 1; ++d) + for (unsigned int d = 0; d < dim - 1; ++d) if (indices[d] == dofs1d) { indices[d] = 0; diff --git a/source/fe/mapping_q_cache.cc b/source/fe/mapping_q_cache.cc index 3b16a492b5..0975faac00 100644 --- a/source/fe/mapping_q_cache.cc +++ b/source/fe/mapping_q_cache.cc @@ -268,7 +268,7 @@ MappingQCache::initialize( tria, [&](const auto &, const auto &point) { Point new_point; - for (int c = 0; c < spacedim; ++c) + for (unsigned int c = 0; c < spacedim; ++c) new_point[c] = transformation_function.value(point, c); return new_point; }, diff --git a/source/grid/grid_tools.cc b/source/grid/grid_tools.cc index ba6e7f2a0b..eb8688c147 100644 --- a/source/grid/grid_tools.cc +++ b/source/grid/grid_tools.cc @@ -2796,7 +2796,7 @@ namespace GridTools auto p1 = p; auto p2 = p; - for (int d = 0; d < spacedim; ++d) + for (unsigned int d = 0; d < spacedim; ++d) { p1[d] = p1[d] - tolerance; p2[d] = p2[d] + tolerance; diff --git a/source/grid/grid_tools_dof_handlers.cc b/source/grid/grid_tools_dof_handlers.cc index 9a8cf26e33..b5e4645345 100644 --- a/source/grid/grid_tools_dof_handlers.cc +++ b/source/grid/grid_tools_dof_handlers.cc @@ -2286,8 +2286,8 @@ namespace GridTools Point distance; if (matrix.m() == spacedim) - for (int i = 0; i < spacedim; ++i) - for (int j = 0; j < spacedim; ++j) + for (unsigned int i = 0; i < spacedim; ++i) + for (unsigned int j = 0; j < spacedim; ++j) distance(i) += matrix(i, j) * point1(j); else distance = point1; diff --git a/source/non_matching/quadrature_generator.cc b/source/non_matching/quadrature_generator.cc index 7588e76e7e..cef3e4e3b4 100644 --- a/source/non_matching/quadrature_generator.cc +++ b/source/non_matching/quadrature_generator.cc @@ -273,7 +273,7 @@ namespace NonMatching if (!min_lower_abs_grad) { min_lower_abs_grad.emplace(); - for (int d = 0; d < dim; ++d) + for (unsigned int d = 0; d < dim; ++d) { (*min_lower_abs_grad)[d] = lower_bound_on_abs(bounds.gradient[d]); @@ -281,7 +281,7 @@ namespace NonMatching } else { - for (int d = 0; d < dim; ++d) + for (unsigned int d = 0; d < dim; ++d) { (*min_lower_abs_grad)[d] = std::min((*min_lower_abs_grad)[d], @@ -945,7 +945,7 @@ namespace NonMatching { // Get the side lengths for each direction and sort them. std::array, dim> side_lengths; - for (int i = 0; i < dim; ++i) + for (unsigned int i = 0; i < dim; ++i) { side_lengths[i].first = box.side_length(i); side_lengths[i].second = i; -- 2.39.5