diff --git a/opm/output/eclipse/AggregateWellData.hpp b/opm/output/eclipse/AggregateWellData.hpp index f9590981f..897c02c64 100644 --- a/opm/output/eclipse/AggregateWellData.hpp +++ b/opm/output/eclipse/AggregateWellData.hpp @@ -34,6 +34,7 @@ namespace Opm { class SummaryState; class UnitSystem; class WellTestState; + class TracerConfig; namespace Action { class State; } @@ -51,7 +52,7 @@ namespace Opm { namespace RestartIO { namespace Helpers { explicit AggregateWellData(const std::vector& inteHead); void captureDeclaredWellData(const Schedule& sched, - const UnitSystem& units, + const TracerConfig& tracer, const std::size_t sim_step, const Opm::Action::State& action_state, const Opm::WellTestState& wtest_state, diff --git a/opm/output/eclipse/VectorItems/well.hpp b/opm/output/eclipse/VectorItems/well.hpp index e6d2f31d3..40edf705c 100644 --- a/opm/output/eclipse/VectorItems/well.hpp +++ b/opm/output/eclipse/VectorItems/well.hpp @@ -183,6 +183,8 @@ namespace Opm { namespace RestartIO { namespace Helpers { namespace VectorItems LOweightFac = 57, // Well's wighting factor for preferential allocation of lift gas LOminRate = 67, // Well's mimimum lift gas rate LOincFac =115, + + TracerOffset = 122, // Tracer data start at this index }; } // SWell diff --git a/src/opm/output/eclipse/AggregateWellData.cpp b/src/opm/output/eclipse/AggregateWellData.cpp index b9e42b4ab..42831d2f6 100644 --- a/src/opm/output/eclipse/AggregateWellData.cpp +++ b/src/opm/output/eclipse/AggregateWellData.cpp @@ -40,10 +40,13 @@ #include #include #include +#include #include #include +#include + #include #include #include @@ -518,18 +521,36 @@ namespace { return rLimit; } + + template + void assignTracerData(const Opm::TracerConfig& tracers, + const Opm::SummaryState& smry, + const std::string& wname, + SWellArray &sWell) + { + using Ix = ::Opm::RestartIO::Helpers::VectorItems::SWell::index; + std::fill(sWell.begin() + Ix::TracerOffset, sWell.end(), 0); + + std::size_t output_index = Ix::TracerOffset; + for (const auto& tracer : tracers) { + sWell[output_index] = smry.get_well_var(wname, fmt::format("WTIC{}", tracer.name), 0); + output_index++; + } + } + template void staticContrib(const Opm::Well& well, const Opm::GasLiftOpt& glo, - const Opm::UnitSystem& units, const std::size_t sim_step, const Opm::Schedule& sched, + const Opm::TracerConfig& tracers, const Opm::WellTestState& wtest_state, const ::Opm::SummaryState& smry, SWellArray& sWell) { using Ix = ::Opm::RestartIO::Helpers::VectorItems::SWell::index; using M = ::Opm::UnitSystem::measure; + const auto& units = sched.getUnits(); auto swprop = [&units](const M u, const double x) -> float { @@ -691,6 +712,8 @@ namespace { sWell[Ix::WTestInterval] = units.from_si(Opm::UnitSystem::measure::time, wtest_rst->test_interval); sWell[Ix::WTestStartupTime] = units.from_si(Opm::UnitSystem::measure::time, wtest_rst->startup_time); } + + assignTracerData(tracers, smry, well.name(), sWell); } } // SWell @@ -980,7 +1003,7 @@ AggregateWellData(const std::vector& inteHead) void Opm::RestartIO::Helpers::AggregateWellData:: captureDeclaredWellData(const Schedule& sched, - const UnitSystem& units, + const TracerConfig& tracers, const std::size_t sim_step, const ::Opm::Action::State& action_state, const Opm::WellTestState& wtest_state, @@ -1008,21 +1031,21 @@ captureDeclaredWellData(const Schedule& sched, } // Static contributions to SWEL array. - wellLoop(wells, sched, sim_step, [&units, &step_glo, &sim_step, &sched, &wtest_state, &smry, this] + wellLoop(wells, sched, sim_step, [&step_glo, &sim_step, &sched, &tracers, &wtest_state, &smry, this] (const Well& well, const std::size_t wellID) -> void { auto sw = this->sWell_[wellID]; - SWell::staticContrib(well, step_glo, units, sim_step, sched, wtest_state, smry, sw); + SWell::staticContrib(well, step_glo, sim_step, sched, tracers, wtest_state, smry, sw); }); // Static contributions to XWEL array. - wellLoop(wells, sched, sim_step, [&units, &smry, this] + wellLoop(wells, sched, sim_step, [&sched, &smry, this] (const Well& well, const std::size_t wellID) -> void { auto xw = this->xWell_[wellID]; - XWell::staticContrib(well, smry, units, xw); + XWell::staticContrib(well, smry,sched.getUnits(), xw); }); { diff --git a/src/opm/output/eclipse/RestartIO.cpp b/src/opm/output/eclipse/RestartIO.cpp index ea7626b10..39afc6563 100644 --- a/src/opm/output/eclipse/RestartIO.cpp +++ b/src/opm/output/eclipse/RestartIO.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include @@ -378,9 +379,9 @@ namespace { void writeWell(int sim_step, const bool ecl_compatible_rst, const Phases& phases, - const UnitSystem& units, const EclipseGrid& grid, const Schedule& schedule, + const TracerConfig& tracers, const std::vector& well_names, const data::Wells& wells, const Opm::Action::State& action_state, @@ -390,7 +391,7 @@ namespace { EclIO::OutputStream::Restart& rstFile) { auto wellData = Helpers::AggregateWellData(ih); - wellData.captureDeclaredWellData(schedule, units, sim_step, action_state, wtest_state, sumState, ih); + wellData.captureDeclaredWellData(schedule, tracers, sim_step, action_state, wtest_state, sumState, ih); wellData.captureDynamicWellData(schedule, sim_step, wells, sumState); rstFile.write("IWEL", wellData.getIWell()); @@ -418,7 +419,7 @@ namespace { } auto connectionData = Helpers::AggregateConnectionData(ih); - connectionData.captureDeclaredConnData(schedule, grid, units, + connectionData.captureDeclaredConnData(schedule, grid, schedule.getUnits(), wells, sumState, sim_step); rstFile.write("ICON", connectionData.getIConn()); @@ -477,7 +478,6 @@ namespace { void writeDynamicData(const int sim_step, const bool ecl_compatible_rst, const Phases& phases, - const UnitSystem& units, const EclipseGrid& grid, const EclipseState& es, const Schedule& schedule, @@ -490,13 +490,13 @@ namespace { std::optional& aquiferData, EclIO::OutputStream::Restart& rstFile) { - writeGroup(sim_step, units, schedule, sumState, inteHD, rstFile); + writeGroup(sim_step, schedule.getUnits(), schedule, sumState, inteHD, rstFile); // Write network data if the network option is used and network defined if ((es.runspec().networkDimensions().maxNONodes() >= 1) && schedule[sim_step].network().active()) { - writeNetwork(es, sim_step, units, schedule, sumState, inteHD, rstFile); + writeNetwork(es, sim_step, schedule.getUnits(), schedule, sumState, inteHD, rstFile); } // Write well and MSW data only when applicable (i.e., when present) @@ -511,11 +511,11 @@ namespace { }); if (haveMSW) { - writeMSWData(sim_step, units, schedule, grid, + writeMSWData(sim_step, schedule.getUnits(), schedule, grid, sumState, wellSol, inteHD, rstFile); } - writeWell(sim_step, ecl_compatible_rst, phases, units, grid, schedule, + writeWell(sim_step, ecl_compatible_rst, phases, grid, schedule, es.tracer(), wells, wellSol, action_state, wtest_state, sumState, inteHD, rstFile); } @@ -523,7 +523,7 @@ namespace { aquiferData.has_value()) { updateAndWriteAquiferData(es.aquifer(), aquDynData, sumState, - units, aquiferData.value(), rstFile); + schedule.getUnits(), aquiferData.value(), rstFile); } } @@ -815,7 +815,7 @@ void save(EclIO::OutputStream::Restart& rstFile, if (report_step > 0) { writeDynamicData(sim_step, ecl_compatible_rst, es.runspec().phases(), - units, grid, es, schedule, value.wells, action_state, wtest_state, + grid, es, schedule, value.wells, action_state, wtest_state, sumState, inteHD, value.aquifer, aquiferData, rstFile); } diff --git a/src/opm/parser/eclipse/EclipseState/Runspec.cpp b/src/opm/parser/eclipse/EclipseState/Runspec.cpp index 927fbab3f..0410e9fbf 100644 --- a/src/opm/parser/eclipse/EclipseState/Runspec.cpp +++ b/src/opm/parser/eclipse/EclipseState/Runspec.cpp @@ -565,7 +565,6 @@ const Tracers& Runspec::tracers() const { return this->m_tracers; } - Runspec::Runspec( const Deck& deck ) : m_start_time( create_start_time(deck) ) , active_phases( inferActivePhases(deck) ) diff --git a/tests/test_AggregateActionxData.cpp b/tests/test_AggregateActionxData.cpp index 8617dc255..474dd6a45 100644 --- a/tests/test_AggregateActionxData.cpp +++ b/tests/test_AggregateActionxData.cpp @@ -198,7 +198,7 @@ BOOST_AUTO_TEST_CASE(Declared_Actionx_data) } { auto well_aggregator = Opm::RestartIO::Helpers::AggregateWellData(ih); - well_aggregator.captureDeclaredWellData(sched, es.getUnits(), rptStep-1, {}, {}, st, ih); + well_aggregator.captureDeclaredWellData(sched, es.tracer(), rptStep-1, {}, {}, st, ih); rstFile.write("IWEL", well_aggregator.getIWell()); rstFile.write("SWEL", well_aggregator.getSWell()); rstFile.write("XWEL", well_aggregator.getXWell()); diff --git a/tests/test_AggregateUDQData.cpp b/tests/test_AggregateUDQData.cpp index 66bdf75cf..304c18e36 100644 --- a/tests/test_AggregateUDQData.cpp +++ b/tests/test_AggregateUDQData.cpp @@ -259,7 +259,7 @@ BOOST_AUTO_TEST_CASE (Declared_UDQ_data) auto action_state = Opm::Action::State {}; auto wtest_state = Opm::WellTestState{}; auto well_aggregator = Opm::RestartIO::Helpers::AggregateWellData(ih); - well_aggregator.captureDeclaredWellData(sched, es.getUnits(), rptStep-1, action_state, wtest_state, st, ih); + well_aggregator.captureDeclaredWellData(sched, es.tracer(), rptStep-1, action_state, wtest_state, st, ih); rstFile.write("IWEL", well_aggregator.getIWell()); rstFile.write("SWEL", well_aggregator.getSWell()); rstFile.write("XWEL", well_aggregator.getXWell()); diff --git a/tests/test_AggregateWellData.cpp b/tests/test_AggregateWellData.cpp index 9784140f8..ddb2c2fc7 100644 --- a/tests/test_AggregateWellData.cpp +++ b/tests/test_AggregateWellData.cpp @@ -628,7 +628,7 @@ BOOST_AUTO_TEST_CASE (Declared_Well_Data) BOOST_CHECK(tw == std::vector{"OP_1"}); awd.captureDeclaredWellData(simCase.sched, - simCase.es.getUnits(), rptStep, action_state, wtest_state, smry, ih.value); + simCase.es.tracer(), rptStep, action_state, wtest_state, smry, ih.value); // IWEL (OP_1) { @@ -843,7 +843,7 @@ BOOST_AUTO_TEST_CASE (Declared_Well_Data) //smry = sim_state(); awd = Opm::RestartIO::Helpers::AggregateWellData{ih_8.value}; awd.captureDeclaredWellData(simCase.sched, - simCase.es.getUnits(), rptStep_8, action_state, wtest_state, smry, ih_8.value); + simCase.es.tracer(), rptStep_8, action_state, wtest_state, smry, ih_8.value); { using Ix = ::Opm::RestartIO::Helpers::VectorItems::SWell::index; @@ -879,7 +879,7 @@ BOOST_AUTO_TEST_CASE (Declared_Well_Data_MSW_well_data) auto awd = Opm::RestartIO::Helpers::AggregateWellData{ih.value}; awd.captureDeclaredWellData(simCase.sched, - simCase.es.getUnits(), rptStep, action_state, wtest_state, smry, ih.value); + simCase.es.tracer(), rptStep, action_state, wtest_state, smry, ih.value); // IWEL (PROD1) { @@ -1278,7 +1278,7 @@ BOOST_AUTO_TEST_CASE(WELL_POD) { sim_step); auto wellData = Opm::RestartIO::Helpers::AggregateWellData(ih); - wellData.captureDeclaredWellData(simCase.sched, units, sim_step, action_state, wtest_state, sumState, ih); + wellData.captureDeclaredWellData(simCase.sched, simCase.es.tracer(), sim_step, action_state, wtest_state, sumState, ih); wellData.captureDynamicWellData(simCase.sched, sim_step, xw , sumState); auto connectionData = Opm::RestartIO::Helpers::AggregateConnectionData(ih); diff --git a/tests/test_LGOData.cpp b/tests/test_LGOData.cpp index 95b71b66a..9ddc6625e 100644 --- a/tests/test_LGOData.cpp +++ b/tests/test_LGOData.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include @@ -99,7 +100,7 @@ BOOST_AUTO_TEST_CASE(liftGasOptimzation_data) const auto dh = Opm::RestartIO::Helpers::createDoubHead(es, sched, simStep, simStep+1, secs_elapsed, next_step_size); auto wellData = Opm::RestartIO::Helpers::AggregateWellData(ih); - wellData.captureDeclaredWellData(sched, es.getUnits(), simStep, action_state, {}, st, ih); + wellData.captureDeclaredWellData(sched, Opm::TracerConfig{}, simStep, action_state, {}, st, ih); // intehead data auto eachnc = Opm::RestartIO::Helpers::VectorItems::intehead::EACHNCITS; diff --git a/tests/test_rst.cpp b/tests/test_rst.cpp index 4ff3c8b89..97f6c8255 100644 --- a/tests/test_rst.cpp +++ b/tests/test_rst.cpp @@ -297,7 +297,7 @@ BOOST_AUTO_TEST_CASE(State_test) { 0, 0); auto wellData = Opm::RestartIO::Helpers::AggregateWellData(ih); - wellData.captureDeclaredWellData(simCase.sched, units, sim_step, action_state, wtest_state, sumState, ih); + wellData.captureDeclaredWellData(simCase.sched, simCase.es.tracer(), sim_step, action_state, wtest_state, sumState, ih); wellData.captureDynamicWellData(simCase.sched, sim_step, {} , sumState); auto connectionData = Opm::RestartIO::Helpers::AggregateConnectionData(ih);