mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
- adjust OutputWriter to SimulatorTimerInterface
- remove WriterTimer from EclipseWriter and use SimulatorTimerInterface - adjust to the above in AdaptiveTimeStepping.
This commit is contained in:
parent
be69c4c10e
commit
25af9e0033
@ -16,7 +16,6 @@
|
|||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef OPM_ADAPTIVESIMULATORTIMER_HEADER_INCLUDED
|
#ifndef OPM_ADAPTIVESIMULATORTIMER_HEADER_INCLUDED
|
||||||
#define OPM_ADAPTIVESIMULATORTIMER_HEADER_INCLUDED
|
#define OPM_ADAPTIVESIMULATORTIMER_HEADER_INCLUDED
|
||||||
|
|
||||||
|
@ -1,3 +1,21 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2014 IRIS 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
|
#ifndef OPM_SUBSTEPPING_HEADER_INCLUDED
|
||||||
#define OPM_SUBSTEPPING_HEADER_INCLUDED
|
#define OPM_SUBSTEPPING_HEADER_INCLUDED
|
||||||
|
|
||||||
@ -21,19 +39,6 @@ namespace Opm {
|
|||||||
//! \brief contructor taking parameter object
|
//! \brief contructor taking parameter object
|
||||||
AdaptiveTimeStepping( const parameter::ParameterGroup& param );
|
AdaptiveTimeStepping( const parameter::ParameterGroup& param );
|
||||||
|
|
||||||
/** \brief step method that acts like the solver::step method
|
|
||||||
in a sub cycle of time steps
|
|
||||||
|
|
||||||
\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 time current simulation time
|
|
||||||
\param timestep current time step length that is to be sub cycled
|
|
||||||
*/
|
|
||||||
template <class Solver, class State, class WellState>
|
|
||||||
void step( Solver& solver, State& state, WellState& well_state,
|
|
||||||
const double time, const double timestep );
|
|
||||||
|
|
||||||
/** \brief step method that acts like the solver::step method
|
/** \brief step method that acts like the solver::step method
|
||||||
in a sub cycle of time steps
|
in a sub cycle of time steps
|
||||||
|
|
||||||
@ -62,9 +67,9 @@ namespace Opm {
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
template <class Solver, class State, class WellState>
|
template <class Solver, class State, class WellState>
|
||||||
void stepImpl( Solver& solver, State& state, WellState& well_state,
|
void stepImpl( const SimulatorTimer& timer,
|
||||||
const double time, const double timestep,
|
Solver& solver, State& state, WellState& well_state,
|
||||||
const SimulatorTimer* timer, OutputWriter* outputWriter);
|
OutputWriter* outputWriter);
|
||||||
|
|
||||||
typedef std::unique_ptr< TimeStepControlInterface > TimeStepControlType;
|
typedef std::unique_ptr< TimeStepControlInterface > TimeStepControlType;
|
||||||
|
|
||||||
|
@ -1,3 +1,21 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2014 IRIS 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_ADAPTIVETIMESTEPPING_IMPL_HEADER_INCLUDED
|
#ifndef OPM_ADAPTIVETIMESTEPPING_IMPL_HEADER_INCLUDED
|
||||||
#define OPM_ADAPTIVETIMESTEPPING_IMPL_HEADER_INCLUDED
|
#define OPM_ADAPTIVETIMESTEPPING_IMPL_HEADER_INCLUDED
|
||||||
|
|
||||||
@ -48,10 +66,7 @@ namespace Opm {
|
|||||||
void AdaptiveTimeStepping::
|
void AdaptiveTimeStepping::
|
||||||
step( const SimulatorTimer& simulatorTimer, Solver& solver, State& state, WellState& well_state )
|
step( const SimulatorTimer& simulatorTimer, Solver& solver, State& state, WellState& well_state )
|
||||||
{
|
{
|
||||||
const double time = simulatorTimer.simulationTimeElapsed();
|
stepImpl( simulatorTimer, solver, state, well_state );
|
||||||
const double timestep = simulatorTimer.currentStepLength();
|
|
||||||
|
|
||||||
step( solver, state, well_state, time, timestep );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Solver, class State, class WellState>
|
template <class Solver, class State, class WellState>
|
||||||
@ -59,37 +74,25 @@ namespace Opm {
|
|||||||
step( const SimulatorTimer& simulatorTimer, Solver& solver, State& state, WellState& well_state,
|
step( const SimulatorTimer& simulatorTimer, Solver& solver, State& state, WellState& well_state,
|
||||||
OutputWriter& outputWriter )
|
OutputWriter& outputWriter )
|
||||||
{
|
{
|
||||||
const double time = simulatorTimer.simulationTimeElapsed();
|
stepImpl( simulatorTimer, solver, state, well_state, &outputWriter );
|
||||||
const double timestep = simulatorTimer.currentStepLength();
|
|
||||||
|
|
||||||
stepImpl( solver, state, well_state, time, timestep, &simulatorTimer, &outputWriter );
|
|
||||||
}
|
|
||||||
|
|
||||||
// implementation of the step method
|
|
||||||
template <class Solver, class State, class WellState>
|
|
||||||
void AdaptiveTimeStepping::
|
|
||||||
step( Solver& solver, State& state, WellState& well_state,
|
|
||||||
const double time, const double timestep )
|
|
||||||
{
|
|
||||||
stepImpl( solver, state, well_state, time, timestep,
|
|
||||||
(SimulatorTimer *) 0, (OutputWriter *) 0 );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// implementation of the step method
|
// implementation of the step method
|
||||||
template <class Solver, class State, class WState>
|
template <class Solver, class State, class WState>
|
||||||
void AdaptiveTimeStepping::
|
void AdaptiveTimeStepping::
|
||||||
stepImpl( Solver& solver, State& state, WState& well_state,
|
stepImpl( const SimulatorTimer& simulatorTimer,
|
||||||
const double time, const double timestep,
|
Solver& solver, State& state, WState& well_state,
|
||||||
const SimulatorTimer* simulatorTimer,
|
|
||||||
OutputWriter* outputWriter )
|
OutputWriter* outputWriter )
|
||||||
{
|
{
|
||||||
|
const double timestep = simulatorTimer.currentStepLength();
|
||||||
|
|
||||||
// init last time step as a fraction of the given time step
|
// init last time step as a fraction of the given time step
|
||||||
if( last_timestep_ < 0 ) {
|
if( last_timestep_ < 0 ) {
|
||||||
last_timestep_ = initial_fraction_ * timestep ;
|
last_timestep_ = initial_fraction_ * timestep;
|
||||||
}
|
}
|
||||||
|
|
||||||
// create adaptive step timer with previously used sub step size
|
// create adaptive step timer with previously used sub step size
|
||||||
AdaptiveSimulatorTimer substepTimer( time, time+timestep, last_timestep_ );
|
AdaptiveSimulatorTimer substepTimer( simulatorTimer, last_timestep_ );
|
||||||
|
|
||||||
// copy states in case solver has to be restarted (to be revised)
|
// copy states in case solver has to be restarted (to be revised)
|
||||||
State last_state( state );
|
State last_state( state );
|
||||||
@ -145,8 +148,10 @@ namespace Opm {
|
|||||||
|
|
||||||
if( timestep_verbose_ )
|
if( timestep_verbose_ )
|
||||||
{
|
{
|
||||||
std::cout << "Substep[ " << substepTimer.currentStepNum() << " ] " << unit::convert::to(substepTimer.simulationTimeElapsed(),unit::day) << std::endl;
|
std::cout << std::endl
|
||||||
std::cout << "Suggested time step size = " << unit::convert::to(dtEstimate, unit::day) << " (days)" << std::endl;
|
<<"Substep( " << substepTimer.currentStepNum()
|
||||||
|
<< " ): Current time (days) " << unit::convert::to(substepTimer.simulationTimeElapsed(),unit::day) << std::endl
|
||||||
|
<< " Current stepsize est (days) " << unit::convert::to(dtEstimate, unit::day) << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// set new time step length
|
// set new time step length
|
||||||
@ -158,8 +163,7 @@ namespace Opm {
|
|||||||
|
|
||||||
// write data if outputWriter was provided
|
// write data if outputWriter was provided
|
||||||
if( outputWriter ) {
|
if( outputWriter ) {
|
||||||
assert( simulatorTimer );
|
outputWriter->writeTimeStep( substepTimer, state, well_state );
|
||||||
outputWriter->writeTimeStep( *simulatorTimer, substepTimer, state, well_state );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else // in case of no convergence (linearIterations < 0)
|
else // in case of no convergence (linearIterations < 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user