mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
SimFullImplOutput: added future to ensure that write history is accounted for.
This commit is contained in:
parent
d5c375f297
commit
5044a07e46
@ -262,22 +262,33 @@ namespace Opm
|
|||||||
const WellState wellState_;
|
const WellState wellState_;
|
||||||
const bool substep_;
|
const bool substep_;
|
||||||
|
|
||||||
|
std::future< bool > asyncWait_;
|
||||||
|
|
||||||
explicit WriterCall( BlackoilOutputWriter& writer,
|
explicit WriterCall( BlackoilOutputWriter& writer,
|
||||||
const SimulatorTimerInterface& timer,
|
const SimulatorTimerInterface& timer,
|
||||||
const SimulatorState& state,
|
const SimulatorState& state,
|
||||||
const WellState& wellState,
|
const WellState& wellState,
|
||||||
bool substep)
|
bool substep,
|
||||||
|
std::future< bool >&& asyncWait)
|
||||||
: writer_( writer ),
|
: writer_( writer ),
|
||||||
timer_( timer.clone() ),
|
timer_( timer.clone() ),
|
||||||
state_( state ),
|
state_( state ),
|
||||||
wellState_( wellState ),
|
wellState_( wellState ),
|
||||||
substep_( substep )
|
substep_( substep ),
|
||||||
|
asyncWait_( std::move( asyncWait ) )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
// callback to writer's serial writeTimeStep method
|
// callback to writer's serial writeTimeStep method
|
||||||
void operator () ()
|
bool operator () ()
|
||||||
{
|
{
|
||||||
|
// wait for previous time step thread to be finished
|
||||||
|
// to ensure that write history is correct.
|
||||||
|
if( asyncWait_.valid() ) {
|
||||||
|
asyncWait_.wait();
|
||||||
|
}
|
||||||
|
|
||||||
writer_.writeTimeStepSerial( *timer_, state_, wellState_, substep_ );
|
writer_.writeTimeStepSerial( *timer_, state_, wellState_, substep_ );
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -294,7 +305,7 @@ namespace Opm
|
|||||||
vtkWriter_->writeTimeStep( timer, localState, localWellState, false );
|
vtkWriter_->writeTimeStep( timer, localState, localWellState, false );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isIORank = true ;
|
bool isIORank = output_ ;
|
||||||
if( parallelOutput_ && parallelOutput_->isParallel() )
|
if( parallelOutput_ && parallelOutput_->isParallel() )
|
||||||
{
|
{
|
||||||
// collect all solutions to I/O rank
|
// collect all solutions to I/O rank
|
||||||
@ -308,9 +319,11 @@ namespace Opm
|
|||||||
if( isIORank )
|
if( isIORank )
|
||||||
{
|
{
|
||||||
if( asyncOutput_ ) {
|
if( asyncOutput_ ) {
|
||||||
|
|
||||||
// spawn write thread that calls eclWriter.writeTimeStepSerial
|
// spawn write thread that calls eclWriter.writeTimeStepSerial
|
||||||
WriterCall call( *this, timer, state, wellState, substep );
|
// timer, state, and wellState are copied, previous async future is moved
|
||||||
std::async( std::move( call ) );
|
WriterCall call( *this, timer, state, wellState, substep, std::move( asyncWait_ ) );
|
||||||
|
asyncWait_ = std::move( std::async( std::move( call ) ) );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// just write the data to disk
|
// just write the data to disk
|
||||||
|
@ -44,6 +44,7 @@
|
|||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
#include <future>
|
||||||
|
|
||||||
#include <boost/filesystem.hpp>
|
#include <boost/filesystem.hpp>
|
||||||
|
|
||||||
@ -262,6 +263,7 @@ namespace Opm
|
|||||||
std::unique_ptr< EclipseWriter > eclWriter_;
|
std::unique_ptr< EclipseWriter > eclWriter_;
|
||||||
EclipseStateConstPtr eclipseState_;
|
EclipseStateConstPtr eclipseState_;
|
||||||
const bool asyncOutput_ ;
|
const bool asyncOutput_ ;
|
||||||
|
std::future< bool > asyncWait_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user