mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Remove use of GroupTree from opm-common
This commit is contained in:
parent
2a1d42edcb
commit
63e55bfa8f
@ -30,17 +30,17 @@
|
|||||||
|
|
||||||
namespace Opm
|
namespace Opm
|
||||||
{
|
{
|
||||||
void WellCollection::addField(const Group2& fieldGroup, size_t timeStep, const PhaseUsage& phaseUsage) {
|
void WellCollection::addField(const Group2& fieldGroup, const PhaseUsage& phaseUsage) {
|
||||||
WellsGroupInterface* fieldNode = findNode(fieldGroup.name());
|
WellsGroupInterface* fieldNode = findNode(fieldGroup.name());
|
||||||
if (fieldNode) {
|
if (fieldNode) {
|
||||||
OPM_THROW(std::runtime_error, "Trying to add FIELD node, but this already exists. Can only have one FIELD node.");
|
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 Group2& groupChild, std::string parent_name,
|
void WellCollection::addGroup(const Group2& groupChild, std::string parent_name,
|
||||||
size_t timeStep, const PhaseUsage& phaseUsage) {
|
const PhaseUsage& phaseUsage) {
|
||||||
WellsGroupInterface* parent = findNode(parent_name);
|
WellsGroupInterface* parent = findNode(parent_name);
|
||||||
if (!parent) {
|
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.");
|
OPM_THROW(std::runtime_error, "Trying to add child group to group named " << parent_name << ", but this does not exist in the WellCollection.");
|
||||||
@ -55,7 +55,7 @@ namespace Opm
|
|||||||
group_control_active_ = true;
|
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) {
|
if (child->injSpec().control_mode_ == InjectionSpecification::VREP) {
|
||||||
having_vrep_groups_ = true;
|
having_vrep_groups_ = true;
|
||||||
@ -69,7 +69,7 @@ namespace Opm
|
|||||||
child->setParent(parent);
|
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) {
|
if (wellChild.getStatus() == WellCommon::SHUT) {
|
||||||
//SHUT wells are not added to the well collection
|
//SHUT wells are not added to the well collection
|
||||||
return;
|
return;
|
||||||
@ -77,7 +77,7 @@ namespace Opm
|
|||||||
|
|
||||||
WellsGroupInterface* parent = findNode(wellChild.groupName());
|
WellsGroupInterface* parent = findNode(wellChild.groupName());
|
||||||
if (!parent) {
|
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);
|
std::shared_ptr<WellsGroupInterface> child = createWellWellsGroup(wellChild, summaryState, phaseUsage);
|
||||||
|
@ -36,12 +36,12 @@ namespace Opm
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
void addField(const Group2& 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 Group2& groupChild, std::string parent_name,
|
void addGroup(const Group2& groupChild, std::string parent_name,
|
||||||
size_t timeStep, const PhaseUsage& phaseUsage);
|
const PhaseUsage& phaseUsage);
|
||||||
|
|
||||||
/// Adds the child to the collection
|
/// Adds the child to the collection
|
||||||
/// and appends it to parent's children.
|
/// and appends it to parent's children.
|
||||||
|
@ -1556,7 +1556,7 @@ namespace Opm
|
|||||||
}
|
}
|
||||||
} // anonymous namespace
|
} // anonymous namespace
|
||||||
|
|
||||||
std::shared_ptr<WellsGroupInterface> createGroupWellsGroup(const Group2& group, size_t timeStep, const PhaseUsage& phase_usage )
|
std::shared_ptr<WellsGroupInterface> createGroupWellsGroup(const Group2& group, const PhaseUsage& phase_usage )
|
||||||
{
|
{
|
||||||
InjectionSpecification injection_specification;
|
InjectionSpecification injection_specification;
|
||||||
ProductionSpecification production_specification;
|
ProductionSpecification production_specification;
|
||||||
|
@ -549,7 +549,7 @@ namespace Opm
|
|||||||
/// \param[in] group the Group to construct object for
|
/// \param[in] group the Group to construct object for
|
||||||
/// \param[in] timeStep the time step in question
|
/// \param[in] timeStep the time step in question
|
||||||
/// \param[in] the phase usage
|
/// \param[in] the phase usage
|
||||||
std::shared_ptr<WellsGroupInterface> createGroupWellsGroup(const Group2& group, size_t timeStep,
|
std::shared_ptr<WellsGroupInterface> createGroupWellsGroup(const Group2& group,
|
||||||
const PhaseUsage& phase_usage );
|
const PhaseUsage& phase_usage );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,7 +26,6 @@
|
|||||||
|
|
||||||
#include <opm/core/wells/WellCollection.hpp>
|
#include <opm/core/wells/WellCollection.hpp>
|
||||||
#include <opm/core/wells/WellsGroup.hpp>
|
#include <opm/core/wells/WellsGroup.hpp>
|
||||||
#include <opm/parser/eclipse/EclipseState/Schedule/Group/GroupTree.hpp>
|
|
||||||
|
|
||||||
#include <opm/grid/utility/CompressedPropertyAccess.hpp>
|
#include <opm/grid/utility/CompressedPropertyAccess.hpp>
|
||||||
|
|
||||||
|
@ -372,19 +372,15 @@ WellsManager::init(const Opm::EclipseState& eclipseState,
|
|||||||
|
|
||||||
{
|
{
|
||||||
const auto& fieldGroup = schedule.getGroup2( "FIELD", timeStep);
|
const auto& fieldGroup = schedule.getGroup2( "FIELD", timeStep);
|
||||||
well_collection_.addField(fieldGroup, timeStep, pu);
|
well_collection_.addField(fieldGroup, pu);
|
||||||
|
|
||||||
const auto& grouptree = schedule.getGroupTree( timeStep );
|
|
||||||
std::vector< std::string > group_stack = { "FIELD" };
|
std::vector< std::string > group_stack = { "FIELD" };
|
||||||
|
|
||||||
do {
|
do {
|
||||||
auto parent = group_stack.back();
|
const auto& parent = schedule.getGroup2(group_stack.back(), timeStep);
|
||||||
group_stack.pop_back();
|
group_stack.pop_back();
|
||||||
const auto& children = grouptree.children( parent );
|
for (const auto& child: parent.groups()) {
|
||||||
group_stack.insert( group_stack.end(), children.begin(), children.end() );
|
group_stack.push_back(child);
|
||||||
|
well_collection_.addGroup( schedule.getGroup2( child, timeStep ), parent.name(), pu );
|
||||||
for( const auto& child : children ) {
|
|
||||||
well_collection_.addGroup( schedule.getGroup2( child, timeStep ), parent, timeStep, pu );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} while( !group_stack.empty() );
|
} 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) {
|
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
|
// wells_on_proc is a vector of flag to indicate whether a well is on the process
|
||||||
if (wells_on_proc[i]) {
|
if (wells_on_proc[i]) {
|
||||||
well_collection_.addWell(wells[i], summaryState, timeStep, pu);
|
well_collection_.addWell(wells[i], summaryState, pu);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,7 +30,6 @@
|
|||||||
#include <opm/parser/eclipse/EclipseState/Schedule/Well/Well2.hpp>
|
#include <opm/parser/eclipse/EclipseState/Schedule/Well/Well2.hpp>
|
||||||
#include <opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp>
|
#include <opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp>
|
||||||
#include <opm/parser/eclipse/EclipseState/Schedule/Group/Group2.hpp>
|
#include <opm/parser/eclipse/EclipseState/Schedule/Group/Group2.hpp>
|
||||||
#include <opm/parser/eclipse/EclipseState/Schedule/Group/GroupTree.hpp>
|
|
||||||
|
|
||||||
using namespace Opm;
|
using namespace Opm;
|
||||||
|
|
||||||
@ -51,10 +50,10 @@ BOOST_AUTO_TEST_CASE(AddWellsAndGroupToCollection) {
|
|||||||
|
|
||||||
// Add groups to WellCollection
|
// Add groups to WellCollection
|
||||||
const auto& fieldGroup = sched.getGroup2("FIELD", 2);
|
const auto& fieldGroup = sched.getGroup2("FIELD", 2);
|
||||||
collection.addField(fieldGroup, 2, pu);
|
collection.addField(fieldGroup, pu);
|
||||||
|
|
||||||
collection.addGroup( sched.getGroup2( "G1", 2 ), fieldGroup.name(), 2, pu);
|
collection.addGroup( sched.getGroup2( "G1", 2 ), fieldGroup.name(), pu);
|
||||||
collection.addGroup( sched.getGroup2( "G2", 2 ), fieldGroup.name(), 2, pu);
|
collection.addGroup( sched.getGroup2( "G2", 2 ), fieldGroup.name(), pu);
|
||||||
|
|
||||||
BOOST_CHECK_EQUAL("FIELD", collection.findNode("FIELD")->name());
|
BOOST_CHECK_EQUAL("FIELD", collection.findNode("FIELD")->name());
|
||||||
BOOST_CHECK_EQUAL("FIELD", collection.findNode("G1")->getParent()->name());
|
BOOST_CHECK_EQUAL("FIELD", collection.findNode("G1")->getParent()->name());
|
||||||
@ -64,7 +63,7 @@ BOOST_AUTO_TEST_CASE(AddWellsAndGroupToCollection) {
|
|||||||
WellCollection wellCollection;
|
WellCollection wellCollection;
|
||||||
const auto wells = sched.getWells2atEnd();
|
const auto wells = sched.getWells2atEnd();
|
||||||
for (size_t i=0; i<wells.size(); i++) {
|
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());
|
BOOST_CHECK_EQUAL("G1", collection.findNode("INJ1")->getParent()->name());
|
||||||
@ -90,9 +89,9 @@ BOOST_AUTO_TEST_CASE(EfficiencyFactor) {
|
|||||||
WellCollection collection;
|
WellCollection collection;
|
||||||
// Add groups to WellCollection
|
// Add groups to WellCollection
|
||||||
const auto& fieldGroup = sched.getGroup2("FIELD", timestep);
|
const auto& fieldGroup = sched.getGroup2("FIELD", timestep);
|
||||||
collection.addField(fieldGroup, timestep, pu);
|
collection.addField(fieldGroup, pu);
|
||||||
collection.addGroup( sched.getGroup2( "G1", timestep ), fieldGroup.name(), timestep, pu);
|
collection.addGroup( sched.getGroup2( "G1", timestep ), fieldGroup.name(), pu);
|
||||||
collection.addGroup( sched.getGroup2( "G2", timestep ), fieldGroup.name(), timestep, 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("FIELD")->efficiencyFactor());
|
||||||
BOOST_CHECK_EQUAL(1.0, collection.findNode("G1")->getParent()->efficiencyFactor());
|
BOOST_CHECK_EQUAL(1.0, collection.findNode("G1")->getParent()->efficiencyFactor());
|
||||||
@ -101,7 +100,7 @@ BOOST_AUTO_TEST_CASE(EfficiencyFactor) {
|
|||||||
// Add wells to WellCollection
|
// Add wells to WellCollection
|
||||||
const auto wells1 = sched.getWells2(timestep);
|
const auto wells1 = sched.getWells2(timestep);
|
||||||
for (size_t i=0; i<wells1.size(); i++) {
|
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)
|
// 0.5(inj1) * 0.8(G1)
|
||||||
|
@ -34,8 +34,6 @@
|
|||||||
|
|
||||||
#include <opm/parser/eclipse/Parser/Parser.hpp>
|
#include <opm/parser/eclipse/Parser/Parser.hpp>
|
||||||
#include <opm/parser/eclipse/EclipseState/Schedule/Group/Group2.hpp>
|
#include <opm/parser/eclipse/EclipseState/Schedule/Group/Group2.hpp>
|
||||||
#include <opm/parser/eclipse/EclipseState/Schedule/Group/GroupTree.hpp>
|
|
||||||
|
|
||||||
#include <opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp>
|
#include <opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp>
|
||||||
#include <opm/parser/eclipse/EclipseState/Schedule/Well/Well2.hpp>
|
#include <opm/parser/eclipse/EclipseState/Schedule/Well/Well2.hpp>
|
||||||
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
|
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
|
||||||
@ -92,14 +90,10 @@ BOOST_AUTO_TEST_CASE(ConstructGroupFromGroup) {
|
|||||||
const Opm::Runspec runspec (deck);
|
const Opm::Runspec runspec (deck);
|
||||||
const Schedule sched(deck, grid, eclipseProperties, runspec);
|
const Schedule sched(deck, grid, eclipseProperties, runspec);
|
||||||
|
|
||||||
|
|
||||||
const auto& nodes = sched.getGroupTree(2);
|
|
||||||
|
|
||||||
for( const auto& grp_name : sched.groupNames() ) {
|
for( const auto& grp_name : sched.groupNames() ) {
|
||||||
if( !nodes.exists( grp_name ) ) continue;
|
|
||||||
const auto& group = sched.getGroup2(grp_name, 2);
|
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.name(), wellsGroup->name());
|
||||||
if (group.isInjectionGroup()) {
|
if (group.isInjectionGroup()) {
|
||||||
const auto& injection = group.injectionProperties();
|
const auto& injection = group.injectionProperties();
|
||||||
@ -134,12 +128,10 @@ BOOST_AUTO_TEST_CASE(EfficiencyFactor) {
|
|||||||
const Schedule sched(deck, grid, eclipseProperties, runspec);
|
const Schedule sched(deck, grid, eclipseProperties, runspec);
|
||||||
|
|
||||||
|
|
||||||
const auto& nodes = sched.getGroupTree(2);
|
|
||||||
for( const auto& grp_name : sched.groupNames() ) {
|
for( const auto& grp_name : sched.groupNames() ) {
|
||||||
if( !nodes.exists( grp_name ) ) continue;
|
|
||||||
const auto& group = sched.getGroup2(grp_name, 2);
|
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.name(), wellsGroup->name());
|
||||||
BOOST_CHECK_EQUAL(group.getGroupEfficiencyFactor(), wellsGroup->efficiencyFactor());
|
BOOST_CHECK_EQUAL(group.getGroupEfficiencyFactor(), wellsGroup->efficiencyFactor());
|
||||||
BOOST_CHECK_EQUAL(group.getGroupEfficiencyFactor(), wellsGroup->efficiencyFactor());
|
BOOST_CHECK_EQUAL(group.getGroupEfficiencyFactor(), wellsGroup->efficiencyFactor());
|
||||||
|
Loading…
Reference in New Issue
Block a user