Add optional methods to get VFP tables

This commit is contained in:
Joakim Hove
2021-01-25 12:20:45 +01:00
parent a8f3ef088e
commit c4e6bf0dd8
2 changed files with 17 additions and 0 deletions

View File

@@ -124,10 +124,12 @@ namespace Opm {
std::vector<std::reference_wrapper<const VFPProdTable>> vfpprod() const;
const VFPProdTable& vfpprod(int table_id) const;
void update_vfpprod(VFPProdTable vfpprod);
std::optional<std::reference_wrapper<const VFPProdTable>> try_vfpprod(int table_id) const;
std::vector<std::reference_wrapper<const VFPInjTable>> vfpinj() const;
const VFPInjTable& vfpinj(int table_id) const;
void update_vfpinj(VFPInjTable vfpinj);
std::optional<std::reference_wrapper<const VFPInjTable>> try_vfpinj(int table_id) const;
const Action::Actions& actions() const;
void update_actions(Action::Actions actions);

View File

@@ -318,6 +318,14 @@ void ScheduleState::update_vfpprod(VFPProdTable vfpprod) {
this->m_vfpprod[table_id] = std::make_shared<VFPProdTable>( std::move(vfpprod) );
}
std::optional<std::reference_wrapper<const VFPProdTable>> ScheduleState::try_vfpprod(int table_id) const {
auto vfp_iter = this->m_vfpprod.find(table_id);
if (vfp_iter != this->m_vfpprod.end())
return std::cref(*vfp_iter->second);
return {};
}
std::vector<std::reference_wrapper<const VFPInjTable>> ScheduleState::vfpinj() const {
std::vector<std::reference_wrapper<const VFPInjTable>> tables;
for (const auto& [_, table] : this->m_vfpinj) {
@@ -327,6 +335,13 @@ std::vector<std::reference_wrapper<const VFPInjTable>> ScheduleState::vfpinj() c
return tables;
}
std::optional<std::reference_wrapper<const VFPInjTable>> ScheduleState::try_vfpinj(int table_id) const {
auto vfp_iter = this->m_vfpinj.find(table_id);
if (vfp_iter != this->m_vfpinj.end())
return std::cref(*vfp_iter->second);
return {};
}
const VFPInjTable& ScheduleState::vfpinj(int table_id) const {
auto vfp_iter = this->m_vfpinj.find(table_id);
if (vfp_iter == this->m_vfpinj.end())