timeError --> relativeChange.

This commit is contained in:
Robert Kloefkorn 2015-11-10 09:53:40 -07:00
parent 005a0c2930
commit d3af817ff2
4 changed files with 18 additions and 26 deletions

View File

@ -49,9 +49,9 @@ namespace Opm {
{} {}
/// return || u^n+1 - u^n || / || u^n+1 || /// return || u^n+1 - u^n || / || u^n+1 ||
double timeError() const double relativeChange() const
{ {
return solver_.model().computeTimeError( previous_, current_ ); return solver_.model().relativeChange( previous_, current_ );
} }
}; };
} }
@ -195,11 +195,11 @@ namespace Opm {
// create object to compute the time error, simply forwards the call to the model // create object to compute the time error, simply forwards the call to the model
detail::SolutionTimeErrorSolverWrapper< Solver, State > detail::SolutionTimeErrorSolverWrapper< Solver, State >
timeError( solver, last_state, state ); relativeChange( solver, last_state, state );
// compute new time step estimate // compute new time step estimate
double dtEstimate = double dtEstimate =
timeStepControl_->computeTimeStepSize( dt, linearIterations, timeError ); timeStepControl_->computeTimeStepSize( dt, linearIterations, relativeChange );
// limit the growth of the timestep size by the growth factor // limit the growth of the timestep size by the growth factor
dtEstimate = std::min( dtEstimate, double(max_growth_ * dt) ); dtEstimate = std::min( dtEstimate, double(max_growth_ * dt) );

View File

@ -55,7 +55,7 @@ namespace Opm
} }
double SimpleIterationCountTimeStepControl:: double SimpleIterationCountTimeStepControl::
computeTimeStepSize( const double dt, const int iterations, const SolutionTimeErrorInterface& /* timeError */ ) const computeTimeStepSize( const double dt, const int iterations, const RelativeChangeInterface& /* relativeChange */ ) const
{ {
double dtEstimate = dt ; double dtEstimate = dt ;
@ -90,7 +90,7 @@ namespace Opm
{} {}
double PIDTimeStepControl:: double PIDTimeStepControl::
computeTimeStepSize( const double dt, const int /* iterations */, const SolutionTimeErrorInterface& errorObj ) const computeTimeStepSize( const double dt, const int /* iterations */, const RelativeChangeInterface& relChange ) const
{ {
// shift errors // shift errors
for( int i=0; i<2; ++i ) { for( int i=0; i<2; ++i ) {
@ -98,7 +98,7 @@ namespace Opm
} }
// store new error // store new error
const double error = errorObj.timeError(); const double error = relChange.relativeChange();
errors_[ 2 ] = error; errors_[ 2 ] = error;
if( error > tol_ ) if( error > tol_ )
@ -141,9 +141,9 @@ namespace Opm
{} {}
double PIDAndIterationCountTimeStepControl:: double PIDAndIterationCountTimeStepControl::
computeTimeStepSize( const double dt, const int iterations, const SolutionTimeErrorInterface& errorObj ) const computeTimeStepSize( const double dt, const int iterations, const RelativeChangeInterface& relChange ) const
{ {
double dtEstimate = BaseType :: computeTimeStepSize( dt, iterations, errorObj ); double dtEstimate = BaseType :: computeTimeStepSize( dt, iterations, relChange );
// further reduce step size if to many iterations were used // further reduce step size if to many iterations were used
if( iterations > target_iterations_ ) if( iterations > target_iterations_ )

View File

@ -26,7 +26,6 @@
#include <boost/any.hpp> #include <boost/any.hpp>
#include <boost/range/iterator_range.hpp> #include <boost/range/iterator_range.hpp>
#include <opm/core/simulator/TimeStepControlInterface.hpp> #include <opm/core/simulator/TimeStepControlInterface.hpp>
#include <opm/core/linalg/ParallelIstlInformation.hpp>
namespace Opm namespace Opm
{ {
@ -49,7 +48,7 @@ namespace Opm
const bool verbose = false); const bool verbose = false);
/// \brief \copydoc TimeStepControlInterface::computeTimeStepSize /// \brief \copydoc TimeStepControlInterface::computeTimeStepSize
double computeTimeStepSize( const double dt, const int iterations, const SolutionTimeErrorInterface& /* timeError */ ) const; double computeTimeStepSize( const double dt, const int iterations, const RelativeChangeInterface& /* relativeChange */ ) const;
protected: protected:
const int target_iterations_; const int target_iterations_;
@ -78,22 +77,18 @@ namespace Opm
/// \brief constructor /// \brief constructor
/// \param tol tolerance for the relative changes of the numerical solution to be accepted /// \param tol tolerance for the relative changes of the numerical solution to be accepted
/// in one time step (default is 1e-3) /// in one time step (default is 1e-3)
/// \paramm pinfo The information about the parallel information. Needed to
/// compute parallel scalarproducts.
/// \param verbose if true get some output (default = false) /// \param verbose if true get some output (default = false)
PIDTimeStepControl( const double tol = 1e-3, PIDTimeStepControl( const double tol = 1e-3,
const bool verbose = false ); const bool verbose = false );
/// \brief \copydoc TimeStepControlInterface::computeTimeStepSize /// \brief \copydoc TimeStepControlInterface::computeTimeStepSize
double computeTimeStepSize( const double dt, const int /* iterations */, const SolutionTimeErrorInterface& timeError ) const; double computeTimeStepSize( const double dt, const int /* iterations */, const RelativeChangeInterface& relativeChange ) const;
protected: protected:
const double tol_; const double tol_;
mutable std::vector< double > errors_; mutable std::vector< double > errors_;
const bool verbose_; const bool verbose_;
private:
// const boost::any parallel_information_;
}; };
/////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -110,16 +105,13 @@ namespace Opm
/// \param target_iterations number of desired iterations per time step /// \param target_iterations number of desired iterations per time step
/// \param tol tolerance for the relative changes of the numerical solution to be accepted /// \param tol tolerance for the relative changes of the numerical solution to be accepted
/// in one time step (default is 1e-3) /// in one time step (default is 1e-3)
// \param maxgrowth max growth factor for new time step in relation of old time step (default = 3.0)
/// \paramm pinfo The information about the parallel information. Needed to
/// compute parallel scalarproducts.
/// \param verbose if true get some output (default = false) /// \param verbose if true get some output (default = false)
PIDAndIterationCountTimeStepControl( const int target_iterations = 20, PIDAndIterationCountTimeStepControl( const int target_iterations = 20,
const double tol = 1e-3, const double tol = 1e-3,
const bool verbose = false); const bool verbose = false);
/// \brief \copydoc TimeStepControlInterface::computeTimeStepSize /// \brief \copydoc TimeStepControlInterface::computeTimeStepSize
double computeTimeStepSize( const double dt, const int iterations, const SolutionTimeErrorInterface& timeError ) const; double computeTimeStepSize( const double dt, const int iterations, const RelativeChangeInterface& relativeChange ) const;
protected: protected:
const int target_iterations_; const int target_iterations_;

View File

@ -26,19 +26,19 @@ namespace Opm
/////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////
/// ///
/// TimeStepControlInterface /// RelativeChangeInterface
/// ///
/////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////
class SolutionTimeErrorInterface class RelativeChangeInterface
{ {
protected: protected:
SolutionTimeErrorInterface() {} RelativeChangeInterface() {}
public: public:
/// \return || u^n+1 - u^n || / || u^n+1 || /// \return || u^n+1 - u^n || / || u^n+1 ||
virtual double timeError() const = 0; virtual double relativeChange() const = 0;
/// virtual destructor (empty) /// virtual destructor (empty)
virtual ~SolutionTimeErrorInterface () {} virtual ~RelativeChangeInterface() {}
}; };
/////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////
@ -57,7 +57,7 @@ namespace Opm
/// \param timeError object to compute || u^n+1 - u^n || / || u^n+1 || /// \param timeError object to compute || u^n+1 - u^n || / || u^n+1 ||
/// ///
/// \return suggested time step size for the next step /// \return suggested time step size for the next step
virtual double computeTimeStepSize( const double dt, const int iterations, const SolutionTimeErrorInterface& timeError ) const = 0; virtual double computeTimeStepSize( const double dt, const int iterations, const RelativeChangeInterface& relativeChange ) const = 0;
/// virtual destructor (empty) /// virtual destructor (empty)
virtual ~TimeStepControlInterface () {} virtual ~TimeStepControlInterface () {}