From cbf61996d7c051db637620ad78f121b55b3e9b91 Mon Sep 17 00:00:00 2001 From: Tor Harald Sandve Date: Thu, 18 Jan 2018 11:11:18 +0100 Subject: [PATCH 1/6] Remove unused stuff --- src/opm/output/eclipse/Summary.cpp | 9 --------- tests/test_Summary.cpp | 6 +++--- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/src/opm/output/eclipse/Summary.cpp b/src/opm/output/eclipse/Summary.cpp index 04be2d38e..12ee0179a 100644 --- a/src/opm/output/eclipse/Summary.cpp +++ b/src/opm/output/eclipse/Summary.cpp @@ -727,15 +727,6 @@ static const std::unordered_map< std::string, UnitSystem::measure> region_units {"RWIP" , UnitSystem::measure::volume } }; -static const std::unordered_map< std::string, UnitSystem::measure> block_units = { - {"BPR" , UnitSystem::measure::pressure}, - {"BPRESSUR" , UnitSystem::measure::pressure}, - {"BSWAT" , UnitSystem::measure::identity}, - {"BWSAT" , UnitSystem::measure::identity}, - {"BSGAS" , UnitSystem::measure::identity}, - {"BGSAS" , UnitSystem::measure::identity}, -}; - inline std::vector< const Well* > find_wells( const Schedule& schedule, const smspec_node_type* node, size_t timestep ) { diff --git a/tests/test_Summary.cpp b/tests/test_Summary.cpp index 1228c22a4..a7816ea8a 100644 --- a/tests/test_Summary.cpp +++ b/tests/test_Summary.cpp @@ -404,9 +404,9 @@ BOOST_AUTO_TEST_CASE(group_keywords) { setup cfg( "test_Summary_group" ); out::Summary writer( cfg.es, cfg.config, cfg.grid, cfg.schedule, cfg.name ); - writer.add_timestep( 0, 0 * day, cfg.es, cfg.schedule, cfg.wells , {}); - writer.add_timestep( 1, 1 * day, cfg.es, cfg.schedule, cfg.wells , {}); - writer.add_timestep( 2, 2 * day, cfg.es, cfg.schedule, cfg.wells , {}); + writer.add_timestep( 0, 0 * day, cfg.es, cfg.schedule, cfg.wells , cfg.solution , {}); + writer.add_timestep( 1, 1 * day, cfg.es, cfg.schedule, cfg.wells , cfg.solution , {}); + writer.add_timestep( 2, 2 * day, cfg.es, cfg.schedule, cfg.wells , cfg.solution , {}); writer.write(); auto res = readsum( cfg.name ); From 5822c362f5adbc1bd6e6f1fb6569d9f4766423a8 Mon Sep 17 00:00:00 2001 From: Tor Harald Sandve Date: Mon, 29 Jan 2018 08:09:51 +0100 Subject: [PATCH 2/6] Communicate well data --- opm/output/data/Wells.hpp | 120 +++++++++++++++++++++++++++++++++++++- tests/test_Wells.cpp | 1 + 2 files changed, 120 insertions(+), 1 deletion(-) diff --git a/opm/output/data/Wells.hpp b/opm/output/data/Wells.hpp index f5822d8b0..12fd2e850 100644 --- a/opm/output/data/Wells.hpp +++ b/opm/output/data/Wells.hpp @@ -77,6 +77,11 @@ namespace Opm { /// true if any option is set; false otherwise inline bool any() const noexcept; + template + void write(MessageBufferType& buffer) const; + template + void read(MessageBufferType& buffer); + private: double& get_ref( opt ); const double& get_ref( opt ) const; @@ -104,6 +109,11 @@ namespace Opm { Rates rates; double pressure; double reservoir_rate; + + template + void write(MessageBufferType& buffer) const; + template + void read(MessageBufferType& buffer); }; struct Well { @@ -115,6 +125,10 @@ namespace Opm { std::vector< Completion > completions; inline bool flowing() const noexcept; + template + void write(MessageBufferType& buffer) const; + template + void read(MessageBufferType& buffer); }; @@ -145,9 +159,35 @@ namespace Opm { return completion->rates.get( m, 0.0 ); } + template + void write(MessageBufferType& buffer) const { + unsigned int size = this->size(); + buffer.write(size); + for (const auto& witr : *this) { + const std::string& name = witr.first; + buffer.write(name); + const Well& well = witr.second; + well.write(buffer); + } + } + + template + void read(MessageBufferType& buffer) { + unsigned int size; + buffer.read(size); + for (size_t i = 0; i < size; ++i) { + std::string name; + buffer.read(name); + Well well; + well.read(buffer); + this->emplace(name, well); + } + } + }; - using Wells = WellRates; + using Wells = WellRates; + /* IMPLEMENTATIONS */ @@ -228,7 +268,85 @@ namespace Opm { return this->rates.any(); } + template + void Rates::write(MessageBufferType& buffer) const { + buffer.write(this->mask); + buffer.write(this->wat); + buffer.write(this->oil); + buffer.write(this->gas); + buffer.write(this->polymer); + buffer.write(this->solvent); + buffer.write(this->energy); + buffer.write(this->dissolved_gas); + buffer.write(this->vaporized_oil); + buffer.write(this->reservoir_water); + buffer.write(this->reservoir_oil); + buffer.write(this->reservoir_gas); } + + template + void Completion::write(MessageBufferType& buffer) const { + buffer.write(this->index); + this->rates.write(buffer); + buffer.write(this->pressure); + buffer.write(this->reservoir_rate); + } + + template + void Well::write(MessageBufferType& buffer) const { + this->rates.write(buffer); + buffer.write(this->bhp); + buffer.write(this->thp); + buffer.write(this->temperature); + buffer.write(this->control); + unsigned int size = this->completions.size(); + buffer.write(size); + for (const Completion& comp : this->completions) + comp.write(buffer); + } + + template + void Rates::read(MessageBufferType& buffer) { + buffer.read(this->mask); + buffer.read(this->wat); + buffer.read(this->oil); + buffer.read(this->gas); + buffer.read(this->polymer); + buffer.read(this->solvent); + buffer.read(this->energy); + buffer.read(this->dissolved_gas); + buffer.read(this->vaporized_oil); + buffer.read(this->reservoir_water); + buffer.read(this->reservoir_oil); + buffer.read(this->reservoir_gas); + } + + template + void Completion::read(MessageBufferType& buffer) { + buffer.read(this->index); + this->rates.read(buffer); + buffer.read(this->pressure); + buffer.read(this->reservoir_rate); + } + + template + void Well::read(MessageBufferType& buffer) { + this->rates.read(buffer); + buffer.read(this->bhp); + buffer.read(this->thp); + buffer.read(this->temperature); + buffer.read(this->control); + unsigned int size = 0.0; //this->completions.size(); + buffer.read(size); + this->completions.resize(size); + for (size_t i = 0; i < size; ++i) + { + auto& comp = this->completions[ i ]; + comp.read(buffer); + } + } + +} } #endif //OPM_OUTPUT_WELLS_HPP diff --git a/tests/test_Wells.cpp b/tests/test_Wells.cpp index 4121b328a..295a7e23f 100644 --- a/tests/test_Wells.cpp +++ b/tests/test_Wells.cpp @@ -127,3 +127,4 @@ BOOST_AUTO_TEST_CASE(get_completions) { BOOST_CHECK_EQUAL( 0.0, wellRates.get("OP_2" , 10000 , data::Rates::opt::wat) ); BOOST_CHECK_EQUAL( 26.41 , wellRates.get( "OP_2" , 188 , data::Rates::opt::wat)); } + From 3f8519803248dc8103e564bc4ca28bc31d3c1f8d Mon Sep 17 00:00:00 2001 From: Tor Harald Sandve Date: Tue, 6 Feb 2018 08:31:15 +0100 Subject: [PATCH 3/6] Fix merge conflict --- src/opm/output/eclipse/Summary.cpp | 9 +++++++++ tests/test_Summary.cpp | 6 +++--- tests/test_Wells.cpp | 1 - 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/opm/output/eclipse/Summary.cpp b/src/opm/output/eclipse/Summary.cpp index 12ee0179a..04be2d38e 100644 --- a/src/opm/output/eclipse/Summary.cpp +++ b/src/opm/output/eclipse/Summary.cpp @@ -727,6 +727,15 @@ static const std::unordered_map< std::string, UnitSystem::measure> region_units {"RWIP" , UnitSystem::measure::volume } }; +static const std::unordered_map< std::string, UnitSystem::measure> block_units = { + {"BPR" , UnitSystem::measure::pressure}, + {"BPRESSUR" , UnitSystem::measure::pressure}, + {"BSWAT" , UnitSystem::measure::identity}, + {"BWSAT" , UnitSystem::measure::identity}, + {"BSGAS" , UnitSystem::measure::identity}, + {"BGSAS" , UnitSystem::measure::identity}, +}; + inline std::vector< const Well* > find_wells( const Schedule& schedule, const smspec_node_type* node, size_t timestep ) { diff --git a/tests/test_Summary.cpp b/tests/test_Summary.cpp index a7816ea8a..1228c22a4 100644 --- a/tests/test_Summary.cpp +++ b/tests/test_Summary.cpp @@ -404,9 +404,9 @@ BOOST_AUTO_TEST_CASE(group_keywords) { setup cfg( "test_Summary_group" ); out::Summary writer( cfg.es, cfg.config, cfg.grid, cfg.schedule, cfg.name ); - writer.add_timestep( 0, 0 * day, cfg.es, cfg.schedule, cfg.wells , cfg.solution , {}); - writer.add_timestep( 1, 1 * day, cfg.es, cfg.schedule, cfg.wells , cfg.solution , {}); - writer.add_timestep( 2, 2 * day, cfg.es, cfg.schedule, cfg.wells , cfg.solution , {}); + writer.add_timestep( 0, 0 * day, cfg.es, cfg.schedule, cfg.wells , {}); + writer.add_timestep( 1, 1 * day, cfg.es, cfg.schedule, cfg.wells , {}); + writer.add_timestep( 2, 2 * day, cfg.es, cfg.schedule, cfg.wells , {}); writer.write(); auto res = readsum( cfg.name ); diff --git a/tests/test_Wells.cpp b/tests/test_Wells.cpp index 295a7e23f..4121b328a 100644 --- a/tests/test_Wells.cpp +++ b/tests/test_Wells.cpp @@ -127,4 +127,3 @@ BOOST_AUTO_TEST_CASE(get_completions) { BOOST_CHECK_EQUAL( 0.0, wellRates.get("OP_2" , 10000 , data::Rates::opt::wat) ); BOOST_CHECK_EQUAL( 26.41 , wellRates.get( "OP_2" , 188 , data::Rates::opt::wat)); } - From 55ed844438628178015bc108696dff5ae6b56614 Mon Sep 17 00:00:00 2001 From: Tor Harald Sandve Date: Wed, 7 Feb 2018 14:32:01 +0100 Subject: [PATCH 4/6] Add cell data in perforation cells to data::well::completion With this no cell data is needed in opm-output --- opm/output/data/Wells.hpp | 9 +++++ src/opm/output/eclipse/EclipseIO.cpp | 31 ++++++++++----- tests/test_RFT.cpp | 56 ++++++++++++++++++++-------- 3 files changed, 70 insertions(+), 26 deletions(-) diff --git a/opm/output/data/Wells.hpp b/opm/output/data/Wells.hpp index 12fd2e850..ae7f80ce4 100644 --- a/opm/output/data/Wells.hpp +++ b/opm/output/data/Wells.hpp @@ -109,6 +109,9 @@ namespace Opm { Rates rates; double pressure; double reservoir_rate; + double cell_pressure; + double cell_saturation_water; + double cell_saturation_gas; template void write(MessageBufferType& buffer) const; @@ -290,6 +293,9 @@ namespace Opm { this->rates.write(buffer); buffer.write(this->pressure); buffer.write(this->reservoir_rate); + buffer.write(this->cell_pressure); + buffer.write(this->cell_saturation_water); + buffer.write(this->cell_saturation_gas); } template @@ -327,6 +333,9 @@ namespace Opm { this->rates.read(buffer); buffer.read(this->pressure); buffer.read(this->reservoir_rate); + buffer.read(this->cell_pressure); + buffer.read(this->cell_saturation_water); + buffer.read(this->cell_saturation_gas); } template diff --git a/src/opm/output/eclipse/EclipseIO.cpp b/src/opm/output/eclipse/EclipseIO.cpp index 386a4f297..0311b352a 100644 --- a/src/opm/output/eclipse/EclipseIO.cpp +++ b/src/opm/output/eclipse/EclipseIO.cpp @@ -108,7 +108,7 @@ class RFT { time_t current_time, double days, const UnitSystem& units, - data::Solution cells); + data::Wells wellData); private: std::string filename; bool fmt_file; @@ -129,11 +129,9 @@ void RFT::writeTimeStep( std::vector< const Well* > wells, time_t current_time, double days, const UnitSystem& units, - data::Solution cells) { + data::Wells wellDatas) { using rft = ERT::ert_unique_ptr< ecl_rft_node_type, ecl_rft_node_free >; - const std::vector& pressure = cells.data("PRESSURE"); - const std::vector& swat = cells.data("SWAT"); - const std::vector& sgas = cells.has("SGAS") ? cells.data("SGAS") : std::vector( pressure.size() , 0 ); + fortio_type * fortio; int first_report_step = report_step; @@ -145,7 +143,6 @@ void RFT::writeTimeStep( std::vector< const Well* > wells, else fortio = fortio_open_writer( filename.c_str() , fmt_file , ECL_ENDIAN_FLIP ); - cells.convertFromSI( units ); for ( const auto& well : wells ) { if( !( well->getRFTActive( report_step ) || well->getPLTActive( report_step ) ) ) @@ -154,7 +151,13 @@ void RFT::writeTimeStep( std::vector< const Well* > wells, auto* rft_node = ecl_rft_node_alloc_new( well->name().c_str(), "RFT", current_time, days ); + const auto& wellData = wellDatas.at(well->name()); + + if (wellData.completions.empty()) + continue; + for( const auto& completion : well->getCompletions( report_step ) ) { + const size_t i = size_t( completion.getI() ); const size_t j = size_t( completion.getJ() ); const size_t k = size_t( completion.getK() ); @@ -163,9 +166,17 @@ void RFT::writeTimeStep( std::vector< const Well* > wells, const auto index = grid.activeIndex( i, j, k ); const double depth = grid.getCellDepth( i, j, k ); - const double press = pressure[ index ]; - const double satwat = swat[ index ]; - const double satgas = sgas[ index ]; + + const auto& completionData = std::find_if( wellData.completions.begin(), + wellData.completions.end(), + [=]( const data::Completion& c ) { + return c.index == index; + } ); + + + const double press = units.from_si(UnitSystem::measure::pressure,completionData->cell_pressure); + const double satwat = units.from_si(UnitSystem::measure::identity, completionData->cell_saturation_water); + const double satgas = units.from_si(UnitSystem::measure::identity, completionData->cell_saturation_gas); auto* cell = ecl_rft_cell_alloc_RFT( i, j, k, depth, press, satwat, satgas ); @@ -478,7 +489,7 @@ void EclipseIO::writeTimeStep(int report_step, secs_elapsed + this->impl->schedule.posixStartTime(), units.from_si( UnitSystem::measure::time, secs_elapsed ), units, - cells ); + wells ); } } diff --git a/tests/test_RFT.cpp b/tests/test_RFT.cpp index fe4a0a625..16b1e609d 100755 --- a/tests/test_RFT.cpp +++ b/tests/test_RFT.cpp @@ -66,21 +66,22 @@ void verifyRFTFile(const std::string& rft_filename) { const ecl_rft_cell_type * ecl_rft_cell2 = ecl_rft_node_lookup_ijk(ecl_rft_node, 8, 8, 1); const ecl_rft_cell_type * ecl_rft_cell3 = ecl_rft_node_lookup_ijk(ecl_rft_node, 8, 8, 2); - BOOST_CHECK_CLOSE(ecl_rft_cell_get_pressure(ecl_rft_cell1), 210088*0.00001, 0.00001); - BOOST_CHECK_CLOSE(ecl_rft_cell_get_pressure(ecl_rft_cell2), 210188*0.00001, 0.00001); - BOOST_CHECK_CLOSE(ecl_rft_cell_get_pressure(ecl_rft_cell3), 210288*0.00001, 0.00001); + double tol = 0.00001; + BOOST_CHECK_CLOSE(ecl_rft_cell_get_pressure(ecl_rft_cell1), 0.00000, tol); + BOOST_CHECK_CLOSE(ecl_rft_cell_get_pressure(ecl_rft_cell2), 0.00001, tol); + BOOST_CHECK_CLOSE(ecl_rft_cell_get_pressure(ecl_rft_cell3), 0.00002, tol); - BOOST_CHECK_EQUAL(ecl_rft_cell_get_sgas(ecl_rft_cell1), 0.0); - BOOST_CHECK_EQUAL(ecl_rft_cell_get_sgas(ecl_rft_cell2), 0.0); - BOOST_CHECK_EQUAL(ecl_rft_cell_get_sgas(ecl_rft_cell3), 0.0); + BOOST_CHECK_CLOSE(ecl_rft_cell_get_sgas(ecl_rft_cell1), 0.0, tol); + BOOST_CHECK_CLOSE(ecl_rft_cell_get_sgas(ecl_rft_cell2), 0.2, tol); + BOOST_CHECK_CLOSE(ecl_rft_cell_get_sgas(ecl_rft_cell3), 0.4, tol); - BOOST_CHECK_EQUAL(ecl_rft_cell_get_swat(ecl_rft_cell1), 0.0); - BOOST_CHECK_EQUAL(ecl_rft_cell_get_swat(ecl_rft_cell2), 0.0); - BOOST_CHECK_EQUAL(ecl_rft_cell_get_swat(ecl_rft_cell3), 0.0); + BOOST_CHECK_CLOSE(ecl_rft_cell_get_swat(ecl_rft_cell1), 0.0, tol); + BOOST_CHECK_CLOSE(ecl_rft_cell_get_swat(ecl_rft_cell2), 0.1, tol); + BOOST_CHECK_CLOSE(ecl_rft_cell_get_swat(ecl_rft_cell3), 0.2, tol); - BOOST_CHECK_EQUAL(ecl_rft_cell_get_soil(ecl_rft_cell1), 1.0); - BOOST_CHECK_EQUAL(ecl_rft_cell_get_soil(ecl_rft_cell2), 1.0); - BOOST_CHECK_EQUAL(ecl_rft_cell_get_soil(ecl_rft_cell3), 1.0); + BOOST_CHECK_CLOSE(ecl_rft_cell_get_soil(ecl_rft_cell1), 1.0, tol); + BOOST_CHECK_CLOSE(ecl_rft_cell_get_soil(ecl_rft_cell2), 0.7, tol); + BOOST_CHECK_CLOSE(ecl_rft_cell_get_soil(ecl_rft_cell3), 0.4, tol); BOOST_CHECK_EQUAL(ecl_rft_cell_get_depth(ecl_rft_cell1), (0.250 + (0.250/2))); BOOST_CHECK_EQUAL(ecl_rft_cell_get_depth(ecl_rft_cell2), (2*0.250 + (0.250/2))); @@ -136,9 +137,21 @@ BOOST_AUTO_TEST_CASE(test_RFT) { r2.set( data::Rates::opt::oil, 4.22 ); r2.set( data::Rates::opt::gas, 4.23 ); + std::vector well1_comps(9); + for (size_t i = 0; i < 9; ++i) { + Opm::data::Completion well_comp { grid.activeIndex(8,8,i) ,r1, 0.0 , 0.0, (double)i, 0.1*i,0.2*i}; + well1_comps[i] = well_comp; + } + std::vector well2_comps(6); + for (size_t i = 0; i < 6; ++i) { + Opm::data::Completion well_comp { grid.activeIndex(3,3,i+3) ,r2, 0.0 , 0.0, (double)i, i*0.1,i*0.2}; + well2_comps[i] = well_comp; + } + Opm::data::Wells wells; - wells["OP_1"] = { r1, 1.0, 1.1, 3.1, 1, {} }; - wells["OP_2"] = { r2, 1.0, 1.1, 3.2, 1, {} }; + wells["OP_1"] = { r1, 1.0, 1.1, 3.1, 1, well1_comps }; + wells["OP_2"] = { r2, 1.0, 1.1, 3.2, 1, well2_comps }; + eclipseWriter.writeTimeStep( 2, false, @@ -214,9 +227,20 @@ BOOST_AUTO_TEST_CASE(test_RFT2) { r2.set( data::Rates::opt::oil, 4.22 ); r2.set( data::Rates::opt::gas, 4.23 ); + std::vector well1_comps(9); + for (size_t i = 0; i < 9; ++i) { + Opm::data::Completion well_comp { grid.activeIndex(8,8,i) ,r1, 0.0 , 0.0, (double)i, 0.1*i,0.2*i}; + well1_comps[i] = well_comp; + } + std::vector well2_comps(6); + for (size_t i = 0; i < 6; ++i) { + Opm::data::Completion well_comp { grid.activeIndex(3,3,i+3) ,r2, 0.0 , 0.0, (double)i, i*0.1,i*0.2}; + well2_comps[i] = well_comp; + } + Opm::data::Wells wells; - wells["OP_1"] = { r1, 1.0, 1.1, 3.1, 1, {} }; - wells["OP_2"] = { r2, 1.0, 1.1, 3.2, 1, {} }; + wells["OP_1"] = { r1, 1.0, 1.1, 3.1, 1, well1_comps }; + wells["OP_2"] = { r2, 1.0, 1.1, 3.2, 1, well2_comps }; eclipseWriter.writeTimeStep( step, false, From 206241c9aea703fd36adb2767035d95994d53df8 Mon Sep 17 00:00:00 2001 From: Tor Harald Sandve Date: Thu, 8 Feb 2018 10:40:13 +0100 Subject: [PATCH 5/6] Store global index instead of active index in well completions Fix bug in output of completion related stuff when run on mulitiple cores. --- opm/output/data/Wells.hpp | 6 +++--- src/opm/output/eclipse/EclipseIO.cpp | 2 +- src/opm/output/eclipse/RestartIO.cpp | 4 ++-- src/opm/output/eclipse/Summary.cpp | 5 ++--- tests/test_RFT.cpp | 8 ++++---- tests/test_Summary.cpp | 4 ++-- 6 files changed, 14 insertions(+), 15 deletions(-) diff --git a/opm/output/data/Wells.hpp b/opm/output/data/Wells.hpp index ae7f80ce4..d6dfe883f 100644 --- a/opm/output/data/Wells.hpp +++ b/opm/output/data/Wells.hpp @@ -102,10 +102,10 @@ namespace Opm { }; struct Completion { - using active_index = size_t; + using global_index = size_t; static const constexpr int restart_size = 2; - active_index index; + global_index index; Rates rates; double pressure; double reservoir_rate; @@ -146,7 +146,7 @@ namespace Opm { } - double get(const std::string& well_name , Completion::active_index completion_grid_index, Rates::opt m) const { + double get(const std::string& well_name , Completion::global_index completion_grid_index, Rates::opt m) const { const auto& witr = this->find( well_name ); if( witr == this->end() ) return 0.0; diff --git a/src/opm/output/eclipse/EclipseIO.cpp b/src/opm/output/eclipse/EclipseIO.cpp index 0311b352a..525bc2a84 100644 --- a/src/opm/output/eclipse/EclipseIO.cpp +++ b/src/opm/output/eclipse/EclipseIO.cpp @@ -164,7 +164,7 @@ void RFT::writeTimeStep( std::vector< const Well* > wells, if( !grid.cellActive( i, j, k ) ) continue; - const auto index = grid.activeIndex( i, j, k ); + const auto index = grid.getGlobalIndex( i, j, k ); const double depth = grid.getCellDepth( i, j, k ); const auto& completionData = std::find_if( wellData.completions.begin(), diff --git a/src/opm/output/eclipse/RestartIO.cpp b/src/opm/output/eclipse/RestartIO.cpp index e5c0d4337..280e46193 100644 --- a/src/opm/output/eclipse/RestartIO.cpp +++ b/src/opm/output/eclipse/RestartIO.cpp @@ -364,13 +364,13 @@ std::vector< double > serialize_OPM_XWEL( const data::Wells& wells, std::vector< double > xwel; for( const auto* sched_well : sched_wells ) { - if( wells.count( sched_well->name() ) == 0 ) { + if( wells.count( sched_well->name() ) == 0 || sched_well->getStatus(report_step) == Opm::WellCommon::SHUT) { const auto elems = (sched_well->getCompletions( report_step ).size() * (phases.size() + data::Completion::restart_size)) + 2 /* bhp, temperature */ + phases.size(); - // write zeros if no well data is provided + // write zeros if no well data is provided or it is shut xwel.insert( xwel.end(), elems, 0.0 ); continue; } diff --git a/src/opm/output/eclipse/Summary.cpp b/src/opm/output/eclipse/Summary.cpp index 04be2d38e..aa751827d 100644 --- a/src/opm/output/eclipse/Summary.cpp +++ b/src/opm/output/eclipse/Summary.cpp @@ -225,8 +225,7 @@ inline quantity crate( const fn_args& args ) { // NUMS array in the eclispe SMSPEC file; the values in this array // are offset 1 - whereas we need to use this index here to look // up a completion with offset 0. - const auto global_index = args.num - 1; - const auto active_index = args.grid.activeIndex( global_index ); + const size_t global_index = args.num - 1; if( args.schedule_wells.empty() ) return zero; const auto& name = args.schedule_wells.front()->name(); @@ -236,7 +235,7 @@ inline quantity crate( const fn_args& args ) { const auto& completion = std::find_if( well.completions.begin(), well.completions.end(), [=]( const data::Completion& c ) { - return c.index == active_index; + return c.index == global_index; } ); if( completion == well.completions.end() ) return zero; diff --git a/tests/test_RFT.cpp b/tests/test_RFT.cpp index 16b1e609d..9f9059d00 100755 --- a/tests/test_RFT.cpp +++ b/tests/test_RFT.cpp @@ -139,12 +139,12 @@ BOOST_AUTO_TEST_CASE(test_RFT) { std::vector well1_comps(9); for (size_t i = 0; i < 9; ++i) { - Opm::data::Completion well_comp { grid.activeIndex(8,8,i) ,r1, 0.0 , 0.0, (double)i, 0.1*i,0.2*i}; + Opm::data::Completion well_comp { grid.getGlobalIndex(8,8,i) ,r1, 0.0 , 0.0, (double)i, 0.1*i,0.2*i}; well1_comps[i] = well_comp; } std::vector well2_comps(6); for (size_t i = 0; i < 6; ++i) { - Opm::data::Completion well_comp { grid.activeIndex(3,3,i+3) ,r2, 0.0 , 0.0, (double)i, i*0.1,i*0.2}; + Opm::data::Completion well_comp { grid.getGlobalIndex(3,3,i+3) ,r2, 0.0 , 0.0, (double)i, i*0.1,i*0.2}; well2_comps[i] = well_comp; } @@ -229,12 +229,12 @@ BOOST_AUTO_TEST_CASE(test_RFT2) { std::vector well1_comps(9); for (size_t i = 0; i < 9; ++i) { - Opm::data::Completion well_comp { grid.activeIndex(8,8,i) ,r1, 0.0 , 0.0, (double)i, 0.1*i,0.2*i}; + Opm::data::Completion well_comp { grid.getGlobalIndex(8,8,i) ,r1, 0.0 , 0.0, (double)i, 0.1*i,0.2*i}; well1_comps[i] = well_comp; } std::vector well2_comps(6); for (size_t i = 0; i < 6; ++i) { - Opm::data::Completion well_comp { grid.activeIndex(3,3,i+3) ,r2, 0.0 , 0.0, (double)i, i*0.1,i*0.2}; + Opm::data::Completion well_comp { grid.getGlobalIndex(3,3,i+3) ,r2, 0.0 , 0.0, (double)i, i*0.1,i*0.2}; well2_comps[i] = well_comp; } diff --git a/tests/test_Summary.cpp b/tests/test_Summary.cpp index 1228c22a4..b2a0bb23d 100644 --- a/tests/test_Summary.cpp +++ b/tests/test_Summary.cpp @@ -144,8 +144,8 @@ static data::Wells result_wells() { crates2.set( rt::reservoir_gas, 300.8 / day ); /* - The active index assigned to the completion must be manually - syncronized with the active index in the COMPDAT keyword in the + The global index assigned to the completion must be manually + syncronized with the global index in the COMPDAT keyword in the input deck. */ data::Completion well1_comp1 { 0 , crates1, 1.9 , 123.4}; From e2e38ddc0cb90ed8dfb635227f6a2ee7ee012126 Mon Sep 17 00:00:00 2001 From: Tor Harald Sandve Date: Mon, 12 Feb 2018 11:42:59 +0100 Subject: [PATCH 6/6] Add write/read test for data::wells --- tests/test_Summary.cpp | 52 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/tests/test_Summary.cpp b/tests/test_Summary.cpp index b2a0bb23d..cf13476ce 100644 --- a/tests/test_Summary.cpp +++ b/tests/test_Summary.cpp @@ -1098,3 +1098,55 @@ BOOST_AUTO_TEST_CASE(EXTRA) { /* Override a NOT MISC variable - ignored. */ BOOST_CHECK( ecl_sum_get_general_var( resp , 4 , "FOPR") > 0.0 ); } + +struct MessageBuffer +{ + std::stringstream str_; + + template + void read( T& value ) + { + str_.read( (char *) &value, sizeof(value) ); + } + + template + void write( const T& value ) + { + str_.write( (char *) &value, sizeof(value) ); + } + + void write( const std::string& str) + { + int size = str.size(); + write(size); + for (int k = 0; k < size; ++k) { + write(str[k]); + } + } + + void read( std::string& str) + { + int size = 0; + read(size); + str.resize(size); + for (int k = 0; k < size; ++k) { + read(str[k]); + } + } + +}; + +BOOST_AUTO_TEST_CASE(READ_WRITE_WELLDATA) { + + Opm::data::Wells wellRates = result_wells(); + + MessageBuffer buffer; + wellRates.write(buffer); + + Opm::data::Wells wellRatesCopy; + wellRatesCopy.read(buffer); + + BOOST_CHECK_CLOSE( wellRatesCopy.get( "W_1" , rt::wat) , wellRates.get( "W_1" , rt::wat), 1e-16); + BOOST_CHECK_CLOSE( wellRatesCopy.get( "W_2" , 101 , rt::wat) , wellRates.get( "W_2" , 101 , rt::wat), 1e-16); + +}