Skip to content

Commit

Permalink
Add possibleFutureConnections to Schedule
Browse files Browse the repository at this point in the history
  • Loading branch information
lisajulia committed Jul 25, 2024
1 parent 974bd79 commit afa2123
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
2 changes: 1 addition & 1 deletion opm/input/eclipse/Schedule/Action/PyAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ namespace Action {
bool PyAction::valid_keyword(const std::string& keyword) {
static std::unordered_set<std::string> pyaction_allowed_list = {
"BOX",
"COMPSEGS",
"COMPDAT", "COMPLUMP", "COMPSEGS",
"FIELD",
"ENDBOX", "EXIT",
"GCONINJE", "GCONPROD", "GCONSUMP","GRUPTREE",
Expand Down
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
6 changes: 5 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 @@ -469,6 +472,7 @@ namespace Opm
std::vector<ScheduleState> snapshots{};
WriteRestartFileEvents restart_output{};
CompletedCells completed_cells{};
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
Expand Down Expand Up @@ -539,7 +543,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 afa2123

Please sign in to comment.