#9102 Thermal Fracture: handle field units.

This commit is contained in:
Kristian Bendiksen 2022-08-03 14:07:20 +02:00 committed by Magne Sjaastad
parent d2d6e61271
commit 49bfc62ea7
7 changed files with 70 additions and 16 deletions

View File

@ -96,7 +96,7 @@ QString RiaEclipseUnitTools::unitStringPressure( RiaDefines::EclipseUnitSystem u
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RiaEclipseUnitTools::convertToMeter( double sourceValue, const QString& sourceValueUnitText )
double RiaEclipseUnitTools::convertToMeter( double sourceValue, const QString& sourceValueUnitText, bool replaceUnmatched )
{
QString timmed = sourceValueUnitText.trimmed();
@ -112,30 +112,35 @@ double RiaEclipseUnitTools::convertToMeter( double sourceValue, const QString& s
{
return sourceValue / 1000.0;
}
else if ( timmed.compare( "in", Qt::CaseInsensitive ) == 0 )
else if ( timmed.compare( "in", Qt::CaseInsensitive ) == 0 || timmed.compare( "inches", Qt::CaseInsensitive ) == 0 )
{
return RiaEclipseUnitTools::inchToMeter( sourceValue );
}
else if ( timmed.compare( "ft", Qt::CaseInsensitive ) == 0 || timmed.compare( "md-ft", Qt::CaseInsensitive ) == 0 )
else if ( timmed.compare( "ft", Qt::CaseInsensitive ) == 0 || timmed.compare( "feet", Qt::CaseInsensitive ) == 0 ||
timmed.compare( "md-ft", Qt::CaseInsensitive ) == 0 )
{
return RiaEclipseUnitTools::feetToMeter( sourceValue );
}
return HUGE_VAL;
if ( replaceUnmatched )
return HUGE_VAL;
else
return sourceValue;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RiaEclipseUnitTools::convertToFeet( double sourceValue, const QString& sourceValueUnitText )
double RiaEclipseUnitTools::convertToFeet( double sourceValue, const QString& sourceValueUnitText, bool replaceUnmatched )
{
QString timmed = sourceValueUnitText.trimmed();
if ( timmed.compare( "ft", Qt::CaseInsensitive ) == 0 || timmed.compare( "md-ft", Qt::CaseInsensitive ) == 0 )
if ( timmed.compare( "ft", Qt::CaseInsensitive ) == 0 || timmed.compare( "feet", Qt::CaseInsensitive ) == 0 ||
timmed.compare( "md-ft", Qt::CaseInsensitive ) == 0 )
{
return sourceValue;
}
else if ( timmed.compare( "in", Qt::CaseInsensitive ) == 0 )
else if ( timmed.compare( "in", Qt::CaseInsensitive ) == 0 || timmed.compare( "inches", Qt::CaseInsensitive ) == 0 )
{
return RiaEclipseUnitTools::inchToFeet( sourceValue );
}
@ -154,5 +159,8 @@ double RiaEclipseUnitTools::convertToFeet( double sourceValue, const QString& so
return RiaEclipseUnitTools::meterToFeet( sourceValue );
}
return HUGE_VAL;
if ( replaceUnmatched )
return HUGE_VAL;
else
return sourceValue;
}

View File

@ -49,6 +49,6 @@ public:
static QString unitStringPressure( RiaDefines::EclipseUnitSystem unitSystem );
static double convertToMeter( double sourceValue, const QString& unitText );
static double convertToFeet( double sourceValue, const QString& unitText );
static double convertToMeter( double sourceValue, const QString& unitText, bool replaceUnmatched = true );
static double convertToFeet( double sourceValue, const QString& unitText, bool replaceUnmatched = true );
};

View File

@ -101,6 +101,7 @@ std::pair<std::shared_ptr<RigThermalFractureDefinition>, QString>
return std::make_pair( nullptr, QString( "Inconsistent units found in file: %1" ).arg( filePath ) );
}
definition->setUnitSystem( unitSystem );
isFirstHeader = false;
}
else if ( isValidNode )

View File

@ -160,12 +160,10 @@ void RimThermalFractureTemplate::loadDataAndUpdate()
{
setDefaultConductivityResultIfEmpty();
// if ( fractureTemplateUnit() == RiaDefines::EclipseUnitSystem::UNITS_UNKNOWN )
// {
// setUnitSystem( m_fractureDefinitionData->unitSet() );
// }
// TODO: handle other units
setUnitSystem( RiaDefines::EclipseUnitSystem::UNITS_METRIC );
if ( fractureTemplateUnit() == RiaDefines::EclipseUnitSystem::UNITS_UNKNOWN )
{
setUnitSystem( m_fractureDefinitionData->unitSystem() );
}
if ( !m_userDefinedWellPathDepthAtFracture )
{

View File

@ -27,6 +27,7 @@
///
//--------------------------------------------------------------------------------------------------
RigThermalFractureDefinition::RigThermalFractureDefinition()
: m_unitSystem( RiaDefines::EclipseUnitSystem::UNITS_UNKNOWN )
{
}
@ -53,6 +54,22 @@ QString RigThermalFractureDefinition::name() const
return m_name;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigThermalFractureDefinition::setUnitSystem( RiaDefines::EclipseUnitSystem unitSystem )
{
m_unitSystem = unitSystem;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiaDefines::EclipseUnitSystem RigThermalFractureDefinition::unitSystem() const
{
return m_unitSystem;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -58,9 +58,14 @@ public:
std::vector<cvf::Vec3d> relativeCoordinates( int timeStepIndex ) const;
void setUnitSystem( RiaDefines::EclipseUnitSystem unitSystem );
RiaDefines::EclipseUnitSystem unitSystem() const;
private:
QString m_name;
RiaDefines::EclipseUnitSystem m_unitSystem;
std::vector<double> m_timeSteps;
std::vector<RigThermalFractureResult> m_results;
};

View File

@ -18,6 +18,7 @@
#include "RigThermalFractureResultUtil.h"
#include "RiaEclipseUnitTools.h"
#include "RiaLogging.h"
#include "RiaWeightedMeanCalculator.h"
@ -256,6 +257,30 @@ cvf::cref<RigFractureGrid>
return nullptr;
}
// Check that the data is in the required unit system.
// Convert if not the case.
if ( requiredUnitSet != fractureDefinition->unitSystem() )
{
// Convert to the conductivity unit system used by the fracture template
// The conductivity value is used in the computations of transmissibility when exporting COMPDAT, and has unit
// md-m or md-ft This unit must match the unit used to represent coordinates of the grid used for export
for ( auto& yValues : conductivityValues )
{
for ( auto& xVal : yValues )
{
if ( requiredUnitSet == RiaDefines::EclipseUnitSystem::UNITS_FIELD )
{
xVal = RiaEclipseUnitTools::convertToFeet( xVal, conductivityUnitTextOnFile, false );
}
else if ( requiredUnitSet == RiaDefines::EclipseUnitSystem::UNITS_METRIC )
{
xVal = RiaEclipseUnitTools::convertToMeter( xVal, conductivityUnitTextOnFile, false );
}
}
}
}
// Create bounding box
cvf::BoundingBox boundingBox;
for ( auto p : points )