From 6c47cdb22fef0c35c81b4c92daa99d45227b35df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A5rd=20Skaflestad?= Date: Wed, 28 Aug 2019 10:31:26 +0200 Subject: [PATCH] Add New RFT File Writer This commit implements a new file writing function void Opm::RftIO::write() that is intended to replace the current RFT output functionality defined in terms of private class 'RFT' in EclipseIO.cpp. We support the basic RFT output consisting of - Timestamp (elapsed and date) - WELLETC metadata including all unit conventions - Connection cell (I,J,K), connection cell hostgrid (blank for main grid only), connection cell centre depth, connection cell pressure, and connection cell water and gas saturations Connections in inactive cells are omitted. Note that unit of measure strings aren't implemented in terms of UnitSystem::name() due to the strings being padded on the left for centering effect. Add unit tests to exercise the new writer. --- CMakeLists_files.cmake | 2 + opm/output/eclipse/WriteRFT.hpp | 89 ++ src/opm/output/eclipse/WriteRFT.cpp | 413 ++++++ tests/test_RFT.cpp | 1988 +++++++++++++++++++++++++++ 4 files changed, 2492 insertions(+) create mode 100644 opm/output/eclipse/WriteRFT.hpp create mode 100644 src/opm/output/eclipse/WriteRFT.cpp diff --git a/CMakeLists_files.cmake b/CMakeLists_files.cmake index 457a9bb91..5f85c0aae 100644 --- a/CMakeLists_files.cmake +++ b/CMakeLists_files.cmake @@ -205,6 +205,7 @@ if(ENABLE_ECL_OUTPUT) src/opm/output/eclipse/RegionCache.cpp src/opm/output/eclipse/RestartValue.cpp src/opm/output/eclipse/WriteInit.cpp + src/opm/output/eclipse/WriteRFT.cpp src/opm/output/data/Solution.cpp ) endif() @@ -642,6 +643,7 @@ if(ENABLE_ECL_OUTPUT) opm/output/eclipse/Tables.hpp opm/output/eclipse/WindowedArray.hpp opm/output/eclipse/WriteInit.hpp + opm/output/eclipse/WriteRFT.hpp opm/output/eclipse/WriteRestartHelpers.hpp opm/output/OutputWriter.hpp ) diff --git a/opm/output/eclipse/WriteRFT.hpp b/opm/output/eclipse/WriteRFT.hpp new file mode 100644 index 000000000..af8cf2f31 --- /dev/null +++ b/opm/output/eclipse/WriteRFT.hpp @@ -0,0 +1,89 @@ +/* + Copyright (c) 2019 Equinor 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 . +*/ + +#ifndef OPM_WRITE_RFT_HPP +#define OPM_WRITE_RFT_HPP + +namespace Opm { + + class EclipseGrid; + class Schedule; + class UnitSystem; + +} // namespace Opm + +namespace Opm { namespace data { + + class WellRates; + +}} // namespace Opm::data + +namespace Opm { namespace EclIO { namespace OutputStream { + + class RFT; + +}}} // namespace Opm::EclIO::OutputStream + +namespace Opm { namespace RftIO { + + /// Collect RFT data and output to pre-opened output stream. + /// + /// RFT data is output for all affected wells at a given timestep, + /// and consists of + /// + /// 1) Time stamp (elapsed and date) + /// 2) Metadata about the output (units of measure, well types, + /// data type identifier) + /// 3) Depth, pressure, Sw, Sg, (I,J,K), and hostgrid for each + /// reservoir connection of the affected well. + /// + /// If no RFT output is requested at given timestep, then this + /// function returns with no output written to the RFT file. + /// + /// \param[in] reportStep Report step time point for which to output + /// RFT data. + /// + /// \param[in] elapsed Number of seconds of simulated time until + /// this report step (\p reportStep). + /// + /// \param[in] usys Unit system conventions for output. Typically + /// corresponds to run's active unit system (i.e., \code + /// EclipseState::getUnits() \endcode). + /// + /// \param[in] grid Run's active grid. Used to determine which + /// reservoir connections are in active grid cells. + /// + /// \param[in] schedule Run's SCHEDULE section from which to access + /// the active wells and the RFT configuration. + /// + /// \param[in,out] rftFile RFT output stream. On input, appropriately + /// positioned for new content (i.e., at end-of-file). On output, + /// containing new RFT output (if applicable) and positioned after + /// new contents. + void write(const int reportStep, + const double elapsed, + const ::Opm::UnitSystem& usys, + const ::Opm::EclipseGrid& grid, + const ::Opm::Schedule& schedule, + const ::Opm::data::WellRates& wellSol, + ::Opm::EclIO::OutputStream::RFT& rftFile); + +}} // namespace Opm::RftIO + +#endif // OPM_WRITE_RFT_HPP diff --git a/src/opm/output/eclipse/WriteRFT.cpp b/src/opm/output/eclipse/WriteRFT.cpp new file mode 100644 index 000000000..97e75ca68 --- /dev/null +++ b/src/opm/output/eclipse/WriteRFT.cpp @@ -0,0 +1,413 @@ +/* + Copyright (c) 2019 Equinor ASA + Copyright (c) 2016 Statoil ASA + Copyright (c) 2013-2015 Andreas Lauser + Copyright (c) 2013 SINTEF ICT, Applied Mathematics. + Copyright (c) 2013 Uni Research AS + Copyright (c) 2015 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 +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include + +namespace { + enum etcIx : std::vector>::size_type + { + Time = 0, + Well = 1, + LGR = 2, + Depth = 3, + Pressure = 4, + DataType = 5, + WellType = 6, + LiqRate = 7, + GasRate = 8, + ResVRate = 9, + Velocity = 10, + Reserved = 11, // Untouched + Viscosity = 12, + ConcPlyBr = 13, + PlyBrRate = 14, + PlyBrAds = 15, + }; + + namespace RftUnits { + namespace exceptions { + void metric(std::vector>& welletc) + { + welletc[etcIx::Depth] = " METRES"; + welletc[etcIx::Velocity] = " M/SEC"; + } + + void field(std::vector>& welletc) + { + welletc[etcIx::Depth] = " FEET"; + welletc[etcIx::Velocity] = " FT/SEC"; + welletc[etcIx::PlyBrRate] = " LB/DAY"; + } + + void lab(std::vector>& welletc) + { + welletc[etcIx::Time] = " HR"; + welletc[etcIx::Pressure] = " ATMA"; + welletc[etcIx::Velocity] = " CM/SEC"; + welletc[etcIx::ConcPlyBr] = " GM/SCC"; + welletc[etcIx::PlyBrRate] = " GM/HR"; + welletc[etcIx::PlyBrAds] = " GM/GM"; + } + + void pvt_m(std::vector>& welletc) + { + // PVT_M is METRIC with pressures in atmospheres. + metric(welletc); + + welletc[etcIx::Pressure] = " ATMA"; + } + + void input(std::vector>& welletc) + { + welletc[etcIx::Time] = " INPUT"; + welletc[etcIx::Depth] = " INPUT"; + welletc[etcIx::Pressure] = " INPUT"; + welletc[etcIx::LiqRate] = " INPUT"; + welletc[etcIx::GasRate] = " INPUT"; + welletc[etcIx::ResVRate] = " INPUT"; + welletc[etcIx::Velocity] = " INPUT"; + welletc[etcIx::Viscosity] = " INPUT"; + welletc[etcIx::ConcPlyBr] = " INPUT"; + welletc[etcIx::PlyBrRate] = " INPUT"; + welletc[etcIx::PlyBrAds] = " INPUT"; + } + } // namespace exceptions + + std::string + centre(std::string s, const std::string::size_type width = 8) + { + if (s.size() > width) { return s.substr(0, width); } + if (s.size() == width) { return s; } + + const auto npad = width - s.size(); + const auto left = (npad + 1) / 2; // ceil(npad / 2) + + return std::string(left, ' ') + s; + } + + std::string combine(std::string left, std::string right) + { + return left + '/' + right; + } + + void fill(const ::Opm::UnitSystem& usys, + std::vector>& welletc) + { + using M = ::Opm::UnitSystem::measure; + + welletc[etcIx::Time] = centre(std::string{usys.name(M::time)} + 'S'); + welletc[etcIx::Depth] = centre(usys.name(M::length)); + welletc[etcIx::Pressure] = centre(usys.name(M::pressure)); + welletc[etcIx::LiqRate] = centre(usys.name(M::liquid_surface_rate)); + welletc[etcIx::GasRate] = centre(usys.name(M::gas_surface_rate)); + welletc[etcIx::ResVRate] = centre(usys.name(M::rate)); + welletc[etcIx::Velocity] = centre(combine(usys.name(M::length), + usys.name(M::time))); + welletc[etcIx::Viscosity] = centre(usys.name(M::viscosity)); + welletc[etcIx::ConcPlyBr] = + centre(combine(usys.name(M::mass), + usys.name(M::liquid_surface_volume))); + + welletc[etcIx::PlyBrRate] = centre(usys.name(M::mass_rate)); + welletc[etcIx::PlyBrAds] = centre(combine(usys.name(M::mass), + usys.name(M::mass))); + } + } // namespace RftUnits + + class WellRFT + { + public: + explicit WellRFT(const std::size_t nconn = 0); + + void add(const ::Opm::UnitSystem& usys, + const ::Opm::Connection& conn, + const ::Opm::data::Connection& xcon, + const double depth); + + std::size_t nConn() const { return this->i_.size(); } + + const std::vector& conI() const { return this->i_; } + const std::vector& conJ() const { return this->j_; } + const std::vector& conK() const { return this->k_; } + + const std::vector& depth() const { return this->depth_; } + const std::vector& pressure() const { return this->press_; } + const std::vector& swat() const { return this->swat_; } + const std::vector& sgas() const { return this->sgas_; } + + const std::vector>& + hostgrid() const + { + return this->host_; + } + + private: + std::vector i_; + std::vector j_; + std::vector k_; + + std::vector depth_; + std::vector press_; + std::vector swat_; + std::vector sgas_; + + std::vector> host_; + }; + + WellRFT::WellRFT(const std::size_t nconn) + { + if (nconn == 0) { return; } + + this->i_.reserve(nconn); + this->j_.reserve(nconn); + this->k_.reserve(nconn); + + this->depth_.reserve(nconn); + this->press_.reserve(nconn); + this->swat_ .reserve(nconn); + this->sgas_ .reserve(nconn); + + this->host_.reserve(nconn); + } + + void WellRFT::add(const ::Opm::UnitSystem& usys, + const ::Opm::Connection& conn, + const ::Opm::data::Connection& xcon, + const double depth) + { + this->i_.push_back(conn.getI() + 1); + this->j_.push_back(conn.getJ() + 1); + this->k_.push_back(conn.getK() + 1); + + using M = ::Opm::UnitSystem::measure; + auto cvrt = [&usys](const M meas, const double x) -> float + { + return usys.from_si(meas, x); + }; + + this->depth_.push_back(cvrt(M::length , depth)); + this->press_.push_back(cvrt(M::pressure, xcon.cell_pressure)); + + this->swat_.push_back(xcon.cell_saturation_water); + this->sgas_.push_back(xcon.cell_saturation_gas); + + this->host_.emplace_back(); + } + + WellRFT + createWellRFT(const int reportStep, + const std::string& wname, + const ::Opm::UnitSystem& usys, + const ::Opm::EclipseGrid& grid, + const ::Opm::Schedule& sched, + const std::vector& xcon) + { + auto rft = WellRFT{ xcon.size() }; + + for (const auto& conn : sched.getWell2(wname, reportStep).getConnections()) { + const auto i = static_cast(conn.getI()); + const auto j = static_cast(conn.getJ()); + const auto k = static_cast(conn.getK()); + + if (! grid.cellActive(i, j, k)) { + // Inactive cell. Ignore. + continue; + } + + const auto ix = grid.getGlobalIndex(i, j, k); + auto xconPos = std::find_if(xcon.begin(), xcon.end(), + [ix](const ::Opm::data::Connection& c) + { + return c.index == ix; + }); + + if (xconPos == xcon.end()) { + // RFT data not available for this connection. Unexpected. + continue; + } + + rft.add(usys, conn, *xconPos, grid.getCellDepth(ix)); + } + + return rft; + } + + std::vector> + wellETC(const std::string& wellName, + const std::string& dataType, + const ::Opm::UnitSystem& usys) + { + using UT = ::Opm::UnitSystem::UnitType; + auto ret = std::vector>(16); + + // Note: ret[etcIx::LGR] is well's LGR. Default constructed + // (i.e., blank) string is sufficient to represent no LGR. + + ret[etcIx::Well] = wellName; + + // 'P' -> PLT, 'R' -> RFT, 'S' -> Segment + ret[etcIx::DataType] = dataType; + + // We support "standard" well type only. + ret[etcIx::WellType] = "STANDARD"; + + RftUnits::fill(usys, ret); + + switch (usys.getType()) { + case UT::UNIT_TYPE_METRIC: + RftUnits::exceptions::metric(ret); + break; + + case UT::UNIT_TYPE_FIELD: + RftUnits::exceptions::field(ret); + break; + + case UT::UNIT_TYPE_LAB: + RftUnits::exceptions::lab(ret); + break; + + case UT::UNIT_TYPE_PVT_M: + RftUnits::exceptions::pvt_m(ret); + break; + + case UT::UNIT_TYPE_INPUT: + RftUnits::exceptions::input(ret); + break; + } + + return ret; + } + + void writeWellHeader(const double elapsed, + const std::string& wellName, + const ::Opm::Schedule& sched, + const ::Opm::UnitSystem& usys, + ::Opm::EclIO::OutputStream::RFT& rftFile) + { + { + const auto time = + usys.from_si(::Opm::UnitSystem::measure::time, elapsed); + + rftFile.write("TIME", std::vector { + static_cast(time) + }); + } + + { + const auto timePoint = ::Opm::RestartIO:: + getSimulationTimePoint(sched.getStartTime(), elapsed); + + rftFile.write("DATE", std::vector { + timePoint.day, // 1..31 + timePoint.month, // 1..12 + timePoint.year, + }); + } + + rftFile.write("WELLETC", wellETC(wellName, "R", usys)); + } + + void write(const WellRFT& rft, ::Opm::EclIO::OutputStream::RFT& rftFile) + { + rftFile.write("CONIPOS", rft.conI()); + rftFile.write("CONJPOS", rft.conJ()); + rftFile.write("CONKPOS", rft.conK()); + + rftFile.write("HOSTGRID", rft.hostgrid()); + + rftFile.write("DEPTH" , rft.depth()); + rftFile.write("PRESSURE", rft.pressure()); + rftFile.write("SWAT" , rft.swat()); + rftFile.write("SGAS" , rft.sgas()); + } + + void writeWellRFT(const int reportStep, + const double elapsed, + const std::string& wname, + const ::Opm::UnitSystem& usys, + const ::Opm::EclipseGrid& grid, + const ::Opm::Schedule& sched, + const std::vector& xcon, + ::Opm::EclIO::OutputStream::RFT& rftFile) + { + const auto rft = + createWellRFT(reportStep, wname, usys, grid, sched, xcon); + + writeWellHeader(elapsed, wname, sched, usys, rftFile); + + if (rft.nConn() > std::size_t{0}) { + write(rft, rftFile); + } + } +} // Anonymous namespace + +void Opm::RftIO::write(const int reportStep, + const double elapsed, + const ::Opm::UnitSystem& usys, + const ::Opm::EclipseGrid& grid, + const ::Opm::Schedule& schedule, + const ::Opm::data::WellRates& wellSol, + ::Opm::EclIO::OutputStream::RFT& rftFile) +{ + const auto& rftCfg = schedule.rftConfig(); + if (! rftCfg.active(reportStep)) { + // RFT not yet activated. Nothing to do. + return; + } + + for (const auto& wname : schedule.wellNames(reportStep)) { + if (! (rftCfg.rft(wname, reportStep) || + rftCfg.plt(wname, reportStep))) + { + // RFT output not requested for 'wname' at this time. + continue; + } + + // RFT output requested for 'wname' at this time. + writeWellRFT(reportStep, elapsed, wname, usys, grid, + schedule, wellSol.at(wname).connections, + rftFile); + } +} diff --git a/tests/test_RFT.cpp b/tests/test_RFT.cpp index 49364f09e..e854cae0f 100644 --- a/tests/test_RFT.cpp +++ b/tests/test_RFT.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include #include @@ -39,6 +40,9 @@ #include #include +#include +#include + #include #include #include @@ -236,6 +240,8 @@ namespace { } } // Anonymous namespace +BOOST_AUTO_TEST_SUITE(Using_EclipseIO) + BOOST_AUTO_TEST_CASE(test_RFT) { const auto rset = RSet{ "TESTRFT" }; @@ -430,3 +436,1985 @@ BOOST_AUTO_TEST_CASE(test_RFT2) } } } + +BOOST_AUTO_TEST_SUITE_END() // Using_EclipseIO + +// ===================================================================== + +BOOST_AUTO_TEST_SUITE(Using_Direct_Write) + +namespace { + struct Setup + { + explicit Setup(const std::string& deckfile) + : Setup{ ::Opm::Parser{}.parseFile(deckfile) } + {} + + explicit Setup(const ::Opm::Deck& deck) + : es { deck } + , sched{ deck, es } + { + } + + ::Opm::EclipseState es; + ::Opm::Schedule sched; + }; + + std::vector + connRes_OP1(const ::Opm::EclipseGrid& grid) + { + auto xcon = std::vector{}; + xcon.reserve(9); + + for (auto con = 0; con < 9; ++con) { + xcon.emplace_back(); + + auto& c = xcon.back(); + c.index = grid.getGlobalIndex(8, 8, con); + + c.cell_pressure = (120 + con*10)*::Opm::unit::barsa; + + c.cell_saturation_gas = 0.15; + c.cell_saturation_water = 0.3 + con/20.0; + } + + return xcon; + } + + ::Opm::data::Well wellSol_OP1(const ::Opm::EclipseGrid& grid) + { + auto xw = ::Opm::data::Well{}; + xw.connections = connRes_OP1(grid); + + return xw; + } + + std::vector + connRes_OP2(const ::Opm::EclipseGrid& grid) + { + auto xcon = std::vector{}; + xcon.reserve(6); + + for (auto con = 3; con < 9; ++con) { + xcon.emplace_back(); + + auto& c = xcon.back(); + c.index = grid.getGlobalIndex(3, 3, con); + + c.cell_pressure = (120 + con*10)*::Opm::unit::barsa; + + c.cell_saturation_gas = 0.6 - con/20.0; + c.cell_saturation_water = 0.25; + } + + return xcon; + } + + ::Opm::data::Well wellSol_OP2(const ::Opm::EclipseGrid& grid) + { + auto xw = ::Opm::data::Well{}; + xw.connections = connRes_OP2(grid); + + return xw; + } + + ::Opm::data::WellRates wellSol(const ::Opm::EclipseGrid& grid) + { + auto xw = ::Opm::data::Wells{}; + + xw["OP_1"] = wellSol_OP1(grid); + xw["OP_2"] = wellSol_OP2(grid); + + return xw; + } +} + +BOOST_AUTO_TEST_CASE(Basic_Unformatted) +{ + using RftDate = ::Opm::EclIO::ERft::RftDate; + + const auto rset = RSet { "TESTRFT" }; + const auto model = Setup{ "testrft.DATA" }; + + { + auto rftFile = ::Opm::EclIO::OutputStream::RFT { + rset, ::Opm::EclIO::OutputStream::Formatted { false }, + ::Opm::EclIO::OutputStream::RFT::OpenExisting{ false } + }; + + const auto reportStep = 2; + const auto elapsed = model.sched.seconds(reportStep); + const auto& grid = model.es.getInputGrid(); + + ::Opm::RftIO::write(reportStep, elapsed, model.es.getUnits(), + grid, model.sched, wellSol(grid), rftFile); + } + + { + const auto rft = ::Opm::EclIO::ERft { + ::Opm::EclIO::OutputStream::outputFileName(rset, "RFT") + }; + + { + const auto xRFT = RFTRresults { + rft, "OP_1", RftDate{ 2008, 10, 10 } + }; + + const auto thick = 0.25f; + + BOOST_CHECK_CLOSE(xRFT.depth(9, 9, 1), 1*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(9, 9, 2), 2*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(9, 9, 3), 3*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(9, 9, 4), 4*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(9, 9, 5), 5*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(9, 9, 6), 6*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(9, 9, 7), 7*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(9, 9, 8), 8*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(9, 9, 9), 9*thick + thick/2.0f, 1.0e-10f); + + BOOST_CHECK_CLOSE(xRFT.pressure(9, 9, 1), 120.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(9, 9, 2), 130.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(9, 9, 3), 140.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(9, 9, 4), 150.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(9, 9, 5), 160.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(9, 9, 6), 170.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(9, 9, 7), 180.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(9, 9, 8), 190.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(9, 9, 9), 200.0f, 1.0e-10f); + + BOOST_CHECK_CLOSE(xRFT.sgas(9, 9, 1), 0.15f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(9, 9, 2), 0.15f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(9, 9, 3), 0.15f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(9, 9, 4), 0.15f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(9, 9, 5), 0.15f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(9, 9, 6), 0.15f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(9, 9, 7), 0.15f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(9, 9, 8), 0.15f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(9, 9, 9), 0.15f, 1.0e-10f); + + BOOST_CHECK_CLOSE(xRFT.swat(9, 9, 1), 0.30f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(9, 9, 2), 0.35f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(9, 9, 3), 0.40f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(9, 9, 4), 0.45f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(9, 9, 5), 0.50f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(9, 9, 6), 0.55f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(9, 9, 7), 0.60f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(9, 9, 8), 0.65f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(9, 9, 9), 0.70f, 1.0e-10f); + } + + { + const auto xRFT = RFTRresults { + rft, "OP_2", RftDate{ 2008, 10, 10 } + }; + + const auto thick = 0.25f; + + BOOST_CHECK_CLOSE(xRFT.depth(4, 4, 4), 4*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(4, 4, 5), 5*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(4, 4, 6), 6*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(4, 4, 7), 7*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(4, 4, 8), 8*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(4, 4, 9), 9*thick + thick/2.0f, 1.0e-10f); + + BOOST_CHECK_CLOSE(xRFT.pressure(4, 4, 4), 150.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(4, 4, 5), 160.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(4, 4, 6), 170.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(4, 4, 7), 180.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(4, 4, 8), 190.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(4, 4, 9), 200.0f, 1.0e-10f); + + BOOST_CHECK_CLOSE(xRFT.sgas(4, 4, 4), 0.45f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(4, 4, 5), 0.40f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(4, 4, 6), 0.35f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(4, 4, 7), 0.30f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(4, 4, 8), 0.25f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(4, 4, 9), 0.20f, 1.0e-10f); + + BOOST_CHECK_CLOSE(xRFT.swat(4, 4, 4), 0.25f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(4, 4, 5), 0.25f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(4, 4, 6), 0.25f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(4, 4, 7), 0.25f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(4, 4, 8), 0.25f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(4, 4, 9), 0.25f, 1.0e-10f); + } + + { + const auto date = RftDate{2008, 10, 10}; + + BOOST_CHECK(rft.hasArray("WELLETC", "OP_1", date)); + + const auto& welletc = rft.getRft("WELLETC", "OP_1", date); + + BOOST_CHECK_EQUAL(welletc[ 0], " DAYS"); + BOOST_CHECK_EQUAL(welletc[ 1], "OP_1"); + BOOST_CHECK_EQUAL(welletc[ 2], ""); + BOOST_CHECK_EQUAL(welletc[ 3], " METRES"); + BOOST_CHECK_EQUAL(welletc[ 4], " BARSA"); + BOOST_CHECK_EQUAL(welletc[ 5], "R"); + BOOST_CHECK_EQUAL(welletc[ 6], "STANDARD"); + BOOST_CHECK_EQUAL(welletc[ 7], " SM3/DAY"); + BOOST_CHECK_EQUAL(welletc[ 8], " SM3/DAY"); + BOOST_CHECK_EQUAL(welletc[ 9], " RM3/DAY"); + BOOST_CHECK_EQUAL(welletc[10], " M/SEC"); + // No check for welletc[11] + BOOST_CHECK_EQUAL(welletc[12], " CP"); + BOOST_CHECK_EQUAL(welletc[13], " KG/SM3"); + BOOST_CHECK_EQUAL(welletc[14], " KG/DAY"); + BOOST_CHECK_EQUAL(welletc[15], " KG/KG"); + } + + { + const auto date = RftDate{2008, 10, 10}; + + BOOST_CHECK(rft.hasArray("WELLETC", "OP_2", date)); + + const auto& welletc = rft.getRft("WELLETC", "OP_2", date); + + BOOST_CHECK_EQUAL(welletc[ 0], " DAYS"); + BOOST_CHECK_EQUAL(welletc[ 1], "OP_2"); + BOOST_CHECK_EQUAL(welletc[ 2], ""); + BOOST_CHECK_EQUAL(welletc[ 3], " METRES"); + BOOST_CHECK_EQUAL(welletc[ 4], " BARSA"); + BOOST_CHECK_EQUAL(welletc[ 5], "R"); + BOOST_CHECK_EQUAL(welletc[ 6], "STANDARD"); + BOOST_CHECK_EQUAL(welletc[ 7], " SM3/DAY"); + BOOST_CHECK_EQUAL(welletc[ 8], " SM3/DAY"); + BOOST_CHECK_EQUAL(welletc[ 9], " RM3/DAY"); + BOOST_CHECK_EQUAL(welletc[10], " M/SEC"); + // No check for welletc[11] + BOOST_CHECK_EQUAL(welletc[12], " CP"); + BOOST_CHECK_EQUAL(welletc[13], " KG/SM3"); + BOOST_CHECK_EQUAL(welletc[14], " KG/DAY"); + BOOST_CHECK_EQUAL(welletc[15], " KG/KG"); + } + } + + { + auto rftFile = ::Opm::EclIO::OutputStream::RFT { + rset, ::Opm::EclIO::OutputStream::Formatted { false }, + ::Opm::EclIO::OutputStream::RFT::OpenExisting{ true } + }; + + const auto reportStep = 3; + const auto elapsed = model.sched.seconds(reportStep); + const auto& grid = model.es.getInputGrid(); + + ::Opm::RftIO::write(reportStep, elapsed, model.es.getUnits(), + grid, model.sched, wellSol(grid), rftFile); + } + + { + const auto rft = ::Opm::EclIO::ERft { + ::Opm::EclIO::OutputStream::outputFileName(rset, "RFT") + }; + + { + const auto xRFT = RFTRresults { + rft, "OP_1", RftDate{ 2008, 10, 10 } + }; + + const auto thick = 0.25f; + + BOOST_CHECK_CLOSE(xRFT.depth(9, 9, 1), 1*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(9, 9, 2), 2*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(9, 9, 3), 3*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(9, 9, 4), 4*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(9, 9, 5), 5*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(9, 9, 6), 6*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(9, 9, 7), 7*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(9, 9, 8), 8*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(9, 9, 9), 9*thick + thick/2.0f, 1.0e-10f); + + BOOST_CHECK_CLOSE(xRFT.pressure(9, 9, 1), 120.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(9, 9, 2), 130.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(9, 9, 3), 140.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(9, 9, 4), 150.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(9, 9, 5), 160.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(9, 9, 6), 170.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(9, 9, 7), 180.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(9, 9, 8), 190.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(9, 9, 9), 200.0f, 1.0e-10f); + + BOOST_CHECK_CLOSE(xRFT.sgas(9, 9, 1), 0.15f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(9, 9, 2), 0.15f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(9, 9, 3), 0.15f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(9, 9, 4), 0.15f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(9, 9, 5), 0.15f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(9, 9, 6), 0.15f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(9, 9, 7), 0.15f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(9, 9, 8), 0.15f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(9, 9, 9), 0.15f, 1.0e-10f); + + BOOST_CHECK_CLOSE(xRFT.swat(9, 9, 1), 0.30f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(9, 9, 2), 0.35f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(9, 9, 3), 0.40f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(9, 9, 4), 0.45f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(9, 9, 5), 0.50f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(9, 9, 6), 0.55f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(9, 9, 7), 0.60f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(9, 9, 8), 0.65f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(9, 9, 9), 0.70f, 1.0e-10f); + } + + { + const auto xRFT = RFTRresults { + rft, "OP_2", RftDate{ 2008, 10, 10 } + }; + + const auto thick = 0.25f; + + BOOST_CHECK_CLOSE(xRFT.depth(4, 4, 4), 4*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(4, 4, 5), 5*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(4, 4, 6), 6*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(4, 4, 7), 7*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(4, 4, 8), 8*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(4, 4, 9), 9*thick + thick/2.0f, 1.0e-10f); + + BOOST_CHECK_CLOSE(xRFT.pressure(4, 4, 4), 150.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(4, 4, 5), 160.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(4, 4, 6), 170.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(4, 4, 7), 180.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(4, 4, 8), 190.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(4, 4, 9), 200.0f, 1.0e-10f); + + BOOST_CHECK_CLOSE(xRFT.sgas(4, 4, 4), 0.45f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(4, 4, 5), 0.40f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(4, 4, 6), 0.35f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(4, 4, 7), 0.30f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(4, 4, 8), 0.25f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(4, 4, 9), 0.20f, 1.0e-10f); + + BOOST_CHECK_CLOSE(xRFT.swat(4, 4, 4), 0.25f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(4, 4, 5), 0.25f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(4, 4, 6), 0.25f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(4, 4, 7), 0.25f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(4, 4, 8), 0.25f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(4, 4, 9), 0.25f, 1.0e-10f); + } + + { + const auto xRFT = RFTRresults { + rft, "OP_2", RftDate{ 2008, 11, 10 } + }; + + const auto thick = 0.25f; + + BOOST_CHECK_CLOSE(xRFT.depth(4, 4, 4), 4*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(4, 4, 5), 5*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(4, 4, 6), 6*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(4, 4, 7), 7*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(4, 4, 8), 8*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(4, 4, 9), 9*thick + thick/2.0f, 1.0e-10f); + + BOOST_CHECK_CLOSE(xRFT.pressure(4, 4, 4), 150.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(4, 4, 5), 160.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(4, 4, 6), 170.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(4, 4, 7), 180.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(4, 4, 8), 190.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(4, 4, 9), 200.0f, 1.0e-10f); + + BOOST_CHECK_CLOSE(xRFT.sgas(4, 4, 4), 0.45f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(4, 4, 5), 0.40f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(4, 4, 6), 0.35f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(4, 4, 7), 0.30f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(4, 4, 8), 0.25f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(4, 4, 9), 0.20f, 1.0e-10f); + + BOOST_CHECK_CLOSE(xRFT.swat(4, 4, 4), 0.25f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(4, 4, 5), 0.25f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(4, 4, 6), 0.25f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(4, 4, 7), 0.25f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(4, 4, 8), 0.25f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(4, 4, 9), 0.25f, 1.0e-10f); + } + + { + const auto date = RftDate{2008, 10, 10}; + + BOOST_CHECK(rft.hasArray("WELLETC", "OP_1", date)); + + const auto& welletc = rft.getRft("WELLETC", "OP_1", date); + + BOOST_CHECK_EQUAL(welletc[ 0], " DAYS"); + BOOST_CHECK_EQUAL(welletc[ 1], "OP_1"); + BOOST_CHECK_EQUAL(welletc[ 2], ""); + BOOST_CHECK_EQUAL(welletc[ 3], " METRES"); + BOOST_CHECK_EQUAL(welletc[ 4], " BARSA"); + BOOST_CHECK_EQUAL(welletc[ 5], "R"); + BOOST_CHECK_EQUAL(welletc[ 6], "STANDARD"); + BOOST_CHECK_EQUAL(welletc[ 7], " SM3/DAY"); + BOOST_CHECK_EQUAL(welletc[ 8], " SM3/DAY"); + BOOST_CHECK_EQUAL(welletc[ 9], " RM3/DAY"); + BOOST_CHECK_EQUAL(welletc[10], " M/SEC"); + // No check for welletc[11] + BOOST_CHECK_EQUAL(welletc[12], " CP"); + BOOST_CHECK_EQUAL(welletc[13], " KG/SM3"); + BOOST_CHECK_EQUAL(welletc[14], " KG/DAY"); + BOOST_CHECK_EQUAL(welletc[15], " KG/KG"); + } + + { + const auto date = RftDate{2008, 10, 10}; + + BOOST_CHECK(rft.hasArray("WELLETC", "OP_2", date)); + + const auto& welletc = rft.getRft("WELLETC", "OP_2", date); + + BOOST_CHECK_EQUAL(welletc[ 0], " DAYS"); + BOOST_CHECK_EQUAL(welletc[ 1], "OP_2"); + BOOST_CHECK_EQUAL(welletc[ 2], ""); + BOOST_CHECK_EQUAL(welletc[ 3], " METRES"); + BOOST_CHECK_EQUAL(welletc[ 4], " BARSA"); + BOOST_CHECK_EQUAL(welletc[ 5], "R"); + BOOST_CHECK_EQUAL(welletc[ 6], "STANDARD"); + BOOST_CHECK_EQUAL(welletc[ 7], " SM3/DAY"); + BOOST_CHECK_EQUAL(welletc[ 8], " SM3/DAY"); + BOOST_CHECK_EQUAL(welletc[ 9], " RM3/DAY"); + BOOST_CHECK_EQUAL(welletc[10], " M/SEC"); + // No check for welletc[11] + BOOST_CHECK_EQUAL(welletc[12], " CP"); + BOOST_CHECK_EQUAL(welletc[13], " KG/SM3"); + BOOST_CHECK_EQUAL(welletc[14], " KG/DAY"); + BOOST_CHECK_EQUAL(welletc[15], " KG/KG"); + } + + { + const auto date = RftDate{2008, 11, 10}; + + BOOST_CHECK(rft.hasArray("WELLETC", "OP_2", date)); + + const auto& welletc = rft.getRft("WELLETC", "OP_2", date); + + BOOST_CHECK_EQUAL(welletc[ 0], " DAYS"); + BOOST_CHECK_EQUAL(welletc[ 1], "OP_2"); + BOOST_CHECK_EQUAL(welletc[ 2], ""); + BOOST_CHECK_EQUAL(welletc[ 3], " METRES"); + BOOST_CHECK_EQUAL(welletc[ 4], " BARSA"); + BOOST_CHECK_EQUAL(welletc[ 5], "R"); + BOOST_CHECK_EQUAL(welletc[ 6], "STANDARD"); + BOOST_CHECK_EQUAL(welletc[ 7], " SM3/DAY"); + BOOST_CHECK_EQUAL(welletc[ 8], " SM3/DAY"); + BOOST_CHECK_EQUAL(welletc[ 9], " RM3/DAY"); + BOOST_CHECK_EQUAL(welletc[10], " M/SEC"); + // No check for welletc[11] + BOOST_CHECK_EQUAL(welletc[12], " CP"); + BOOST_CHECK_EQUAL(welletc[13], " KG/SM3"); + BOOST_CHECK_EQUAL(welletc[14], " KG/DAY"); + BOOST_CHECK_EQUAL(welletc[15], " KG/KG"); + } + } +} + +BOOST_AUTO_TEST_CASE(Basic_Formatted) +{ + using RftDate = ::Opm::EclIO::ERft::RftDate; + + const auto rset = RSet { "TESTRFT" }; + const auto model = Setup{ "testrft.DATA" }; + + { + auto rftFile = ::Opm::EclIO::OutputStream::RFT { + rset, ::Opm::EclIO::OutputStream::Formatted { true }, + ::Opm::EclIO::OutputStream::RFT::OpenExisting{ false } + }; + + const auto reportStep = 2; + const auto elapsed = model.sched.seconds(reportStep); + const auto& grid = model.es.getInputGrid(); + + ::Opm::RftIO::write(reportStep, elapsed, model.es.getUnits(), + grid, model.sched, wellSol(grid), rftFile); + } + + { + const auto rft = ::Opm::EclIO::ERft { + ::Opm::EclIO::OutputStream::outputFileName(rset, "FRFT") + }; + + { + const auto xRFT = RFTRresults { + rft, "OP_1", RftDate{ 2008, 10, 10 } + }; + + const auto thick = 0.25f; + + BOOST_CHECK_CLOSE(xRFT.depth(9, 9, 1), 1*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(9, 9, 2), 2*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(9, 9, 3), 3*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(9, 9, 4), 4*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(9, 9, 5), 5*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(9, 9, 6), 6*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(9, 9, 7), 7*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(9, 9, 8), 8*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(9, 9, 9), 9*thick + thick/2.0f, 1.0e-10f); + + BOOST_CHECK_CLOSE(xRFT.pressure(9, 9, 1), 120.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(9, 9, 2), 130.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(9, 9, 3), 140.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(9, 9, 4), 150.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(9, 9, 5), 160.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(9, 9, 6), 170.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(9, 9, 7), 180.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(9, 9, 8), 190.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(9, 9, 9), 200.0f, 1.0e-10f); + + BOOST_CHECK_CLOSE(xRFT.sgas(9, 9, 1), 0.15f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(9, 9, 2), 0.15f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(9, 9, 3), 0.15f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(9, 9, 4), 0.15f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(9, 9, 5), 0.15f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(9, 9, 6), 0.15f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(9, 9, 7), 0.15f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(9, 9, 8), 0.15f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(9, 9, 9), 0.15f, 1.0e-10f); + + BOOST_CHECK_CLOSE(xRFT.swat(9, 9, 1), 0.30f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(9, 9, 2), 0.35f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(9, 9, 3), 0.40f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(9, 9, 4), 0.45f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(9, 9, 5), 0.50f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(9, 9, 6), 0.55f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(9, 9, 7), 0.60f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(9, 9, 8), 0.65f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(9, 9, 9), 0.70f, 1.0e-10f); + } + + { + const auto xRFT = RFTRresults { + rft, "OP_2", RftDate{ 2008, 10, 10 } + }; + + const auto thick = 0.25f; + + BOOST_CHECK_CLOSE(xRFT.depth(4, 4, 4), 4*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(4, 4, 5), 5*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(4, 4, 6), 6*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(4, 4, 7), 7*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(4, 4, 8), 8*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(4, 4, 9), 9*thick + thick/2.0f, 1.0e-10f); + + BOOST_CHECK_CLOSE(xRFT.pressure(4, 4, 4), 150.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(4, 4, 5), 160.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(4, 4, 6), 170.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(4, 4, 7), 180.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(4, 4, 8), 190.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(4, 4, 9), 200.0f, 1.0e-10f); + + BOOST_CHECK_CLOSE(xRFT.sgas(4, 4, 4), 0.45f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(4, 4, 5), 0.40f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(4, 4, 6), 0.35f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(4, 4, 7), 0.30f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(4, 4, 8), 0.25f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(4, 4, 9), 0.20f, 1.0e-10f); + + BOOST_CHECK_CLOSE(xRFT.swat(4, 4, 4), 0.25f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(4, 4, 5), 0.25f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(4, 4, 6), 0.25f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(4, 4, 7), 0.25f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(4, 4, 8), 0.25f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(4, 4, 9), 0.25f, 1.0e-10f); + } + + { + const auto date = RftDate{2008, 10, 10}; + + BOOST_CHECK(rft.hasArray("WELLETC", "OP_1", date)); + + const auto& welletc = rft.getRft("WELLETC", "OP_1", date); + + BOOST_CHECK_EQUAL(welletc[ 0], " DAYS"); + BOOST_CHECK_EQUAL(welletc[ 1], "OP_1"); + BOOST_CHECK_EQUAL(welletc[ 2], ""); + BOOST_CHECK_EQUAL(welletc[ 3], " METRES"); + BOOST_CHECK_EQUAL(welletc[ 4], " BARSA"); + BOOST_CHECK_EQUAL(welletc[ 5], "R"); + BOOST_CHECK_EQUAL(welletc[ 6], "STANDARD"); + BOOST_CHECK_EQUAL(welletc[ 7], " SM3/DAY"); + BOOST_CHECK_EQUAL(welletc[ 8], " SM3/DAY"); + BOOST_CHECK_EQUAL(welletc[ 9], " RM3/DAY"); + BOOST_CHECK_EQUAL(welletc[10], " M/SEC"); + // No check for welletc[11] + BOOST_CHECK_EQUAL(welletc[12], " CP"); + BOOST_CHECK_EQUAL(welletc[13], " KG/SM3"); + BOOST_CHECK_EQUAL(welletc[14], " KG/DAY"); + BOOST_CHECK_EQUAL(welletc[15], " KG/KG"); + } + + { + const auto date = RftDate{2008, 10, 10}; + + BOOST_CHECK(rft.hasArray("WELLETC", "OP_2", date)); + + const auto& welletc = rft.getRft("WELLETC", "OP_2", date); + + BOOST_CHECK_EQUAL(welletc[ 0], " DAYS"); + BOOST_CHECK_EQUAL(welletc[ 1], "OP_2"); + BOOST_CHECK_EQUAL(welletc[ 2], ""); + BOOST_CHECK_EQUAL(welletc[ 3], " METRES"); + BOOST_CHECK_EQUAL(welletc[ 4], " BARSA"); + BOOST_CHECK_EQUAL(welletc[ 5], "R"); + BOOST_CHECK_EQUAL(welletc[ 6], "STANDARD"); + BOOST_CHECK_EQUAL(welletc[ 7], " SM3/DAY"); + BOOST_CHECK_EQUAL(welletc[ 8], " SM3/DAY"); + BOOST_CHECK_EQUAL(welletc[ 9], " RM3/DAY"); + BOOST_CHECK_EQUAL(welletc[10], " M/SEC"); + // No check for welletc[11] + BOOST_CHECK_EQUAL(welletc[12], " CP"); + BOOST_CHECK_EQUAL(welletc[13], " KG/SM3"); + BOOST_CHECK_EQUAL(welletc[14], " KG/DAY"); + BOOST_CHECK_EQUAL(welletc[15], " KG/KG"); + } + } + + { + auto rftFile = ::Opm::EclIO::OutputStream::RFT { + rset, ::Opm::EclIO::OutputStream::Formatted { true }, + ::Opm::EclIO::OutputStream::RFT::OpenExisting{ true } + }; + + const auto reportStep = 3; + const auto elapsed = model.sched.seconds(reportStep); + const auto& grid = model.es.getInputGrid(); + + ::Opm::RftIO::write(reportStep, elapsed, model.es.getUnits(), + grid, model.sched, wellSol(grid), rftFile); + } + + { + const auto rft = ::Opm::EclIO::ERft { + ::Opm::EclIO::OutputStream::outputFileName(rset, "FRFT") + }; + + { + const auto xRFT = RFTRresults { + rft, "OP_1", RftDate{ 2008, 10, 10 } + }; + + const auto thick = 0.25f; + + BOOST_CHECK_CLOSE(xRFT.depth(9, 9, 1), 1*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(9, 9, 2), 2*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(9, 9, 3), 3*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(9, 9, 4), 4*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(9, 9, 5), 5*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(9, 9, 6), 6*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(9, 9, 7), 7*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(9, 9, 8), 8*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(9, 9, 9), 9*thick + thick/2.0f, 1.0e-10f); + + BOOST_CHECK_CLOSE(xRFT.pressure(9, 9, 1), 120.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(9, 9, 2), 130.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(9, 9, 3), 140.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(9, 9, 4), 150.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(9, 9, 5), 160.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(9, 9, 6), 170.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(9, 9, 7), 180.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(9, 9, 8), 190.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(9, 9, 9), 200.0f, 1.0e-10f); + + BOOST_CHECK_CLOSE(xRFT.sgas(9, 9, 1), 0.15f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(9, 9, 2), 0.15f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(9, 9, 3), 0.15f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(9, 9, 4), 0.15f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(9, 9, 5), 0.15f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(9, 9, 6), 0.15f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(9, 9, 7), 0.15f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(9, 9, 8), 0.15f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(9, 9, 9), 0.15f, 1.0e-10f); + + BOOST_CHECK_CLOSE(xRFT.swat(9, 9, 1), 0.30f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(9, 9, 2), 0.35f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(9, 9, 3), 0.40f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(9, 9, 4), 0.45f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(9, 9, 5), 0.50f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(9, 9, 6), 0.55f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(9, 9, 7), 0.60f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(9, 9, 8), 0.65f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(9, 9, 9), 0.70f, 1.0e-10f); + } + + { + const auto xRFT = RFTRresults { + rft, "OP_2", RftDate{ 2008, 10, 10 } + }; + + const auto thick = 0.25f; + + BOOST_CHECK_CLOSE(xRFT.depth(4, 4, 4), 4*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(4, 4, 5), 5*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(4, 4, 6), 6*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(4, 4, 7), 7*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(4, 4, 8), 8*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(4, 4, 9), 9*thick + thick/2.0f, 1.0e-10f); + + BOOST_CHECK_CLOSE(xRFT.pressure(4, 4, 4), 150.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(4, 4, 5), 160.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(4, 4, 6), 170.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(4, 4, 7), 180.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(4, 4, 8), 190.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(4, 4, 9), 200.0f, 1.0e-10f); + + BOOST_CHECK_CLOSE(xRFT.sgas(4, 4, 4), 0.45f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(4, 4, 5), 0.40f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(4, 4, 6), 0.35f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(4, 4, 7), 0.30f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(4, 4, 8), 0.25f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(4, 4, 9), 0.20f, 1.0e-10f); + + BOOST_CHECK_CLOSE(xRFT.swat(4, 4, 4), 0.25f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(4, 4, 5), 0.25f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(4, 4, 6), 0.25f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(4, 4, 7), 0.25f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(4, 4, 8), 0.25f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(4, 4, 9), 0.25f, 1.0e-10f); + } + + { + const auto xRFT = RFTRresults { + rft, "OP_2", RftDate{ 2008, 11, 10 } + }; + + const auto thick = 0.25f; + + BOOST_CHECK_CLOSE(xRFT.depth(4, 4, 4), 4*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(4, 4, 5), 5*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(4, 4, 6), 6*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(4, 4, 7), 7*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(4, 4, 8), 8*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(4, 4, 9), 9*thick + thick/2.0f, 1.0e-10f); + + BOOST_CHECK_CLOSE(xRFT.pressure(4, 4, 4), 150.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(4, 4, 5), 160.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(4, 4, 6), 170.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(4, 4, 7), 180.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(4, 4, 8), 190.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(4, 4, 9), 200.0f, 1.0e-10f); + + BOOST_CHECK_CLOSE(xRFT.sgas(4, 4, 4), 0.45f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(4, 4, 5), 0.40f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(4, 4, 6), 0.35f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(4, 4, 7), 0.30f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(4, 4, 8), 0.25f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(4, 4, 9), 0.20f, 1.0e-10f); + + BOOST_CHECK_CLOSE(xRFT.swat(4, 4, 4), 0.25f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(4, 4, 5), 0.25f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(4, 4, 6), 0.25f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(4, 4, 7), 0.25f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(4, 4, 8), 0.25f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(4, 4, 9), 0.25f, 1.0e-10f); + } + + { + const auto date = RftDate{2008, 10, 10}; + + BOOST_CHECK(rft.hasArray("WELLETC", "OP_1", date)); + + const auto& welletc = rft.getRft("WELLETC", "OP_1", date); + + BOOST_CHECK_EQUAL(welletc[ 0], " DAYS"); + BOOST_CHECK_EQUAL(welletc[ 1], "OP_1"); + BOOST_CHECK_EQUAL(welletc[ 2], ""); + BOOST_CHECK_EQUAL(welletc[ 3], " METRES"); + BOOST_CHECK_EQUAL(welletc[ 4], " BARSA"); + BOOST_CHECK_EQUAL(welletc[ 5], "R"); + BOOST_CHECK_EQUAL(welletc[ 6], "STANDARD"); + BOOST_CHECK_EQUAL(welletc[ 7], " SM3/DAY"); + BOOST_CHECK_EQUAL(welletc[ 8], " SM3/DAY"); + BOOST_CHECK_EQUAL(welletc[ 9], " RM3/DAY"); + BOOST_CHECK_EQUAL(welletc[10], " M/SEC"); + // No check for welletc[11] + BOOST_CHECK_EQUAL(welletc[12], " CP"); + BOOST_CHECK_EQUAL(welletc[13], " KG/SM3"); + BOOST_CHECK_EQUAL(welletc[14], " KG/DAY"); + BOOST_CHECK_EQUAL(welletc[15], " KG/KG"); + } + + { + const auto date = RftDate{2008, 10, 10}; + + BOOST_CHECK(rft.hasArray("WELLETC", "OP_2", date)); + + const auto& welletc = rft.getRft("WELLETC", "OP_2", date); + + BOOST_CHECK_EQUAL(welletc[ 0], " DAYS"); + BOOST_CHECK_EQUAL(welletc[ 1], "OP_2"); + BOOST_CHECK_EQUAL(welletc[ 2], ""); + BOOST_CHECK_EQUAL(welletc[ 3], " METRES"); + BOOST_CHECK_EQUAL(welletc[ 4], " BARSA"); + BOOST_CHECK_EQUAL(welletc[ 5], "R"); + BOOST_CHECK_EQUAL(welletc[ 6], "STANDARD"); + BOOST_CHECK_EQUAL(welletc[ 7], " SM3/DAY"); + BOOST_CHECK_EQUAL(welletc[ 8], " SM3/DAY"); + BOOST_CHECK_EQUAL(welletc[ 9], " RM3/DAY"); + BOOST_CHECK_EQUAL(welletc[10], " M/SEC"); + // No check for welletc[11] + BOOST_CHECK_EQUAL(welletc[12], " CP"); + BOOST_CHECK_EQUAL(welletc[13], " KG/SM3"); + BOOST_CHECK_EQUAL(welletc[14], " KG/DAY"); + BOOST_CHECK_EQUAL(welletc[15], " KG/KG"); + } + + { + const auto date = RftDate{2008, 11, 10}; + + BOOST_CHECK(rft.hasArray("WELLETC", "OP_2", date)); + + const auto& welletc = rft.getRft("WELLETC", "OP_2", date); + + BOOST_CHECK_EQUAL(welletc[ 0], " DAYS"); + BOOST_CHECK_EQUAL(welletc[ 1], "OP_2"); + BOOST_CHECK_EQUAL(welletc[ 2], ""); + BOOST_CHECK_EQUAL(welletc[ 3], " METRES"); + BOOST_CHECK_EQUAL(welletc[ 4], " BARSA"); + BOOST_CHECK_EQUAL(welletc[ 5], "R"); + BOOST_CHECK_EQUAL(welletc[ 6], "STANDARD"); + BOOST_CHECK_EQUAL(welletc[ 7], " SM3/DAY"); + BOOST_CHECK_EQUAL(welletc[ 8], " SM3/DAY"); + BOOST_CHECK_EQUAL(welletc[ 9], " RM3/DAY"); + BOOST_CHECK_EQUAL(welletc[10], " M/SEC"); + // No check for welletc[11] + BOOST_CHECK_EQUAL(welletc[12], " CP"); + BOOST_CHECK_EQUAL(welletc[13], " KG/SM3"); + BOOST_CHECK_EQUAL(welletc[14], " KG/DAY"); + BOOST_CHECK_EQUAL(welletc[15], " KG/KG"); + } + } +} + +BOOST_AUTO_TEST_CASE(Field_Units) +{ + using RftDate = ::Opm::EclIO::ERft::RftDate; + + const auto rset = RSet { "TESTRFT" }; + const auto model = Setup{ "testrft.DATA" }; + const auto usys = ::Opm::UnitSystem::newFIELD(); + + { + auto rftFile = ::Opm::EclIO::OutputStream::RFT { + rset, ::Opm::EclIO::OutputStream::Formatted { false }, + ::Opm::EclIO::OutputStream::RFT::OpenExisting{ false } + }; + + const auto reportStep = 2; + const auto elapsed = model.sched.seconds(reportStep); + const auto& grid = model.es.getInputGrid(); + + ::Opm::RftIO::write(reportStep, elapsed, usys, grid, + model.sched, wellSol(grid), rftFile); + } + + { + const auto rft = ::Opm::EclIO::ERft { + ::Opm::EclIO::OutputStream::outputFileName(rset, "RFT") + }; + + { + const auto xRFT = RFTRresults { + rft, "OP_1", RftDate{ 2008, 10, 10 } + }; + + const auto thick = ::Opm::unit::convert::to(0.25f, ::Opm::unit::feet); + + BOOST_CHECK_CLOSE(xRFT.depth(9, 9, 1), 1*thick + thick/2.0f, 5.0e-6f); + BOOST_CHECK_CLOSE(xRFT.depth(9, 9, 2), 2*thick + thick/2.0f, 5.0e-6f); + BOOST_CHECK_CLOSE(xRFT.depth(9, 9, 3), 3*thick + thick/2.0f, 5.0e-6f); + BOOST_CHECK_CLOSE(xRFT.depth(9, 9, 4), 4*thick + thick/2.0f, 5.0e-6f); + BOOST_CHECK_CLOSE(xRFT.depth(9, 9, 5), 5*thick + thick/2.0f, 5.0e-6f); + BOOST_CHECK_CLOSE(xRFT.depth(9, 9, 6), 6*thick + thick/2.0f, 5.0e-6f); + BOOST_CHECK_CLOSE(xRFT.depth(9, 9, 7), 7*thick + thick/2.0f, 5.0e-6f); + BOOST_CHECK_CLOSE(xRFT.depth(9, 9, 8), 8*thick + thick/2.0f, 5.0e-6f); + BOOST_CHECK_CLOSE(xRFT.depth(9, 9, 9), 9*thick + thick/2.0f, 5.0e-6f); + + BOOST_CHECK_CLOSE(xRFT.pressure(9, 9, 1), 1.740452852762511e+03f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(9, 9, 2), 1.885490590492720e+03f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(9, 9, 3), 2.030528328222930e+03f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(9, 9, 4), 2.175566065953139e+03f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(9, 9, 5), 2.320603803683348e+03f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(9, 9, 6), 2.465641541413557e+03f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(9, 9, 7), 2.610679279143767e+03f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(9, 9, 8), 2.755717016873976e+03f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(9, 9, 9), 2.900754754604185e+03f, 1.0e-10f); + + BOOST_CHECK_CLOSE(xRFT.sgas(9, 9, 1), 0.15f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(9, 9, 2), 0.15f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(9, 9, 3), 0.15f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(9, 9, 4), 0.15f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(9, 9, 5), 0.15f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(9, 9, 6), 0.15f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(9, 9, 7), 0.15f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(9, 9, 8), 0.15f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(9, 9, 9), 0.15f, 1.0e-10f); + + BOOST_CHECK_CLOSE(xRFT.swat(9, 9, 1), 0.30f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(9, 9, 2), 0.35f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(9, 9, 3), 0.40f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(9, 9, 4), 0.45f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(9, 9, 5), 0.50f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(9, 9, 6), 0.55f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(9, 9, 7), 0.60f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(9, 9, 8), 0.65f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(9, 9, 9), 0.70f, 1.0e-10f); + } + + { + const auto xRFT = RFTRresults { + rft, "OP_2", RftDate{ 2008, 10, 10 } + }; + + const auto thick = ::Opm::unit::convert::to(0.25f, ::Opm::unit::feet); + + BOOST_CHECK_CLOSE(xRFT.depth(4, 4, 4), 4*thick + thick/2.0f, 5.0e-6f); + BOOST_CHECK_CLOSE(xRFT.depth(4, 4, 5), 5*thick + thick/2.0f, 5.0e-6f); + BOOST_CHECK_CLOSE(xRFT.depth(4, 4, 6), 6*thick + thick/2.0f, 5.0e-6f); + BOOST_CHECK_CLOSE(xRFT.depth(4, 4, 7), 7*thick + thick/2.0f, 5.0e-6f); + BOOST_CHECK_CLOSE(xRFT.depth(4, 4, 8), 8*thick + thick/2.0f, 5.0e-6f); + BOOST_CHECK_CLOSE(xRFT.depth(4, 4, 9), 9*thick + thick/2.0f, 5.0e-6f); + + BOOST_CHECK_CLOSE(xRFT.pressure(4, 4, 4), 2.175566065953139e+03f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(4, 4, 5), 2.320603803683348e+03f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(4, 4, 6), 2.465641541413557e+03f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(4, 4, 7), 2.610679279143767e+03f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(4, 4, 8), 2.755717016873976e+03f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(4, 4, 9), 2.900754754604185e+03f, 1.0e-10f); + + BOOST_CHECK_CLOSE(xRFT.sgas(4, 4, 4), 0.45f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(4, 4, 5), 0.40f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(4, 4, 6), 0.35f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(4, 4, 7), 0.30f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(4, 4, 8), 0.25f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(4, 4, 9), 0.20f, 1.0e-10f); + + BOOST_CHECK_CLOSE(xRFT.swat(4, 4, 4), 0.25f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(4, 4, 5), 0.25f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(4, 4, 6), 0.25f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(4, 4, 7), 0.25f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(4, 4, 8), 0.25f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(4, 4, 9), 0.25f, 1.0e-10f); + } + + { + const auto date = RftDate{2008, 10, 10}; + + BOOST_CHECK(rft.hasArray("WELLETC", "OP_1", date)); + + const auto& welletc = rft.getRft("WELLETC", "OP_1", date); + + BOOST_CHECK_EQUAL(welletc[ 0], " DAYS"); + BOOST_CHECK_EQUAL(welletc[ 1], "OP_1"); + BOOST_CHECK_EQUAL(welletc[ 2], ""); + BOOST_CHECK_EQUAL(welletc[ 3], " FEET"); + BOOST_CHECK_EQUAL(welletc[ 4], " PSIA"); + BOOST_CHECK_EQUAL(welletc[ 5], "R"); + BOOST_CHECK_EQUAL(welletc[ 6], "STANDARD"); + BOOST_CHECK_EQUAL(welletc[ 7], " STB/DAY"); + BOOST_CHECK_EQUAL(welletc[ 8], "MSCF/DAY"); + BOOST_CHECK_EQUAL(welletc[ 9], " RB/DAY"); + BOOST_CHECK_EQUAL(welletc[10], " FT/SEC"); + // No check for welletc[11] + BOOST_CHECK_EQUAL(welletc[12], " CP"); + BOOST_CHECK_EQUAL(welletc[13], " LB/STB"); + BOOST_CHECK_EQUAL(welletc[14], " LB/DAY"); + BOOST_CHECK_EQUAL(welletc[15], " LB/LB"); + } + + { + const auto date = RftDate{2008, 10, 10}; + + BOOST_CHECK(rft.hasArray("WELLETC", "OP_2", date)); + + const auto& welletc = rft.getRft("WELLETC", "OP_2", date); + + BOOST_CHECK_EQUAL(welletc[ 0], " DAYS"); + BOOST_CHECK_EQUAL(welletc[ 1], "OP_2"); + BOOST_CHECK_EQUAL(welletc[ 2], ""); + BOOST_CHECK_EQUAL(welletc[ 3], " FEET"); + BOOST_CHECK_EQUAL(welletc[ 4], " PSIA"); + BOOST_CHECK_EQUAL(welletc[ 5], "R"); + BOOST_CHECK_EQUAL(welletc[ 6], "STANDARD"); + BOOST_CHECK_EQUAL(welletc[ 7], " STB/DAY"); + BOOST_CHECK_EQUAL(welletc[ 8], "MSCF/DAY"); + BOOST_CHECK_EQUAL(welletc[ 9], " RB/DAY"); + BOOST_CHECK_EQUAL(welletc[10], " FT/SEC"); + // No check for welletc[11] + BOOST_CHECK_EQUAL(welletc[12], " CP"); + BOOST_CHECK_EQUAL(welletc[13], " LB/STB"); + BOOST_CHECK_EQUAL(welletc[14], " LB/DAY"); + BOOST_CHECK_EQUAL(welletc[15], " LB/LB"); + } + } + + { + auto rftFile = ::Opm::EclIO::OutputStream::RFT { + rset, ::Opm::EclIO::OutputStream::Formatted { false }, + ::Opm::EclIO::OutputStream::RFT::OpenExisting{ true } + }; + + const auto reportStep = 3; + const auto elapsed = model.sched.seconds(reportStep); + const auto& grid = model.es.getInputGrid(); + + ::Opm::RftIO::write(reportStep, elapsed, usys, grid, + model.sched, wellSol(grid), rftFile); + } + + { + const auto rft = ::Opm::EclIO::ERft { + ::Opm::EclIO::OutputStream::outputFileName(rset, "RFT") + }; + + { + const auto xRFT = RFTRresults { + rft, "OP_1", RftDate{ 2008, 10, 10 } + }; + + const auto thick = ::Opm::unit::convert::to(0.25f, ::Opm::unit::feet); + + BOOST_CHECK_CLOSE(xRFT.depth(9, 9, 1), 1*thick + thick/2.0f, 5.0e-6f); + BOOST_CHECK_CLOSE(xRFT.depth(9, 9, 2), 2*thick + thick/2.0f, 5.0e-6f); + BOOST_CHECK_CLOSE(xRFT.depth(9, 9, 3), 3*thick + thick/2.0f, 5.0e-6f); + BOOST_CHECK_CLOSE(xRFT.depth(9, 9, 4), 4*thick + thick/2.0f, 5.0e-6f); + BOOST_CHECK_CLOSE(xRFT.depth(9, 9, 5), 5*thick + thick/2.0f, 5.0e-6f); + BOOST_CHECK_CLOSE(xRFT.depth(9, 9, 6), 6*thick + thick/2.0f, 5.0e-6f); + BOOST_CHECK_CLOSE(xRFT.depth(9, 9, 7), 7*thick + thick/2.0f, 5.0e-6f); + BOOST_CHECK_CLOSE(xRFT.depth(9, 9, 8), 8*thick + thick/2.0f, 5.0e-6f); + BOOST_CHECK_CLOSE(xRFT.depth(9, 9, 9), 9*thick + thick/2.0f, 5.0e-6f); + + BOOST_CHECK_CLOSE(xRFT.pressure(9, 9, 1), 1.740452852762511e+03f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(9, 9, 2), 1.885490590492720e+03f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(9, 9, 3), 2.030528328222930e+03f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(9, 9, 4), 2.175566065953139e+03f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(9, 9, 5), 2.320603803683348e+03f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(9, 9, 6), 2.465641541413557e+03f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(9, 9, 7), 2.610679279143767e+03f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(9, 9, 8), 2.755717016873976e+03f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(9, 9, 9), 2.900754754604185e+03f, 1.0e-10f); + + BOOST_CHECK_CLOSE(xRFT.sgas(9, 9, 1), 0.15f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(9, 9, 2), 0.15f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(9, 9, 3), 0.15f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(9, 9, 4), 0.15f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(9, 9, 5), 0.15f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(9, 9, 6), 0.15f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(9, 9, 7), 0.15f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(9, 9, 8), 0.15f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(9, 9, 9), 0.15f, 1.0e-10f); + + BOOST_CHECK_CLOSE(xRFT.swat(9, 9, 1), 0.30f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(9, 9, 2), 0.35f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(9, 9, 3), 0.40f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(9, 9, 4), 0.45f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(9, 9, 5), 0.50f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(9, 9, 6), 0.55f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(9, 9, 7), 0.60f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(9, 9, 8), 0.65f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(9, 9, 9), 0.70f, 1.0e-10f); + } + + { + const auto xRFT = RFTRresults { + rft, "OP_2", RftDate{ 2008, 10, 10 } + }; + + const auto thick = ::Opm::unit::convert::to(0.25f, ::Opm::unit::feet); + + BOOST_CHECK_CLOSE(xRFT.depth(4, 4, 4), 4*thick + thick/2.0f, 5.0e-6f); + BOOST_CHECK_CLOSE(xRFT.depth(4, 4, 5), 5*thick + thick/2.0f, 5.0e-6f); + BOOST_CHECK_CLOSE(xRFT.depth(4, 4, 6), 6*thick + thick/2.0f, 5.0e-6f); + BOOST_CHECK_CLOSE(xRFT.depth(4, 4, 7), 7*thick + thick/2.0f, 5.0e-6f); + BOOST_CHECK_CLOSE(xRFT.depth(4, 4, 8), 8*thick + thick/2.0f, 5.0e-6f); + BOOST_CHECK_CLOSE(xRFT.depth(4, 4, 9), 9*thick + thick/2.0f, 5.0e-6f); + + BOOST_CHECK_CLOSE(xRFT.pressure(4, 4, 4), 2.175566065953139e+03f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(4, 4, 5), 2.320603803683348e+03f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(4, 4, 6), 2.465641541413557e+03f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(4, 4, 7), 2.610679279143767e+03f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(4, 4, 8), 2.755717016873976e+03f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(4, 4, 9), 2.900754754604185e+03f, 1.0e-10f); + + BOOST_CHECK_CLOSE(xRFT.sgas(4, 4, 4), 0.45f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(4, 4, 5), 0.40f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(4, 4, 6), 0.35f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(4, 4, 7), 0.30f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(4, 4, 8), 0.25f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(4, 4, 9), 0.20f, 1.0e-10f); + + BOOST_CHECK_CLOSE(xRFT.swat(4, 4, 4), 0.25f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(4, 4, 5), 0.25f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(4, 4, 6), 0.25f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(4, 4, 7), 0.25f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(4, 4, 8), 0.25f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(4, 4, 9), 0.25f, 1.0e-10f); + } + + { + const auto xRFT = RFTRresults { + rft, "OP_2", RftDate{ 2008, 11, 10 } + }; + + const auto thick = ::Opm::unit::convert::to(0.25f, ::Opm::unit::feet); + + BOOST_CHECK_CLOSE(xRFT.depth(4, 4, 4), 4*thick + thick/2.0f, 5.0e-6f); + BOOST_CHECK_CLOSE(xRFT.depth(4, 4, 5), 5*thick + thick/2.0f, 5.0e-6f); + BOOST_CHECK_CLOSE(xRFT.depth(4, 4, 6), 6*thick + thick/2.0f, 5.0e-6f); + BOOST_CHECK_CLOSE(xRFT.depth(4, 4, 7), 7*thick + thick/2.0f, 5.0e-6f); + BOOST_CHECK_CLOSE(xRFT.depth(4, 4, 8), 8*thick + thick/2.0f, 5.0e-6f); + BOOST_CHECK_CLOSE(xRFT.depth(4, 4, 9), 9*thick + thick/2.0f, 5.0e-6f); + + BOOST_CHECK_CLOSE(xRFT.pressure(4, 4, 4), 2.175566065953139e+03f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(4, 4, 5), 2.320603803683348e+03f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(4, 4, 6), 2.465641541413557e+03f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(4, 4, 7), 2.610679279143767e+03f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(4, 4, 8), 2.755717016873976e+03f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(4, 4, 9), 2.900754754604185e+03f, 1.0e-10f); + + BOOST_CHECK_CLOSE(xRFT.sgas(4, 4, 4), 0.45f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(4, 4, 5), 0.40f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(4, 4, 6), 0.35f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(4, 4, 7), 0.30f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(4, 4, 8), 0.25f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(4, 4, 9), 0.20f, 1.0e-10f); + + BOOST_CHECK_CLOSE(xRFT.swat(4, 4, 4), 0.25f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(4, 4, 5), 0.25f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(4, 4, 6), 0.25f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(4, 4, 7), 0.25f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(4, 4, 8), 0.25f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(4, 4, 9), 0.25f, 1.0e-10f); + } + + { + const auto date = RftDate{2008, 10, 10}; + + BOOST_CHECK(rft.hasArray("WELLETC", "OP_1", date)); + + const auto& welletc = rft.getRft("WELLETC", "OP_1", date); + + BOOST_CHECK_EQUAL(welletc[ 0], " DAYS"); + BOOST_CHECK_EQUAL(welletc[ 1], "OP_1"); + BOOST_CHECK_EQUAL(welletc[ 2], ""); + BOOST_CHECK_EQUAL(welletc[ 3], " FEET"); + BOOST_CHECK_EQUAL(welletc[ 4], " PSIA"); + BOOST_CHECK_EQUAL(welletc[ 5], "R"); + BOOST_CHECK_EQUAL(welletc[ 6], "STANDARD"); + BOOST_CHECK_EQUAL(welletc[ 7], " STB/DAY"); + BOOST_CHECK_EQUAL(welletc[ 8], "MSCF/DAY"); + BOOST_CHECK_EQUAL(welletc[ 9], " RB/DAY"); + BOOST_CHECK_EQUAL(welletc[10], " FT/SEC"); + // No check for welletc[11] + BOOST_CHECK_EQUAL(welletc[12], " CP"); + BOOST_CHECK_EQUAL(welletc[13], " LB/STB"); + BOOST_CHECK_EQUAL(welletc[14], " LB/DAY"); + BOOST_CHECK_EQUAL(welletc[15], " LB/LB"); + } + + { + const auto date = RftDate{2008, 10, 10}; + + BOOST_CHECK(rft.hasArray("WELLETC", "OP_2", date)); + + const auto& welletc = rft.getRft("WELLETC", "OP_2", date); + + BOOST_CHECK_EQUAL(welletc[ 0], " DAYS"); + BOOST_CHECK_EQUAL(welletc[ 1], "OP_2"); + BOOST_CHECK_EQUAL(welletc[ 2], ""); + BOOST_CHECK_EQUAL(welletc[ 3], " FEET"); + BOOST_CHECK_EQUAL(welletc[ 4], " PSIA"); + BOOST_CHECK_EQUAL(welletc[ 5], "R"); + BOOST_CHECK_EQUAL(welletc[ 6], "STANDARD"); + BOOST_CHECK_EQUAL(welletc[ 7], " STB/DAY"); + BOOST_CHECK_EQUAL(welletc[ 8], "MSCF/DAY"); + BOOST_CHECK_EQUAL(welletc[ 9], " RB/DAY"); + BOOST_CHECK_EQUAL(welletc[10], " FT/SEC"); + // No check for welletc[11] + BOOST_CHECK_EQUAL(welletc[12], " CP"); + BOOST_CHECK_EQUAL(welletc[13], " LB/STB"); + BOOST_CHECK_EQUAL(welletc[14], " LB/DAY"); + BOOST_CHECK_EQUAL(welletc[15], " LB/LB"); + } + + { + const auto date = RftDate{2008, 11, 10}; + + BOOST_CHECK(rft.hasArray("WELLETC", "OP_2", date)); + + const auto& welletc = rft.getRft("WELLETC", "OP_2", date); + + BOOST_CHECK_EQUAL(welletc[ 0], " DAYS"); + BOOST_CHECK_EQUAL(welletc[ 1], "OP_2"); + BOOST_CHECK_EQUAL(welletc[ 2], ""); + BOOST_CHECK_EQUAL(welletc[ 3], " FEET"); + BOOST_CHECK_EQUAL(welletc[ 4], " PSIA"); + BOOST_CHECK_EQUAL(welletc[ 5], "R"); + BOOST_CHECK_EQUAL(welletc[ 6], "STANDARD"); + BOOST_CHECK_EQUAL(welletc[ 7], " STB/DAY"); + BOOST_CHECK_EQUAL(welletc[ 8], "MSCF/DAY"); + BOOST_CHECK_EQUAL(welletc[ 9], " RB/DAY"); + BOOST_CHECK_EQUAL(welletc[10], " FT/SEC"); + // No check for welletc[11] + BOOST_CHECK_EQUAL(welletc[12], " CP"); + BOOST_CHECK_EQUAL(welletc[13], " LB/STB"); + BOOST_CHECK_EQUAL(welletc[14], " LB/DAY"); + BOOST_CHECK_EQUAL(welletc[15], " LB/LB"); + } + } +} + +BOOST_AUTO_TEST_CASE(Lab_Units) +{ + using RftDate = ::Opm::EclIO::ERft::RftDate; + + const auto rset = RSet { "TESTRFT" }; + const auto model = Setup{ "testrft.DATA" }; + const auto usys = ::Opm::UnitSystem::newLAB(); + + { + auto rftFile = ::Opm::EclIO::OutputStream::RFT { + rset, ::Opm::EclIO::OutputStream::Formatted { false }, + ::Opm::EclIO::OutputStream::RFT::OpenExisting{ false } + }; + + const auto reportStep = 2; + const auto elapsed = model.sched.seconds(reportStep); + const auto& grid = model.es.getInputGrid(); + + ::Opm::RftIO::write(reportStep, elapsed, usys, grid, + model.sched, wellSol(grid), rftFile); + } + + { + const auto rft = ::Opm::EclIO::ERft { + ::Opm::EclIO::OutputStream::outputFileName(rset, "RFT") + }; + + { + const auto xRFT = RFTRresults { + rft, "OP_1", RftDate{ 2008, 10, 10 } + }; + + const auto thick = 25.0f; // cm + + BOOST_CHECK_CLOSE(xRFT.depth(9, 9, 1), 1*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(9, 9, 2), 2*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(9, 9, 3), 3*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(9, 9, 4), 4*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(9, 9, 5), 5*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(9, 9, 6), 6*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(9, 9, 7), 7*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(9, 9, 8), 8*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(9, 9, 9), 9*thick + thick/2.0f, 1.0e-10f); + + BOOST_CHECK_CLOSE(xRFT.pressure(9, 9, 1), 1.184307920059215e+02f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(9, 9, 2), 1.283000246730817e+02f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(9, 9, 3), 1.381692573402418e+02f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(9, 9, 4), 1.480384900074019e+02f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(9, 9, 5), 1.579077226745621e+02f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(9, 9, 6), 1.677769553417222e+02f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(9, 9, 7), 1.776461880088823e+02f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(9, 9, 8), 1.875154206760424e+02f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(9, 9, 9), 1.973846533432026e+02f, 1.0e-10f); + + BOOST_CHECK_CLOSE(xRFT.sgas(9, 9, 1), 0.15f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(9, 9, 2), 0.15f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(9, 9, 3), 0.15f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(9, 9, 4), 0.15f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(9, 9, 5), 0.15f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(9, 9, 6), 0.15f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(9, 9, 7), 0.15f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(9, 9, 8), 0.15f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(9, 9, 9), 0.15f, 1.0e-10f); + + BOOST_CHECK_CLOSE(xRFT.swat(9, 9, 1), 0.30f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(9, 9, 2), 0.35f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(9, 9, 3), 0.40f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(9, 9, 4), 0.45f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(9, 9, 5), 0.50f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(9, 9, 6), 0.55f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(9, 9, 7), 0.60f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(9, 9, 8), 0.65f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(9, 9, 9), 0.70f, 1.0e-10f); + } + + { + const auto xRFT = RFTRresults { + rft, "OP_2", RftDate{ 2008, 10, 10 } + }; + + const auto thick = 25.0f; // cm + + BOOST_CHECK_CLOSE(xRFT.depth(4, 4, 4), 4*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(4, 4, 5), 5*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(4, 4, 6), 6*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(4, 4, 7), 7*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(4, 4, 8), 8*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(4, 4, 9), 9*thick + thick/2.0f, 1.0e-10f); + + BOOST_CHECK_CLOSE(xRFT.pressure(4, 4, 4), 1.480384900074019e+02f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(4, 4, 5), 1.579077226745621e+02f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(4, 4, 6), 1.677769553417222e+02f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(4, 4, 7), 1.776461880088823e+02f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(4, 4, 8), 1.875154206760424e+02f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(4, 4, 9), 1.973846533432026e+02f, 1.0e-10f); + + BOOST_CHECK_CLOSE(xRFT.sgas(4, 4, 4), 0.45f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(4, 4, 5), 0.40f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(4, 4, 6), 0.35f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(4, 4, 7), 0.30f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(4, 4, 8), 0.25f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(4, 4, 9), 0.20f, 1.0e-10f); + + BOOST_CHECK_CLOSE(xRFT.swat(4, 4, 4), 0.25f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(4, 4, 5), 0.25f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(4, 4, 6), 0.25f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(4, 4, 7), 0.25f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(4, 4, 8), 0.25f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(4, 4, 9), 0.25f, 1.0e-10f); + } + + { + const auto date = RftDate{2008, 10, 10}; + + BOOST_CHECK(rft.hasArray("WELLETC", "OP_1", date)); + + const auto& welletc = rft.getRft("WELLETC", "OP_1", date); + + BOOST_CHECK_EQUAL(welletc[ 0], " HR"); + BOOST_CHECK_EQUAL(welletc[ 1], "OP_1"); + BOOST_CHECK_EQUAL(welletc[ 2], ""); + BOOST_CHECK_EQUAL(welletc[ 3], " CM"); + BOOST_CHECK_EQUAL(welletc[ 4], " ATMA"); + BOOST_CHECK_EQUAL(welletc[ 5], "R"); + BOOST_CHECK_EQUAL(welletc[ 6], "STANDARD"); + BOOST_CHECK_EQUAL(welletc[ 7], " SCC/HR"); + BOOST_CHECK_EQUAL(welletc[ 8], " SCC/HR"); + BOOST_CHECK_EQUAL(welletc[ 9], " RCC/HR"); + BOOST_CHECK_EQUAL(welletc[10], " CM/SEC"); + // No check for welletc[11] + BOOST_CHECK_EQUAL(welletc[12], " CP"); + BOOST_CHECK_EQUAL(welletc[13], " GM/SCC"); + BOOST_CHECK_EQUAL(welletc[14], " GM/HR"); + BOOST_CHECK_EQUAL(welletc[15], " GM/GM"); + } + + { + const auto date = RftDate{2008, 10, 10}; + + BOOST_CHECK(rft.hasArray("WELLETC", "OP_2", date)); + + const auto& welletc = rft.getRft("WELLETC", "OP_2", date); + + BOOST_CHECK_EQUAL(welletc[ 0], " HR"); + BOOST_CHECK_EQUAL(welletc[ 1], "OP_2"); + BOOST_CHECK_EQUAL(welletc[ 2], ""); + BOOST_CHECK_EQUAL(welletc[ 3], " CM"); + BOOST_CHECK_EQUAL(welletc[ 4], " ATMA"); + BOOST_CHECK_EQUAL(welletc[ 5], "R"); + BOOST_CHECK_EQUAL(welletc[ 6], "STANDARD"); + BOOST_CHECK_EQUAL(welletc[ 7], " SCC/HR"); + BOOST_CHECK_EQUAL(welletc[ 8], " SCC/HR"); + BOOST_CHECK_EQUAL(welletc[ 9], " RCC/HR"); + BOOST_CHECK_EQUAL(welletc[10], " CM/SEC"); + // No check for welletc[11] + BOOST_CHECK_EQUAL(welletc[12], " CP"); + BOOST_CHECK_EQUAL(welletc[13], " GM/SCC"); + BOOST_CHECK_EQUAL(welletc[14], " GM/HR"); + BOOST_CHECK_EQUAL(welletc[15], " GM/GM"); + } + } + + { + auto rftFile = ::Opm::EclIO::OutputStream::RFT { + rset, ::Opm::EclIO::OutputStream::Formatted { false }, + ::Opm::EclIO::OutputStream::RFT::OpenExisting{ true } + }; + + const auto reportStep = 3; + const auto elapsed = model.sched.seconds(reportStep); + const auto& grid = model.es.getInputGrid(); + + ::Opm::RftIO::write(reportStep, elapsed, usys, grid, + model.sched, wellSol(grid), rftFile); + } + + { + const auto rft = ::Opm::EclIO::ERft { + ::Opm::EclIO::OutputStream::outputFileName(rset, "RFT") + }; + + { + const auto xRFT = RFTRresults { + rft, "OP_1", RftDate{ 2008, 10, 10 } + }; + + const auto thick = 25.0f; // cm + + BOOST_CHECK_CLOSE(xRFT.depth(9, 9, 1), 1*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(9, 9, 2), 2*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(9, 9, 3), 3*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(9, 9, 4), 4*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(9, 9, 5), 5*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(9, 9, 6), 6*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(9, 9, 7), 7*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(9, 9, 8), 8*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(9, 9, 9), 9*thick + thick/2.0f, 1.0e-10f); + + BOOST_CHECK_CLOSE(xRFT.pressure(9, 9, 1), 1.184307920059215e+02f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(9, 9, 2), 1.283000246730817e+02f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(9, 9, 3), 1.381692573402418e+02f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(9, 9, 4), 1.480384900074019e+02f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(9, 9, 5), 1.579077226745621e+02f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(9, 9, 6), 1.677769553417222e+02f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(9, 9, 7), 1.776461880088823e+02f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(9, 9, 8), 1.875154206760424e+02f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(9, 9, 9), 1.973846533432026e+02f, 1.0e-10f); + + BOOST_CHECK_CLOSE(xRFT.sgas(9, 9, 1), 0.15f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(9, 9, 2), 0.15f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(9, 9, 3), 0.15f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(9, 9, 4), 0.15f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(9, 9, 5), 0.15f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(9, 9, 6), 0.15f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(9, 9, 7), 0.15f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(9, 9, 8), 0.15f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(9, 9, 9), 0.15f, 1.0e-10f); + + BOOST_CHECK_CLOSE(xRFT.swat(9, 9, 1), 0.30f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(9, 9, 2), 0.35f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(9, 9, 3), 0.40f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(9, 9, 4), 0.45f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(9, 9, 5), 0.50f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(9, 9, 6), 0.55f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(9, 9, 7), 0.60f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(9, 9, 8), 0.65f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(9, 9, 9), 0.70f, 1.0e-10f); + } + + { + const auto xRFT = RFTRresults { + rft, "OP_2", RftDate{ 2008, 10, 10 } + }; + + const auto thick = 25.0f; // cm + + BOOST_CHECK_CLOSE(xRFT.depth(4, 4, 4), 4*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(4, 4, 5), 5*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(4, 4, 6), 6*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(4, 4, 7), 7*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(4, 4, 8), 8*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(4, 4, 9), 9*thick + thick/2.0f, 1.0e-10f); + + BOOST_CHECK_CLOSE(xRFT.pressure(4, 4, 4), 1.480384900074019e+02f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(4, 4, 5), 1.579077226745621e+02f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(4, 4, 6), 1.677769553417222e+02f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(4, 4, 7), 1.776461880088823e+02f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(4, 4, 8), 1.875154206760424e+02f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(4, 4, 9), 1.973846533432026e+02f, 1.0e-10f); + + BOOST_CHECK_CLOSE(xRFT.sgas(4, 4, 4), 0.45f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(4, 4, 5), 0.40f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(4, 4, 6), 0.35f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(4, 4, 7), 0.30f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(4, 4, 8), 0.25f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(4, 4, 9), 0.20f, 1.0e-10f); + + BOOST_CHECK_CLOSE(xRFT.swat(4, 4, 4), 0.25f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(4, 4, 5), 0.25f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(4, 4, 6), 0.25f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(4, 4, 7), 0.25f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(4, 4, 8), 0.25f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(4, 4, 9), 0.25f, 1.0e-10f); + } + + { + const auto xRFT = RFTRresults { + rft, "OP_2", RftDate{ 2008, 11, 10 } + }; + + const auto thick = 25.0f; // cm + + BOOST_CHECK_CLOSE(xRFT.depth(4, 4, 4), 4*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(4, 4, 5), 5*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(4, 4, 6), 6*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(4, 4, 7), 7*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(4, 4, 8), 8*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(4, 4, 9), 9*thick + thick/2.0f, 1.0e-10f); + + BOOST_CHECK_CLOSE(xRFT.pressure(4, 4, 4), 1.480384900074019e+02f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(4, 4, 5), 1.579077226745621e+02f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(4, 4, 6), 1.677769553417222e+02f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(4, 4, 7), 1.776461880088823e+02f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(4, 4, 8), 1.875154206760424e+02f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(4, 4, 9), 1.973846533432026e+02f, 1.0e-10f); + + BOOST_CHECK_CLOSE(xRFT.sgas(4, 4, 4), 0.45f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(4, 4, 5), 0.40f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(4, 4, 6), 0.35f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(4, 4, 7), 0.30f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(4, 4, 8), 0.25f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(4, 4, 9), 0.20f, 1.0e-10f); + + BOOST_CHECK_CLOSE(xRFT.swat(4, 4, 4), 0.25f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(4, 4, 5), 0.25f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(4, 4, 6), 0.25f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(4, 4, 7), 0.25f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(4, 4, 8), 0.25f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(4, 4, 9), 0.25f, 1.0e-10f); + } + + { + const auto date = RftDate{2008, 10, 10}; + + BOOST_CHECK(rft.hasArray("WELLETC", "OP_1", date)); + + const auto& welletc = rft.getRft("WELLETC", "OP_1", date); + + BOOST_CHECK_EQUAL(welletc[ 0], " HR"); + BOOST_CHECK_EQUAL(welletc[ 1], "OP_1"); + BOOST_CHECK_EQUAL(welletc[ 2], ""); + BOOST_CHECK_EQUAL(welletc[ 3], " CM"); + BOOST_CHECK_EQUAL(welletc[ 4], " ATMA"); + BOOST_CHECK_EQUAL(welletc[ 5], "R"); + BOOST_CHECK_EQUAL(welletc[ 6], "STANDARD"); + BOOST_CHECK_EQUAL(welletc[ 7], " SCC/HR"); + BOOST_CHECK_EQUAL(welletc[ 8], " SCC/HR"); + BOOST_CHECK_EQUAL(welletc[ 9], " RCC/HR"); + BOOST_CHECK_EQUAL(welletc[10], " CM/SEC"); + // No check for welletc[11] + BOOST_CHECK_EQUAL(welletc[12], " CP"); + BOOST_CHECK_EQUAL(welletc[13], " GM/SCC"); + BOOST_CHECK_EQUAL(welletc[14], " GM/HR"); + BOOST_CHECK_EQUAL(welletc[15], " GM/GM"); + } + + { + const auto date = RftDate{2008, 10, 10}; + + BOOST_CHECK(rft.hasArray("WELLETC", "OP_2", date)); + + const auto& welletc = rft.getRft("WELLETC", "OP_2", date); + + BOOST_CHECK_EQUAL(welletc[ 0], " HR"); + BOOST_CHECK_EQUAL(welletc[ 1], "OP_2"); + BOOST_CHECK_EQUAL(welletc[ 2], ""); + BOOST_CHECK_EQUAL(welletc[ 3], " CM"); + BOOST_CHECK_EQUAL(welletc[ 4], " ATMA"); + BOOST_CHECK_EQUAL(welletc[ 5], "R"); + BOOST_CHECK_EQUAL(welletc[ 6], "STANDARD"); + BOOST_CHECK_EQUAL(welletc[ 7], " SCC/HR"); + BOOST_CHECK_EQUAL(welletc[ 8], " SCC/HR"); + BOOST_CHECK_EQUAL(welletc[ 9], " RCC/HR"); + BOOST_CHECK_EQUAL(welletc[10], " CM/SEC"); + // No check for welletc[11] + BOOST_CHECK_EQUAL(welletc[12], " CP"); + BOOST_CHECK_EQUAL(welletc[13], " GM/SCC"); + BOOST_CHECK_EQUAL(welletc[14], " GM/HR"); + BOOST_CHECK_EQUAL(welletc[15], " GM/GM"); + } + + { + const auto date = RftDate{2008, 11, 10}; + + BOOST_CHECK(rft.hasArray("WELLETC", "OP_2", date)); + + const auto& welletc = rft.getRft("WELLETC", "OP_2", date); + + BOOST_CHECK_EQUAL(welletc[ 0], " HR"); + BOOST_CHECK_EQUAL(welletc[ 1], "OP_2"); + BOOST_CHECK_EQUAL(welletc[ 2], ""); + BOOST_CHECK_EQUAL(welletc[ 3], " CM"); + BOOST_CHECK_EQUAL(welletc[ 4], " ATMA"); + BOOST_CHECK_EQUAL(welletc[ 5], "R"); + BOOST_CHECK_EQUAL(welletc[ 6], "STANDARD"); + BOOST_CHECK_EQUAL(welletc[ 7], " SCC/HR"); + BOOST_CHECK_EQUAL(welletc[ 8], " SCC/HR"); + BOOST_CHECK_EQUAL(welletc[ 9], " RCC/HR"); + BOOST_CHECK_EQUAL(welletc[10], " CM/SEC"); + // No check for welletc[11] + BOOST_CHECK_EQUAL(welletc[12], " CP"); + BOOST_CHECK_EQUAL(welletc[13], " GM/SCC"); + BOOST_CHECK_EQUAL(welletc[14], " GM/HR"); + BOOST_CHECK_EQUAL(welletc[15], " GM/GM"); + } + } +} + +BOOST_AUTO_TEST_CASE(PVT_M_Units) +{ + using RftDate = ::Opm::EclIO::ERft::RftDate; + + const auto rset = RSet { "TESTRFT" }; + const auto model = Setup{ "testrft.DATA" }; + const auto usys = ::Opm::UnitSystem::newPVT_M(); + + { + auto rftFile = ::Opm::EclIO::OutputStream::RFT { + rset, ::Opm::EclIO::OutputStream::Formatted { false }, + ::Opm::EclIO::OutputStream::RFT::OpenExisting{ false } + }; + + const auto reportStep = 2; + const auto elapsed = model.sched.seconds(reportStep); + const auto& grid = model.es.getInputGrid(); + + ::Opm::RftIO::write(reportStep, elapsed, usys, grid, + model.sched, wellSol(grid), rftFile); + } + + { + const auto rft = ::Opm::EclIO::ERft { + ::Opm::EclIO::OutputStream::outputFileName(rset, "RFT") + }; + + { + const auto xRFT = RFTRresults { + rft, "OP_1", RftDate{ 2008, 10, 10 } + }; + + const auto thick = 0.25f; + + BOOST_CHECK_CLOSE(xRFT.depth(9, 9, 1), 1*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(9, 9, 2), 2*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(9, 9, 3), 3*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(9, 9, 4), 4*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(9, 9, 5), 5*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(9, 9, 6), 6*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(9, 9, 7), 7*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(9, 9, 8), 8*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(9, 9, 9), 9*thick + thick/2.0f, 1.0e-10f); + + BOOST_CHECK_CLOSE(xRFT.pressure(9, 9, 1), 1.184307920059215e+02f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(9, 9, 2), 1.283000246730817e+02f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(9, 9, 3), 1.381692573402418e+02f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(9, 9, 4), 1.480384900074019e+02f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(9, 9, 5), 1.579077226745621e+02f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(9, 9, 6), 1.677769553417222e+02f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(9, 9, 7), 1.776461880088823e+02f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(9, 9, 8), 1.875154206760424e+02f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(9, 9, 9), 1.973846533432026e+02f, 1.0e-10f); + + BOOST_CHECK_CLOSE(xRFT.sgas(9, 9, 1), 0.15f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(9, 9, 2), 0.15f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(9, 9, 3), 0.15f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(9, 9, 4), 0.15f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(9, 9, 5), 0.15f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(9, 9, 6), 0.15f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(9, 9, 7), 0.15f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(9, 9, 8), 0.15f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(9, 9, 9), 0.15f, 1.0e-10f); + + BOOST_CHECK_CLOSE(xRFT.swat(9, 9, 1), 0.30f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(9, 9, 2), 0.35f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(9, 9, 3), 0.40f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(9, 9, 4), 0.45f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(9, 9, 5), 0.50f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(9, 9, 6), 0.55f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(9, 9, 7), 0.60f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(9, 9, 8), 0.65f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(9, 9, 9), 0.70f, 1.0e-10f); + } + + { + const auto xRFT = RFTRresults { + rft, "OP_2", RftDate{ 2008, 10, 10 } + }; + + const auto thick = 0.25f; + + BOOST_CHECK_CLOSE(xRFT.depth(4, 4, 4), 4*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(4, 4, 5), 5*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(4, 4, 6), 6*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(4, 4, 7), 7*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(4, 4, 8), 8*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(4, 4, 9), 9*thick + thick/2.0f, 1.0e-10f); + + BOOST_CHECK_CLOSE(xRFT.pressure(4, 4, 4), 1.480384900074019e+02f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(4, 4, 5), 1.579077226745621e+02f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(4, 4, 6), 1.677769553417222e+02f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(4, 4, 7), 1.776461880088823e+02f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(4, 4, 8), 1.875154206760424e+02f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(4, 4, 9), 1.973846533432026e+02f, 1.0e-10f); + + BOOST_CHECK_CLOSE(xRFT.sgas(4, 4, 4), 0.45f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(4, 4, 5), 0.40f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(4, 4, 6), 0.35f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(4, 4, 7), 0.30f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(4, 4, 8), 0.25f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(4, 4, 9), 0.20f, 1.0e-10f); + + BOOST_CHECK_CLOSE(xRFT.swat(4, 4, 4), 0.25f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(4, 4, 5), 0.25f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(4, 4, 6), 0.25f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(4, 4, 7), 0.25f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(4, 4, 8), 0.25f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(4, 4, 9), 0.25f, 1.0e-10f); + } + + { + const auto date = RftDate{2008, 10, 10}; + + BOOST_CHECK(rft.hasArray("WELLETC", "OP_1", date)); + + const auto& welletc = rft.getRft("WELLETC", "OP_1", date); + + BOOST_CHECK_EQUAL(welletc[ 0], " DAYS"); + BOOST_CHECK_EQUAL(welletc[ 1], "OP_1"); + BOOST_CHECK_EQUAL(welletc[ 2], ""); + BOOST_CHECK_EQUAL(welletc[ 3], " METRES"); + BOOST_CHECK_EQUAL(welletc[ 4], " ATMA"); + BOOST_CHECK_EQUAL(welletc[ 5], "R"); + BOOST_CHECK_EQUAL(welletc[ 6], "STANDARD"); + BOOST_CHECK_EQUAL(welletc[ 7], " SM3/DAY"); + BOOST_CHECK_EQUAL(welletc[ 8], " SM3/DAY"); + BOOST_CHECK_EQUAL(welletc[ 9], " RM3/DAY"); + BOOST_CHECK_EQUAL(welletc[10], " M/SEC"); + // No check for welletc[11] + BOOST_CHECK_EQUAL(welletc[12], " CP"); + BOOST_CHECK_EQUAL(welletc[13], " KG/SM3"); + BOOST_CHECK_EQUAL(welletc[14], " KG/DAY"); + BOOST_CHECK_EQUAL(welletc[15], " KG/KG"); + } + + { + const auto date = RftDate{2008, 10, 10}; + + BOOST_CHECK(rft.hasArray("WELLETC", "OP_2", date)); + + const auto& welletc = rft.getRft("WELLETC", "OP_2", date); + + BOOST_CHECK_EQUAL(welletc[ 0], " DAYS"); + BOOST_CHECK_EQUAL(welletc[ 1], "OP_2"); + BOOST_CHECK_EQUAL(welletc[ 2], ""); + BOOST_CHECK_EQUAL(welletc[ 3], " METRES"); + BOOST_CHECK_EQUAL(welletc[ 4], " ATMA"); + BOOST_CHECK_EQUAL(welletc[ 5], "R"); + BOOST_CHECK_EQUAL(welletc[ 6], "STANDARD"); + BOOST_CHECK_EQUAL(welletc[ 7], " SM3/DAY"); + BOOST_CHECK_EQUAL(welletc[ 8], " SM3/DAY"); + BOOST_CHECK_EQUAL(welletc[ 9], " RM3/DAY"); + BOOST_CHECK_EQUAL(welletc[10], " M/SEC"); + // No check for welletc[11] + BOOST_CHECK_EQUAL(welletc[12], " CP"); + BOOST_CHECK_EQUAL(welletc[13], " KG/SM3"); + BOOST_CHECK_EQUAL(welletc[14], " KG/DAY"); + BOOST_CHECK_EQUAL(welletc[15], " KG/KG"); + } + } + + { + auto rftFile = ::Opm::EclIO::OutputStream::RFT { + rset, ::Opm::EclIO::OutputStream::Formatted { false }, + ::Opm::EclIO::OutputStream::RFT::OpenExisting{ true } + }; + + const auto reportStep = 3; + const auto elapsed = model.sched.seconds(reportStep); + const auto& grid = model.es.getInputGrid(); + + ::Opm::RftIO::write(reportStep, elapsed, usys, grid, + model.sched, wellSol(grid), rftFile); + } + + { + const auto rft = ::Opm::EclIO::ERft { + ::Opm::EclIO::OutputStream::outputFileName(rset, "RFT") + }; + + { + const auto xRFT = RFTRresults { + rft, "OP_1", RftDate{ 2008, 10, 10 } + }; + + const auto thick = 0.25; + + BOOST_CHECK_CLOSE(xRFT.depth(9, 9, 1), 1*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(9, 9, 2), 2*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(9, 9, 3), 3*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(9, 9, 4), 4*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(9, 9, 5), 5*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(9, 9, 6), 6*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(9, 9, 7), 7*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(9, 9, 8), 8*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(9, 9, 9), 9*thick + thick/2.0f, 1.0e-10f); + + BOOST_CHECK_CLOSE(xRFT.pressure(9, 9, 1), 1.184307920059215e+02f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(9, 9, 2), 1.283000246730817e+02f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(9, 9, 3), 1.381692573402418e+02f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(9, 9, 4), 1.480384900074019e+02f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(9, 9, 5), 1.579077226745621e+02f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(9, 9, 6), 1.677769553417222e+02f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(9, 9, 7), 1.776461880088823e+02f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(9, 9, 8), 1.875154206760424e+02f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(9, 9, 9), 1.973846533432026e+02f, 1.0e-10f); + + BOOST_CHECK_CLOSE(xRFT.sgas(9, 9, 1), 0.15f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(9, 9, 2), 0.15f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(9, 9, 3), 0.15f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(9, 9, 4), 0.15f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(9, 9, 5), 0.15f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(9, 9, 6), 0.15f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(9, 9, 7), 0.15f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(9, 9, 8), 0.15f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(9, 9, 9), 0.15f, 1.0e-10f); + + BOOST_CHECK_CLOSE(xRFT.swat(9, 9, 1), 0.30f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(9, 9, 2), 0.35f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(9, 9, 3), 0.40f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(9, 9, 4), 0.45f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(9, 9, 5), 0.50f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(9, 9, 6), 0.55f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(9, 9, 7), 0.60f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(9, 9, 8), 0.65f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(9, 9, 9), 0.70f, 1.0e-10f); + } + + { + const auto xRFT = RFTRresults { + rft, "OP_2", RftDate{ 2008, 10, 10 } + }; + + const auto thick = 0.25; + + BOOST_CHECK_CLOSE(xRFT.depth(4, 4, 4), 4*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(4, 4, 5), 5*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(4, 4, 6), 6*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(4, 4, 7), 7*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(4, 4, 8), 8*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(4, 4, 9), 9*thick + thick/2.0f, 1.0e-10f); + + BOOST_CHECK_CLOSE(xRFT.pressure(4, 4, 4), 1.480384900074019e+02f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(4, 4, 5), 1.579077226745621e+02f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(4, 4, 6), 1.677769553417222e+02f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(4, 4, 7), 1.776461880088823e+02f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(4, 4, 8), 1.875154206760424e+02f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(4, 4, 9), 1.973846533432026e+02f, 1.0e-10f); + + BOOST_CHECK_CLOSE(xRFT.sgas(4, 4, 4), 0.45f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(4, 4, 5), 0.40f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(4, 4, 6), 0.35f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(4, 4, 7), 0.30f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(4, 4, 8), 0.25f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(4, 4, 9), 0.20f, 1.0e-10f); + + BOOST_CHECK_CLOSE(xRFT.swat(4, 4, 4), 0.25f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(4, 4, 5), 0.25f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(4, 4, 6), 0.25f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(4, 4, 7), 0.25f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(4, 4, 8), 0.25f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(4, 4, 9), 0.25f, 1.0e-10f); + } + + { + const auto xRFT = RFTRresults { + rft, "OP_2", RftDate{ 2008, 11, 10 } + }; + + const auto thick = 0.25; + + BOOST_CHECK_CLOSE(xRFT.depth(4, 4, 4), 4*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(4, 4, 5), 5*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(4, 4, 6), 6*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(4, 4, 7), 7*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(4, 4, 8), 8*thick + thick/2.0f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.depth(4, 4, 9), 9*thick + thick/2.0f, 1.0e-10f); + + BOOST_CHECK_CLOSE(xRFT.pressure(4, 4, 4), 1.480384900074019e+02f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(4, 4, 5), 1.579077226745621e+02f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(4, 4, 6), 1.677769553417222e+02f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(4, 4, 7), 1.776461880088823e+02f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(4, 4, 8), 1.875154206760424e+02f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.pressure(4, 4, 9), 1.973846533432026e+02f, 1.0e-10f); + + BOOST_CHECK_CLOSE(xRFT.sgas(4, 4, 4), 0.45f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(4, 4, 5), 0.40f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(4, 4, 6), 0.35f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(4, 4, 7), 0.30f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(4, 4, 8), 0.25f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.sgas(4, 4, 9), 0.20f, 1.0e-10f); + + BOOST_CHECK_CLOSE(xRFT.swat(4, 4, 4), 0.25f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(4, 4, 5), 0.25f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(4, 4, 6), 0.25f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(4, 4, 7), 0.25f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(4, 4, 8), 0.25f, 1.0e-10f); + BOOST_CHECK_CLOSE(xRFT.swat(4, 4, 9), 0.25f, 1.0e-10f); + } + + { + const auto date = RftDate{2008, 10, 10}; + + BOOST_CHECK(rft.hasArray("WELLETC", "OP_1", date)); + + const auto& welletc = rft.getRft("WELLETC", "OP_1", date); + + BOOST_CHECK_EQUAL(welletc[ 0], " DAYS"); + BOOST_CHECK_EQUAL(welletc[ 1], "OP_1"); + BOOST_CHECK_EQUAL(welletc[ 2], ""); + BOOST_CHECK_EQUAL(welletc[ 3], " METRES"); + BOOST_CHECK_EQUAL(welletc[ 4], " ATMA"); + BOOST_CHECK_EQUAL(welletc[ 5], "R"); + BOOST_CHECK_EQUAL(welletc[ 6], "STANDARD"); + BOOST_CHECK_EQUAL(welletc[ 7], " SM3/DAY"); + BOOST_CHECK_EQUAL(welletc[ 8], " SM3/DAY"); + BOOST_CHECK_EQUAL(welletc[ 9], " RM3/DAY"); + BOOST_CHECK_EQUAL(welletc[10], " M/SEC"); + // No check for welletc[11] + BOOST_CHECK_EQUAL(welletc[12], " CP"); + BOOST_CHECK_EQUAL(welletc[13], " KG/SM3"); + BOOST_CHECK_EQUAL(welletc[14], " KG/DAY"); + BOOST_CHECK_EQUAL(welletc[15], " KG/KG"); + } + + { + const auto date = RftDate{2008, 10, 10}; + + BOOST_CHECK(rft.hasArray("WELLETC", "OP_2", date)); + + const auto& welletc = rft.getRft("WELLETC", "OP_2", date); + + BOOST_CHECK_EQUAL(welletc[ 0], " DAYS"); + BOOST_CHECK_EQUAL(welletc[ 1], "OP_2"); + BOOST_CHECK_EQUAL(welletc[ 2], ""); + BOOST_CHECK_EQUAL(welletc[ 3], " METRES"); + BOOST_CHECK_EQUAL(welletc[ 4], " ATMA"); + BOOST_CHECK_EQUAL(welletc[ 5], "R"); + BOOST_CHECK_EQUAL(welletc[ 6], "STANDARD"); + BOOST_CHECK_EQUAL(welletc[ 7], " SM3/DAY"); + BOOST_CHECK_EQUAL(welletc[ 8], " SM3/DAY"); + BOOST_CHECK_EQUAL(welletc[ 9], " RM3/DAY"); + BOOST_CHECK_EQUAL(welletc[10], " M/SEC"); + // No check for welletc[11] + BOOST_CHECK_EQUAL(welletc[12], " CP"); + BOOST_CHECK_EQUAL(welletc[13], " KG/SM3"); + BOOST_CHECK_EQUAL(welletc[14], " KG/DAY"); + BOOST_CHECK_EQUAL(welletc[15], " KG/KG"); + } + + { + const auto date = RftDate{2008, 11, 10}; + + BOOST_CHECK(rft.hasArray("WELLETC", "OP_2", date)); + + const auto& welletc = rft.getRft("WELLETC", "OP_2", date); + + BOOST_CHECK_EQUAL(welletc[ 0], " DAYS"); + BOOST_CHECK_EQUAL(welletc[ 1], "OP_2"); + BOOST_CHECK_EQUAL(welletc[ 2], ""); + BOOST_CHECK_EQUAL(welletc[ 3], " METRES"); + BOOST_CHECK_EQUAL(welletc[ 4], " ATMA"); + BOOST_CHECK_EQUAL(welletc[ 5], "R"); + BOOST_CHECK_EQUAL(welletc[ 6], "STANDARD"); + BOOST_CHECK_EQUAL(welletc[ 7], " SM3/DAY"); + BOOST_CHECK_EQUAL(welletc[ 8], " SM3/DAY"); + BOOST_CHECK_EQUAL(welletc[ 9], " RM3/DAY"); + BOOST_CHECK_EQUAL(welletc[10], " M/SEC"); + // No check for welletc[11] + BOOST_CHECK_EQUAL(welletc[12], " CP"); + BOOST_CHECK_EQUAL(welletc[13], " KG/SM3"); + BOOST_CHECK_EQUAL(welletc[14], " KG/DAY"); + BOOST_CHECK_EQUAL(welletc[15], " KG/KG"); + } + } +} + +BOOST_AUTO_TEST_SUITE_END() // Using_Direct_Write