#7158 Add option to introduce extra well path point at sea level.

This commit is contained in:
Kristian Bendiksen 2021-01-19 10:15:00 +01:00
parent a01c511308
commit 1d0705de46
2 changed files with 80 additions and 0 deletions

View File

@ -1,8 +1,12 @@
#include "RimFileWellPath.h"
#include "RicfCommandObject.h"
#include "RifWellPathImporter.h"
#include "RimProject.h"
#include "RimTools.h"
#include "cafUtils.h"
#include "QDir"
@ -48,6 +52,14 @@ RimFileWellPath::RimFileWellPath()
CAF_PDM_InitField( &m_wellPathIndexInFile, "WellPathNumberInFile", -1, "Well Number in File", "", "", "" );
m_wellPathIndexInFile.uiCapability()->setUiReadOnly( true );
CAF_PDM_InitField( &m_useAutoGeneratedPointAtSeaLevel,
"UseAutoGeneratedPointAtSeaLevel",
false,
"Generate Point at Sea Level",
"",
"",
"" );
}
//--------------------------------------------------------------------------------------------------
@ -115,6 +127,8 @@ void RimFileWellPath::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering
{
RimWellPath::defineUiOrdering( uiConfigName, uiOrdering );
uiOrdering.add( &m_useAutoGeneratedPointAtSeaLevel );
caf::PdmUiGroup* fileInfoGroup = uiOrdering.createGroupBeforeGroup( "Simulation Well", "File" );
if ( isStoredInCache() )
@ -166,6 +180,11 @@ bool RimFileWellPath::readWellPathFile( QString* errorMessage, RifWellPathImport
setSurveyType( wellMetaData.m_surveyType );
updateDate = wellMetaData.m_updateDate.toString( "d MMMM yyyy" );
if ( m_useAutoGeneratedPointAtSeaLevel )
{
ensureWellPathStartAtSeaLevel( wellData.m_wellPathGeometry.p() );
}
setWellPathGeometry( wellData.m_wellPathGeometry.p() );
// Now that the data is read, we know if this is an SSIHUB wellpath that needs to be stored in the
@ -275,3 +294,58 @@ void RimFileWellPath::updateFilePathsFromProjectPath( const QString& newProjectP
m_filePathInCache = newCacheFileName;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimFileWellPath::ensureWellPathStartAtSeaLevel( RigWellPath* wellPath )
{
std::vector<cvf::Vec3d> wellPathPoints = wellPath->wellPathPoints();
std::vector<double> measuredDepths = wellPath->measuredDepths();
if ( wellPathPoints.empty() || measuredDepths.empty() || wellPathPoints.size() != measuredDepths.size() ) return;
cvf::Vec3d firstPoint = wellPathPoints[0];
const double epsilon = 1e-3;
bool firstPointAtSeaLevel = std::abs( firstPoint.z() ) < epsilon;
if ( !firstPointAtSeaLevel )
{
// Insert a new point on sea level straight above the
// first point in the read well path.
std::vector<cvf::Vec3d> newPoints = { cvf::Vec3d( firstPoint.x(), firstPoint.y(), 0.0 ) };
newPoints.insert( newPoints.end(), wellPathPoints.begin(), wellPathPoints.end() );
wellPath->setWellPathPoints( newPoints );
// Give the new point zero measured depth.
std::vector<double> newMeasuredDepths = { 0.0 };
// And adjust measured depths of the read data
// with the diff between the old and new first point.
double diffMd = std::abs( newPoints[1].z() - newPoints[0].z() );
for ( double originalMd : measuredDepths )
{
newMeasuredDepths.push_back( originalMd + diffMd );
}
wellPath->setMeasuredDepths( newMeasuredDepths );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimFileWellPath::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
const QVariant& oldValue,
const QVariant& newValue )
{
RimWellPath::fieldChangedByUi( changedField, oldValue, newValue );
if ( changedField == &m_useAutoGeneratedPointAtSeaLevel )
{
RifWellPathImporter wellPathImporter;
QString errorMessage;
if ( readWellPathFile( &errorMessage, &wellPathImporter, false ) )
{
RimProject::current()->scheduleCreateDisplayModelAndRedrawAllViews();
}
}
}

View File

@ -34,6 +34,9 @@ public:
void updateFilePathsFromProjectPath( const QString& newProjectPath, const QString& oldProjectPath ) override;
static QString getCacheDirectoryPath();
protected:
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
private:
QString surveyType() { return m_surveyType; }
void setSurveyType( QString surveyType );
@ -42,6 +45,8 @@ private:
void setupBeforeSave() override;
void ensureWellPathStartAtSeaLevel( RigWellPath* wellPath );
caf::PdmField<caf::FilePath> m_filePath;
caf::PdmField<QString> m_filePathInCache; // Used for SSIHUB imported well paths
caf::PdmField<int> m_wellPathIndexInFile; // -1 means none.
@ -52,6 +57,7 @@ private:
caf::PdmField<QString> updateDate;
caf::PdmField<QString> updateUser;
caf::PdmField<QString> m_surveyType;
caf::PdmField<bool> m_useAutoGeneratedPointAtSeaLevel;
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
};