diff --git a/ApplicationCode/FileInterface/RifEclipseSummaryAddress.cpp b/ApplicationCode/FileInterface/RifEclipseSummaryAddress.cpp index e4c6698e72..8393689538 100644 --- a/ApplicationCode/FileInterface/RifEclipseSummaryAddress.cpp +++ b/ApplicationCode/FileInterface/RifEclipseSummaryAddress.cpp @@ -17,6 +17,89 @@ ///////////////////////////////////////////////////////////////////////////////// #include "RifEclipseSummaryAddress.h" +#include "cvfAssert.h" + +// todo: Make class member +std::tuple ijkTupleFromString(const std::string &s) +{ + auto firstSep = s.find(','); + auto lastSep = s.find(',', firstSep + 1); + CVF_ASSERT(firstSep != std::string::npos && lastSep != std::string::npos); + auto textI = s.substr(0, firstSep); + auto textJ = s.substr(firstSep + 1, lastSep - firstSep - 1); + auto textK = s.substr(lastSep + 1); + return std::make_tuple(std::stoi(textI), std::stoi(textJ), std::stoi(textK)); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RifEclipseSummaryAddress::RifEclipseSummaryAddress(SummaryVarCategory category, + std::map& identifiers) : + m_variableCategory(category), + m_regionNumber(-1), + m_regionNumber2(-1), + m_wellSegmentNumber(-1), + m_cellI(-1), + m_cellJ(-1), + m_cellK(-1) +{ + std::tuple ijkTuple; + switch (category) + { + case SUMMARY_REGION: + m_regionNumber = std::stoi(identifiers[INPUT_REGION_NUMBER]); + break; + case SUMMARY_REGION_2_REGION: + m_regionNumber = std::stoi(identifiers[INPUT_REGION_NUMBER]); + m_regionNumber2 = std::stoi(identifiers[INPUT_REGION2_NUMBER]); + break; + case SUMMARY_WELL_GROUP: + m_wellGroupName = identifiers[INPUT_WELL_GROUP_NAME]; + break; + case SUMMARY_WELL: + m_wellName = identifiers[INPUT_WELL_NAME]; + break; + case SUMMARY_WELL_COMPLETION: + m_wellName = identifiers[INPUT_WELL_NAME]; + ijkTuple = ijkTupleFromString(identifiers[INPUT_CELL_IJK]); + m_cellI = std::get<0>(ijkTuple); + m_cellJ = std::get<1>(ijkTuple); + m_cellK = std::get<2>(ijkTuple); + break; + case SUMMARY_WELL_LGR: + m_lgrName = identifiers[INPUT_LGR_NAME]; + m_wellName = identifiers[INPUT_WELL_NAME]; + break; + case SUMMARY_WELL_COMPLETION_LGR: + m_lgrName = identifiers[INPUT_LGR_NAME]; + m_wellName = identifiers[INPUT_WELL_NAME]; + ijkTuple = ijkTupleFromString(identifiers[INPUT_CELL_IJK]); + m_cellI = std::get<0>(ijkTuple); + m_cellJ = std::get<1>(ijkTuple); + m_cellK = std::get<2>(ijkTuple); + break; + case SUMMARY_WELL_SEGMENT: + m_wellName = identifiers[INPUT_WELL_NAME]; + m_wellSegmentNumber = std::stoi(identifiers[INPUT_SEGMENT_NUMBER]); + case SUMMARY_BLOCK: + ijkTuple = ijkTupleFromString(identifiers[INPUT_CELL_IJK]); + m_cellI = std::get<0>(ijkTuple); + m_cellJ = std::get<1>(ijkTuple); + m_cellK = std::get<2>(ijkTuple); + break; + case SUMMARY_BLOCK_LGR: + m_lgrName = identifiers[INPUT_LGR_NAME]; + ijkTuple = ijkTupleFromString(identifiers[INPUT_CELL_IJK]); + m_cellI = std::get<0>(ijkTuple); + m_cellJ = std::get<1>(ijkTuple); + m_cellK = std::get<2>(ijkTuple); + break; + } + + // Set quantity for all categories + m_quantityName = identifiers[INPUT_VECTOR_NAME]; +} //-------------------------------------------------------------------------------------------------- /// diff --git a/ApplicationCode/FileInterface/RifEclipseSummaryAddress.h b/ApplicationCode/FileInterface/RifEclipseSummaryAddress.h index 030216b3ab..d7538d4c0d 100644 --- a/ApplicationCode/FileInterface/RifEclipseSummaryAddress.h +++ b/ApplicationCode/FileInterface/RifEclipseSummaryAddress.h @@ -18,6 +18,7 @@ #pragma once #include +#include //================================================================================================== // @@ -47,6 +48,18 @@ public: SUMMARY_BLOCK_LGR, }; + enum SummaryIdentifierType + { + INPUT_REGION_NUMBER, + INPUT_REGION2_NUMBER, + INPUT_WELL_NAME, + INPUT_WELL_GROUP_NAME, + INPUT_CELL_IJK, + INPUT_LGR_NAME, + INPUT_SEGMENT_NUMBER, + INPUT_VECTOR_NAME + }; + public: RifEclipseSummaryAddress(): @@ -85,6 +98,9 @@ public: { } + RifEclipseSummaryAddress(SummaryVarCategory category, + std::map& identifiers); + // Static specialized creation methods static RifEclipseSummaryAddress fieldVarAddress(const std::string& fieldVarName);