/* Copyright 2017 SINTEF Digital, Mathematics and Cybernetics. Copyright 2017 Statoil ASA. Copyright 2016 - 2017 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 { template auto dValueError(const dValue& d, const std::string& name, const std::string& methodName, const Value& Rs, const Value& Rv, const Value& pressure) { return fmt::format("Problematic d value {} obtained for well {}" " during {} calculations with rs {}" ", rv {} and pressure {}." " Continue as if no dissolution (rs = 0) and vaporization (rv = 0) " " for this connection.", d, name, methodName, Rs, Rv, pressure); } } namespace Opm { template RatioCalculator:: RatioCalculator(unsigned gasCompIdx, unsigned oilCompIdx, unsigned waterCompIdx, std::string_view name) : gasComp_{gasCompIdx} , oilComp_(oilCompIdx) , waterComp_{waterCompIdx} , name_(name) { } template void RatioCalculator:: disOilVapWatVolumeRatio(Value& volumeRatio, const Value& rvw, const Value& rsw, const Value& pressure, const std::vector& cmix_s, const std::vector& b_perfcells_dense, DeferredLogger& deferred_logger) const { // Incorporate RSW/RVW factors if both water and gas active const Value d = 1.0 - rvw * rsw; if (d <= 0.0) { deferred_logger.debug(dValueError(d, name_, "disOilVapWatVolumeRatio", rsw, rvw, pressure)); } const Value tmp_wat = d > 0.0 ? (cmix_s[waterComp_] - rvw * cmix_s[gasComp_]) / d : cmix_s[waterComp_]; volumeRatio += tmp_wat / b_perfcells_dense[waterComp_]; const Value tmp_gas = d > 0.0 ? (cmix_s[gasComp_] - rsw * cmix_s[waterComp_]) / d : cmix_s[gasComp_]; volumeRatio += tmp_gas / b_perfcells_dense[gasComp_]; } template void RatioCalculator:: gasOilVolumeRatio(Value& volumeRatio, const Value& rv, const Value& rs, const Value& pressure, const std::vector& cmix_s, const std::vector& b_perfcells_dense, DeferredLogger& deferred_logger) const { // Incorporate RS/RV factors if both oil and gas active const Value d = 1.0 - rv * rs; if (d <= 0.0) { deferred_logger.debug(dValueError(d, name_, "gasOilVolumeRatio", rs, rv, pressure)); } const Value tmp_oil = d > 0.0 ? (cmix_s[oilComp_] - rv * cmix_s[gasComp_]) / d : cmix_s[oilComp_]; volumeRatio += tmp_oil / b_perfcells_dense[oilComp_]; const Value tmp_gas = d > 0.0 ? (cmix_s[gasComp_] - rs * cmix_s[oilComp_]) / d : cmix_s[gasComp_]; volumeRatio += tmp_gas / b_perfcells_dense[gasComp_]; } #define INSTANTIATE_TYPE(T) \ template class RatioCalculator; \ template class RatioCalculator>; \ template class RatioCalculator>; \ template class RatioCalculator>; \ template class RatioCalculator>; \ template class RatioCalculator>; \ template class RatioCalculator>; \ template class RatioCalculator>; \ template class RatioCalculator>; INSTANTIATE_TYPE(double) #if FLOW_INSTANTIATE_FLOAT INSTANTIATE_TYPE(float) #endif }