diff --git a/ApplicationCode/ReservoirDataModel/RigWellPathFormations.cpp b/ApplicationCode/ReservoirDataModel/RigWellPathFormations.cpp index 2732d79390..6f33c1b5cb 100644 --- a/ApplicationCode/ReservoirDataModel/RigWellPathFormations.cpp +++ b/ApplicationCode/ReservoirDataModel/RigWellPathFormations.cpp @@ -33,10 +33,17 @@ RigWellPathFormations::RigWellPathFormations(const std::vector(formation, level)); + m_formations.push_back(std::pair(formation, level)); + } } } @@ -58,9 +65,6 @@ struct MeasuredDepthComp void RigWellPathFormations::measuredDepthAndFormationNamesWithoutDuplicatesOnDepth(std::vector* names, std::vector* measuredDepths) const { - names->clear(); - measuredDepths->clear(); - std::map tempMakeVectorUniqueOnMeasuredDepth; for (const std::pair& formation : m_formations) @@ -96,18 +100,21 @@ struct LevelAndName QString name; }; +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- enum PICK_POSITION { TOP, BASE }; + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void evaluateFormations(const std::vector>& formations, - const RigWellPathFormations::FormationLevel& maxLevel, - bool includeFluids, const PICK_POSITION& position, - std::map* uniqueListMaker) +void evaluateFormationsForOnePosition(const std::vector>& formations, + const RigWellPathFormations::FormationLevel& maxLevel, const PICK_POSITION& position, + std::map* uniqueListMaker) { QString postFix; @@ -132,15 +139,6 @@ void evaluateFormations(const std::vector maxLevel) continue; if (!uniqueListMaker->count(md) || uniqueListMaker->at(md).level < formation.second) @@ -150,25 +148,42 @@ void evaluateFormations(const std::vector>& formations, - std::map* uniqueListMaker) +void evaluateFormations(const std::vector>& formations, + const RigWellPathFormations::FormationLevel& maxLevel, + std::vector* names, std::vector* measuredDepths) { - for (const std::pair& formation : formations) + std::map tempMakeVectorUniqueOnMeasuredDepth; + + evaluateFormationsForOnePosition(formations, maxLevel, PICK_POSITION::TOP, &tempMakeVectorUniqueOnMeasuredDepth); + evaluateFormationsForOnePosition(formations, maxLevel, PICK_POSITION::BASE, &tempMakeVectorUniqueOnMeasuredDepth); + + for (auto it = tempMakeVectorUniqueOnMeasuredDepth.begin(); it != tempMakeVectorUniqueOnMeasuredDepth.end(); it++) { - if (formation.second == RigWellPathFormations::FLUID) - { - (*uniqueListMaker)[formation.first.mdBase] = - LevelAndName(formation.second, formation.first.formationName + " Base"); - } + measuredDepths->push_back(it->first); + names->push_back(it->second.name); + } +} + +void evaluateFluids(const std::vector& fluidFormations, + std::vector* names, std::vector* measuredDepths) +{ + + std::map uniqueListMaker; + + for (const RigWellPathFormation& formation : fluidFormations) + { + uniqueListMaker[formation.mdBase] = formation.formationName + " Base"; } - for (const std::pair& formation : formations) + for (const RigWellPathFormation& formation : fluidFormations) { - if (formation.second == RigWellPathFormations::FLUID) - { - (*uniqueListMaker)[formation.first.mdTop] = - LevelAndName(formation.second, formation.first.formationName + " Top"); - } + uniqueListMaker[formation.mdTop] = formation.formationName + " Top"; + } + + for (auto it = uniqueListMaker.begin(); it != uniqueListMaker.end(); it++) + { + measuredDepths->push_back(it->first); + names->push_back(it->second); } } @@ -182,34 +197,22 @@ void RigWellPathFormations::measuredDepthAndFormationNamesUpToLevel(FormationLev names->clear(); measuredDepths->clear(); - std::map tempMakeVectorUniqueOnMeasuredDepth; + if (includeFluids) + { + evaluateFluids(m_fluids, names, measuredDepths); + } if (maxLevel == RigWellPathFormations::NONE) { - if (includeFluids) - { - evaluateFluids(m_formations, &tempMakeVectorUniqueOnMeasuredDepth); - } - else - { - return; - } + return; } else if (maxLevel == RigWellPathFormations::ALL) { measuredDepthAndFormationNamesWithoutDuplicatesOnDepth(names, measuredDepths); - return; } else { - evaluateFormations(m_formations, maxLevel, includeFluids, PICK_POSITION::TOP, &tempMakeVectorUniqueOnMeasuredDepth); - evaluateFormations(m_formations, maxLevel, includeFluids, PICK_POSITION::BASE, &tempMakeVectorUniqueOnMeasuredDepth); - } - - for (auto it = tempMakeVectorUniqueOnMeasuredDepth.begin(); it != tempMakeVectorUniqueOnMeasuredDepth.end(); it++) - { - measuredDepths->push_back(it->first); - names->push_back(it->second.name); + evaluateFormations(m_formations, maxLevel, names, measuredDepths); } } @@ -248,7 +251,21 @@ QString RigWellPathFormations::keyInFile() const //-------------------------------------------------------------------------------------------------- size_t RigWellPathFormations::formationNamesCount() const { - return m_formations.size(); + return m_formations.size() + m_fluids.size(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RigWellPathFormations::isFluid(QString formationName) +{ + formationName = formationName.trimmed(); + + if (formationName == "OIL" || formationName == "GAS" || formationName == "WATER") + { + return true; + } + return false; } //-------------------------------------------------------------------------------------------------- @@ -258,11 +275,6 @@ RigWellPathFormations::FormationLevel RigWellPathFormations::detectLevel(QString { formationName = formationName.trimmed(); - if (formationName == "OIL" || formationName == "GAS" || formationName == "WATER") - { - return RigWellPathFormations::FLUID; - } - bool isGroupName = true; for (QChar c : formationName) { diff --git a/ApplicationCode/ReservoirDataModel/RigWellPathFormations.h b/ApplicationCode/ReservoirDataModel/RigWellPathFormations.h index 2b9fb2776f..6d1909be69 100644 --- a/ApplicationCode/ReservoirDataModel/RigWellPathFormations.h +++ b/ApplicationCode/ReservoirDataModel/RigWellPathFormations.h @@ -39,12 +39,9 @@ class RigWellPathFormations : public cvf::Object public: RigWellPathFormations(const std::vector& formations, const QString& filePath, const QString& key); - void measuredDepthAndFormationNamesWithoutDuplicatesOnDepth(std::vector* names, - std::vector* measuredDepths) const; - enum FormationLevel { - GROUP, LEVEL0, LEVEL1, LEVEL2, LEVEL3, LEVEL4, LEVEL5, LEVEL6, LEVEL7, LEVEL8, LEVEL9, LEVEL10, ALL, FLUID, UNKNOWN, NONE + GROUP, LEVEL0, LEVEL1, LEVEL2, LEVEL3, LEVEL4, LEVEL5, LEVEL6, LEVEL7, LEVEL8, LEVEL9, LEVEL10, ALL, UNKNOWN, NONE }; void measuredDepthAndFormationNamesUpToLevel(FormationLevel level, std::vector* names, @@ -58,6 +55,10 @@ public: size_t formationNamesCount() const; private: + void measuredDepthAndFormationNamesWithoutDuplicatesOnDepth(std::vector* names, + std::vector* measuredDepths) const; + + bool isFluid(QString formationName); FormationLevel detectLevel(QString formationName); private: @@ -67,4 +68,5 @@ private: std::map m_formationsLevelsPresent; std::vector> m_formations; + std::vector m_fluids; };