Skip to content
Snippets Groups Projects
Commit 532aa90b authored by Stefan Girke's avatar Stefan Girke
Browse files

[bugfix] solvermonitor prints now the correct values of newton steps etc.

parent 6de27a1a
No related branches found
No related tags found
No related merge requests found
...@@ -96,13 +96,13 @@ namespace Fem ...@@ -96,13 +96,13 @@ namespace Fem
switch( comb ) switch( comb )
{ {
case CombinationType::max: case CombinationType::max:
res = std::max( res, e->getData( name ) ); res = std::max( res, e->getData( name ) ); break;
case CombinationType::min: case CombinationType::min:
res = std::min( res, e->getData( name ) ); res = std::min( res, e->getData( name ) ); break;
case CombinationType::sum: case CombinationType::sum:
res += e->getData( name ); res += e->getData( name ); break;
case CombinationType::avg: case CombinationType::avg:
res += e->getData( name ); res += e->getData( name ); break;
} }
} }
}; };
...@@ -149,7 +149,7 @@ namespace Fem ...@@ -149,7 +149,7 @@ namespace Fem
const double getData( const std::string name, CombinationType comb = CombinationType::max ) const 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 ); ForLoopType< GetData >::apply( tuple_, res, name, comb );
return res; return res;
} }
......
...@@ -74,7 +74,8 @@ namespace Fem ...@@ -74,7 +74,8 @@ namespace Fem
typedef SolverMonitorImp SolverMonitorType; typedef SolverMonitorImp SolverMonitorType;
typedef std::map< std::string, std::tuple< double*, double*, bool > > DataDoubleType; 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 = "" ) SubSolverMonitor( const std::string keyPrefix = "" )
: solverMonitor_() : solverMonitor_()
...@@ -87,13 +88,13 @@ namespace Fem ...@@ -87,13 +88,13 @@ namespace Fem
{ {
assert( monitorData ); assert( monitorData );
//dangerous cast //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 ) void registerData( const std::string name, long unsigned int* monitorData, long unsigned int* externalMonitorData = nullptr, bool internal = false )
{ {
assert( monitorData ); 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 ) void registerData( const std::string name, double* monitorData, double* externalMonitorData = nullptr, bool internal = false )
...@@ -109,6 +110,12 @@ namespace Fem ...@@ -109,6 +110,12 @@ namespace Fem
assert( std::get<0>(dataInt_[ name ]) ); assert( std::get<0>(dataInt_[ name ]) );
return (double)*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() ) if( dataDouble_.find(name) != dataDouble_.end() )
{ {
assert( std::get<0>(dataDouble_[ name ]) ); assert( std::get<0>(dataDouble_[ name ]) );
...@@ -134,6 +141,9 @@ namespace Fem ...@@ -134,6 +141,9 @@ namespace Fem
for (auto it = std::begin(dataInt_); it!=std::end(dataInt_); ++it) for (auto it = std::begin(dataInt_); it!=std::end(dataInt_); ++it)
if( std::get<1>(it->second) ) if( std::get<1>(it->second) )
*std::get<0>(it->second) = *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 ); solverMonitor_.setTimeStepInfo( tp );
} }
...@@ -151,6 +161,7 @@ namespace Fem ...@@ -151,6 +161,7 @@ namespace Fem
SolverMonitorType solverMonitor_; SolverMonitorType solverMonitor_;
DataDoubleType dataDouble_; DataDoubleType dataDouble_;
DataIntType dataInt_; DataIntType dataInt_;
DataLongIntType dataLongInt_;
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment