mirror of
https://github.com/OPM/ResInsight.git
synced 2026-09-03 20:53:13 -05:00
Merge fracture unit refactoring into dev #2509
Add display of M and F in front of fracture templates Add convert of StimPlan templates Add copy/paste of StimPlan templates Remove obsolete unit conversion code
This commit is contained in:
@@ -40,6 +40,7 @@ bool hasNegativeValues(std::vector<double> xs);
|
||||
cvf::ref<RigStimPlanFractureDefinition> RifStimPlanXmlReader::readStimPlanXMLFile(const QString& stimPlanFileName,
|
||||
double conductivityScalingFactor,
|
||||
MirrorMode mirrorMode,
|
||||
RiaEclipseUnitTools::UnitSystem requiredUnit,
|
||||
QString * errorMessage)
|
||||
{
|
||||
RiaLogging::info(QString("Starting to open StimPlan XML file: '%1'").arg(stimPlanFileName));
|
||||
@@ -56,7 +57,7 @@ cvf::ref<RigStimPlanFractureDefinition> RifStimPlanXmlReader::readStimPlanXMLFil
|
||||
QXmlStreamReader xmlStream;
|
||||
xmlStream.setDevice(&dataFile);
|
||||
xmlStream.readNext();
|
||||
readStimplanGridAndTimesteps(xmlStream, stimPlanFileData.p(), mirrorMode);
|
||||
readStimplanGridAndTimesteps(xmlStream, stimPlanFileData.p(), mirrorMode, requiredUnit);
|
||||
|
||||
RiaEclipseUnitTools::UnitSystemType unitSystem = stimPlanFileData->unitSet();
|
||||
|
||||
@@ -167,8 +168,9 @@ cvf::ref<RigStimPlanFractureDefinition> RifStimPlanXmlReader::readStimPlanXMLFil
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RifStimPlanXmlReader::readStimplanGridAndTimesteps(QXmlStreamReader &xmlStream,
|
||||
RigStimPlanFractureDefinition* stimPlanFileData,
|
||||
MirrorMode mirrorMode)
|
||||
RigStimPlanFractureDefinition* stimPlanFileData,
|
||||
MirrorMode mirrorMode,
|
||||
RiaEclipseUnitTools::UnitSystem requiredUnit)
|
||||
{
|
||||
size_t startNegValuesYs = 0;
|
||||
QString gridunit = "unknown";
|
||||
@@ -182,6 +184,8 @@ void RifStimPlanXmlReader::readStimplanGridAndTimesteps(QXmlStreamReader &xmlStr
|
||||
|
||||
if (xmlStream.isStartElement())
|
||||
{
|
||||
RiaEclipseUnitTools::UnitSystem destinationUnit = requiredUnit;
|
||||
|
||||
if (xmlStream.name() == "grid")
|
||||
{
|
||||
gridunit = getAttributeValueString(xmlStream, "uom");
|
||||
@@ -190,31 +194,51 @@ 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")
|
||||
{
|
||||
size_t dummy;
|
||||
std::vector<double> gridValues;
|
||||
getGriddingValues(xmlStream, gridValues, dummy);
|
||||
stimPlanFileData->m_fileXs = gridValues;
|
||||
std::vector<double> gridValuesXs;
|
||||
{
|
||||
size_t dummy;
|
||||
std::vector<double> gridValues;
|
||||
getGriddingValues(xmlStream, gridValues, dummy);
|
||||
|
||||
stimPlanFileData->generateXsFromFileXs(mirrorMode == MIRROR_AUTO ? !hasNegativeValues(gridValues) : (bool)mirrorMode);
|
||||
gridValuesXs = RifStimPlanXmlReader::valuesInRequiredUnitSystem(stimPlanFileData->m_unitSet, destinationUnit, gridValues);
|
||||
}
|
||||
|
||||
stimPlanFileData->m_fileXs = gridValuesXs;
|
||||
|
||||
stimPlanFileData->generateXsFromFileXs(mirrorMode == MIRROR_AUTO ? !hasNegativeValues(gridValuesXs) : (bool)mirrorMode);
|
||||
}
|
||||
|
||||
else if (xmlStream.name() == "ys")
|
||||
{
|
||||
std::vector<double> gridValues;
|
||||
getGriddingValues(xmlStream, gridValues, startNegValuesYs);
|
||||
std::vector<double> gridValuesYs;
|
||||
{
|
||||
std::vector<double> gridValues;
|
||||
getGriddingValues(xmlStream, gridValues, startNegValuesYs);
|
||||
|
||||
gridValuesYs = RifStimPlanXmlReader::valuesInRequiredUnitSystem(stimPlanFileData->m_unitSet, destinationUnit, gridValues);
|
||||
}
|
||||
|
||||
// Reorder and change sign
|
||||
std::vector<double> ys;
|
||||
for (double y : gridValues)
|
||||
for (double y : gridValuesYs)
|
||||
{
|
||||
ys.insert(ys.begin(), -y);
|
||||
}
|
||||
@@ -273,6 +297,56 @@ std::vector<std::vector<double>> RifStimPlanXmlReader::getAllDepthDataAtTimeSte
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<double> RifStimPlanXmlReader::valuesInRequiredUnitSystem(RiaEclipseUnitTools::UnitSystem sourceUnit,
|
||||
RiaEclipseUnitTools::UnitSystem requiredUnit,
|
||||
const std::vector<double>& values)
|
||||
{
|
||||
if (sourceUnit == RiaEclipseUnitTools::UNITS_FIELD && requiredUnit == RiaEclipseUnitTools::UNITS_METRIC)
|
||||
{
|
||||
std::vector<double> convertedValues;
|
||||
for (const auto &valueInFeet : values)
|
||||
{
|
||||
convertedValues.push_back(RiaEclipseUnitTools::feetToMeter(valueInFeet));
|
||||
}
|
||||
|
||||
return convertedValues;
|
||||
}
|
||||
else if (sourceUnit == RiaEclipseUnitTools::UNITS_METRIC && requiredUnit == RiaEclipseUnitTools::UNITS_FIELD)
|
||||
{
|
||||
std::vector<double> convertedValues;
|
||||
for (const auto &valueInMeter : values)
|
||||
{
|
||||
convertedValues.push_back(RiaEclipseUnitTools::meterToFeet(valueInMeter));
|
||||
}
|
||||
|
||||
return convertedValues;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -38,12 +38,14 @@ public:
|
||||
static cvf::ref<RigStimPlanFractureDefinition> readStimPlanXMLFile(const QString& stimPlanFileName,
|
||||
double conductivityScalingFactor,
|
||||
MirrorMode mirrorMode,
|
||||
RiaEclipseUnitTools::UnitSystem requiredUnit,
|
||||
QString * errorMessage);
|
||||
|
||||
private:
|
||||
static void readStimplanGridAndTimesteps(QXmlStreamReader &xmlStream,
|
||||
RigStimPlanFractureDefinition* stimPlanFileData,
|
||||
MirrorMode mirrorMode);
|
||||
MirrorMode mirrorMode,
|
||||
RiaEclipseUnitTools::UnitSystem requiredUnit);
|
||||
|
||||
static double getAttributeValueDouble(QXmlStreamReader &xmlStream, QString parameterName);
|
||||
static QString getAttributeValueString(QXmlStreamReader &xmlStream, QString parameterName);
|
||||
@@ -51,6 +53,11 @@ private:
|
||||
|
||||
static std::vector<std::vector<double>> getAllDepthDataAtTimeStep(QXmlStreamReader &xmlStream);
|
||||
|
||||
static std::vector<double> valuesInRequiredUnitSystem(RiaEclipseUnitTools::UnitSystem sourceUnit,
|
||||
RiaEclipseUnitTools::UnitSystem requiredUnit,
|
||||
const std::vector<double>& values);
|
||||
|
||||
static double valueInRequiredUnitSystem(RiaEclipseUnitTools::UnitSystem sourceUnit,
|
||||
RiaEclipseUnitTools::UnitSystem requiredUnit,
|
||||
double value);
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user