From 532aa90bf900c2181731631642dac1c28b881039 Mon Sep 17 00:00:00 2001
From: Stefan Girke <stefan.girke@wwu.de>
Date: Wed, 17 Feb 2016 18:35:02 +0100
Subject: [PATCH] [bugfix] solvermonitor prints now the correct values of
 newton steps etc.

---
 dune/fem-dg/algorithm/caller/solvermonitor.hh   | 10 +++++-----
 .../algorithm/caller/sub/solvermonitor.hh       | 17 ++++++++++++++---
 2 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/dune/fem-dg/algorithm/caller/solvermonitor.hh b/dune/fem-dg/algorithm/caller/solvermonitor.hh
index ce6f5b95..bc24a8ac 100644
--- a/dune/fem-dg/algorithm/caller/solvermonitor.hh
+++ b/dune/fem-dg/algorithm/caller/solvermonitor.hh
@@ -96,13 +96,13 @@ namespace Fem
         switch( comb )
         {
           case CombinationType::max:
-            res = std::max( res, e->getData( name ) );
+            res = std::max( res, e->getData( name ) ); break;
           case CombinationType::min:
-            res = std::min( res, e->getData( name ) );
+            res = std::min( res, e->getData( name ) ); break;
           case CombinationType::sum:
-            res += e->getData( name );
+            res += e->getData( name ); break;
           case CombinationType::avg:
-            res += e->getData( name );
+            res += e->getData( name ); break;
         }
       }
     };
@@ -149,7 +149,7 @@ namespace Fem
 
     const double getData( const std::string name, CombinationType comb = CombinationType::max ) const
     {
-      double res = (comb == CombinationType::max) ? std::numeric_limits<double>::max() : 0.0;
+      double res = (comb == CombinationType::min) ? std::numeric_limits<double>::max() : 0.0;
       ForLoopType< GetData >::apply( tuple_, res, name, comb );
       return res;
     }
diff --git a/dune/fem-dg/algorithm/caller/sub/solvermonitor.hh b/dune/fem-dg/algorithm/caller/sub/solvermonitor.hh
index f4cc2f6f..8bec2739 100644
--- a/dune/fem-dg/algorithm/caller/sub/solvermonitor.hh
+++ b/dune/fem-dg/algorithm/caller/sub/solvermonitor.hh
@@ -74,7 +74,8 @@ namespace Fem
     typedef SolverMonitorImp               SolverMonitorType;
 
     typedef std::map< std::string, std::tuple< double*, double*, bool > > DataDoubleType;
-    typedef std::map< std::string, std::tuple< long unsigned int*, long unsigned int*, bool > >       DataIntType;
+    typedef std::map< std::string, std::tuple< int*, int*, bool > >       DataIntType;
+    typedef std::map< std::string, std::tuple< long unsigned int*, long unsigned int*, bool > > DataLongIntType;
 
     SubSolverMonitor( const std::string keyPrefix = "" )
       : solverMonitor_()
@@ -87,13 +88,13 @@ namespace Fem
     {
       assert( monitorData );
       //dangerous cast
-      dataInt_.insert( std::make_pair(name, std::make_tuple( reinterpret_cast<long unsigned int*>(monitorData), reinterpret_cast<long unsigned int*>(externalMonitorData), internal ) ) );
+      dataInt_.insert( std::make_pair(name, std::make_tuple( monitorData, externalMonitorData, internal ) ) );
     }
 
     void registerData( const std::string name, long unsigned int* monitorData, long unsigned int* externalMonitorData = nullptr, bool internal = false )
     {
       assert( monitorData );
-      dataInt_.insert( std::make_pair(name, std::make_tuple( monitorData, externalMonitorData, internal ) ) );
+      dataLongInt_.insert( std::make_pair(name, std::make_tuple( monitorData, externalMonitorData, internal ) ) );
     }
 
     void registerData( const std::string name, double* monitorData, double* externalMonitorData = nullptr, bool internal = false )
@@ -109,6 +110,12 @@ namespace Fem
         assert( std::get<0>(dataInt_[ name ]) );
         return (double)*std::get<0>(dataInt_[ name ]);
       }
+      if( dataLongInt_.find(name) != dataLongInt_.end() )
+      {
+        assert( std::get<0>(dataLongInt_[ name ]) );
+        return (double)*std::get<0>(dataLongInt_[ name ]);
+      }
+
       if( dataDouble_.find(name) != dataDouble_.end() )
       {
         assert( std::get<0>(dataDouble_[ name ]) );
@@ -134,6 +141,9 @@ namespace Fem
       for (auto it = std::begin(dataInt_); it!=std::end(dataInt_); ++it)
         if( std::get<1>(it->second) )
           *std::get<0>(it->second) = *std::get<1>(it->second);
+      for (auto it = std::begin(dataLongInt_); it!=std::end(dataLongInt_); ++it)
+        if( std::get<1>(it->second) )
+          *std::get<0>(it->second) = *std::get<1>(it->second);
       solverMonitor_.setTimeStepInfo( tp );
     }
 
@@ -151,6 +161,7 @@ namespace Fem
     SolverMonitorType solverMonitor_;
     DataDoubleType            dataDouble_;
     DataIntType               dataInt_;
+    DataLongIntType           dataLongInt_;
   };
 
 
-- 
GitLab