EclWellManager: replace the manual well event detection by the one of opm-parser

to my defense I can say that the Schedule::events() API was not
present in opm-parser when the EclWellManager needed this. (I think it
wasn't available back then, maybe I just was not aware of it.)
This commit is contained in:
Andreas Lauser 2016-02-26 14:56:53 +01:00
parent 1b3df8cb35
commit 95334957e0

View File

@ -33,6 +33,7 @@
#include <opm/parser/eclipse/Deck/Deck.hpp> #include <opm/parser/eclipse/Deck/Deck.hpp>
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp> #include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp> #include <opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Events.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/CompletionSet.hpp> #include <opm/parser/eclipse/EclipseState/Schedule/CompletionSet.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Well.hpp> #include <opm/parser/eclipse/EclipseState/Schedule/Well.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/TimeMap.hpp> #include <opm/parser/eclipse/EclipseState/Schedule/TimeMap.hpp>
@ -126,9 +127,8 @@ public:
WellCompletionsMap wellCompMap; WellCompletionsMap wellCompMap;
computeWellCompletionsMap_(episodeIdx, wellCompMap); computeWellCompletionsMap_(episodeIdx, wellCompMap);
if (wasRestarted || wellTopologyChanged_(eclState, episodeIdx)) { if (wasRestarted || wellTopologyChanged_(eclState, episodeIdx))
updateWellTopology_(episodeIdx, wellCompMap, gridDofIsPenetrated_); updateWellTopology_(episodeIdx, wellCompMap, gridDofIsPenetrated_);
}
// set those parameters of the wells which do not change the topology of the // set those parameters of the wells which do not change the topology of the
// linearized system of equations // linearized system of equations
@ -566,24 +566,16 @@ public:
if (wellTopologyChanged_(eclState, reportStepIdx)) if (wellTopologyChanged_(eclState, reportStepIdx))
return true; return true;
// this is slightly hacky because it assumes that the object which stores the set Opm::ScheduleConstPtr schedule = eclState->getSchedule();
// of wells which are relevant for a report step does not change if there are no if (schedule->getTimeMap()->numTimesteps() <= (unsigned) reportStepIdx)
// changed well parameters. opm-parser does not guarantee this, but so far it
// seems to adhere to it...
auto deckSchedule = eclState->getSchedule();
if (deckSchedule->getTimeMap()->numTimesteps() <= (unsigned) reportStepIdx)
// for the "until the universe dies" episode, the wells don't change // for the "until the universe dies" episode, the wells don't change
return false; return false;
const auto& curDeckWells = deckSchedule->getWells(reportStepIdx); const Opm::Events& events = schedule->getEvents();
const auto& prevDeckWells = deckSchedule->getWells(reportStepIdx - 1); return events.hasEvent(Opm::ScheduleEvents::PRODUCTION_UPDATE |
Opm::ScheduleEvents::INJECTION_UPDATE |
for (unsigned i = 0; i < curDeckWells.size(); ++i) { Opm::ScheduleEvents::WELL_STATUS_CHANGE,
if (curDeckWells[i] != prevDeckWells[i]) reportStepIdx);
return true;
}
return false;
} }
protected: protected:
@ -595,68 +587,15 @@ protected:
return true; return true;
} }
auto deckSchedule = eclState->getSchedule(); Opm::ScheduleConstPtr schedule = eclState->getSchedule();
if (deckSchedule->getTimeMap()->numTimesteps() <= (unsigned) reportStepIdx) if (schedule->getTimeMap()->numTimesteps() <= (unsigned) reportStepIdx)
// for the "until the universe dies" episode, the wells don't change // for the "until the universe dies" episode, the wells don't change
return false; return false;
const auto& curDeckWells = deckSchedule->getWells(reportStepIdx); const Opm::Events& events = schedule->getEvents();
const auto& prevDeckWells = deckSchedule->getWells(reportStepIdx - 1); return events.hasEvent(Opm::ScheduleEvents::NEW_WELL |
Opm::ScheduleEvents::COMPLETION_CHANGE,
if (curDeckWells.size() != prevDeckWells.size()) reportStepIdx);
// the number of wells changed
return true;
auto curWellIt = curDeckWells.begin();
const auto& curWellEndIt = curDeckWells.end();
for (; curWellIt != curWellEndIt; ++curWellIt) {
// find the well in the previous time step
auto prevWellIt = prevDeckWells.begin();
const auto& prevWellEndIt = prevDeckWells.end();
for (; ; ++prevWellIt) {
if (prevWellIt == prevWellEndIt)
// current well has not been featured in previous report step, i.e.,
// the well topology has changed...
return true;
if ((*prevWellIt)->name() == (*curWellIt)->name())
// the previous report step had a well with the same name as the
// current one!
break;
}
// make sure that the wells exhibit the same completions!
const auto curCompletionSet = (*curWellIt)->getCompletions(reportStepIdx);
const auto prevCompletionSet = (*prevWellIt)->getCompletions(reportStepIdx);
if (curCompletionSet->size() != prevCompletionSet->size())
// number of completions of the well has changed!
return true;
for (size_t curWellComplIdx = 0;
curWellComplIdx < curCompletionSet->size();
++ curWellComplIdx)
{
Opm::CompletionConstPtr curCompletion = curCompletionSet->get(curWellComplIdx);
for (size_t prevWellComplIdx = 0;; ++ prevWellComplIdx)
{
if (prevWellComplIdx == prevCompletionSet->size())
// a new completion has appeared in the current report step
return true;
Opm::CompletionConstPtr prevCompletion = prevCompletionSet->get(curWellComplIdx);
if (curCompletion->getI() == prevCompletion->getI()
&& curCompletion->getJ() == prevCompletion->getJ()
&& curCompletion->getK() == prevCompletion->getK())
// completion is present in both wells, look at next completion!
break;
}
}
}
return false;
} }
void updateWellTopology_(unsigned reportStepIdx, void updateWellTopology_(unsigned reportStepIdx,