mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Replace old timestep completed event with new scheme
This commit is contained in:
parent
2a26964c7d
commit
c1eadadb72
@ -36,6 +36,7 @@
|
|||||||
#include <opm/core/utility/StopWatch.hpp>
|
#include <opm/core/utility/StopWatch.hpp>
|
||||||
#include <opm/core/io/vtk/writeVtkData.hpp>
|
#include <opm/core/io/vtk/writeVtkData.hpp>
|
||||||
#include <opm/core/utility/miscUtilities.hpp>
|
#include <opm/core/utility/miscUtilities.hpp>
|
||||||
|
#include <opm/core/utility/Event.hpp>
|
||||||
|
|
||||||
#include <opm/core/wells/WellsManager.hpp>
|
#include <opm/core/wells/WellsManager.hpp>
|
||||||
|
|
||||||
@ -48,9 +49,6 @@
|
|||||||
#include <opm/core/transport/implicit/TransportSolverTwophaseImplicit.hpp>
|
#include <opm/core/transport/implicit/TransportSolverTwophaseImplicit.hpp>
|
||||||
#include <boost/filesystem.hpp>
|
#include <boost/filesystem.hpp>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <boost/lexical_cast.hpp>
|
|
||||||
#include <boost/function.hpp>
|
|
||||||
#include <boost/signal.hpp>
|
|
||||||
|
|
||||||
#include <numeric>
|
#include <numeric>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
@ -103,7 +101,7 @@ namespace Opm
|
|||||||
std::vector<int> allcells_;
|
std::vector<int> allcells_;
|
||||||
|
|
||||||
// list of hooks that are notified when a timestep completes
|
// 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
|
// connect the hook to the signal in the implementation class
|
||||||
void SimulatorIncompTwophase::connect_timestep_impl (boost::function0 <void> hook) {
|
Event& SimulatorIncompTwophase::timestep_completed () {
|
||||||
pimpl_->timestep_completed.connect (hook);
|
return pimpl_->timestep_completed_;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void reportVolumes(std::ostream &os, double satvol[2], double tot_porevol_init,
|
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
|
// notify all clients that we are done with the timestep
|
||||||
callback_timer.start ();
|
callback_timer.start ();
|
||||||
timestep_completed ();
|
timestep_completed_.signal ();
|
||||||
callback_timer.stop ();
|
callback_timer.stop ();
|
||||||
time_in_callbacks += callback_timer.secsSinceStart ();
|
time_in_callbacks += callback_timer.secsSinceStart ();
|
||||||
}
|
}
|
||||||
|
@ -21,8 +21,6 @@
|
|||||||
#define OPM_SIMULATORINCOMPTWOPHASE_HEADER_INCLUDED
|
#define OPM_SIMULATORINCOMPTWOPHASE_HEADER_INCLUDED
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <boost/function.hpp>
|
|
||||||
#include <boost/bind.hpp>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
struct UnstructuredGrid;
|
struct UnstructuredGrid;
|
||||||
@ -40,6 +38,7 @@ namespace Opm
|
|||||||
class TwophaseState;
|
class TwophaseState;
|
||||||
class WellState;
|
class WellState;
|
||||||
struct SimulatorReport;
|
struct SimulatorReport;
|
||||||
|
class Event;
|
||||||
|
|
||||||
/// Class collecting all necessary components for a two-phase simulation.
|
/// Class collecting all necessary components for a two-phase simulation.
|
||||||
class SimulatorIncompTwophase
|
class SimulatorIncompTwophase
|
||||||
@ -90,19 +89,16 @@ namespace Opm
|
|||||||
TwophaseState& state,
|
TwophaseState& state,
|
||||||
WellState& well_state);
|
WellState& well_state);
|
||||||
|
|
||||||
/// Register a callback for notifications about completed timestep.
|
/// Event that is signaled every time the simulator has completed a
|
||||||
/// The specified method of the object is called when the simulator
|
/// a timestep.
|
||||||
/// has completed a timestep and the state objects are (possibly)
|
///
|
||||||
/// changed.
|
/// 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
|
/// If you want to know the current timestep, the callback must
|
||||||
/// also monitor the timer object which was passed to run().
|
/// 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
|
/// \example
|
||||||
/// \code{.cpp}
|
/// \code{.cpp}
|
||||||
/// struct Foo {
|
/// struct Foo {
|
||||||
@ -111,23 +107,17 @@ namespace Opm
|
|||||||
///
|
///
|
||||||
/// SimulatorIncompTwophase sim (...);
|
/// SimulatorIncompTwophase sim (...);
|
||||||
/// Foo f;
|
/// Foo f;
|
||||||
/// sim.connect_timestep <Foo, &Foo::bar> (f);
|
/// sim.timestep_completed ().add <Foo, &Foo::bar> (f);
|
||||||
/// sim.run (...);
|
/// sim.run (...);
|
||||||
/// \endcode
|
/// \endcode
|
||||||
template <typename T, void (T::*callback)()>
|
Event& timestep_completed ();
|
||||||
void connect_timestep (T& t);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct Impl;
|
struct Impl;
|
||||||
// Using shared_ptr instead of unique_ptr since unique_ptr requires complete type for Impl.
|
// Using shared_ptr instead of unique_ptr since unique_ptr requires complete type for Impl.
|
||||||
std::shared_ptr<Impl> pimpl_;
|
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
|
} // namespace Opm
|
||||||
|
|
||||||
#include "SimulatorIncompTwophase_impl.hpp"
|
|
||||||
|
|
||||||
#endif // OPM_SIMULATORINCOMPTWOPHASE_HEADER_INCLUDED
|
#endif // OPM_SIMULATORINCOMPTWOPHASE_HEADER_INCLUDED
|
||||||
|
Loading…
Reference in New Issue
Block a user