#6888 Fix assert when MD gives anchor position outside of active cells bounding box.

This commit is contained in:
Kristian Bendiksen 2020-11-02 19:13:56 +01:00
parent 1f748e3c39
commit be8b54046e
5 changed files with 44 additions and 17 deletions

View File

@ -243,8 +243,6 @@ RimFractureModel::~RimFractureModel()
if ( wellPath && wellPathCollection )
{
wellPathCollection->removeWellPath( wellPath );
delete wellPath;
wellPathCollection->uiCapability()->updateConnectedEditors();
wellPathCollection->scheduleRedrawAffectedViews();
}
@ -502,24 +500,29 @@ void RimFractureModel::updateThicknessDirection()
if ( m_thicknessDirectionWellPath )
{
RimWellPathGeometryDef* wellGeomDef = m_thicknessDirectionWellPath->geometryDefinition();
wellGeomDef->deleteAllTargets();
// Disable auto-generated target at sea level: this will usually be outside the
// bounding box, and will introduce problems when the project is reloaded.
wellGeomDef->setUseAutoGeneratedTargetAtSeaLevel( false );
cvf::Vec3d topPosition;
cvf::Vec3d bottomPosition;
findThicknessTargetPoints( topPosition, bottomPosition );
topPosition.z() *= -1.0;
bottomPosition.z() *= -1.0;
if ( findThicknessTargetPoints( topPosition, bottomPosition ) )
{
topPosition.z() *= -1.0;
bottomPosition.z() *= -1.0;
RimWellPathGeometryDef* wellGeomDef = m_thicknessDirectionWellPath->geometryDefinition();
wellGeomDef->deleteAllTargets();
RimWellPathTarget* topPathTarget = new RimWellPathTarget();
topPathTarget->setAsPointTargetXYD( topPosition );
RimWellPathTarget* topPathTarget = new RimWellPathTarget();
RimWellPathTarget* bottomPathTarget = new RimWellPathTarget();
bottomPathTarget->setAsPointTargetXYD( bottomPosition );
topPathTarget->setAsPointTargetXYD( topPosition );
RimWellPathTarget* bottomPathTarget = new RimWellPathTarget();
bottomPathTarget->setAsPointTargetXYD( bottomPosition );
wellGeomDef->insertTarget( nullptr, topPathTarget );
wellGeomDef->insertTarget( nullptr, bottomPathTarget );
wellGeomDef->insertTarget( nullptr, topPathTarget );
wellGeomDef->insertTarget( nullptr, bottomPathTarget );
}
wellGeomDef->updateConnectedEditors();
wellGeomDef->updateWellPathVisualization();
@ -951,10 +954,10 @@ QString RimFractureModel::vecToString( const cvf::Vec3d& vec )
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimFractureModel::findThicknessTargetPoints( cvf::Vec3d& topPosition, cvf::Vec3d& bottomPosition )
bool RimFractureModel::findThicknessTargetPoints( cvf::Vec3d& topPosition, cvf::Vec3d& bottomPosition )
{
RigEclipseCaseData* eclipseCaseData = getEclipseCaseData();
if ( !eclipseCaseData ) return;
if ( !eclipseCaseData ) return false;
const cvf::Vec3d& position = anchorPosition();
const cvf::Vec3d& direction = thicknessDirection();
@ -970,6 +973,13 @@ void RimFractureModel::findThicknessTargetPoints( cvf::Vec3d& topPosition, cvf::
RiaLogging::info( QString( "Position: %1" ).arg( RimFractureModel::vecToString( position ) ) );
RiaLogging::info( QString( "Direction: %1" ).arg( RimFractureModel::vecToString( direction ) ) );
if ( !geometryBoundingBox.contains( position ) )
{
//
RiaLogging::error( "Anchor position is outside the grid bounding box. Unable to compute direction." );
return false;
}
// Create plane on top and bottom of formation
cvf::Plane topPlane;
topPlane.setFromPointAndNormal( geometryBoundingBox.max(), cvf::Vec3d::Z_AXIS );
@ -985,6 +995,8 @@ void RimFractureModel::findThicknessTargetPoints( cvf::Vec3d& topPosition, cvf::
cvf::Vec3d belowPlane = position + ( direction * 10000.0 );
bottomPlane.intersect( position, belowPlane, &bottomPosition );
RiaLogging::info( QString( "Bottom: %1" ).arg( RimFractureModel::vecToString( bottomPosition ) ) );
return true;
}
//--------------------------------------------------------------------------------------------------

View File

@ -190,7 +190,7 @@ private:
void updateThicknessDirection();
void updateDistanceToBarrierAndDip();
cvf::Vec3d calculateTSTDirection() const;
void findThicknessTargetPoints( cvf::Vec3d& topPosition, cvf::Vec3d& bottomPosition );
bool findThicknessTargetPoints( cvf::Vec3d& topPosition, cvf::Vec3d& bottomPosition );
static double calculateFormationDip( const cvf::Vec3d& direction );
static QString vecToString( const cvf::Vec3d& vec );

View File

@ -119,6 +119,11 @@ bool RimFractureModelStressCalculator::calculate( RiaDefines::CurveProperty curv
// Generate MD data by interpolation
const std::vector<double>& mdValuesOfWellPath = wellPathGeometry->measuredDepths();
std::vector<double> tvdValuesOfWellPath = wellPathGeometry->trueVerticalDepths();
if ( mdValuesOfWellPath.empty() )
{
RiaLogging::error( "Well path geometry had no MD values." );
return false;
}
measuredDepthValues =
RigWellPathGeometryTools::interpolateMdFromTvd( mdValuesOfWellPath, tvdValuesOfWellPath, tvDepthValues );

View File

@ -584,3 +584,11 @@ void RimWellPathGeometryDef::initAfterRead()
m_useAutoGeneratedTargetAtSeaLevel = false;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellPathGeometryDef::setUseAutoGeneratedTargetAtSeaLevel( bool autoGenerate )
{
m_useAutoGeneratedTargetAtSeaLevel = autoGenerate;
}

View File

@ -68,6 +68,8 @@ public:
void enableTargetPointPicking( bool isEnabling );
void setUseAutoGeneratedTargetAtSeaLevel( bool autoGenerate );
std::vector<RiaWellPlanCalculator::WellPlanSegment> wellPlan() const;
std::vector<RimWellPathTarget*> activeWellTargets() const;