Prepare for Creating Network-Level Summary Output

This commit adds a level of indirection to the existing group-level
data (active controls and guiderates), and adds a new 'NodeData'
level to the 'data::' protocol for transporting values from the
simulator to the output layer.

Update all call sites and users accordingly.
This commit is contained in:
Bård Skaflestad
2020-09-19 00:09:16 +02:00
parent ac40c65f64
commit 6ea0e73512
14 changed files with 237 additions and 184 deletions

View File

@@ -24,6 +24,7 @@
#include <map>
#include <stdexcept>
#include <string>
#include <utility>
#include <vector>
#include <opm/output/data/GuideRateValue.hpp>
@@ -105,34 +106,87 @@ namespace Opm { namespace data {
}
};
class GroupValues : public std::map<std::string, GroupData> {
public:
struct NodeData {
double pressure { 0.0 };
template <class MessageBufferType>
void write(MessageBufferType& buffer) const
{
unsigned int size = this->size();
buffer.write(size);
for (const auto& [gname, gdata] : *this) {
buffer.write(gname);
gdata .write(buffer);
}
buffer.write(this->pressure);
}
template <class MessageBufferType>
void read(MessageBufferType& buffer)
{
buffer.read(this->pressure);
}
bool operator==(const NodeData& other) const
{
return this->pressure == other.pressure;
}
};
class GroupAndNetworkValues {
public:
std::map<std::string, GroupData> groupData {};
std::map<std::string, NodeData> nodeData {};
template <class MessageBufferType>
void write(MessageBufferType& buffer) const
{
this->writeMap(this->groupData, buffer);
this->writeMap(this->nodeData, buffer);
}
template <class MessageBufferType>
void read(MessageBufferType& buffer)
{
this->readMap(buffer, this->groupData);
this->readMap(buffer, this->nodeData);
}
bool operator==(const GroupAndNetworkValues& other) const
{
return (this->groupData == other.groupData)
&& (this->nodeData == other.nodeData);
}
void clear()
{
this->groupData.clear();
this->nodeData.clear();
}
private:
template <class MessageBufferType, class ValueType>
void writeMap(const std::map<std::string, ValueType>& map,
MessageBufferType& buffer) const
{
const unsigned int size = map.size();
buffer.write(size);
for (const auto& [name, elm] : map) {
buffer.write(name);
elm .write(buffer);
}
}
template <class MessageBufferType, class ValueType>
void readMap(MessageBufferType& buffer,
std::map<std::string, ValueType>& map)
{
unsigned int size;
buffer.read(size);
for (size_t i = 0; i < size; ++i) {
for (std::size_t i = 0; i < size; ++i) {
std::string name;
buffer.read(name);
auto gdata = GroupData{};
gdata.read(buffer);
auto elm = ValueType{};
elm.read(buffer);
this->emplace(name, gdata);
map.emplace(name, std::move(elm));
}
}
};

View File

@@ -71,11 +71,11 @@ namespace Opm {
using ExtraVector = std::vector<std::pair<RestartKey, std::vector<double>>>;
data::Solution solution;
data::Wells wells;
data::GroupValues groups;
data::GroupAndNetworkValues grp_nwrk;
ExtraVector extra;
std::vector<data::AquiferData> aquifer;
RestartValue(data::Solution sol, data::Wells wells_arg, data::GroupValues groups_arg);
RestartValue(data::Solution sol, data::Wells wells_arg, data::GroupAndNetworkValues grpn_nwrk_arg);
RestartValue() {}
@@ -91,7 +91,7 @@ namespace Opm {
{
return solution == val2.solution &&
wells == val2.wells &&
groups == val2.groups &&
grp_nwrk == val2.grp_nwrk &&
extra == val2.extra;
}
};

View File

@@ -38,7 +38,7 @@ namespace Opm {
namespace Opm { namespace data {
class WellRates;
class GroupValues;
class GroupAndNetworkValues;
}} // namespace Opm::data
namespace Opm { namespace out {
@@ -59,16 +59,16 @@ public:
void add_timestep(const SummaryState& st, const int report_step);
void eval(SummaryState& summary_state,
const int report_step,
const double secs_elapsed,
const EclipseState& es,
const Schedule& schedule,
const data::WellRates& well_solution,
const data::GroupValues& group_solution,
GlobalProcessParameters single_values,
const RegionParameters& region_values = {},
const BlockValues& block_values = {}) const;
void eval(SummaryState& summary_state,
const int report_step,
const double secs_elapsed,
const EclipseState& es,
const Schedule& schedule,
const data::WellRates& well_solution,
const data::GroupAndNetworkValues& group_and_nwrk_solution,
GlobalProcessParameters single_values,
const RegionParameters& region_values = {},
const BlockValues& block_values = {}) const;
void write() const;