Use std::shared_ptr for Python handle to Schedule

This commit is contained in:
Joakim Hove
2020-03-31 12:28:07 +02:00
parent 4a6814d6bc
commit d6a1d3029e
7 changed files with 9 additions and 7 deletions
+1 -1
View File
@@ -630,7 +630,7 @@ private:
Opm::EclipseState* eclState_; Opm::EclipseState* eclState_;
Opm::Schedule* eclSchedule_; Opm::Schedule* eclSchedule_;
Opm::SummaryConfig* eclSummaryConfig_; Opm::SummaryConfig* eclSummaryConfig_;
Opm::Python python; std::shared_ptr<Opm::Python> python = std::make_shared<Opm::Python>();
Dune::EdgeWeightMethod edgeWeightsMethod_; Dune::EdgeWeightMethod edgeWeightsMethod_;
bool ownersFirst_; bool ownersFirst_;
+1 -1
View File
@@ -326,7 +326,7 @@ int main(int argc, char** argv)
std::cout << "Reading deck file '" << deckFilename << "'\n"; std::cout << "Reading deck file '" << deckFilename << "'\n";
std::cout.flush(); std::cout.flush();
} }
Opm::Python python; auto python = std::make_shared<Opm::Python>();
std::shared_ptr<Opm::Deck> deck; std::shared_ptr<Opm::Deck> deck;
std::shared_ptr<Opm::EclipseState> eclipseState; std::shared_ptr<Opm::EclipseState> eclipseState;
std::shared_ptr<Opm::Schedule> schedule; std::shared_ptr<Opm::Schedule> schedule;
+1 -1
View File
@@ -355,7 +355,7 @@ int mainFlow(int argc, char** argv)
std::cout << "Reading deck file '" << deckFilename << "'\n"; std::cout << "Reading deck file '" << deckFilename << "'\n";
std::cout.flush(); std::cout.flush();
} }
Opm::Python python; std::shared_ptr<Opm::Python> python = std::make_shared<Opm::Python>();
std::shared_ptr<Opm::Deck> deck; std::shared_ptr<Opm::Deck> deck;
std::shared_ptr<Opm::EclipseState> eclipseState; std::shared_ptr<Opm::EclipseState> eclipseState;
std::shared_ptr<Opm::Schedule> schedule; std::shared_ptr<Opm::Schedule> schedule;
+1 -1
View File
@@ -277,7 +277,7 @@ BOOST_AUTO_TEST_CASE( Test_Norne_PVT) {
Opm::ParseContext parseContext({{ ParseContext::PARSE_RANDOM_SLASH , InputError::IGNORE }}); Opm::ParseContext parseContext({{ ParseContext::PARSE_RANDOM_SLASH , InputError::IGNORE }});
Opm::ErrorGuard errorGuard; Opm::ErrorGuard errorGuard;
Opm::Parser parser; Opm::Parser parser;
Opm::Python python; auto python = std::make_shared<Opm::Python>();
auto deck = parser.parseFile("norne_pvt.data", parseContext, errorGuard); auto deck = parser.parseFile("norne_pvt.data", parseContext, errorGuard);
+1 -1
View File
@@ -37,7 +37,7 @@ BOOST_AUTO_TEST_CASE(TestStoppedWells)
Opm::Parser parser; Opm::Parser parser;
Opm::Deck deck(parser.parseFile(filename)); Opm::Deck deck(parser.parseFile(filename));
Opm::EclipseState eclipseState(deck); Opm::EclipseState eclipseState(deck);
Opm::Python python; auto python = std::make_shared<Opm::Python>();
const Schedule sched(deck, eclipseState, python); const Schedule sched(deck, eclipseState, python);
// Both wells are open in the first schedule step // Both wells are open in the first schedule step
+2 -1
View File
@@ -71,14 +71,15 @@ struct SetupTest {
{ {
const Opm::TableManager table ( deck ); const Opm::TableManager table ( deck );
const Opm::Runspec runspec (deck); const Opm::Runspec runspec (deck);
python = std::make_shared<Opm::Python>();
schedule.reset( new Opm::Schedule(deck, *ecl_state, python)); schedule.reset( new Opm::Schedule(deck, *ecl_state, python));
summaryState.reset( new Opm::SummaryState(std::chrono::system_clock::from_time_t(schedule->getStartTime()))); summaryState.reset( new Opm::SummaryState(std::chrono::system_clock::from_time_t(schedule->getStartTime())));
} }
current_timestep = 0; current_timestep = 0;
}; };
Opm::Python python;
std::unique_ptr<const Opm::EclipseState> ecl_state; std::unique_ptr<const Opm::EclipseState> ecl_state;
std::shared_ptr<Opm::Python> python;
std::unique_ptr<const Opm::Schedule> schedule; std::unique_ptr<const Opm::Schedule> schedule;
std::unique_ptr<Opm::SummaryState> summaryState; std::unique_ptr<Opm::SummaryState> summaryState;
std::vector<std::vector<Opm::PerforationData>> well_perf_data; std::vector<std::vector<Opm::PerforationData>> well_perf_data;
@@ -52,6 +52,7 @@ struct Setup
: es (deck) : es (deck)
, pu (Opm::phaseUsageFromDeck(es)) , pu (Opm::phaseUsageFromDeck(es))
, grid (es.getInputGrid()) , grid (es.getInputGrid())
, python( std::make_shared<Opm::Python>() )
, sched(deck, es, python) , sched(deck, es, python)
, st(std::chrono::system_clock::from_time_t(sched.getStartTime())) , st(std::chrono::system_clock::from_time_t(sched.getStartTime()))
{ {
@@ -102,10 +103,10 @@ struct Setup
} }
} }
Opm::Python python;
Opm::EclipseState es; Opm::EclipseState es;
Opm::PhaseUsage pu; Opm::PhaseUsage pu;
Opm::GridManager grid; Opm::GridManager grid;
std::shared_ptr<Opm::Python> python;
Opm::Schedule sched; Opm::Schedule sched;
Opm::SummaryState st; Opm::SummaryState st;
std::vector<std::vector<Opm::PerforationData>> well_perf_data; std::vector<std::vector<Opm::PerforationData>> well_perf_data;