mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
use unit::convert::to instead of hard coded 86400 factor.
This commit is contained in:
parent
0e133f2cca
commit
246acea765
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user