/* Copyright 2017 SINTEF ICT, Applied Mathematics. Copyright 2017 Statoil ASA. 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 . */ #if HAVE_CONFIG_H #include #endif #include #include #include #include #include #include namespace Opm { namespace ECLUnits { namespace Impl { ert_ecl_unit_enum getUnitConvention(const int usys); template class USys; template <> class USys : public ::Opm::ECLUnits::UnitSystem { public: virtual double pressure() const override { return Metric::Pressure; } virtual double reservoirRate() const override { return Metric::ReservoirVolume / Metric::Time; } virtual double reservoirVolume() const override { return Metric::ReservoirVolume; } virtual double time() const override { return Metric::Time; } virtual double transmissibility() const override { return Metric::Transmissibility; } }; template <> class USys : public ::Opm::ECLUnits::UnitSystem { public: virtual double pressure() const override { return Field::Pressure; } virtual double reservoirRate() const override { return Field::ReservoirVolume / Field::Time; } virtual double reservoirVolume() const override { return Field::ReservoirVolume; } virtual double time() const override { return Field::Time; } virtual double transmissibility() const override { return Field::Transmissibility; } }; template <> class USys : public ::Opm::ECLUnits::UnitSystem { public: virtual double pressure() const override { return Lab::Pressure; } virtual double reservoirRate() const override { return Lab::ReservoirVolume / Lab::Time; } virtual double reservoirVolume() const override { return Lab::ReservoirVolume; } virtual double time() const override { return Lab::Time; } virtual double transmissibility() const override { return Lab::Transmissibility; } }; template <> class USys : public ::Opm::ECLUnits::UnitSystem { public: virtual double pressure() const override { return unit::atm; } virtual double reservoirRate() const override { using namespace prefix; using namespace unit; return cubic(meter) / day; } virtual double reservoirVolume() const override { using namespace prefix; using namespace unit; return cubic(meter); } virtual double time() const override { return unit::day; } virtual double transmissibility() const override { using namespace prefix; using namespace unit; return centi*Poise * cubic(meter) / (day * atm); } }; } // namespace Impl }} // namespace Opm::ECLUnits ert_ecl_unit_enum Opm::ECLUnits::Impl::getUnitConvention(const int usys) { switch (usys) { case 1: return ECL_METRIC_UNITS; case 2: return ECL_FIELD_UNITS; case 3: return ECL_LAB_UNITS; case 4: return ECL_PVT_M_UNITS; } throw std::runtime_error("Unsupported Unit Convention: " + std::to_string(usys)); } std::unique_ptr Opm::ECLUnits::createUnitSystem(const int usys) { using UPtr = std::unique_ptr; switch (Impl::getUnitConvention(usys)) { case ECL_METRIC_UNITS: return UPtr{ new Impl::USys{} }; case ECL_FIELD_UNITS: return UPtr{ new Impl::USys{} }; case ECL_LAB_UNITS: return UPtr{ new Impl::USys{} }; case ECL_PVT_M_UNITS: return UPtr{ new Impl::USys{} }; } throw std::runtime_error("Unsupported Unit Convention: " + std::to_string(usys)); }