Also check group constrains for iter > nupcol

This commit is contained in:
Tor Harald Sandve 2024-11-20 18:06:45 +01:00
parent 73a28a7abb
commit 933d2949be

View File

@ -2208,13 +2208,9 @@ namespace Opm {
bool changed_well_group = false; bool changed_well_group = false;
// Check group individual constraints. // Check group individual constraints.
const int nupcol = this->schedule()[episodeIdx].nupcol(); const Group& fieldGroup = this->schedule().getGroup("FIELD", episodeIdx);
// don't switch group control when iterationIdx > nupcol changed_well_group = updateGroupControls(fieldGroup, deferred_logger, episodeIdx, iterationIdx);
// to avoid oscilations between group controls
if (iterationIdx <= nupcol) {
const Group& fieldGroup = this->schedule().getGroup("FIELD", episodeIdx);
changed_well_group = updateGroupControls(fieldGroup, deferred_logger, episodeIdx, iterationIdx);
}
// Check wells' group constraints and communicate. // Check wells' group constraints and communicate.
bool changed_well_to_group = false; bool changed_well_to_group = false;
{ {
@ -2236,14 +2232,10 @@ namespace Opm {
if (changed_well_to_group) { if (changed_well_to_group) {
updateAndCommunicate(episodeIdx, iterationIdx, deferred_logger); updateAndCommunicate(episodeIdx, iterationIdx, deferred_logger);
changed_well_group = true; changed_well_group = true;
simulator_.gridView().comm());
} }
changed_well_to_group = comm.sum(static_cast<int>(changed_well_to_group)); // Check individual well constraints and communicate.
if (changed_well_to_group) { bool changed_well_individual = false;
updateAndCommunicate(episodeIdx, iterationIdx, deferred_logger);
changed_well_group = true;
}
{ {
// For MS Wells a linear solve is performed below and the matrix might be singular. // For MS Wells a linear solve is performed below and the matrix might be singular.
// We need to communicate the exception thrown to the others and rethrow. // We need to communicate the exception thrown to the others and rethrow.
@ -2266,7 +2258,6 @@ namespace Opm {
} }
// update wsolvent fraction for REIN wells // update wsolvent fraction for REIN wells
//const Group& fieldGroup = this->schedule().getGroup("FIELD", episodeIdx);
this->updateWsolvent(fieldGroup, episodeIdx, this->nupcolWellState()); this->updateWsolvent(fieldGroup, episodeIdx, this->nupcolWellState());
return { changed_well_group, more_network_update }; return { changed_well_group, more_network_update };
@ -2479,7 +2470,14 @@ namespace Opm {
if (this->switched_prod_groups_.count(group.name()) > 0) { if (this->switched_prod_groups_.count(group.name()) > 0) {
for (const auto& key : this->switched_prod_groups_[group.name()]) { for (const auto& key : this->switched_prod_groups_[group.name()]) {
if (std::count(this->switched_prod_groups_[group.name()].begin(), this->switched_prod_groups_[group.name()].end(), key) >= 3) { if (std::count(this->switched_prod_groups_[group.name()].begin(), this->switched_prod_groups_[group.name()].end(), key) >= 3) {
std::cout << "group control osccilating " << group.name() << " keep at " << key << std::endl; if (std::count(this->switched_prod_groups_[group.name()].begin(), this->switched_prod_groups_[group.name()].end(), key) == 3) {
const std::string msg =
fmt::format("Group control for group {} is oscilating. Group control kept at {}.",
group.name(),
key);
deferred_logger.info(msg);
this->switched_prod_groups_[group.name()].push_back(key);
}
return false; return false;
} }
} }