mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-01-21 07:52:57 -06:00
Merge pull request #1945 from joakim-hove/use-group2
Use class Group2 from opm-common
This commit is contained in:
commit
7f406921c4
@ -21,7 +21,7 @@
|
||||
#include <opm/core/wells/WellCollection.hpp>
|
||||
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/Well/Well2.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/Group/Group.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/Group/Group2.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/SummaryState.hpp>
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
@ -30,17 +30,17 @@
|
||||
|
||||
namespace Opm
|
||||
{
|
||||
void WellCollection::addField(const Group& fieldGroup, size_t timeStep, const PhaseUsage& phaseUsage) {
|
||||
void WellCollection::addField(const Group2& fieldGroup, 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, timeStep, phaseUsage));
|
||||
roots_.push_back(createGroupWellsGroup(fieldGroup, phaseUsage));
|
||||
}
|
||||
|
||||
void WellCollection::addGroup(const Group& groupChild, std::string parent_name,
|
||||
size_t timeStep, const PhaseUsage& phaseUsage) {
|
||||
void WellCollection::addGroup(const Group2& groupChild, std::string parent_name,
|
||||
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.");
|
||||
@ -51,11 +51,11 @@ namespace Opm
|
||||
|
||||
}
|
||||
|
||||
if (groupChild.isProductionGroup(timeStep) || groupChild.isInjectionGroup(timeStep)) {
|
||||
if (groupChild.isProductionGroup() || groupChild.isInjectionGroup()) {
|
||||
group_control_active_ = true;
|
||||
}
|
||||
|
||||
std::shared_ptr<WellsGroupInterface> child = createGroupWellsGroup(groupChild, timeStep, phaseUsage);
|
||||
std::shared_ptr<WellsGroupInterface> child = createGroupWellsGroup(groupChild, phaseUsage);
|
||||
|
||||
if (child->injSpec().control_mode_ == InjectionSpecification::VREP) {
|
||||
having_vrep_groups_ = true;
|
||||
@ -69,7 +69,7 @@ namespace Opm
|
||||
child->setParent(parent);
|
||||
}
|
||||
|
||||
void WellCollection::addWell(const Well2& wellChild, const SummaryState& summaryState, size_t timeStep, const PhaseUsage& phaseUsage) {
|
||||
void WellCollection::addWell(const Well2& wellChild, const SummaryState& summaryState, const PhaseUsage& phaseUsage) {
|
||||
if (wellChild.getStatus() == WellCommon::SHUT) {
|
||||
//SHUT wells are not added to the well collection
|
||||
return;
|
||||
@ -77,7 +77,7 @@ namespace Opm
|
||||
|
||||
WellsGroupInterface* parent = findNode(wellChild.groupName());
|
||||
if (!parent) {
|
||||
OPM_THROW(std::runtime_error, "Trying to add well " << wellChild.name() << " Step: " << boost::lexical_cast<std::string>(timeStep) << " to group named " << wellChild.groupName() << ", but this group does not exist in the WellCollection.");
|
||||
OPM_THROW(std::runtime_error, "Trying to add well " << wellChild.name() << " to group named " << wellChild.groupName() << ", but this group does not exist in the WellCollection.");
|
||||
}
|
||||
|
||||
std::shared_ptr<WellsGroupInterface> child = createWellWellsGroup(wellChild, summaryState, phaseUsage);
|
||||
|
@ -27,7 +27,7 @@
|
||||
#include <opm/core/props/phaseUsageFromDeck.hpp>
|
||||
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/Well/Well2.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/Group/Group.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/Group/Group2.hpp>
|
||||
|
||||
namespace Opm
|
||||
{
|
||||
@ -36,12 +36,12 @@ namespace Opm
|
||||
{
|
||||
public:
|
||||
|
||||
void addField(const Group& fieldGroup, size_t timeStep, const PhaseUsage& phaseUsage);
|
||||
void addField(const Group2& fieldGroup, const PhaseUsage& phaseUsage);
|
||||
|
||||
void addWell(const Well2& wellChild, const SummaryState& summaryState, size_t timeStep, const PhaseUsage& phaseUsage);
|
||||
void addWell(const Well2& wellChild, const SummaryState& summaryState, const PhaseUsage& phaseUsage);
|
||||
|
||||
void addGroup(const Group& groupChild, std::string parent_name,
|
||||
size_t timeStep, const PhaseUsage& phaseUsage);
|
||||
void addGroup(const Group2& groupChild, std::string parent_name,
|
||||
const PhaseUsage& phaseUsage);
|
||||
|
||||
/// Adds the child to the collection
|
||||
/// and appends it to parent's children.
|
||||
|
@ -1556,30 +1556,32 @@ namespace Opm
|
||||
}
|
||||
} // anonymous namespace
|
||||
|
||||
std::shared_ptr<WellsGroupInterface> createGroupWellsGroup(const Group& group, size_t timeStep, const PhaseUsage& phase_usage )
|
||||
std::shared_ptr<WellsGroupInterface> createGroupWellsGroup(const Group2& group, const PhaseUsage& phase_usage )
|
||||
{
|
||||
InjectionSpecification injection_specification;
|
||||
ProductionSpecification production_specification;
|
||||
if (group.isInjectionGroup(timeStep)) {
|
||||
injection_specification.injector_type_ = toInjectorType(group.getInjectionPhase(timeStep));
|
||||
injection_specification.control_mode_ = toInjectionControlMode(GroupInjection::ControlEnum2String(group.getInjectionControlMode(timeStep)));
|
||||
injection_specification.surface_flow_max_rate_ = group.getSurfaceMaxRate(timeStep);
|
||||
injection_specification.reservoir_flow_max_rate_ = group.getReservoirMaxRate(timeStep);
|
||||
injection_specification.reinjection_fraction_target_ = group.getTargetReinjectFraction(timeStep);
|
||||
injection_specification.voidage_replacment_fraction_ = group.getTargetVoidReplacementFraction(timeStep);
|
||||
if (group.isInjectionGroup()) {
|
||||
const auto& injection = group.injectionProperties();
|
||||
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;
|
||||
injection_specification.reservoir_flow_max_rate_ = injection.resv_max_rate;
|
||||
injection_specification.reinjection_fraction_target_ = injection.target_reinj_fraction;
|
||||
injection_specification.voidage_replacment_fraction_ = injection.target_void_fraction;
|
||||
}
|
||||
|
||||
if (group.isProductionGroup(timeStep)) {
|
||||
production_specification.oil_max_rate_ = group.getOilTargetRate(timeStep);
|
||||
production_specification.control_mode_ = toProductionControlMode(GroupProduction::ControlEnum2String(group.getProductionControlMode(timeStep)));
|
||||
production_specification.water_max_rate_ = group.getWaterTargetRate(timeStep);
|
||||
production_specification.gas_max_rate_ = group.getGasTargetRate(timeStep);
|
||||
production_specification.liquid_max_rate_ = group.getLiquidTargetRate(timeStep);
|
||||
production_specification.procedure_ = toProductionProcedure(GroupProductionExceedLimit::ActionEnum2String(group.getProductionExceedLimitAction(timeStep)));
|
||||
production_specification.reservoir_flow_max_rate_ = group.getReservoirVolumeTargetRate(timeStep);
|
||||
if (group.isProductionGroup()) {
|
||||
const auto& production = group.productionProperties();
|
||||
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;
|
||||
production_specification.gas_max_rate_ = production.gas_target;
|
||||
production_specification.liquid_max_rate_ = production.liquid_target;
|
||||
production_specification.procedure_ = toProductionProcedure(GroupProductionExceedLimit::ActionEnum2String(production.exceed_action));
|
||||
production_specification.reservoir_flow_max_rate_ = production.resv_target;
|
||||
}
|
||||
|
||||
const double efficiency_factor = group.getGroupEfficiencyFactor(timeStep);
|
||||
const double efficiency_factor = group.getGroupEfficiencyFactor();
|
||||
|
||||
std::shared_ptr<WellsGroupInterface> wells_group(new WellsGroup(group.name(), efficiency_factor, production_specification, injection_specification, phase_usage));
|
||||
return wells_group;
|
||||
|
@ -26,7 +26,7 @@
|
||||
#include <opm/core/props/BlackoilPhases.hpp>
|
||||
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/Well/Well2.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/Group/Group.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/Group/Group2.hpp>
|
||||
|
||||
#include <string>
|
||||
#include <memory>
|
||||
@ -549,7 +549,7 @@ namespace Opm
|
||||
/// \param[in] group the Group to construct object for
|
||||
/// \param[in] timeStep the time step in question
|
||||
/// \param[in] the phase usage
|
||||
std::shared_ptr<WellsGroupInterface> createGroupWellsGroup(const Group& group, size_t timeStep,
|
||||
std::shared_ptr<WellsGroupInterface> createGroupWellsGroup(const Group2& group,
|
||||
const PhaseUsage& phase_usage );
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,6 @@
|
||||
|
||||
#include <opm/core/wells/WellCollection.hpp>
|
||||
#include <opm/core/wells/WellsGroup.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/Group/GroupTree.hpp>
|
||||
|
||||
#include <opm/grid/utility/CompressedPropertyAccess.hpp>
|
||||
|
||||
|
@ -371,20 +371,16 @@ WellsManager::init(const Opm::EclipseState& eclipseState,
|
||||
setupWellControls(wells, summaryState, well_names, pu, wells_on_proc);
|
||||
|
||||
{
|
||||
const auto& fieldGroup = schedule.getGroup( "FIELD" );
|
||||
well_collection_.addField(fieldGroup, timeStep, pu);
|
||||
|
||||
const auto& grouptree = schedule.getGroupTree( timeStep );
|
||||
const auto& fieldGroup = schedule.getGroup2( "FIELD", timeStep);
|
||||
well_collection_.addField(fieldGroup, pu);
|
||||
std::vector< std::string > group_stack = { "FIELD" };
|
||||
|
||||
do {
|
||||
auto parent = group_stack.back();
|
||||
const auto& parent = schedule.getGroup2(group_stack.back(), timeStep);
|
||||
group_stack.pop_back();
|
||||
const auto& children = grouptree.children( parent );
|
||||
group_stack.insert( group_stack.end(), children.begin(), children.end() );
|
||||
|
||||
for( const auto& child : children ) {
|
||||
well_collection_.addGroup( schedule.getGroup( child ), parent, timeStep, pu );
|
||||
for (const auto& child: parent.groups()) {
|
||||
group_stack.push_back(child);
|
||||
well_collection_.addGroup( schedule.getGroup2( child, timeStep ), parent.name(), pu );
|
||||
}
|
||||
|
||||
} while( !group_stack.empty() );
|
||||
@ -393,7 +389,7 @@ WellsManager::init(const Opm::EclipseState& eclipseState,
|
||||
for (size_t i = 0; i < wells_on_proc.size(); ++i) {
|
||||
// wells_on_proc is a vector of flag to indicate whether a well is on the process
|
||||
if (wells_on_proc[i]) {
|
||||
well_collection_.addWell(wells[i], summaryState, timeStep, pu);
|
||||
well_collection_.addWell(wells[i], summaryState, pu);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -29,8 +29,7 @@
|
||||
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/Well/Well2.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/Group/Group.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/Group/GroupTree.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/Group/Group2.hpp>
|
||||
|
||||
using namespace Opm;
|
||||
|
||||
@ -50,11 +49,11 @@ BOOST_AUTO_TEST_CASE(AddWellsAndGroupToCollection) {
|
||||
WellCollection collection;
|
||||
|
||||
// Add groups to WellCollection
|
||||
const auto& fieldGroup = sched.getGroup("FIELD");
|
||||
collection.addField(fieldGroup, 2, pu);
|
||||
const auto& fieldGroup = sched.getGroup2("FIELD", 2);
|
||||
collection.addField(fieldGroup, pu);
|
||||
|
||||
collection.addGroup( sched.getGroup( "G1" ), fieldGroup.name(), 2, pu);
|
||||
collection.addGroup( sched.getGroup( "G2" ), fieldGroup.name(), 2, pu);
|
||||
collection.addGroup( sched.getGroup2( "G1", 2 ), fieldGroup.name(), pu);
|
||||
collection.addGroup( sched.getGroup2( "G2", 2 ), fieldGroup.name(), pu);
|
||||
|
||||
BOOST_CHECK_EQUAL("FIELD", collection.findNode("FIELD")->name());
|
||||
BOOST_CHECK_EQUAL("FIELD", collection.findNode("G1")->getParent()->name());
|
||||
@ -64,7 +63,7 @@ BOOST_AUTO_TEST_CASE(AddWellsAndGroupToCollection) {
|
||||
WellCollection wellCollection;
|
||||
const auto wells = sched.getWells2atEnd();
|
||||
for (size_t i=0; i<wells.size(); i++) {
|
||||
collection.addWell(wells[i], summaryState, 2, pu);
|
||||
collection.addWell(wells[i], summaryState, pu);
|
||||
}
|
||||
|
||||
BOOST_CHECK_EQUAL("G1", collection.findNode("INJ1")->getParent()->name());
|
||||
@ -89,10 +88,10 @@ BOOST_AUTO_TEST_CASE(EfficiencyFactor) {
|
||||
size_t timestep = 2;
|
||||
WellCollection collection;
|
||||
// Add groups to WellCollection
|
||||
const auto& fieldGroup = sched.getGroup("FIELD");
|
||||
collection.addField(fieldGroup, timestep, pu);
|
||||
collection.addGroup( sched.getGroup( "G1" ), fieldGroup.name(), timestep, pu);
|
||||
collection.addGroup( sched.getGroup( "G2" ), fieldGroup.name(), timestep, pu);
|
||||
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);
|
||||
|
||||
BOOST_CHECK_EQUAL(1.0, collection.findNode("FIELD")->efficiencyFactor());
|
||||
BOOST_CHECK_EQUAL(1.0, collection.findNode("G1")->getParent()->efficiencyFactor());
|
||||
@ -101,7 +100,7 @@ BOOST_AUTO_TEST_CASE(EfficiencyFactor) {
|
||||
// Add wells to WellCollection
|
||||
const auto wells1 = sched.getWells2(timestep);
|
||||
for (size_t i=0; i<wells1.size(); i++) {
|
||||
collection.addWell(wells1[i], summaryState, timestep, pu);
|
||||
collection.addWell(wells1[i], summaryState, pu);
|
||||
}
|
||||
|
||||
// 0.5(inj1) * 0.8(G1)
|
||||
|
@ -33,9 +33,7 @@
|
||||
#include <opm/core/wells/WellsGroup.hpp>
|
||||
|
||||
#include <opm/parser/eclipse/Parser/Parser.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/Group/Group.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/Group/GroupTree.hpp>
|
||||
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/Group/Group2.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/Well/Well2.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
|
||||
@ -92,27 +90,27 @@ BOOST_AUTO_TEST_CASE(ConstructGroupFromGroup) {
|
||||
const Opm::Runspec runspec (deck);
|
||||
const Schedule sched(deck, grid, eclipseProperties, runspec);
|
||||
|
||||
|
||||
const auto& nodes = sched.getGroupTree(2);
|
||||
|
||||
for( const auto& grp_name : sched.groupNames() ) {
|
||||
if( !nodes.exists( grp_name ) ) continue;
|
||||
const auto& group = sched.getGroup(grp_name);
|
||||
const auto& group = sched.getGroup2(grp_name, 2);
|
||||
|
||||
std::shared_ptr<WellsGroupInterface> wellsGroup = createGroupWellsGroup(group, 2, pu);
|
||||
std::shared_ptr<WellsGroupInterface> wellsGroup = createGroupWellsGroup(group, pu);
|
||||
BOOST_CHECK_EQUAL(group.name(), wellsGroup->name());
|
||||
if (group.isInjectionGroup(2)) {
|
||||
BOOST_CHECK_EQUAL(group.getSurfaceMaxRate(2), wellsGroup->injSpec().surface_flow_max_rate_);
|
||||
BOOST_CHECK_EQUAL(group.getReservoirMaxRate(2), wellsGroup->injSpec().reservoir_flow_max_rate_);
|
||||
BOOST_CHECK_EQUAL(group.getTargetReinjectFraction(2), wellsGroup->injSpec().reinjection_fraction_target_);
|
||||
BOOST_CHECK_EQUAL(group.getTargetVoidReplacementFraction(2), wellsGroup->injSpec().voidage_replacment_fraction_);
|
||||
if (group.isInjectionGroup()) {
|
||||
const auto& injection = group.injectionProperties();
|
||||
|
||||
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_);
|
||||
BOOST_CHECK_EQUAL(injection.target_reinj_fraction, wellsGroup->injSpec().reinjection_fraction_target_);
|
||||
BOOST_CHECK_EQUAL(injection.target_void_fraction, wellsGroup->injSpec().voidage_replacment_fraction_);
|
||||
}
|
||||
if (group.isProductionGroup(2)) {
|
||||
BOOST_CHECK_EQUAL(group.getReservoirVolumeTargetRate(2), wellsGroup->prodSpec().reservoir_flow_max_rate_);
|
||||
BOOST_CHECK_EQUAL(group.getGasTargetRate(2), wellsGroup->prodSpec().gas_max_rate_);
|
||||
BOOST_CHECK_EQUAL(group.getOilTargetRate(2), wellsGroup->prodSpec().oil_max_rate_);
|
||||
BOOST_CHECK_EQUAL(group.getWaterTargetRate(2), wellsGroup->prodSpec().water_max_rate_);
|
||||
BOOST_CHECK_EQUAL(group.getLiquidTargetRate(2), wellsGroup->prodSpec().liquid_max_rate_);
|
||||
|
||||
if (group.isProductionGroup()) {
|
||||
const auto& production = group.productionProperties();
|
||||
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_);
|
||||
BOOST_CHECK_EQUAL(production.water_target, wellsGroup->prodSpec().water_max_rate_);
|
||||
BOOST_CHECK_EQUAL(production.liquid_target, wellsGroup->prodSpec().liquid_max_rate_);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -130,15 +128,13 @@ BOOST_AUTO_TEST_CASE(EfficiencyFactor) {
|
||||
const Schedule sched(deck, grid, eclipseProperties, runspec);
|
||||
|
||||
|
||||
const auto& nodes = sched.getGroupTree(2);
|
||||
for( const auto& grp_name : sched.groupNames() ) {
|
||||
if( !nodes.exists( grp_name ) ) continue;
|
||||
const auto& group = sched.getGroup(grp_name);
|
||||
const auto& group = sched.getGroup2(grp_name, 2);
|
||||
|
||||
std::shared_ptr<WellsGroupInterface> wellsGroup = createGroupWellsGroup(group, 2, pu);
|
||||
std::shared_ptr<WellsGroupInterface> wellsGroup = createGroupWellsGroup(group, pu);
|
||||
BOOST_CHECK_EQUAL(group.name(), wellsGroup->name());
|
||||
BOOST_CHECK_EQUAL(group.getGroupEfficiencyFactor(2), wellsGroup->efficiencyFactor());
|
||||
BOOST_CHECK_EQUAL(group.getGroupEfficiencyFactor(2), wellsGroup->efficiencyFactor());
|
||||
BOOST_CHECK_EQUAL(group.getGroupEfficiencyFactor(), wellsGroup->efficiencyFactor());
|
||||
BOOST_CHECK_EQUAL(group.getGroupEfficiencyFactor(), wellsGroup->efficiencyFactor());
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user