diff --git a/examples/printvfp.cpp b/examples/printvfp.cpp index 698b01478..d02d5f053 100644 --- a/examples/printvfp.cpp +++ b/examples/printvfp.cpp @@ -19,59 +19,65 @@ #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include +#include + +#include + +#include + #include +#include +#include +#include +#include + +#include + #include -#include +#include + +#include + +#include +#include #include +#include +#include +#include +#include using namespace Opm; +namespace { + struct Setup { - std::unique_ptr ecl_state; - std::shared_ptr python; - std::unique_ptr schedule; - std::unique_ptr summary_state; - std::unique_ptr> vfp_properties; + explicit Setup(const std::string& file) + : Setup { Parser{}.parseFile(file) } + {} - Setup(const std::string& file) + explicit Setup(const Deck& deck) + : ecl_state { std::make_unique(deck) } + , schedule { std::make_unique(deck, *ecl_state, std::make_shared()) } + , well_state { std::make_unique>(phaseUsage(ecl_state->runspec().phases())) } { - Parser parser; - auto deck = parser.parseFile(file); - ecl_state.reset(new EclipseState(deck) ); - - const TableManager table( deck ); - const Runspec runspec(deck); - python = std::make_shared(); - schedule.reset( new Schedule(deck, *ecl_state, python)); - summary_state.reset( new SummaryState(TimeService::from_time_t(schedule->getStartTime()))); - const int step = 0; - const auto& sched_state = schedule->operator[](step); - WellState well_state(phaseUsage(runspec.phases())); - vfp_properties = std::make_unique>(sched_state.vfpinj(), - sched_state.vfpprod(), - well_state); - }; + const auto& sched_state = (*this->schedule)[step]; + + this->vfp_properties = std::make_unique> + (sched_state.vfpinj(), sched_state.vfpprod(), *well_state); + } + + std::unique_ptr ecl_state; + std::unique_ptr schedule; + std::unique_ptr> well_state; + std::unique_ptr> vfp_properties; }; - - double computeBhp(const VFPProdTable& table, const double flo, const double thp, @@ -83,24 +89,25 @@ double computeBhp(const VFPProdTable& table, // First, find the values to interpolate between. // Assuming positive flo here! assert(flo > 0.0); - auto flo_i = VFPHelpers::findInterpData(flo, table.getFloAxis()); - auto thp_i = VFPHelpers::findInterpData(thp, table.getTHPAxis()); // assume constant - auto wfr_i = VFPHelpers::findInterpData(wfr, table.getWFRAxis()); - auto gfr_i = VFPHelpers::findInterpData(gfr, table.getGFRAxis()); - auto alq_i = VFPHelpers::findInterpData(alq, table.getALQAxis()); //assume constant + + const auto flo_i = VFPHelpers::findInterpData(flo, table.getFloAxis()); + const auto thp_i = VFPHelpers::findInterpData(thp, table.getTHPAxis()); // assume constant + const auto wfr_i = VFPHelpers::findInterpData(wfr, table.getWFRAxis()); + const auto gfr_i = VFPHelpers::findInterpData(gfr, table.getGFRAxis()); + const auto alq_i = VFPHelpers::findInterpData(alq, table.getALQAxis()); // assume constant return VFPHelpers::interpolate(table, flo_i, thp_i, wfr_i, gfr_i, alq_i).value; } - - +} // Anonymous namespace int main(int argc, char** argv) { if (argc < 2) { return EXIT_FAILURE; } - Setup setup(argv[1]); + + const Setup setup(argv[1]); // const int table_id = 1; const int table_id = 4; diff --git a/opm/simulators/flow/FlowGenericVanguard.cpp b/opm/simulators/flow/FlowGenericVanguard.cpp index 00cfba33d..73ad12923 100644 --- a/opm/simulators/flow/FlowGenericVanguard.cpp +++ b/opm/simulators/flow/FlowGenericVanguard.cpp @@ -22,16 +22,22 @@ */ #include -#include +#include #include #include #include + #include + #include #include -#include +#include +#include + +#include + #include #include #include @@ -51,6 +57,7 @@ #include #include #include +#include #include #include #include @@ -67,8 +74,9 @@ #include #include #include -#include -#include + +#include + #include #include @@ -239,8 +247,11 @@ void FlowGenericVanguard::init() } - if (!this->summaryState_) - this->summaryState_ = std::make_unique( TimeService::from_time_t(this->eclSchedule_->getStartTime() )); + if (!this->summaryState_) { + this->summaryState_ = std::make_unique + (TimeService::from_time_t(this->eclSchedule_->getStartTime()), + this->eclState_->runspec().udqParams().undefinedValue()); + } // Initialize parallelWells with all local wells const auto& schedule_wells = schedule().getWellsatEnd(); diff --git a/opm/simulators/utils/readDeck.cpp b/opm/simulators/utils/readDeck.cpp index e3b64f345..6d14d0c04 100644 --- a/opm/simulators/utils/readDeck.cpp +++ b/opm/simulators/utils/readDeck.cpp @@ -55,7 +55,6 @@ #include #include #include -#include #include #include #include @@ -405,7 +404,7 @@ void Opm::ensureOutputDirExists(const std::string& cmdline_output_dir) void Opm::prepareResultOutputDirectory(const std::string& baseName, const std::filesystem::path& outputDir) -{ +{ //Loop over all files in the output directory and subdirectories and delete them if their name is baseName + a correct extension std::regex r(baseName + R"(\.(F?(DBG|E?GRID|INIT|PRT|RFT|SMSPEC|UNSMRY|UNRST)|([ABCFGHSTUXYZ]\d{4})|(INFOSTEP|INFOITER|OPMRST)))"); for (auto& file : std::filesystem::recursive_directory_iterator(outputDir)) { diff --git a/tests/test_wellmodel.cpp b/tests/test_wellmodel.cpp index 978b6f951..ee838429e 100644 --- a/tests/test_wellmodel.cpp +++ b/tests/test_wellmodel.cpp @@ -27,15 +27,19 @@ #include #include -#include #include -#include -#include -#include #include + #include +#include +#include +#include +#include +#include + #include + #include #include @@ -50,13 +54,18 @@ #include #include +#include +#include + #if HAVE_DUNE_FEM #include #else #include #endif - +#include +#include +#include using StandardWell = Opm::StandardWell; @@ -64,18 +73,21 @@ struct SetupTest { using Grid = UnstructuredGrid; - SetupTest () + SetupTest() { - Opm::Parser parser; - auto deck = parser.parseFile("TESTWELLMODEL.DATA"); - ecl_state.reset(new Opm::EclipseState(deck) ); - { - const Opm::TableManager table ( deck ); - const Opm::Runspec runspec (deck); - python = std::make_shared(); - schedule.reset( new Opm::Schedule(deck, *ecl_state, python)); - summaryState.reset( new Opm::SummaryState(Opm::TimeService::from_time_t(schedule->getStartTime()))); - } + const auto deck = Opm::Parser{}.parseFile("TESTWELLMODEL.DATA"); + this->ecl_state = std::make_unique(deck); + + const Opm::TableManager table(deck); + const Opm::Runspec runspec(deck); + + this->schedule = std::make_unique + (deck, *this->ecl_state, std::make_shared()); + + this->summaryState = std::make_unique + (Opm::TimeService::from_time_t(schedule->getStartTime()), + this->ecl_state->runspec().udqParams().undefinedValue()); + current_timestep = 0; }; @@ -136,7 +148,6 @@ BOOST_AUTO_TEST_CASE(TestStandardWellInput) { BOOST_CHECK_THROW( StandardWell( well, pinfo, -1, param, *rateConverter, 0, 3, 3, 0, pdata), std::invalid_argument); } - BOOST_AUTO_TEST_CASE(TestBehavoir) { const SetupTest setup_test; const auto& wells_ecl = setup_test.schedule->getWells(setup_test.current_timestep); diff --git a/tests/test_wellstate.cpp b/tests/test_wellstate.cpp index 2d7340003..c156ecd42 100644 --- a/tests/test_wellstate.cpp +++ b/tests/test_wellstate.cpp @@ -17,49 +17,59 @@ along with OPM. If not, see . */ -#include #include -#include -#include #define BOOST_TEST_MODULE WellStateFIBOTest -#include "MpiFixture.hpp" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - #include -#include +#include "MpiFixture.hpp" + +#include +#include + #include -#include -#include + +#include + #include #include #include +#include +#include #include #include +#include +#include +#include +#include +#include +#include +#include +#include + #include -#include #include +#include #include #include -#include +#include +#include +#include + +#include #include #include +#include +#include +#include +#include #include +#include BOOST_GLOBAL_FIXTURE(MPIFixture); @@ -73,9 +83,9 @@ struct Setup : es (deck) , pu (Opm::phaseUsageFromDeck(es)) , grid (es.getInputGrid()) - , python( std::make_shared() ) - , sched(deck, es, python) - , st(Opm::TimeService::from_time_t(sched.getStartTime())) + , sched(deck, es, std::make_shared()) + , st { Opm::TimeService::from_time_t(sched.getStartTime()), + es.runspec().udqParams().undefinedValue() } { initWellPerfData(); }