From 245fa70c71102179fb57c9ab86412d73181c73cb Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Wed, 11 Feb 2015 07:49:21 -0600 Subject: [PATCH] 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. --- source/grid/tria_boundary.cc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/source/grid/tria_boundary.cc b/source/grid/tria_boundary.cc index d7fae946ec..61c0ea8f5e 100644 --- a/source/grid/tria_boundary.cc +++ b/source/grid/tria_boundary.cc @@ -1,6 +1,6 @@ // --------------------------------------------------------------------- // -// Copyright (C) 1998 - 2014 by the deal.II authors +// Copyright (C) 1998 - 2015 by the deal.II authors // // This file is part of the deal.II library. // @@ -604,6 +604,7 @@ normal_vector (const typename Triangulation::face_iterator &face, const double eps = 1e-12; Tensor<1,spacedim> grad_F[facedim]; + unsigned int iteration = 0; while (true) { Point F; @@ -630,6 +631,14 @@ normal_vector (const typename Triangulation::face_iterator &face, const Point 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; -- 2.39.5