mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
140 lines
6.5 KiB
C++
140 lines
6.5 KiB
C++
/*
|
|
Copyright 2014 IRIS AS
|
|
Copyright 2015 Dr. Blatt - HPC-Simulation-Software & Services
|
|
Copyright 2015 Statoil AS
|
|
|
|
This file is part of the Open Porous Media project (OPM).
|
|
|
|
OPM is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
OPM is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
#ifndef OPM_SUBSTEPPING_HEADER_INCLUDED
|
|
#define OPM_SUBSTEPPING_HEADER_INCLUDED
|
|
|
|
#include <iostream>
|
|
#include <utility>
|
|
|
|
#include <opm/common/utility/parameters/ParameterGroup.hpp>
|
|
#include <opm/common/ErrorMacros.hpp>
|
|
#include <opm/simulators/timestepping/SimulatorTimer.hpp>
|
|
#include <opm/simulators/timestepping/TimeStepControlInterface.hpp>
|
|
|
|
namespace Opm {
|
|
|
|
|
|
// AdaptiveTimeStepping
|
|
//---------------------
|
|
|
|
class AdaptiveTimeStepping
|
|
{
|
|
public:
|
|
//! \brief contructor taking parameter object
|
|
//! \param param The parameter object
|
|
//! \param pinfo The information about the data distribution
|
|
//! and communication for a parallel run.
|
|
AdaptiveTimeStepping( const ParameterGroup& param,
|
|
const bool terminal_output = true );
|
|
|
|
//! \brief contructor taking parameter object
|
|
//! \param tuning Pointer to ecl TUNING keyword
|
|
//! \param time_step current report step
|
|
//! \param param The parameter object
|
|
//! \param pinfo The information about the data distribution
|
|
//! and communication for a parallel run.
|
|
AdaptiveTimeStepping( const Tuning& tuning,
|
|
size_t time_step,
|
|
const ParameterGroup& param,
|
|
const bool terminal_output = true );
|
|
|
|
/** \brief step method that acts like the solver::step method
|
|
in a sub cycle of time steps
|
|
|
|
\param timer simulator timer providing time and timestep
|
|
\param solver solver object that must implement a method step( dt, state, well_state )
|
|
\param state current state of the solution variables
|
|
\param well_state additional well state object
|
|
\param event event status for possible tuning
|
|
*/
|
|
template <class Solver, class State, class WellState>
|
|
SimulatorReport step( const SimulatorTimer& timer,
|
|
Solver& solver, State& state, WellState& well_state,
|
|
const bool event);
|
|
|
|
/** \brief step method that acts like the solver::step method
|
|
in a sub cycle of time steps
|
|
|
|
\param timer simulator timer providing time and timestep
|
|
\param fipnum Fluid-in-place numbering array
|
|
\param solver solver object that must implement a method step( dt, state, well_state )
|
|
\param state current state of the solution variables
|
|
\param well_state additional well state object
|
|
\param event event status for possible tuning
|
|
\param outputWriter writer object to write sub steps
|
|
*/
|
|
template <class Solver, class State, class WellState, class Output>
|
|
SimulatorReport step( const SimulatorTimer& timer,
|
|
Solver& solver, State& state, WellState& well_state,
|
|
const bool event,
|
|
Output& outputWriter,
|
|
const std::vector<int>* fipnum = nullptr);
|
|
|
|
/** \brief Returns the simulator report for the failed substeps of the last
|
|
* report step.
|
|
*/
|
|
const SimulatorReport& failureReport() const { return failureReport_; };
|
|
|
|
double suggestedNextStep() const { return suggested_next_timestep_; }
|
|
|
|
void setSuggestedNextStep(const double x) { suggested_next_timestep_ = x; }
|
|
|
|
void updateTUNING(const Tuning& tuning, size_t time_step) {
|
|
restart_factor_ = tuning.getTSFCNV(time_step);
|
|
growth_factor_ = tuning.getTFDIFF(time_step);
|
|
max_growth_ = tuning.getTSFMAX(time_step);
|
|
max_time_step_ = tuning.getTSMAXZ(time_step);
|
|
suggested_next_timestep_ = tuning.getTSINIT(time_step);
|
|
timestep_after_event_ = tuning.getTMAXWC(time_step);
|
|
}
|
|
|
|
|
|
protected:
|
|
template <class Solver, class State, class WellState, class Output>
|
|
SimulatorReport stepImpl( const SimulatorTimer& timer,
|
|
Solver& solver, State& state, WellState& well_state,
|
|
const bool event,
|
|
Output* outputWriter,
|
|
const std::vector<int>* fipnum);
|
|
|
|
void init(const ParameterGroup& param);
|
|
|
|
typedef std::unique_ptr< TimeStepControlInterface > TimeStepControlType;
|
|
|
|
SimulatorReport failureReport_; //!< statistics for the failed substeps of the last timestep
|
|
TimeStepControlType timeStepControl_; //!< time step control object
|
|
double restart_factor_; //!< factor to multiply time step with when solver fails to converge
|
|
double growth_factor_; //!< factor to multiply time step when solver recovered from failed convergence
|
|
double max_growth_; //!< factor that limits the maximum growth of a time step
|
|
double max_time_step_; //!< maximal allowed time step size
|
|
const int solver_restart_max_; //!< how many restart of solver are allowed
|
|
const bool solver_verbose_; //!< solver verbosity
|
|
const bool timestep_verbose_; //!< timestep verbosity
|
|
double suggested_next_timestep_; //!< suggested size of next timestep
|
|
bool full_timestep_initially_; //!< beginning with the size of the time step from data file
|
|
double timestep_after_event_; //!< suggested size of timestep after an event
|
|
bool use_newton_iteration_; //!< use newton iteration count for adaptive time step control
|
|
};
|
|
}
|
|
|
|
#include <opm/simulators/timestepping/AdaptiveTimeStepping_impl.hpp>
|
|
#endif
|