From: Daniel Arndt Date: Tue, 27 Nov 2018 16:52:29 +0000 (+0100) Subject: Avoid C-style cast in dofs X-Git-Tag: v9.1.0-rc1~525^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6b44ab00e846c415ec31d332272490afd9b9d9e0;p=dealii.git Avoid C-style cast in dofs --- diff --git a/source/dofs/dof_handler_policy.cc b/source/dofs/dof_handler_policy.cc index 08f223ebac..48cfdee471 100644 --- a/source/dofs/dof_handler_policy.cc +++ b/source/dofs/dof_handler_policy.cc @@ -4119,9 +4119,10 @@ namespace internal displacements[i] = shift; shift += rcounts[i]; } - Assert(((int)new_numbers_copy.size()) == - rcounts[Utilities::MPI::this_mpi_process( - tr->get_communicator())], + Assert(new_numbers_copy.size() == + static_cast( + rcounts[Utilities::MPI::this_mpi_process( + tr->get_communicator())]), ExcInternalError()); ierr = MPI_Allgatherv(new_numbers_copy.data(), new_numbers_copy.size(), diff --git a/source/dofs/dof_renumbering.cc b/source/dofs/dof_renumbering.cc index 4cc48a8f55..577e70657a 100644 --- a/source/dofs/dof_renumbering.cc +++ b/source/dofs/dof_renumbering.cc @@ -1722,14 +1722,11 @@ namespace DoFRenumbering unsigned int global_index = 0; - typename std::vector< - typename DoFHandlerType::level_cell_iterator>::const_iterator cell; - - for (cell = cells.begin(); cell != cells.end(); ++cell) + for (const auto &cell : cells) { - Assert((*cell)->level() == (int)level, ExcInternalError()); + Assert(cell->level() == static_cast(level), ExcInternalError()); - (*cell)->get_active_or_mg_dof_indices(cell_dofs); + cell->get_active_or_mg_dof_indices(cell_dofs); std::sort(cell_dofs.begin(), cell_dofs.end()); for (unsigned int i = 0; i < n_cell_dofs; ++i) diff --git a/source/dofs/dof_tools.cc b/source/dofs/dof_tools.cc index f91993853e..93e76a220d 100644 --- a/source/dofs/dof_tools.cc +++ b/source/dofs/dof_tools.cc @@ -129,7 +129,7 @@ namespace DoFTools const ComponentMask &component_mask) { std::vector local_component_association( - fe.dofs_per_cell, (unsigned char)(-1)); + fe.dofs_per_cell, static_cast(-1)); // compute the component each local dof belongs to. // if the shape function is primitive, then this @@ -170,7 +170,7 @@ namespace DoFTools Assert(std::find(local_component_association.begin(), local_component_association.end(), - (unsigned char)(-1)) == + static_cast(-1)) == local_component_association.end(), ExcInternalError()); @@ -280,13 +280,13 @@ namespace DoFTools DoFHandlerType::space_dimension> &fe = fe_collection[f]; local_block_association[f].resize(fe.dofs_per_cell, - (unsigned char)(-1)); + static_cast(-1)); for (unsigned int i = 0; i < fe.dofs_per_cell; ++i) local_block_association[f][i] = fe.system_to_block_index(i).first; Assert(std::find(local_block_association[f].begin(), local_block_association[f].end(), - (unsigned char)(-1)) == + static_cast(-1)) == local_block_association[f].end(), ExcInternalError()); } @@ -2649,7 +2649,8 @@ namespace DoFTools if (cell->at_boundary(face)) vertex_boundary[vg] = true; else if ((!level_boundary_patches) && - (cell->neighbor(face)->level() != (int)level)) + (cell->neighbor(face)->level() != + static_cast(level))) vertex_boundary[vg] = true; } } diff --git a/source/dofs/dof_tools_constraints.cc b/source/dofs/dof_tools_constraints.cc index 86348638f9..28b477c455 100644 --- a/source/dofs/dof_tools_constraints.cc +++ b/source/dofs/dof_tools_constraints.cc @@ -2245,7 +2245,7 @@ namespace DoFTools // matrix, we assume that for a 0* rotation we would have to build the // identity matrix - Assert(matrix.m() == (int)spacedim, ExcInternalError()) + Assert(matrix.m() == spacedim, ExcInternalError()) Quadrature quadrature(fe.get_unit_face_support_points()); @@ -2351,7 +2351,7 @@ namespace DoFTools ExcMessage("The supplied (rotation or interpolation) matrix must " "be a square matrix")); - Assert(first_vector_components.empty() || matrix.m() == (int)spacedim, + Assert(first_vector_components.empty() || matrix.m() == spacedim, ExcMessage("first_vector_components is nonempty, so matrix must " "be a rotation matrix exactly of size spacedim")); @@ -2362,15 +2362,15 @@ namespace DoFTools const unsigned int n_dofs_per_face = face_1->get_fe(face_1->nth_active_fe_index(0)).dofs_per_face; - Assert( - matrix.m() == 0 || - (first_vector_components.empty() && - matrix.m() == n_dofs_per_face) || - (!first_vector_components.empty() && matrix.m() == (int)spacedim), - ExcMessage("The matrix must have either size 0 or spacedim " - "(if first_vector_components is nonempty) " - "or the size must be equal to the # of DoFs on the face " - "(if first_vector_components is empty).")); + Assert(matrix.m() == 0 || + (first_vector_components.empty() && + matrix.m() == n_dofs_per_face) || + (!first_vector_components.empty() && matrix.m() == spacedim), + ExcMessage( + "The matrix must have either size 0 or spacedim " + "(if first_vector_components is nonempty) " + "or the size must be equal to the # of DoFs on the face " + "(if first_vector_components is empty).")); } if (!face_2->has_children()) @@ -2379,15 +2379,15 @@ namespace DoFTools const unsigned int n_dofs_per_face = face_2->get_fe(face_2->nth_active_fe_index(0)).dofs_per_face; - Assert( - matrix.m() == 0 || - (first_vector_components.empty() && - matrix.m() == n_dofs_per_face) || - (!first_vector_components.empty() && matrix.m() == (int)spacedim), - ExcMessage("The matrix must have either size 0 or spacedim " - "(if first_vector_components is nonempty) " - "or the size must be equal to the # of DoFs on the face " - "(if first_vector_components is empty).")); + Assert(matrix.m() == 0 || + (first_vector_components.empty() && + matrix.m() == n_dofs_per_face) || + (!first_vector_components.empty() && matrix.m() == spacedim), + ExcMessage( + "The matrix must have either size 0 or spacedim " + "(if first_vector_components is nonempty) " + "or the size must be equal to the # of DoFs on the face " + "(if first_vector_components is empty).")); } #endif