From 4e737885e4249c10347d8e4ba307652f251298c2 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 20 Feb 2018 15:35:08 +0100 Subject: [PATCH] #2509 Fracture : Move unit conversion of top/bot perforation depth --- .../FileInterface/RifStimPlanXmlReader.cpp | 42 +++++++++++++--- .../FileInterface/RifStimPlanXmlReader.h | 6 ++- .../RigStimPlanFractureDefinition.cpp | 50 ++----------------- .../RigStimPlanFractureDefinition.h | 4 +- 4 files changed, 46 insertions(+), 56 deletions(-) diff --git a/ApplicationCode/FileInterface/RifStimPlanXmlReader.cpp b/ApplicationCode/FileInterface/RifStimPlanXmlReader.cpp index a3438226f4..a57fdf986a 100644 --- a/ApplicationCode/FileInterface/RifStimPlanXmlReader.cpp +++ b/ApplicationCode/FileInterface/RifStimPlanXmlReader.cpp @@ -184,6 +184,8 @@ void RifStimPlanXmlReader::readStimplanGridAndTimesteps(QXmlStreamReader &xmlStr if (xmlStream.isStartElement()) { + RiaEclipseUnitTools::UnitSystem destinationUnit = requiredUnit; + if (xmlStream.name() == "grid") { gridunit = getAttributeValueString(xmlStream, "uom"); @@ -192,11 +194,20 @@ void RifStimPlanXmlReader::readStimplanGridAndTimesteps(QXmlStreamReader &xmlStr else if (gridunit == "ft") stimPlanFileData->m_unitSet = RiaEclipseUnitTools::UNITS_FIELD; else stimPlanFileData->m_unitSet = RiaEclipseUnitTools::UNITS_UNKNOWN; - double tvdToTopPerfFt = getAttributeValueDouble(xmlStream, "TVDToTopPerfFt"); - double tvdToBottomPerfFt = getAttributeValueDouble(xmlStream, "TVDToBottomPerfFt"); + if (destinationUnit == RiaEclipseUnitTools::UNITS_UNKNOWN) + { + // Use file unit set if requested unit is unknown + destinationUnit = stimPlanFileData->m_unitSet; + } - stimPlanFileData->setTvdToTopPerf(tvdToTopPerfFt, RiaDefines::UNIT_FEET); - stimPlanFileData->setTvdToBottomPerf(tvdToBottomPerfFt, RiaDefines::UNIT_FEET); + double tvdToTopPerfFt = getAttributeValueDouble(xmlStream, "TVDToTopPerfFt"); + double tvdToBotPerfFt = getAttributeValueDouble(xmlStream, "TVDToBottomPerfFt"); + + double tvdToTopPerfRequestedUnit = RifStimPlanXmlReader::valueInRequiredUnitSystem(RiaEclipseUnitTools::UNITS_FIELD, destinationUnit, tvdToTopPerfFt); + double tvdToBotPerfRequestedUnit = RifStimPlanXmlReader::valueInRequiredUnitSystem(RiaEclipseUnitTools::UNITS_FIELD, destinationUnit, tvdToBotPerfFt); + + stimPlanFileData->setTvdToTopPerf(tvdToTopPerfRequestedUnit); + stimPlanFileData->setTvdToBottomPerf(tvdToBotPerfRequestedUnit); } if (xmlStream.name() == "xs") @@ -207,7 +218,7 @@ void RifStimPlanXmlReader::readStimplanGridAndTimesteps(QXmlStreamReader &xmlStr std::vector gridValues; getGriddingValues(xmlStream, gridValues, dummy); - gridValuesXs = RifStimPlanXmlReader::valuesInRequiredUnitSystem(stimPlanFileData->m_unitSet, requiredUnit, gridValues); + gridValuesXs = RifStimPlanXmlReader::valuesInRequiredUnitSystem(stimPlanFileData->m_unitSet, destinationUnit, gridValues); } stimPlanFileData->m_fileXs = gridValuesXs; @@ -222,7 +233,7 @@ void RifStimPlanXmlReader::readStimplanGridAndTimesteps(QXmlStreamReader &xmlStr std::vector gridValues; getGriddingValues(xmlStream, gridValues, startNegValuesYs); - gridValuesYs = RifStimPlanXmlReader::valuesInRequiredUnitSystem(stimPlanFileData->m_unitSet, requiredUnit, gridValues); + gridValuesYs = RifStimPlanXmlReader::valuesInRequiredUnitSystem(stimPlanFileData->m_unitSet, destinationUnit, gridValues); } // Reorder and change sign @@ -317,6 +328,25 @@ std::vector RifStimPlanXmlReader::valuesInRequiredUnitSystem(RiaEclipseU return values; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RifStimPlanXmlReader::valueInRequiredUnitSystem(RiaEclipseUnitTools::UnitSystem sourceUnit, + RiaEclipseUnitTools::UnitSystem requiredUnit, + double value) +{ + if (sourceUnit == RiaEclipseUnitTools::UNITS_FIELD && requiredUnit == RiaEclipseUnitTools::UNITS_METRIC) + { + return RiaEclipseUnitTools::feetToMeter(value); + } + else if (sourceUnit == RiaEclipseUnitTools::UNITS_METRIC && requiredUnit == RiaEclipseUnitTools::UNITS_FIELD) + { + return RiaEclipseUnitTools::meterToFeet(value); + } + + return value; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/FileInterface/RifStimPlanXmlReader.h b/ApplicationCode/FileInterface/RifStimPlanXmlReader.h index eeb1f32c97..b698b1e62e 100644 --- a/ApplicationCode/FileInterface/RifStimPlanXmlReader.h +++ b/ApplicationCode/FileInterface/RifStimPlanXmlReader.h @@ -56,6 +56,8 @@ private: static std::vector valuesInRequiredUnitSystem(RiaEclipseUnitTools::UnitSystem sourceUnit, RiaEclipseUnitTools::UnitSystem requiredUnit, const std::vector& values); + + static double valueInRequiredUnitSystem(RiaEclipseUnitTools::UnitSystem sourceUnit, + RiaEclipseUnitTools::UnitSystem requiredUnit, + double value); }; - - diff --git a/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.cpp b/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.cpp index 758ccfb488..3d3c05cffe 100644 --- a/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.cpp +++ b/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.cpp @@ -133,59 +133,17 @@ double RigStimPlanFractureDefinition::maxY() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigStimPlanFractureDefinition::setTvdToTopPerf(double topPerfTvd, RiaDefines::DepthUnitType unit) +void RigStimPlanFractureDefinition::setTvdToTopPerf(double topPerfTvd) { - if (unit == RiaDefines::UNIT_METER) - { - if (m_unitSet == RiaEclipseUnitTools::UNITS_FIELD) - { - m_topPerfTvd = RiaEclipseUnitTools::meterToFeet(topPerfTvd); - } - else if (m_unitSet == RiaEclipseUnitTools::UNITS_METRIC) - { - m_topPerfTvd = topPerfTvd; - } - } - else if (unit == RiaDefines::UNIT_FEET) - { - if (m_unitSet == RiaEclipseUnitTools::UNITS_FIELD) - { - m_topPerfTvd = topPerfTvd; - } - else if (m_unitSet == RiaEclipseUnitTools::UNITS_METRIC) - { - m_topPerfTvd = RiaEclipseUnitTools::feetToMeter(topPerfTvd); - } - } + m_topPerfTvd = topPerfTvd; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigStimPlanFractureDefinition::setTvdToBottomPerf(double bottomPerfTvd, RiaDefines::DepthUnitType unit) +void RigStimPlanFractureDefinition::setTvdToBottomPerf(double bottomPerfTvd) { - if (unit == RiaDefines::UNIT_METER) - { - if (m_unitSet == RiaEclipseUnitTools::UNITS_FIELD) - { - m_bottomPerfTvd = RiaEclipseUnitTools::meterToFeet(bottomPerfTvd); - } - else if (m_unitSet == RiaEclipseUnitTools::UNITS_METRIC) - { - m_bottomPerfTvd = bottomPerfTvd; - } - } - else if (unit == RiaDefines::UNIT_FEET) - { - if (m_unitSet == RiaEclipseUnitTools::UNITS_FIELD) - { - m_bottomPerfTvd = bottomPerfTvd; - } - else if (m_unitSet == RiaEclipseUnitTools::UNITS_METRIC) - { - m_bottomPerfTvd = RiaEclipseUnitTools::feetToMeter(bottomPerfTvd); - } - } + m_bottomPerfTvd = bottomPerfTvd; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.h b/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.h index 9414e272bb..0d89a72532 100644 --- a/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.h +++ b/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.h @@ -68,8 +68,8 @@ public: double maxDepth() const; double topPerfTvd() const; double bottomPerfTvd() const; - void setTvdToTopPerf(double topPerfTvd, RiaDefines::DepthUnitType unit); - void setTvdToBottomPerf(double bottomPerfTvd, RiaDefines::DepthUnitType unit); + void setTvdToTopPerf(double topPerfTvd); + void setTvdToBottomPerf(double bottomPerfTvd); cvf::ref createFractureGrid(const QString& resultName, int activeTimeStepIndex,