Read sim start time from EclipseState

Reading the start time from EclipseState means it's no longer required
as a parameter to every method, and that the current time can be
calculated as start time + time elapsed.
This commit is contained in:
Jørgen Kvalsvik
2016-05-20 11:33:37 +02:00
parent 91d5cad61e
commit e2a5c01a8b
6 changed files with 14 additions and 23 deletions

View File

@@ -55,7 +55,7 @@ public:
*
* If NNC is given, writes TRANNNC keyword.
*/
void writeInit( time_t current_posix_time, const NNC& nnc = NNC() );
void writeInit( const NNC& nnc = NNC() );
/*!
* \brief Write a reservoir state and summary information to disk.
@@ -69,7 +69,6 @@ public:
* meaningful after the first time step has been completed.
*/
void writeTimeStep( int report_step,
time_t current_posix_time,
double seconds_elapsed,
data::Solution,
data::Wells,

View File

@@ -526,6 +526,7 @@ class EclipseWriter::Impl {
std::string baseName;
out::Summary summary;
RFT rft;
time_t sim_start_time;
int numCells;
std::array< int, 3 > cartesianSize;
const int* compressed_to_cartesian;
@@ -546,6 +547,7 @@ EclipseWriter::Impl::Impl( std::shared_ptr< const EclipseState > eclipseState,
es->getIOConfig()->getFMTOUT(),
compressed_to_cart,
numCells, es->getInputGrid()->getCartesianSize() )
, sim_start_time( es->getSchedule()->posixStartTime() )
, numCells( numCells )
, compressed_to_cartesian( compressed_to_cart )
, gridToEclipseIdx( numCells, int(-1) )
@@ -554,7 +556,7 @@ EclipseWriter::Impl::Impl( std::shared_ptr< const EclipseState > eclipseState,
, ert_phase_mask( ertPhaseMask( eclipseState->getTableManager() ) )
{}
void EclipseWriter::writeInit( time_t current_posix_time, const NNC& nnc ) {
void EclipseWriter::writeInit( const NNC& nnc ) {
if( !this->impl->output_enabled )
return;
@@ -566,7 +568,7 @@ void EclipseWriter::writeInit( time_t current_posix_time, const NNC& nnc ) {
fortio.writeHeader( this->impl->numCells,
this->impl->compressed_to_cartesian,
current_posix_time,
this->impl->sim_start_time,
es,
this->impl->ert_phase_mask );
@@ -617,7 +619,6 @@ void EclipseWriter::writeInit( time_t current_posix_time, const NNC& nnc ) {
// implementation of the writeTimeStep method
void EclipseWriter::writeTimeStep(int report_step,
time_t current_posix_time,
double secs_elapsed,
data::Solution cells,
data::Wells wells,
@@ -629,6 +630,7 @@ void EclipseWriter::writeTimeStep(int report_step,
using dc = data::Solution::key;
time_t current_posix_time = this->impl->sim_start_time + secs_elapsed;
const auto* conversion_table = this->impl->conversion_table;
const auto& gridToEclipseIdx = this->impl->gridToEclipseIdx;
const auto& es = *this->impl->es;

View File

@@ -266,13 +266,12 @@ BOOST_AUTO_TEST_CASE(EclipseWriterIntegration)
auto start_time = util_make_datetime( 0, 0, 0, 10, 10, 2008 );
auto first_step = util_make_datetime( 0, 0, 0, 10, 11, 2008 );
eclWriter.writeInit( start_time );
eclWriter.writeInit();
data::Wells wells;
for( int i = 0; i < 5; ++i ) {
eclWriter.writeTimeStep( i,
first_step,
first_step - start_time,
createBlackoilState( i, 3 * 3 * 3 ),
wells, false);

View File

@@ -122,15 +122,10 @@ BOOST_AUTO_TEST_CASE(test_RFT) {
* eclipseState->getInputGrid()->getNZ();
EclipseWriter eclipseWriter( eclipseState, numCells, nullptr );
time_t btime = util_make_datetime( 0, 0, 0, 1, 12, 1979 );
time_t start_time = util_make_datetime( 0, 0, 0, 10, 10, 2008 );
eclipseWriter.writeInit( start_time );
time_t times[] = { btime,
util_make_datetime( 0, 0, 0, 10, 10, 2008 ),
util_make_datetime( 0, 0, 0, 10, 11, 2008 ) };
time_t start_time = eclipseState->getSchedule()->posixStartTime();
/* step time read from deck and hard-coded here */
time_t step_time = util_make_datetime( 0, 0, 0, 10, 10, 2008 );
eclipseWriter.writeInit();
Opm::data::Wells wells {
{ { "OP_1", { {}, 1.0, 1.1, {} } },
@@ -143,8 +138,7 @@ BOOST_AUTO_TEST_CASE(test_RFT) {
};
eclipseWriter.writeTimeStep( 2,
times[ 1 ],
times[ 1 ] - btime,
step_time - start_time,
createBlackoilState( 2, numCells ),
wells, false);
}

View File

@@ -232,13 +232,12 @@ first_sim(test_work_area_type * test_area) {
EclipseWriter eclWriter( eclipseState, num_cells, nullptr );
auto start_time = util_make_datetime( 0, 0, 0, 1, 11, 1979 );
auto first_step = util_make_datetime( 0, 0, 0, 10, 10, 2008 );
eclWriter.writeInit( start_time );
eclWriter.writeInit();
auto sol = mkSolution( num_cells );
auto wells = mkWells();
eclWriter.writeTimeStep( 1,
first_step,
first_step - start_time,
sol, wells, false);

View File

@@ -141,8 +141,7 @@ BOOST_AUTO_TEST_CASE(EclipseWriteRestartWellInfo) {
const auto num_cells = eclipseState->getInputGrid()->getCartesianSize();
EclipseWriter eclipseWriter( eclipseState, num_cells, nullptr );
time_t start_time = util_make_datetime( 0, 0, 0, 1, 11, 1979 );
eclipseWriter.writeInit( start_time );
eclipseWriter.writeInit();
int countTimeStep = eclipseState->getSchedule()->getTimeMap()->numTimesteps();
@@ -160,7 +159,6 @@ BOOST_AUTO_TEST_CASE(EclipseWriteRestartWellInfo) {
for(int timestep = 0; timestep <= countTimeStep; ++timestep){
eclipseWriter.writeTimeStep( timestep,
start_time + timestep,
timestep,
solution,
wells, false);