From: Wolfgang Bangerth Date: Fri, 15 Jan 2021 04:32:21 +0000 (-0700) Subject: Simplify control flow slightly. X-Git-Tag: v9.3.0-rc1~613^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F11526%2Fhead;p=dealii.git Simplify control flow slightly. --- diff --git a/source/dofs/dof_tools_constraints.cc b/source/dofs/dof_tools_constraints.cc index b8cbe7a92d..7809d2d525 100644 --- a/source/dofs/dof_tools_constraints.cc +++ b/source/dofs/dof_tools_constraints.cc @@ -528,46 +528,46 @@ namespace DoFTools // satisfied, and we can move on to the next dependent // DoF (row). The only thing we should make sure is that the // row of the matrix really just contains this one entry. - bool is_trivial_constraint = false; + { + bool is_trivial_constraint = false; - for (unsigned int i = 0; i < n_primary_dofs; ++i) - if (face_constraints(row, i) == 1.0) - if (dependent_dofs[row] == primary_dofs[i]) - { - is_trivial_constraint = true; + for (unsigned int i = 0; i < n_primary_dofs; ++i) + if (face_constraints(row, i) == 1.0) + if (dependent_dofs[row] == primary_dofs[i]) + { + is_trivial_constraint = true; - for (unsigned int ii = 0; ii < n_primary_dofs; ++ii) - if (ii != i) - Assert(face_constraints(row, ii) == 0.0, - ExcInternalError()); + for (unsigned int ii = 0; ii < n_primary_dofs; ++ii) + if (ii != i) + Assert(face_constraints(row, ii) == 0.0, + ExcInternalError()); - break; - } + break; + } - if (is_trivial_constraint == false) - { - // add up the absolute values of all constraints in this line - // to get a measure of their absolute size - number1 abs_sum = 0; - for (unsigned int i = 0; i < n_primary_dofs; ++i) - abs_sum += std::abs(face_constraints(row, i)); - - // then enter those constraints that are larger than - // 1e-14*abs_sum. everything else probably originated from - // inexact inversion of matrices and similar effects. having - // those constraints in here will only lead to problems - // because it makes sparsity patterns fuller than necessary - // without producing any significant effect - constraints.add_line(dependent_dofs[row]); - for (unsigned int i = 0; i < n_primary_dofs; ++i) - if ((face_constraints(row, i) != 0) && - (std::fabs(face_constraints(row, i)) >= - 1e-14 * abs_sum)) - constraints.add_entry(dependent_dofs[row], - primary_dofs[i], - face_constraints(row, i)); - constraints.set_inhomogeneity(dependent_dofs[row], 0.); - } + if (is_trivial_constraint == true) + continue; + } + // add up the absolute values of all constraints in this line + // to get a measure of their absolute size + number1 abs_sum = 0; + for (unsigned int i = 0; i < n_primary_dofs; ++i) + abs_sum += std::abs(face_constraints(row, i)); + + // then enter those constraints that are larger than + // 1e-14*abs_sum. everything else probably originated from + // inexact inversion of matrices and similar effects. having + // those constraints in here will only lead to problems + // because it makes sparsity patterns fuller than necessary + // without producing any significant effect + constraints.add_line(dependent_dofs[row]); + for (unsigned int i = 0; i < n_primary_dofs; ++i) + if ((face_constraints(row, i) != 0) && + (std::fabs(face_constraints(row, i)) >= 1e-14 * abs_sum)) + constraints.add_entry(dependent_dofs[row], + primary_dofs[i], + face_constraints(row, i)); + constraints.set_inhomogeneity(dependent_dofs[row], 0.); } }