From dc607ce3ffc7ec0b19a78586a30d3a36c6824765 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Mon, 24 Oct 2022 09:36:05 +0200 Subject: [PATCH] add BlackoilWellModelGuideRates start by moving getGuideRateValues --- CMakeLists_files.cmake | 2 + .../wells/BlackoilWellModelGeneric.cpp | 31 +--------- .../wells/BlackoilWellModelGeneric.hpp | 8 +-- .../wells/BlackoilWellModelGuideRates.cpp | 61 +++++++++++++++++++ .../wells/BlackoilWellModelGuideRates.hpp | 58 ++++++++++++++++++ 5 files changed, 128 insertions(+), 32 deletions(-) create mode 100644 opm/simulators/wells/BlackoilWellModelGuideRates.cpp create mode 100644 opm/simulators/wells/BlackoilWellModelGuideRates.hpp diff --git a/CMakeLists_files.cmake b/CMakeLists_files.cmake index 64220e46d..b5c96746e 100644 --- a/CMakeLists_files.cmake +++ b/CMakeLists_files.cmake @@ -82,6 +82,7 @@ list (APPEND MAIN_SOURCE_FILES opm/simulators/wells/ALQState.cpp opm/simulators/wells/BlackoilWellModelConstraints.cpp opm/simulators/wells/BlackoilWellModelGeneric.cpp + opm/simulators/wells/BlackoilWellModelGuideRates.cpp opm/simulators/wells/BlackoilWellModelRestart.cpp opm/simulators/wells/GasLiftCommon.cpp opm/simulators/wells/GasLiftGroupInfo.cpp @@ -352,6 +353,7 @@ list (APPEND PUBLIC_HEADER_FILES opm/simulators/wells/BlackoilWellModel_impl.hpp opm/simulators/wells/BlackoilWellModelConstraints.hpp opm/simulators/wells/BlackoilWellModelGeneric.hpp + opm/simulators/wells/BlackoilWellModelGuideRates.hpp opm/simulators/wells/BlackoilWellModelRestart.hpp opm/simulators/wells/GasLiftCommon.hpp opm/simulators/wells/GasLiftGroupInfo.hpp diff --git a/opm/simulators/wells/BlackoilWellModelGeneric.cpp b/opm/simulators/wells/BlackoilWellModelGeneric.cpp index 0e588f975..db13d5802 100644 --- a/opm/simulators/wells/BlackoilWellModelGeneric.cpp +++ b/opm/simulators/wells/BlackoilWellModelGeneric.cpp @@ -37,6 +37,7 @@ #include #include +#include #include #include #include @@ -950,37 +951,11 @@ getGuideRateValues(const Well& well) const const auto qs = WellGroupHelpers:: getWellRateVector(this->wellState(), this->phase_usage_, wname); - this->getGuideRateValues(qs, well.isInjector(), wname, grval); + BlackoilWellModelGuideRates(*this).getGuideRateValues(qs, well.isInjector(), wname, grval); return grval; } -void -BlackoilWellModelGeneric:: -getGuideRateValues(const GuideRate::RateVector& qs, - const bool is_inj, - const std::string& wgname, - data::GuideRateValue& grval) const -{ - auto getGR = [this, &wgname, &qs](const GuideRateModel::Target t) - { - return this->guideRate_.getSI(wgname, t, qs); - }; - - // Note: GuideRate does currently (2020-07-20) not support Target::RES. - grval.set(data::GuideRateValue::Item::Gas, - getGR(GuideRateModel::Target::GAS)); - - grval.set(data::GuideRateValue::Item::Water, - getGR(GuideRateModel::Target::WAT)); - - if (!is_inj) { - // Producer. Extract "all" guiderate values. - grval.set(data::GuideRateValue::Item::Oil, - getGR(GuideRateModel::Target::OIL)); - } -} - data::GuideRateValue BlackoilWellModelGeneric:: getGuideRateValues(const Group& group) const @@ -1004,7 +979,7 @@ getGuideRateValues(const Group& group) const getProductionGroupRateVector(this->groupState(), this->phase_usage_, gname); const auto is_inj = false; // This procedure only applies to G*PGR. - this->getGuideRateValues(qs, is_inj, gname, grval); + BlackoilWellModelGuideRates(*this).getGuideRateValues(qs, is_inj, gname, grval); return grval; } diff --git a/opm/simulators/wells/BlackoilWellModelGeneric.hpp b/opm/simulators/wells/BlackoilWellModelGeneric.hpp index e225e33e2..193575c0e 100644 --- a/opm/simulators/wells/BlackoilWellModelGeneric.hpp +++ b/opm/simulators/wells/BlackoilWellModelGeneric.hpp @@ -165,6 +165,10 @@ public: const SummaryState& summaryState() const { return summaryState_; } + const GuideRate& guideRate() const { return guideRate_; } + + bool reportStepStarts() const { return report_step_starts_; } + protected: /* @@ -270,10 +274,6 @@ protected: data::GuideRateValue getGuideRateValues(const Group& group) const; data::GuideRateValue getGuideRateValues(const Well& well) const; data::GuideRateValue getGuideRateInjectionGroupValues(const Group& group) const; - void getGuideRateValues(const GuideRate::RateVector& qs, - const bool is_inj, - const std::string& wgname, - data::GuideRateValue& grval) const; void assignWellGuideRates(data::Wells& wsrpt, const int reportStepIdx) const; diff --git a/opm/simulators/wells/BlackoilWellModelGuideRates.cpp b/opm/simulators/wells/BlackoilWellModelGuideRates.cpp new file mode 100644 index 000000000..2e703c93b --- /dev/null +++ b/opm/simulators/wells/BlackoilWellModelGuideRates.cpp @@ -0,0 +1,61 @@ +/* + Copyright 2016 SINTEF ICT, Applied Mathematics. + Copyright 2016 - 2017 Statoil ASA. + Copyright 2017 Dr. Blatt - HPC-Simulation-Software & Services + Copyright 2016 - 2018 IRIS AS + + This file is part of the Open Porous Media project (OPM). + + OPM is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OPM is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with OPM. If not, see . +*/ + +#include +#include + +#include + +#include + +#include +#include + +namespace Opm { + +void +BlackoilWellModelGuideRates:: +getGuideRateValues(const GuideRate::RateVector& qs, + const bool is_inj, + const std::string& wgname, + data::GuideRateValue& grval) const +{ + auto getGR = [this, &wgname, &qs](const GuideRateModel::Target t) + { + return wellModel_.guideRate().getSI(wgname, t, qs); + }; + + // Note: GuideRate does currently (2020-07-20) not support Target::RES. + grval.set(data::GuideRateValue::Item::Gas, + getGR(GuideRateModel::Target::GAS)); + + grval.set(data::GuideRateValue::Item::Water, + getGR(GuideRateModel::Target::WAT)); + + if (!is_inj) { + // Producer. Extract "all" guiderate values. + grval.set(data::GuideRateValue::Item::Oil, + getGR(GuideRateModel::Target::OIL)); + } +} + +} diff --git a/opm/simulators/wells/BlackoilWellModelGuideRates.hpp b/opm/simulators/wells/BlackoilWellModelGuideRates.hpp new file mode 100644 index 000000000..690cd0795 --- /dev/null +++ b/opm/simulators/wells/BlackoilWellModelGuideRates.hpp @@ -0,0 +1,58 @@ +/* + Copyright 2016 SINTEF ICT, Applied Mathematics. + Copyright 2016 - 2017 Statoil ASA. + Copyright 2017 Dr. Blatt - HPC-Simulation-Software & Services + Copyright 2016 - 2018 IRIS AS + + This file is part of the Open Porous Media project (OPM). + + OPM is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OPM is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with OPM. If not, see . +*/ + +#ifndef OPM_BLACKOILWELLMODEL_GUIDE_RATES_HEADER_INCLUDED +#define OPM_BLACKOILWELLMODEL_GUIDE_RATES_HEADER_INCLUDED + +#include + +#include + +namespace Opm { + +class BlackoilWellModelGeneric; +namespace data { class GuideRateValue; } +class Group; + +/// Class for handling the guide rates in the blackoil well model. +class BlackoilWellModelGuideRates +{ +public: + //! \brief Constructor initializes reference to the well model. + BlackoilWellModelGuideRates(const BlackoilWellModelGeneric& wellModel) + : wellModel_(wellModel) + {} + + //! \brief Obtain guide rate values. + void getGuideRateValues(const GuideRate::RateVector& qs, + const bool is_inj, + const std::string& wgname, + data::GuideRateValue& grval) const; + +private: + const BlackoilWellModelGeneric& wellModel_; //!< Reference to well model +}; + + +} // namespace Opm + +#endif