use unit::convert::to instead of hard coded 86400 factor.

This commit is contained in:
Robert Kloefkorn 2014-10-07 09:48:57 +02:00
parent 0e133f2cca
commit 246acea765
3 changed files with 21 additions and 17 deletions

View File

@ -24,6 +24,7 @@
#include <algorithm>
#include <numeric>
#include <opm/core/utility/Units.hpp>
#include <opm/core/simulator/AdaptiveSimulatorTimer.hpp>
namespace Opm
@ -131,15 +132,27 @@ namespace Opm
}
/// \brief report start and end time as well as used steps so far
void AdaptiveSimulatorTimer::report(std::ostream& os) const
void AdaptiveSimulatorTimer::
report(std::ostream& os) const
{
const double factor = 86400.0;
os << "Sub steps started at time = " << start_time_/factor << " (days)" << std::endl;
os << "Sub steps started at time = " << unit::convert::to( start_time_, unit::day ) << " (days)" << std::endl;
for( size_t i=0; i<steps_.size(); ++i )
{
os << " step[ " << i << " ] = " << steps_[ i ]/factor << " (days)" << std::endl;
os << " step[ " << i << " ] = " << unit::convert::to( steps_[ i ], unit::day ) << " (days)" << std::endl;
}
std::cout << "sub steps end time = " << simulationTimeElapsed()/factor << " (days)" << std::endl;
std::cout << "sub steps end time = " << unit::convert::to( simulationTimeElapsed(), unit::day ) << " (days)" << std::endl;
}
double AdaptiveSimulatorTimer::
computeInitialTimeStep( const double lastDt ) const
{
const double maxTimeStep = total_time_ - start_time_;
const double fraction = (lastDt / maxTimeStep);
// when lastDt and maxTimeStep are close together, choose the max time step
if( fraction > 0.95 ) return maxTimeStep;
// otherwise choose lastDt
return std::min( lastDt, maxTimeStep );
}
} // namespace Opm

View File

@ -94,16 +94,7 @@ namespace Opm
double suggestedMax_;
double suggestedAverage_;
double computeInitialTimeStep( const double lastDt ) const
{
const double maxTimeStep = total_time_ - start_time_;
const double fraction = (lastDt / maxTimeStep);
// when lastDt and maxTimeStep are close together, choose the max time step
if( fraction > 0.95 ) return maxTimeStep;
// otherwise choose lastDt
return std::min( lastDt, maxTimeStep );
}
double computeInitialTimeStep( const double lastDt ) const;
};
} // namespace Opm

View File

@ -83,7 +83,7 @@ namespace Opm {
const double dtEstimate =
timeStepControl_->computeTimeStepSize( timer.currentStepLength(), linearIterations, state );
if( timestep_verbose_ )
std::cout << "Suggested time step size = " << dtEstimate/86400.0 << " (days)" << std::endl;
std::cout << "Suggested time step size = " << unit::convert::to(dtEstimate, unit::day) << " (days)" << std::endl;
// set new time step length
timer.provideTimeStepEstimate( dtEstimate );
@ -119,7 +119,7 @@ namespace Opm {
if( timestep_verbose_ )
{
timer.report( std::cout );
std::cout << "Last suggested step size = " << last_timestep_/86400.0 << " (days)" << std::endl;
std::cout << "Last suggested step size = " << unit::convert::to( last_timestep_, unit::day ) << " (days)" << std::endl;
}
if( ! std::isfinite( last_timestep_ ) ) // check for NaN