Support networks with multiple fixed-pressure nodes
This commit is contained in:
parent
f77a337084
commit
97b5bc6209
@ -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,8 @@ 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;
|
||||
bool is_disconnected(const std::string& node) 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;
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user