Improve MSW export including multi lateral wells

Based on branch https://github.com/OPM/ResInsight/tree/system-msw-refactor

- Move completion settings to property of well path
- Rename to RimFishbones
- Export implicit COMPSEGS for fishbones main bore
- Add valve for each branch
- Increase version number to be able to handle import of legacy project files
This commit is contained in:
Magne Sjaastad
2021-02-26 14:27:59 +01:00
parent 5415a8c42d
commit 8bab748fa6
104 changed files with 3250 additions and 3203 deletions

View File

@@ -22,7 +22,6 @@
#include "RicWellTarget3dEditor.h"
#include "RimWellPathGeometryDef.h"
#include "RimWellPathLateralGeometryDef.h"
#include "RimWellPathTarget.h"
#include "cafPickEventHandler.h"
@@ -56,7 +55,7 @@ RicWellPathGeometry3dEditor::~RicWellPathGeometry3dEditor()
//--------------------------------------------------------------------------------------------------
void RicWellPathGeometry3dEditor::configureAndUpdateUi( const QString& uiConfigName )
{
RimWellPathGeometryDefInterface* geomDef = dynamic_cast<RimWellPathGeometryDefInterface*>( this->pdmObject() );
RimWellPathGeometryDef* geomDef = dynamic_cast<RimWellPathGeometryDef*>( this->pdmObject() );
for ( auto targetEditor : m_targetEditors )
{

View File

@@ -24,7 +24,6 @@
#include "RimCase.h"
#include "RimModeledWellPath.h"
#include "RimWellPathGeometryDef.h"
#include "RimWellPathLateralGeometryDef.h"
#include "RimWellPathTarget.h"
#include "RiuViewer.h"
@@ -86,7 +85,7 @@ void RicWellTarget3dEditor::configureAndUpdateUi( const QString& uiConfigName )
return;
}
RimWellPathGeometryDefInterface* geomDef;
RimWellPathGeometryDef* geomDef;
target->firstAncestorOrThisOfTypeAsserted( geomDef );
target->m_targetType.uiCapability()->addFieldEditor( this );
@@ -153,7 +152,7 @@ void RicWellTarget3dEditor::slotUpdated( const cvf::Vec3d& origin, const cvf::Ve
cvf::ref<caf::DisplayCoordTransform> dispXf = view->displayCoordTransform();
RimWellPathGeometryDefInterface* geomDef;
RimWellPathGeometryDef* geomDef;
target->firstAncestorOrThisOfTypeAsserted( geomDef );
cvf::Vec3d domainOrigin = dispXf->transformToDomainCoord( origin ) - geomDef->anchorPointXyz();

View File

@@ -34,7 +34,6 @@
#include "RimModeledWellPath.h"
#include "RimWellPath.h"
#include "RimWellPathGeometryDef.h"
#include "RimWellPathLateralGeometryDef.h"
#include "RimWellPathTarget.h"
#include "RiuViewerCommands.h"
@@ -56,8 +55,7 @@
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicCreateWellTargetsPickEventHandler::RicCreateWellTargetsPickEventHandler(
gsl::not_null<RimWellPathGeometryDefInterface*> wellGeometryDef )
RicCreateWellTargetsPickEventHandler::RicCreateWellTargetsPickEventHandler( gsl::not_null<RimWellPathGeometryDef*> wellGeometryDef )
: m_geometryToAddTargetsTo( wellGeometryDef )
{
}
@@ -97,55 +95,94 @@ bool RicCreateWellTargetsPickEventHandler::handle3dPickEvent( const Ric3dPickEve
cvf::Vec3d targetPointInDomain = cvf::Vec3d::ZERO;
// If clicked on an other well path, snap target point to well path center line
auto firstPickItem = eventObject.m_pickItemInfos.front();
auto firstPickItem = eventObject.m_pickItemInfos.front();
auto wellPathSourceInfo = dynamic_cast<const RivWellPathSourceInfo*>( firstPickItem.sourceInfo() );
auto intersectionPointInDomain =
rimView->displayCoordTransform()->transformToDomainCoord( firstPickItem.globalPickedPoint() );
bool doSetAzimuthAndInclination = false;
double azimuth = 0.0;
double inclination = 0.0;
double azimuth = std::numeric_limits<double>::infinity();
double inclination = std::numeric_limits<double>::infinity();
auto wellPathSourceInfo = dynamic_cast<const RivWellPathSourceInfo*>( firstPickItem.sourceInfo() );
if ( isValidWellPathSourceObject( wellPathSourceInfo ) )
if ( wellPathSourceInfo && wellPathSourceInfo->wellPath() && wellPathSourceInfo->wellPath()->wellPathGeometry() )
{
calculateWellPathGeometryAtPickPoint( firstPickItem,
wellPathSourceInfo,
intersectionPointInDomain,
&targetPointInDomain,
&azimuth,
&inclination );
auto wellPathGeometry = wellPathSourceInfo->wellPath()->wellPathGeometry();
targetPointInDomain =
wellPathSourceInfo->closestPointOnCenterLine( firstPickItem.faceIdx(), intersectionPointInDomain );
double md = wellPathSourceInfo->measuredDepth( firstPickItem.faceIdx(), intersectionPointInDomain );
doSetAzimuthAndInclination = calculateAzimuthAndInclinationAtMd( md, wellPathGeometry, &azimuth, &inclination );
double rkbDiff = wellPathGeometry->rkbDiff();
if ( m_geometryToAddTargetsTo->airGap() == 0.0 && rkbDiff != std::numeric_limits<double>::infinity() )
{
m_geometryToAddTargetsTo->setAirGap( rkbDiff );
}
}
else if ( isGridSourceObject( firstPickItem.sourceInfo() ) )
{
targetPointInDomain = calculateGridPickPoint( rimView, firstPickItem, intersectionPointInDomain );
targetPointInDomain = intersectionPointInDomain;
doSetAzimuthAndInclination = false;
cvf::Vec3d domainRayOrigin =
rimView->displayCoordTransform()->transformToDomainCoord( firstPickItem.globalRayOrigin() );
cvf::Vec3d domainRayEnd = targetPointInDomain + ( targetPointInDomain - domainRayOrigin );
cvf::Vec3d hexElementIntersection =
findHexElementIntersection( rimView, firstPickItem, domainRayOrigin, domainRayEnd );
CVF_TIGHT_ASSERT( !hexElementIntersection.isUndefined() );
if ( !hexElementIntersection.isUndefined() )
{
targetPointInDomain = hexElementIntersection;
}
}
else
{
targetPointInDomain = intersectionPointInDomain;
targetPointInDomain = intersectionPointInDomain;
doSetAzimuthAndInclination = false;
}
if ( auto wellPathGeometryDef = dynamic_cast<RimWellPathGeometryDef*>( m_geometryToAddTargetsTo.p() );
wellPathGeometryDef )
if ( !m_geometryToAddTargetsTo->firstActiveTarget() )
{
addNewTargetToModeledWellPath( firstPickItem,
wellPathGeometryDef,
intersectionPointInDomain,
targetPointInDomain,
azimuth,
inclination );
m_geometryToAddTargetsTo->setReferencePointXyz( targetPointInDomain );
if ( wellPathSourceInfo )
{
double mdAtFirstTarget =
wellPathSourceInfo->measuredDepth( firstPickItem.faceIdx(), intersectionPointInDomain );
RimModeledWellPath* modeledWellPath = dynamic_cast<RimModeledWellPath*>( wellPathSourceInfo->wellPath() );
if ( modeledWellPath )
{
mdAtFirstTarget += modeledWellPath->geometryDefinition()->mdAtFirstTarget();
}
m_geometryToAddTargetsTo->setMdAtFirstTarget( mdAtFirstTarget );
}
}
else if ( auto wellPathLateralGeometryDef =
dynamic_cast<RimWellPathLateralGeometryDef*>( m_geometryToAddTargetsTo.p() );
wellPathLateralGeometryDef )
cvf::Vec3d referencePoint = m_geometryToAddTargetsTo->anchorPointXyz();
cvf::Vec3d relativeTagetPoint = targetPointInDomain - referencePoint;
RimWellPathTarget* newTarget = new RimWellPathTarget;
if ( doSetAzimuthAndInclination )
{
addNewTargetToModeledWellPathLateral( firstPickItem,
wellPathLateralGeometryDef,
intersectionPointInDomain,
targetPointInDomain,
azimuth,
inclination );
newTarget->setAsPointXYZAndTangentTarget( cvf::Vec3d( relativeTagetPoint.x(),
relativeTagetPoint.y(),
relativeTagetPoint.z() ),
azimuth,
inclination );
}
else
{
newTarget->setAsPointTargetXYD(
cvf::Vec3d( relativeTagetPoint.x(), relativeTagetPoint.y(), -relativeTagetPoint.z() ) );
}
m_geometryToAddTargetsTo->insertTarget( nullptr, newTarget );
m_geometryToAddTargetsTo->updateConnectedEditors();
m_geometryToAddTargetsTo->updateWellPathVisualization( true );
return true; // Todo: See if we really should eat the event instead
}
@@ -206,155 +243,6 @@ bool RicCreateWellTargetsPickEventHandler::calculateAzimuthAndInclinationAtMd( d
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicCreateWellTargetsPickEventHandler::calculateWellPathGeometryAtPickPoint(
const RiuPickItemInfo& pickItem,
gsl::not_null<const RivWellPathSourceInfo*> wellPathSourceInfo,
const cvf::Vec3d& intersectionPointInDomain,
gsl::not_null<cvf::Vec3d*> targetPointInDomain,
gsl::not_null<double*> azimuth,
gsl::not_null<double*> inclination ) const
{
*targetPointInDomain = wellPathSourceInfo->closestPointOnCenterLine( pickItem.faceIdx(), intersectionPointInDomain );
bool doSetAzimuthAndInclination = false;
auto wellPathGeometry = wellPathSourceInfo->wellPath()->wellPathGeometry();
if ( wellPathGeometry )
{
double md = wellPathSourceInfo->measuredDepth( pickItem.faceIdx(), intersectionPointInDomain );
doSetAzimuthAndInclination = calculateAzimuthAndInclinationAtMd( md, wellPathGeometry, azimuth, inclination );
double rkbDiff = wellPathGeometry->rkbDiff();
auto wellPathGeometryDef = dynamic_cast<RimWellPathGeometryDef*>( m_geometryToAddTargetsTo.p() );
if ( wellPathGeometryDef && wellPathGeometryDef->airGap() == 0.0 &&
rkbDiff != std::numeric_limits<double>::infinity() )
{
wellPathGeometryDef->setAirGap( rkbDiff );
}
}
return doSetAzimuthAndInclination;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::Vec3d RicCreateWellTargetsPickEventHandler::calculateGridPickPoint( gsl::not_null<const Rim3dView*> rimView,
const RiuPickItemInfo& pickItem,
const cvf::Vec3d& intersectionPointInDomain ) const
{
auto targetPointInDomain = intersectionPointInDomain;
cvf::Vec3d domainRayOrigin = rimView->displayCoordTransform()->transformToDomainCoord( pickItem.globalRayOrigin() );
cvf::Vec3d domainRayEnd = targetPointInDomain + ( targetPointInDomain - domainRayOrigin );
cvf::Vec3d hexElementIntersection = findHexElementIntersection( rimView, pickItem, domainRayOrigin, domainRayEnd );
CVF_TIGHT_ASSERT( !hexElementIntersection.isUndefined() );
if ( !hexElementIntersection.isUndefined() )
{
targetPointInDomain = hexElementIntersection;
}
return targetPointInDomain;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicCreateWellTargetsPickEventHandler::addNewTargetToModeledWellPath( const RiuPickItemInfo& pickItem,
gsl::not_null<RimWellPathGeometryDef*> wellPathGeometryDef,
const cvf::Vec3d& intersectionPointInDomain,
const cvf::Vec3d& targetPointInDomain,
double azimuth,
double inclination )
{
if ( !m_geometryToAddTargetsTo->firstActiveTarget() )
{
wellPathGeometryDef->setReferencePointXyz( targetPointInDomain );
auto wellPathSourceInfo = dynamic_cast<const RivWellPathSourceInfo*>( pickItem.sourceInfo() );
if ( wellPathSourceInfo )
{
double mdAtFirstTarget = wellPathSourceInfo->measuredDepth( pickItem.faceIdx(), intersectionPointInDomain );
RimModeledWellPath* modeledWellPath = dynamic_cast<RimModeledWellPath*>( wellPathSourceInfo->wellPath() );
if ( modeledWellPath )
{
mdAtFirstTarget += modeledWellPath->geometryDefinition()->mdAtFirstTarget();
}
wellPathGeometryDef->setMdAtFirstTarget( mdAtFirstTarget );
}
}
cvf::Vec3d referencePoint = wellPathGeometryDef->anchorPointXyz();
cvf::Vec3d relativeTargetPoint = targetPointInDomain - referencePoint;
RimWellPathTarget* newTarget = new RimWellPathTarget;
bool doSetAzimuthAndInclination = azimuth != std::numeric_limits<double>::infinity() &&
inclination != std::numeric_limits<double>::infinity();
if ( doSetAzimuthAndInclination )
{
newTarget->setAsPointXYZAndTangentTarget( relativeTargetPoint, azimuth, inclination );
}
else
{
newTarget->setAsPointTargetXYD(
cvf::Vec3d( relativeTargetPoint.x(), relativeTargetPoint.y(), -relativeTargetPoint.z() ) );
}
m_geometryToAddTargetsTo->insertTarget( nullptr, newTarget );
m_geometryToAddTargetsTo->updateConnectedEditors();
m_geometryToAddTargetsTo->updateWellPathVisualization( false );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicCreateWellTargetsPickEventHandler::addNewTargetToModeledWellPathLateral(
const RiuPickItemInfo& pickItem,
gsl::not_null<RimWellPathLateralGeometryDef*> wellPathLateralGeometryDef,
const cvf::Vec3d& intersectionPointInDomain,
const cvf::Vec3d& targetPointInDomain,
double azimuth,
double inclination )
{
auto wellPathSourceInfo = dynamic_cast<const RivWellPathSourceInfo*>( pickItem.sourceInfo() );
if ( wellPathSourceInfo )
{
double mdAtConnection = wellPathSourceInfo->measuredDepth( pickItem.faceIdx(), intersectionPointInDomain );
wellPathLateralGeometryDef->setParentGeometry( wellPathSourceInfo->wellPath()->wellPathGeometry() );
wellPathLateralGeometryDef->setMdAtConnection( mdAtConnection );
}
cvf::Vec3d referencePoint = wellPathLateralGeometryDef->anchorPointXyz();
cvf::Vec3d relativeTargetPoint = targetPointInDomain - referencePoint;
RimWellPathTarget* newTarget = new RimWellPathTarget;
bool doSetAzimuthAndInclination = azimuth != std::numeric_limits<double>::infinity() &&
inclination != std::numeric_limits<double>::infinity();
if ( doSetAzimuthAndInclination )
{
newTarget->setAsPointXYZAndTangentTarget( cvf::Vec3d( relativeTargetPoint.x(),
relativeTargetPoint.y(),
relativeTargetPoint.z() ),
azimuth,
inclination );
}
else
{
newTarget->setAsPointTargetXYD(
cvf::Vec3d( relativeTargetPoint.x(), relativeTargetPoint.y(), -relativeTargetPoint.z() ) );
}
m_geometryToAddTargetsTo->insertTarget( nullptr, newTarget );
m_geometryToAddTargetsTo->updateConnectedEditors();
m_geometryToAddTargetsTo->updateWellPathVisualization( false );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -368,18 +256,10 @@ bool RicCreateWellTargetsPickEventHandler::isGridSourceObject( const cvf::Object
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicCreateWellTargetsPickEventHandler::isValidWellPathSourceObject( const RivWellPathSourceInfo* wellPathSourceInfo )
{
return wellPathSourceInfo && wellPathSourceInfo->wellPath() && wellPathSourceInfo->wellPath()->wellPathGeometry();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::Vec3d RicCreateWellTargetsPickEventHandler::findHexElementIntersection( gsl::not_null<const Rim3dView*> view,
const RiuPickItemInfo& pickItem,
const cvf::Vec3d& domainRayOrigin,
const cvf::Vec3d& domainRayEnd )
cvf::Vec3d RicCreateWellTargetsPickEventHandler::findHexElementIntersection( gsl::not_null<Rim3dView*> view,
const RiuPickItemInfo& pickItem,
const cvf::Vec3d& domainRayOrigin,
const cvf::Vec3d& domainRayEnd )
{
auto sourceInfo = dynamic_cast<const RivSourceInfo*>( pickItem.sourceInfo() );
auto femSourceInfo = dynamic_cast<const RivFemPickSourceInfo*>( pickItem.sourceInfo() );
@@ -393,7 +273,7 @@ cvf::Vec3d RicCreateWellTargetsPickEventHandler::findHexElementIntersection( gsl
{
cellIndex = sourceInfo->m_cellFaceFromTriangleMapper->cellIndex( pickItem.faceIdx() );
const RimEclipseView* eclipseView = dynamic_cast<const RimEclipseView*>( view.get() );
RimEclipseView* eclipseView = dynamic_cast<RimEclipseView*>( view.get() );
if ( eclipseView && eclipseView->mainGrid() )
{
RigGridBase* hitGrid = eclipseView->mainGrid()->gridByIndex( gridIndex );
@@ -408,11 +288,11 @@ cvf::Vec3d RicCreateWellTargetsPickEventHandler::findHexElementIntersection( gsl
{
size_t elementIndex = femSourceInfo->triangleToElmMapper()->elementIndex( pickItem.faceIdx() );
const RimGeoMechView* geoMechView = dynamic_cast<const RimGeoMechView*>( view.get() );
RimGeoMechView* geoMechView = dynamic_cast<RimGeoMechView*>( view.get() );
if ( geoMechView && geoMechView->femParts() )
{
const RigFemPart* femPart = geoMechView->femParts()->part( femPartIndex );
RigElementType elType = femPart->elementType( elementIndex );
RigFemPart* femPart = geoMechView->femParts()->part( femPartIndex );
RigElementType elType = femPart->elementType( elementIndex );
if ( elType == HEX8 || elType == HEX8P )
{

View File

@@ -24,12 +24,8 @@
#include <gsl/gsl>
class RimWellPathGeometryDefInterface;
class RigWellPath;
class RiuPickItemInfo;
class RivWellPathSourceInfo;
class RimWellPathGeometryDef;
class RimWellPathLateralGeometryDef;
class RigWellPath;
//==================================================================================================
///
@@ -37,7 +33,7 @@ class RimWellPathLateralGeometryDef;
class RicCreateWellTargetsPickEventHandler : public Ric3dViewPickEventHandler
{
public:
RicCreateWellTargetsPickEventHandler( gsl::not_null<RimWellPathGeometryDefInterface*> wellGeometryDef );
RicCreateWellTargetsPickEventHandler( gsl::not_null<RimWellPathGeometryDef*> wellGeometryDef );
~RicCreateWellTargetsPickEventHandler();
void registerAsPickEventHandler() override;
@@ -51,38 +47,13 @@ private:
gsl::not_null<const RigWellPath*> wellPathGeometry,
double* azimuth,
double* inclination ) const;
bool calculateWellPathGeometryAtPickPoint( const RiuPickItemInfo& pickItem,
gsl::not_null<const RivWellPathSourceInfo*> sourceInfo,
const cvf::Vec3d& intersectionPointInDomain,
gsl::not_null<cvf::Vec3d*> targetPointInDomain,
gsl::not_null<double*> azimuth,
gsl::not_null<double*> inclination ) const;
cvf::Vec3d calculateGridPickPoint( gsl::not_null<const Rim3dView*> rimView,
const RiuPickItemInfo& pickItem,
const cvf::Vec3d& intersectionPointInDomain ) const;
void addNewTargetToModeledWellPath( const RiuPickItemInfo& pickItem,
gsl::not_null<RimWellPathGeometryDef*> wellPathGeometryDef,
const cvf::Vec3d& intersectionPointInDomain,
const cvf::Vec3d& targetPointInDomain,
double azimuth,
double inclination );
void addNewTargetToModeledWellPathLateral( const RiuPickItemInfo& pickItem,
gsl::not_null<RimWellPathLateralGeometryDef*> wellPathLateralGeometryDef,
const cvf::Vec3d& intersectionPointInDomain,
const cvf::Vec3d& targetPointInDomain,
double azimuth,
double inclination );
static bool isGridSourceObject( const cvf::Object* object );
static bool isValidWellPathSourceObject( const RivWellPathSourceInfo* sourceInfo );
static cvf::Vec3d findHexElementIntersection( gsl::not_null<const Rim3dView*> view,
const RiuPickItemInfo& pickItem,
const cvf::Vec3d& domainRayOrigin,
const cvf::Vec3d& domainRayEnd );
static cvf::Vec3d findHexElementIntersection( gsl::not_null<Rim3dView*> view,
const RiuPickItemInfo& pickItem,
const cvf::Vec3d& domainRayOrigin,
const cvf::Vec3d& domainRayEnd );
private:
caf::PdmPointer<RimWellPathGeometryDefInterface> m_geometryToAddTargetsTo;
caf::PdmPointer<RimWellPathGeometryDef> m_geometryToAddTargetsTo;
};

View File

@@ -20,15 +20,16 @@
#include "WellPathCommands/RicWellPathsUnitSystemSettingsImpl.h"
#include "RigWellPath.h"
#include "RimFishbones.h"
#include "RimFishbonesCollection.h"
#include "RimFishbonesMultipleSubs.h"
#include "RimModeledWellPathLateral.h"
#include "RimModeledWellPath.h"
#include "RimOilField.h"
#include "RimProject.h"
#include "RimWellPath.h"
#include "RimWellPathCollection.h"
#include "RimWellPathGeometryDef.h"
#include "RimWellPathGroup.h"
#include "RimWellPathLateralGeometryDef.h"
#include "RimWellPathTarget.h"
#include "Riu3DMainWindowTools.h"
#include "Riu3dSelectionManager.h"
@@ -74,18 +75,17 @@ void RicNewWellPathLateralAtDepthFeature::onActionTriggered( bool isChecked )
if ( wellPathCollection )
{
auto newModeledWellPath = new RimModeledWellPathLateral();
auto newModeledWellPath = new RimModeledWellPath();
auto [pointVector, measuredDepths] =
wellPath->wellPathGeometry()->clippedPointSubset( wellPath->wellPathGeometry()->measuredDepths().front(),
wellPathSelItem->m_measuredDepth );
if ( pointVector.size() < 2u ) return;
newModeledWellPath->geometryDefinition()->setParentGeometry( wellPath->wellPathGeometry() );
newModeledWellPath->geometryDefinition()->setMdAtConnection( wellPathSelItem->m_measuredDepth );
newModeledWellPath->geometryDefinition()->createTargetAtConnectionPoint(
pointVector[pointVector.size() - 1u] - pointVector[pointVector.size() - 2u] );
newModeledWellPath->geometryDefinition()->setMdAtFirstTarget( measuredDepths.back() );
newModeledWellPath->geometryDefinition()->setUseAutoGeneratedTargetAtSeaLevel( false );
newModeledWellPath->geometryDefinition()->setFixedWellPathPoints( pointVector );
newModeledWellPath->geometryDefinition()->setFixedMeasuredDepths( measuredDepths );
newModeledWellPath->setName( wellPath->name() + QString( " md=%1" ).arg( wellPathSelItem->m_measuredDepth ) );
newModeledWellPath->geometryDefinition()->enableTargetPointPicking( true );
newModeledWellPath->createWellPathGeometry();
if ( wellPathGroup )