22#ifndef OPM_OUTPUT_DATA_INTERREGFLOWMAP_HPP
23#define OPM_OUTPUT_DATA_INTERREGFLOWMAP_HPP
25#include <opm/output/data/InterRegFlow.hpp>
42namespace Opm {
namespace data {
50 using Neighbours = std::vector<int>;
53 using Offset = Neighbours::size_type;
56 using Start = std::vector<Offset>;
59 using RateBuffer = std::vector<float>;
62 using Window = InterRegFlow<RateBuffer::iterator>;
115 std::optional<std::pair<ReadOnlyWindow, ReadOnlyWindow::ElmT>>
119 template <
class MessageBufferType>
120 void write(MessageBufferType& buffer)
const
122 this->connections_.write(buffer);
123 this->writeVector(this->rates_, buffer);
127 template <
class MessageBufferType>
128 void read(MessageBufferType& buffer)
130 this->connections_.read(buffer);
132 auto rates = RateBuffer{};
133 this->readVector(buffer, rates);
134 this->appendRates(rates);
142 using Graph = utility::CSRGraphFromCoordinates<int, true>;
144 Graph connections_{};
147 template <
typename T,
class A,
class MessageBufferType>
148 void writeVector(
const std::vector<T,A>& vec,
149 MessageBufferType& buffer)
const
151 const auto n = vec.size();
154 for (
const auto& x : vec) {
159 template <
typename T,
class A,
class MessageBufferType>
160 void readVector(MessageBufferType& buffer,
161 std::vector<T,A>& vec)
163 auto n = 0 * vec.size();
168 for (
auto& x : vec) {
173 template <
typename Rates>
174 void appendRates(
const Rates& rates)
176 this->rates_.insert(this->rates_.end(), rates.begin(), rates.end());
Facility for converting collection of region ID pairs into a sparse (CSR) adjacency matrix representa...
Form CSR adjacency matrix representation of inter-region flow rate graph provided as a list of connec...
Definition InterRegFlowMap.hpp:47
Offset numRegions() const
Retrieve number of rows (source entities) in input graph.
Definition InterRegFlowMap.cpp:113
void compress(const std::size_t numRegions)
Form CSR adjacency matrix representation of input graph from connections established in previous call...
Definition InterRegFlowMap.cpp:76
void clear()
Clear all internal buffers, but preserve allocated capacity.
Definition InterRegFlowMap.cpp:170
void addConnection(const int r1, const int r2, const FlowRates &rates)
Add flow rate connection between regions.
Definition InterRegFlowMap.cpp:44
Window::Component Component
Client type through which to identify a component flow of a single inter-region connection.
Definition InterRegFlowMap.hpp:73
std::optional< std::pair< ReadOnlyWindow, ReadOnlyWindow::ElmT > > getInterRegFlows(const int r1, const int r2) const
Retrieve accumulated inter-region flow rates for identified pair of regions.
Definition InterRegFlowMap.cpp:122
Window::FlowRates FlowRates
Client type through which to define a single inter-region connection.
Definition InterRegFlowMap.hpp:69
InterRegFlow< std::vector< float >::const_iterator > ReadOnlyWindow
Client view of flows between specified region pair.
Definition InterRegFlowMap.hpp:66
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30