Use std::optional<std::string> for fip_region member
This commit is contained in:
parent
0f28d7c199
commit
e613a7c31d
@ -56,7 +56,8 @@ struct SummaryNode {
|
|||||||
Type type;
|
Type type;
|
||||||
std::string wgname;
|
std::string wgname;
|
||||||
int number;
|
int number;
|
||||||
std::string fip_region;
|
|
||||||
|
std::optional<std::string> fip_region;
|
||||||
|
|
||||||
constexpr static int default_number { std::numeric_limits<int>::min() };
|
constexpr static int default_number { std::numeric_limits<int>::min() };
|
||||||
|
|
||||||
|
@ -22,10 +22,12 @@
|
|||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
#include <optional>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
|
||||||
#include <opm/io/eclipse/SummaryNode.hpp>
|
#include <opm/io/eclipse/SummaryNode.hpp>
|
||||||
#include <opm/common/OpmLog/KeywordLocation.hpp>
|
#include <opm/common/OpmLog/KeywordLocation.hpp>
|
||||||
|
|
||||||
@ -59,7 +61,7 @@ namespace Opm {
|
|||||||
const std::string& namedEntity() const { return this->name_; }
|
const std::string& namedEntity() const { return this->name_; }
|
||||||
int number() const { return this->number_; }
|
int number() const { return this->number_; }
|
||||||
bool isUserDefined() const { return this->userDefined_; }
|
bool isUserDefined() const { return this->userDefined_; }
|
||||||
const std::string& fip_region() const { return this->fip_region_; }
|
const std::string& fip_region() const { return *this->fip_region_ ; }
|
||||||
|
|
||||||
std::string uniqueNodeKey() const;
|
std::string uniqueNodeKey() const;
|
||||||
const KeywordLocation& location( ) const { return this->loc; }
|
const KeywordLocation& location( ) const { return this->loc; }
|
||||||
@ -88,7 +90,7 @@ namespace Opm {
|
|||||||
Type type_{ Type::Undefined };
|
Type type_{ Type::Undefined };
|
||||||
std::string name_{};
|
std::string name_{};
|
||||||
int number_{std::numeric_limits<int>::min()};
|
int number_{std::numeric_limits<int>::min()};
|
||||||
std::string fip_region_;
|
std::optional<std::string> fip_region_;
|
||||||
bool userDefined_{false};
|
bool userDefined_{false};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -398,7 +398,7 @@ struct fn_args {
|
|||||||
double duration;
|
double duration;
|
||||||
const int sim_step;
|
const int sim_step;
|
||||||
int num;
|
int num;
|
||||||
const std::string fip_region;
|
const std::optional<std::variant<std::string, int>> extra_data;
|
||||||
const Opm::SummaryState& st;
|
const Opm::SummaryState& st;
|
||||||
const Opm::data::Wells& wells;
|
const Opm::data::Wells& wells;
|
||||||
const Opm::data::GroupAndNetworkValues& grp_nwrk;
|
const Opm::data::GroupAndNetworkValues& grp_nwrk;
|
||||||
@ -783,7 +783,7 @@ inline quantity duration( const fn_args& args ) {
|
|||||||
template<rt phase , bool injection>
|
template<rt phase , bool injection>
|
||||||
quantity region_rate( const fn_args& args ) {
|
quantity region_rate( const fn_args& args ) {
|
||||||
double sum = 0;
|
double sum = 0;
|
||||||
const auto& well_connections = args.regionCache.connections( args.fip_region, args.num );
|
const auto& well_connections = args.regionCache.connections( std::get<std::string>(*args.extra_data), args.num );
|
||||||
|
|
||||||
for (const auto& pair : well_connections) {
|
for (const auto& pair : well_connections) {
|
||||||
|
|
||||||
@ -1522,7 +1522,7 @@ inline std::vector<Opm::Well> find_wells( const Opm::Schedule& schedule,
|
|||||||
|
|
||||||
const auto region = node.number;
|
const auto region = node.number;
|
||||||
|
|
||||||
for ( const auto& connection : regionCache.connections( node.fip_region, region ) ){
|
for ( const auto& connection : regionCache.connections( *node.fip_region , region ) ){
|
||||||
const auto& w_name = connection.first;
|
const auto& w_name = connection.first;
|
||||||
if (schedule.hasWell(w_name, sim_step)) {
|
if (schedule.hasWell(w_name, sim_step)) {
|
||||||
const auto& well = schedule.getWell( w_name, sim_step );
|
const auto& well = schedule.getWell( w_name, sim_step );
|
||||||
|
@ -1057,6 +1057,7 @@ SummaryConfigNode& SummaryConfigNode::fip_region(const std::string& fip_region)
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SummaryConfigNode& SummaryConfigNode::parameterType(const Type type)
|
SummaryConfigNode& SummaryConfigNode::parameterType(const Type type)
|
||||||
{
|
{
|
||||||
this->type_ = type;
|
this->type_ = type;
|
||||||
@ -1376,9 +1377,8 @@ bool SummaryConfig::require3DField( const std::string& keyword ) const {
|
|||||||
std::set<std::string> SummaryConfig::fip_regions() const {
|
std::set<std::string> SummaryConfig::fip_regions() const {
|
||||||
std::set<std::string> reg_set;
|
std::set<std::string> reg_set;
|
||||||
for (const auto& node : this->m_keywords) {
|
for (const auto& node : this->m_keywords) {
|
||||||
const auto& fip_region = node.fip_region();
|
if (node.category() == EclIO::SummaryNode::Category::Region)
|
||||||
if (fip_region.size() > 0)
|
reg_set.insert( node.fip_region() );
|
||||||
reg_set.insert( fip_region );
|
|
||||||
}
|
}
|
||||||
return reg_set;
|
return reg_set;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user