#5663 Fix element property input for UCS

This commit is contained in:
Gaute Lindkvist
2020-03-10 18:43:11 +01:00
parent 2b7cbee0a6
commit 1c75d9b4bd
16 changed files with 219 additions and 146 deletions

View File

@@ -42,7 +42,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RiaCellDividingTools.h
${CMAKE_CURRENT_LIST_DIR}/RiaFieldHandleTools.h
${CMAKE_CURRENT_LIST_DIR}/RiaBoundingBoxTools.h
${CMAKE_CURRENT_LIST_DIR}/RiaWellLogUnitTools.h
${CMAKE_CURRENT_LIST_DIR}/RiaWellLogUnitTools.inl
)
set (SOURCE_GROUP_SOURCE_FILES
@@ -82,7 +82,6 @@ ${CMAKE_CURRENT_LIST_DIR}/RiaGitDiff.cpp
${CMAKE_CURRENT_LIST_DIR}/RiaCellDividingTools.cpp
${CMAKE_CURRENT_LIST_DIR}/RiaFieldHandleTools.cpp
${CMAKE_CURRENT_LIST_DIR}/RiaBoundingBoxTools.cpp
${CMAKE_CURRENT_LIST_DIR}/RiaWellLogUnitTools.cpp
)
list(APPEND CODE_HEADER_FILES

View File

@@ -25,11 +25,13 @@
class RigWellPath;
template <typename FloatType>
class RiaWellLogUnitTools
{
public:
static const double GRAVITY_ACCEL;
static const double UNIT_WEIGHT_OF_WATER;
static const FloatType gravityAcceleration();
static const FloatType unitWeightOfWater();
static bool stringsMatch( const QString& lhs, const QString& rhs );
static QString noUnitString();
static QString sg_emwUnitString();
@@ -39,35 +41,38 @@ public:
static QString gPerCm3UnitString();
static QString kgPerM3UnitString();
static QString pascalUnitString();
static QString pascalUnitStringShort();
public:
static std::vector<double> convertDepths( const std::vector<double>& depthsIn,
RiaDefines::DepthUnitType unitsIn,
RiaDefines::DepthUnitType unitsOut );
static bool convertValues( const std::vector<double>& tvdRKBs,
const std::vector<double>& valuesIn,
std::vector<double>* valuesOut,
const QString& unitsIn,
const QString& unitsOut );
static bool convertValues( std::vector<std::pair<double, double>>* measuredDepthsAndValues,
const QString& unitsIn,
const QString& unitsOut,
const RigWellPath* wellPath );
static std::vector<FloatType> convertDepths( const std::vector<FloatType>& depthsIn,
RiaDefines::DepthUnitType unitsIn,
RiaDefines::DepthUnitType unitsOut );
static bool convertValues( const std::vector<FloatType>& tvdRKBs,
const std::vector<FloatType>& valuesIn,
std::vector<FloatType>* valuesOut,
const QString& unitsIn,
const QString& unitsOut );
static bool convertValues( std::vector<std::pair<FloatType, FloatType>>* measuredDepthsAndValues,
const QString& unitsIn,
const QString& unitsOut,
const RigWellPath* wellPath );
static std::vector<double> tvdRKBs( const std::vector<double>& measuredDepths, const RigWellPath* wellPath );
static std::vector<FloatType> tvdRKBs( const std::vector<FloatType>& measuredDepths, const RigWellPath* wellPath );
// Supported conversions
static std::vector<double> convertGpcm3ToBar( const std::vector<double>& tvdRKBs,
const std::vector<double>& valuesInGpcm3 );
static std::vector<double> convertBarToGpcm3( const std::vector<double>& tvdRKBs,
const std::vector<double>& valuesInBar );
static std::vector<FloatType> convertGpcm3ToBar( const std::vector<FloatType>& tvdRKBs,
const std::vector<FloatType>& valuesInGpcm3 );
static std::vector<FloatType> convertBarToGpcm3( const std::vector<FloatType>& tvdRKBs,
const std::vector<FloatType>& valuesInBar );
static std::vector<double> convertNormalizedByPPToBar( const std::vector<double>& tvdRKBs,
const std::vector<double>& valuesInBar );
static std::vector<double> convertBarToNormalizedByPP( const std::vector<double>& tvdRKBs,
const std::vector<double>& valuesInBar );
static std::vector<double> multiply( const std::vector<double>& values, double factor );
static double pascalPerBar();
static double MPaPerBar();
static double hydrostaticPorePressureBar( double tvdRKB );
static std::vector<FloatType> convertNormalizedByPPToBar( const std::vector<FloatType>& tvdRKBs,
const std::vector<FloatType>& valuesInBar );
static std::vector<FloatType> convertBarToNormalizedByPP( const std::vector<FloatType>& tvdRKBs,
const std::vector<FloatType>& valuesInBar );
static std::vector<FloatType> multiply( const std::vector<FloatType>& values, FloatType factor );
static FloatType pascalPerBar();
static FloatType MPaPerBar();
static FloatType hydrostaticPorePressureBar( FloatType tvdRKB );
};
#include "RiaWellLogUnitTools.inl"

View File

@@ -15,8 +15,6 @@
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RiaWellLogUnitTools.h"
#include "RiaEclipseUnitTools.h"
#include "RigWellPath.h"
@@ -24,10 +22,30 @@
#include <limits>
const double RiaWellLogUnitTools::GRAVITY_ACCEL = 9.81;
const double RiaWellLogUnitTools::UNIT_WEIGHT_OF_WATER = RiaWellLogUnitTools::GRAVITY_ACCEL * 1000.0; // N / m^3
bool stringsMatch( const QString& lhs, const QString& rhs )
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
template <typename FloatType>
const FloatType RiaWellLogUnitTools<FloatType>::gravityAcceleration()
{
return (FloatType) 9.81;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
template <typename FloatType>
const FloatType RiaWellLogUnitTools<FloatType>::unitWeightOfWater()
{
return RiaWellLogUnitTools<FloatType>::gravityAcceleration() * 1000.0; // N / m^3
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
template <typename FloatType>
bool RiaWellLogUnitTools<FloatType>::stringsMatch( const QString& lhs, const QString& rhs )
{
return QString::compare( lhs, rhs, Qt::CaseInsensitive ) == 0;
}
@@ -35,7 +53,8 @@ bool stringsMatch( const QString& lhs, const QString& rhs )
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RiaWellLogUnitTools::noUnitString()
template <typename FloatType>
QString RiaWellLogUnitTools<FloatType>::noUnitString()
{
return "NO_UNIT";
}
@@ -43,7 +62,8 @@ QString RiaWellLogUnitTools::noUnitString()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RiaWellLogUnitTools::sg_emwUnitString()
template <typename FloatType>
QString RiaWellLogUnitTools<FloatType>::sg_emwUnitString()
{
return "sg_EMW";
}
@@ -51,7 +71,8 @@ QString RiaWellLogUnitTools::sg_emwUnitString()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RiaWellLogUnitTools::barUnitString()
template <typename FloatType>
QString RiaWellLogUnitTools<FloatType>::barUnitString()
{
return "Bar";
}
@@ -59,7 +80,8 @@ QString RiaWellLogUnitTools::barUnitString()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RiaWellLogUnitTools::barX100UnitString()
template <typename FloatType>
QString RiaWellLogUnitTools<FloatType>::barX100UnitString()
{
return "Bar x100";
}
@@ -67,7 +89,8 @@ QString RiaWellLogUnitTools::barX100UnitString()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RiaWellLogUnitTools::MPaUnitString()
template <typename FloatType>
QString RiaWellLogUnitTools<FloatType>::MPaUnitString()
{
return "MPa";
}
@@ -75,7 +98,8 @@ QString RiaWellLogUnitTools::MPaUnitString()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RiaWellLogUnitTools::gPerCm3UnitString()
template <typename FloatType>
QString RiaWellLogUnitTools<FloatType>::gPerCm3UnitString()
{
return "g/cm3";
}
@@ -83,7 +107,8 @@ QString RiaWellLogUnitTools::gPerCm3UnitString()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RiaWellLogUnitTools::kgPerM3UnitString()
template <typename FloatType>
QString RiaWellLogUnitTools<FloatType>::kgPerM3UnitString()
{
return "kg/m3";
}
@@ -91,7 +116,8 @@ QString RiaWellLogUnitTools::kgPerM3UnitString()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RiaWellLogUnitTools::pascalUnitString()
template <typename FloatType>
QString RiaWellLogUnitTools<FloatType>::pascalUnitString()
{
return "pascal";
}
@@ -99,7 +125,17 @@ QString RiaWellLogUnitTools::pascalUnitString()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<double> RiaWellLogUnitTools::convertDepths( const std::vector<double>& depthsIn,
template <typename FloatType>
QString RiaWellLogUnitTools<FloatType>::pascalUnitStringShort()
{
return "pa";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
template <typename FloatType>
std::vector<FloatType> RiaWellLogUnitTools<FloatType>::convertDepths( const std::vector<FloatType>& depthsIn,
RiaDefines::DepthUnitType unitsIn,
RiaDefines::DepthUnitType unitsOut )
{
@@ -117,9 +153,10 @@ std::vector<double> RiaWellLogUnitTools::convertDepths( const std::vector<double
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiaWellLogUnitTools::convertValues( const std::vector<double>& tvdRKBs,
const std::vector<double>& valuesIn,
std::vector<double>* valuesOut,
template <typename FloatType>
bool RiaWellLogUnitTools<FloatType>::convertValues( const std::vector<FloatType>& tvdRKBs,
const std::vector<FloatType>& valuesIn,
std::vector<FloatType>* valuesOut,
const QString& unitsIn,
const QString& unitsOut )
{
@@ -162,13 +199,13 @@ bool RiaWellLogUnitTools::convertValues( const std::vector<double>& tvdRKBs,
}
else if ( stringsMatch( unitsIn, barX100UnitString() ) && stringsMatch( unitsOut, MPaUnitString() ) )
{
*valuesOut = multiply( valuesIn, 100.0 );
*valuesOut = multiply( valuesIn, (FloatType)100.0 );
*valuesOut = multiply( *valuesOut, MPaPerBar() );
return true;
}
else if ( stringsMatch( unitsIn, barX100UnitString() ) && stringsMatch( unitsOut, barUnitString() ) )
{
*valuesOut = multiply( valuesIn, 100 );
*valuesOut = multiply( valuesIn, (FloatType)100 );
return true;
}
else if ( stringsMatch( unitsIn, barUnitString() ) && stringsMatch( unitsOut, MPaUnitString() ) )
@@ -178,7 +215,7 @@ bool RiaWellLogUnitTools::convertValues( const std::vector<double>& tvdRKBs,
}
else if ( stringsMatch( unitsIn, barUnitString() ) && stringsMatch( unitsOut, barX100UnitString() ) )
{
*valuesOut = multiply( valuesIn, 1.0 / 100.0 );
*valuesOut = multiply( valuesIn, (FloatType) 0.01 );
return true;
}
else if ( ( stringsMatch( unitsIn, noUnitString() ) || stringsMatch( unitsIn, sg_emwUnitString() ) ) &&
@@ -193,12 +230,12 @@ bool RiaWellLogUnitTools::convertValues( const std::vector<double>& tvdRKBs,
*valuesOut = convertBarToNormalizedByPP( tvdRKBs, valuesIn );
return true;
}
else if ( stringsMatch( unitsIn, pascalUnitString() ) && stringsMatch( unitsOut, barUnitString() ) )
else if ( (stringsMatch( unitsIn, pascalUnitString()) || stringsMatch( unitsIn, pascalUnitString() ) && stringsMatch( unitsOut, barUnitString() ) ))
{
*valuesOut = multiply( valuesIn, 1.0 / pascalPerBar() );
return true;
}
else if ( stringsMatch( unitsIn, barUnitString() ) && stringsMatch( unitsOut, pascalUnitString() ) )
else if ( stringsMatch( unitsIn, barUnitString() ) && (stringsMatch( unitsIn, pascalUnitString()) || stringsMatch( unitsIn, pascalUnitString() )) )
{
*valuesOut = multiply( valuesIn, pascalPerBar() );
return true;
@@ -209,7 +246,8 @@ bool RiaWellLogUnitTools::convertValues( const std::vector<double>& tvdRKBs,
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiaWellLogUnitTools::convertValues( std::vector<std::pair<double, double>>* measuredDepthsAndValues,
template <typename FloatType>
bool RiaWellLogUnitTools<FloatType>::convertValues( std::vector<std::pair<FloatType, FloatType>>* measuredDepthsAndValues,
const QString& unitsIn,
const QString& unitsOut,
const RigWellPath* wellPath )
@@ -217,8 +255,8 @@ bool RiaWellLogUnitTools::convertValues( std::vector<std::pair<double, double>>*
CAF_ASSERT( measuredDepthsAndValues );
if ( unitsIn == unitsOut ) return true;
std::vector<double> tvdRKBs( measuredDepthsAndValues->size(), 0.0 );
std::vector<double> values( measuredDepthsAndValues->size(), 0.0 );
std::vector<FloatType> tvdRKBs( measuredDepthsAndValues->size(), 0.0 );
std::vector<FloatType> values( measuredDepthsAndValues->size(), 0.0 );
for ( size_t i = 0; i < measuredDepthsAndValues->size(); ++i )
{
auto depthValuePair = ( *measuredDepthsAndValues )[i];
@@ -227,7 +265,7 @@ bool RiaWellLogUnitTools::convertValues( std::vector<std::pair<double, double>>*
tvdRKBs[i] = -point.z() + wellPath->rkbDiff();
values[i] = depthValuePair.second;
}
std::vector<double> valuesOut;
std::vector<FloatType> valuesOut;
if ( convertValues( tvdRKBs, values, &valuesOut, unitsIn, unitsOut ) )
{
CAF_ASSERT( measuredDepthsAndValues->size() == valuesOut.size() );
@@ -243,7 +281,8 @@ bool RiaWellLogUnitTools::convertValues( std::vector<std::pair<double, double>>*
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<double> RiaWellLogUnitTools::tvdRKBs( const std::vector<double>& measuredDepths, const RigWellPath* wellPath )
template <typename FloatType>
std::vector<FloatType> RiaWellLogUnitTools<FloatType>::tvdRKBs( const std::vector<FloatType>& measuredDepths, const RigWellPath* wellPath )
{
std::vector<double> tvdRKBs( measuredDepths.size(), 0.0 );
for ( size_t i = 0; i < measuredDepths.size(); ++i )
@@ -251,28 +290,29 @@ std::vector<double> RiaWellLogUnitTools::tvdRKBs( const std::vector<double>& mea
cvf::Vec3d point = wellPath->interpolatedPointAlongWellPath( measuredDepths[i] );
tvdRKBs[i] = -point.z() + wellPath->rkbDiff();
}
return tvdRKBs;
return std::vector<FloatType>(tvdRKBs.begin(), tvdRKBs.end());
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<double> RiaWellLogUnitTools::convertGpcm3ToBar( const std::vector<double>& tvdRKBs,
const std::vector<double>& valuesInGpcm3 )
template <typename FloatType>
std::vector<FloatType> RiaWellLogUnitTools<FloatType>::convertGpcm3ToBar( const std::vector<FloatType>& tvdRKBs,
const std::vector<FloatType>& valuesInGpcm3 )
{
CAF_ASSERT( tvdRKBs.size() == valuesInGpcm3.size() );
std::vector<double> valuesInBar( valuesInGpcm3.size(), 0.0 );
std::vector<FloatType> valuesInBar( valuesInGpcm3.size(), 0.0 );
for ( size_t i = 0; i < tvdRKBs.size(); ++i )
{
// We need SI as input (kg / m^3), so multiply by 1000:
double mudWeightsSI = valuesInGpcm3[i] * 1000;
FloatType mudWeightsSI = valuesInGpcm3[i] * 1000;
// To get specific mudWeight (N / m^3):
double specificMudWeight = mudWeightsSI * GRAVITY_ACCEL;
FloatType specificMudWeight = mudWeightsSI * gravityAcceleration();
// Pore pressure in pascal
double valuePascal = specificMudWeight * tvdRKBs[i];
FloatType valuePascal = specificMudWeight * tvdRKBs[i];
// Pore pressure in bar
valuesInBar[i] = 1.0 / pascalPerBar() * valuePascal;
@@ -283,22 +323,23 @@ std::vector<double> RiaWellLogUnitTools::convertGpcm3ToBar( const std::vector<do
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<double> RiaWellLogUnitTools::convertBarToGpcm3( const std::vector<double>& tvdRKBs,
const std::vector<double>& valuesInBar )
template <typename FloatType>
std::vector<FloatType> RiaWellLogUnitTools<FloatType>::convertBarToGpcm3( const std::vector<FloatType>& tvdRKBs,
const std::vector<FloatType>& valuesInBar )
{
CAF_ASSERT( tvdRKBs.size() == valuesInBar.size() );
std::vector<double> valuesInGpcm3( valuesInBar.size(), 0.0 );
std::vector<FloatType> valuesInGpcm3( valuesInBar.size(), 0.0 );
for ( size_t i = 0; i < tvdRKBs.size(); ++i )
{
// Pore pressure in pascal (N / m^2)
double valuePascal = pascalPerBar() * valuesInBar[i];
FloatType valuePascal = pascalPerBar() * valuesInBar[i];
// N / m^3:
double specificMudWeight = valuePascal / tvdRKBs[i];
FloatType specificMudWeight = valuePascal / tvdRKBs[i];
// Mud weight in SI (kg / m^3):
double mudWeightsSI = specificMudWeight / GRAVITY_ACCEL;
FloatType mudWeightsSI = specificMudWeight / gravityAcceleration();
// Mud weights g/cm^3:
valuesInGpcm3[i] = mudWeightsSI / 1000;
@@ -309,12 +350,13 @@ std::vector<double> RiaWellLogUnitTools::convertBarToGpcm3( const std::vector<do
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<double> RiaWellLogUnitTools::convertNormalizedByPPToBar( const std::vector<double>& tvdRKBs,
const std::vector<double>& normalizedValues )
template<typename FloatType>
std::vector<FloatType> RiaWellLogUnitTools<FloatType>::convertNormalizedByPPToBar( const std::vector<FloatType>& tvdRKBs,
const std::vector<FloatType>& normalizedValues )
{
CAF_ASSERT( tvdRKBs.size() == normalizedValues.size() );
std::vector<double> valuesInBar( tvdRKBs.size(), 0.0 );
std::vector<FloatType> valuesInBar( tvdRKBs.size(), 0.0 );
for ( size_t i = 0; i < tvdRKBs.size(); ++i )
{
valuesInBar[i] = normalizedValues[i] * hydrostaticPorePressureBar( tvdRKBs[i] );
@@ -325,12 +367,13 @@ std::vector<double> RiaWellLogUnitTools::convertNormalizedByPPToBar( const std::
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<double> RiaWellLogUnitTools::convertBarToNormalizedByPP( const std::vector<double>& tvdRKBs,
const std::vector<double>& valuesInBar )
template <typename FloatType>
std::vector<FloatType> RiaWellLogUnitTools<FloatType>::convertBarToNormalizedByPP( const std::vector<FloatType>& tvdRKBs,
const std::vector<FloatType>& valuesInBar )
{
CAF_ASSERT( tvdRKBs.size() == valuesInBar.size() );
std::vector<double> normalizedValues( tvdRKBs.size(), 0.0 );
std::vector<FloatType> normalizedValues( tvdRKBs.size(), 0.0 );
for ( size_t i = 0; i < tvdRKBs.size(); ++i )
{
normalizedValues[i] = valuesInBar[i] / hydrostaticPorePressureBar( tvdRKBs[i] );
@@ -341,9 +384,10 @@ std::vector<double> RiaWellLogUnitTools::convertBarToNormalizedByPP( const std::
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<double> RiaWellLogUnitTools::multiply( const std::vector<double>& valuesIn, double factor )
template <typename FloatType>
std::vector<FloatType> RiaWellLogUnitTools<FloatType>::multiply( const std::vector<FloatType>& valuesIn, FloatType factor )
{
std::vector<double> valuesOut( valuesIn.size(), std::numeric_limits<double>::infinity() );
std::vector<FloatType> valuesOut( valuesIn.size(), std::numeric_limits<FloatType>::infinity() );
for ( size_t i = 0; i < valuesIn.size(); ++i )
{
valuesOut[i] = valuesIn[i] * factor;
@@ -354,7 +398,8 @@ std::vector<double> RiaWellLogUnitTools::multiply( const std::vector<double>& va
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RiaWellLogUnitTools::pascalPerBar()
template <typename FloatType>
FloatType RiaWellLogUnitTools<FloatType>::pascalPerBar()
{
return 1.0e5;
}
@@ -362,15 +407,17 @@ double RiaWellLogUnitTools::pascalPerBar()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RiaWellLogUnitTools::MPaPerBar()
template <typename FloatType>
FloatType RiaWellLogUnitTools<FloatType>::MPaPerBar()
{
return 1.0e-1;
return (FloatType) 1.0e-1;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RiaWellLogUnitTools::hydrostaticPorePressureBar( double depth )
template <typename FloatType>
FloatType RiaWellLogUnitTools<FloatType>::hydrostaticPorePressureBar( FloatType depth )
{
return 1.0 / pascalPerBar() * depth * UNIT_WEIGHT_OF_WATER;
return (FloatType) 1.0 / pascalPerBar() * depth * unitWeightOfWater();
}