Skip to content

Commit

Permalink
Merge pull request #4150 from lisajulia/fix/ACTIONX-COMPDAT
Browse files Browse the repository at this point in the history
Add possibleFutureConnections to Schedule
  • Loading branch information
blattms authored Jul 30, 2024
2 parents d075bc8 + e75fde5 commit 6ea038e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
14 changes: 12 additions & 2 deletions opm/input/eclipse/Schedule/Schedule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ void Schedule::iterateScheduleSection(std::size_t load_start, std::size_t load_e

if (Action::ActionX::valid_keyword(action_keyword.name())){
action.addKeyword(action_keyword);
this->prefetch_cell_properties(grid, action_keyword);
this->prefetchPossibleFutureConnections(grid, action_keyword);
this->store_wgnames(action_keyword);
}
else {
Expand Down Expand Up @@ -658,7 +658,7 @@ void Schedule::iterateScheduleSection(std::size_t load_start, std::size_t load_e
}


void Schedule::prefetch_cell_properties(const ScheduleGrid& grid, const DeckKeyword& keyword){
void Schedule::prefetchPossibleFutureConnections(const ScheduleGrid& grid, const DeckKeyword& keyword){
if(keyword.is<ParserKeywords::COMPDAT>()){
for (auto record : keyword){
const auto& itemI = record.getItem("I");
Expand All @@ -674,10 +674,16 @@ void Schedule::iterateScheduleSection(std::size_t load_start, std::size_t load_e
int K1 = record.getItem("K1").get<int>(0) - 1;
int K2 = record.getItem("K2").get<int>(0) - 1;

const auto wellName = record.getItem("WELL").getTrimmedString(0);

// Retrieve or create the set of future connections for the well
auto& currentSet = this->possibleFutureConnections[wellName];
for (int k = K1; k <= K2; k++){
auto cell = grid.get_cell(I, J, k);
(void) cell;
//Only interested in activating the cells.
std::array<int,3> ijk{I,J,k};
currentSet.insert(ijk);
}
}
return;
Expand Down Expand Up @@ -1059,6 +1065,10 @@ void Schedule::iterateScheduleSection(std::size_t load_start, std::size_t load_e
return this->getWell(well_name, this->snapshots.size() - 1);
}

const std::unordered_map<std::string, std::set<std::array<int,3>>>& Schedule::getPossibleFutureConnections() const {
return this->possibleFutureConnections;
}

std::unordered_set<int> Schedule::getAquiferFluxSchedule() const {
std::unordered_set<int> ids;
for (const auto& snapshot : this->snapshots) {
Expand Down
10 changes: 9 additions & 1 deletion opm/input/eclipse/Schedule/Schedule.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,9 @@ namespace Opm
std::unordered_set<int> getAquiferFluxSchedule() const;
std::vector<Well> getWells(std::size_t timeStep) const;
std::vector<Well> getWellsatEnd() const;

const std::unordered_map<std::string, std::set<std::array<int,3>>>& getPossibleFutureConnections() const;

void shut_well(const std::string& well_name, std::size_t report_step);
void shut_well(const std::string& well_name);
void stop_well(const std::string& well_name, std::size_t report_step);
Expand Down Expand Up @@ -470,6 +473,11 @@ namespace Opm
WriteRestartFileEvents restart_output{};
CompletedCells completed_cells{};

// This unordered_map contains possible future connections of wells that might get added through an ACTIONX.
// For parallel runs, this unordered_map is retrieved by the grid partitioner to ensure these connections
// end up on the same partition.
std::unordered_map<std::string, std::set<std::array<int,3>>> possibleFutureConnections;

// The current_report_step is set to the current report step when a PYACTION call is executed.
// This is needed since the Schedule object does not know the current report step of the simulator and
// we only allow PYACTIONS for the current and future report steps.
Expand Down Expand Up @@ -539,7 +547,7 @@ namespace Opm
std::set<std::string>* compsegs_wells = nullptr);

void internalWELLSTATUSACTIONXFromPYACTION(const std::string& well_name, std::size_t report_step, const std::string& wellStatus);
void prefetch_cell_properties(const ScheduleGrid& grid, const DeckKeyword& keyword);
void prefetchPossibleFutureConnections(const ScheduleGrid& grid, const DeckKeyword& keyword);
void store_wgnames(const DeckKeyword& keyword);
std::vector<std::string> wellNames(const std::string& pattern,
const HandlerContext& context,
Expand Down

0 comments on commit 6ea038e

Please sign in to comment.