From df9e434c740cb65930cb04a0f98dbc0a829cd307 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Mon, 15 May 2017 14:13:59 +0200 Subject: [PATCH] Use double "s" in Transmissibilities, create cpp file for transmissibility condenser --- .../FileInterface/RifEclipseExportTools.cpp | 4 +- .../ProjectDataModel/RimEclipseCase.cpp | 2 +- .../ReservoirDataModel/CMakeLists_files.cmake | 3 +- .../ReservoirDataModel/RigFracture.cpp | 2 +- .../ReservoirDataModel/RigFracture.h | 4 +- .../ReservoirDataModel/RigNNCData.cpp | 2 +- .../ReservoirDataModel/RigNNCData.h | 2 +- ...ser.h => RigTransmissibilityCondenser.cpp} | 160 ++++++++-------- .../RigTransmissibilityCondenser.h | 71 ++++++++ .../UnitTests/CMakeLists_files.cmake | 2 +- .../RigTransmisibilityCondenser-Test.cpp | 154 ---------------- .../RigTransmissibilityCondenser-Test.cpp | 172 ++++++++++++++++++ 12 files changed, 331 insertions(+), 247 deletions(-) rename ApplicationCode/ReservoirDataModel/{RigTransmisibilityCondenser.h => RigTransmissibilityCondenser.cpp} (51%) create mode 100644 ApplicationCode/ReservoirDataModel/RigTransmissibilityCondenser.h delete mode 100644 ApplicationCode/UnitTests/RigTransmisibilityCondenser-Test.cpp create mode 100644 ApplicationCode/UnitTests/RigTransmissibilityCondenser-Test.cpp diff --git a/ApplicationCode/FileInterface/RifEclipseExportTools.cpp b/ApplicationCode/FileInterface/RifEclipseExportTools.cpp index 04b4eb326b..f3bd933add 100644 --- a/ApplicationCode/FileInterface/RifEclipseExportTools.cpp +++ b/ApplicationCode/FileInterface/RifEclipseExportTools.cpp @@ -296,7 +296,7 @@ void RifEclipseExportTools::printStimPlanCellsMatrixTransContributions(const std std::vector stimPlanContributingEclipseCells = fracStimPlanCellData.getContributingEclipseCells(); - std::vector stimPlanContributingEclipseCellTransmisibilities = fracStimPlanCellData.getContributingEclipseCellTransmisibilities(); + std::vector stimPlanContributingEclipseCellTransmissibilities = fracStimPlanCellData.getContributingEclipseCellTransmissibilities(); for (int i = 0; i < stimPlanContributingEclipseCells.size(); i++) { @@ -331,7 +331,7 @@ void RifEclipseExportTools::printStimPlanCellsMatrixTransContributions(const std out << spj; out << qSetFieldWidth(10); - out << QString::number(stimPlanContributingEclipseCellTransmisibilities[i], 'e', 3); + out << QString::number(stimPlanContributingEclipseCellTransmissibilities[i], 'e', 3); out << "\n"; } diff --git a/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp b/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp index a3915c08bb..42152e78a6 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp @@ -570,7 +570,7 @@ bool RimEclipseCase::openReserviorCase() size_t combinedTransResIdx = results->cellResults()->findScalarResultIndex(RimDefines::STATIC_NATIVE, RimDefines::combinedTransmissibilityResultName()); if (combinedTransResIdx != cvf::UNDEFINED_SIZE_T) { - eclipseCaseData()->mainGrid()->nncData()->setCombTransmisibilityScalarResultIndex(combinedTransResIdx); + eclipseCaseData()->mainGrid()->nncData()->setCombTransmissibilityScalarResultIndex(combinedTransResIdx); } } diff --git a/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake b/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake index 80ead82257..f60ea47f7e 100644 --- a/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake +++ b/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake @@ -42,7 +42,7 @@ ${CEE_CURRENT_LIST_DIR}cvfGeometryTools.h ${CEE_CURRENT_LIST_DIR}cvfGeometryTools.inl ${CEE_CURRENT_LIST_DIR}RigPipeInCellEvaluator.h ${CEE_CURRENT_LIST_DIR}RigTernaryResultAccessor2d.h -${CEE_CURRENT_LIST_DIR}RigTransmisibilityCondenser.h +${CEE_CURRENT_LIST_DIR}RigTransmissibilityCondenser.h ${CEE_CURRENT_LIST_DIR}RigEclipseNativeStatCalc.h ${CEE_CURRENT_LIST_DIR}RigEclipseNativeVisibleCellsStatCalc.h ${CEE_CURRENT_LIST_DIR}RigEclipseMultiPropertyStatCalc.h @@ -97,6 +97,7 @@ ${CEE_CURRENT_LIST_DIR}RigFault.cpp ${CEE_CURRENT_LIST_DIR}RigNNCData.cpp ${CEE_CURRENT_LIST_DIR}cvfGeometryTools.cpp ${CEE_CURRENT_LIST_DIR}RigTernaryResultAccessor2d.cpp +${CEE_CURRENT_LIST_DIR}RigTransmissibilityCondenser.cpp ${CEE_CURRENT_LIST_DIR}RigEclipseNativeStatCalc.cpp ${CEE_CURRENT_LIST_DIR}RigEclipseNativeVisibleCellsStatCalc.cpp ${CEE_CURRENT_LIST_DIR}RigEclipseMultiPropertyStatCalc.cpp diff --git a/ApplicationCode/ReservoirDataModel/RigFracture.cpp b/ApplicationCode/ReservoirDataModel/RigFracture.cpp index ebfc4e584b..6b52540413 100644 --- a/ApplicationCode/ReservoirDataModel/RigFracture.cpp +++ b/ApplicationCode/ReservoirDataModel/RigFracture.cpp @@ -41,7 +41,7 @@ RigFractureStimPlanCellData::RigFractureStimPlanCellData(size_t i, size_t j) void RigFractureStimPlanCellData::addContributingEclipseCell(size_t eclipseCell, double transmissibility) { contributingEclipseCells.push_back(eclipseCell); - contributingEclipseCellTransmisibilities.push_back(transmissibility); + contributingEclipseCellTransmissibilities.push_back(transmissibility); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ReservoirDataModel/RigFracture.h b/ApplicationCode/ReservoirDataModel/RigFracture.h index dcf43489ad..b1ea6f56b7 100644 --- a/ApplicationCode/ReservoirDataModel/RigFracture.h +++ b/ApplicationCode/ReservoirDataModel/RigFracture.h @@ -61,7 +61,7 @@ public: size_t m_j; std::vector getContributingEclipseCells() { return contributingEclipseCells; } - std::vector getContributingEclipseCellTransmisibilities() { return contributingEclipseCellTransmisibilities; } + std::vector getContributingEclipseCellTransmissibilities() { return contributingEclipseCellTransmissibilities; } void addContributingEclipseCell(size_t eclipseCell, double transmissibility); private: @@ -69,7 +69,7 @@ private: double performationLenghtHorizontal; std::vector contributingEclipseCells; - std::vector contributingEclipseCellTransmisibilities; + std::vector contributingEclipseCellTransmissibilities; }; diff --git a/ApplicationCode/ReservoirDataModel/RigNNCData.cpp b/ApplicationCode/ReservoirDataModel/RigNNCData.cpp index 72a4f023a4..58238fb5d3 100644 --- a/ApplicationCode/ReservoirDataModel/RigNNCData.cpp +++ b/ApplicationCode/ReservoirDataModel/RigNNCData.cpp @@ -188,7 +188,7 @@ const std::vector* RigNNCData::connectionScalarResult(size_t scalarResul //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigNNCData::setCombTransmisibilityScalarResultIndex(size_t scalarResultIndex) +void RigNNCData::setCombTransmissibilityScalarResultIndex(size_t scalarResultIndex) { std::map >::iterator it = m_connectionResults.find(cvf::UNDEFINED_SIZE_T); if (it != m_connectionResults.end()) diff --git a/ApplicationCode/ReservoirDataModel/RigNNCData.h b/ApplicationCode/ReservoirDataModel/RigNNCData.h index d9d55439a8..4ab245fe5f 100644 --- a/ApplicationCode/ReservoirDataModel/RigNNCData.h +++ b/ApplicationCode/ReservoirDataModel/RigNNCData.h @@ -69,7 +69,7 @@ public: std::vector& makeConnectionScalarResult(size_t scalarResultIndex); const std::vector* connectionScalarResult(size_t scalarResultIndex) const; - void setCombTransmisibilityScalarResultIndex(size_t scalarResultIndex); + void setCombTransmissibilityScalarResultIndex(size_t scalarResultIndex); bool hasScalarValues(size_t scalarResultIndex); diff --git a/ApplicationCode/ReservoirDataModel/RigTransmisibilityCondenser.h b/ApplicationCode/ReservoirDataModel/RigTransmissibilityCondenser.cpp similarity index 51% rename from ApplicationCode/ReservoirDataModel/RigTransmisibilityCondenser.h rename to ApplicationCode/ReservoirDataModel/RigTransmissibilityCondenser.cpp index 6c7b0f6820..67f02644d4 100644 --- a/ApplicationCode/ReservoirDataModel/RigTransmisibilityCondenser.h +++ b/ApplicationCode/ReservoirDataModel/RigTransmissibilityCondenser.cpp @@ -1,82 +1,23 @@ -#pragma once +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2017 - Statoil ASA +// +// ResInsight 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. +// +// ResInsight 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 at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// -#include -#include -#include "cafAssert.h" +#include "RigTransmissibilityCondenser.h" -class RigTransmissibilityCondenser -{ -public: - class CellAddress - { - public: - enum CellType { ECLIPSE, STIMPLAN }; - - CellAddress(): m_isExternal(false), - m_cellType(STIMPLAN), - m_globalCellIdx(-1) {} - CellAddress(bool isExternal, CellType cellType, size_t globalCellIdx) - : m_isExternal(isExternal), - m_cellType(cellType), - m_globalCellIdx(globalCellIdx) {} - - bool m_isExternal; - CellType m_cellType; - size_t m_globalCellIdx; - - bool operator==(const CellAddress& o) { return (m_isExternal == o.m_isExternal) && (m_cellType == o.m_cellType) && (m_globalCellIdx == o.m_globalCellIdx); } - - // Ordering external after internal is important for the matrix order internally - bool operator<(const CellAddress& other) const - { - if (m_isExternal != other.m_isExternal) return !m_isExternal; // Internal cells < External cells - if (m_cellType != other.m_cellType) return m_cellType < other.m_cellType; // Eclipse < StimPlan - if (m_globalCellIdx != other.m_globalCellIdx) return m_globalCellIdx < other.m_globalCellIdx; - return false; - } - }; - - void addNeighborTransmisibility(CellAddress cell1, CellAddress cell2, double transmisibility) - { - m_condensedTransmisibilities.clear(); - if ( cell1 < cell2 ) - m_neighborTransmisibilities[cell1][cell2] = transmisibility; - else - m_neighborTransmisibilities[cell2][cell1] = transmisibility; - } - - std::vector externalCells() - { - calculateCondensedTransmisibilitiesIfNeeded(); std::vector extCells; - for ( const auto& adrToAdrTransMapPair : m_condensedTransmisibilities ) extCells.push_back(adrToAdrTransMapPair.first); - } - - double condensedTransmisibility( CellAddress externalCell1, CellAddress externalCell2) - { - CAF_ASSERT(!(externalCell1 == externalCell2)); - - calculateCondensedTransmisibilitiesIfNeeded(); - - if (externalCell2 < externalCell1) std::swap(externalCell1, externalCell2); - - const auto& adrToAdrTransMapPair = m_condensedTransmisibilities.find(externalCell1); - if ( adrToAdrTransMapPair != m_condensedTransmisibilities.end() ) - { - const auto& adrTransPair = adrToAdrTransMapPair->second.find(externalCell2); - if ( adrTransPair != adrToAdrTransMapPair->second.end() ) - { - return adrTransPair->second; - } - } - return 0.0; - } - -private: - void calculateCondensedTransmisibilitiesIfNeeded(); - - std::map > m_neighborTransmisibilities; - std::map > m_condensedTransmisibilities; -}; #include #include @@ -84,9 +25,56 @@ private: //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigTransmissibilityCondenser::calculateCondensedTransmisibilitiesIfNeeded() +void RigTransmissibilityCondenser::addNeighborTransmissibility(CellAddress cell1, CellAddress cell2, double transmissibility) { - if (m_condensedTransmisibilities.size()) return; + m_condensedTransmissibilities.clear(); + m_externalCellAddrSet.clear(); + + if ( cell1 < cell2 ) + m_neighborTransmissibilities[cell1][cell2] = transmissibility; + else + m_neighborTransmissibilities[cell2][cell1] = transmissibility; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::set RigTransmissibilityCondenser::externalCells() +{ + calculateCondensedTransmissibilitiesIfNeeded(); + + return m_externalCellAddrSet; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RigTransmissibilityCondenser::condensedTransmissibility(CellAddress externalCell1, CellAddress externalCell2) +{ + CAF_ASSERT(!(externalCell1 == externalCell2)); + + calculateCondensedTransmissibilitiesIfNeeded(); + + if ( externalCell2 < externalCell1 ) std::swap(externalCell1, externalCell2); + + const auto& adrToAdrTransMapPair = m_condensedTransmissibilities.find(externalCell1); + if ( adrToAdrTransMapPair != m_condensedTransmissibilities.end() ) + { + const auto& adrTransPair = adrToAdrTransMapPair->second.find(externalCell2); + if ( adrTransPair != adrToAdrTransMapPair->second.end() ) + { + return adrTransPair->second; + } + } + return 0.0; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigTransmissibilityCondenser::calculateCondensedTransmissibilitiesIfNeeded() +{ + if (m_condensedTransmissibilities.size()) return; // Find all equations, and their total ordering @@ -101,7 +89,7 @@ void RigTransmissibilityCondenser::calculateCondensedTransmisibilitiesIfNeeded() std::map cellAddressToEqIdxMap; std::vector eqIdxToCellAddressMapping; { - for ( const auto& adrEqIdxPair : m_neighborTransmisibilities ) + for ( const auto& adrEqIdxPair : m_neighborTransmissibilities ) { cellAddressToEqIdxMap.insert({ adrEqIdxPair.first, -1 }); for ( const auto& adrTranspair : adrEqIdxPair.second ) @@ -132,7 +120,7 @@ void RigTransmissibilityCondenser::calculateCondensedTransmisibilitiesIfNeeded() MatrixXd totalSystem = MatrixXd::Zero(totalEquationCount, totalEquationCount); - for (const auto& adrToAdrTransMapPair : m_neighborTransmisibilities) + for (const auto& adrToAdrTransMapPair : m_neighborTransmissibilities) { CAF_ASSERT(cellAddressToEqIdxMap.count(adrToAdrTransMapPair.first)); // Remove when stabilized int c1EquationIdx = cellAddressToEqIdxMap[adrToAdrTransMapPair.first]; @@ -170,10 +158,16 @@ void RigTransmissibilityCondenser::calculateCondensedTransmisibilitiesIfNeeded() { CellAddress cell1 = eqIdxToCellAddressMapping[exEqIdx + internalEquationCount]; CellAddress cell2 = eqIdxToCellAddressMapping[exColIdx + internalEquationCount]; - if (cell1 < cell2) m_condensedTransmisibilities[cell1][cell2] = T; - else m_condensedTransmisibilities[cell2][cell1] = T; + if (cell1 < cell2) m_condensedTransmissibilities[cell1][cell2] = T; + else m_condensedTransmissibilities[cell2][cell1] = T; + + m_externalCellAddrSet.insert(cell1); + m_externalCellAddrSet.insert(cell2); + } } } } + + diff --git a/ApplicationCode/ReservoirDataModel/RigTransmissibilityCondenser.h b/ApplicationCode/ReservoirDataModel/RigTransmissibilityCondenser.h new file mode 100644 index 0000000000..38b2efe693 --- /dev/null +++ b/ApplicationCode/ReservoirDataModel/RigTransmissibilityCondenser.h @@ -0,0 +1,71 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2017 - Statoil ASA +// +// ResInsight 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. +// +// ResInsight 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 at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafAssert.h" + +#include +#include +#include + +class RigTransmissibilityCondenser +{ +public: + class CellAddress + { + public: + enum CellType { ECLIPSE, STIMPLAN }; + + CellAddress(): m_isExternal(false), + m_cellType(STIMPLAN), + m_globalCellIdx(-1) {} + CellAddress(bool isExternal, CellType cellType, size_t globalCellIdx) + : m_isExternal(isExternal), + m_cellType(cellType), + m_globalCellIdx(globalCellIdx) {} + + bool m_isExternal; + CellType m_cellType; + size_t m_globalCellIdx; + + bool operator==(const CellAddress& o) { return (m_isExternal == o.m_isExternal) && (m_cellType == o.m_cellType) && (m_globalCellIdx == o.m_globalCellIdx); } + + // Ordering external after internal is important for the matrix order internally + bool operator<(const CellAddress& other) const + { + if (m_isExternal != other.m_isExternal) return !m_isExternal; // Internal cells < External cells + if (m_cellType != other.m_cellType) return m_cellType < other.m_cellType; // Eclipse < StimPlan + if (m_globalCellIdx != other.m_globalCellIdx) return m_globalCellIdx < other.m_globalCellIdx; + return false; + } + }; + + void addNeighborTransmissibility(CellAddress cell1, CellAddress cell2, double transmissibility); + + std::set externalCells(); + + double condensedTransmissibility( CellAddress externalCell1, CellAddress externalCell2); + +private: + void calculateCondensedTransmissibilitiesIfNeeded(); + + std::map > m_neighborTransmissibilities; + std::map > m_condensedTransmissibilities; + std::set m_externalCellAddrSet; +}; diff --git a/ApplicationCode/UnitTests/CMakeLists_files.cmake b/ApplicationCode/UnitTests/CMakeLists_files.cmake index 69874462fb..a48c2cbec2 100644 --- a/ApplicationCode/UnitTests/CMakeLists_files.cmake +++ b/ApplicationCode/UnitTests/CMakeLists_files.cmake @@ -23,7 +23,7 @@ ${CEE_CURRENT_LIST_DIR}ScalarMapper-Test.cpp ${CEE_CURRENT_LIST_DIR}WellPathAsciiFileReader-Test.cpp ${CEE_CURRENT_LIST_DIR}opm-flowdiagnostics-Test.cpp ${CEE_CURRENT_LIST_DIR}RigCellGeometryTools-Test.cpp -${CEE_CURRENT_LIST_DIR}RigTransmisibilityCondenser-Test.cpp +${CEE_CURRENT_LIST_DIR}RigTransmissibilityCondenser-Test.cpp ) diff --git a/ApplicationCode/UnitTests/RigTransmisibilityCondenser-Test.cpp b/ApplicationCode/UnitTests/RigTransmisibilityCondenser-Test.cpp deleted file mode 100644 index 980440fc02..0000000000 --- a/ApplicationCode/UnitTests/RigTransmisibilityCondenser-Test.cpp +++ /dev/null @@ -1,154 +0,0 @@ -#include "gtest/gtest.h" - -#include "RigTransmisibilityCondenser.h" - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -TEST(RigTransmissibilityCondenser, BasicTest) -{ - using RiCa = RigTransmissibilityCondenser::CellAddress; - #if 1 - { - RigTransmissibilityCondenser condenser; - - condenser.addNeighborTransmisibility({ true, RiCa::ECLIPSE, 1 }, { true, RiCa::STIMPLAN, 1 }, 1.0); - - double condT = condenser.condensedTransmisibility({ true, RiCa::ECLIPSE, 1 }, { true, RiCa::STIMPLAN, 1 }); - - EXPECT_DOUBLE_EQ(1.0, condT); - } - - { - RigTransmissibilityCondenser condenser; - - condenser.addNeighborTransmisibility({ true, RiCa::ECLIPSE, 1 }, { true, RiCa::STIMPLAN, 1 }, 0.5); - - double condT = condenser.condensedTransmisibility({ true, RiCa::ECLIPSE, 1 }, { true, RiCa::STIMPLAN, 1 }); - - EXPECT_DOUBLE_EQ(0.5, condT); - } - - { - RigTransmissibilityCondenser condenser; - - condenser.addNeighborTransmisibility({ true, RiCa::ECLIPSE, 1 }, { false, RiCa::STIMPLAN, 1 }, 0.5); - condenser.addNeighborTransmisibility({ false, RiCa::STIMPLAN, 1 }, { true, RiCa::STIMPLAN, 2 }, 0.5); - - double condT = condenser.condensedTransmisibility({ true, RiCa::ECLIPSE, 1 }, { true, RiCa::STIMPLAN, 2 }); - - EXPECT_DOUBLE_EQ(0.25, condT); - } - - { - RigTransmissibilityCondenser condenser; - - condenser.addNeighborTransmisibility({ true, RiCa::ECLIPSE, 1 }, { false, RiCa::STIMPLAN, 1 }, 0.5); - condenser.addNeighborTransmisibility({ true, RiCa::ECLIPSE, 1 }, { false, RiCa::STIMPLAN, 2 }, 0.5); - condenser.addNeighborTransmisibility({ false, RiCa::STIMPLAN, 1 }, { true, RiCa::STIMPLAN, 3 }, 0.5); - condenser.addNeighborTransmisibility({ false, RiCa::STIMPLAN, 2 }, { true, RiCa::STIMPLAN, 3 }, 0.5); - - double condT = condenser.condensedTransmisibility({ true, RiCa::ECLIPSE, 1 }, { true, RiCa::STIMPLAN, 3 }); - - EXPECT_DOUBLE_EQ(0.5, condT); - } - { - RigTransmissibilityCondenser condenser; - - condenser.addNeighborTransmisibility({ true, RiCa::ECLIPSE, 1 }, { false, RiCa::STIMPLAN, 1 }, 0.5); - condenser.addNeighborTransmisibility({ true, RiCa::ECLIPSE, 1 }, { false, RiCa::STIMPLAN, 2 }, 0.5); - condenser.addNeighborTransmisibility({ false, RiCa::STIMPLAN, 1 }, { false, RiCa::STIMPLAN, 3 }, 0.5); - condenser.addNeighborTransmisibility({ false, RiCa::STIMPLAN, 2 }, { false, RiCa::STIMPLAN, 3 }, 0.5); - condenser.addNeighborTransmisibility({ false, RiCa::STIMPLAN, 3 }, { true, RiCa::STIMPLAN, 4 }, 0.5); - double condT = condenser.condensedTransmisibility({ true, RiCa::ECLIPSE, 1 }, { true, RiCa::STIMPLAN, 4 }); - - EXPECT_DOUBLE_EQ(0.25, condT); - - } - #endif - - - { - RigTransmissibilityCondenser condenser; - - condenser.addNeighborTransmisibility({ true, RiCa::ECLIPSE, 5 }, { false, RiCa::STIMPLAN, 1 }, 0.5); - - condenser.addNeighborTransmisibility({ false, RiCa::STIMPLAN, 1 }, { false, RiCa::STIMPLAN, 2 }, 0.5); - condenser.addNeighborTransmisibility({ false, RiCa::STIMPLAN, 1 }, { false, RiCa::STIMPLAN, 3 }, 0.5); - condenser.addNeighborTransmisibility({ false, RiCa::STIMPLAN, 2 }, { false, RiCa::STIMPLAN, 4 }, 0.5); - condenser.addNeighborTransmisibility({ false, RiCa::STIMPLAN, 3 }, { false, RiCa::STIMPLAN, 4 }, 0.5); - - condenser.addNeighborTransmisibility({ true, RiCa::STIMPLAN, 6 }, { false, RiCa::STIMPLAN, 4 }, 0.5); - - double condT = condenser.condensedTransmisibility({ true, RiCa::ECLIPSE, 5 }, { true, RiCa::STIMPLAN, 6 }); - - EXPECT_NEAR(0.1666666667, condT, 1e-7); - } - #if 1 - { - RigTransmissibilityCondenser condenser; - - condenser.addNeighborTransmisibility({ true, RiCa::ECLIPSE, 5 }, { false, RiCa::STIMPLAN, 1 }, 0.5); - condenser.addNeighborTransmisibility({ true, RiCa::ECLIPSE, 7 }, { false, RiCa::STIMPLAN, 2 }, 0.5); - condenser.addNeighborTransmisibility({ true, RiCa::ECLIPSE, 8 }, { false, RiCa::STIMPLAN, 3 }, 0.5); - condenser.addNeighborTransmisibility({ true, RiCa::ECLIPSE, 9 }, { false, RiCa::STIMPLAN, 4 }, 0.5); - - condenser.addNeighborTransmisibility({ false, RiCa::STIMPLAN, 1 }, { false, RiCa::STIMPLAN, 2 }, 0.5); - condenser.addNeighborTransmisibility({ false, RiCa::STIMPLAN, 1 }, { false, RiCa::STIMPLAN, 3 }, 0.5); - condenser.addNeighborTransmisibility({ false, RiCa::STIMPLAN, 2 }, { false, RiCa::STIMPLAN, 4 }, 0.5); - condenser.addNeighborTransmisibility({ false, RiCa::STIMPLAN, 3 }, { false, RiCa::STIMPLAN, 4 }, 0.5); - - condenser.addNeighborTransmisibility({ true, RiCa::STIMPLAN, 6 }, { false, RiCa::STIMPLAN, 4 }, 0.5); - - double condT = condenser.condensedTransmisibility({ true, RiCa::ECLIPSE, 5 }, { true, RiCa::STIMPLAN, 6 }); - - EXPECT_NEAR(0.045454545, condT, 1e-7); - } - #endif - #if 1 - { - // Test example from Matlab scripts, that match the iterative solution - - RigTransmissibilityCondenser condenser; - - condenser.addNeighborTransmisibility({ false, RiCa::STIMPLAN, 1 }, { false, RiCa::STIMPLAN, 2 }, 0.01127000); - condenser.addNeighborTransmisibility({ false, RiCa::STIMPLAN, 1 }, { false, RiCa::STIMPLAN, 4 }, 1.12700000); - condenser.addNeighborTransmisibility({ false, RiCa::STIMPLAN, 1 }, { true, RiCa::ECLIPSE, 7 }, 0.09016000); - condenser.addNeighborTransmisibility({ false, RiCa::STIMPLAN, 2 }, { false, RiCa::STIMPLAN, 3 }, 0.01127000); - condenser.addNeighborTransmisibility({ false, RiCa::STIMPLAN, 2 }, { false, RiCa::STIMPLAN, 5 }, 1.12700000); - condenser.addNeighborTransmisibility({ false, RiCa::STIMPLAN, 2 }, { true, RiCa::ECLIPSE, 8 }, 0.09016000); - condenser.addNeighborTransmisibility({ false, RiCa::STIMPLAN, 3 }, { false, RiCa::STIMPLAN, 6 }, 1.50266667); - condenser.addNeighborTransmisibility({ false, RiCa::STIMPLAN, 3 }, { true, RiCa::ECLIPSE, 9 }, 0.09016000); - condenser.addNeighborTransmisibility({ false, RiCa::STIMPLAN, 4 }, { false, RiCa::STIMPLAN, 5 }, 0.01127000); - condenser.addNeighborTransmisibility({ false, RiCa::STIMPLAN, 4 }, { true, RiCa::ECLIPSE, 10 }, 0.09016000); - condenser.addNeighborTransmisibility({ false, RiCa::STIMPLAN, 5 }, { false, RiCa::STIMPLAN, 6 }, 0.01502667); - condenser.addNeighborTransmisibility({ false, RiCa::STIMPLAN, 5 }, { true, RiCa::ECLIPSE, 11 }, 0.09016000); - condenser.addNeighborTransmisibility({ false, RiCa::STIMPLAN, 6 }, { true, RiCa::ECLIPSE, 12 }, 0.09016000); - condenser.addNeighborTransmisibility({ false, RiCa::STIMPLAN, 6 }, { true, RiCa::STIMPLAN, 13 }, 0.19219491); - - EXPECT_NEAR(0.00402732, condenser.condensedTransmisibility({ true, RiCa::ECLIPSE, 1+6 }, { true, RiCa::ECLIPSE, 2+6 }), 1e-6); - EXPECT_NEAR(0.00027347, condenser.condensedTransmisibility({ true, RiCa::ECLIPSE, 1+6 }, { true, RiCa::ECLIPSE, 3+6 }), 1e-6); - EXPECT_NEAR(0.03879174, condenser.condensedTransmisibility({ true, RiCa::ECLIPSE, 1+6 }, { true, RiCa::ECLIPSE, 4+6 }), 1e-6); - EXPECT_NEAR(0.00400489, condenser.condensedTransmisibility({ true, RiCa::ECLIPSE, 1+6 }, { true, RiCa::ECLIPSE, 5+6 }), 1e-6); - EXPECT_NEAR(0.00026172, condenser.condensedTransmisibility({ true, RiCa::ECLIPSE, 1+6 }, { true, RiCa::ECLIPSE, 6+6 }), 1e-6); - EXPECT_NEAR(0.00055791, condenser.condensedTransmisibility({ true, RiCa::ECLIPSE, 1+6 }, { true, RiCa::STIMPLAN, 7+6 }), 1e-6); - EXPECT_NEAR(0.00245697, condenser.condensedTransmisibility({ true, RiCa::ECLIPSE, 2+6 }, { true, RiCa::ECLIPSE, 3+6 }), 1e-6); - EXPECT_NEAR(0.00401064, condenser.condensedTransmisibility({ true, RiCa::ECLIPSE, 2+6 }, { true, RiCa::ECLIPSE, 4+6 }), 1e-6); - EXPECT_NEAR(0.03442773, condenser.condensedTransmisibility({ true, RiCa::ECLIPSE, 2+6 }, { true, RiCa::ECLIPSE, 5+6 }), 1e-6); - EXPECT_NEAR(0.00233846, condenser.condensedTransmisibility({ true, RiCa::ECLIPSE, 2+6 }, { true, RiCa::ECLIPSE, 6+6 }), 1e-6); - EXPECT_NEAR(0.00498491, condenser.condensedTransmisibility({ true, RiCa::ECLIPSE, 2+6 }, { true, RiCa::STIMPLAN, 7+6 }), 1e-6); - EXPECT_NEAR(0.00027351, condenser.condensedTransmisibility({ true, RiCa::ECLIPSE, 3+6 }, { true, RiCa::ECLIPSE, 4+6 }), 1e-6); - EXPECT_NEAR(0.00246579, condenser.condensedTransmisibility({ true, RiCa::ECLIPSE, 3+6 }, { true, RiCa::ECLIPSE, 5+6 }), 1e-6); - EXPECT_NEAR(0.01956640, condenser.condensedTransmisibility({ true, RiCa::ECLIPSE, 3+6 }, { true, RiCa::ECLIPSE, 6+6 }), 1e-6); - EXPECT_NEAR(0.04170988, condenser.condensedTransmisibility({ true, RiCa::ECLIPSE, 3+6 }, { true, RiCa::STIMPLAN, 7+6 }), 1e-6); - EXPECT_NEAR(0.00402105, condenser.condensedTransmisibility({ true, RiCa::ECLIPSE, 4+6 }, { true, RiCa::ECLIPSE, 5+6 }), 1e-6); - EXPECT_NEAR(0.00026189, condenser.condensedTransmisibility({ true, RiCa::ECLIPSE, 4+6 }, { true, RiCa::ECLIPSE, 6+6 }), 1e-6); - EXPECT_NEAR(0.00055827, condenser.condensedTransmisibility({ true, RiCa::ECLIPSE, 4+6 }, { true, RiCa::STIMPLAN, 7+6 }), 1e-6); - EXPECT_NEAR(0.00237402, condenser.condensedTransmisibility({ true, RiCa::ECLIPSE, 5+6 }, { true, RiCa::ECLIPSE, 6+6 }), 1e-6); - EXPECT_NEAR(0.00506073, condenser.condensedTransmisibility({ true, RiCa::ECLIPSE, 5+6 }, { true, RiCa::STIMPLAN, 7+6 }), 1e-6); - EXPECT_NEAR(0.04448791, condenser.condensedTransmisibility({ true, RiCa::ECLIPSE, 6+6 }, { true, RiCa::STIMPLAN, 7+6 }), 1e-6); - } - #endif -} - - diff --git a/ApplicationCode/UnitTests/RigTransmissibilityCondenser-Test.cpp b/ApplicationCode/UnitTests/RigTransmissibilityCondenser-Test.cpp new file mode 100644 index 0000000000..54d7a9bcd1 --- /dev/null +++ b/ApplicationCode/UnitTests/RigTransmissibilityCondenser-Test.cpp @@ -0,0 +1,172 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2017 - Statoil ASA +// +// ResInsight 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. +// +// ResInsight 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 at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "gtest/gtest.h" + +#include "RigTransmissibilityCondenser.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST(RigTransmissibilityCondenser, BasicTest) +{ + using RiCa = RigTransmissibilityCondenser::CellAddress; + #if 1 + { + RigTransmissibilityCondenser condenser; + + condenser.addNeighborTransmissibility({ true, RiCa::ECLIPSE, 1 }, { true, RiCa::STIMPLAN, 1 }, 1.0); + + double condT = condenser.condensedTransmissibility({ true, RiCa::ECLIPSE, 1 }, { true, RiCa::STIMPLAN, 1 }); + + EXPECT_DOUBLE_EQ(1.0, condT); + } + + { + RigTransmissibilityCondenser condenser; + + condenser.addNeighborTransmissibility({ true, RiCa::ECLIPSE, 1 }, { true, RiCa::STIMPLAN, 1 }, 0.5); + + double condT = condenser.condensedTransmissibility({ true, RiCa::ECLIPSE, 1 }, { true, RiCa::STIMPLAN, 1 }); + + EXPECT_DOUBLE_EQ(0.5, condT); + } + + { + RigTransmissibilityCondenser condenser; + + condenser.addNeighborTransmissibility({ true, RiCa::ECLIPSE, 1 }, { false, RiCa::STIMPLAN, 1 }, 0.5); + condenser.addNeighborTransmissibility({ false, RiCa::STIMPLAN, 1 }, { true, RiCa::STIMPLAN, 2 }, 0.5); + + double condT = condenser.condensedTransmissibility({ true, RiCa::ECLIPSE, 1 }, { true, RiCa::STIMPLAN, 2 }); + + EXPECT_DOUBLE_EQ(0.25, condT); + } + + { + RigTransmissibilityCondenser condenser; + + condenser.addNeighborTransmissibility({ true, RiCa::ECLIPSE, 1 }, { false, RiCa::STIMPLAN, 1 }, 0.5); + condenser.addNeighborTransmissibility({ true, RiCa::ECLIPSE, 1 }, { false, RiCa::STIMPLAN, 2 }, 0.5); + condenser.addNeighborTransmissibility({ false, RiCa::STIMPLAN, 1 }, { true, RiCa::STIMPLAN, 3 }, 0.5); + condenser.addNeighborTransmissibility({ false, RiCa::STIMPLAN, 2 }, { true, RiCa::STIMPLAN, 3 }, 0.5); + + double condT = condenser.condensedTransmissibility({ true, RiCa::ECLIPSE, 1 }, { true, RiCa::STIMPLAN, 3 }); + + EXPECT_DOUBLE_EQ(0.5, condT); + } + { + RigTransmissibilityCondenser condenser; + + condenser.addNeighborTransmissibility({ true, RiCa::ECLIPSE, 1 }, { false, RiCa::STIMPLAN, 1 }, 0.5); + condenser.addNeighborTransmissibility({ true, RiCa::ECLIPSE, 1 }, { false, RiCa::STIMPLAN, 2 }, 0.5); + condenser.addNeighborTransmissibility({ false, RiCa::STIMPLAN, 1 }, { false, RiCa::STIMPLAN, 3 }, 0.5); + condenser.addNeighborTransmissibility({ false, RiCa::STIMPLAN, 2 }, { false, RiCa::STIMPLAN, 3 }, 0.5); + condenser.addNeighborTransmissibility({ false, RiCa::STIMPLAN, 3 }, { true, RiCa::STIMPLAN, 4 }, 0.5); + double condT = condenser.condensedTransmissibility({ true, RiCa::ECLIPSE, 1 }, { true, RiCa::STIMPLAN, 4 }); + + EXPECT_DOUBLE_EQ(0.25, condT); + + } + #endif + + + { + RigTransmissibilityCondenser condenser; + + condenser.addNeighborTransmissibility({ true, RiCa::ECLIPSE, 5 }, { false, RiCa::STIMPLAN, 1 }, 0.5); + + condenser.addNeighborTransmissibility({ false, RiCa::STIMPLAN, 1 }, { false, RiCa::STIMPLAN, 2 }, 0.5); + condenser.addNeighborTransmissibility({ false, RiCa::STIMPLAN, 1 }, { false, RiCa::STIMPLAN, 3 }, 0.5); + condenser.addNeighborTransmissibility({ false, RiCa::STIMPLAN, 2 }, { false, RiCa::STIMPLAN, 4 }, 0.5); + condenser.addNeighborTransmissibility({ false, RiCa::STIMPLAN, 3 }, { false, RiCa::STIMPLAN, 4 }, 0.5); + + condenser.addNeighborTransmissibility({ true, RiCa::STIMPLAN, 6 }, { false, RiCa::STIMPLAN, 4 }, 0.5); + + double condT = condenser.condensedTransmissibility({ true, RiCa::ECLIPSE, 5 }, { true, RiCa::STIMPLAN, 6 }); + + EXPECT_NEAR(0.1666666667, condT, 1e-7); + } + #if 1 + { + RigTransmissibilityCondenser condenser; + + condenser.addNeighborTransmissibility({ true, RiCa::ECLIPSE, 5 }, { false, RiCa::STIMPLAN, 1 }, 0.5); + condenser.addNeighborTransmissibility({ true, RiCa::ECLIPSE, 7 }, { false, RiCa::STIMPLAN, 2 }, 0.5); + condenser.addNeighborTransmissibility({ true, RiCa::ECLIPSE, 8 }, { false, RiCa::STIMPLAN, 3 }, 0.5); + condenser.addNeighborTransmissibility({ true, RiCa::ECLIPSE, 9 }, { false, RiCa::STIMPLAN, 4 }, 0.5); + + condenser.addNeighborTransmissibility({ false, RiCa::STIMPLAN, 1 }, { false, RiCa::STIMPLAN, 2 }, 0.5); + condenser.addNeighborTransmissibility({ false, RiCa::STIMPLAN, 1 }, { false, RiCa::STIMPLAN, 3 }, 0.5); + condenser.addNeighborTransmissibility({ false, RiCa::STIMPLAN, 2 }, { false, RiCa::STIMPLAN, 4 }, 0.5); + condenser.addNeighborTransmissibility({ false, RiCa::STIMPLAN, 3 }, { false, RiCa::STIMPLAN, 4 }, 0.5); + + condenser.addNeighborTransmissibility({ true, RiCa::STIMPLAN, 6 }, { false, RiCa::STIMPLAN, 4 }, 0.5); + + double condT = condenser.condensedTransmissibility({ true, RiCa::ECLIPSE, 5 }, { true, RiCa::STIMPLAN, 6 }); + + EXPECT_NEAR(0.045454545, condT, 1e-7); + } + #endif + #if 1 + { + // Test example from Matlab scripts, that match the iterative solution + + RigTransmissibilityCondenser condenser; + + condenser.addNeighborTransmissibility({ false, RiCa::STIMPLAN, 1 }, { false, RiCa::STIMPLAN, 2 }, 0.01127000); + condenser.addNeighborTransmissibility({ false, RiCa::STIMPLAN, 1 }, { false, RiCa::STIMPLAN, 4 }, 1.12700000); + condenser.addNeighborTransmissibility({ false, RiCa::STIMPLAN, 1 }, { true, RiCa::ECLIPSE, 7 }, 0.09016000); + condenser.addNeighborTransmissibility({ false, RiCa::STIMPLAN, 2 }, { false, RiCa::STIMPLAN, 3 }, 0.01127000); + condenser.addNeighborTransmissibility({ false, RiCa::STIMPLAN, 2 }, { false, RiCa::STIMPLAN, 5 }, 1.12700000); + condenser.addNeighborTransmissibility({ false, RiCa::STIMPLAN, 2 }, { true, RiCa::ECLIPSE, 8 }, 0.09016000); + condenser.addNeighborTransmissibility({ false, RiCa::STIMPLAN, 3 }, { false, RiCa::STIMPLAN, 6 }, 1.50266667); + condenser.addNeighborTransmissibility({ false, RiCa::STIMPLAN, 3 }, { true, RiCa::ECLIPSE, 9 }, 0.09016000); + condenser.addNeighborTransmissibility({ false, RiCa::STIMPLAN, 4 }, { false, RiCa::STIMPLAN, 5 }, 0.01127000); + condenser.addNeighborTransmissibility({ false, RiCa::STIMPLAN, 4 }, { true, RiCa::ECLIPSE, 10 }, 0.09016000); + condenser.addNeighborTransmissibility({ false, RiCa::STIMPLAN, 5 }, { false, RiCa::STIMPLAN, 6 }, 0.01502667); + condenser.addNeighborTransmissibility({ false, RiCa::STIMPLAN, 5 }, { true, RiCa::ECLIPSE, 11 }, 0.09016000); + condenser.addNeighborTransmissibility({ false, RiCa::STIMPLAN, 6 }, { true, RiCa::ECLIPSE, 12 }, 0.09016000); + condenser.addNeighborTransmissibility({ false, RiCa::STIMPLAN, 6 }, { true, RiCa::STIMPLAN, 13 }, 0.19219491); + + EXPECT_NEAR(0.00402732, condenser.condensedTransmissibility({ true, RiCa::ECLIPSE, 1+6 }, { true, RiCa::ECLIPSE, 2+6 }), 1e-6); + EXPECT_NEAR(0.00027347, condenser.condensedTransmissibility({ true, RiCa::ECLIPSE, 1+6 }, { true, RiCa::ECLIPSE, 3+6 }), 1e-6); + EXPECT_NEAR(0.03879174, condenser.condensedTransmissibility({ true, RiCa::ECLIPSE, 1+6 }, { true, RiCa::ECLIPSE, 4+6 }), 1e-6); + EXPECT_NEAR(0.00400489, condenser.condensedTransmissibility({ true, RiCa::ECLIPSE, 1+6 }, { true, RiCa::ECLIPSE, 5+6 }), 1e-6); + EXPECT_NEAR(0.00026172, condenser.condensedTransmissibility({ true, RiCa::ECLIPSE, 1+6 }, { true, RiCa::ECLIPSE, 6+6 }), 1e-6); + EXPECT_NEAR(0.00055791, condenser.condensedTransmissibility({ true, RiCa::ECLIPSE, 1+6 }, { true, RiCa::STIMPLAN, 7+6 }), 1e-6); + EXPECT_NEAR(0.00245697, condenser.condensedTransmissibility({ true, RiCa::ECLIPSE, 2+6 }, { true, RiCa::ECLIPSE, 3+6 }), 1e-6); + EXPECT_NEAR(0.00401064, condenser.condensedTransmissibility({ true, RiCa::ECLIPSE, 2+6 }, { true, RiCa::ECLIPSE, 4+6 }), 1e-6); + EXPECT_NEAR(0.03442773, condenser.condensedTransmissibility({ true, RiCa::ECLIPSE, 2+6 }, { true, RiCa::ECLIPSE, 5+6 }), 1e-6); + EXPECT_NEAR(0.00233846, condenser.condensedTransmissibility({ true, RiCa::ECLIPSE, 2+6 }, { true, RiCa::ECLIPSE, 6+6 }), 1e-6); + EXPECT_NEAR(0.00498491, condenser.condensedTransmissibility({ true, RiCa::ECLIPSE, 2+6 }, { true, RiCa::STIMPLAN, 7+6 }), 1e-6); + EXPECT_NEAR(0.00027351, condenser.condensedTransmissibility({ true, RiCa::ECLIPSE, 3+6 }, { true, RiCa::ECLIPSE, 4+6 }), 1e-6); + EXPECT_NEAR(0.00246579, condenser.condensedTransmissibility({ true, RiCa::ECLIPSE, 3+6 }, { true, RiCa::ECLIPSE, 5+6 }), 1e-6); + EXPECT_NEAR(0.01956640, condenser.condensedTransmissibility({ true, RiCa::ECLIPSE, 3+6 }, { true, RiCa::ECLIPSE, 6+6 }), 1e-6); + EXPECT_NEAR(0.04170988, condenser.condensedTransmissibility({ true, RiCa::ECLIPSE, 3+6 }, { true, RiCa::STIMPLAN, 7+6 }), 1e-6); + EXPECT_NEAR(0.00402105, condenser.condensedTransmissibility({ true, RiCa::ECLIPSE, 4+6 }, { true, RiCa::ECLIPSE, 5+6 }), 1e-6); + EXPECT_NEAR(0.00026189, condenser.condensedTransmissibility({ true, RiCa::ECLIPSE, 4+6 }, { true, RiCa::ECLIPSE, 6+6 }), 1e-6); + EXPECT_NEAR(0.00055827, condenser.condensedTransmissibility({ true, RiCa::ECLIPSE, 4+6 }, { true, RiCa::STIMPLAN, 7+6 }), 1e-6); + EXPECT_NEAR(0.00237402, condenser.condensedTransmissibility({ true, RiCa::ECLIPSE, 5+6 }, { true, RiCa::ECLIPSE, 6+6 }), 1e-6); + EXPECT_NEAR(0.00506073, condenser.condensedTransmissibility({ true, RiCa::ECLIPSE, 5+6 }, { true, RiCa::STIMPLAN, 7+6 }), 1e-6); + EXPECT_NEAR(0.04448791, condenser.condensedTransmissibility({ true, RiCa::ECLIPSE, 6+6 }, { true, RiCa::STIMPLAN, 7+6 }), 1e-6); + } + #endif +} + +