Replace old timestep completed event with new scheme
This commit is contained in:
@@ -295,7 +295,6 @@ list (APPEND PUBLIC_HEADER_FILES
|
||||
opm/core/simulator/BlackoilState.hpp
|
||||
opm/core/simulator/SimulatorCompressibleTwophase.hpp
|
||||
opm/core/simulator/SimulatorIncompTwophase.hpp
|
||||
opm/core/simulator/SimulatorIncompTwophase_impl.hpp
|
||||
opm/core/simulator/SimulatorReport.hpp
|
||||
opm/core/simulator/SimulatorTimer.hpp
|
||||
opm/core/simulator/TwophaseState.hpp
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
#include <opm/core/utility/StopWatch.hpp>
|
||||
#include <opm/core/io/vtk/writeVtkData.hpp>
|
||||
#include <opm/core/utility/miscUtilities.hpp>
|
||||
#include <opm/core/utility/Event.hpp>
|
||||
|
||||
#include <opm/core/wells/WellsManager.hpp>
|
||||
|
||||
@@ -48,9 +49,6 @@
|
||||
#include <opm/core/transport/implicit/TransportSolverTwophaseImplicit.hpp>
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <memory>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/function.hpp>
|
||||
#include <boost/signal.hpp>
|
||||
|
||||
#include <numeric>
|
||||
#include <fstream>
|
||||
@@ -103,7 +101,7 @@ namespace Opm
|
||||
std::vector<int> allcells_;
|
||||
|
||||
// list of hooks that are notified when a timestep completes
|
||||
boost::signal0 <void> timestep_completed;
|
||||
EventSource timestep_completed_;
|
||||
};
|
||||
|
||||
|
||||
@@ -134,8 +132,8 @@ namespace Opm
|
||||
}
|
||||
|
||||
// connect the hook to the signal in the implementation class
|
||||
void SimulatorIncompTwophase::connect_timestep_impl (boost::function0 <void> hook) {
|
||||
pimpl_->timestep_completed.connect (hook);
|
||||
Event& SimulatorIncompTwophase::timestep_completed () {
|
||||
return pimpl_->timestep_completed_;
|
||||
}
|
||||
|
||||
static void reportVolumes(std::ostream &os, double satvol[2], double tot_porevol_init,
|
||||
@@ -600,7 +598,7 @@ namespace Opm
|
||||
|
||||
// notify all clients that we are done with the timestep
|
||||
callback_timer.start ();
|
||||
timestep_completed ();
|
||||
timestep_completed_.signal ();
|
||||
callback_timer.stop ();
|
||||
time_in_callbacks += callback_timer.secsSinceStart ();
|
||||
}
|
||||
|
||||
@@ -21,8 +21,6 @@
|
||||
#define OPM_SIMULATORINCOMPTWOPHASE_HEADER_INCLUDED
|
||||
|
||||
#include <memory>
|
||||
#include <boost/function.hpp>
|
||||
#include <boost/bind.hpp>
|
||||
#include <vector>
|
||||
|
||||
struct UnstructuredGrid;
|
||||
@@ -40,6 +38,7 @@ namespace Opm
|
||||
class TwophaseState;
|
||||
class WellState;
|
||||
struct SimulatorReport;
|
||||
class Event;
|
||||
|
||||
/// Class collecting all necessary components for a two-phase simulation.
|
||||
class SimulatorIncompTwophase
|
||||
@@ -90,19 +89,16 @@ namespace Opm
|
||||
TwophaseState& state,
|
||||
WellState& well_state);
|
||||
|
||||
/// Register a callback for notifications about completed timestep.
|
||||
/// The specified method of the object is called when the simulator
|
||||
/// has completed a timestep and the state objects are (possibly)
|
||||
/// changed.
|
||||
/// Event that is signaled every time the simulator has completed a
|
||||
/// a timestep.
|
||||
///
|
||||
/// Register a callback with this event to do processing at the end
|
||||
/// of every timestep, for instance to do reporting.
|
||||
///
|
||||
/// \note
|
||||
/// If you want to know the current timestep, the callback must
|
||||
/// also monitor the timer object which was passed to run().
|
||||
/// \tparam T Type of the callback object.
|
||||
/// \tparam callback Address of a member function of T which will
|
||||
/// be invoked when a timestep completes.
|
||||
/// \param[in] t Object which will receive notifications. The
|
||||
/// lifetime of the object must span over the
|
||||
/// duration of the simulation, and it is your
|
||||
/// responsibility to ensure that.
|
||||
///
|
||||
/// \example
|
||||
/// \code{.cpp}
|
||||
/// struct Foo {
|
||||
@@ -111,23 +107,17 @@ namespace Opm
|
||||
///
|
||||
/// SimulatorIncompTwophase sim (...);
|
||||
/// Foo f;
|
||||
/// sim.connect_timestep <Foo, &Foo::bar> (f);
|
||||
/// sim.timestep_completed ().add <Foo, &Foo::bar> (f);
|
||||
/// sim.run (...);
|
||||
/// \endcode
|
||||
template <typename T, void (T::*callback)()>
|
||||
void connect_timestep (T& t);
|
||||
Event& timestep_completed ();
|
||||
|
||||
private:
|
||||
struct Impl;
|
||||
// Using shared_ptr instead of unique_ptr since unique_ptr requires complete type for Impl.
|
||||
std::shared_ptr<Impl> pimpl_;
|
||||
|
||||
// implementation which is not templated, and can be in library
|
||||
void connect_timestep_impl (boost::function0<void> hook);
|
||||
};
|
||||
|
||||
} // namespace Opm
|
||||
|
||||
#include "SimulatorIncompTwophase_impl.hpp"
|
||||
|
||||
#endif // OPM_SIMULATORINCOMPTWOPHASE_HEADER_INCLUDED
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
#ifndef OPM_SIMULATORINCOMPTWOPHASE_HEADER_INCLUDED
|
||||
#error Do not include SimulatorIncompTwophase directly!
|
||||
#endif
|
||||
|
||||
namespace Opm {
|
||||
|
||||
template <typename T, void (T::*callback)()>
|
||||
inline void SimulatorIncompTwophase::connect_timestep (T& t) {
|
||||
connect_timestep_impl (boost::function0<void> (boost::bind (callback, t)));
|
||||
}
|
||||
|
||||
} /* namespace Opm */
|
||||
Reference in New Issue
Block a user