Use Schedule::restart_groups()

This commit is contained in:
Joakim Hove 2020-06-24 15:38:44 +02:00
parent 2876751fe2
commit e65880aafb
5 changed files with 17 additions and 28 deletions

View File

@ -202,6 +202,15 @@ namespace Opm
std::vector<std::string> groupNames(size_t timeStep) const;
std::vector<std::string> groupNames(const std::string& pattern) const;
std::vector<std::string> groupNames() const;
/*
The restart_groups function returns a vector of groups pointers which
is organized as follows:
1. The number of elements is WELLDIMS::MAXGROUPS + 1
2. The elements are sorted according to group.insert_index().
3. If there are less than WELLDIMS::MAXGROUPS nullptr is used.
4. The very last element corresponds to the FIELD group.
*/
std::vector<const Group*> restart_groups(size_t timeStep) const;
void updateWell(std::shared_ptr<Well> well, size_t reportStep);

View File

@ -1248,13 +1248,7 @@ captureDeclaredGroupData(const Opm::Schedule& sched,
const Opm::SummaryState& sumState,
const std::vector<int>& inteHead)
{
std::vector<const Opm::Group*> curGroups(ngmaxz(inteHead), nullptr);
for (const auto& group_name : sched.groupNames(simStep)) {
const auto& group = sched.getGroup(group_name, simStep);
int ind = (group.name() == "FIELD")
? ngmaxz(inteHead)-1 : group.insert_index()-1;
curGroups[ind] = std::addressof(group);
}
const auto& curGroups = sched.restart_groups(simStep);
groupLoop(curGroups, [&sched, simStep, sumState, this]
(const Group& group, const std::size_t groupID) -> void

View File

@ -378,30 +378,12 @@ std::pair<bool, int > findInVector(const std::vector<T> & vecOfElements, const
return result;
}
// Make ordered list of current groups
const std::vector<const Opm::Group*> currentGroups(const Opm::Schedule& sched,
const std::size_t simStep,
const std::vector<int>& inteHead )
{
std::vector<const Opm::Group*> curGroups(ngmaxz(inteHead), nullptr);
for (const auto& group_name : sched.groupNames(simStep)) {
const auto& group = sched.getGroup(group_name, simStep);
//The FIELD group is the first group according to the insert_index()
//In the Eclipse compatible restart file, the FILED group is put at the end of the list of groups (ngmaxz(inteHead)-1)
int ind = (group.name() == "FIELD")
? ngmaxz(inteHead)-1 : group.insert_index()-1;
curGroups[ind] = std::addressof(group);
}
return curGroups;
}
const std::vector<int> Opm::RestartIO::Helpers::igphData::ig_phase(const Opm::Schedule& sched,
const std::size_t simStep,
const std::vector<int>& inteHead )
{
const auto curGroups = currentGroups(sched, simStep, inteHead);
const auto curGroups = sched.restart_groups(simStep);
std::vector<int> inj_phase(ngmaxz(inteHead), 0);
for (std::size_t ind = 0; ind < curGroups.size(); ind++) {
if (curGroups[ind] != nullptr) {
@ -579,7 +561,7 @@ captureDeclaredUDQData(const Opm::Schedule& sched,
}
std::size_t i_gudq = 0;
const auto curGroups = currentGroups(sched, simStep, inteHead);
const auto curGroups = sched.restart_groups(simStep);
const auto ngmax = ngmaxz(inteHead);
int cnt_dudg = 0;
for (const auto& udq_input : udqCfg.input()) {

View File

@ -2682,7 +2682,8 @@ void Schedule::invalidNamePattern( const std::string& namePattern, std::size_t
}
std::vector<const Group*> Schedule::restart_groups(std::size_t timeStep) const {
std::vector<const Group*> rst_groups( this->numGroups(timeStep), nullptr );
std::size_t wdmax = this->m_runspec.wellDimensions().maxGroupsInField();
std::vector<const Group*> rst_groups(wdmax + 1 , nullptr );
for (const auto& group_name : this->groupNames(timeStep)) {
const auto& group = this->getGroup(group_name, timeStep);

View File

@ -258,6 +258,8 @@ static std::string createDeckWithWellsOrdered() {
std::string input =
"START -- 0 \n"
"10 MAI 2007 / \n"
"WELLDIMS\n"
" * * 3 /\n"
"SCHEDULE\n"
"WELSPECS\n"
" \'CW_1\' \'CG\' 3 3 3.33 \'OIL\' 7* / \n"
@ -326,6 +328,7 @@ static std::string createDeckRFTConfig() {
return R"(RUNSPEC
START -- 0
1 NOV 1979 /
SCHEDULE
DATES -- 1 (sim step = 0)
1 DES 1979/