Displacement curves fault faces (#10243)

This commit is contained in:
Jørgen Herje
2023-05-22 11:37:57 +02:00
committed by GitHub
parent 9a219ddcb2
commit b83fe73395
33 changed files with 1235 additions and 47 deletions

View File

@@ -9,6 +9,7 @@ set(SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/RimGeoMechContourMapViewCollection.h
${CMAKE_CURRENT_LIST_DIR}/RimGeoMechPartCollection.h
${CMAKE_CURRENT_LIST_DIR}/RimGeoMechPart.h
${CMAKE_CURRENT_LIST_DIR}/RimGeoMechFaultReactivationResult.h
)
set(SOURCE_GROUP_SOURCE_FILES
@@ -22,6 +23,7 @@ set(SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RimGeoMechContourMapViewCollection.cpp
${CMAKE_CURRENT_LIST_DIR}/RimGeoMechPartCollection.cpp
${CMAKE_CURRENT_LIST_DIR}/RimGeoMechPart.cpp
${CMAKE_CURRENT_LIST_DIR}/RimGeoMechFaultReactivationResult.cpp
)
list(APPEND CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES})

View File

@@ -441,7 +441,7 @@ RimGridView* RimGeoMechContourMapProjection::baseView() const
std::vector<size_t> RimGeoMechContourMapProjection::findIntersectingCells( const cvf::BoundingBox& bbox ) const
{
std::vector<size_t> allCellIndices;
m_femPart->findIntersectingCellsWithExistingSearchTree( bbox, &allCellIndices );
m_femPart->findIntersectingElementsWithExistingSearchTree( bbox, &allCellIndices );
return allCellIndices;
}

View File

@@ -0,0 +1,394 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2023- Equinor ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RimGeoMechFaultReactivationResult.h"
#include "RiaApplication.h"
#include "RiaLogging.h"
#include "RicWellLogTools.h"
#include "WellLogCommands/RicNewWellLogPlotFeatureImpl.h"
#include "WellLogCommands/RicWellLogPlotCurveFeatureImpl.h"
#include "RigFemPartCollection.h"
#include "RigGeoMechCaseData.h"
#include "RigReservoirGridTools.h"
#include "RimGeoMechCase.h"
#include "RimGeoMechView.h"
#include "RimGridView.h"
#include "RimIntersectionCollection.h"
#include "RimMainPlotCollection.h"
#include "RimModeledWellPath.h"
#include "RimWellLogDiffCurve.h"
#include "RimWellLogExtractionCurve.h"
#include "RimWellLogPlotCollection.h"
#include "RimWellLogPlotNameConfig.h"
#include "RimWellLogTrack.h"
#include "RimWellPathGeometryDef.h"
#include "RimOilField.h"
#include "RimProject.h"
#include "RimWellPathCollection.h"
#include "cafPdmFieldScriptingCapability.h"
#include "cafPdmObjectScriptingCapability.h"
#include "cafPdmUiPushButtonEditor.h"
#include "cvfBoundingBox.h"
CAF_PDM_SOURCE_INIT( RimGeoMechFaultReactivationResult, "RimGeoMechFaultReactivationResult" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimGeoMechFaultReactivationResult::RimGeoMechFaultReactivationResult()
{
// TODO: Update icon
CAF_PDM_InitObject( "Fault Reactivation Result", ":/GeoMechCase24x24.png" );
CAF_PDM_InitFieldNoDefault( &m_intersection, "Intersection", "Intersection" );
CAF_PDM_InitField( &m_distanceFromIntersection, "FaceDistanceFromIntersection", 0.0, "Face Distance From Intersection" );
CAF_PDM_InitField( &m_widthOutsideIntersection, "FaceWidthOutsideIntersection", 0.0, "Face Width Outside Intersection" );
CAF_PDM_InitFieldNoDefault( &m_createFaultReactivationResult, "CreateReactivationResult", "" );
caf::PdmUiPushButtonEditor::configureEditorForField( &m_createFaultReactivationResult );
CAF_PDM_InitFieldNoDefault( &m_faceAWellPath, "FaceAWellPath", "Face A Well Path" );
m_faceAWellPath.uiCapability()->setUiHidden( true );
CAF_PDM_InitFieldNoDefault( &m_faceBWellPath, "FaceBWellPath", "Face B Well Path" );
m_faceBWellPath.uiCapability()->setUiHidden( true );
CAF_PDM_InitField( &m_faceAWellPathPartIndex, "FaceAWellPathPartIndex", 0, "Face A Well Path Part Index" );
m_faceAWellPathPartIndex.uiCapability()->setUiHidden( true );
CAF_PDM_InitField( &m_faceBWellPathPartIndex, "FaceBWellPathPartIndex", 0, "Face B Well Path Part Index" );
m_faceBWellPathPartIndex.uiCapability()->setUiHidden( true );
setDeletable( false );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimGeoMechFaultReactivationResult::~RimGeoMechFaultReactivationResult()
{
delete m_faceAWellPath;
delete m_faceBWellPath;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimGeoMechFaultReactivationResult::onLoadDataAndUpdate()
{
createWellGeometry();
createWellLogCurves();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QList<caf::PdmOptionItemInfo> RimGeoMechFaultReactivationResult::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions )
{
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;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
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 );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimGeoMechFaultReactivationResult::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
const QVariant& oldValue,
const QVariant& newValue )
{
if ( changedField == &m_distanceFromIntersection || changedField == &m_widthOutsideIntersection )
{
createWellGeometry();
}
if ( changedField == &m_createFaultReactivationResult && m_intersection() )
{
onLoadDataAndUpdate();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimGeoMechFaultReactivationResult::defineEditorAttribute( const caf::PdmFieldHandle* field,
QString uiConfigName,
caf::PdmUiEditorAttribute* attribute )
{
if ( field == &m_createFaultReactivationResult )
{
caf::PdmUiPushButtonEditorAttribute* attrib = dynamic_cast<caf::PdmUiPushButtonEditorAttribute*>( attribute );
if ( attrib )
{
attrib->m_buttonText = "Create";
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimGeoMechFaultReactivationResult::createWellGeometry()
{
RimGeoMechCase* geomCase = firstAncestorOrThisOfTypeAsserted<RimGeoMechCase>();
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
const auto allWellPaths = wellPathCollection->allWellPaths();
if ( !m_faceAWellPath ||
( m_faceAWellPath && std::find( allWellPaths.begin(), allWellPaths.end(), m_faceAWellPath ) == allWellPaths.end() ) )
{
m_faceAWellPath = new RimModeledWellPath();
m_faceAWellPath->setName( "Fault Face A Well" );
m_faceAWellPath->setShowWellPath( false );
wellPathCollection->addWellPath( m_faceAWellPath );
}
if ( !m_faceBWellPath ||
( m_faceBWellPath && std::find( allWellPaths.begin(), allWellPaths.end(), m_faceBWellPath ) == allWellPaths.end() ) )
{
m_faceBWellPath = new RimModeledWellPath();
m_faceBWellPath->setName( "Fault Face B Well" );
m_faceBWellPath->setShowWellPath( false );
wellPathCollection->addWellPath( m_faceBWellPath );
}
if ( !m_faceAWellPath->geometryDefinition() || !m_faceBWellPath->geometryDefinition() ) return;
// Delete the previous well path target values
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 );
// 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 };
m_faceAWellPath->geometryDefinition()->createAndInsertTargets( faceAWellPoints );
m_faceBWellPath->geometryDefinition()->createAndInsertTargets( faceBWellPoints );
m_faceAWellPath->geometryDefinition()->setUseAutoGeneratedTargetAtSeaLevel( false );
m_faceBWellPath->geometryDefinition()->setUseAutoGeneratedTargetAtSeaLevel( false );
m_faceAWellPath->createWellPathGeometry();
m_faceBWellPath->createWellPathGeometry();
// Detect which part well path centers are in
m_faceAWellPathPartIndex = getPartIndexFromPoint( geoMechPartCollection, faceAWellPathCenter );
m_faceBWellPathPartIndex = getPartIndexFromPoint( geoMechPartCollection, faceBWellPathCenter );
// Update UI
wellPathCollection->uiCapability()->updateConnectedEditors();
RimProject::current()->scheduleCreateDisplayModelAndRedrawAllViews();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimGeoMechFaultReactivationResult::createWellLogCurves()
{
RimGeoMechCase* geomCase = firstAncestorOrThisOfTypeAsserted<RimGeoMechCase>();
if ( !geomCase ) return;
Rim3dView* view = RiaApplication::instance()->activeMainOrComparisonGridView();
if ( !view ) return;
// Create Plot
const bool showAfterCreation = true;
const QString name = plotDescription();
RimWellLogPlot* newPlot = RicNewWellLogPlotFeatureImpl::createWellLogPlot( showAfterCreation, name );
newPlot->setNamingMethod( RiaDefines::ObjectNamingMethod::CUSTOM );
newPlot->nameConfig()->setCustomName( name );
// Create curve tracks
const bool doUpdateAfter = true;
RimWellLogTrack* wellLogExtractionDisplacementTrack =
RicNewWellLogPlotFeatureImpl::createWellLogPlotTrack( doUpdateAfter, QString( "Fault Reactivation Displacement Curves" ), newPlot );
RimWellLogTrack* wellLogDiffTrack =
RicNewWellLogPlotFeatureImpl::createWellLogPlotTrack( doUpdateAfter, QString( "Fault Reactivation Displacement Diff" ), newPlot );
RimWellLogTrack* wellLogExtractionFaultmobTrack =
RicNewWellLogPlotFeatureImpl::createWellLogPlotTrack( doUpdateAfter, QString( "Fault Reactivation Faultmob Curves" ), newPlot );
// Well log extraction displacement curves
RigFemResultAddress wellLogExtractionDisplacementResult( RigFemResultPosEnum::RIG_NODAL, "U", "U_LENGTH" );
auto* faceADisplacementCurve = createWellLogExtractionCurveAndAddToTrack( wellLogExtractionDisplacementTrack,
wellLogExtractionDisplacementResult,
m_faceAWellPath(),
m_faceAWellPathPartIndex() );
auto* faceBDisplacementCurve = createWellLogExtractionCurveAndAddToTrack( wellLogExtractionDisplacementTrack,
wellLogExtractionDisplacementResult,
m_faceBWellPath(),
m_faceBWellPathPartIndex() );
if ( !faceADisplacementCurve || !faceBDisplacementCurve )
{
RiaLogging::error( "Failed to create well log extraction displacement curves" );
return;
}
// Create well log diff curve for m_faceAWellPath and m_faceBWellPath
RimWellLogDiffCurve* faceWellLogDiffCurve = RicWellLogTools::addWellLogDiffCurve( wellLogDiffTrack );
faceWellLogDiffCurve->setWellLogCurves( faceADisplacementCurve, faceBDisplacementCurve );
faceWellLogDiffCurve->loadDataAndUpdate( true );
faceWellLogDiffCurve->updateConnectedEditors();
// Well log extraction faultmob curves
RigFemResultAddress wellLogExtractionFaultmobResult( RigFemResultPosEnum::RIG_ELEMENT_NODAL_FACE, "SE", "FAULTMOB" );
createWellLogExtractionCurveAndAddToTrack( wellLogExtractionFaultmobTrack,
wellLogExtractionFaultmobResult,
m_faceAWellPath(),
m_faceAWellPathPartIndex() );
createWellLogExtractionCurveAndAddToTrack( wellLogExtractionFaultmobTrack,
wellLogExtractionFaultmobResult,
m_faceBWellPath(),
m_faceBWellPathPartIndex() );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RimGeoMechFaultReactivationResult::getPartIndexFromPoint( const RigFemPartCollection* const partCollection, const cvf::Vec3d& point ) const
{
int idx = 0;
if ( !partCollection ) return idx;
const cvf::BoundingBox intersectingBb( point, point );
std::vector<size_t> intersectedGlobalElementIndices;
partCollection->findIntersectingGlobalElementIndices( intersectingBb, &intersectedGlobalElementIndices );
if ( intersectedGlobalElementIndices.empty() ) return idx;
// Utilize first intersected element to detect part for point
const auto [partId, elementIndex] = partCollection->partIdAndElementIndex( intersectedGlobalElementIndices.front() );
idx = partId;
return idx;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimWellLogExtractionCurve* RimGeoMechFaultReactivationResult::createWellLogExtractionCurveAndAddToTrack( RimWellLogTrack* track,
const RigFemResultAddress& resultAddress,
RimModeledWellPath* wellPath,
int partId )
{
RimGeoMechCase* geomCase = firstAncestorOrThisOfTypeAsserted<RimGeoMechCase>();
if ( !geomCase ) return nullptr;
Rim3dView* view = RiaApplication::instance()->activeMainOrComparisonGridView();
if ( !view ) return nullptr;
const int branchIndex = -1;
const bool useBranchDetection = false;
const bool updateParentPlot = true;
RimWellLogExtractionCurve* wellLogExtractionCurve =
RicWellLogTools::addWellLogExtractionCurve( track, geomCase, view, wellPath, nullptr, branchIndex, useBranchDetection );
wellLogExtractionCurve->setGeoMechResultAddress( resultAddress );
wellLogExtractionCurve->setGeoMechPart( partId );
wellLogExtractionCurve->updateConnectedEditors();
wellLogExtractionCurve->loadDataAndUpdate( updateParentPlot );
return wellLogExtractionCurve;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimGeoMechFaultReactivationResult::plotDescription() const
{
RimWellLogPlotCollection* wellLogPlotCollection = RimMainPlotCollection::current()->wellLogPlotCollection();
QString plotDescription = "Fault Reactivation Plot";
if ( !wellLogPlotCollection ) return plotDescription;
int count = 0;
for ( const auto& plot : wellLogPlotCollection->wellLogPlots() )
{
if ( plot->description().startsWith( plotDescription ) ) ++count;
}
return count == 0 ? plotDescription : QString( "%1 %2" ).arg( plotDescription ).arg( count );
}

View File

@@ -0,0 +1,80 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2023- Equinor ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "RimCheckableNamedObject.h"
#include "RimExtrudedCurveIntersection.h"
#include "RimIntersectionResultsDefinitionCollection.h"
#include "cafPdmField.h"
#include "cafPdmObject.h"
#include "cafPdmPtrField.h"
#include "cvfVector3.h"
#include <vector>
class RigFemPartCollection;
class RigFemResultAddress;
class RimModeledWellPath;
class RimWellLogTrack;
class RimWellLogExtractionCurve;
class RimGeoMechFaultReactivationResult : public caf::PdmObject
{
CAF_PDM_HEADER_INIT;
public:
RimGeoMechFaultReactivationResult();
~RimGeoMechFaultReactivationResult() override;
private:
void onLoadDataAndUpdate();
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;
void defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override;
void createWellGeometry();
void createWellLogCurves();
int getPartIndexFromPoint( const RigFemPartCollection* const partCollection, const cvf::Vec3d& point ) const;
RimWellLogExtractionCurve* createWellLogExtractionCurveAndAddToTrack( RimWellLogTrack* track,
const RigFemResultAddress& resultAddress,
RimModeledWellPath* wellPath,
int partId );
QString plotDescription() const;
private:
caf::PdmPtrField<RimExtrudedCurveIntersection*> m_intersection;
caf::PdmField<bool> m_createFaultReactivationResult;
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::PdmPtrField<RimModeledWellPath*> m_faceAWellPath;
caf::PdmPtrField<RimModeledWellPath*> m_faceBWellPath;
caf::PdmField<int> m_faceAWellPathPartIndex;
caf::PdmField<int> m_faceBWellPathPartIndex;
};

View File

@@ -37,6 +37,7 @@
#include "RimEclipseView.h"
#include "RimGeoMechCase.h"
#include "RimGeoMechCellColors.h"
#include "RimGeoMechFaultReactivationResult.h"
#include "RimGeoMechPart.h"
#include "RimGeoMechPartCollection.h"
#include "RimGeoMechPropertyFilterCollection.h"
@@ -98,6 +99,9 @@ RimGeoMechView::RimGeoMechView()
m_tensorResults = new RimTensorResults();
m_tensorResults.uiCapability()->setUiTreeHidden( true );
CAF_PDM_InitFieldNoDefault( &m_faultReactivationResult, "FaultReactivationResult", "Fault Reactivation Result" );
m_faultReactivationResult = new RimGeoMechFaultReactivationResult();
CAF_PDM_InitFieldNoDefault( &m_propertyFilterCollection, "PropertyFilters", "Property Filters" );
m_propertyFilterCollection = new RimGeoMechPropertyFilterCollection();
m_propertyFilterCollection.uiCapability()->setUiTreeHidden( true );
@@ -132,6 +136,7 @@ RimGeoMechView::~RimGeoMechView()
delete m_tensorResults;
delete cellResult;
delete m_propertyFilterCollection;
delete m_faultReactivationResult;
}
//--------------------------------------------------------------------------------------------------
@@ -1050,6 +1055,7 @@ void RimGeoMechView::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrderin
uiTreeOrdering.add( m_tensorResults() );
uiTreeOrdering.add( m_cellFilterCollection() );
uiTreeOrdering.add( m_propertyFilterCollection() );
uiTreeOrdering.add( m_faultReactivationResult() );
addRequiredUiTreeObjects( uiTreeOrdering );

View File

@@ -37,6 +37,7 @@ class Rim3dOverlayInfoConfig;
class RimCellRangeFilterCollection;
class RimGeoMechCase;
class RimGeoMechCellColors;
class RimGeoMechFaultReactivationResult;
class RimGeoMechPartCollection;
class RimGeoMechPropertyFilterCollection;
class RimGeoMechResultDefinition;
@@ -150,6 +151,7 @@ private:
caf::PdmChildField<RimTensorResults*> m_tensorResults;
caf::PdmChildField<RimGeoMechPropertyFilterCollection*> m_propertyFilterCollection;
caf::PdmChildField<RimGeoMechFaultReactivationResult*> m_faultReactivationResult;
caf::PdmPointer<RimGeoMechPropertyFilterCollection> m_overridePropertyFilterCollection;
caf::PdmChildField<RimGeoMechPartCollection*> m_partsCollection;
caf::PdmPointer<RimGeoMechCase> m_geomechCase;

View File

@@ -638,6 +638,7 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
menuBuilder << "RicNewWellLogRftCurveFeature";
menuBuilder << "RicNewWellLogFileCurveFeature";
menuBuilder << "RicNewWellMeasurementCurveFeature";
menuBuilder << "RicNewWellLogDiffCurveFeature";
menuBuilder << "RicNewEnsembleWellLogCurveSetFeature";
menuBuilder << "Separator";
menuBuilder << "RicDeleteSubPlotFeature";
@@ -1243,6 +1244,7 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
}
else if ( dynamic_cast<RimWellLogCurve*>( firstUiItem ) || dynamic_cast<RimWellLogTrack*>( firstUiItem ) )
{
menuBuilder << "RicNewWellLogDiffCurveFeature";
menuBuilder << "RicExportToLasFileFeature";
menuBuilder << "RicChangeDataSourceFeature";
}

View File

@@ -26,6 +26,7 @@ set(SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/RimRftTools.h
${CMAKE_CURRENT_LIST_DIR}/RimRftTopologyCurve.h
${CMAKE_CURRENT_LIST_DIR}/RimWellLogCurveInfoTextProvider.h
${CMAKE_CURRENT_LIST_DIR}/RimWellLogDiffCurve.h
)
set(SOURCE_GROUP_SOURCE_FILES
@@ -56,6 +57,7 @@ set(SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RimRftTools.cpp
${CMAKE_CURRENT_LIST_DIR}/RimRftTopologyCurve.cpp
${CMAKE_CURRENT_LIST_DIR}/RimWellLogCurveInfoTextProvider.cpp
${CMAKE_CURRENT_LIST_DIR}/RimWellLogDiffCurve.cpp
)
list(APPEND CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES})

View File

@@ -0,0 +1,300 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2023- Equinor ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RimWellLogDiffCurve.h"
#include "RiaDefines.h"
#include "RiaLogging.h"
#include "RigWellLogCurveData.h"
#include "RimMainPlotCollection.h"
#include "RimOilField.h"
#include "RimPlot.h"
#include "RimProject.h"
#include "RimWellLogPlot.h"
#include "RimWellLogPlotCollection.h"
#include "RimWellLogTrack.h"
#include "RimWellPathCollection.h"
#include "RiuPlotCurve.h"
#include "cafPdmUiTreeOrdering.h"
CAF_PDM_SOURCE_INIT( RimWellLogDiffCurve, "WellLogDiffCurve" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimWellLogDiffCurve::RimWellLogDiffCurve()
{
CAF_PDM_InitObject( "Well Log Diff Curve", ":/WellLogCurve16x16.png" );
CAF_PDM_InitFieldNoDefault( &m_firstWellLogCurve, "FirstWellLogCurve", "First Well Log Curve" );
CAF_PDM_InitFieldNoDefault( &m_secondWellLogCurve, "SecondWellLogCurve", "Second Well Log Curve" );
setNamingMethod( RiaDefines::ObjectNamingMethod::AUTO );
setDeletable( true );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimWellLogDiffCurve::~RimWellLogDiffCurve()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogDiffCurve::setWellLogCurves( RimWellLogCurve* firstWellLogCurve, RimWellLogCurve* secondWellLogCurve )
{
disconnectWellLogCurveChangedFromSlots( m_firstWellLogCurve );
disconnectWellLogCurveChangedFromSlots( m_secondWellLogCurve );
if ( firstWellLogCurve )
{
m_firstWellLogCurve = firstWellLogCurve;
connectWellLogCurveChangedToSlots( m_firstWellLogCurve );
}
if ( secondWellLogCurve )
{
m_secondWellLogCurve = secondWellLogCurve;
connectWellLogCurveChangedToSlots( m_secondWellLogCurve );
}
if ( m_namingMethod() == RiaDefines::ObjectNamingMethod::AUTO )
{
setAutomaticName();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimWellLogDiffCurve::createCurveAutoName()
{
if ( !m_firstWellLogCurve() || !m_secondWellLogCurve() ) return QString( "Not able to find source curves for difference curve" );
return QString( "Diff (%1 - %2)" ).arg( m_firstWellLogCurve->curveName() ).arg( m_secondWellLogCurve->curveName() );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogDiffCurve::onLoadDataAndUpdate( bool updateParentPlot )
{
if ( !m_firstWellLogCurve() || !m_secondWellLogCurve() ) return;
if ( m_namingMethod() == RiaDefines::ObjectNamingMethod::AUTO )
{
setAutomaticName();
}
// Use well A as reference for resampled curve data
auto* firstCurveData = m_firstWellLogCurve()->curveData();
auto* secondCurveData = m_secondWellLogCurve()->curveData();
if ( !firstCurveData || !secondCurveData ) return;
if ( firstCurveData->depthUnit() != secondCurveData->depthUnit() )
{
RiaLogging::warning( "Well log curve depth units are not the same" );
}
if ( firstCurveData->propertyValueUnit() != secondCurveData->propertyValueUnit() )
{
RiaLogging::warning( "Well log curve property value units are not the same" );
}
const auto depthUnit = firstCurveData->depthUnit();
const auto depthType = RiaDefines::DepthTypeEnum::MEASURED_DEPTH;
const auto propertyUnit = firstCurveData->propertyValueUnit();
// Get curve A depths and property values
const auto firstCurveDepthValues = firstCurveData->depths( depthType );
const auto firstCurvePropertyValues = firstCurveData->propertyValues();
// Resample curve B to curve A
cvf::ref<RigWellLogCurveData> secondCurveDataResampled = secondCurveData->calculateResampledCurveData( depthType, firstCurveDepthValues );
auto secondCurveDepthValuesResampled = secondCurveDataResampled->depths( depthType );
auto secondCurvePropertyValuesResampled = secondCurveDataResampled->propertyValues();
// Verify equal sizes
if ( firstCurveDepthValues.size() != firstCurvePropertyValues.size() ) return;
if ( firstCurveDepthValues.size() != secondCurveDepthValuesResampled.size() ) return;
if ( firstCurveDepthValues.size() != secondCurvePropertyValuesResampled.size() ) return;
// Calculate diff curve
std::vector<double> curveDiffDepthValues( firstCurveDepthValues.size() );
std::vector<double> curveDiffPropertyValues( firstCurvePropertyValues.size() );
for ( size_t i = 0; i < firstCurvePropertyValues.size(); ++i )
{
curveDiffPropertyValues[i] = firstCurvePropertyValues[i] - secondCurvePropertyValuesResampled[i];
curveDiffDepthValues[i] = firstCurveDepthValues[i];
}
const bool useLogarithmicScale = false;
const bool isExtractionCurve = false;
// Set curve data
auto depthsMap = std::map<RiaDefines::DepthTypeEnum, std::vector<double>>();
depthsMap[depthType] = curveDiffDepthValues;
setPropertyValuesAndDepths( curveDiffPropertyValues, depthsMap, 0.0, depthUnit, isExtractionCurve, useLogarithmicScale, propertyUnit );
// Set curve data to plot
std::vector<double> xPlotValues = curveData()->propertyValuesByIntervals();
std::vector<double> yPlotValues = curveData()->depthValuesByIntervals( depthType, depthUnit );
m_plotCurve->setSamplesFromXValuesAndYValues( xPlotValues, yPlotValues, useLogarithmicScale );
updateCurvePresentation( updateParentPlot );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogDiffCurve::setAutomaticName()
{
m_curveName = createCurveAutoName();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogDiffCurve::onWellLogCurveChanged( const SignalEmitter* emitter )
{
onLoadDataAndUpdate( true );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogDiffCurve::connectWellLogCurveChangedToSlots( RimWellLogCurve* wellLogCurve )
{
if ( !wellLogCurve ) return;
wellLogCurve->dataChanged.connect( this, &RimWellLogDiffCurve::onWellLogCurveChanged );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogDiffCurve::disconnectWellLogCurveChangedFromSlots( RimWellLogCurve* wellLogCurve )
{
if ( !wellLogCurve ) return;
wellLogCurve->dataChanged.disconnect( this );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimWellLogDiffCurve::wellName() const
{
return m_curveName;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimWellLogDiffCurve::wellLogChannelUiName() const
{
return m_curveName;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimWellLogDiffCurve::wellLogChannelUnits() const
{
CAF_ASSERT( "TO BE IMPLEMETNED!" );
if ( m_firstWellLogCurve->wellLogChannelUnits() != m_secondWellLogCurve->wellLogChannelUnits() )
{
return QString( "%1 - %2" ).arg( m_firstWellLogCurve->wellLogChannelUnits() ).arg( m_secondWellLogCurve->wellLogChannelUnits() );
}
return m_firstWellLogCurve->wellLogChannelUnits();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogDiffCurve::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
{
RimPlotCurve::updateFieldUiState();
caf::PdmUiGroup* group = uiOrdering.addNewGroup( "Data Source" );
group->add( &m_firstWellLogCurve );
group->add( &m_secondWellLogCurve );
RimStackablePlotCurve::defaultUiOrdering( uiOrdering );
uiOrdering.skipRemainingFields( true );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogDiffCurve::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName )
{
uiTreeOrdering.skipRemainingChildren( true );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogDiffCurve::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue )
{
RimWellLogCurve::fieldChangedByUi( changedField, oldValue, newValue );
if ( changedField == &m_firstWellLogCurve || changedField == &m_secondWellLogCurve )
{
if ( !m_firstWellLogCurve() || !m_secondWellLogCurve() ) return;
PdmObjectHandle* prevValue = oldValue.value<caf::PdmPointer<PdmObjectHandle>>().rawPtr();
auto* prevWellLogCurve = dynamic_cast<RimWellLogCurve*>( prevValue );
disconnectWellLogCurveChangedFromSlots( prevWellLogCurve );
if ( changedField == &m_firstWellLogCurve ) connectWellLogCurveChangedToSlots( m_firstWellLogCurve );
if ( changedField == &m_secondWellLogCurve ) connectWellLogCurveChangedToSlots( m_firstWellLogCurve );
onLoadDataAndUpdate( true );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QList<caf::PdmOptionItemInfo> RimWellLogDiffCurve::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions )
{
QList<caf::PdmOptionItemInfo> options;
options = RimWellLogCurve::calculateValueOptions( fieldNeedingOptions );
if ( !options.empty() ) return options;
if ( fieldNeedingOptions == &m_firstWellLogCurve || fieldNeedingOptions == &m_secondWellLogCurve )
{
RimWellLogPlotCollection* wellLogPlotCollection = RimMainPlotCollection::current()->wellLogPlotCollection();
if ( !wellLogPlotCollection ) return {};
// Find each well log plot in collection
std::vector<RimWellLogCurve*> wellLogCurves = wellLogPlotCollection->descendantsOfType<RimWellLogCurve>();
for ( RimWellLogCurve* curve : wellLogCurves )
{
if ( !curve || curve == this ) continue;
options.push_back( caf::PdmOptionItemInfo( curve->curveName(), curve ) );
}
}
return options;
}

View File

@@ -0,0 +1,70 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2023- Equinor ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "RimWellLogCurve.h"
#include "cafPdmPtrField.h"
#include "cvfObject.h"
class RimCase;
class RimWellPath;
//==================================================================================================
///
///
//==================================================================================================
class RimWellLogDiffCurve : public RimWellLogCurve
{
CAF_PDM_HEADER_INIT;
public:
RimWellLogDiffCurve();
~RimWellLogDiffCurve() override;
void setWellLogCurves( RimWellLogCurve* firstWellLogCurve, RimWellLogCurve* secondWellLogCurve );
// Inherited via RimWellLogCurve
virtual QString wellName() const override;
virtual QString wellLogChannelUiName() const override;
virtual QString wellLogChannelUnits() const override;
protected:
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "" ) override;
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override;
private:
// Inherited via RimWellLogCurve
virtual QString createCurveAutoName() override;
virtual void onLoadDataAndUpdate( bool updateParentPlot ) override;
void setAutomaticName();
void onWellLogCurveChanged( const SignalEmitter* emitter );
void connectWellLogCurveChangedToSlots( RimWellLogCurve* wellLogCurve );
void disconnectWellLogCurveChangedFromSlots( RimWellLogCurve* wellLogCurve );
private:
caf::PdmPtrField<RimCase*> m_case;
caf::PdmPtrField<RimWellLogCurve*> m_firstWellLogCurve;
caf::PdmPtrField<RimWellLogCurve*> m_secondWellLogCurve;
};

View File

@@ -67,11 +67,11 @@ int RimWellIADataAccess::elementIndex( cvf::Vec3d position )
cvf::BoundingBox bb;
bb.add( position );
std::vector<size_t> closeCells;
m_caseData->femParts()->part( 0 )->findIntersectingCells( bb, &closeCells );
if ( closeCells.size() == 0 ) return -1;
std::vector<size_t> closeElements;
m_caseData->femParts()->part( 0 )->findIntersectingElementIndices( bb, &closeElements );
if ( closeElements.size() == 0 ) return -1;
return (int)closeCells[0];
return (int)closeElements[0];
}
//--------------------------------------------------------------------------------------------------

View File

@@ -639,6 +639,14 @@ bool RimWellPath::showWellPath() const
return m_showWellPath();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellPath::setShowWellPath( bool showWellPath )
{
m_showWellPath = showWellPath;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -139,6 +139,7 @@ public:
bool showWellPathLabel() const;
bool showWellPath() const;
void setShowWellPath( bool showWellPath );
cvf::Color3f wellPathColor() const;
void setWellPathColor( const cvf::Color3f& color );

View File

@@ -236,7 +236,7 @@ void RimWellPathGeometryDef::setFixedMeasuredDepths( const std::vector<double>&
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RimWellPathTarget*> RimWellPathGeometryDef::createTargets( const std::vector<cvf::Vec3d>& points )
std::vector<RimWellPathTarget*> RimWellPathGeometryDef::createAndInsertTargets( const std::vector<cvf::Vec3d>& points )
{
CAF_ASSERT( points.size() >= 2u );

View File

@@ -66,7 +66,7 @@ public:
void setFixedWellPathPoints( const std::vector<cvf::Vec3d>& points );
void setFixedMeasuredDepths( const std::vector<double>& mds );
std::vector<RimWellPathTarget*> createTargets( const std::vector<cvf::Vec3d>& points );
std::vector<RimWellPathTarget*> createAndInsertTargets( const std::vector<cvf::Vec3d>& points );
std::pair<RimWellPathTarget*, RimWellPathTarget*> findActiveTargetsAroundInsertionPoint( const RimWellPathTarget* targetToInsertBefore );