Fault reactivation (#10624)

Update result to generate well paths based on information from model generator. Store settings in JSON file.
Add method to access local coordinate system definition
This commit is contained in:
jonjenssen
2023-09-19 18:03:36 +02:00
committed by GitHub
parent 9b797fdd36
commit 5d3fb8ceb9
17 changed files with 346 additions and 109 deletions

View File

@@ -25,15 +25,17 @@
#include "WellLogCommands/RicNewWellLogPlotFeatureImpl.h"
#include "WellLogCommands/RicWellLogPlotCurveFeatureImpl.h"
#include "RifJsonEncodeDecode.h"
#include "RigFemPartCollection.h"
#include "RigGeoMechCaseData.h"
#include "RigHexIntersectionTools.h"
#include "RigReservoirGridTools.h"
#include "RimFaultReactivationTools.h"
#include "RimGeoMechCase.h"
#include "RimGeoMechView.h"
#include "RimGridView.h"
#include "RimIntersectionCollection.h"
#include "RimMainPlotCollection.h"
#include "RimModeledWellPath.h"
#include "RimWellLogCalculatedCurve.h"
@@ -55,26 +57,29 @@
#include <array>
#include <QDir>
#include <QFileInfo>
#include <QMap>
#include <QVariant>
CAF_PDM_SOURCE_INIT( RimGeoMechFaultReactivationResult, "RimGeoMechFaultReactivationResult" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimGeoMechFaultReactivationResult::RimGeoMechFaultReactivationResult()
: m_bHaveValidData( false )
{
// TODO: Update icon
CAF_PDM_InitObject( "Fault Reactivation Result", ":/GeoMechCase24x24.png" );
CAF_PDM_InitFieldNoDefault( &m_intersection, "Intersection", "Intersection" );
CAF_PDM_InitField( &m_distanceFromFault, "DistanceFromFault", 5.0, "Distance From Fault" );
CAF_PDM_InitField( &m_distanceFromIntersection,
"FaceDistanceFromIntersection",
m_defaultDistanceFromIntersection,
"Face Distance From Intersection" );
CAF_PDM_InitField( &m_widthOutsideIntersection, "FaceWidthOutsideIntersection", 0.0, "Face Width Outside Intersection" );
CAF_PDM_InitFieldNoDefault( &m_createFaultReactivationPlot, "CreateReactivationPlot", "" );
caf::PdmUiPushButtonEditor::configureEditorForField( &m_createFaultReactivationPlot );
CAF_PDM_InitFieldNoDefault( &m_createFaultReactivationResult, "CreateReactivationResult", "" );
caf::PdmUiPushButtonEditor::configureEditorForField( &m_createFaultReactivationResult );
CAF_PDM_InitFieldNoDefault( &m_faultNormal, "FaultNormal", "" );
CAF_PDM_InitFieldNoDefault( &m_faultTopPosition, "FaultTopPosition", "" );
CAF_PDM_InitFieldNoDefault( &m_faultBottomPosition, "FaultBottomPosition", "" );
CAF_PDM_InitFieldNoDefault( &m_faceAWellPath, "FaceAWellPath", "Face A Well Path" );
m_faceAWellPath.uiCapability()->setUiHidden( true );
@@ -94,8 +99,6 @@ RimGeoMechFaultReactivationResult::RimGeoMechFaultReactivationResult()
//--------------------------------------------------------------------------------------------------
RimGeoMechFaultReactivationResult::~RimGeoMechFaultReactivationResult()
{
delete m_faceAWellPath;
delete m_faceBWellPath;
}
//--------------------------------------------------------------------------------------------------
@@ -103,6 +106,27 @@ RimGeoMechFaultReactivationResult::~RimGeoMechFaultReactivationResult()
//--------------------------------------------------------------------------------------------------
void RimGeoMechFaultReactivationResult::onLoadDataAndUpdate()
{
auto geomCase = geoMechCase();
if ( geomCase == nullptr ) return;
auto filename = geomCase->gridFileName();
QFileInfo fi( filename );
auto folder = fi.path();
auto basename = fi.baseName();
QDir workDir( folder );
auto modelSettingsFilename = workDir.absoluteFilePath( basename + ".settings.json" );
auto map = ResInsightInternalJson::JsonReader::decodeFile( modelSettingsFilename );
if ( !map.isEmpty() )
{
m_faultNormal = RimFaultReactivationTools::normalVector( map );
m_faultTopPosition = RimFaultReactivationTools::topFaultPosition( map );
m_faultBottomPosition = RimFaultReactivationTools::bottomFaultPosition( map );
m_bHaveValidData = true;
}
createWellGeometry();
createWellLogCurves();
}
@@ -114,22 +138,6 @@ QList<caf::PdmOptionItemInfo> RimGeoMechFaultReactivationResult::calculateValueO
{
QList<caf::PdmOptionItemInfo> options;
if ( fieldNeedingOptions == &m_intersection )
{
RimGridView* activeView = RiaApplication::instance()->activeGridView();
if ( !activeView || !activeView->intersectionCollection() ) return options;
for ( auto* intersection : activeView->intersectionCollection()->intersections() )
{
// Only utilize polyline intersections with two points
if ( intersection && intersection->type() == RimExtrudedCurveIntersection::CrossSectionEnum::CS_POLYLINE &&
!intersection->polyLines().empty() && intersection->polyLines()[0].size() == 2 )
{
options.push_back( caf::PdmOptionItemInfo( intersection->name(), intersection ) );
}
}
}
return options;
}
@@ -139,14 +147,10 @@ QList<caf::PdmOptionItemInfo> RimGeoMechFaultReactivationResult::calculateValueO
void RimGeoMechFaultReactivationResult::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
{
caf::PdmUiGroup* group = uiOrdering.addNewGroup( "Fault Reactivation Result" );
group->add( &m_intersection );
group->add( &m_distanceFromIntersection );
group->add( &m_widthOutsideIntersection );
group->add( &m_createFaultReactivationResult );
group->add( &m_faceAWellPath );
group->add( &m_faceBWellPath );
group->add( &m_faceAWellPathPartIndex );
group->add( &m_faceBWellPathPartIndex );
group->add( &m_distanceFromFault );
group->add( &m_createFaultReactivationPlot );
uiOrdering.skipRemainingFields( true );
}
//--------------------------------------------------------------------------------------------------
@@ -156,11 +160,11 @@ void RimGeoMechFaultReactivationResult::fieldChangedByUi( const caf::PdmFieldHan
const QVariant& oldValue,
const QVariant& newValue )
{
if ( changedField == &m_distanceFromIntersection || changedField == &m_widthOutsideIntersection )
if ( changedField == &m_distanceFromFault )
{
createWellGeometry();
}
if ( changedField == &m_createFaultReactivationResult && m_intersection() )
if ( changedField == &m_createFaultReactivationPlot )
{
createWellGeometry();
createWellLogCurves();
@@ -174,7 +178,7 @@ void RimGeoMechFaultReactivationResult::defineEditorAttribute( const caf::PdmFie
QString uiConfigName,
caf::PdmUiEditorAttribute* attribute )
{
if ( field == &m_createFaultReactivationResult )
if ( field == &m_createFaultReactivationPlot )
{
caf::PdmUiPushButtonEditorAttribute* attrib = dynamic_cast<caf::PdmUiPushButtonEditorAttribute*>( attribute );
if ( attrib )
@@ -189,14 +193,16 @@ void RimGeoMechFaultReactivationResult::defineEditorAttribute( const caf::PdmFie
//--------------------------------------------------------------------------------------------------
void RimGeoMechFaultReactivationResult::createWellGeometry()
{
RimGeoMechCase* geomCase = firstAncestorOrThisOfTypeAsserted<RimGeoMechCase>();
if ( !m_bHaveValidData ) return;
auto geomCase = geoMechCase();
if ( !geomCase || !geomCase->geoMechData() ) return;
RigFemPartCollection* geoMechPartCollection = geomCase->geoMechData()->femParts();
if ( !geoMechPartCollection ) return;
RimWellPathCollection* wellPathCollection = RimProject::current()->activeOilField()->wellPathCollection();
if ( !wellPathCollection ) return;
// Create well paths if not existing collection
// Create well paths if not existing in collection
const auto allWellPaths = wellPathCollection->allWellPaths();
if ( !m_faceAWellPath ||
( m_faceAWellPath && std::find( allWellPaths.begin(), allWellPaths.end(), m_faceAWellPath ) == allWellPaths.end() ) )
@@ -221,41 +227,14 @@ void RimGeoMechFaultReactivationResult::createWellGeometry()
m_faceAWellPath->geometryDefinition()->deleteAllTargets();
m_faceBWellPath->geometryDefinition()->deleteAllTargets();
// Using first two points from first polyline
const auto polyLines = m_intersection()->polyLines();
if ( polyLines.size() != 1 || polyLines[0].size() != 2 )
{
RiaLogging::error( "Polyline intersection for fault face must be defined with only 2 points!" );
return;
}
const std::vector<cvf::Vec3d> points = { polyLines[0][0], polyLines[0][1] };
// Create vector for well path defined by point a and b
const cvf::Vec3d a = points[0];
const cvf::Vec3d b = points[1];
const cvf::Vec3d wellVector = b - a;
// Cross product of well path vector and z-axis (New vector must be normalized)
const cvf::Vec3d normVector = wellVector ^ cvf::Vector3<double>::Z_AXIS;
const cvf::Vec3d distanceVector = m_distanceFromIntersection() * normVector.getNormalized();
// Get normalized vector along well to adjust point a and b outside of defined intersection
const auto normalizedWellVector = wellVector.getNormalized();
const cvf::Vec3d widthAdjustedA = a - ( normalizedWellVector * m_widthOutsideIntersection() );
const cvf::Vec3d widthAdjustedB = b + ( normalizedWellVector * m_widthOutsideIntersection() );
// Create well points for face A and B
const std::pair<cvf::Vec3d, cvf::Vec3d> faceAWellStartAndEnd = { widthAdjustedA + distanceVector, widthAdjustedB + distanceVector };
const std::pair<cvf::Vec3d, cvf::Vec3d> faceBWellStartAndEnd = { widthAdjustedA - distanceVector, widthAdjustedB - distanceVector };
// Get center point between face well points to detect which part fault faces are in
auto centerpoint = []( const cvf::Vec3d& a, const cvf::Vec3d& b ) -> cvf::Vec3d { return ( a + b ) / 2.0; };
const cvf::Vec3d faceAWellPathCenter = centerpoint( faceAWellStartAndEnd.first, faceAWellStartAndEnd.second );
const cvf::Vec3d faceBWellPathCenter = centerpoint( faceBWellStartAndEnd.first, faceBWellStartAndEnd.second );
cvf::Vec3d partATop = m_faultTopPosition() + m_faultNormal() * m_distanceFromFault;
cvf::Vec3d partABottom = m_faultBottomPosition() + m_faultNormal() * m_distanceFromFault;
cvf::Vec3d partBTop = m_faultTopPosition() - m_faultNormal() * m_distanceFromFault;
cvf::Vec3d partBBottom = m_faultBottomPosition() - m_faultNormal() * m_distanceFromFault;
// Update the well path target values
const std::vector<cvf::Vec3d> faceAWellPoints = { faceAWellStartAndEnd.first, faceAWellPathCenter, faceAWellStartAndEnd.second };
const std::vector<cvf::Vec3d> faceBWellPoints = { faceBWellStartAndEnd.first, faceBWellPathCenter, faceBWellStartAndEnd.second };
const std::vector<cvf::Vec3d> faceAWellPoints = { partATop, partABottom };
const std::vector<cvf::Vec3d> faceBWellPoints = { partBTop, partBBottom };
m_faceAWellPath->geometryDefinition()->createAndInsertTargets( faceAWellPoints );
m_faceBWellPath->geometryDefinition()->createAndInsertTargets( faceBWellPoints );
m_faceAWellPath->geometryDefinition()->setUseAutoGeneratedTargetAtSeaLevel( false );
@@ -264,8 +243,8 @@ void RimGeoMechFaultReactivationResult::createWellGeometry()
m_faceBWellPath->createWellPathGeometry();
// Detect which part well path centers are in
m_faceAWellPathPartIndex = getPartIndexFromPoint( geoMechPartCollection, faceAWellPathCenter );
m_faceBWellPathPartIndex = getPartIndexFromPoint( geoMechPartCollection, faceBWellPathCenter );
m_faceAWellPathPartIndex = getPartIndexFromPoint( geoMechPartCollection, partATop );
m_faceBWellPathPartIndex = getPartIndexFromPoint( geoMechPartCollection, partBTop );
// Update UI
wellPathCollection->uiCapability()->updateConnectedEditors();
@@ -277,7 +256,9 @@ void RimGeoMechFaultReactivationResult::createWellGeometry()
//--------------------------------------------------------------------------------------------------
void RimGeoMechFaultReactivationResult::createWellLogCurves()
{
RimGeoMechCase* geomCase = firstAncestorOrThisOfTypeAsserted<RimGeoMechCase>();
if ( !m_bHaveValidData ) return;
auto geomCase = geoMechCase();
if ( !geomCase ) return;
Rim3dView* view = RiaApplication::instance()->activeMainOrComparisonGridView();
if ( !view ) return;
@@ -375,8 +356,9 @@ RimWellLogExtractionCurve* RimGeoMechFaultReactivationResult::createWellLogExtra
RimModeledWellPath* wellPath,
int partId )
{
RimGeoMechCase* geomCase = firstAncestorOrThisOfTypeAsserted<RimGeoMechCase>();
auto geomCase = geoMechCase();
if ( !geomCase ) return nullptr;
Rim3dView* view = RiaApplication::instance()->activeMainOrComparisonGridView();
if ( !view ) return nullptr;
@@ -412,3 +394,11 @@ QString RimGeoMechFaultReactivationResult::plotDescription() const
return count == 0 ? plotDescription : QString( "%1 %2" ).arg( plotDescription ).arg( count );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimGeoMechCase* RimGeoMechFaultReactivationResult::geoMechCase() const
{
return firstAncestorOrThisOfTypeAsserted<RimGeoMechCase>();
}

View File

@@ -35,6 +35,7 @@ class RigFemResultAddress;
class RimModeledWellPath;
class RimWellLogTrack;
class RimWellLogExtractionCurve;
class RimGeoMechCase;
class RimGeoMechFaultReactivationResult : public caf::PdmObject
{
@@ -44,9 +45,9 @@ public:
RimGeoMechFaultReactivationResult();
~RimGeoMechFaultReactivationResult() override;
private:
void onLoadDataAndUpdate();
private:
QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override;
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
@@ -64,13 +65,16 @@ private:
QString plotDescription() const;
RimGeoMechCase* geoMechCase() const;
private:
caf::PdmPtrField<RimExtrudedCurveIntersection*> m_intersection;
caf::PdmField<bool> m_createFaultReactivationPlot;
caf::PdmField<bool> m_createFaultReactivationResult;
caf::PdmField<double> m_distanceFromFault;
caf::PdmField<double> m_distanceFromIntersection; // To move wells to each side of intersection
caf::PdmField<double> m_widthOutsideIntersection; // To stretch well points outside intersection
caf::PdmField<cvf::Vec3d> m_faultNormal;
caf::PdmField<cvf::Vec3d> m_faultTopPosition;
caf::PdmField<cvf::Vec3d> m_faultBottomPosition;
caf::PdmPtrField<RimModeledWellPath*> m_faceAWellPath;
caf::PdmPtrField<RimModeledWellPath*> m_faceBWellPath;
@@ -78,5 +82,5 @@ private:
caf::PdmField<int> m_faceAWellPathPartIndex;
caf::PdmField<int> m_faceBWellPathPartIndex;
const double m_defaultDistanceFromIntersection = 1.0; // [m] Default value from intersection and into each part
bool m_bHaveValidData;
};

View File

@@ -201,6 +201,8 @@ void RimGeoMechView::onLoadDataAndUpdate()
if ( m_partsCollection ) m_partsCollection->syncWithCase( m_geomechCase );
if ( m_faultReactivationResult ) m_faultReactivationResult->onLoadDataAndUpdate();
scheduleCreateDisplayModelAndRedraw();
progress.incrementProgress();