Two small adjustments that came up when running in debug mode.

This commit is contained in:
Robert Kloefkorn
2014-10-10 13:55:28 +02:00
parent 2fcb3c6638
commit 44f90f974e
2 changed files with 14 additions and 11 deletions

View File

@@ -55,13 +55,16 @@ namespace Opm {
// sub step time loop
while( ! timer.done() )
{
// get current delta t
const double dt = timer.currentStepLength() ;
// initialize time step control in case current state is needed later
timeStepControl_->initialize( state );
int linearIterations = -1;
try {
// (linearIterations < 0 means on convergence in solver)
linearIterations = solver.step(timer.currentStepLength(), state, well_state);
linearIterations = solver.step( dt, state, well_state);
if( solver_verbose_ ) {
// report number of linear iterations
@@ -81,7 +84,7 @@ namespace Opm {
// compute new time step estimate
const double dtEstimate =
timeStepControl_->computeTimeStepSize( timer.currentStepLength(), linearIterations, state );
timeStepControl_->computeTimeStepSize( dt, linearIterations, state );
if( timestep_verbose_ )
std::cout << "Suggested time step size = " << unit::convert::to(dtEstimate, unit::day) << " (days)" << std::endl;
@@ -99,7 +102,7 @@ namespace Opm {
OPM_THROW(Opm::NumericalProblem,"Solver failed to converge after " << restarts << " restarts.");
}
const double newTimeStep = restart_factor_ * timer.currentStepLength();
const double newTimeStep = restart_factor_ * dt;
// we need to revise this
timer.provideTimeStepEstimate( newTimeStep );
if( solver_verbose_ )

View File

@@ -44,24 +44,24 @@ namespace Opm
double PIDTimeStepControl::
computeTimeStepSize( const double dt, const int /* iterations */, const SimulatorState& state ) const
{
const std::size_t size = p0_.size();
assert( state.pressure().size() == size );
assert( state.saturation().size() == size );
assert( sat0_.size() == size );
const std::size_t pSize = p0_.size();
assert( state.pressure().size() == pSize );
const std::size_t satSize = sat0_.size();
assert( state.saturation().size() == satSize );
// compute u^n - u^n+1
for( std::size_t i=0; i<size; ++i )
{
for( std::size_t i=0; i<pSize; ++i )
p0_[ i ] -= state.pressure()[ i ];
for( std::size_t i=0; i<satSize; ++i )
sat0_[ i ] -= state.saturation()[ i ];
}
// compute || u^n - u^n+1 ||
const double stateOld = euclidianNormSquared( p0_.begin(), p0_.end() ) +
euclidianNormSquared( sat0_.begin(), sat0_.end() );
// compute || u^n+1 ||
const double stateNew = euclidianNormSquared( state.pressure().begin(), state.pressure().end() ) +
const double stateNew = euclidianNormSquared( state.pressure().begin(), state.pressure().end() ) +
euclidianNormSquared( state.saturation().begin(), state.saturation().end() );
// shift errors