From 4f7ebe3e72b8967e070c88681b920c07033e3944 Mon Sep 17 00:00:00 2001
From: Oliver Sander <oliver.sander@tu-dresden.de>
Date: Sat, 27 Feb 2021 17:15:41 +0100
Subject: [PATCH] TrustRegionSolver: Make detection of trust-region underflows
 work

There already was code that printed a warning when the trust-region
radius dropped below the required solver tolerance.  (If that happens,
the solver terminates, because the small trust-region forces the
correction to be smaller than the required tolerance.  However,
the code didn't warn the user about this, and such cases almost
looked like successful runs.)

Unfortunately, the warning code didn't work, because the standard
solver termination criterion stopped the TR iteration before
reaching the check for the trust-region size.
---
 dune/elasticity/common/trustregionsolver.cc | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/dune/elasticity/common/trustregionsolver.cc b/dune/elasticity/common/trustregionsolver.cc
index 279dcf1..92e45ba 100644
--- a/dune/elasticity/common/trustregionsolver.cc
+++ b/dune/elasticity/common/trustregionsolver.cc
@@ -551,16 +551,12 @@ void TrustRegionSolver<BasisType,VectorType>::solve()
 
             if (correctionInfinityNorm < this->tolerance_) {
                 if (this->verbosity_ == NumProc::FULL and rank==0)
-                    std::cout << "CORRECTION IS SMALL ENOUGH" << std::endl;
-
-                if (this->verbosity_ != NumProc::QUIET and rank==0)
-                    std::cout << i+1 << " trust-region steps were taken." << std::endl;
-                break;
-            }
-
-            if (trustRegion.radius() < this->tolerance_) {
-              if (this->verbosity_ == NumProc::FULL and rank==0)
-                    std::cout << "TRUST REGION RADIUS IS TOO SMALL, SMALLER THAN TOLERANCE, STOPPING NOW" << std::endl;
+                {
+                    if (correctionInfinityNorm < trustRegion.radius())
+                        std::cout << "CORRECTION IS SMALL ENOUGH" << std::endl;
+                    else
+                        std::cout << "TRUST-REGION UNDERFLOW!" << std::endl;
+                }
 
                 if (this->verbosity_ != NumProc::QUIET and rank==0)
                     std::cout << i+1 << " trust-region steps were taken." << std::endl;
-- 
GitLab