Merge pull request #1959 from joakim-hove/group-uda

Group uda
This commit is contained in:
Joakim Hove 2019-08-09 08:50:33 +02:00 committed by GitHub
commit 3e15ec4ba3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 24 additions and 23 deletions

View File

@ -30,17 +30,17 @@
namespace Opm
{
void WellCollection::addField(const Group2& fieldGroup, const PhaseUsage& phaseUsage) {
void WellCollection::addField(const Group2& fieldGroup, const SummaryState& summaryState, const PhaseUsage& phaseUsage) {
WellsGroupInterface* fieldNode = findNode(fieldGroup.name());
if (fieldNode) {
OPM_THROW(std::runtime_error, "Trying to add FIELD node, but this already exists. Can only have one FIELD node.");
}
roots_.push_back(createGroupWellsGroup(fieldGroup, phaseUsage));
roots_.push_back(createGroupWellsGroup(fieldGroup, summaryState, phaseUsage));
}
void WellCollection::addGroup(const Group2& groupChild, std::string parent_name,
const PhaseUsage& phaseUsage) {
const SummaryState& summaryState, const PhaseUsage& phaseUsage) {
WellsGroupInterface* parent = findNode(parent_name);
if (!parent) {
OPM_THROW(std::runtime_error, "Trying to add child group to group named " << parent_name << ", but this does not exist in the WellCollection.");
@ -55,8 +55,7 @@ namespace Opm
group_control_active_ = true;
}
std::shared_ptr<WellsGroupInterface> child = createGroupWellsGroup(groupChild, phaseUsage);
std::shared_ptr<WellsGroupInterface> child = createGroupWellsGroup(groupChild, summaryState, phaseUsage);
if (child->injSpec().control_mode_ == InjectionSpecification::VREP) {
having_vrep_groups_ = true;
}

View File

@ -36,12 +36,12 @@ namespace Opm
{
public:
void addField(const Group2& fieldGroup, const PhaseUsage& phaseUsage);
void addField(const Group2& fieldGroup, const SummaryState& summaryState, const PhaseUsage& phaseUsage);
void addWell(const Well2& wellChild, const SummaryState& summaryState, const PhaseUsage& phaseUsage);
void addGroup(const Group2& groupChild, std::string parent_name,
const PhaseUsage& phaseUsage);
const SummaryState& summaryState, const PhaseUsage& phaseUsage);
/// Adds the child to the collection
/// and appends it to parent's children.

View File

@ -1556,12 +1556,12 @@ namespace Opm
}
} // anonymous namespace
std::shared_ptr<WellsGroupInterface> createGroupWellsGroup(const Group2& group, const PhaseUsage& phase_usage )
std::shared_ptr<WellsGroupInterface> createGroupWellsGroup(const Group2& group, const SummaryState& st, const PhaseUsage& phase_usage )
{
InjectionSpecification injection_specification;
ProductionSpecification production_specification;
if (group.isInjectionGroup()) {
const auto& injection = group.injectionProperties();
const auto& injection = group.injectionControls(st);
injection_specification.injector_type_ = toInjectorType(injection.phase);
injection_specification.control_mode_ = toInjectionControlMode(GroupInjection::ControlEnum2String(injection.cmode));
injection_specification.surface_flow_max_rate_ = injection.surface_max_rate;
@ -1571,7 +1571,7 @@ namespace Opm
}
if (group.isProductionGroup()) {
const auto& production = group.productionProperties();
const auto& production = group.productionControls(st);
production_specification.oil_max_rate_ = production.oil_target;
production_specification.control_mode_ = toProductionControlMode(GroupProduction::ControlEnum2String(production.cmode));
production_specification.water_max_rate_ = production.water_target;

View File

@ -550,6 +550,7 @@ namespace Opm
/// \param[in] timeStep the time step in question
/// \param[in] the phase usage
std::shared_ptr<WellsGroupInterface> createGroupWellsGroup(const Group2& group,
const SummaryState& summaryState,
const PhaseUsage& phase_usage );
}

View File

@ -372,7 +372,7 @@ WellsManager::init(const Opm::EclipseState& eclipseState,
{
const auto& fieldGroup = schedule.getGroup2( "FIELD", timeStep);
well_collection_.addField(fieldGroup, pu);
well_collection_.addField(fieldGroup, summaryState, pu);
std::vector< std::string > group_stack = { "FIELD" };
do {
@ -380,7 +380,7 @@ WellsManager::init(const Opm::EclipseState& eclipseState,
group_stack.pop_back();
for (const auto& child: parent.groups()) {
group_stack.push_back(child);
well_collection_.addGroup( schedule.getGroup2( child, timeStep ), parent.name(), pu );
well_collection_.addGroup( schedule.getGroup2( child, timeStep ), parent.name(), summaryState, pu );
}
} while( !group_stack.empty() );

View File

@ -50,10 +50,10 @@ BOOST_AUTO_TEST_CASE(AddWellsAndGroupToCollection) {
// Add groups to WellCollection
const auto& fieldGroup = sched.getGroup2("FIELD", 2);
collection.addField(fieldGroup, pu);
collection.addField(fieldGroup, summaryState, pu);
collection.addGroup( sched.getGroup2( "G1", 2 ), fieldGroup.name(), pu);
collection.addGroup( sched.getGroup2( "G2", 2 ), fieldGroup.name(), pu);
collection.addGroup( sched.getGroup2( "G1", 2 ), fieldGroup.name(), summaryState, pu);
collection.addGroup( sched.getGroup2( "G2", 2 ), fieldGroup.name(), summaryState, pu);
BOOST_CHECK_EQUAL("FIELD", collection.findNode("FIELD")->name());
BOOST_CHECK_EQUAL("FIELD", collection.findNode("G1")->getParent()->name());
@ -89,9 +89,9 @@ BOOST_AUTO_TEST_CASE(EfficiencyFactor) {
WellCollection collection;
// Add groups to WellCollection
const auto& fieldGroup = sched.getGroup2("FIELD", timestep);
collection.addField(fieldGroup, pu);
collection.addGroup( sched.getGroup2( "G1", timestep ), fieldGroup.name(), pu);
collection.addGroup( sched.getGroup2( "G2", timestep ), fieldGroup.name(), pu);
collection.addField( fieldGroup, summaryState, pu);
collection.addGroup( sched.getGroup2( "G1", timestep ), fieldGroup.name(), summaryState, pu);
collection.addGroup( sched.getGroup2( "G2", timestep ), fieldGroup.name(), summaryState, pu);
BOOST_CHECK_EQUAL(1.0, collection.findNode("FIELD")->efficiencyFactor());
BOOST_CHECK_EQUAL(1.0, collection.findNode("G1")->getParent()->efficiencyFactor());

View File

@ -89,14 +89,15 @@ BOOST_AUTO_TEST_CASE(ConstructGroupFromGroup) {
const Eclipse3DProperties eclipseProperties ( deck , table, grid);
const Opm::Runspec runspec (deck);
const Schedule sched(deck, grid, eclipseProperties, runspec);
SummaryState summaryState;
for( const auto& grp_name : sched.groupNames() ) {
const auto& group = sched.getGroup2(grp_name, 2);
std::shared_ptr<WellsGroupInterface> wellsGroup = createGroupWellsGroup(group, pu);
std::shared_ptr<WellsGroupInterface> wellsGroup = createGroupWellsGroup(group, summaryState, pu);
BOOST_CHECK_EQUAL(group.name(), wellsGroup->name());
if (group.isInjectionGroup()) {
const auto& injection = group.injectionProperties();
const auto& injection = group.injectionControls(summaryState);
BOOST_CHECK_EQUAL(injection.surface_max_rate, wellsGroup->injSpec().surface_flow_max_rate_);
BOOST_CHECK_EQUAL(injection.resv_max_rate, wellsGroup->injSpec().reservoir_flow_max_rate_);
@ -105,7 +106,7 @@ BOOST_AUTO_TEST_CASE(ConstructGroupFromGroup) {
}
if (group.isProductionGroup()) {
const auto& production = group.productionProperties();
const auto& production = group.productionControls(summaryState);
BOOST_CHECK_EQUAL(production.resv_target, wellsGroup->prodSpec().reservoir_flow_max_rate_);
BOOST_CHECK_EQUAL(production.gas_target, wellsGroup->prodSpec().gas_max_rate_);
BOOST_CHECK_EQUAL(production.oil_target, wellsGroup->prodSpec().oil_max_rate_);
@ -126,12 +127,12 @@ BOOST_AUTO_TEST_CASE(EfficiencyFactor) {
const Eclipse3DProperties eclipseProperties ( deck , table, grid);
const Opm::Runspec runspec (deck);
const Schedule sched(deck, grid, eclipseProperties, runspec);
SummaryState summaryState;
for( const auto& grp_name : sched.groupNames() ) {
const auto& group = sched.getGroup2(grp_name, 2);
std::shared_ptr<WellsGroupInterface> wellsGroup = createGroupWellsGroup(group, pu);
std::shared_ptr<WellsGroupInterface> wellsGroup = createGroupWellsGroup(group, summaryState, pu);
BOOST_CHECK_EQUAL(group.name(), wellsGroup->name());
BOOST_CHECK_EQUAL(group.getGroupEfficiencyFactor(), wellsGroup->efficiencyFactor());
BOOST_CHECK_EQUAL(group.getGroupEfficiencyFactor(), wellsGroup->efficiencyFactor());