Merge pull request #3702 from vkip/network_multi_root
Support networks with multiple fixed-pressure nodes
This commit is contained in:
commit
d94edc0723
@ -25,6 +25,7 @@
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <functional>
|
||||
|
||||
#include <opm/input/eclipse/Schedule/Network/Branch.hpp>
|
||||
#include <opm/input/eclipse/Schedule/Network/Node.hpp>
|
||||
@ -45,7 +46,7 @@ public:
|
||||
bool has_node(const std::string& name) const;
|
||||
void update_node(Node node);
|
||||
const Node& node(const std::string& name) const;
|
||||
const Node& root() const;
|
||||
std::vector<std::reference_wrapper<const Node>> roots() const;
|
||||
std::vector<Branch> downtree_branches(const std::string& node) const;
|
||||
std::vector<const Branch*> branches() const;
|
||||
std::optional<Branch> uptree_branch(const std::string& node) const;
|
||||
|
@ -878,14 +878,14 @@ File {} line {}.)", wname, location.keyword, location.filename, location.lineno)
|
||||
const bool is_terminal_node = pressure_item.hasValue(0) && (pressure_item.get<double>(0) >= 0);
|
||||
if (is_terminal_node) {
|
||||
if (vfp_table > 0) {
|
||||
std::string msg = fmt::format("The group {} is a terminal node of the network and should not have a vfp table assigned to it.", group_name);
|
||||
throw OpmInputError(msg, handlerContext.keyword.location());
|
||||
std::string msg = fmt::format("The group {} is a terminal node of the network and should not have a vfp table assigned to it. This vfp table will be ignored.", group_name);
|
||||
OpmLog::warning(OpmInputError::format(msg, handlerContext.keyword.location()));
|
||||
}
|
||||
node.terminal_pressure(pressure_item.getSIDouble(0));
|
||||
nodes.push_back(node);
|
||||
// Remove the branch upstream if it was part of the network
|
||||
if (network.has_node(downtree_node) && network.has_node(uptree_node))
|
||||
network.drop_branch(uptree_node, downtree_node);
|
||||
// Need to add the flow further up the network in case of other fixed-pressure nodes
|
||||
if (!uptree_node.empty())
|
||||
network.add_or_replace_branch(Network::Branch(downtree_node, uptree_node, 9999, 0.0));
|
||||
} else {
|
||||
if (vfp_table <= 0) {
|
||||
// If vfp table is defaulted (or set to <=0) then the group is not part of the network.
|
||||
|
@ -20,6 +20,8 @@
|
||||
#include <iterator>
|
||||
#include <stdexcept>
|
||||
#include <fmt/format.h>
|
||||
#include <vector>
|
||||
#include <functional>
|
||||
|
||||
#include <opm/input/eclipse/Schedule/Network/ExtNetwork.hpp>
|
||||
|
||||
@ -67,20 +69,18 @@ const Node& ExtNetwork::node(const std::string& name) const {
|
||||
}
|
||||
|
||||
|
||||
const Node& ExtNetwork::root() const {
|
||||
std::vector<std::reference_wrapper<const Node>> ExtNetwork::roots() const {
|
||||
if (this->m_nodes.empty())
|
||||
throw std::invalid_argument("No root defined for empty network");
|
||||
|
||||
auto node_ptr = &(this->m_nodes.begin()->second);
|
||||
while (true) {
|
||||
auto next_branch = this->uptree_branch(node_ptr->name());
|
||||
if (!next_branch)
|
||||
break;
|
||||
|
||||
node_ptr = &(this->node( next_branch->uptree_node() ));
|
||||
std::vector<std::reference_wrapper<const Node>> root_vector;
|
||||
// Roots are defined as uptree nodes of a branch with a fixed pressure
|
||||
for (const auto& branch : this->m_branches) {
|
||||
const auto& node = this->node( branch.uptree_node() );
|
||||
if (node.terminal_pressure().has_value()) root_vector.push_back(node);
|
||||
}
|
||||
|
||||
return *node_ptr;
|
||||
return root_vector;
|
||||
}
|
||||
|
||||
void ExtNetwork::add_branch(Branch branch)
|
||||
|
@ -222,7 +222,7 @@ BRANPROP
|
||||
const auto& p = network.node("PLAT-A");
|
||||
BOOST_CHECK(p.terminal_pressure());
|
||||
BOOST_CHECK_EQUAL(p.terminal_pressure().value(), 21 * 100000);
|
||||
BOOST_CHECK(p == network.root());
|
||||
BOOST_CHECK(p == network.roots()[0]);
|
||||
|
||||
BOOST_CHECK_THROW(network.node("NO_SUCH_NODE"), std::out_of_range);
|
||||
|
||||
@ -411,5 +411,5 @@ GRUPNET
|
||||
const auto& p = network.node("PLAT-A");
|
||||
BOOST_CHECK(p.terminal_pressure());
|
||||
BOOST_CHECK_EQUAL(p.terminal_pressure().value(), 21 * 100000);
|
||||
BOOST_CHECK(p == network.root());
|
||||
BOOST_CHECK(p == network.roots()[0]);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user