]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Merge pull request #515 from bangerth/terminate-loop-and-error-message
authorTimo Heister <timo.heister@gmail.com>
Wed, 11 Feb 2015 17:15:41 +0000 (12:15 -0500)
committerTimo Heister <timo.heister@gmail.com>
Wed, 11 Feb 2015 17:15:41 +0000 (12:15 -0500)
Terminate a loop in a timely manner.

In StraightBoundary::normal_vector(), we currently have a loop that could run
forever. This is not useful. Rather, terminate it after at most 10 iterations
and if it fails output some guidance to what the reason may be.

1  2 
source/grid/tria_boundary.cc

index e296a5f2152f7286435c66b8a8d2a0592a0fe5de,61c0ea8f5e395c3b682735fee0184050ff3159d8..e32916554fcee4103bb6c7941e43a2f0095de74a
@@@ -628,8 -629,16 +629,16 @@@ normal_vector (const typename Triangula
            for (unsigned int k=0; k<spacedim; ++k)
              H[i][j] += grad_F[i][k] * grad_F[j][k];
  
 -      const Point<facedim> delta_xi = -invert(H) * J;
 +      const Tensor<1,facedim> delta_xi = -invert(H) * J;
        xi += delta_xi;
+       ++iteration;
+       Assert (iteration<10,
+               ExcMessage("The Newton iteration to find the reference point "
+                          "did not converge in 10 iterations. Do you have a "
+                          "deformed cell? (See the glossary for a definition "
+                          "of what a deformed cell is. You may want to output "
+                          "the vertices of your cell."));
  
        if (delta_xi.norm() < eps)
          break;

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.