]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Simplify control flow slightly. 11526/head
authorWolfgang Bangerth <bangerth@colostate.edu>
Fri, 15 Jan 2021 04:32:21 +0000 (21:32 -0700)
committerWolfgang Bangerth <bangerth@colostate.edu>
Fri, 15 Jan 2021 04:32:21 +0000 (21:32 -0700)
source/dofs/dof_tools_constraints.cc

index b8cbe7a92d5cef79d88c80cd8281461760b34626..7809d2d525566937a1de957cc7bce26bf390aa01 100644 (file)
@@ -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.);
             }
       }
 

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.