From: Matthias Maier Date: Thu, 16 Apr 2015 15:32:25 +0000 (+0200) Subject: Simplify nested if/for clauses to avoid -Wdangling-else warnings X-Git-Tag: v8.3.0-rc1~265^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F813%2Fhead;p=dealii.git Simplify nested if/for clauses to avoid -Wdangling-else warnings --- diff --git a/include/deal.II/lac/constraint_matrix.templates.h b/include/deal.II/lac/constraint_matrix.templates.h index 2fe7edc31b..835988e11d 100644 --- a/include/deal.II/lac/constraint_matrix.templates.h +++ b/include/deal.II/lac/constraint_matrix.templates.h @@ -1,6 +1,6 @@ // --------------------------------------------------------------------- // -// Copyright (C) 1999 - 2014 by the deal.II authors +// Copyright (C) 1999 - 2015 by the deal.II authors // // This file is part of the deal.II library. // @@ -636,33 +636,37 @@ distribute_local_to_global (const Vector &local_vector, const ConstraintLine *position = lines_cache.size() <= line_index ? 0 : &lines[lines_cache[line_index]]; - // Gauss elimination of the matrix columns - // with the inhomogeneity. Go through them one - // by one and again check whether they are + // Gauss elimination of the matrix columns with the inhomogeneity. + // Go through them one by one and again check whether they are // constrained. If so, distribute the constraint const double val = position->inhomogeneity; if (val != 0) for (size_type j=0; jis_artificial ()) + { + // artificial cells can at best neighbor ghost cells, but we're not + // interested in these interfaces + if (cell->is_artificial ()) + continue; + for (unsigned int face=0; face::faces_per_cell; ++face) if (cell->face(face)->has_children()) { @@ -857,6 +860,7 @@ namespace DoFTools ExcInternalError()); } } + } } @@ -884,9 +888,12 @@ namespace DoFTools typename DH::active_cell_iterator cell = dof_handler.begin_active(), endc = dof_handler.end(); for (; cell!=endc; ++cell) - // artificial cells can at best neighbor ghost cells, but we're not - // interested in these interfaces - if (!cell->is_artificial ()) + { + // artificial cells can at best neighbor ghost cells, but we're not + // interested in these interfaces + if (cell->is_artificial ()) + continue; + for (unsigned int face=0; face::faces_per_cell; ++face) if (cell->face(face)->has_children()) { @@ -1073,6 +1080,7 @@ namespace DoFTools ExcInternalError()); } } + } } @@ -1137,9 +1145,12 @@ namespace DoFTools typename DH::active_cell_iterator cell = dof_handler.begin_active(), endc = dof_handler.end(); for (; cell!=endc; ++cell) - // artificial cells can at best neighbor ghost cells, but we're not - // interested in these interfaces - if (!cell->is_artificial ()) + { + // artificial cells can at best neighbor ghost cells, but we're not + // interested in these interfaces + if (cell->is_artificial ()) + continue; + for (unsigned int face=0; face::faces_per_cell; ++face) if (cell->face(face)->has_children()) { @@ -1594,6 +1605,7 @@ namespace DoFTools } } } + } } } diff --git a/source/grid/tria_accessor.cc b/source/grid/tria_accessor.cc index 2fc78e1fc4..11551eae90 100644 --- a/source/grid/tria_accessor.cc +++ b/source/grid/tria_accessor.cc @@ -1830,39 +1830,39 @@ CellAccessor::neighbor_of_coarser_neighbor (const unsigned int ne - // if the guess was false, then - // we need to loop over all faces - // and subfaces and find the - // number the hard way + // if the guess was false, then we need to loop over all faces and + // subfaces and find the number the hard way for (unsigned int face_no=0; face_no::faces_per_cell; ++face_no) { - if (face_no!=face_no_guess) + if (face_no==face_no_guess) + continue; + + const TriaIterator > face + =neighbor_cell->face(face_no); + + if (!face->has_children()) + continue; + + for (unsigned int subface_no=0; subface_non_children(); ++subface_no) { - const TriaIterator > face - =neighbor_cell->face(face_no); - if (face->has_children()) - for (unsigned int subface_no=0; subface_non_children(); ++subface_no) - if (face->child_index(subface_no)==this_face_index) - // call a helper function, that - // translates the current subface - // number to a subface number for - // the current FaceRefineCase - return std::make_pair (face_no, translate_subface_no(face, subface_no)); - else if (face->child(subface_no)->has_children()) - for (unsigned int subsub_no=0; subsub_nochild(subface_no)->n_children(); ++subsub_no) - if (face->child(subface_no)->child_index(subsub_no)==this_face_index) - // call a helper function, that - // translates the current subface - // number and subsubface number to - // a subface number for the current - // FaceRefineCase - return std::make_pair (face_no, translate_subface_no(face, subface_no, subsub_no)); + if (face->child_index(subface_no)==this_face_index) + // call a helper function, that translates the current + // subface number to a subface number for the current + // FaceRefineCase + return std::make_pair (face_no, translate_subface_no(face, subface_no)); + + if (face->child(subface_no)->has_children()) + for (unsigned int subsub_no=0; subsub_nochild(subface_no)->n_children(); ++subsub_no) + if (face->child(subface_no)->child_index(subsub_no)==this_face_index) + // call a helper function, that translates the current + // subface number and subsubface number to a subface + // number for the current FaceRefineCase + return std::make_pair (face_no, translate_subface_no(face, subface_no, subsub_no)); } } - // we should never get here, - // since then we did not find - // our way back... + // we should never get here, since then we did not find our way + // back... Assert (false, ExcInternalError()); return std::make_pair (numbers::invalid_unsigned_int, numbers::invalid_unsigned_int);