diff --git a/CMakeLists_files.cmake b/CMakeLists_files.cmake index 5f82e1103..b9e4e9341 100644 --- a/CMakeLists_files.cmake +++ b/CMakeLists_files.cmake @@ -108,6 +108,7 @@ list (APPEND MAIN_SOURCE_FILES opm/simulators/wells/WellInterfaceIndices.cpp opm/simulators/wells/WellProdIndexCalculator.cpp opm/simulators/wells/WellState.cpp + opm/simulators/wells/WellTest.cpp opm/simulators/wells/WGState.cpp ) @@ -381,6 +382,7 @@ list (APPEND PUBLIC_HEADER_FILES opm/simulators/wells/WellInterface_impl.hpp opm/simulators/wells/WellProdIndexCalculator.hpp opm/simulators/wells/WellState.hpp + opm/simulators/wells/WellTest.hpp opm/simulators/wells/WGState.hpp ) diff --git a/opm/simulators/wells/WellInterfaceFluidSystem.cpp b/opm/simulators/wells/WellInterfaceFluidSystem.cpp index c87825fe0..31b3833cd 100644 --- a/opm/simulators/wells/WellInterfaceFluidSystem.cpp +++ b/opm/simulators/wells/WellInterfaceFluidSystem.cpp @@ -28,13 +28,14 @@ #include #include -#include +#include #include +#include +#include +#include #include #include -#include -#include -#include +#include #include #include @@ -579,7 +580,8 @@ checkMaxWaterCutLimit(const WellEconProductionLimits& econ_production_limits, const double max_water_cut_limit = econ_production_limits.maxWaterCut(); assert(max_water_cut_limit > 0.); - const bool watercut_limit_violated = checkMaxRatioLimitWell(ws, max_water_cut_limit, waterCut); + const bool watercut_limit_violated = + WellTest(*this).checkMaxRatioLimitWell(ws, max_water_cut_limit, waterCut); if (watercut_limit_violated) { report.ratio_limit_violated = true; @@ -613,7 +615,7 @@ checkMaxGORLimit(const WellEconProductionLimits& econ_production_limits, const double max_gor_limit = econ_production_limits.maxGasOilRatio(); assert(max_gor_limit > 0.); - const bool gor_limit_violated = checkMaxRatioLimitWell(ws, max_gor_limit, gor); + const bool gor_limit_violated = WellTest(*this).checkMaxRatioLimitWell(ws, max_gor_limit, gor); if (gor_limit_violated) { report.ratio_limit_violated = true; @@ -648,7 +650,7 @@ checkMaxWGRLimit(const WellEconProductionLimits& econ_production_limits, const double max_wgr_limit = econ_production_limits.maxWaterGasRatio(); assert(max_wgr_limit > 0.); - const bool wgr_limit_violated = checkMaxRatioLimitWell(ws, max_wgr_limit, wgr); + const bool wgr_limit_violated = WellTest(*this).checkMaxRatioLimitWell(ws, max_wgr_limit, wgr); if (wgr_limit_violated) { report.ratio_limit_violated = true; @@ -922,24 +924,6 @@ checkMaxRatioLimitCompletions(const SingleWellState& ws, } } -template -template -bool WellInterfaceFluidSystem:: -checkMaxRatioLimitWell(const SingleWellState& ws, - const double max_ratio_limit, - const RatioFunc& ratioFunc) const -{ - const int np = number_of_phases_; - - std::vector well_rates(np, 0.0); - for (int p = 0; p < np; ++p) { - well_rates[p] = ws.surface_rates[p]; - } - - const double well_ratio = ratioFunc(well_rates, phaseUsage()); - return (well_ratio > max_ratio_limit); -} - template int WellInterfaceFluidSystem:: diff --git a/opm/simulators/wells/WellInterfaceFluidSystem.hpp b/opm/simulators/wells/WellInterfaceFluidSystem.hpp index 43fae1cb9..544fa0336 100644 --- a/opm/simulators/wells/WellInterfaceFluidSystem.hpp +++ b/opm/simulators/wells/WellInterfaceFluidSystem.hpp @@ -182,11 +182,6 @@ private: const double max_ratio_limit, const RatioFunc& ratioFunc, RatioLimitCheckReport& report) const; - - template - bool checkMaxRatioLimitWell(const SingleWellState& well_state, - const double max_ratio_limit, - const RatioFunc& ratioFunc) const; }; } diff --git a/opm/simulators/wells/WellTest.cpp b/opm/simulators/wells/WellTest.cpp new file mode 100644 index 000000000..db450691d --- /dev/null +++ b/opm/simulators/wells/WellTest.cpp @@ -0,0 +1,46 @@ +/* + Copyright 2017 SINTEF Digital, Mathematics and Cybernetics. + Copyright 2017 Statoil ASA. + Copyright 2018 IRIS + + 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 + +namespace Opm +{ + +bool WellTest::checkMaxRatioLimitWell(const SingleWellState& ws, + const double max_ratio_limit, + const RatioFunc& ratioFunc) const +{ + const int np = well_.numPhases(); + + std::vector well_rates(np, 0.0); + for (int p = 0; p < np; ++p) { + well_rates[p] = ws.surface_rates[p]; + } + + const double well_ratio = ratioFunc(well_rates, well_.phaseUsage()); + return (well_ratio > max_ratio_limit); +} + +} // namespace Opm diff --git a/opm/simulators/wells/WellTest.hpp b/opm/simulators/wells/WellTest.hpp new file mode 100644 index 000000000..0769379c0 --- /dev/null +++ b/opm/simulators/wells/WellTest.hpp @@ -0,0 +1,56 @@ +/* + Copyright 2017 SINTEF Digital, Mathematics and Cybernetics. + Copyright 2017 Statoil ASA. + Copyright 2017 IRIS + Copyright 2019 Norce + + 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_WELL_TEST_HEADER_INCLUDED +#define OPM_WELL_TEST_HEADER_INCLUDED + +#include +#include + +namespace Opm +{ + +class PhaseUsage; +class SingleWellState; +class WellInterfaceGeneric; + +//! \brief Class for performing well tests. +class WellTest { +public: + //! \brief Constructor sets reference to well. + WellTest(const WellInterfaceGeneric& well) : well_(well) {} + + using RatioFunc = std::function& rates, + const PhaseUsage& pu)>; + + bool checkMaxRatioLimitWell(const SingleWellState& ws, + const double max_ratio_limit, + const RatioFunc& ratioFunc) const; + +private: + const WellInterfaceGeneric& well_; //!< Reference to well interface +}; + +} + +#endif // OPM_WELL_TEST_HEADER_INCLUDED