From c7f9d032290ad460324fa47dfbe2777c3bf8a82a Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Sat, 18 Apr 2020 09:20:04 +0200 Subject: [PATCH 01/46] Grid cell time history curves : Guard null pointer access --- .../RimEclipseGeometrySelectionItem.cpp | 2 +- .../RimGridTimeHistoryCurve.cpp | 31 ++++++++++++------- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimEclipseGeometrySelectionItem.cpp b/ApplicationCode/ProjectDataModel/RimEclipseGeometrySelectionItem.cpp index f4922cdcbf..10390aa13f 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseGeometrySelectionItem.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseGeometrySelectionItem.cpp @@ -97,7 +97,7 @@ QString RimEclipseGeometrySelectionItem::geometrySelectionText() const } else { - text = "No case"; + return "No case"; } text += ", "; diff --git a/ApplicationCode/ProjectDataModel/RimGridTimeHistoryCurve.cpp b/ApplicationCode/ProjectDataModel/RimGridTimeHistoryCurve.cpp index 74147dbef8..ba28dea1c5 100644 --- a/ApplicationCode/ProjectDataModel/RimGridTimeHistoryCurve.cpp +++ b/ApplicationCode/ProjectDataModel/RimGridTimeHistoryCurve.cpp @@ -225,13 +225,16 @@ std::vector RimGridTimeHistoryCurve::yValues() const RigCaseCellResultsData* cellResultsData = m_eclipseResultDefinition->currentGridCellResults(); - std::vector timeStepDates = cellResultsData->timeStepDates(); + if ( cellResultsData ) + { + std::vector timeStepDates = cellResultsData->timeStepDates(); - values = RigTimeHistoryResultAccessor::timeHistoryValues( eclTopItem->eclipseCase()->eclipseCaseData(), - m_eclipseResultDefinition(), - gridIndex, - cellIndex, - timeStepDates.size() ); + values = RigTimeHistoryResultAccessor::timeHistoryValues( eclTopItem->eclipseCase()->eclipseCaseData(), + m_eclipseResultDefinition(), + gridIndex, + cellIndex, + timeStepDates.size() ); + } } if ( geoMechGeomSelectionItem() && geoMechGeomSelectionItem()->geoMechCase() ) @@ -464,11 +467,14 @@ std::vector RimGridTimeHistoryCurve::timeStepValues() const { RigCaseCellResultsData* cellResultsData = m_eclipseResultDefinition->currentGridCellResults(); - std::vector timeStepDates = cellResultsData->timeStepDates(); - - for ( QDateTime dt : timeStepDates ) + if ( cellResultsData ) { - dateTimes.push_back( dt.toTime_t() ); + std::vector timeStepDates = cellResultsData->timeStepDates(); + + for ( QDateTime dt : timeStepDates ) + { + dateTimes.push_back( dt.toTime_t() ); + } } } @@ -512,7 +518,10 @@ std::vector RimGridTimeHistoryCurve::daysSinceSimulationStart() const { RigCaseCellResultsData* cellResultsData = m_eclipseResultDefinition->currentGridCellResults(); - daysSinceSimulationStart = cellResultsData->daysSinceSimulationStart(); + if ( cellResultsData ) + { + daysSinceSimulationStart = cellResultsData->daysSinceSimulationStart(); + } } RimGeoMechGeometrySelectionItem* geoMechTopItem = geoMechGeomSelectionItem(); From 695571c2b07474cdbb9b3d1de4e8fb4377de55a6 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Sat, 18 Apr 2020 09:20:40 +0200 Subject: [PATCH 02/46] LibEcl : Add missing include for latest VS2019 --- ThirdParty/Ert/lib/ecl/ecl_smspec.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/ThirdParty/Ert/lib/ecl/ecl_smspec.cpp b/ThirdParty/Ert/lib/ecl/ecl_smspec.cpp index a99cf7ab8b..11e769b7f5 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_smspec.cpp +++ b/ThirdParty/Ert/lib/ecl/ecl_smspec.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include #include From eeb90fcdeab0312710e0703a20f6a7febbc411d5 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 29 Apr 2020 19:50:46 +0200 Subject: [PATCH 03/46] #5856 Well Disks : Guard recompute and limit evaluation to visible wells --- .../ProjectDataModel/RimEclipseView.cpp | 4 ++-- .../ProjectDataModel/RimSimWellInView.cpp | 20 +++++++++++++++++++ .../ProjectDataModel/RimSimWellInView.h | 1 + .../RimSimWellInViewCollection.cpp | 19 +++++++++--------- .../RimSimWellInViewCollection.h | 4 ++-- 5 files changed, 35 insertions(+), 13 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp index 2448601b19..25032a69b1 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp @@ -652,7 +652,7 @@ void RimEclipseView::onUpdateDisplayModelForCurrentTimeStep() updateVisibleGeometriesAndCellColors(); - wellCollection()->updateWellDisks(); + wellCollection()->scaleWellDisks(); appendWellsAndFracturesToModel(); @@ -945,7 +945,7 @@ void RimEclipseView::onLoadDataAndUpdate() this->faultCollection()->syncronizeFaults(); - this->m_wellCollection->updateWellDisks(); + this->m_wellCollection->scaleWellDisks(); scheduleReservoirGridGeometryRegen(); m_simWellsPartManager->clearGeometryCache(); diff --git a/ApplicationCode/ProjectDataModel/RimSimWellInView.cpp b/ApplicationCode/ProjectDataModel/RimSimWellInView.cpp index 1cfd675104..dcbfe143a6 100644 --- a/ApplicationCode/ProjectDataModel/RimSimWellInView.cpp +++ b/ApplicationCode/ProjectDataModel/RimSimWellInView.cpp @@ -641,6 +641,26 @@ size_t RimSimWellInView::resultWellIndex() const return m_resultWellIndex; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimSimWellInView::isWellDiskVisible() const +{ + const RimEclipseView* reservoirView = nullptr; + this->firstAncestorOrThisOfType( reservoirView ); + + if ( reservoirView == nullptr ) return false; + if ( this->simWellData() == nullptr ) return false; + + if ( !reservoirView->wellCollection()->isActive() ) return false; + + if ( !this->showWell() ) return false; + + if ( !this->showWellDisks() ) return false; + + return true; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimSimWellInView.h b/ApplicationCode/ProjectDataModel/RimSimWellInView.h index d37b1339aa..01da2e1900 100644 --- a/ApplicationCode/ProjectDataModel/RimSimWellInView.h +++ b/ApplicationCode/ProjectDataModel/RimSimWellInView.h @@ -61,6 +61,7 @@ public: const RigSimWellData* simWellData() const; size_t resultWellIndex() const; + bool isWellDiskVisible() const; bool isWellCellsVisible() const; bool isWellPipeVisible( size_t frameIndex ) const; bool isWellSpheresVisible( size_t frameIndex ) const; diff --git a/ApplicationCode/ProjectDataModel/RimSimWellInViewCollection.cpp b/ApplicationCode/ProjectDataModel/RimSimWellInViewCollection.cpp index c17740798a..0e7fd32cec 100644 --- a/ApplicationCode/ProjectDataModel/RimSimWellInViewCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimSimWellInViewCollection.cpp @@ -508,8 +508,6 @@ void RimSimWellInViewCollection::fieldChangedByUi( const caf::PdmFieldHandle* ch if ( &isActive == changedField || &m_showWellLabel == changedField || &m_showWellCells == changedField || &m_showWellCellFence == changedField || &wellCellFenceType == changedField ) { - RimWellDiskConfig wellDiskConfig = getActiveWellDiskConfig(); - updateWellDisks( wellDiskConfig ); m_reservoirView->scheduleGeometryRegen( VISIBLE_WELL_CELLS ); m_reservoirView->scheduleCreateDisplayModelAndRedraw(); } @@ -520,11 +518,9 @@ void RimSimWellInViewCollection::fieldChangedByUi( const caf::PdmFieldHandle* ch else if ( &m_wellDiskQuantity == changedField || &m_wellDiskPropertyType == changedField || &m_wellDiskPropertyConfigType == changedField || &m_wellDiskshowLabelsBackground == changedField || &m_wellDiskShowQuantityLabels == changedField || &m_wellDiskSummaryCase == changedField || - &m_wellDiskScaleFactor == changedField || &m_showWellDisks == changedField || - &wellDiskColor == changedField ) + &m_wellDiskScaleFactor == changedField || &wellDiskColor == changedField || + &m_showWellDisks == changedField ) { - RimWellDiskConfig wellDiskConfig = getActiveWellDiskConfig(); - updateWellDisks( wellDiskConfig ); m_reservoirView->updateDisplayModelForCurrentTimeStepAndRedraw(); } else if ( &spheresScaleFactor == changedField || &m_showWellSpheres == changedField || @@ -1057,21 +1053,26 @@ bool RimSimWellInViewCollection::showWellDiskQuantityLables() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSimWellInViewCollection::updateWellDisks() +void RimSimWellInViewCollection::scaleWellDisks() { + if ( !isActive ) return; + if ( m_showWellDisks().isFalse() ) return; + RimWellDiskConfig wellDiskConfig = getActiveWellDiskConfig(); - updateWellDisks( wellDiskConfig ); + scaleWellDisksFromConfig( wellDiskConfig ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSimWellInViewCollection::updateWellDisks( const RimWellDiskConfig& wellDiskConfig ) +void RimSimWellInViewCollection::scaleWellDisksFromConfig( const RimWellDiskConfig& wellDiskConfig ) { double minValue = std::numeric_limits::max(); double maxValue = -minValue; for ( RimSimWellInView* w : wells ) { + if ( !w->isWellDiskVisible() ) continue; + bool isOk = true; double value = w->calculateInjectionProductionFractions( wellDiskConfig, &isOk ); if ( isOk ) diff --git a/ApplicationCode/ProjectDataModel/RimSimWellInViewCollection.h b/ApplicationCode/ProjectDataModel/RimSimWellInViewCollection.h index a7c49cf0c5..d87bb5a20e 100644 --- a/ApplicationCode/ProjectDataModel/RimSimWellInViewCollection.h +++ b/ApplicationCode/ProjectDataModel/RimSimWellInViewCollection.h @@ -158,7 +158,7 @@ public: static void updateWellAllocationPlots(); void setDefaultSourceCaseForWellDisks(); - void updateWellDisks(); + void scaleWellDisks(); double wellDiskScaleFactor() const; caf::PdmField wellDiskColor; @@ -177,7 +177,7 @@ protected: private: void calculateWellGeometryVisibility( size_t frameIndex ); void updateStateFromEnabledChildCount( size_t showLabelCount, caf::PdmField* fieldToUpdate ); - void updateWellDisks( const RimWellDiskConfig& wellDiskConfig ); + void scaleWellDisksFromConfig( const RimWellDiskConfig& wellDiskConfig ); RimWellDiskConfig getActiveWellDiskConfig() const; private: From 4d98a8d502277fd3e3c5ca4aed4045e2d1d58d05 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 30 Apr 2020 07:27:56 +0200 Subject: [PATCH 04/46] #5856 Well Disks: Convert to time_t once instead of N times --- ApplicationCode/ProjectDataModel/RimSimWellInViewTools.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimSimWellInViewTools.cpp b/ApplicationCode/ProjectDataModel/RimSimWellInViewTools.cpp index f1653fb54c..b7be62d388 100644 --- a/ApplicationCode/ProjectDataModel/RimSimWellInViewTools.cpp +++ b/ApplicationCode/ProjectDataModel/RimSimWellInViewTools.cpp @@ -184,10 +184,12 @@ double RimSimWellInViewTools::extractValueForTimeStep( RifSummaryReaderInterface // Find the data point which best matches the selected time step std::vector resampledTimeSteps = resampler.resampledTimeSteps(); std::vector resampledValues = resampler.resampledValues(); + + time_t currentTime_t = currentDate.toTime_t(); + for ( unsigned int i = 0; i < resampledTimeSteps.size(); i++ ) { - QDateTime t = QDateTime::fromTime_t( resampledTimeSteps[i] ); - if ( t > currentDate ) + if ( resampledTimeSteps[i] > currentTime_t ) { *isOk = true; return resampledValues[i]; From 5de98ea7b045438d68991190be5a99ec29aa529f Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 27 Apr 2020 09:42:15 +0200 Subject: [PATCH 05/46] #5847 Eclipse Ascii Case: Import of properties with comment in header fails --- .../RifEclipseInputFileTools.cpp | 50 ++++++++++++++----- 1 file changed, 38 insertions(+), 12 deletions(-) diff --git a/ApplicationCode/FileInterface/RifEclipseInputFileTools.cpp b/ApplicationCode/FileInterface/RifEclipseInputFileTools.cpp index 9b06a825e0..5cd530d117 100644 --- a/ApplicationCode/FileInterface/RifEclipseInputFileTools.cpp +++ b/ApplicationCode/FileInterface/RifEclipseInputFileTools.cpp @@ -846,24 +846,50 @@ bool RifEclipseInputFileTools::readProperty( const QString& fileName, return false; } - ecl_kw_type* eclipseKeywordData = ecl_kw_fscanf_alloc_grdecl_dynamic__( filePointer, - eclipseKeyWord.toLatin1().data(), - false, - ecl_type_create_from_type( ECL_FLOAT_TYPE ) ); - bool isOk = false; - if ( eclipseKeywordData ) + qint64 filePos = -1; + { - QString errMsg; - isOk = readDataFromKeyword( eclipseKeywordData, caseData, resultName, &errMsg ); - if ( !isOk ) + std::vector keywordsAndFilePos; + findKeywordsOnFile( fileName, &keywordsAndFilePos ); + for ( auto kwAndPos : keywordsAndFilePos ) { - RiaLogging::error( QString( "Failed to read property: %1" ).arg( errMsg ) ); + if ( kwAndPos.keyword == eclipseKeyWord ) + { + filePos = kwAndPos.filePos; + } } - ecl_kw_free( eclipseKeywordData ); + } + + bool isOk = false; + + if ( filePos == -1 ) + { + RiaLogging::error( QString( "Failed to load keyword %1 from file: %2" ).arg( eclipseKeyWord ).arg( fileName ) ); } else { - RiaLogging::error( QString( "Failed to load keyword %1 from file: %2" ).arg( eclipseKeyWord ).arg( fileName ) ); + fseek( filePointer, filePos, SEEK_SET ); + + ecl_kw_type* eclipseKeywordData = + ecl_kw_fscanf_alloc_grdecl_dynamic__( filePointer, + eclipseKeyWord.toLatin1().data(), + false, + ecl_type_create_from_type( ECL_FLOAT_TYPE ) ); + + if ( eclipseKeywordData ) + { + QString errMsg; + isOk = readDataFromKeyword( eclipseKeywordData, caseData, resultName, &errMsg ); + if ( !isOk ) + { + RiaLogging::error( QString( "Failed to read property: %1" ).arg( errMsg ) ); + } + ecl_kw_free( eclipseKeywordData ); + } + else + { + RiaLogging::error( QString( "Failed to load keyword %1 from file: %2" ).arg( eclipseKeyWord ).arg( fileName ) ); + } } fclose( filePointer ); From 41a4e470d39ccd241b5b7b134a30bbee768903d0 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 30 Apr 2020 07:45:36 +0200 Subject: [PATCH 06/46] #5852 3D view: Avoid creation of viz objects in clearGeometryCache m_geometries[geomType].clearAndSetReservoir( geomType, rimEclipseCase, m_reservoirView ) was causing relative heavy performance issues. This is related to several structures being allocated and initialized in constructor in some visusualization object. Preferred workflow: Mark the geometry for recreation using the flag, and do the actual work when visualization is to be created. --- .../ModelVisualization/RivReservoirViewPartMgr.cpp | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.cpp b/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.cpp index e9c8e896d1..fe1639e3cc 100644 --- a/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.cpp @@ -162,11 +162,6 @@ void RivReservoirViewPartMgr::clearGeometryCache( RivCellSetEnum geomType ) for ( size_t i = 0; i < m_propFilteredGeometryFramesNeedsRegen.size(); ++i ) { m_propFilteredGeometryFramesNeedsRegen[i] = true; - if ( m_propFilteredGeometryFrames[i].notNull() ) - { - m_propFilteredGeometryFrames[i]->clearAndSetReservoir( geomType, rimEclipseCase, m_reservoirView ); - m_propFilteredGeometryFrames[i]->setTransform( m_scaleTransform.p() ); - } } } else if ( geomType == PROPERTY_FILTERED_WELL_CELLS ) @@ -174,18 +169,11 @@ void RivReservoirViewPartMgr::clearGeometryCache( RivCellSetEnum geomType ) for ( size_t i = 0; i < m_propFilteredWellGeometryFramesNeedsRegen.size(); ++i ) { m_propFilteredWellGeometryFramesNeedsRegen[i] = true; - if ( m_propFilteredWellGeometryFrames[i].notNull() ) - { - m_propFilteredWellGeometryFrames[i]->clearAndSetReservoir( geomType, rimEclipseCase, m_reservoirView ); - m_propFilteredWellGeometryFrames[i]->setTransform( m_scaleTransform.p() ); - } } } else { m_geometriesNeedsRegen[geomType] = true; - m_geometries[geomType].clearAndSetReservoir( geomType, rimEclipseCase, m_reservoirView ); - m_geometries[geomType].setTransform( m_scaleTransform.p() ); } } From fdd3625bc21a2c8d29f8c6e7557beaa813ca181f Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 30 Apr 2020 08:18:18 +0200 Subject: [PATCH 07/46] #5852 3D view: Avoid more work than required --- .../ProjectDataModel/RimSimWellInViewCollection.cpp | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimSimWellInViewCollection.cpp b/ApplicationCode/ProjectDataModel/RimSimWellInViewCollection.cpp index 0e7fd32cec..9c4c00f647 100644 --- a/ApplicationCode/ProjectDataModel/RimSimWellInViewCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimSimWellInViewCollection.cpp @@ -505,8 +505,8 @@ void RimSimWellInViewCollection::fieldChangedByUi( const caf::PdmFieldHandle* ch setDefaultSourceCaseForWellDisks(); } - if ( &isActive == changedField || &m_showWellLabel == changedField || &m_showWellCells == changedField || - &m_showWellCellFence == changedField || &wellCellFenceType == changedField ) + if ( &isActive == changedField || &m_showWellCells == changedField || &m_showWellCellFence == changedField || + &wellCellFenceType == changedField || &showWellsIntersectingVisibleCells == changedField ) { m_reservoirView->scheduleGeometryRegen( VISIBLE_WELL_CELLS ); m_reservoirView->scheduleCreateDisplayModelAndRedraw(); @@ -519,7 +519,7 @@ void RimSimWellInViewCollection::fieldChangedByUi( const caf::PdmFieldHandle* ch &m_wellDiskPropertyConfigType == changedField || &m_wellDiskshowLabelsBackground == changedField || &m_wellDiskShowQuantityLabels == changedField || &m_wellDiskSummaryCase == changedField || &m_wellDiskScaleFactor == changedField || &wellDiskColor == changedField || - &m_showWellDisks == changedField ) + &m_showWellDisks == changedField || &m_showWellLabel == changedField ) { m_reservoirView->updateDisplayModelForCurrentTimeStepAndRedraw(); } @@ -540,12 +540,6 @@ void RimSimWellInViewCollection::fieldChangedByUi( const caf::PdmFieldHandle* ch for ( RimSimWellInView* w : wells ) w->schedule2dIntersectionViewUpdate(); } - else if ( &showWellsIntersectingVisibleCells == changedField ) - { - m_reservoirView->scheduleGeometryRegen( VISIBLE_WELL_CELLS ); - m_reservoirView->scheduleSimWellGeometryRegen(); - m_reservoirView->scheduleCreateDisplayModelAndRedraw(); - } } if ( &m_wellPipeColors == changedField || &m_defaultWellPipeColor == changedField ) From 943d9772980e2fd91b4187d44490a0f0e710f6e0 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 4 May 2020 13:27:09 +0200 Subject: [PATCH 08/46] #5856 Well Disks : Improve logic to guard when geometry is created --- ApplicationCode/ModelVisualization/RivWellDiskPartMgr.cpp | 2 +- ApplicationCode/ProjectDataModel/RimSimWellInView.cpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/ApplicationCode/ModelVisualization/RivWellDiskPartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellDiskPartMgr.cpp index e02a72879e..5f88174dc4 100644 --- a/ApplicationCode/ModelVisualization/RivWellDiskPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellDiskPartMgr.cpp @@ -468,7 +468,7 @@ void RivWellDiskPartMgr::appendDynamicGeometryPartsToModel( cvf::ModelBasicList* if ( m_rimWell.isNull() ) return; if ( !viewWithSettings() ) return; - if ( !m_rimWell->isWellPipeVisible( frameIndex ) ) return; + if ( !m_rimWell->isWellDiskVisible() ) return; if ( !m_rimWell->isValidDisk() ) return; buildWellDiskParts( frameIndex, displayXf ); diff --git a/ApplicationCode/ProjectDataModel/RimSimWellInView.cpp b/ApplicationCode/ProjectDataModel/RimSimWellInView.cpp index dcbfe143a6..fc7c625169 100644 --- a/ApplicationCode/ProjectDataModel/RimSimWellInView.cpp +++ b/ApplicationCode/ProjectDataModel/RimSimWellInView.cpp @@ -653,6 +653,7 @@ bool RimSimWellInView::isWellDiskVisible() const if ( this->simWellData() == nullptr ) return false; if ( !reservoirView->wellCollection()->isActive() ) return false; + if ( !reservoirView->wellCollection()->isWellDisksVisible() ) return false; if ( !this->showWell() ) return false; From 6d9985d2ef92b835071cf6c63b8b94432edb839e Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 4 May 2020 15:00:14 +0200 Subject: [PATCH 09/46] #5865 Fault and NNC performance : Build NNC geometry when needed --- .../ModelVisualization/RivFaultPartMgr.cpp | 172 +++++++++++------- .../ModelVisualization/RivFaultPartMgr.h | 10 + 2 files changed, 120 insertions(+), 62 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivFaultPartMgr.cpp b/ApplicationCode/ModelVisualization/RivFaultPartMgr.cpp index aca436e0f7..4099e96b4c 100644 --- a/ApplicationCode/ModelVisualization/RivFaultPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivFaultPartMgr.cpp @@ -64,6 +64,11 @@ RivFaultPartMgr::RivFaultPartMgr( const RigGridBase* grid, , m_rimFault( rimFault ) , m_opacityLevel( 1.0f ) , m_defaultColor( cvf::Color3::WHITE ) + , m_isNativeFaultsGenerated( false ) + , m_isOppositeFaultsGenerated( false ) + , m_isNativeNncsGenerated( false ) + , m_isAllNncsGenerated( false ) + { CVF_ASSERT( rimFault->faultGeometry() ); cvf::ref> connIdxes = new cvf::Array; @@ -100,7 +105,7 @@ void RivFaultPartMgr::setCellVisibility( cvf::UByteArray* cellVisibilities ) m_NNCGenerator->setCellVisibility( cellVisibilities, m_grid.p() ); m_allenNNCGenerator->setCellVisibility( cellVisibilities, m_grid.p() ); - generatePartGeometry(); + clearFlags(); } //-------------------------------------------------------------------------------------------------- @@ -379,73 +384,96 @@ void RivFaultPartMgr::generatePartGeometry() } } - { - cvf::ref geo = m_NNCGenerator->generateSurface(); - if ( geo.notNull() ) - { - geo->computeNormals(); - - if ( useBufferObjects ) - { - geo->setRenderMode( cvf::DrawableGeo::BUFFER_OBJECT ); - } - - cvf::ref part = new cvf::Part; - part->setName( "NNC in Fault. Grid " + cvf::String( static_cast( m_grid->gridIndex() ) ) ); - part->setDrawable( geo.p() ); - - // Set mapping from triangle face index to cell index - cvf::ref si = new RivSourceInfo( m_rimFault, m_grid->gridIndex() ); - si->m_NNCIndices = m_NNCGenerator->triangleToNNCIndex().p(); - part->setSourceInfo( si.p() ); - - part->updateBoundingBox(); - part->setEnableMask( faultBit ); - part->setPriority( RivPartPriority::PartType::Nnc ); - - cvf::ref eff = new cvf::Effect; - part->setEffect( eff.p() ); - - m_NNCFaces = part; - } - } - - { - cvf::ref geo = m_allenNNCGenerator->generateSurface(); - if ( geo.notNull() ) - { - geo->computeNormals(); - - if ( useBufferObjects ) - { - geo->setRenderMode( cvf::DrawableGeo::BUFFER_OBJECT ); - } - - cvf::ref part = new cvf::Part; - part->setName( "Allen NNC in Fault. Grid " + cvf::String( static_cast( m_grid->gridIndex() ) ) ); - part->setDrawable( geo.p() ); - - // Set mapping from triangle face index to cell index - cvf::ref si = new RivSourceInfo( m_rimFault, m_grid->gridIndex() ); - si->m_NNCIndices = m_allenNNCGenerator->triangleToNNCIndex().p(); - part->setSourceInfo( si.p() ); - - part->updateBoundingBox(); - part->setEnableMask( faultBit ); - part->setPriority( RivPartPriority::PartType::Nnc ); - - cvf::ref eff = new cvf::Effect; - part->setEffect( eff.p() ); - - m_allenNNCFaces = part; - } - } + m_isNativeFaultsGenerated = true; + m_isOppositeFaultsGenerated = true; createLabelWithAnchorLine( m_nativeFaultFaces.p() ); updatePartEffect(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivFaultPartMgr::generateNativeNncPartGeometry() +{ + cvf::ref geo = m_NNCGenerator->generateSurface(); + if ( geo.notNull() ) + { + geo->computeNormals(); + geo->setRenderMode( cvf::DrawableGeo::BUFFER_OBJECT ); + + cvf::ref part = new cvf::Part; + part->setName( "NNC in Fault. Grid " + cvf::String( static_cast( m_grid->gridIndex() ) ) ); + part->setDrawable( geo.p() ); + + // Set mapping from triangle face index to cell index + cvf::ref si = new RivSourceInfo( m_rimFault, m_grid->gridIndex() ); + si->m_NNCIndices = m_NNCGenerator->triangleToNNCIndex().p(); + part->setSourceInfo( si.p() ); + + part->updateBoundingBox(); + part->setEnableMask( faultBit ); + part->setPriority( RivPartPriority::PartType::Nnc ); + + cvf::ref eff = new cvf::Effect; + part->setEffect( eff.p() ); + + m_NNCFaces = part; + + updatePartEffect(); + } + + m_isNativeNncsGenerated = true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivFaultPartMgr::generateAllNncPartGeometry() +{ + cvf::ref geo = m_allenNNCGenerator->generateSurface(); + if ( geo.notNull() ) + { + geo->computeNormals(); + + geo->setRenderMode( cvf::DrawableGeo::BUFFER_OBJECT ); + + cvf::ref part = new cvf::Part; + part->setName( "Allen NNC in Fault. Grid " + cvf::String( static_cast( m_grid->gridIndex() ) ) ); + part->setDrawable( geo.p() ); + + // Set mapping from triangle face index to cell index + cvf::ref si = new RivSourceInfo( m_rimFault, m_grid->gridIndex() ); + si->m_NNCIndices = m_allenNNCGenerator->triangleToNNCIndex().p(); + part->setSourceInfo( si.p() ); + + part->updateBoundingBox(); + part->setEnableMask( faultBit ); + part->setPriority( RivPartPriority::PartType::Nnc ); + + cvf::ref eff = new cvf::Effect; + part->setEffect( eff.p() ); + + m_allenNNCFaces = part; + + updatePartEffect(); + } + + m_isAllNncsGenerated = true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivFaultPartMgr::clearFlags() +{ + m_isNativeFaultsGenerated = false; + m_isOppositeFaultsGenerated = false; + m_isNativeNncsGenerated = false; + m_isAllNncsGenerated = false; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -651,6 +679,11 @@ cvf::Vec3f RivFaultPartMgr::findClosestVertex( const cvf::Vec3f& point, const cv //-------------------------------------------------------------------------------------------------- void RivFaultPartMgr::appendNativeFaultFacesToModel( cvf::ModelBasicList* model ) { + if ( !m_isNativeFaultsGenerated ) + { + generatePartGeometry(); + } + if ( m_nativeFaultFaces.notNull() ) { model->addPart( m_nativeFaultFaces.p() ); @@ -662,6 +695,11 @@ void RivFaultPartMgr::appendNativeFaultFacesToModel( cvf::ModelBasicList* model //-------------------------------------------------------------------------------------------------- void RivFaultPartMgr::appendOppositeFaultFacesToModel( cvf::ModelBasicList* model ) { + if ( !m_isOppositeFaultsGenerated ) + { + generatePartGeometry(); + } + if ( m_oppositeFaultFaces.notNull() ) { model->addPart( m_oppositeFaultFaces.p() ); @@ -691,6 +729,11 @@ void RivFaultPartMgr::appendMeshLinePartsToModel( cvf::ModelBasicList* model ) //-------------------------------------------------------------------------------------------------- void RivFaultPartMgr::appendCompleteNNCFacesToModel( cvf::ModelBasicList* model ) { + if ( !m_isAllNncsGenerated ) + { + generateAllNncPartGeometry(); + } + if ( m_allenNNCFaces.notNull() ) model->addPart( m_allenNNCFaces.p() ); } @@ -699,6 +742,11 @@ void RivFaultPartMgr::appendCompleteNNCFacesToModel( cvf::ModelBasicList* model //-------------------------------------------------------------------------------------------------- void RivFaultPartMgr::appendNativeNNCFacesToModel( cvf::ModelBasicList* model ) { + if ( !m_isNativeNncsGenerated ) + { + generateNativeNncPartGeometry(); + } + if ( m_NNCFaces.notNull() ) model->addPart( m_NNCFaces.p() ); } diff --git a/ApplicationCode/ModelVisualization/RivFaultPartMgr.h b/ApplicationCode/ModelVisualization/RivFaultPartMgr.h index a8115a0b4d..bb755a053d 100644 --- a/ApplicationCode/ModelVisualization/RivFaultPartMgr.h +++ b/ApplicationCode/ModelVisualization/RivFaultPartMgr.h @@ -71,6 +71,12 @@ public: private: void generatePartGeometry(); + + void generateNativeNncPartGeometry(); + void generateAllNncPartGeometry(); + + void clearFlags(); + void updatePartEffect(); void updateNNCColors( size_t timeStepIndex, RimEclipseCellColors* cellResultColors ); @@ -91,20 +97,24 @@ private: cvf::ref m_cellVisibility; + bool m_isNativeFaultsGenerated; cvf::ref m_nativeFaultGenerator; cvf::ref m_nativeFaultFaces; cvf::ref m_nativeFaultGridLines; cvf::ref m_nativeFaultFacesTextureCoords; + bool m_isOppositeFaultsGenerated; cvf::ref m_oppositeFaultGenerator; cvf::ref m_oppositeFaultFaces; cvf::ref m_oppositeFaultGridLines; cvf::ref m_oppositeFaultFacesTextureCoords; + bool m_isNativeNncsGenerated; cvf::ref m_NNCGenerator; cvf::ref m_NNCFaces; cvf::ref m_NNCTextureCoords; + bool m_isAllNncsGenerated; cvf::ref m_allenNNCGenerator; cvf::ref m_allenNNCFaces; cvf::ref m_allenNNCTextureCoords; From cc803b5c38e33b8abcb4cc171d3041e4649b787c Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 5 May 2020 12:52:02 +0200 Subject: [PATCH 10/46] Set version to 2020.04.1-RC01 --- ResInsightVersion.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ResInsightVersion.cmake b/ResInsightVersion.cmake index dbf2b03832..1e4c38f616 100644 --- a/ResInsightVersion.cmake +++ b/ResInsightVersion.cmake @@ -1,10 +1,10 @@ set(RESINSIGHT_MAJOR_VERSION 2020) set(RESINSIGHT_MINOR_VERSION 04) -set(RESINSIGHT_PATCH_VERSION 0) +set(RESINSIGHT_PATCH_VERSION 1) # Opional text with no restrictions -#set(RESINSIGHT_VERSION_TEXT "-RC01") +set(RESINSIGHT_VERSION_TEXT "-RC01") # Optional text # Must be unique and increasing within one combination of major/minor/patch version From 00cd16ed4fd453d159f15bf0f28df44ae10d7160 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 12 May 2020 08:26:22 +0200 Subject: [PATCH 11/46] Fix misspelled Allan diagram (#5906) Closes #5816 --- ApplicationCode/Application/RiaDefines.cpp | 10 +-- ApplicationCode/Application/RiaDefines.h | 6 +- .../Python/rips/tests/test_nnc_properties.py | 12 +-- .../ModelVisualization/RivFaultPartMgr.cpp | 38 ++++----- .../ModelVisualization/RivFaultPartMgr.h | 6 +- .../RivNNCGeometryGenerator.cpp | 8 +- .../RivNNCGeometryGenerator.h | 4 +- .../RivReservoirFaultsPartMgr.cpp | 2 +- .../RimEclipseResultDefinition.cpp | 27 ++++-- .../ProjectDataModel/RimEclipseView.cpp | 2 +- .../RimRegularLegendConfig.cpp | 19 +++-- .../ReservoirDataModel/CMakeLists_files.cmake | 8 +- ...iagramData.cpp => RigAllanDiagramData.cpp} | 6 +- ...lenDiagramData.h => RigAllanDiagramData.h} | 6 +- .../RigCaseCellResultsData.cpp | 84 +++++++++---------- .../RigCaseCellResultsData.h | 8 +- ....cpp => RigEclipseAllanFaultsStatCalc.cpp} | 18 ++-- ...Calc.h => RigEclipseAllanFaultsStatCalc.h} | 4 +- .../ReservoirDataModel/RigEclipseCaseData.cpp | 4 +- .../ReservoirDataModel/RigEclipseCaseData.h | 4 +- .../UserInterface/RiuResultTextBuilder.cpp | 12 +-- 21 files changed, 154 insertions(+), 134 deletions(-) rename ApplicationCode/ReservoirDataModel/{RigAllenDiagramData.cpp => RigAllanDiagramData.cpp} (91%) rename ApplicationCode/ReservoirDataModel/{RigAllenDiagramData.h => RigAllanDiagramData.h} (93%) rename ApplicationCode/ReservoirDataModel/{RigEclipseAllenFaultsStatCalc.cpp => RigEclipseAllanFaultsStatCalc.cpp} (87%) rename ApplicationCode/ReservoirDataModel/{RigEclipseAllenFaultsStatCalc.h => RigEclipseAllanFaultsStatCalc.h} (94%) diff --git a/ApplicationCode/Application/RiaDefines.cpp b/ApplicationCode/Application/RiaDefines.cpp index 037162e062..f459d77fc0 100644 --- a/ApplicationCode/Application/RiaDefines.cpp +++ b/ApplicationCode/Application/RiaDefines.cpp @@ -33,7 +33,7 @@ void caf::AppEnum::setUp() addItem( RiaDefines::GENERATED, "GENERATED", "Generated" ); addItem( RiaDefines::INPUT_PROPERTY, "INPUT_PROPERTY", "Input Property" ); addItem( RiaDefines::FORMATION_NAMES, "FORMATION_NAMES", "Formation Names" ); - addItem( RiaDefines::ALLEN_DIAGRAMS, "ALLEN_DIAGRAMS", "Allen Diagrams" ); + addItem( RiaDefines::ALLAN_DIAGRAMS, "ALLAN_DIAGRAMS", "Allan Diagrams" ); addItem( RiaDefines::FLOW_DIAGNOSTICS, "FLOW_DIAGNOSTICS", "Flow Diagnostics" ); addItem( RiaDefines::INJECTION_FLOODING, "INJECTION_FLOODING", "Injection Flooding" ); setDefault( RiaDefines::DYNAMIC_NATIVE ); @@ -373,17 +373,17 @@ QString RiaDefines::completionTypeResultName() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RiaDefines::formationBinaryAllenResultName() +QString RiaDefines::formationBinaryAllanResultName() { - return "Binary Formation Allen"; + return "Binary Formation Allan"; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RiaDefines::formationAllenResultName() +QString RiaDefines::formationAllanResultName() { - return "Formation Allen"; + return "Formation Allan"; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Application/RiaDefines.h b/ApplicationCode/Application/RiaDefines.h index 3f79b25b31..04385e6e40 100644 --- a/ApplicationCode/Application/RiaDefines.h +++ b/ApplicationCode/Application/RiaDefines.h @@ -33,7 +33,7 @@ enum ResultCatType GENERATED, INPUT_PROPERTY, FORMATION_NAMES, - ALLEN_DIAGRAMS, + ALLAN_DIAGRAMS, FLOW_DIAGNOSTICS, INJECTION_FLOODING, REMOVED, @@ -106,8 +106,8 @@ QString mobilePoreVolumeName(); QString completionTypeResultName(); // Fault results -QString formationBinaryAllenResultName(); -QString formationAllenResultName(); +QString formationBinaryAllanResultName(); +QString formationAllanResultName(); // Mock model text identifiers QString mockModelBasic(); diff --git a/ApplicationCode/GrpcInterface/Python/rips/tests/test_nnc_properties.py b/ApplicationCode/GrpcInterface/Python/rips/tests/test_nnc_properties.py index cf9c6caa97..fa666fa1c1 100644 --- a/ApplicationCode/GrpcInterface/Python/rips/tests/test_nnc_properties.py +++ b/ApplicationCode/GrpcInterface/Python/rips/tests/test_nnc_properties.py @@ -20,9 +20,9 @@ def test_10kSync(rips_instance, initialize_test): assert("TRAN" == properties[0].name) assert(NNCProperties_pb2.NNCPropertyType.Value('NNC_STATIC') == properties[0].property_type) - assert("Binary Formation Allen" == properties[1].name) + assert("Binary Formation Allan" == properties[1].name) assert(NNCProperties_pb2.NNCPropertyType.Value('NNC_GENERATED') == properties[1].property_type) - assert("Formation Allen" == properties[2].name) + assert("Formation Allan" == properties[2].name) assert(NNCProperties_pb2.NNCPropertyType.Value('NNC_GENERATED') == properties[2].property_type) nnc_connections = case.nnc_connections() @@ -40,10 +40,10 @@ def test_10kSync(rips_instance, initialize_test): for t in tran_vals: assert(isinstance(t, float)) - allen_vals = case.nnc_connections_generated_values("Formation Allen", 0) - assert(len(allen_vals) == len(nnc_connections)) + allan_vals = case.nnc_connections_generated_values("Formation Allan", 0) + assert(len(allan_vals) == len(nnc_connections)) - for a in allen_vals: + for a in allan_vals: assert(isinstance(a, float)) # Generate some data @@ -81,4 +81,4 @@ def test_invalid_time_steps(rips_instance, initialize_test): casePath = dataroot.PATH + "/TEST10K_FLT_LGR_NNC/TEST10K_FLT_LGR_NNC.EGRID" case = rips_instance.project.load_case(path=casePath) with pytest.raises(grpc.RpcError): - case.nnc_connections_generated_values("Formation Allen", 9999) + case.nnc_connections_generated_values("Formation Allan", 9999) diff --git a/ApplicationCode/ModelVisualization/RivFaultPartMgr.cpp b/ApplicationCode/ModelVisualization/RivFaultPartMgr.cpp index 4099e96b4c..8b99a4da7d 100644 --- a/ApplicationCode/ModelVisualization/RivFaultPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivFaultPartMgr.cpp @@ -87,12 +87,12 @@ RivFaultPartMgr::RivFaultPartMgr( const RigGridBase* grid, m_NNCTextureCoords = new cvf::Vec2fArray; - m_allenNNCGenerator = new RivNNCGeometryGenerator( true, + m_allanNNCGenerator = new RivNNCGeometryGenerator( true, grid->mainGrid()->nncData(), grid->mainGrid()->displayModelOffset(), connIdxes.p() ); - m_allenNNCTextureCoords = new cvf::Vec2fArray; + m_allanNNCTextureCoords = new cvf::Vec2fArray; } //-------------------------------------------------------------------------------------------------- @@ -103,7 +103,7 @@ void RivFaultPartMgr::setCellVisibility( cvf::UByteArray* cellVisibilities ) m_nativeFaultGenerator->setCellVisibility( cellVisibilities ); m_oppositeFaultGenerator->setCellVisibility( cellVisibilities ); m_NNCGenerator->setCellVisibility( cellVisibilities, m_grid.p() ); - m_allenNNCGenerator->setCellVisibility( cellVisibilities, m_grid.p() ); + m_allanNNCGenerator->setCellVisibility( cellVisibilities, m_grid.p() ); clearFlags(); } @@ -432,7 +432,7 @@ void RivFaultPartMgr::generateNativeNncPartGeometry() //-------------------------------------------------------------------------------------------------- void RivFaultPartMgr::generateAllNncPartGeometry() { - cvf::ref geo = m_allenNNCGenerator->generateSurface(); + cvf::ref geo = m_allanNNCGenerator->generateSurface(); if ( geo.notNull() ) { geo->computeNormals(); @@ -440,12 +440,12 @@ void RivFaultPartMgr::generateAllNncPartGeometry() geo->setRenderMode( cvf::DrawableGeo::BUFFER_OBJECT ); cvf::ref part = new cvf::Part; - part->setName( "Allen NNC in Fault. Grid " + cvf::String( static_cast( m_grid->gridIndex() ) ) ); + part->setName( "Allan NNC in Fault. Grid " + cvf::String( static_cast( m_grid->gridIndex() ) ) ); part->setDrawable( geo.p() ); // Set mapping from triangle face index to cell index cvf::ref si = new RivSourceInfo( m_rimFault, m_grid->gridIndex() ); - si->m_NNCIndices = m_allenNNCGenerator->triangleToNNCIndex().p(); + si->m_NNCIndices = m_allanNNCGenerator->triangleToNNCIndex().p(); part->setSourceInfo( si.p() ); part->updateBoundingBox(); @@ -455,7 +455,7 @@ void RivFaultPartMgr::generateAllNncPartGeometry() cvf::ref eff = new cvf::Effect; part->setEffect( eff.p() ); - m_allenNNCFaces = part; + m_allanNNCFaces = part; updatePartEffect(); } @@ -523,7 +523,7 @@ void RivFaultPartMgr::updatePartEffect() m_oppositeFaultFaces->setPriority( RivPartPriority::PartType::TransparentFault ); if ( m_NNCFaces.notNull() ) m_NNCFaces->setPriority( RivPartPriority::PartType::TransparentNnc ); - if ( m_allenNNCFaces.notNull() ) m_allenNNCFaces->setPriority( RivPartPriority::PartType::TransparentNnc ); + if ( m_allanNNCFaces.notNull() ) m_allanNNCFaces->setPriority( RivPartPriority::PartType::TransparentNnc ); if ( m_nativeFaultGridLines.notNull() ) { @@ -734,7 +734,7 @@ void RivFaultPartMgr::appendCompleteNNCFacesToModel( cvf::ModelBasicList* model generateAllNncPartGeometry(); } - if ( m_allenNNCFaces.notNull() ) model->addPart( m_allenNNCFaces.p() ); + if ( m_allanNNCFaces.notNull() ) model->addPart( m_allanNNCFaces.p() ); } //-------------------------------------------------------------------------------------------------- @@ -798,9 +798,9 @@ caf::FaceCulling RivFaultPartMgr::faceCullingMode() const void RivFaultPartMgr::updateNNCColors( size_t timeStepIndex, RimEclipseCellColors* cellResultColors ) { bool updateNnc = m_NNCFaces.notNull(); - bool updateAllen = m_allenNNCFaces.notNull(); + bool updateAllan = m_allanNNCFaces.notNull(); - if ( !updateNnc && !updateAllen ) + if ( !updateNnc && !updateAllan ) { return; } @@ -843,9 +843,9 @@ void RivFaultPartMgr::updateNNCColors( size_t timeStepIndex, RimEclipseCellColor nativeTimeStepIndex ); } - if ( updateAllen ) + if ( updateAllan ) { - m_allenNNCGenerator->textureCoordinates( m_allenNNCTextureCoords.p(), + m_allanNNCGenerator->textureCoordinates( m_allanNNCTextureCoords.p(), mapper, resultType, eclResAddr, @@ -879,12 +879,12 @@ void RivFaultPartMgr::updateNNCColors( size_t timeStepIndex, RimEclipseCellColor m_NNCFaces->setEffect( nncEffect.p() ); } - if ( updateAllen ) + if ( updateAllan ) { - cvf::DrawableGeo* dg = dynamic_cast( m_allenNNCFaces->drawable() ); - if ( dg ) dg->setTextureCoordArray( m_allenNNCTextureCoords.p() ); + cvf::DrawableGeo* dg = dynamic_cast( m_allanNNCFaces->drawable() ); + if ( dg ) dg->setTextureCoordArray( m_allanNNCTextureCoords.p() ); - m_allenNNCFaces->setEffect( nncEffect.p() ); + m_allanNNCFaces->setEffect( nncEffect.p() ); } } else @@ -916,9 +916,9 @@ void RivFaultPartMgr::updateNNCColors( size_t timeStepIndex, RimEclipseCellColor m_NNCFaces->setEffect( nncEffect.p() ); } - if ( updateAllen ) + if ( updateAllan ) { - m_allenNNCFaces->setEffect( nncEffect.p() ); + m_allanNNCFaces->setEffect( nncEffect.p() ); } } } diff --git a/ApplicationCode/ModelVisualization/RivFaultPartMgr.h b/ApplicationCode/ModelVisualization/RivFaultPartMgr.h index bb755a053d..cc0519b0d9 100644 --- a/ApplicationCode/ModelVisualization/RivFaultPartMgr.h +++ b/ApplicationCode/ModelVisualization/RivFaultPartMgr.h @@ -115,9 +115,9 @@ private: cvf::ref m_NNCTextureCoords; bool m_isAllNncsGenerated; - cvf::ref m_allenNNCGenerator; - cvf::ref m_allenNNCFaces; - cvf::ref m_allenNNCTextureCoords; + cvf::ref m_allanNNCGenerator; + cvf::ref m_allanNNCFaces; + cvf::ref m_allanNNCTextureCoords; cvf::ref m_faultLabelPart; cvf::ref m_faultLabelLinePart; diff --git a/ApplicationCode/ModelVisualization/RivNNCGeometryGenerator.cpp b/ApplicationCode/ModelVisualization/RivNNCGeometryGenerator.cpp index 5d56de94ca..c19912ba91 100644 --- a/ApplicationCode/ModelVisualization/RivNNCGeometryGenerator.cpp +++ b/ApplicationCode/ModelVisualization/RivNNCGeometryGenerator.cpp @@ -31,11 +31,11 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RivNNCGeometryGenerator::RivNNCGeometryGenerator( bool includeAllen, +RivNNCGeometryGenerator::RivNNCGeometryGenerator( bool includeAllan, const RigNNCData* nncData, const cvf::Vec3d& offset, const cvf::Array* nncIndexes ) - : m_includeAllenDiagramGeometry( includeAllen ) + : m_includeAllanDiagramGeometry( includeAllan ) , m_nncData( nncData ) , m_nncIndexes( nncIndexes ) , m_offset( offset ) @@ -90,7 +90,7 @@ void RivNNCGeometryGenerator::computeArrays() { size_t conIdx = m_nncIndexes.isNull() ? nIdx : ( *m_nncIndexes )[nIdx]; - if ( !m_includeAllenDiagramGeometry && conIdx >= m_nncData->nativeConnectionCount() ) + if ( !m_includeAllanDiagramGeometry && conIdx >= m_nncData->nativeConnectionCount() ) { continue; } @@ -164,7 +164,7 @@ void RivNNCGeometryGenerator::textureCoordinates( cvf::Vec2fArray* cvf::Vec2f* rawPtr = textureCoords->ptr(); const std::vector* nncResultVals = nullptr; if ( resultType == RiaDefines::STATIC_NATIVE || resultType == RiaDefines::FORMATION_NAMES || - resultType == RiaDefines::ALLEN_DIAGRAMS ) + resultType == RiaDefines::ALLAN_DIAGRAMS ) { nncResultVals = m_nncData->staticConnectionScalarResult( resVarAddr ); } diff --git a/ApplicationCode/ModelVisualization/RivNNCGeometryGenerator.h b/ApplicationCode/ModelVisualization/RivNNCGeometryGenerator.h index d0c254b67a..548911d61a 100644 --- a/ApplicationCode/ModelVisualization/RivNNCGeometryGenerator.h +++ b/ApplicationCode/ModelVisualization/RivNNCGeometryGenerator.h @@ -42,7 +42,7 @@ class RigEclipseResultAddress; class RivNNCGeometryGenerator : public cvf::Object { public: - RivNNCGeometryGenerator( bool includeAllen, + RivNNCGeometryGenerator( bool includeAllan, const RigNNCData* nncData, const cvf::Vec3d& offset, const cvf::Array* nncIndexes ); @@ -67,7 +67,7 @@ private: void computeArrays(); private: - bool m_includeAllenDiagramGeometry; + bool m_includeAllanDiagramGeometry; // Input cvf::cref m_nncData; diff --git a/ApplicationCode/ModelVisualization/RivReservoirFaultsPartMgr.cpp b/ApplicationCode/ModelVisualization/RivReservoirFaultsPartMgr.cpp index c6e8dc2e3b..878df82b25 100644 --- a/ApplicationCode/ModelVisualization/RivReservoirFaultsPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivReservoirFaultsPartMgr.cpp @@ -169,7 +169,7 @@ void RivReservoirFaultsPartMgr::appendPartsToModel( cvf::ModelBasicList* model ) eclipseResultAddress = cellResultColors->eclipseResultAddress(); } - if ( eclipseResultAddress.m_resultCatType == RiaDefines::ALLEN_DIAGRAMS ) + if ( eclipseResultAddress.m_resultCatType == RiaDefines::ALLAN_DIAGRAMS ) { showCompleteNncGeo = true; } diff --git a/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.cpp b/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.cpp index 1863f13c4d..b054d4b966 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.cpp @@ -28,7 +28,7 @@ #include "RicfCommandObject.h" #include "RigActiveCellInfo.h" -#include "RigAllenDiagramData.h" +#include "RigAllanDiagramData.h" #include "RigCaseCellResultsData.h" #include "RigEclipseCaseData.h" #include "RigEclipseResultInfo.h" @@ -693,7 +693,7 @@ QList continue; } - if ( resType == RiaDefines::ALLEN_DIAGRAMS && !isSeparateFaultResult ) + if ( resType == RiaDefines::ALLAN_DIAGRAMS && !isSeparateFaultResult ) { continue; } @@ -1234,6 +1234,17 @@ void RimEclipseResultDefinition::initAfterRead() assignFlowSolutionFromCase(); } + if ( m_resultVariable == "Formation Allen" ) + { + m_resultVariable = RiaDefines::formationAllanResultName(); + m_resultType = RiaDefines::ResultCatType::ALLAN_DIAGRAMS; + } + else if ( m_resultVariable == "Binary Formation Allen" ) + { + m_resultVariable = RiaDefines::formationBinaryAllanResultName(); + m_resultType = RiaDefines::ResultCatType::ALLAN_DIAGRAMS; + } + m_porosityModelUiField = m_porosityModel; m_resultTypeUiField = m_resultType; m_resultVariableUiField = m_resultVariable; @@ -1406,8 +1417,8 @@ bool RimEclipseResultDefinition::hasCategoryResult() const if ( this->m_resultType() == RiaDefines::FLOW_DIAGNOSTICS && m_resultVariable() == RIG_FLD_MAX_FRACTION_TRACER_RESNAME ) return true; - if ( this->resultVariable() == RiaDefines::formationAllenResultName() || - this->resultVariable() == RiaDefines::formationBinaryAllenResultName() ) + if ( this->resultVariable() == RiaDefines::formationAllanResultName() || + this->resultVariable() == RiaDefines::formationBinaryAllanResultName() ) { return true; } @@ -1891,9 +1902,9 @@ void RimEclipseResultDefinition::updateRangesForExplicitLegends( RimRegularLegen std::vector fnVector = eclipseCaseData->formationNames(); legendConfigToUpdate->setNamedCategoriesInverse( fnVector ); } - else if ( this->resultType() == RiaDefines::ALLEN_DIAGRAMS ) + else if ( this->resultType() == RiaDefines::ALLAN_DIAGRAMS ) { - if ( this->resultVariable() == RiaDefines::formationAllenResultName() ) + if ( this->resultVariable() == RiaDefines::formationAllanResultName() ) { const std::vector fnVector = eclipseCaseData->formationNames(); std::vector fnameIdxes; @@ -1907,7 +1918,7 @@ void RimEclipseResultDefinition::updateRangesForExplicitLegends( RimRegularLegen formationColorMapper->setInterpolateColors( legendBaseColors ); const std::map, int>& formationCombToCathegory = - eclipseCaseData->allenDiagramData()->formationCombinationToCategory(); + eclipseCaseData->allanDiagramData()->formationCombinationToCategory(); std::vector> categories; for ( int frmNameIdx : fnameIdxes ) @@ -1937,7 +1948,7 @@ void RimEclipseResultDefinition::updateRangesForExplicitLegends( RimRegularLegen legendConfigToUpdate->setCategoryItems( categories ); } - else if ( this->resultVariable() == RiaDefines::formationBinaryAllenResultName() ) + else if ( this->resultVariable() == RiaDefines::formationBinaryAllanResultName() ) { std::vector> categories; categories.emplace_back( std::make_tuple( "Same formation", 0, cvf::Color3ub::BROWN ) ); diff --git a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp index 25032a69b1..fee857e5c2 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp @@ -2192,7 +2192,7 @@ bool RimEclipseView::isUsingFormationNames() const { if ( cellResult()->resultType() == RiaDefines::FORMATION_NAMES ) return true; - if ( faultResultSettings()->customFaultResult()->resultType() == RiaDefines::ALLEN_DIAGRAMS ) return true; + if ( faultResultSettings()->customFaultResult()->resultType() == RiaDefines::ALLAN_DIAGRAMS ) return true; return eclipsePropertyFilterCollection()->isUsingFormationNames(); } diff --git a/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.cpp b/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.cpp index 3e43881375..85df791f40 100644 --- a/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.cpp +++ b/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.cpp @@ -541,6 +541,15 @@ void RimRegularLegendConfig::setAutomaticRanges( double globalMin, double global //-------------------------------------------------------------------------------------------------- void RimRegularLegendConfig::initAfterRead() { + if ( resultVariableName == "Binary Formation Allen" ) + { + resultVariableName = RiaDefines::formationBinaryAllanResultName(); + } + else if ( resultVariableName == "Formation Allen" ) + { + resultVariableName = RiaDefines::formationAllanResultName(); + } + updateFieldVisibility(); this->updateUiIconFromToggleField(); @@ -961,7 +970,7 @@ QList if ( rftCurveSet ) hasRftPlotParent = true; bool isCategoryResult = false; - bool isAllenDiagram = false; + bool isAllanDiagram = false; { RimEclipseCellColors* eclCellColors = nullptr; this->firstAncestorOrThisOfType( eclCellColors ); @@ -983,9 +992,9 @@ QList isCategoryResult = true; } - if ( eclCellColors && eclCellColors->resultType() == RiaDefines::ALLEN_DIAGRAMS ) + if ( eclCellColors && eclCellColors->resultType() == RiaDefines::ALLAN_DIAGRAMS ) { - isAllenDiagram = true; + isAllanDiagram = true; } } @@ -996,7 +1005,7 @@ QList // This is an app enum field, see cafInternalPdmFieldTypeSpecializations.h for the default specialization of // this type std::vector mappingTypes; - if ( !isAllenDiagram ) + if ( !isAllanDiagram ) { mappingTypes.push_back( LINEAR_DISCRETE ); @@ -1023,7 +1032,7 @@ QList // This is an app enum field, see cafInternalPdmFieldTypeSpecializations.h for the default specialization of // this type std::vector rangeTypes; - if ( !isAllenDiagram ) + if ( !isAllanDiagram ) { if ( !hasEnsembleCurveSetParent && !hasRftPlotParent ) { diff --git a/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake b/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake index 4f310adfe0..bdf59f710e 100644 --- a/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake +++ b/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake @@ -16,7 +16,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RigCombMultResultAccessor.h ${CMAKE_CURRENT_LIST_DIR}/RigResultModifier.h ${CMAKE_CURRENT_LIST_DIR}/RigResultModifierFactory.h ${CMAKE_CURRENT_LIST_DIR}/RigFormationNames.h -${CMAKE_CURRENT_LIST_DIR}/RigAllenDiagramData.h +${CMAKE_CURRENT_LIST_DIR}/RigAllanDiagramData.h ${CMAKE_CURRENT_LIST_DIR}/RigFlowDiagResultAddress.h ${CMAKE_CURRENT_LIST_DIR}/RigFlowDiagResults.h ${CMAKE_CURRENT_LIST_DIR}/RigFlowDiagResultFrames.h @@ -74,7 +74,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RigGridCrossPlotCurveGrouping.h ${CMAKE_CURRENT_LIST_DIR}/RigEclipseCrossPlotDataExtractor.h ${CMAKE_CURRENT_LIST_DIR}/RigEquil.h ${CMAKE_CURRENT_LIST_DIR}/RigWbsParameter.h -${CMAKE_CURRENT_LIST_DIR}/RigEclipseAllenFaultsStatCalc.h +${CMAKE_CURRENT_LIST_DIR}/RigEclipseAllanFaultsStatCalc.h ${CMAKE_CURRENT_LIST_DIR}/RigCellFaceGeometryTools.h ${CMAKE_CURRENT_LIST_DIR}/RigNncConnection.h ${CMAKE_CURRENT_LIST_DIR}/RigWellDiskData.h @@ -97,7 +97,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RigCombTransResultAccessor.cpp ${CMAKE_CURRENT_LIST_DIR}/RigCombMultResultAccessor.cpp ${CMAKE_CURRENT_LIST_DIR}/RigResultModifierFactory.cpp ${CMAKE_CURRENT_LIST_DIR}/RigFormationNames.cpp -${CMAKE_CURRENT_LIST_DIR}/RigAllenDiagramData.cpp +${CMAKE_CURRENT_LIST_DIR}/RigAllanDiagramData.cpp ${CMAKE_CURRENT_LIST_DIR}/RigFlowDiagResultAddress.cpp ${CMAKE_CURRENT_LIST_DIR}/RigFlowDiagResults.cpp ${CMAKE_CURRENT_LIST_DIR}/RigFlowDiagResultFrames.cpp @@ -149,7 +149,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RigCaseCellResultCalculator.cpp ${CMAKE_CURRENT_LIST_DIR}/RigEclipseCrossPlotDataExtractor.cpp ${CMAKE_CURRENT_LIST_DIR}/RigEquil.cpp ${CMAKE_CURRENT_LIST_DIR}/RigWbsParameter.cpp -${CMAKE_CURRENT_LIST_DIR}/RigEclipseAllenFaultsStatCalc.cpp +${CMAKE_CURRENT_LIST_DIR}/RigEclipseAllanFaultsStatCalc.cpp ${CMAKE_CURRENT_LIST_DIR}/RigCellFaceGeometryTools.cpp ${CMAKE_CURRENT_LIST_DIR}/RigNncConnection.cpp ${CMAKE_CURRENT_LIST_DIR}/RigWellDiskData.cpp diff --git a/ApplicationCode/ReservoirDataModel/RigAllenDiagramData.cpp b/ApplicationCode/ReservoirDataModel/RigAllanDiagramData.cpp similarity index 91% rename from ApplicationCode/ReservoirDataModel/RigAllenDiagramData.cpp rename to ApplicationCode/ReservoirDataModel/RigAllanDiagramData.cpp index 75592dd1eb..fd5ad06e75 100644 --- a/ApplicationCode/ReservoirDataModel/RigAllenDiagramData.cpp +++ b/ApplicationCode/ReservoirDataModel/RigAllanDiagramData.cpp @@ -16,7 +16,7 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RigAllenDiagramData.h" +#include "RigAllanDiagramData.h" #include "RigCaseCellResultsData.h" #include "RigFormationNames.h" @@ -25,13 +25,13 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RigAllenDiagramData::RigAllenDiagramData() +RigAllanDiagramData::RigAllanDiagramData() { } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RigAllenDiagramData::~RigAllenDiagramData() +RigAllanDiagramData::~RigAllanDiagramData() { } diff --git a/ApplicationCode/ReservoirDataModel/RigAllenDiagramData.h b/ApplicationCode/ReservoirDataModel/RigAllanDiagramData.h similarity index 93% rename from ApplicationCode/ReservoirDataModel/RigAllenDiagramData.h rename to ApplicationCode/ReservoirDataModel/RigAllanDiagramData.h index d5c4b458b4..7403674d14 100644 --- a/ApplicationCode/ReservoirDataModel/RigAllenDiagramData.h +++ b/ApplicationCode/ReservoirDataModel/RigAllanDiagramData.h @@ -23,11 +23,11 @@ #include -class RigAllenDiagramData : public cvf::Object +class RigAllanDiagramData : public cvf::Object { public: - RigAllenDiagramData(); - ~RigAllenDiagramData() override; + RigAllanDiagramData(); + ~RigAllanDiagramData() override; const std::map, int>& formationCombinationToCategory() { diff --git a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp index 441ba46b66..0fdaea6cf3 100644 --- a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp +++ b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp @@ -23,7 +23,7 @@ #include "RiaApplication.h" #include "RiaLogging.h" -#include "RigAllenDiagramData.h" +#include "RigAllanDiagramData.h" #include "RigCaseCellResultCalculator.h" #include "RigEclipseCaseData.h" #include "RigEclipseMultiPropertyStatCalc.h" @@ -45,7 +45,7 @@ #include -#include "RigEclipseAllenFaultsStatCalc.h" +#include "RigEclipseAllanFaultsStatCalc.h" #include #include @@ -63,7 +63,7 @@ RigCaseCellResultsData::RigCaseCellResultsData( RigEclipseCaseData* ow m_ownerCaseData = ownerCaseData; m_ownerMainGrid = ownerCaseData->mainGrid(); - m_allenDiagramData = new RigAllenDiagramData; + m_allanDiagramData = new RigAllanDiagramData; } //-------------------------------------------------------------------------------------------------- @@ -426,11 +426,11 @@ size_t RigCaseCellResultsData::findOrCreateScalarResultIndex( const RigEclipseRe QString( "%1K" ).arg( baseName ) ) ); statisticsCalculator = calc; } - else if ( resultName == RiaDefines::formationAllenResultName() || - resultName == RiaDefines::formationBinaryAllenResultName() ) + else if ( resultName == RiaDefines::formationAllanResultName() || + resultName == RiaDefines::formationBinaryAllanResultName() ) { - cvf::ref calc = - new RigEclipseAllenFaultsStatCalc( m_ownerMainGrid->nncData(), resVarAddr ); + cvf::ref calc = + new RigEclipseAllanFaultsStatCalc( m_ownerMainGrid->nncData(), resVarAddr ); statisticsCalculator = calc; } else @@ -912,12 +912,12 @@ void RigCaseCellResultsData::createPlaceholderResultEntries() // Fault results { - findOrCreateScalarResultIndex( RigEclipseResultAddress( RiaDefines::ALLEN_DIAGRAMS, - RiaDefines::formationBinaryAllenResultName() ), + findOrCreateScalarResultIndex( RigEclipseResultAddress( RiaDefines::ALLAN_DIAGRAMS, + RiaDefines::formationBinaryAllanResultName() ), false ); - findOrCreateScalarResultIndex( RigEclipseResultAddress( RiaDefines::ALLEN_DIAGRAMS, - RiaDefines::formationAllenResultName() ), + findOrCreateScalarResultIndex( RigEclipseResultAddress( RiaDefines::ALLAN_DIAGRAMS, + RiaDefines::formationAllanResultName() ), false ); } @@ -1227,10 +1227,10 @@ size_t RigCaseCellResultsData::findOrLoadKnownScalarResult( const RigEclipseResu { computeRiTRANSbyAreaComponent( resultName ); } - else if ( resultName == RiaDefines::formationAllenResultName() || - resultName == RiaDefines::formationBinaryAllenResultName() ) + else if ( resultName == RiaDefines::formationAllanResultName() || + resultName == RiaDefines::formationBinaryAllanResultName() ) { - computeAllenResults( this, m_ownerMainGrid ); + computeAllanResults( this, m_ownerMainGrid ); } } else if ( type == RiaDefines::DYNAMIC_NATIVE ) @@ -2894,7 +2894,7 @@ void RigCaseCellResultsData::setActiveFormationNames( RigFormationNames* activeF } } - computeAllenResults( this, m_ownerMainGrid ); + computeAllanResults( this, m_ownerMainGrid ); } //-------------------------------------------------------------------------------------------------- @@ -2908,9 +2908,9 @@ const RigFormationNames* RigCaseCellResultsData::activeFormationNames() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RigAllenDiagramData* RigCaseCellResultsData::allenDiagramData() +RigAllanDiagramData* RigCaseCellResultsData::allanDiagramData() { - return m_allenDiagramData.p(); + return m_allanDiagramData.p(); } //-------------------------------------------------------------------------------------------------- @@ -3006,7 +3006,7 @@ RigStatisticsDataCache* RigCaseCellResultsData::statistics( const RigEclipseResu //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigCaseCellResultsData::computeAllenResults( RigCaseCellResultsData* cellResultsData, RigMainGrid* mainGrid ) +void RigCaseCellResultsData::computeAllanResults( RigCaseCellResultsData* cellResultsData, RigMainGrid* mainGrid ) { CVF_ASSERT( mainGrid ); CVF_ASSERT( cellResultsData ); @@ -3017,38 +3017,38 @@ void RigCaseCellResultsData::computeAllenResults( RigCaseCellResultsData* cellRe if ( hasFormationData ) { - auto fnAllenResultResAddr = - RigEclipseResultAddress( RiaDefines::ALLEN_DIAGRAMS, RiaDefines::formationAllenResultName() ); - auto fnBinAllenResAddr = - RigEclipseResultAddress( RiaDefines::ALLEN_DIAGRAMS, RiaDefines::formationBinaryAllenResultName() ); + auto fnAllanResultResAddr = + RigEclipseResultAddress( RiaDefines::ALLAN_DIAGRAMS, RiaDefines::formationAllanResultName() ); + auto fnBinAllanResAddr = + RigEclipseResultAddress( RiaDefines::ALLAN_DIAGRAMS, RiaDefines::formationBinaryAllanResultName() ); // Create and retreive nnc result arrays - std::vector& fnAllenNncResults = - mainGrid->nncData()->makeStaticConnectionScalarResult( RiaDefines::formationAllenResultName() ); - std::vector& fnBinAllenNncResults = - mainGrid->nncData()->makeStaticConnectionScalarResult( RiaDefines::formationBinaryAllenResultName() ); + std::vector& fnAllanNncResults = + mainGrid->nncData()->makeStaticConnectionScalarResult( RiaDefines::formationAllanResultName() ); + std::vector& fnBinAllanNncResults = + mainGrid->nncData()->makeStaticConnectionScalarResult( RiaDefines::formationBinaryAllanResultName() ); // Associate them with eclipse result address - mainGrid->nncData()->setEclResultAddress( RiaDefines::formationAllenResultName(), fnAllenResultResAddr ); - mainGrid->nncData()->setEclResultAddress( RiaDefines::formationBinaryAllenResultName(), fnBinAllenResAddr ); + mainGrid->nncData()->setEclResultAddress( RiaDefines::formationAllanResultName(), fnAllanResultResAddr ); + mainGrid->nncData()->setEclResultAddress( RiaDefines::formationBinaryAllanResultName(), fnBinAllanResAddr ); const std::vector& fnData = cellResultsData->cellScalarResults( fnNamesResAddr, 0 ); - // Add a result entry for the special allen grid data (used only for the grid cells without nnc coverage) + // Add a result entry for the special Allan grid data (used only for the grid cells without nnc coverage) - cellResultsData->addStaticScalarResult( RiaDefines::ALLEN_DIAGRAMS, - RiaDefines::formationAllenResultName(), + cellResultsData->addStaticScalarResult( RiaDefines::ALLAN_DIAGRAMS, + RiaDefines::formationAllanResultName(), false, fnData.size() ); - cellResultsData->addStaticScalarResult( RiaDefines::ALLEN_DIAGRAMS, - RiaDefines::formationBinaryAllenResultName(), + cellResultsData->addStaticScalarResult( RiaDefines::ALLAN_DIAGRAMS, + RiaDefines::formationBinaryAllanResultName(), false, fnData.size() ); - std::vector* alData = cellResultsData->modifiableCellScalarResult( fnAllenResultResAddr, 0 ); - std::vector* binAlData = cellResultsData->modifiableCellScalarResult( fnBinAllenResAddr, 0 ); + std::vector* alData = cellResultsData->modifiableCellScalarResult( fnAllanResultResAddr, 0 ); + std::vector* binAlData = cellResultsData->modifiableCellScalarResult( fnBinAllanResAddr, 0 ); ( *alData ) = fnData; @@ -3097,18 +3097,18 @@ void RigCaseCellResultsData::computeAllenResults( RigCaseCellResultsData* cellRe formationCombinationToCategory[formationCombination] = category; } - fnBinAllenNncResults[i] = 1.0; + fnBinAllanNncResults[i] = 1.0; } else { category = formation1; - fnBinAllenNncResults[i] = 0.0; + fnBinAllanNncResults[i] = 0.0; } - fnAllenNncResults[i] = category; + fnAllanNncResults[i] = category; } - cellResultsData->allenDiagramData()->setFormationCombinationToCategorymap( formationCombinationToCategory ); + cellResultsData->allanDiagramData()->setFormationCombinationToCategorymap( formationCombinationToCategory ); } else { @@ -3132,9 +3132,9 @@ void RigCaseCellResultsData::computeAllenResults( RigCaseCellResultsData* cellRe binaryValue = 1.0; } - fnAllenNncResults[i] = k1; - allAllenFormationResults[i] = k1; - fnBinAllenNncResults[i] = binaryValue; + fnAllanNncResults[i] = k1; + allAllanFormationResults[i] = k1; + fnBinAllanNncResults[i] = binaryValue; } #endif } diff --git a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.h b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.h index d1dc69b6fa..a8f2e023b3 100644 --- a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.h +++ b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.h @@ -40,7 +40,7 @@ class RigStatisticsDataCache; class RigEclipseTimeStepInfo; class RigEclipseCaseData; class RigFormationNames; -class RigAllenDiagramData; +class RigAllanDiagramData; class RimEclipseCase; @@ -59,7 +59,7 @@ public: void setHdf5Filename( const QString& hdf5SourSimFilename ); void setActiveFormationNames( RigFormationNames* activeFormationNames ); const RigFormationNames* activeFormationNames() const; - RigAllenDiagramData* allenDiagramData(); + RigAllanDiagramData* allanDiagramData(); void setMainGrid( RigMainGrid* ownerGrid ); void setActiveCellInfo( RigActiveCellInfo* activeCellInfo ); @@ -190,12 +190,12 @@ private: RigStatisticsDataCache* statistics( const RigEclipseResultAddress& resVarAddr ); - static void computeAllenResults( RigCaseCellResultsData* cellResultsData, RigMainGrid* mainGrid ); + static void computeAllanResults( RigCaseCellResultsData* cellResultsData, RigMainGrid* mainGrid ); private: cvf::ref m_readerInterface; cvf::cref m_activeFormationNamesData; - cvf::ref m_allenDiagramData; + cvf::ref m_allanDiagramData; std::vector>> m_cellScalarResults; ///< Scalar results on the complete reservoir for ///< each Result index (ResultVariable) and timestep diff --git a/ApplicationCode/ReservoirDataModel/RigEclipseAllenFaultsStatCalc.cpp b/ApplicationCode/ReservoirDataModel/RigEclipseAllanFaultsStatCalc.cpp similarity index 87% rename from ApplicationCode/ReservoirDataModel/RigEclipseAllenFaultsStatCalc.cpp rename to ApplicationCode/ReservoirDataModel/RigEclipseAllanFaultsStatCalc.cpp index daea254a19..8bf619e8b4 100644 --- a/ApplicationCode/ReservoirDataModel/RigEclipseAllenFaultsStatCalc.cpp +++ b/ApplicationCode/ReservoirDataModel/RigEclipseAllanFaultsStatCalc.cpp @@ -17,7 +17,7 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RigEclipseAllenFaultsStatCalc.h" +#include "RigEclipseAllanFaultsStatCalc.h" #include "RigActiveCellInfo.h" #include "RigCaseCellResultsData.h" @@ -30,7 +30,7 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RigEclipseAllenFaultsStatCalc::RigEclipseAllenFaultsStatCalc( RigNNCData* cellResultsData, +RigEclipseAllanFaultsStatCalc::RigEclipseAllanFaultsStatCalc( RigNNCData* cellResultsData, const RigEclipseResultAddress& scalarResultIndex ) : m_caseData( cellResultsData ) , m_resultAddress( scalarResultIndex ) @@ -40,7 +40,7 @@ RigEclipseAllenFaultsStatCalc::RigEclipseAllenFaultsStatCalc( RigNNCData* //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigEclipseAllenFaultsStatCalc::minMaxCellScalarValues( size_t timeStepIndex, double& min, double& max ) +void RigEclipseAllanFaultsStatCalc::minMaxCellScalarValues( size_t timeStepIndex, double& min, double& max ) { MinMaxAccumulator acc( min, max ); traverseCells( acc, timeStepIndex ); @@ -51,7 +51,7 @@ void RigEclipseAllenFaultsStatCalc::minMaxCellScalarValues( size_t timeStepIndex //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigEclipseAllenFaultsStatCalc::posNegClosestToZero( size_t timeStepIndex, double& pos, double& neg ) +void RigEclipseAllanFaultsStatCalc::posNegClosestToZero( size_t timeStepIndex, double& pos, double& neg ) { PosNegAccumulator acc( pos, neg ); traverseCells( acc, timeStepIndex ); @@ -62,7 +62,7 @@ void RigEclipseAllenFaultsStatCalc::posNegClosestToZero( size_t timeStepIndex, d //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigEclipseAllenFaultsStatCalc::valueSumAndSampleCount( size_t timeStepIndex, double& valueSum, size_t& sampleCount ) +void RigEclipseAllanFaultsStatCalc::valueSumAndSampleCount( size_t timeStepIndex, double& valueSum, size_t& sampleCount ) { SumCountAccumulator acc( valueSum, sampleCount ); traverseCells( acc, timeStepIndex ); @@ -73,7 +73,7 @@ void RigEclipseAllenFaultsStatCalc::valueSumAndSampleCount( size_t timeStepIndex //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigEclipseAllenFaultsStatCalc::addDataToHistogramCalculator( size_t timeStepIndex, +void RigEclipseAllanFaultsStatCalc::addDataToHistogramCalculator( size_t timeStepIndex, RigHistogramCalculator& histogramCalculator ) { traverseCells( histogramCalculator, timeStepIndex ); @@ -82,7 +82,7 @@ void RigEclipseAllenFaultsStatCalc::addDataToHistogramCalculator( size_t //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigEclipseAllenFaultsStatCalc::uniqueValues( size_t timeStepIndex, std::set& values ) +void RigEclipseAllanFaultsStatCalc::uniqueValues( size_t timeStepIndex, std::set& values ) { UniqueValueAccumulator acc; traverseCells( acc, timeStepIndex ); @@ -92,7 +92,7 @@ void RigEclipseAllenFaultsStatCalc::uniqueValues( size_t timeStepIndex, std::set //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -size_t RigEclipseAllenFaultsStatCalc::timeStepCount() +size_t RigEclipseAllanFaultsStatCalc::timeStepCount() { return (size_t)1; } @@ -100,6 +100,6 @@ size_t RigEclipseAllenFaultsStatCalc::timeStepCount() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigEclipseAllenFaultsStatCalc::mobileVolumeWeightedMean( size_t timeStepIndex, double& result ) +void RigEclipseAllanFaultsStatCalc::mobileVolumeWeightedMean( size_t timeStepIndex, double& result ) { } diff --git a/ApplicationCode/ReservoirDataModel/RigEclipseAllenFaultsStatCalc.h b/ApplicationCode/ReservoirDataModel/RigEclipseAllanFaultsStatCalc.h similarity index 94% rename from ApplicationCode/ReservoirDataModel/RigEclipseAllenFaultsStatCalc.h rename to ApplicationCode/ReservoirDataModel/RigEclipseAllanFaultsStatCalc.h index 8f5f394c22..8796dcc781 100644 --- a/ApplicationCode/ReservoirDataModel/RigEclipseAllenFaultsStatCalc.h +++ b/ApplicationCode/ReservoirDataModel/RigEclipseAllanFaultsStatCalc.h @@ -30,10 +30,10 @@ #include "cvfArray.h" -class RigEclipseAllenFaultsStatCalc : public RigStatisticsCalculator +class RigEclipseAllanFaultsStatCalc : public RigStatisticsCalculator { public: - RigEclipseAllenFaultsStatCalc( RigNNCData* cellResultsData, const RigEclipseResultAddress& scalarResultIndex ); + RigEclipseAllanFaultsStatCalc( RigNNCData* cellResultsData, const RigEclipseResultAddress& scalarResultIndex ); void minMaxCellScalarValues( size_t timeStepIndex, double& min, double& max ) override; void posNegClosestToZero( size_t timeStepIndex, double& pos, double& neg ) override; diff --git a/ApplicationCode/ReservoirDataModel/RigEclipseCaseData.cpp b/ApplicationCode/ReservoirDataModel/RigEclipseCaseData.cpp index c2dcae36ed..f4de0e09c2 100644 --- a/ApplicationCode/ReservoirDataModel/RigEclipseCaseData.cpp +++ b/ApplicationCode/ReservoirDataModel/RigEclipseCaseData.cpp @@ -728,9 +728,9 @@ const std::vector RigEclipseCaseData::formationNames() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RigAllenDiagramData* RigEclipseCaseData::allenDiagramData() +RigAllanDiagramData* RigEclipseCaseData::allanDiagramData() { - return m_matrixModelResults->allenDiagramData(); + return m_matrixModelResults->allanDiagramData(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ReservoirDataModel/RigEclipseCaseData.h b/ApplicationCode/ReservoirDataModel/RigEclipseCaseData.h index 77e5a9d479..ebd928a82b 100644 --- a/ApplicationCode/ReservoirDataModel/RigEclipseCaseData.h +++ b/ApplicationCode/ReservoirDataModel/RigEclipseCaseData.h @@ -47,7 +47,7 @@ class RigWellPath; class RimEclipseCase; class RigVirtualPerforationTransmissibilities; class RigEquil; -class RigAllenDiagramData; +class RigAllanDiagramData; struct RigWellResultPoint; @@ -89,7 +89,7 @@ public: void setActiveFormationNames( RigFormationNames* activeFormationNames ); const RigFormationNames* activeFormationNames() const; const std::vector formationNames() const; - RigAllenDiagramData* allenDiagramData(); + RigAllanDiagramData* allanDiagramData(); void setSimWellData( const cvf::Collection& data ); const cvf::Collection& wellResults() const { return m_simWellData; } diff --git a/ApplicationCode/UserInterface/RiuResultTextBuilder.cpp b/ApplicationCode/UserInterface/RiuResultTextBuilder.cpp index 44e5bfe624..0f345f1a35 100644 --- a/ApplicationCode/UserInterface/RiuResultTextBuilder.cpp +++ b/ApplicationCode/UserInterface/RiuResultTextBuilder.cpp @@ -40,7 +40,7 @@ #include "RivExtrudedCurveIntersectionPartMgr.h" -#include "RigAllenDiagramData.h" +#include "RigAllanDiagramData.h" #include "RimIntersectionResultDefinition.h" #include "cafDisplayCoordTransform.h" @@ -323,7 +323,7 @@ QString RiuResultTextBuilder::faultResultDetails() if ( m_viewWithFaultsSettings && m_viewWithFaultsSettings->faultResultSettings()->hasValidCustomResult() ) { if ( m_viewWithFaultsSettings->faultResultSettings()->customFaultResult()->resultType() != - RiaDefines::ALLEN_DIAGRAMS ) + RiaDefines::ALLAN_DIAGRAMS ) { text += "Fault result data:\n"; this->appendTextFromResultColors( eclipseCaseData, @@ -478,16 +478,16 @@ QString RiuResultTextBuilder::nncResultText() text = QString( "%1 : %2" ).arg( resultVar ).arg( scalarValue ); } - if ( resultType == RiaDefines::ALLEN_DIAGRAMS ) + if ( resultType == RiaDefines::ALLAN_DIAGRAMS ) { nncValues = nncData->staticConnectionScalarResult( eclipseResultAddress ); QString resultValueText; if ( m_viewWithFaultsSettings->currentFaultResultColors()->resultVariable() == - RiaDefines::formationAllenResultName() ) + RiaDefines::formationAllanResultName() ) { std::pair fmIndexPair = - eclipseCase->allenDiagramData()->formationIndexCombinationFromCategory( + eclipseCase->allanDiagramData()->formationIndexCombinationFromCategory( ( *nncValues )[m_nncIndex] ); std::vector fmNames = eclipseCase->formationNames(); @@ -503,7 +503,7 @@ QString RiuResultTextBuilder::nncResultText() // clang-format on } else if ( m_viewWithFaultsSettings->currentFaultResultColors()->resultVariable() == - RiaDefines::formationBinaryAllenResultName() ) + RiaDefines::formationBinaryAllanResultName() ) { resultValueText = ( *nncValues )[m_nncIndex] == 0 ? "Same formation" : "Different formation"; } From 0f456714bc0c6754077bd04ac319c5437138f3ef Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Wed, 13 May 2020 13:00:43 +0200 Subject: [PATCH 12/46] #5863 Always use grid for PP0 --- .../RigGeoMechWellLogExtractor.cpp | 25 ++++++++++++++----- .../RigGeoMechWellLogExtractor.h | 8 +++--- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/ApplicationCode/ReservoirDataModel/RigGeoMechWellLogExtractor.cpp b/ApplicationCode/ReservoirDataModel/RigGeoMechWellLogExtractor.cpp index 09dd255782..622a0be8bc 100644 --- a/ApplicationCode/ReservoirDataModel/RigGeoMechWellLogExtractor.cpp +++ b/ApplicationCode/ReservoirDataModel/RigGeoMechWellLogExtractor.cpp @@ -103,7 +103,7 @@ void RigGeoMechWellLogExtractor::performCurveDataSmoothing( int if ( !mds->empty() && !values->empty() ) { - std::vector*> dependentValues = {tvds, &interfaceShValuesDbl, &interfacePorePressuresDbl}; + std::vector*> dependentValues = { tvds, &interfaceShValuesDbl, &interfacePorePressuresDbl }; std::vector smoothOrFilterSegments = determineFilteringOrSmoothing( interfacePorePressuresDbl ); @@ -486,7 +486,8 @@ void RigGeoMechWellLogExtractor::wellPathAngles( const RigFemResultAddress& resA std::vector RigGeoMechWellLogExtractor::wellPathScaledCurveData( const RigFemResultAddress& resAddr, int frameIndex, - std::vector* values ) + std::vector* values, + bool forceGridSourceForPPReservoir /*=false*/ ) { CVF_ASSERT( values ); @@ -499,8 +500,21 @@ std::vector std::vector ppSandValues( m_intersections.size(), std::numeric_limits::infinity() ); std::vector ppShaleValues( m_intersections.size(), std::numeric_limits::infinity() ); - std::vector ppSandSources = - calculateWbsParameterForAllSegments( RigWbsParameter::PP_Reservoir(), frameIndex, &ppSandValues, true ); + std::vector ppSandSources; + if ( forceGridSourceForPPReservoir ) + { + ppSandSources = calculateWbsParameterForAllSegments( RigWbsParameter::PP_Reservoir(), + RigWbsParameter::GRID, + frameIndex, + &ppSandValues, + true ); + } + else + { + ppSandSources = + calculateWbsParameterForAllSegments( RigWbsParameter::PP_Reservoir(), frameIndex, &ppSandValues, true ); + } + std::vector ppShaleSources = calculateWbsParameterForAllSegments( RigWbsParameter::PP_NonReservoir(), 0, &ppShaleValues, true ); @@ -662,8 +676,7 @@ void RigGeoMechWellLogExtractor::wellBoreFGShale( int frameIndex, std::vector K0_FG, OBG0; // parameters RigFemResultAddress ppAddr( RIG_WELLPATH_DERIVED, RiaDefines::wbsPPResult().toStdString(), "" ); - - curveData( ppAddr, 0, &PP0 ); + wellPathScaledCurveData( ppAddr, 0, &PP0, true ); calculateWbsParameterForAllSegments( RigWbsParameter::K0_FG(), frameIndex, &K0_FG, true ); calculateWbsParameterForAllSegments( RigWbsParameter::OBG0(), 0, &OBG0, true ); diff --git a/ApplicationCode/ReservoirDataModel/RigGeoMechWellLogExtractor.h b/ApplicationCode/ReservoirDataModel/RigGeoMechWellLogExtractor.h index cc355cb411..be63f47ee8 100644 --- a/ApplicationCode/ReservoirDataModel/RigGeoMechWellLogExtractor.h +++ b/ApplicationCode/ReservoirDataModel/RigGeoMechWellLogExtractor.h @@ -102,9 +102,11 @@ private: std::vector* values, bool allowNormalization ); - void wellPathAngles( const RigFemResultAddress& resAddr, std::vector* values ); - std::vector - wellPathScaledCurveData( const RigFemResultAddress& resAddr, int frameIndex, std::vector* values ); + void wellPathAngles( const RigFemResultAddress& resAddr, std::vector* values ); + std::vector wellPathScaledCurveData( const RigFemResultAddress& resAddr, + int frameIndex, + std::vector* values, + bool forceGridSourceforPPReservoir = false ); void wellBoreWallCurveData( const RigFemResultAddress& resAddr, int frameIndex, std::vector* values ); void wellBoreFGShale( int frameIndex, std::vector* values ); From 3ac35050bc0eb1d16ef772876e4b7338f0853fa1 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Wed, 13 May 2020 13:01:21 +0200 Subject: [PATCH 13/46] #5888 only apply LAS-PP-values within reservoir --- .../ReservoirDataModel/RigGeoMechWellLogExtractor.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ApplicationCode/ReservoirDataModel/RigGeoMechWellLogExtractor.cpp b/ApplicationCode/ReservoirDataModel/RigGeoMechWellLogExtractor.cpp index 622a0be8bc..627498c7de 100644 --- a/ApplicationCode/ReservoirDataModel/RigGeoMechWellLogExtractor.cpp +++ b/ApplicationCode/ReservoirDataModel/RigGeoMechWellLogExtractor.cpp @@ -244,7 +244,8 @@ std::vector CVF_ASSERT( primary_it != allSources.end() ); std::vector gridValues; - if ( std::find( allSources.begin(), allSources.end(), RigWbsParameter::GRID ) != allSources.end() ) + if ( std::find( allSources.begin(), allSources.end(), RigWbsParameter::GRID ) != allSources.end() || + parameter == RigWbsParameter::PP_Reservoir() ) { RigFemResultAddress nativeAddr = parameter.femAddress( RigWbsParameter::GRID ); @@ -315,7 +316,8 @@ std::vector if ( !lasFileValues.empty() ) { double lasValue = getWellLogIntersectionValue( intersectionIdx, lasFileValues ); - if ( lasValue != std::numeric_limits::infinity() ) + if ( lasValue != std::numeric_limits::infinity() && intersectionIdx < gridValues.size() && + gridValues[intersectionIdx] != std::numeric_limits::infinity() ) { unscaledValues[intersectionIdx] = lasValue; finalSourcesPerSegment[intersectionIdx] = RigWbsParameter::LAS_FILE; From de4fafe744e96cc7a4a86613a82d04bd200215f3 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 13 May 2020 14:37:51 +0200 Subject: [PATCH 14/46] Fix crash in WBS curves when rkb diff is 0 (ported to patch branch) --- .../RimWellLogExtractionCurve.cpp | 7 ++-- .../RigWellLogCurveData.cpp | 32 +++++++++---------- 2 files changed, 19 insertions(+), 20 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimWellLogExtractionCurve.cpp b/ApplicationCode/ProjectDataModel/RimWellLogExtractionCurve.cpp index 4bf3e65f6c..f4be3a33d3 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogExtractionCurve.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellLogExtractionCurve.cpp @@ -350,9 +350,10 @@ void RimWellLogExtractionCurve::onLoadDataAndUpdate( bool updateParentPlot ) isUsingPseudoLength = false; } - m_qwtPlotCurve->setSamples( curveData()->xPlotValues().data(), - curveData()->depthPlotValues( depthType, displayUnit ).data(), - static_cast( curveData()->xPlotValues().size() ) ); + std::vector xPlotValues = curveData()->xPlotValues(); + std::vector depthPlotValues = curveData()->depthPlotValues( depthType, displayUnit ); + CAF_ASSERT( xPlotValues.size() == depthPlotValues.size() ); + m_qwtPlotCurve->setSamples( xPlotValues.data(), depthPlotValues.data(), static_cast( xPlotValues.size() ) ); m_qwtPlotCurve->setLineSegmentStartStopIndices( curveData()->polylineStartStopIndices() ); diff --git a/ApplicationCode/ReservoirDataModel/RigWellLogCurveData.cpp b/ApplicationCode/ReservoirDataModel/RigWellLogCurveData.cpp index 1ecb03904d..bf09fbd313 100644 --- a/ApplicationCode/ReservoirDataModel/RigWellLogCurveData.cpp +++ b/ApplicationCode/ReservoirDataModel/RigWellLogCurveData.cpp @@ -147,27 +147,25 @@ std::vector RigWellLogCurveData::depths( RiaDefines::DepthTypeEnum depth return it->second; } - if ( m_rkbDiff != 0.0 ) + if ( depthType == RiaDefines::TRUE_VERTICAL_DEPTH_RKB && m_depths.count( RiaDefines::TRUE_VERTICAL_DEPTH ) ) { - if ( depthType == RiaDefines::TRUE_VERTICAL_DEPTH_RKB && m_depths.count( RiaDefines::TRUE_VERTICAL_DEPTH ) ) + std::vector tvds = depths( RiaDefines::TRUE_VERTICAL_DEPTH ); + for ( double& tvdValue : tvds ) { - std::vector tvds = depths( RiaDefines::TRUE_VERTICAL_DEPTH ); - for ( double& tvdValue : tvds ) - { - tvdValue += m_rkbDiff; - } - return tvds; - } - else if ( depthType == RiaDefines::TRUE_VERTICAL_DEPTH && m_depths.count( RiaDefines::TRUE_VERTICAL_DEPTH_RKB ) ) - { - std::vector tvds = depths( RiaDefines::TRUE_VERTICAL_DEPTH_RKB ); - for ( double& tvdValue : tvds ) - { - tvdValue -= m_rkbDiff; - } - return tvds; + tvdValue += m_rkbDiff; } + return tvds; } + else if ( depthType == RiaDefines::TRUE_VERTICAL_DEPTH && m_depths.count( RiaDefines::TRUE_VERTICAL_DEPTH_RKB ) ) + { + std::vector tvds = depths( RiaDefines::TRUE_VERTICAL_DEPTH_RKB ); + for ( double& tvdValue : tvds ) + { + tvdValue -= m_rkbDiff; + } + return tvds; + } + return std::vector(); } From ec2a92476717d95d76bd751ae155657ca346e2c7 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Tue, 12 May 2020 18:19:27 +0200 Subject: [PATCH 15/46] #5915 improve performance of NNC computation and limit to active cells --- ApplicationCode/CMakeLists.txt | 4 +- .../FileInterface/RifReaderEclipseOutput.cpp | 6 +- .../Python/rips/tests/test_nnc_properties.py | 2 +- .../RiaGrpcNNCPropertiesService.cpp | 59 +-- .../RimFaultInViewCollection.cpp | 4 +- .../RigCaseCellResultsData.cpp | 6 +- .../RigCellFaceGeometryTools.cpp | 367 +++++++++--------- .../RigCellFaceGeometryTools.h | 16 +- .../ReservoirDataModel/RigMainGrid.cpp | 4 +- .../ReservoirDataModel/RigNNCData.cpp | 15 +- .../ReservoirDataModel/RigNNCData.h | 10 +- .../ReservoirDataModel/RigNncConnection.cpp | 131 ++++++- .../ReservoirDataModel/RigNncConnection.h | 36 +- ...igNumberOfFloodedPoreVolumesCalculator.cpp | 16 +- .../RigNumberOfFloodedPoreVolumesCalculator.h | 16 +- .../RigReservoirBuilderMock.cpp | 18 +- .../RigReservoirBuilderMock.h | 21 +- .../SocketInterface/RiaNNCCommands.cpp | 4 +- Fwk/AppFwk/cafAnimControl/CMakeLists.txt | 2 +- Fwk/AppFwk/cafCommand/CMakeLists.txt | 2 +- ThirdParty/Ert/CMakeLists.txt | 2 +- 21 files changed, 463 insertions(+), 278 deletions(-) diff --git a/ApplicationCode/CMakeLists.txt b/ApplicationCode/CMakeLists.txt index 99ef3bcbb9..63f7e48aad 100644 --- a/ApplicationCode/CMakeLists.txt +++ b/ApplicationCode/CMakeLists.txt @@ -409,9 +409,9 @@ if (MSVC) # warning C4005: Macro redefinition for math constants (M_PI, M_SQRT2 etc) # If possible, the following command is supposed to be the final target - # set_target_properties(ResInsight PROPERTIES COMPILE_FLAGS "/W4 /wd4190 /wd4100 /wd4127") + # set_target_properties(ResInsight PROPERTIES COMPILE_FLAGS "/W3 /wd4190 /wd4100 /wd4127") - set_target_properties(ResInsight PROPERTIES COMPILE_FLAGS "/W4 /wd4190 /wd4100 /wd4127 /wd4245 /wd4005") + set_target_properties(ResInsight PROPERTIES COMPILE_FLAGS "/W3 /wd4190 /wd4100 /wd4127 /wd4245 /wd4005") if (CMAKE_CXX_COMPILER_VERSION LESS_EQUAL 19.14) # The following warning is generated over 800 times from a qwt header only using VS2015 # Disabling temporarily diff --git a/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp b/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp index 430e9a4117..acaed54836 100644 --- a/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp +++ b/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp @@ -722,8 +722,8 @@ void RifReaderEclipseOutput::transferStaticNNCData( const ecl_grid_type* mainEcl if ( numNNC > 0 ) { // Transform to our own data structures - std::vector nncConnections; - std::vector transmissibilityValuesTemp; + RigConnectionContainer nncConnections; + std::vector transmissibilityValuesTemp; const double* transValues = ecl_nnc_data_get_values( tran_data ); @@ -1287,7 +1287,7 @@ size_t localGridCellIndexFromErtConnection( const RigGridBase* grid, cellK = 0; } - // Introduced based on discussion with Håkon Høgstøl 08.09.2016 + // Introduced based on discussion with H�kon H�gst�l 08.09.2016 if ( cellK >= static_cast( grid->cellCountK() ) ) { int maxCellK = static_cast( grid->cellCountK() ); diff --git a/ApplicationCode/GrpcInterface/Python/rips/tests/test_nnc_properties.py b/ApplicationCode/GrpcInterface/Python/rips/tests/test_nnc_properties.py index fa666fa1c1..279f9c529a 100644 --- a/ApplicationCode/GrpcInterface/Python/rips/tests/test_nnc_properties.py +++ b/ApplicationCode/GrpcInterface/Python/rips/tests/test_nnc_properties.py @@ -26,7 +26,7 @@ def test_10kSync(rips_instance, initialize_test): assert(NNCProperties_pb2.NNCPropertyType.Value('NNC_GENERATED') == properties[2].property_type) nnc_connections = case.nnc_connections() - assert(len(nnc_connections) == 84759) + assert(len(nnc_connections) == 3416) connection = nnc_connections[0] assert(connection.cell1.i == 33) diff --git a/ApplicationCode/GrpcInterface/RiaGrpcNNCPropertiesService.cpp b/ApplicationCode/GrpcInterface/RiaGrpcNNCPropertiesService.cpp index 6ec22178b4..d896b364bd 100644 --- a/ApplicationCode/GrpcInterface/RiaGrpcNNCPropertiesService.cpp +++ b/ApplicationCode/GrpcInterface/RiaGrpcNNCPropertiesService.cpp @@ -88,8 +88,8 @@ rips::Vec3i* createConnectionVec3i( const RigCell& cell ) //-------------------------------------------------------------------------------------------------- grpc::Status RiaNNCConnectionsStateHandler::assignReply( rips::NNCConnections* reply ) { - RigMainGrid* mainGrid = m_eclipseCase->eclipseCaseData()->mainGrid(); - std::vector connections = mainGrid->nncData()->connections(); + RigMainGrid* mainGrid = m_eclipseCase->eclipseCaseData()->mainGrid(); + const RigConnectionContainer& connections = mainGrid->nncData()->connections(); size_t connectionCount = connections.size(); const size_t packageSize = RiaGrpcServiceInterface::numberOfDataUnitsInPackage( sizeof( rips::NNCConnection ) ); @@ -97,7 +97,7 @@ grpc::Status RiaNNCConnectionsStateHandler::assignReply( rips::NNCConnections* r reply->mutable_connections()->Reserve( (int)packageSize ); for ( ; indexInPackage < packageSize && m_currentIdx < connectionCount; ++indexInPackage ) { - RigConnection& connection = connections[m_currentIdx]; + RigConnection connection = connections[m_currentIdx]; const RigCell& cell1 = mainGrid->globalCellArray()[connection.m_c1GlobIdx]; const RigCell& cell2 = mainGrid->globalCellArray()[connection.m_c2GlobIdx]; @@ -188,8 +188,8 @@ const std::vector* getScalarResultByName( const RigNNCData* nncD //-------------------------------------------------------------------------------------------------- grpc::Status RiaNNCValuesStateHandler::assignReply( rips::NNCValues* reply ) { - RigMainGrid* mainGrid = m_eclipseCase->eclipseCaseData()->mainGrid(); - std::vector connections = mainGrid->nncData()->connections(); + RigMainGrid* mainGrid = m_eclipseCase->eclipseCaseData()->mainGrid(); + auto connections = mainGrid->nncData()->connections(); QString propertyName = QString::fromStdString( m_request->property_name() ); RigNNCData::NNCResultType propertyType = static_cast( m_request->property_type() ); @@ -496,31 +496,32 @@ std::vector RiaGrpcNNCPropertiesService::createCallba std::vector callbacks; callbacks = - {new RiaGrpcUnaryCallback( this, - &Self::GetAvailableNNCProperties, - &Self::RequestGetAvailableNNCProperties ), - new RiaGrpcServerToClientStreamCallback( this, - &Self::GetNNCConnections, - &Self::RequestGetNNCConnections, - new RiaNNCConnectionsStateHandler ), - new RiaGrpcServerToClientStreamCallback( this, - &Self::GetNNCValues, - &Self::RequestGetNNCValues, - new RiaNNCValuesStateHandler ), + { new RiaGrpcUnaryCallback( this, + &Self::GetAvailableNNCProperties, + &Self::RequestGetAvailableNNCProperties ), + new RiaGrpcServerToClientStreamCallback( this, + &Self::GetNNCConnections, + &Self::RequestGetNNCConnections, + new RiaNNCConnectionsStateHandler ), + new RiaGrpcServerToClientStreamCallback( this, + &Self::GetNNCValues, + &Self::RequestGetNNCValues, + new RiaNNCValuesStateHandler ), - new RiaGrpcClientToServerStreamCallback( this, - &Self::SetNNCValues, - &Self::RequestSetNNCValues, - new RiaNNCInputValuesStateHandler( true ) )}; + new RiaGrpcClientToServerStreamCallback( this, + &Self::SetNNCValues, + &Self::RequestSetNNCValues, + new RiaNNCInputValuesStateHandler( + true ) ) }; return callbacks; } diff --git a/ApplicationCode/ProjectDataModel/RimFaultInViewCollection.cpp b/ApplicationCode/ProjectDataModel/RimFaultInViewCollection.cpp index cca91bc0cb..eb5edd50b0 100644 --- a/ApplicationCode/ProjectDataModel/RimFaultInViewCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimFaultInViewCollection.cpp @@ -266,8 +266,8 @@ void RimFaultInViewCollection::syncronizeFaults() // NNCs this->noCommonAreaNnncCollection()->noCommonAreaNncs().deleteAllChildObjects(); - RigMainGrid* mainGrid = parentView()->mainGrid(); - const std::vector& nncConnections = mainGrid->nncData()->connections(); + RigMainGrid* mainGrid = parentView()->mainGrid(); + const RigConnectionContainer& nncConnections = mainGrid->nncData()->connections(); for ( size_t connIndex = 0; connIndex < nncConnections.size(); connIndex++ ) { if ( !nncConnections[connIndex].hasCommonArea() ) diff --git a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp index 0fdaea6cf3..4e2d96ef06 100644 --- a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp +++ b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp @@ -2239,7 +2239,7 @@ void RigCaseCellResultsData::computeNncCombRiTrans() bool isFaceNormalsOutwards = m_ownerMainGrid->isFaceNormalsOutwards(); // NNC calculation - const std::vector& nncConnections = m_ownerMainGrid->nncData()->connections(); + const RigConnectionContainer& nncConnections = m_ownerMainGrid->nncData()->connections(); for ( size_t connIdx = 0; connIdx < nncConnections.size(); connIdx++ ) { size_t nativeResvCellIndex = nncConnections[connIdx].m_c1GlobIdx; @@ -2601,7 +2601,7 @@ void RigCaseCellResultsData::computeNncCombRiTRANSbyArea() if ( transResults->size() != riAreaNormTransResults.size() ) return; - const std::vector& connections = m_ownerMainGrid->nncData()->connections(); + const RigConnectionContainer& connections = m_ownerMainGrid->nncData()->connections(); for ( size_t nncConIdx = 0; nncConIdx < riAreaNormTransResults.size(); ++nncConIdx ) { @@ -3063,7 +3063,7 @@ void RigCaseCellResultsData::computeAllanResults( RigCaseCellResultsData* cellRe formationCount = cellResultsData->activeFormationNames()->formationNames().size(); } - const std::vector& nncConnections = mainGrid->nncData()->connections(); + const RigConnectionContainer& nncConnections = mainGrid->nncData()->connections(); std::map, int> formationCombinationToCategory; for ( size_t i = 0; i < nncConnections.size(); i++ ) diff --git a/ApplicationCode/ReservoirDataModel/RigCellFaceGeometryTools.cpp b/ApplicationCode/ReservoirDataModel/RigCellFaceGeometryTools.cpp index 7c7305102c..59a2f99b98 100644 --- a/ApplicationCode/ReservoirDataModel/RigCellFaceGeometryTools.cpp +++ b/ApplicationCode/ReservoirDataModel/RigCellFaceGeometryTools.cpp @@ -18,6 +18,7 @@ #include "RigCellFaceGeometryTools.h" +#include "RigActiveCellInfo.h" #include "RigCell.h" #include "RigMainGrid.h" #include "RigNncConnection.h" @@ -28,6 +29,8 @@ #include +#include + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -40,7 +43,7 @@ cvf::StructGridInterface::FaceType { // Try to find the shared face - bool isPossibleNeighborInDirection[6] = {true, true, true, true, true, true}; + bool isPossibleNeighborInDirection[6] = { true, true, true, true, true, true }; if ( c1.hostGrid() == c2.hostGrid() ) { @@ -116,55 +119,42 @@ cvf::StructGridInterface::FaceType return cvf::StructGridInterface::NO_FACE; } +void assignThreadConnections( std::set>& existingPairs, + RigConnectionContainer& allConnections, + RigConnectionContainer& threadConnections ) +{ + for ( size_t i = 0; i < threadConnections.size(); ++i ) + { +#pragma omp critical + { + RigConnection connection = threadConnections[i]; + auto it = existingPairs.emplace( connection.m_c1GlobIdx, connection.m_c2GlobIdx ); + if ( it.second ) + { + allConnections.push_back( connection ); + } + } + } + threadConnections.clear(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RigCellFaceGeometryTools::computeOtherNncs( const RigMainGrid* mainGrid, - const std::vector& nativeConnections ) +RigConnectionContainer RigCellFaceGeometryTools::computeOtherNncs( const RigMainGrid* mainGrid, + const RigConnectionContainer& nativeConnections, + const RigActiveCellInfo* activeCellInfo ) { // Compute Non-Neighbor Connections (NNC) not reported by Eclipse. NNCs with zero transmissibility are not reported // by Eclipse. Use faults as basis for subset of cells to find NNC connection for. The imported connections from // Eclipse are located at the beginning of the connections vector. - std::vector otherConnections; + std::set> nativeCellPairs; - class CellPair + for ( size_t i = 0; i < nativeConnections.size(); ++i ) { - public: - CellPair( size_t globalIdx1, size_t globalIdx2 ) - { - if ( globalIdx1 < globalIdx2 ) - { - m_globalCellIdx1 = globalIdx1; - m_globalCellIdx2 = globalIdx2; - } - else - { - m_globalCellIdx1 = globalIdx2; - m_globalCellIdx2 = globalIdx1; - } - } - - bool operator<( const CellPair& other ) const - { - if ( m_globalCellIdx1 != other.m_globalCellIdx1 ) - { - return m_globalCellIdx1 < other.m_globalCellIdx1; - } - - return ( m_globalCellIdx2 < other.m_globalCellIdx2 ); - } - - private: - size_t m_globalCellIdx1; - size_t m_globalCellIdx2; - }; - - std::set nativeCellPairs; - - for ( const auto& c : nativeConnections ) - { - nativeCellPairs.emplace( CellPair( c.m_c1GlobIdx, c.m_c2GlobIdx ) ); + RigConnection c = nativeConnections[i]; + nativeCellPairs.emplace( c.m_c1GlobIdx, c.m_c2GlobIdx ); } if ( nativeConnections.size() != nativeCellPairs.size() ) @@ -175,164 +165,181 @@ std::vector RigCellFaceGeometryTools::computeOtherNncs( const Rig qDebug() << message; } - std::set otherCellPairs; - const cvf::Collection& faults = mainGrid->faults(); - for ( size_t faultIdx = 0; faultIdx < faults.size(); faultIdx++ ) + std::set> existingPairs; + RigConnectionContainer otherConnections; + + for ( int faultIdx = 0; faultIdx < (int)faults.size(); faultIdx++ ) { const RigFault* fault = faults.at( faultIdx ); const std::vector& faultFaces = fault->faultFaces(); -#pragma omp parallel for - for ( int faceIdx = 0; faceIdx < static_cast( faultFaces.size() ); faceIdx++ ) +#pragma omp parallel { - const RigFault::FaultFace& f = faultFaces[faceIdx]; - - size_t sourceReservoirCellIndex = f.m_nativeReservoirCellIndex; - cvf::StructGridInterface::FaceType sourceCellFace = f.m_nativeFace; - - if ( sourceReservoirCellIndex >= mainGrid->cellCount() ) + RigConnectionContainer threadConnections; +#pragma omp for + for ( int faceIdx = 0; faceIdx < static_cast( faultFaces.size() ); faceIdx++ ) { - continue; - } + const RigFault::FaultFace& f = faultFaces[faceIdx]; - const std::vector& mainGridNodes = mainGrid->nodes(); - - cvf::BoundingBox bb; - std::array sourceFaceIndices; - mainGrid->globalCellArray()[sourceReservoirCellIndex].faceIndices( sourceCellFace, &sourceFaceIndices ); - - bb.add( mainGridNodes[sourceFaceIndices[0]] ); - bb.add( mainGridNodes[sourceFaceIndices[1]] ); - bb.add( mainGridNodes[sourceFaceIndices[2]] ); - bb.add( mainGridNodes[sourceFaceIndices[3]] ); - - std::vector closeCells; - mainGrid->findIntersectingCells( bb, &closeCells ); - - cvf::StructGridInterface::FaceType candidateFace = cvf::StructGridInterface::oppositeFace( sourceCellFace ); - - size_t neighborCellIndex = std::numeric_limits::max(); - size_t ni = std::numeric_limits::max(); - size_t nj = std::numeric_limits::max(); - size_t nk = std::numeric_limits::max(); - - { - size_t i; - size_t j; - size_t k; - mainGrid->ijkFromCellIndex( sourceReservoirCellIndex, &i, &j, &k ); - - mainGrid->neighborIJKAtCellFace( i, j, k, sourceCellFace, &ni, &nj, &nk ); - - if ( mainGrid->isCellValid( ni, nj, nk ) ) + bool atLeastOneCellActive = !activeCellInfo || + ( activeCellInfo->isActive( f.m_nativeReservoirCellIndex ) || + activeCellInfo->isActive( f.m_oppositeReservoirCellIndex ) ); + if ( atLeastOneCellActive ) { - neighborCellIndex = mainGrid->cellIndexFromIJK( ni, nj, nk ); + RigConnectionContainer faceConnections = extractConnectionsForFace( f, mainGrid, nativeCellPairs ); + threadConnections.insert( faceConnections ); } } - - for ( size_t candidateCellIndex : closeCells ) - { - if ( candidateCellIndex == sourceReservoirCellIndex ) - { - // Exclude cellIndex for source cell - continue; - } - - if ( candidateCellIndex == neighborCellIndex ) - { - // Exclude direct neighbor - continue; - } - - if ( candidateCellIndex >= mainGrid->cellCount() ) - { - continue; - } - - if ( neighborCellIndex != std::numeric_limits::max() ) - { - // Find target IJK index based on source cell and cell face - // Exclude cells not matching destination target index - - size_t ci = std::numeric_limits::max(); - size_t cj = std::numeric_limits::max(); - size_t ck = std::numeric_limits::max(); - mainGrid->ijkFromCellIndex( candidateCellIndex, &ci, &cj, &ck ); - - auto gridAxis = cvf::StructGridInterface::gridAxisFromFace( sourceCellFace ); - if ( gridAxis == cvf::StructGridInterface::GridAxisType::AXIS_I ) - { - if ( ni != ci ) - { - continue; - } - } - else if ( gridAxis == cvf::StructGridInterface::GridAxisType::AXIS_J ) - { - if ( nj != cj ) - { - continue; - } - } - else if ( gridAxis == cvf::StructGridInterface::GridAxisType::AXIS_K ) - { - if ( nk != ck ) - { - continue; - } - } - } - - CellPair candidate( sourceReservoirCellIndex, candidateCellIndex ); - - if ( nativeCellPairs.count( candidate ) > 0 ) - { - continue; - } - - std::vector polygon; - std::vector intersections; - - std::array candidateFaceIndices; - mainGrid->globalCellArray()[candidateCellIndex].faceIndices( candidateFace, &candidateFaceIndices ); - - bool foundOverlap = - cvf::GeometryTools::calculateOverlapPolygonOfTwoQuads( &polygon, - &intersections, - (cvf::EdgeIntersectStorage*)nullptr, - cvf::wrapArrayConst( &mainGridNodes ), - sourceFaceIndices.data(), - candidateFaceIndices.data(), - 1e-6 ); - - if ( foundOverlap ) - { - RigConnection conn; - conn.m_c1GlobIdx = sourceReservoirCellIndex; - conn.m_c1Face = sourceCellFace; - conn.m_c2GlobIdx = candidateCellIndex; - - conn.m_polygon = RigCellFaceGeometryTools::extractPolygon( mainGridNodes, polygon, intersections ); - -#pragma omp critical( critical_section_nnc_computations ) - { - auto itBoolPair = otherCellPairs.insert( candidate ); - if ( itBoolPair.second ) - { - otherConnections.emplace_back( conn ); - } - } - } - } - } + // Merge together connections per thread + assignThreadConnections( existingPairs, otherConnections, threadConnections ); + } // end parallel region } return otherConnections; } +RigConnectionContainer + RigCellFaceGeometryTools::extractConnectionsForFace( const RigFault::FaultFace& face, + const RigMainGrid* mainGrid, + const std::set>& nativeCellPairs ) +{ + RigConnectionContainer faceConnections; + size_t sourceReservoirCellIndex = face.m_nativeReservoirCellIndex; + cvf::StructGridInterface::FaceType sourceCellFace = face.m_nativeFace; + + if ( sourceReservoirCellIndex >= mainGrid->cellCount() ) + { + return {}; + } + + const std::vector& mainGridNodes = mainGrid->nodes(); + + cvf::BoundingBox bb; + std::array sourceFaceIndices; + mainGrid->globalCellArray()[sourceReservoirCellIndex].faceIndices( sourceCellFace, &sourceFaceIndices ); + + bb.add( mainGridNodes[sourceFaceIndices[0]] ); + bb.add( mainGridNodes[sourceFaceIndices[1]] ); + bb.add( mainGridNodes[sourceFaceIndices[2]] ); + bb.add( mainGridNodes[sourceFaceIndices[3]] ); + + std::vector closeCells; + mainGrid->findIntersectingCells( bb, &closeCells ); + + cvf::StructGridInterface::FaceType candidateFace = cvf::StructGridInterface::oppositeFace( sourceCellFace ); + + size_t neighborCellIndex = std::numeric_limits::max(); + size_t ni = std::numeric_limits::max(); + size_t nj = std::numeric_limits::max(); + size_t nk = std::numeric_limits::max(); + + { + size_t i; + size_t j; + size_t k; + mainGrid->ijkFromCellIndex( sourceReservoirCellIndex, &i, &j, &k ); + + mainGrid->neighborIJKAtCellFace( i, j, k, sourceCellFace, &ni, &nj, &nk ); + + if ( mainGrid->isCellValid( ni, nj, nk ) ) + { + neighborCellIndex = mainGrid->cellIndexFromIJK( ni, nj, nk ); + } + } + + for ( size_t candidateCellIndex : closeCells ) + { + if ( candidateCellIndex == sourceReservoirCellIndex ) + { + // Exclude cellIndex for source cell + continue; + } + + if ( candidateCellIndex == neighborCellIndex ) + { + // Exclude direct neighbor + continue; + } + + if ( candidateCellIndex >= mainGrid->cellCount() ) + { + continue; + } + + if ( neighborCellIndex != std::numeric_limits::max() ) + { + // Find target IJK index based on source cell and cell face + // Exclude cells not matching destination target index + + size_t ci = std::numeric_limits::max(); + size_t cj = std::numeric_limits::max(); + size_t ck = std::numeric_limits::max(); + mainGrid->ijkFromCellIndex( candidateCellIndex, &ci, &cj, &ck ); + + auto gridAxis = cvf::StructGridInterface::gridAxisFromFace( sourceCellFace ); + if ( gridAxis == cvf::StructGridInterface::GridAxisType::AXIS_I ) + { + if ( ni != ci ) + { + continue; + } + } + else if ( gridAxis == cvf::StructGridInterface::GridAxisType::AXIS_J ) + { + if ( nj != cj ) + { + continue; + } + } + else if ( gridAxis == cvf::StructGridInterface::GridAxisType::AXIS_K ) + { + if ( nk != ck ) + { + continue; + } + } + } + + std::pair candidate( sourceReservoirCellIndex, candidateCellIndex ); + + if ( nativeCellPairs.count( candidate ) > 0 ) + { + continue; + } + + std::vector polygon; + std::vector intersections; + + std::array candidateFaceIndices; + mainGrid->globalCellArray()[candidateCellIndex].faceIndices( candidateFace, &candidateFaceIndices ); + + bool foundOverlap = + cvf::GeometryTools::calculateOverlapPolygonOfTwoQuads( &polygon, + &intersections, + (cvf::EdgeIntersectStorage*)nullptr, + cvf::wrapArrayConst( &mainGridNodes ), + sourceFaceIndices.data(), + candidateFaceIndices.data(), + 1e-6 ); + + if ( foundOverlap ) + { + RigConnection conn; + conn.m_c1GlobIdx = sourceReservoirCellIndex; + conn.m_c2GlobIdx = candidateCellIndex; + conn.m_c1Face = sourceCellFace; + + conn.m_polygon = RigCellFaceGeometryTools::extractPolygon( mainGridNodes, polygon, intersections ); + + faceConnections.push_back( conn ); + } + } + return faceConnections; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ReservoirDataModel/RigCellFaceGeometryTools.h b/ApplicationCode/ReservoirDataModel/RigCellFaceGeometryTools.h index 5d3343d8ab..6e98655c58 100644 --- a/ApplicationCode/ReservoirDataModel/RigCellFaceGeometryTools.h +++ b/ApplicationCode/ReservoirDataModel/RigCellFaceGeometryTools.h @@ -18,15 +18,21 @@ #pragma once +#include "RigFault.h" +#include "RigNncConnection.h" + #include "cvfCollection.h" #include "cvfStructGrid.h" #include "cvfVector3.h" +#include +#include +#include #include +class RigActiveCellInfo; class RigCell; class RigMainGrid; -class RigConnection; //================================================================================================== /// @@ -40,9 +46,13 @@ public: std::vector* connectionPolygon, std::vector* connectionIntersections ); - static std::vector computeOtherNncs( const RigMainGrid* mainGrid, - const std::vector& nativeConnections ); + static RigConnectionContainer computeOtherNncs( const RigMainGrid* mainGrid, + const RigConnectionContainer& nativeConnections, + const RigActiveCellInfo* activeCellInfo ); + static RigConnectionContainer extractConnectionsForFace( const RigFault::FaultFace& face, + const RigMainGrid* mainGrid, + const std::set>& nativeCellPairs ); static std::vector extractPolygon( const std::vector& nativeNodes, const std::vector& connectionPolygon, const std::vector& connectionIntersections ); diff --git a/ApplicationCode/ReservoirDataModel/RigMainGrid.cpp b/ApplicationCode/ReservoirDataModel/RigMainGrid.cpp index 60445d7de9..25b5dc2703 100644 --- a/ApplicationCode/ReservoirDataModel/RigMainGrid.cpp +++ b/ApplicationCode/ReservoirDataModel/RigMainGrid.cpp @@ -556,7 +556,7 @@ void RigMainGrid::calculateFaults( const RigActiveCellInfo* activeCellInfo ) } } - this->nncData()->computeCompleteSetOfNncs( this ); + this->nncData()->computeCompleteSetOfNncs( this, activeCellInfo ); distributeNNCsToFaults(); } @@ -566,7 +566,7 @@ void RigMainGrid::calculateFaults( const RigActiveCellInfo* activeCellInfo ) //-------------------------------------------------------------------------------------------------- void RigMainGrid::distributeNNCsToFaults() { - const std::vector& nncs = this->nncData()->connections(); + const RigConnectionContainer& nncs = this->nncData()->connections(); for ( size_t nncIdx = 0; nncIdx < nncs.size(); ++nncIdx ) { // Find the fault for each side of the nnc diff --git a/ApplicationCode/ReservoirDataModel/RigNNCData.cpp b/ApplicationCode/ReservoirDataModel/RigNNCData.cpp index cdfc6d8600..5eec61884e 100644 --- a/ApplicationCode/ReservoirDataModel/RigNNCData.cpp +++ b/ApplicationCode/ReservoirDataModel/RigNNCData.cpp @@ -55,9 +55,9 @@ void RigNNCData::processNativeConnections( const RigMainGrid& mainGrid ) { // Found an overlap polygon. Store data about connection - m_connections[cnIdx].m_c1Face = connectionFace; + m_connections.face( cnIdx ) = connectionFace; - m_connections[cnIdx].m_polygon = + m_connections.polygon( cnIdx ) = RigCellFaceGeometryTools::extractPolygon( mainGrid.nodes(), connectionPolygon, connectionIntersections ); // Add to search map, possibly not needed @@ -75,15 +75,16 @@ void RigNNCData::processNativeConnections( const RigMainGrid& mainGrid ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigNNCData::computeCompleteSetOfNncs( const RigMainGrid* mainGrid ) +void RigNNCData::computeCompleteSetOfNncs( const RigMainGrid* mainGrid, const RigActiveCellInfo* activeCellInfo ) { m_nativeConnectionCount = m_connections.size(); - std::vector otherConnections = RigCellFaceGeometryTools::computeOtherNncs( mainGrid, m_connections ); + RigConnectionContainer otherConnections = + RigCellFaceGeometryTools::computeOtherNncs( mainGrid, m_connections, activeCellInfo ); if ( !otherConnections.empty() ) { - m_connections.insert( m_connections.end(), otherConnections.begin(), otherConnections.end() ); + m_connections.insert( otherConnections ); // Transmissibility values from Eclipse has been read into propertyNameCombTrans in // RifReaderEclipseOutput::transferStaticNNCData(). Initialize computed NNCs with zero transmissibility @@ -101,7 +102,7 @@ void RigNNCData::computeCompleteSetOfNncs( const RigMainGrid* mainGrid ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigNNCData::setConnections( std::vector& connections ) +void RigNNCData::setConnections( RigConnectionContainer& connections ) { m_connections = connections; } @@ -117,7 +118,7 @@ size_t RigNNCData::nativeConnectionCount() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -const std::vector& RigNNCData::connections() const +const RigConnectionContainer& RigNNCData::connections() const { return m_connections; } diff --git a/ApplicationCode/ReservoirDataModel/RigNNCData.h b/ApplicationCode/ReservoirDataModel/RigNNCData.h index 86528fda14..06f53f3e26 100644 --- a/ApplicationCode/ReservoirDataModel/RigNNCData.h +++ b/ApplicationCode/ReservoirDataModel/RigNNCData.h @@ -28,9 +28,11 @@ #include "cvfVector3.h" #include // Needed for HUGE_VAL on Linux +#include #include #include +class RigActiveCellInfo; class RigMainGrid; class RigCell; class RigEclipseResultAddress; @@ -48,12 +50,12 @@ public: RigNNCData(); void processNativeConnections( const RigMainGrid& mainGrid ); - void computeCompleteSetOfNncs( const RigMainGrid* mainGrid ); + void computeCompleteSetOfNncs( const RigMainGrid* mainGrid, const RigActiveCellInfo* activeCellInfo ); - void setConnections( std::vector& connections ); + void setConnections( RigConnectionContainer& connections ); size_t nativeConnectionCount() const; - const std::vector& connections() const; + const RigConnectionContainer& connections() const; std::vector& makeStaticConnectionScalarResult( QString nncDataType ); const std::vector* staticConnectionScalarResult( const RigEclipseResultAddress& resVarAddr ) const; @@ -88,7 +90,7 @@ private: bool isNative( QString nncDataType ) const; private: - std::vector m_connections; + RigConnectionContainer m_connections; size_t m_nativeConnectionCount; std::map>> m_connectionResults; std::map m_resultAddrToNNCDataType; diff --git a/ApplicationCode/ReservoirDataModel/RigNncConnection.cpp b/ApplicationCode/ReservoirDataModel/RigNncConnection.cpp index 7f9069b471..48e8d31516 100644 --- a/ApplicationCode/ReservoirDataModel/RigNncConnection.cpp +++ b/ApplicationCode/ReservoirDataModel/RigNncConnection.cpp @@ -25,11 +25,48 @@ //-------------------------------------------------------------------------------------------------- RigConnection::RigConnection() : m_c1GlobIdx( cvf::UNDEFINED_SIZE_T ) - , m_c1Face( cvf::StructGridInterface::NO_FACE ) , m_c2GlobIdx( cvf::UNDEFINED_SIZE_T ) + , m_c1Face( cvf::StructGridInterface::NO_FACE ) { } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigConnection::RigConnection( size_t c1GlobIdx, + size_t c2GlobIdx, + cvf::StructGridInterface::FaceType c1Face, + const std::vector& polygon ) + : m_c1GlobIdx( c1GlobIdx ) + , m_c2GlobIdx( c2GlobIdx ) + , m_c1Face( c1Face ) + , m_polygon( polygon ) +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigConnection::RigConnection( const RigConnection& rhs ) + : m_c1GlobIdx( rhs.m_c1GlobIdx ) + , m_c2GlobIdx( rhs.m_c2GlobIdx ) + , m_c1Face( rhs.m_c1Face ) + , m_polygon( rhs.m_polygon ) +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigConnection& RigConnection::operator=( RigConnection& rhs ) +{ + m_c1GlobIdx = rhs.m_c1GlobIdx; + m_c2GlobIdx = rhs.m_c2GlobIdx; + m_c1Face = rhs.m_c1Face; + m_polygon = rhs.m_polygon; + return *this; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -37,3 +74,95 @@ bool RigConnection::hasCommonArea() const { return m_polygon.size() > 0; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RigConnection::operator<( const RigConnection& other ) const +{ + if ( m_c1GlobIdx != other.m_c1GlobIdx ) + { + return m_c1GlobIdx < other.m_c1GlobIdx; + } + + return ( m_c2GlobIdx < other.m_c2GlobIdx ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigConnection RigConnectionContainer::operator[]( size_t i ) const +{ + const auto& globIndices = m_globalIndices[i]; + return RigConnection( globIndices.first, globIndices.second, m_faces[i], m_polygons[i] ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::pair& RigConnectionContainer::indexPair( size_t i ) +{ + return m_globalIndices[i]; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::StructGridInterface::FaceType& RigConnectionContainer::face( size_t i ) +{ + return m_faces[i]; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector& RigConnectionContainer::polygon( size_t i ) +{ + return m_polygons[i]; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigConnectionContainer::push_back( const RigConnection& connection ) +{ + m_globalIndices.push_back( std::make_pair( connection.m_c1GlobIdx, connection.m_c2GlobIdx ) ); + m_faces.push_back( connection.m_c1Face ); + m_polygons.push_back( connection.m_polygon ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigConnectionContainer::insert( const RigConnectionContainer& other ) +{ + m_globalIndices.insert( m_globalIndices.end(), other.m_globalIndices.begin(), other.m_globalIndices.end() ); + m_faces.insert( m_faces.end(), other.m_faces.begin(), other.m_faces.end() ); + m_polygons.insert( m_polygons.end(), other.m_polygons.begin(), other.m_polygons.end() ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t RigConnectionContainer::size() const +{ + return m_globalIndices.size(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigConnectionContainer::clear() +{ + m_globalIndices.clear(); + m_faces.clear(); + m_polygons.clear(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RigConnectionContainer::empty() const +{ + return m_globalIndices.empty(); +} diff --git a/ApplicationCode/ReservoirDataModel/RigNncConnection.h b/ApplicationCode/ReservoirDataModel/RigNncConnection.h index 1c05bd703c..77addb2b79 100644 --- a/ApplicationCode/ReservoirDataModel/RigNncConnection.h +++ b/ApplicationCode/ReservoirDataModel/RigNncConnection.h @@ -21,6 +21,7 @@ #include "cvfStructGrid.h" #include "cvfVector3.h" +#include #include //-------------------------------------------------------------------------------------------------- @@ -30,12 +31,39 @@ class RigConnection { public: RigConnection(); + RigConnection( size_t c1GlobIdx, + size_t c2GlobIdx, + cvf::StructGridInterface::FaceType c1Face, + const std::vector& polygon ); + RigConnection( const RigConnection& rhs ); - bool hasCommonArea() const; + RigConnection& operator=( RigConnection& rhs ); + bool operator<( const RigConnection& other ) const; + bool hasCommonArea() const; size_t m_c1GlobIdx; - cvf::StructGridInterface::FaceType m_c1Face; size_t m_c2GlobIdx; - - std::vector m_polygon; + cvf::StructGridInterface::FaceType m_c1Face; + std::vector m_polygon; +}; + +class RigConnectionContainer +{ +public: + RigConnection operator[]( size_t i ) const; + + std::pair& indexPair( size_t i ); + cvf::StructGridInterface::FaceType& face( size_t i ); + std::vector& polygon( size_t i ); + + void push_back( const RigConnection& connection ); + void insert( const RigConnectionContainer& other ); + size_t size() const; + void clear(); + bool empty() const; + +private: + std::vector> m_globalIndices; + std::vector m_faces; + std::vector> m_polygons; }; diff --git a/ApplicationCode/ReservoirDataModel/RigNumberOfFloodedPoreVolumesCalculator.cpp b/ApplicationCode/ReservoirDataModel/RigNumberOfFloodedPoreVolumesCalculator.cpp index 18807f7e6f..7d4cddec2e 100644 --- a/ApplicationCode/ReservoirDataModel/RigNumberOfFloodedPoreVolumesCalculator.cpp +++ b/ApplicationCode/ReservoirDataModel/RigNumberOfFloodedPoreVolumesCalculator.cpp @@ -98,8 +98,8 @@ RigNumberOfFloodedPoreVolumesCalculator::RigNumberOfFloodedPoreVolumesCalculator std::vector*> flowrateJatAllTimeSteps; std::vector*> flowrateKatAllTimeSteps; - RigNNCData* nncData = eclipseCaseData->mainGrid()->nncData(); - const std::vector connections = nncData->connections(); + RigNNCData* nncData = eclipseCaseData->mainGrid()->nncData(); + const RigConnectionContainer connections = nncData->connections(); progress.incrementProgress(); @@ -197,7 +197,7 @@ void RigNumberOfFloodedPoreVolumesCalculator::calculate( RigMainGrid* std::vector*> flowrateIatAllTimeSteps, std::vector*> flowrateJatAllTimeSteps, std::vector*> flowrateKatAllTimeSteps, - const std::vector& connections, + const RigConnectionContainer& connections, std::vector*> flowrateNNCatAllTimeSteps, std::vector> summedTracersAtAllTimesteps ) { @@ -290,11 +290,11 @@ void RigNumberOfFloodedPoreVolumesCalculator::calculate( RigMainGrid* //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigNumberOfFloodedPoreVolumesCalculator::distributeNNCflow( const std::vector& connections, - RimEclipseCase* caseToApply, - const std::vector& summedTracerValues, - const std::vector* flowrateNNC, - std::vector& flowrateIntoCell ) +void RigNumberOfFloodedPoreVolumesCalculator::distributeNNCflow( const RigConnectionContainer& connections, + RimEclipseCase* caseToApply, + const std::vector& summedTracerValues, + const std::vector* flowrateNNC, + std::vector& flowrateIntoCell ) { RigActiveCellInfo* actCellInfo = caseToApply->eclipseCaseData()->activeCellInfo( RiaDefines::MATRIX_MODEL ); diff --git a/ApplicationCode/ReservoirDataModel/RigNumberOfFloodedPoreVolumesCalculator.h b/ApplicationCode/ReservoirDataModel/RigNumberOfFloodedPoreVolumesCalculator.h index 542fee1cf9..eba709e23b 100644 --- a/ApplicationCode/ReservoirDataModel/RigNumberOfFloodedPoreVolumesCalculator.h +++ b/ApplicationCode/ReservoirDataModel/RigNumberOfFloodedPoreVolumesCalculator.h @@ -18,13 +18,15 @@ #pragma once +#include "RigNncConnection.h" + #include #include +#include #include class RimEclipseCase; class RigMainGrid; -class RigConnection; //================================================================================================== /// @@ -48,15 +50,15 @@ private: std::vector*> flowrateIatAllTimeSteps, std::vector*> flowrateJatAllTimeSteps, std::vector*> flowrateKatAllTimeSteps, - const std::vector& connections, + const RigConnectionContainer& connections, std::vector*> flowrateNNCatAllTimeSteps, std::vector> summedTracersAtAllTimesteps ); - void distributeNNCflow( const std::vector& connections, - RimEclipseCase* caseToApply, - const std::vector& summedTracerValues, - const std::vector* flowrateNNC, - std::vector& flowrateIntoCell ); + void distributeNNCflow( const RigConnectionContainer& connections, + RimEclipseCase* caseToApply, + const std::vector& summedTracerValues, + const std::vector* flowrateNNC, + std::vector& flowrateIntoCell ); void distributeNeighbourCellFlow( RigMainGrid* mainGrid, RimEclipseCase* caseToApply, diff --git a/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.cpp b/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.cpp index 3365e6fbb7..c420a2690c 100644 --- a/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.cpp +++ b/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.cpp @@ -533,7 +533,7 @@ void RigReservoirBuilderMock::addFaults( RigEclipseCaseData* eclipseCase ) grid->setFaults( faults ); // NNCs - std::vector nncConnections; + RigConnectionContainer nncConnections; { size_t i1 = 2; size_t j1 = 2; @@ -579,14 +579,14 @@ void RigReservoirBuilderMock::enableWellData( bool enableWellData ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigReservoirBuilderMock::addNnc( RigMainGrid* grid, - size_t i1, - size_t j1, - size_t k1, - size_t i2, - size_t j2, - size_t k2, - std::vector& nncConnections ) +void RigReservoirBuilderMock::addNnc( RigMainGrid* grid, + size_t i1, + size_t j1, + size_t k1, + size_t i2, + size_t j2, + size_t k2, + RigConnectionContainer& nncConnections ) { size_t c1GlobalIndex = grid->cellIndexFromIJK( i1, j1, k1 ); size_t c2GlobalIndex = grid->cellIndexFromIJK( i2, j2, k2 ); diff --git a/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.h b/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.h index e6a41ed6be..cdc072dd90 100644 --- a/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.h +++ b/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.h @@ -20,13 +20,16 @@ #pragma once +#include "RigNncConnection.h" + #include "cvfArray.h" #include "cvfObject.h" #include "cvfVector3.h" +#include + class RigEclipseCaseData; class RigMainGrid; -class RigConnection; class RigGridBase; class RigCell; @@ -76,14 +79,14 @@ public: private: void addFaults( RigEclipseCaseData* eclipseCase ); - static void addNnc( RigMainGrid* grid, - size_t i1, - size_t j1, - size_t k1, - size_t i2, - size_t j2, - size_t k2, - std::vector& nncConnections ); + static void addNnc( RigMainGrid* grid, + size_t i1, + size_t j1, + size_t k1, + size_t i2, + size_t j2, + size_t k2, + RigConnectionContainer& nncConnections ); void addWellData( RigEclipseCaseData* eclipseCase, RigGridBase* grid ); static void appendCells( size_t nodeStartIndex, size_t cellCount, RigGridBase* hostGrid, std::vector& cells ); diff --git a/ApplicationCode/SocketInterface/RiaNNCCommands.cpp b/ApplicationCode/SocketInterface/RiaNNCCommands.cpp index 60099e52a4..dbda8325fb 100644 --- a/ApplicationCode/SocketInterface/RiaNNCCommands.cpp +++ b/ApplicationCode/SocketInterface/RiaNNCCommands.cpp @@ -70,8 +70,10 @@ public: socketStream << (quint64)connectionCount; - for ( const RigConnection& connection : mainGrid->nncData()->connections() ) + for ( size_t i = 0; i < mainGrid->nncData()->connections().size(); ++i ) { + RigConnection connection = mainGrid->nncData()->connections()[i]; + const RigCell& cell1 = mainGrid->globalCellArray()[connection.m_c1GlobIdx]; const RigCell& cell2 = mainGrid->globalCellArray()[connection.m_c2GlobIdx]; diff --git a/Fwk/AppFwk/cafAnimControl/CMakeLists.txt b/Fwk/AppFwk/cafAnimControl/CMakeLists.txt index 2be9ac6ef5..a33da46514 100644 --- a/Fwk/AppFwk/cafAnimControl/CMakeLists.txt +++ b/Fwk/AppFwk/cafAnimControl/CMakeLists.txt @@ -62,7 +62,7 @@ target_include_directories(${PROJECT_NAME} target_link_libraries(${PROJECT_NAME} ${QT_LIBRARIES}) if (MSVC) - set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "/W4 /wd4127") + set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "/W3 /wd4127") endif() source_group("" FILES ${PROJECT_FILES}) diff --git a/Fwk/AppFwk/cafCommand/CMakeLists.txt b/Fwk/AppFwk/cafCommand/CMakeLists.txt index 2758cd432b..a54ccb64d0 100644 --- a/Fwk/AppFwk/cafCommand/CMakeLists.txt +++ b/Fwk/AppFwk/cafCommand/CMakeLists.txt @@ -66,7 +66,7 @@ target_link_libraries ( ${PROJECT_NAME} ) if (MSVC) - set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "/W4 /wd4100 /wd4127") + set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "/W3 /wd4100 /wd4127") endif() source_group("" FILES ${PROJECT_FILES}) diff --git a/ThirdParty/Ert/CMakeLists.txt b/ThirdParty/Ert/CMakeLists.txt index c8050a1cae..292a827403 100644 --- a/ThirdParty/Ert/CMakeLists.txt +++ b/ThirdParty/Ert/CMakeLists.txt @@ -119,7 +119,7 @@ if (NOT ERT_WINDOWS) endif() if (MSVC) - add_definitions( "/W3 /D_CRT_SECURE_NO_WARNINGS /wd4996" ) + add_definitions( "/W4 /D_CRT_SECURE_NO_WARNINGS /wd4996" ) endif() From 7674e87359da7e90a7b00166f4fd37bd760319e6 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Wed, 13 May 2020 10:40:39 +0200 Subject: [PATCH 16/46] Use guided openmp for loop --- ApplicationCode/ReservoirDataModel/RigCellFaceGeometryTools.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ApplicationCode/ReservoirDataModel/RigCellFaceGeometryTools.cpp b/ApplicationCode/ReservoirDataModel/RigCellFaceGeometryTools.cpp index 59a2f99b98..bd4aa8a10d 100644 --- a/ApplicationCode/ReservoirDataModel/RigCellFaceGeometryTools.cpp +++ b/ApplicationCode/ReservoirDataModel/RigCellFaceGeometryTools.cpp @@ -179,7 +179,7 @@ RigConnectionContainer RigCellFaceGeometryTools::computeOtherNncs( const RigMain #pragma omp parallel { RigConnectionContainer threadConnections; -#pragma omp for +#pragma omp for schedule( guided ) for ( int faceIdx = 0; faceIdx < static_cast( faultFaces.size() ); faceIdx++ ) { const RigFault::FaultFace& f = faultFaces[faceIdx]; From 24f4b1d4ac74e1d28aae5af9846edc2d2e1e466c Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Wed, 13 May 2020 10:57:30 +0200 Subject: [PATCH 17/46] Improve NNC calculation load balancing --- .../RigCellFaceGeometryTools.cpp | 33 +++++++++++++------ 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/ApplicationCode/ReservoirDataModel/RigCellFaceGeometryTools.cpp b/ApplicationCode/ReservoirDataModel/RigCellFaceGeometryTools.cpp index bd4aa8a10d..4c0db5da93 100644 --- a/ApplicationCode/ReservoirDataModel/RigCellFaceGeometryTools.cpp +++ b/ApplicationCode/ReservoirDataModel/RigCellFaceGeometryTools.cpp @@ -176,22 +176,35 @@ RigConnectionContainer RigCellFaceGeometryTools::computeOtherNncs( const RigMain const std::vector& faultFaces = fault->faultFaces(); + // Build a vector of active face indices so we don't have to have this check inside the parallel loop. + // This makes the load balancing much better in the loop. + std::vector activeFaceIndices; + activeFaceIndices.reserve( faultFaces.size() ); + for ( size_t faceIdx = 0; faceIdx < faultFaces.size(); ++faceIdx ) + { + const RigFault::FaultFace& f = faultFaces[faceIdx]; + + bool atLeastOneCellActive = true; + if ( activeCellInfo && activeCellInfo->reservoirActiveCellCount() > 0u ) + { + atLeastOneCellActive = activeCellInfo->isActive( f.m_nativeReservoirCellIndex ) || + activeCellInfo->isActive( f.m_oppositeReservoirCellIndex ); + } + + if ( atLeastOneCellActive ) activeFaceIndices.push_back( faceIdx ); + } + #pragma omp parallel { RigConnectionContainer threadConnections; #pragma omp for schedule( guided ) - for ( int faceIdx = 0; faceIdx < static_cast( faultFaces.size() ); faceIdx++ ) + for ( int activeFaceIdx = 0; activeFaceIdx < static_cast( activeFaceIndices.size() ); activeFaceIdx++ ) { - const RigFault::FaultFace& f = faultFaces[faceIdx]; + size_t faceIdx = activeFaceIndices[activeFaceIdx]; + const RigFault::FaultFace& f = faultFaces[faceIdx]; - bool atLeastOneCellActive = !activeCellInfo || - ( activeCellInfo->isActive( f.m_nativeReservoirCellIndex ) || - activeCellInfo->isActive( f.m_oppositeReservoirCellIndex ) ); - if ( atLeastOneCellActive ) - { - RigConnectionContainer faceConnections = extractConnectionsForFace( f, mainGrid, nativeCellPairs ); - threadConnections.insert( faceConnections ); - } + RigConnectionContainer faceConnections = extractConnectionsForFace( f, mainGrid, nativeCellPairs ); + threadConnections.insert( faceConnections ); } // Merge together connections per thread assignThreadConnections( existingPairs, otherConnections, threadConnections ); From 4b3d41d53ef79b9370b9b094d858b8c892269bc3 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Thu, 14 May 2020 15:07:17 +0200 Subject: [PATCH 18/46] Reduce NNC memory use --- .../RivNNCGeometryGenerator.cpp | 8 +-- .../RigCaseCellResultsData.cpp | 14 ++--- .../RigCellFaceGeometryTools.cpp | 28 +++++----- .../RigCellFaceGeometryTools.h | 9 ++-- .../ReservoirDataModel/RigNncConnection.cpp | 21 ++++---- .../ReservoirDataModel/RigNncConnection.h | 25 ++++----- .../RigReservoirBuilderMock.cpp | 4 +- .../ReservoirDataModel/cvfGeometryTools.cpp | 53 +++++++++++++++++++ .../ReservoirDataModel/cvfGeometryTools.h | 1 + 9 files changed, 111 insertions(+), 52 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivNNCGeometryGenerator.cpp b/ApplicationCode/ModelVisualization/RivNNCGeometryGenerator.cpp index c19912ba91..c3ba41098e 100644 --- a/ApplicationCode/ModelVisualization/RivNNCGeometryGenerator.cpp +++ b/ApplicationCode/ModelVisualization/RivNNCGeometryGenerator.cpp @@ -74,7 +74,7 @@ void RivNNCGeometryGenerator::computeArrays() std::vector vertices; std::vector triangleToNNC; - const cvf::Vec3d offset = m_offset; + const cvf::Vec3f offset( m_offset ); long long numConnections = static_cast( m_nncIndexes.isNull() ? m_nncData->connections().size() : m_nncIndexes->size() ); @@ -122,14 +122,14 @@ void RivNNCGeometryGenerator::computeArrays() if ( isVisible ) { - cvf::Vec3f vx1 = cvf::Vec3f( conn.m_polygon[0] - offset ); + cvf::Vec3f vx1 = conn.m_polygon[0] - offset; cvf::Vec3f vx2; - cvf::Vec3f vx3 = cvf::Vec3f( conn.m_polygon[1] - offset ); + cvf::Vec3f vx3 = conn.m_polygon[1] - offset; for ( size_t vxIdx = 2; vxIdx < conn.m_polygon.size(); ++vxIdx ) { vx2 = vx3; - vx3 = cvf::Vec3f( conn.m_polygon[vxIdx] - offset ); + vx3 = conn.m_polygon[vxIdx] - offset; #pragma omp critical( critical_section_RivNNCGeometryGenerator_computeArrays ) { vertices.push_back( vx1 ); diff --git a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp index 4e2d96ef06..95495add3d 100644 --- a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp +++ b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp @@ -2285,11 +2285,11 @@ void RigCaseCellResultsData::computeNncCombRiTrans() // Connection geometry - cvf::Vec3d faceAreaVec = cvf::Vec3d::ZERO; - cvf::Vec3d faceCenter = cvf::Vec3d::ZERO; + cvf::Vec3f faceAreaVec = cvf::Vec3f::ZERO; + cvf::Vec3f faceCenter = cvf::Vec3f::ZERO; // Polygon center - const std::vector& realPolygon = nncConnections[connIdx].m_polygon; + const std::vector& realPolygon = nncConnections[connIdx].m_polygon; for ( size_t pIdx = 0; pIdx < realPolygon.size(); ++pIdx ) { faceCenter += realPolygon[pIdx]; @@ -2319,7 +2319,7 @@ void RigCaseCellResultsData::computeNncCombRiTrans() ntg = ( *ntgResults )[ntgResIdx]; } - halfCellTrans = halfCellTransmissibility( perm, ntg, centerToFace, faceAreaVec ); + halfCellTrans = halfCellTransmissibility( perm, ntg, centerToFace, cvf::Vec3d( faceAreaVec ) ); } // Neighbor cell half cell transm @@ -2336,7 +2336,7 @@ void RigCaseCellResultsData::computeNncCombRiTrans() ntg = ( *ntgResults )[ntgResIdx]; } - neighborHalfCellTrans = halfCellTransmissibility( perm, ntg, centerToFace, -faceAreaVec ); + neighborHalfCellTrans = halfCellTransmissibility( perm, ntg, centerToFace, -cvf::Vec3d( faceAreaVec ) ); } double newtranTemp = newtran( cdarchy, 1.0, halfCellTrans, neighborHalfCellTrans ); @@ -2605,8 +2605,8 @@ void RigCaseCellResultsData::computeNncCombRiTRANSbyArea() for ( size_t nncConIdx = 0; nncConIdx < riAreaNormTransResults.size(); ++nncConIdx ) { - const std::vector& realPolygon = connections[nncConIdx].m_polygon; - cvf::Vec3d faceAreaVec = cvf::GeometryTools::polygonAreaNormal3D( realPolygon ); + const std::vector& realPolygon = connections[nncConIdx].m_polygon; + cvf::Vec3f faceAreaVec = cvf::GeometryTools::polygonAreaNormal3D( realPolygon ); double areaOfOverlap = faceAreaVec.length(); riAreaNormTransResults[nncConIdx] = ( *transResults )[nncConIdx] / areaOfOverlap; diff --git a/ApplicationCode/ReservoirDataModel/RigCellFaceGeometryTools.cpp b/ApplicationCode/ReservoirDataModel/RigCellFaceGeometryTools.cpp index 4c0db5da93..56510b5f51 100644 --- a/ApplicationCode/ReservoirDataModel/RigCellFaceGeometryTools.cpp +++ b/ApplicationCode/ReservoirDataModel/RigCellFaceGeometryTools.cpp @@ -119,9 +119,9 @@ cvf::StructGridInterface::FaceType return cvf::StructGridInterface::NO_FACE; } -void assignThreadConnections( std::set>& existingPairs, - RigConnectionContainer& allConnections, - RigConnectionContainer& threadConnections ) +void assignThreadConnections( std::set>& existingPairs, + RigConnectionContainer& allConnections, + RigConnectionContainer& threadConnections ) { for ( size_t i = 0; i < threadConnections.size(); ++i ) { @@ -149,7 +149,7 @@ RigConnectionContainer RigCellFaceGeometryTools::computeOtherNncs( const RigMain // by Eclipse. Use faults as basis for subset of cells to find NNC connection for. The imported connections from // Eclipse are located at the beginning of the connections vector. - std::set> nativeCellPairs; + std::set> nativeCellPairs; for ( size_t i = 0; i < nativeConnections.size(); ++i ) { @@ -167,8 +167,8 @@ RigConnectionContainer RigCellFaceGeometryTools::computeOtherNncs( const RigMain const cvf::Collection& faults = mainGrid->faults(); - std::set> existingPairs; - RigConnectionContainer otherConnections; + std::set> existingPairs; + RigConnectionContainer otherConnections; for ( int faultIdx = 0; faultIdx < (int)faults.size(); faultIdx++ ) { @@ -215,9 +215,9 @@ RigConnectionContainer RigCellFaceGeometryTools::computeOtherNncs( const RigMain } RigConnectionContainer - RigCellFaceGeometryTools::extractConnectionsForFace( const RigFault::FaultFace& face, - const RigMainGrid* mainGrid, - const std::set>& nativeCellPairs ) + RigCellFaceGeometryTools::extractConnectionsForFace( const RigFault::FaultFace& face, + const RigMainGrid* mainGrid, + const std::set>& nativeCellPairs ) { RigConnectionContainer faceConnections; size_t sourceReservoirCellIndex = face.m_nativeReservoirCellIndex; @@ -316,7 +316,7 @@ RigConnectionContainer } } - std::pair candidate( sourceReservoirCellIndex, candidateCellIndex ); + std::pair candidate( sourceReservoirCellIndex, candidateCellIndex ); if ( nativeCellPairs.count( candidate ) > 0 ) { @@ -356,18 +356,18 @@ RigConnectionContainer //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RigCellFaceGeometryTools::extractPolygon( const std::vector& nativeNodes, +std::vector RigCellFaceGeometryTools::extractPolygon( const std::vector& nativeNodes, const std::vector& connectionPolygon, const std::vector& connectionIntersections ) { - std::vector allPolygonNodes; + std::vector allPolygonNodes; for ( size_t polygonIndex : connectionPolygon ) { if ( polygonIndex < nativeNodes.size() ) - allPolygonNodes.push_back( nativeNodes[polygonIndex] ); + allPolygonNodes.push_back( cvf::Vec3f( nativeNodes[polygonIndex] ) ); else - allPolygonNodes.push_back( connectionIntersections[polygonIndex - nativeNodes.size()] ); + allPolygonNodes.push_back( cvf::Vec3f( connectionIntersections[polygonIndex - nativeNodes.size()] ) ); } return allPolygonNodes; diff --git a/ApplicationCode/ReservoirDataModel/RigCellFaceGeometryTools.h b/ApplicationCode/ReservoirDataModel/RigCellFaceGeometryTools.h index 6e98655c58..6f13746af3 100644 --- a/ApplicationCode/ReservoirDataModel/RigCellFaceGeometryTools.h +++ b/ApplicationCode/ReservoirDataModel/RigCellFaceGeometryTools.h @@ -50,10 +50,11 @@ public: const RigConnectionContainer& nativeConnections, const RigActiveCellInfo* activeCellInfo ); - static RigConnectionContainer extractConnectionsForFace( const RigFault::FaultFace& face, - const RigMainGrid* mainGrid, - const std::set>& nativeCellPairs ); - static std::vector extractPolygon( const std::vector& nativeNodes, + static RigConnectionContainer + extractConnectionsForFace( const RigFault::FaultFace& face, + const RigMainGrid* mainGrid, + const std::set>& nativeCellPairs ); + static std::vector extractPolygon( const std::vector& nativeNodes, const std::vector& connectionPolygon, const std::vector& connectionIntersections ); }; diff --git a/ApplicationCode/ReservoirDataModel/RigNncConnection.cpp b/ApplicationCode/ReservoirDataModel/RigNncConnection.cpp index 48e8d31516..1c7b789e26 100644 --- a/ApplicationCode/ReservoirDataModel/RigNncConnection.cpp +++ b/ApplicationCode/ReservoirDataModel/RigNncConnection.cpp @@ -24,8 +24,8 @@ /// //-------------------------------------------------------------------------------------------------- RigConnection::RigConnection() - : m_c1GlobIdx( cvf::UNDEFINED_SIZE_T ) - , m_c2GlobIdx( cvf::UNDEFINED_SIZE_T ) + : m_c1GlobIdx( cvf::UNDEFINED_UINT ) + , m_c2GlobIdx( cvf::UNDEFINED_UINT ) , m_c1Face( cvf::StructGridInterface::NO_FACE ) { } @@ -33,10 +33,10 @@ RigConnection::RigConnection() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RigConnection::RigConnection( size_t c1GlobIdx, - size_t c2GlobIdx, +RigConnection::RigConnection( unsigned c1GlobIdx, + unsigned c2GlobIdx, cvf::StructGridInterface::FaceType c1Face, - const std::vector& polygon ) + const std::vector& polygon ) : m_c1GlobIdx( c1GlobIdx ) , m_c2GlobIdx( c2GlobIdx ) , m_c1Face( c1Face ) @@ -94,13 +94,16 @@ bool RigConnection::operator<( const RigConnection& other ) const RigConnection RigConnectionContainer::operator[]( size_t i ) const { const auto& globIndices = m_globalIndices[i]; - return RigConnection( globIndices.first, globIndices.second, m_faces[i], m_polygons[i] ); + return RigConnection( globIndices.first, + globIndices.second, + static_cast( m_faces[i] ), + m_polygons[i] ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::pair& RigConnectionContainer::indexPair( size_t i ) +std::pair& RigConnectionContainer::indexPair( size_t i ) { return m_globalIndices[i]; } @@ -108,7 +111,7 @@ std::pair& RigConnectionContainer::indexPair( size_t i ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -cvf::StructGridInterface::FaceType& RigConnectionContainer::face( size_t i ) +unsigned char& RigConnectionContainer::face( size_t i ) { return m_faces[i]; } @@ -116,7 +119,7 @@ cvf::StructGridInterface::FaceType& RigConnectionContainer::face( size_t i ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector& RigConnectionContainer::polygon( size_t i ) +std::vector& RigConnectionContainer::polygon( size_t i ) { return m_polygons[i]; } diff --git a/ApplicationCode/ReservoirDataModel/RigNncConnection.h b/ApplicationCode/ReservoirDataModel/RigNncConnection.h index 77addb2b79..8cbccb5c28 100644 --- a/ApplicationCode/ReservoirDataModel/RigNncConnection.h +++ b/ApplicationCode/ReservoirDataModel/RigNncConnection.h @@ -31,20 +31,21 @@ class RigConnection { public: RigConnection(); - RigConnection( size_t c1GlobIdx, - size_t c2GlobIdx, + RigConnection( unsigned c1GlobIdx, + unsigned c2GlobIdx, cvf::StructGridInterface::FaceType c1Face, - const std::vector& polygon ); + const std::vector& polygon ); + RigConnection( const RigConnection& rhs ); RigConnection& operator=( RigConnection& rhs ); bool operator<( const RigConnection& other ) const; bool hasCommonArea() const; - size_t m_c1GlobIdx; - size_t m_c2GlobIdx; + unsigned m_c1GlobIdx; + unsigned m_c2GlobIdx; cvf::StructGridInterface::FaceType m_c1Face; - std::vector m_polygon; + std::vector m_polygon; }; class RigConnectionContainer @@ -52,9 +53,9 @@ class RigConnectionContainer public: RigConnection operator[]( size_t i ) const; - std::pair& indexPair( size_t i ); - cvf::StructGridInterface::FaceType& face( size_t i ); - std::vector& polygon( size_t i ); + std::pair& indexPair( size_t i ); + unsigned char& face( size_t i ); + std::vector& polygon( size_t i ); void push_back( const RigConnection& connection ); void insert( const RigConnectionContainer& other ); @@ -63,7 +64,7 @@ public: bool empty() const; private: - std::vector> m_globalIndices; - std::vector m_faces; - std::vector> m_polygons; + std::vector> m_globalIndices; + std::vector m_faces; + std::vector> m_polygons; }; diff --git a/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.cpp b/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.cpp index c420a2690c..5a27d4f4a3 100644 --- a/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.cpp +++ b/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.cpp @@ -592,8 +592,8 @@ void RigReservoirBuilderMock::addNnc( RigMainGrid* grid, size_t c2GlobalIndex = grid->cellIndexFromIJK( i2, j2, k2 ); RigConnection conn; - conn.m_c1GlobIdx = c1GlobalIndex; - conn.m_c2GlobIdx = c2GlobalIndex; + conn.m_c1GlobIdx = static_cast( c1GlobalIndex ); + conn.m_c2GlobIdx = static_cast( c2GlobalIndex ); nncConnections.push_back( conn ); } diff --git a/ApplicationCode/ReservoirDataModel/cvfGeometryTools.cpp b/ApplicationCode/ReservoirDataModel/cvfGeometryTools.cpp index 735347b90e..6f99798f32 100644 --- a/ApplicationCode/ReservoirDataModel/cvfGeometryTools.cpp +++ b/ApplicationCode/ReservoirDataModel/cvfGeometryTools.cpp @@ -787,6 +787,59 @@ cvf::Vec3d GeometryTools::polygonAreaNormal3D( const std::vector& po } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::Vec3f GeometryTools::polygonAreaNormal3D( const std::vector& polygon ) +{ + size_t pSize = polygon.size(); + switch ( pSize ) + { + case 0: + case 1: + case 2: + { + return cvf::Vec3f::ZERO; + } + break; + case 3: + { + return 0.5f * ( ( polygon[1] - polygon[0] ) ^ ( polygon[2] - polygon[0] ) ); + } + break; + case 4: + { + // Cross product of diagonal = 2*A + return 0.5f * ( ( polygon[2] - polygon[0] ) ^ ( polygon[3] - polygon[1] ) ); + } + break; + default: + { + /// JJS: + // This is possibly not the fastest approach with large polygons, where a scaled projections approach would + // be better, but I suspect this (simpler) approach is faster for small polygons, as long as we do not have + // the polygon normal up front. + // + cvf::Vec3f areaNormal( cvf::Vec3f::ZERO ); + size_t h = ( pSize - 1 ) / 2; + size_t k = ( pSize % 2 ) ? 0 : pSize - 1; + + // First quads + for ( size_t i = 1; i < h; ++i ) + { + areaNormal += ( ( polygon[2 * i] - polygon[0] ) ^ ( polygon[2 * i + 1] - polygon[2 * i - 1] ) ); + } + + // Last triangle or quad + areaNormal += ( ( polygon[2 * h] - polygon[0] ) ^ ( polygon[k] - polygon[2 * h - 1] ) ); + + areaNormal *= 0.5; + + return areaNormal; + } + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ReservoirDataModel/cvfGeometryTools.h b/ApplicationCode/ReservoirDataModel/cvfGeometryTools.h index e68a990c3f..8867a32f26 100644 --- a/ApplicationCode/ReservoirDataModel/cvfGeometryTools.h +++ b/ApplicationCode/ReservoirDataModel/cvfGeometryTools.h @@ -76,6 +76,7 @@ public: static double signedAreaPlanarPolygon( const cvf::Vec3d& planeNormal, const std::vector& polygon ); static cvf::Vec3d polygonAreaNormal3D( const std::vector& polygon ); + static cvf::Vec3f polygonAreaNormal3D( const std::vector& polygon ); enum IntersectionStatus { From 72436f0a7208cffe4f4d73a488c1df1377c986e5 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Thu, 14 May 2020 19:11:45 +0200 Subject: [PATCH 19/46] Improve NNC memory use --- .../FileInterface/RifReaderEclipseOutput.cpp | 5 +- .../RiaGrpcNNCPropertiesService.cpp | 6 +- .../RivNNCGeometryGenerator.cpp | 18 ++-- .../RimFaultInViewCollection.cpp | 4 +- .../RigCaseCellResultsData.cpp | 15 +-- .../RigCellFaceGeometryTools.cpp | 65 +++++-------- .../RigCellFaceGeometryTools.h | 6 +- .../ReservoirDataModel/RigGridBase.cpp | 10 ++ .../ReservoirDataModel/RigGridBase.h | 1 + .../ReservoirDataModel/RigMainGrid.cpp | 8 +- .../ReservoirDataModel/RigNNCData.cpp | 25 ++--- .../ReservoirDataModel/RigNncConnection.cpp | 97 +++++++++++-------- .../ReservoirDataModel/RigNncConnection.h | 46 ++++++--- ...igNumberOfFloodedPoreVolumesCalculator.cpp | 4 +- .../RigReservoirBuilderMock.cpp | 4 +- .../SocketInterface/RiaNNCCommands.cpp | 4 +- .../RiuCellAndNncPickEventHandler.cpp | 10 +- .../UserInterface/RiuResultTextBuilder.cpp | 12 +-- 18 files changed, 178 insertions(+), 162 deletions(-) diff --git a/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp b/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp index acaed54836..f394c580c2 100644 --- a/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp +++ b/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp @@ -733,9 +733,8 @@ void RifReaderEclipseOutput::transferStaticNNCData( const ecl_grid_type* mainEcl RigGridBase* grid1 = mainGrid->gridByIndex( geometry_pair->grid_nr1 ); RigGridBase* grid2 = mainGrid->gridByIndex( geometry_pair->grid_nr2 ); - RigConnection nncConnection; - nncConnection.m_c1GlobIdx = grid1->reservoirCellIndex( geometry_pair->global_index1 ); - nncConnection.m_c2GlobIdx = grid2->reservoirCellIndex( geometry_pair->global_index2 ); + RigConnection nncConnection( grid1->reservoirCellIndex( geometry_pair->global_index1 ), + grid2->reservoirCellIndex( geometry_pair->global_index2 ) ); nncConnections.push_back( nncConnection ); diff --git a/ApplicationCode/GrpcInterface/RiaGrpcNNCPropertiesService.cpp b/ApplicationCode/GrpcInterface/RiaGrpcNNCPropertiesService.cpp index d896b364bd..5dd52b902d 100644 --- a/ApplicationCode/GrpcInterface/RiaGrpcNNCPropertiesService.cpp +++ b/ApplicationCode/GrpcInterface/RiaGrpcNNCPropertiesService.cpp @@ -97,9 +97,9 @@ grpc::Status RiaNNCConnectionsStateHandler::assignReply( rips::NNCConnections* r reply->mutable_connections()->Reserve( (int)packageSize ); for ( ; indexInPackage < packageSize && m_currentIdx < connectionCount; ++indexInPackage ) { - RigConnection connection = connections[m_currentIdx]; - const RigCell& cell1 = mainGrid->globalCellArray()[connection.m_c1GlobIdx]; - const RigCell& cell2 = mainGrid->globalCellArray()[connection.m_c2GlobIdx]; + const RigConnection& connection = connections[m_currentIdx]; + const RigCell& cell1 = mainGrid->globalCellArray()[connection.c1GlobIdx()]; + const RigCell& cell2 = mainGrid->globalCellArray()[connection.c2GlobIdx()]; NNCConnection* nncConnection = reply->add_connections(); nncConnection->set_allocated_cell1( createConnectionVec3i( cell1 ) ); diff --git a/ApplicationCode/ModelVisualization/RivNNCGeometryGenerator.cpp b/ApplicationCode/ModelVisualization/RivNNCGeometryGenerator.cpp index c3ba41098e..cd3998fca0 100644 --- a/ApplicationCode/ModelVisualization/RivNNCGeometryGenerator.cpp +++ b/ApplicationCode/ModelVisualization/RivNNCGeometryGenerator.cpp @@ -97,7 +97,7 @@ void RivNNCGeometryGenerator::computeArrays() const RigConnection& conn = m_nncData->connections()[conIdx]; - if ( conn.m_polygon.size() ) + if ( conn.polygon().size() ) { bool isVisible = true; if ( isVisibilityCalcActive ) @@ -105,15 +105,15 @@ void RivNNCGeometryGenerator::computeArrays() bool cell1Visible = false; bool cell2Visible = false; - if ( ( *allCells )[conn.m_c1GlobIdx].hostGrid() == m_grid.p() ) + if ( ( *allCells )[conn.c1GlobIdx()].hostGrid() == m_grid.p() ) { - size_t cell1GridLocalIdx = ( *allCells )[conn.m_c1GlobIdx].gridLocalCellIndex(); + size_t cell1GridLocalIdx = ( *allCells )[conn.c1GlobIdx()].gridLocalCellIndex(); cell1Visible = ( *m_cellVisibility )[cell1GridLocalIdx]; } - if ( ( *allCells )[conn.m_c2GlobIdx].hostGrid() == m_grid.p() ) + if ( ( *allCells )[conn.c2GlobIdx()].hostGrid() == m_grid.p() ) { - size_t cell2GridLocalIdx = ( *allCells )[conn.m_c2GlobIdx].gridLocalCellIndex(); + size_t cell2GridLocalIdx = ( *allCells )[conn.c2GlobIdx()].gridLocalCellIndex(); cell2Visible = ( *m_cellVisibility )[cell2GridLocalIdx]; } @@ -122,14 +122,14 @@ void RivNNCGeometryGenerator::computeArrays() if ( isVisible ) { - cvf::Vec3f vx1 = conn.m_polygon[0] - offset; + cvf::Vec3f vx1 = conn.polygon()[0] - offset; cvf::Vec3f vx2; - cvf::Vec3f vx3 = conn.m_polygon[1] - offset; + cvf::Vec3f vx3 = conn.polygon()[1] - offset; - for ( size_t vxIdx = 2; vxIdx < conn.m_polygon.size(); ++vxIdx ) + for ( size_t vxIdx = 2; vxIdx < conn.polygon().size(); ++vxIdx ) { vx2 = vx3; - vx3 = conn.m_polygon[vxIdx] - offset; + vx3 = conn.polygon()[vxIdx] - offset; #pragma omp critical( critical_section_RivNNCGeometryGenerator_computeArrays ) { vertices.push_back( vx1 ); diff --git a/ApplicationCode/ProjectDataModel/RimFaultInViewCollection.cpp b/ApplicationCode/ProjectDataModel/RimFaultInViewCollection.cpp index eb5edd50b0..50a3026b2f 100644 --- a/ApplicationCode/ProjectDataModel/RimFaultInViewCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimFaultInViewCollection.cpp @@ -280,7 +280,7 @@ void RimFaultInViewCollection::syncronizeFaults() { size_t gridLocalCellIndex; const RigGridBase* hostGrid = - mainGrid->gridAndGridLocalIdxFromGlobalCellIdx( nncConnections[connIndex].m_c1GlobIdx, + mainGrid->gridAndGridLocalIdxFromGlobalCellIdx( nncConnections[connIndex].c1GlobIdx(), &gridLocalCellIndex ); size_t i, j, k; @@ -303,7 +303,7 @@ void RimFaultInViewCollection::syncronizeFaults() { size_t gridLocalCellIndex; const RigGridBase* hostGrid = - mainGrid->gridAndGridLocalIdxFromGlobalCellIdx( nncConnections[connIndex].m_c2GlobIdx, + mainGrid->gridAndGridLocalIdxFromGlobalCellIdx( nncConnections[connIndex].c2GlobIdx(), &gridLocalCellIndex ); size_t i, j, k; diff --git a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp index 95495add3d..8640c4fafb 100644 --- a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp +++ b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp @@ -2242,9 +2242,10 @@ void RigCaseCellResultsData::computeNncCombRiTrans() const RigConnectionContainer& nncConnections = m_ownerMainGrid->nncData()->connections(); for ( size_t connIdx = 0; connIdx < nncConnections.size(); connIdx++ ) { - size_t nativeResvCellIndex = nncConnections[connIdx].m_c1GlobIdx; - size_t neighborResvCellIdx = nncConnections[connIdx].m_c2GlobIdx; - cvf::StructGridInterface::FaceType faceId = nncConnections[connIdx].m_c1Face; + size_t nativeResvCellIndex = nncConnections[connIdx].c1GlobIdx(); + size_t neighborResvCellIdx = nncConnections[connIdx].c2GlobIdx(); + cvf::StructGridInterface::FaceType faceId = + static_cast( nncConnections[connIdx].face() ); ResultIndexFunction permIdxFunc = nullptr; std::vector* permResults = nullptr; @@ -2289,7 +2290,7 @@ void RigCaseCellResultsData::computeNncCombRiTrans() cvf::Vec3f faceCenter = cvf::Vec3f::ZERO; // Polygon center - const std::vector& realPolygon = nncConnections[connIdx].m_polygon; + const std::vector& realPolygon = nncConnections[connIdx].polygon(); for ( size_t pIdx = 0; pIdx < realPolygon.size(); ++pIdx ) { faceCenter += realPolygon[pIdx]; @@ -2605,7 +2606,7 @@ void RigCaseCellResultsData::computeNncCombRiTRANSbyArea() for ( size_t nncConIdx = 0; nncConIdx < riAreaNormTransResults.size(); ++nncConIdx ) { - const std::vector& realPolygon = connections[nncConIdx].m_polygon; + const std::vector& realPolygon = connections[nncConIdx].polygon(); cvf::Vec3f faceAreaVec = cvf::GeometryTools::polygonAreaNormal3D( realPolygon ); double areaOfOverlap = faceAreaVec.length(); @@ -3070,8 +3071,8 @@ void RigCaseCellResultsData::computeAllanResults( RigCaseCellResultsData* cellRe { const auto& c = nncConnections[i]; - size_t globCellIdx1 = c.m_c1GlobIdx; - size_t globCellIdx2 = c.m_c2GlobIdx; + size_t globCellIdx1 = c.c1GlobIdx(); + size_t globCellIdx2 = c.c2GlobIdx(); int formation1 = (int)( fnData[globCellIdx1] ); int formation2 = (int)( fnData[globCellIdx2] ); diff --git a/ApplicationCode/ReservoirDataModel/RigCellFaceGeometryTools.cpp b/ApplicationCode/ReservoirDataModel/RigCellFaceGeometryTools.cpp index 56510b5f51..4a40a28e3e 100644 --- a/ApplicationCode/ReservoirDataModel/RigCellFaceGeometryTools.cpp +++ b/ApplicationCode/ReservoirDataModel/RigCellFaceGeometryTools.cpp @@ -119,23 +119,12 @@ cvf::StructGridInterface::FaceType return cvf::StructGridInterface::NO_FACE; } -void assignThreadConnections( std::set>& existingPairs, - RigConnectionContainer& allConnections, - RigConnectionContainer& threadConnections ) +void assignThreadConnections( RigConnectionContainer& allConnections, RigConnectionContainer& threadConnections ) { - for ( size_t i = 0; i < threadConnections.size(); ++i ) - { #pragma omp critical - { - RigConnection connection = threadConnections[i]; - auto it = existingPairs.emplace( connection.m_c1GlobIdx, connection.m_c2GlobIdx ); - if ( it.second ) - { - allConnections.push_back( connection ); - } - } + { + allConnections.push_back( threadConnections ); } - threadConnections.clear(); } //-------------------------------------------------------------------------------------------------- @@ -154,7 +143,7 @@ RigConnectionContainer RigCellFaceGeometryTools::computeOtherNncs( const RigMain for ( size_t i = 0; i < nativeConnections.size(); ++i ) { RigConnection c = nativeConnections[i]; - nativeCellPairs.emplace( c.m_c1GlobIdx, c.m_c2GlobIdx ); + nativeCellPairs.emplace( static_cast( c.c1GlobIdx() ), static_cast( c.c2GlobIdx() ) ); } if ( nativeConnections.size() != nativeCellPairs.size() ) @@ -167,8 +156,7 @@ RigConnectionContainer RigCellFaceGeometryTools::computeOtherNncs( const RigMain const cvf::Collection& faults = mainGrid->faults(); - std::set> existingPairs; - RigConnectionContainer otherConnections; + RigConnectionContainer otherConnections; for ( int faultIdx = 0; faultIdx < (int)faults.size(); faultIdx++ ) { @@ -194,38 +182,39 @@ RigConnectionContainer RigCellFaceGeometryTools::computeOtherNncs( const RigMain if ( atLeastOneCellActive ) activeFaceIndices.push_back( faceIdx ); } + size_t totalNumberOfConnections = 0u; #pragma omp parallel { RigConnectionContainer threadConnections; -#pragma omp for schedule( guided ) +#pragma omp for schedule( guided ) reduction( + : totalNumberOfConnections ) for ( int activeFaceIdx = 0; activeFaceIdx < static_cast( activeFaceIndices.size() ); activeFaceIdx++ ) { - size_t faceIdx = activeFaceIndices[activeFaceIdx]; - const RigFault::FaultFace& f = faultFaces[faceIdx]; - - RigConnectionContainer faceConnections = extractConnectionsForFace( f, mainGrid, nativeCellPairs ); - threadConnections.insert( faceConnections ); + size_t faceIdx = activeFaceIndices[activeFaceIdx]; + extractConnectionsForFace( faultFaces[faceIdx], mainGrid, nativeCellPairs, threadConnections ); } +#pragma omp barrier + otherConnections.reserve( otherConnections.size() + totalNumberOfConnections ); + // Merge together connections per thread - assignThreadConnections( existingPairs, otherConnections, threadConnections ); + assignThreadConnections( otherConnections, threadConnections ); } // end parallel region } + otherConnections.remove_duplicates(); return otherConnections; } -RigConnectionContainer - RigCellFaceGeometryTools::extractConnectionsForFace( const RigFault::FaultFace& face, - const RigMainGrid* mainGrid, - const std::set>& nativeCellPairs ) +void RigCellFaceGeometryTools::extractConnectionsForFace( const RigFault::FaultFace& face, + const RigMainGrid* mainGrid, + const std::set>& nativeCellPairs, + RigConnectionContainer& connections ) { - RigConnectionContainer faceConnections; size_t sourceReservoirCellIndex = face.m_nativeReservoirCellIndex; cvf::StructGridInterface::FaceType sourceCellFace = face.m_nativeFace; if ( sourceReservoirCellIndex >= mainGrid->cellCount() ) { - return {}; + return; } const std::vector& mainGridNodes = mainGrid->nodes(); @@ -316,7 +305,8 @@ RigConnectionContainer } } - std::pair candidate( sourceReservoirCellIndex, candidateCellIndex ); + std::pair candidate( static_cast( sourceReservoirCellIndex ), + static_cast( candidateCellIndex ) ); if ( nativeCellPairs.count( candidate ) > 0 ) { @@ -340,17 +330,14 @@ RigConnectionContainer if ( foundOverlap ) { - RigConnection conn; - conn.m_c1GlobIdx = sourceReservoirCellIndex; - conn.m_c2GlobIdx = candidateCellIndex; - conn.m_c1Face = sourceCellFace; + RigConnection conn( sourceReservoirCellIndex, + candidateCellIndex, + sourceCellFace, + RigCellFaceGeometryTools::extractPolygon( mainGridNodes, polygon, intersections ) ); - conn.m_polygon = RigCellFaceGeometryTools::extractPolygon( mainGridNodes, polygon, intersections ); - - faceConnections.push_back( conn ); + connections.push_back( conn ); } } - return faceConnections; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ReservoirDataModel/RigCellFaceGeometryTools.h b/ApplicationCode/ReservoirDataModel/RigCellFaceGeometryTools.h index 6f13746af3..c0d4be189b 100644 --- a/ApplicationCode/ReservoirDataModel/RigCellFaceGeometryTools.h +++ b/ApplicationCode/ReservoirDataModel/RigCellFaceGeometryTools.h @@ -50,10 +50,10 @@ public: const RigConnectionContainer& nativeConnections, const RigActiveCellInfo* activeCellInfo ); - static RigConnectionContainer - extractConnectionsForFace( const RigFault::FaultFace& face, + static void extractConnectionsForFace( const RigFault::FaultFace& face, const RigMainGrid* mainGrid, - const std::set>& nativeCellPairs ); + const std::set>& nativeCellPairs, + RigConnectionContainer& connections ); static std::vector extractPolygon( const std::vector& nativeNodes, const std::vector& connectionPolygon, const std::vector& connectionIntersections ); diff --git a/ApplicationCode/ReservoirDataModel/RigGridBase.cpp b/ApplicationCode/ReservoirDataModel/RigGridBase.cpp index 1ede4502b5..ff42c7aa8c 100644 --- a/ApplicationCode/ReservoirDataModel/RigGridBase.cpp +++ b/ApplicationCode/ReservoirDataModel/RigGridBase.cpp @@ -176,6 +176,16 @@ size_t RigGridBase::cellIndexFromIJK( size_t i, size_t j, size_t k ) const return ci; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t RigGridBase::cellIndexFromIJKUnguarded( size_t i, size_t j, size_t k ) const +{ + size_t ci = i + j * ( m_gridPointDimensions.x() - 1 ) + + k * ( ( m_gridPointDimensions.x() - 1 ) * ( m_gridPointDimensions.y() - 1 ) ); + return ci; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ReservoirDataModel/RigGridBase.h b/ApplicationCode/ReservoirDataModel/RigGridBase.h index 6da2b79e0f..6d99c44b3d 100644 --- a/ApplicationCode/ReservoirDataModel/RigGridBase.h +++ b/ApplicationCode/ReservoirDataModel/RigGridBase.h @@ -91,6 +91,7 @@ public: cvf::Vec3d displayModelOffset() const override; size_t cellIndexFromIJK( size_t i, size_t j, size_t k ) const override; + size_t cellIndexFromIJKUnguarded( size_t i, size_t j, size_t k ) const; bool ijkFromCellIndex( size_t cellIndex, size_t* i, size_t* j, size_t* k ) const override; bool cellIJKFromCoordinate( const cvf::Vec3d& coord, size_t* i, size_t* j, size_t* k ) const override; diff --git a/ApplicationCode/ReservoirDataModel/RigMainGrid.cpp b/ApplicationCode/ReservoirDataModel/RigMainGrid.cpp index 25b5dc2703..0515e667a4 100644 --- a/ApplicationCode/ReservoirDataModel/RigMainGrid.cpp +++ b/ApplicationCode/ReservoirDataModel/RigMainGrid.cpp @@ -574,16 +574,16 @@ void RigMainGrid::distributeNNCsToFaults() int fIdx1 = RigFaultsPrCellAccumulator::NO_FAULT; int fIdx2 = RigFaultsPrCellAccumulator::NO_FAULT; - if ( conn.m_c1Face != StructGridInterface::NO_FACE ) + if ( conn.face() != StructGridInterface::NO_FACE ) { - fIdx1 = m_faultsPrCellAcc->faultIdx( conn.m_c1GlobIdx, conn.m_c1Face ); - fIdx2 = m_faultsPrCellAcc->faultIdx( conn.m_c2GlobIdx, StructGridInterface::oppositeFace( conn.m_c1Face ) ); + fIdx1 = m_faultsPrCellAcc->faultIdx( conn.c1GlobIdx(), conn.face() ); + fIdx2 = m_faultsPrCellAcc->faultIdx( conn.c2GlobIdx(), StructGridInterface::oppositeFace( conn.face() ) ); } if ( fIdx1 < 0 && fIdx2 < 0 ) { cvf::String lgrString( "Same Grid" ); - if ( m_cells[conn.m_c1GlobIdx].hostGrid() != m_cells[conn.m_c2GlobIdx].hostGrid() ) + if ( m_cells[conn.c1GlobIdx()].hostGrid() != m_cells[conn.c2GlobIdx()].hostGrid() ) { lgrString = "Different Grid"; } diff --git a/ApplicationCode/ReservoirDataModel/RigNNCData.cpp b/ApplicationCode/ReservoirDataModel/RigNNCData.cpp index 5eec61884e..d9ec761d5e 100644 --- a/ApplicationCode/ReservoirDataModel/RigNNCData.cpp +++ b/ApplicationCode/ReservoirDataModel/RigNNCData.cpp @@ -41,8 +41,8 @@ void RigNNCData::processNativeConnections( const RigMainGrid& mainGrid ) for ( size_t cnIdx = 0; cnIdx < m_connections.size(); ++cnIdx ) { - const RigCell& c1 = mainGrid.globalCellArray()[m_connections[cnIdx].m_c1GlobIdx]; - const RigCell& c2 = mainGrid.globalCellArray()[m_connections[cnIdx].m_c2GlobIdx]; + const RigCell& c1 = mainGrid.globalCellArray()[m_connections[cnIdx].c1GlobIdx()]; + const RigCell& c2 = mainGrid.globalCellArray()[m_connections[cnIdx].c2GlobIdx()]; std::vector connectionPolygon; std::vector connectionIntersections; @@ -53,21 +53,9 @@ void RigNNCData::processNativeConnections( const RigMainGrid& mainGrid ) if ( connectionFace != cvf::StructGridInterface::NO_FACE ) { - // Found an overlap polygon. Store data about connection - - m_connections.face( cnIdx ) = connectionFace; - - m_connections.polygon( cnIdx ) = - RigCellFaceGeometryTools::extractPolygon( mainGrid.nodes(), connectionPolygon, connectionIntersections ); - - // Add to search map, possibly not needed - // m_cellIdxToFaceToConnectionIdxMap[m_connections[cnIdx].m_c1GlobIdx][connectionFace].push_back(cnIdx); - // m_cellIdxToFaceToConnectionIdxMap[m_connections[cnIdx].m_c2GlobIdx][cvf::StructGridInterface::oppositeFace(connectionFace].push_back(cnIdx); - } - else - { - // cvf::Trace::show("NNC: No overlap found for : C1: " + cvf::String((int)m_connections[cnIdx].m_c1GlobIdx) - // + "C2: " + cvf::String((int)m_connections[cnIdx].m_c2GlobIdx)); + m_connections[cnIdx].setFace( connectionFace ); + m_connections[cnIdx].setPolygon( + RigCellFaceGeometryTools::extractPolygon( mainGrid.nodes(), connectionPolygon, connectionIntersections ) ); } } } @@ -78,13 +66,12 @@ void RigNNCData::processNativeConnections( const RigMainGrid& mainGrid ) void RigNNCData::computeCompleteSetOfNncs( const RigMainGrid* mainGrid, const RigActiveCellInfo* activeCellInfo ) { m_nativeConnectionCount = m_connections.size(); - RigConnectionContainer otherConnections = RigCellFaceGeometryTools::computeOtherNncs( mainGrid, m_connections, activeCellInfo ); if ( !otherConnections.empty() ) { - m_connections.insert( otherConnections ); + m_connections.push_back( otherConnections ); // Transmissibility values from Eclipse has been read into propertyNameCombTrans in // RifReaderEclipseOutput::transferStaticNNCData(). Initialize computed NNCs with zero transmissibility diff --git a/ApplicationCode/ReservoirDataModel/RigNncConnection.cpp b/ApplicationCode/ReservoirDataModel/RigNncConnection.cpp index 1c7b789e26..2d0f93f28f 100644 --- a/ApplicationCode/ReservoirDataModel/RigNncConnection.cpp +++ b/ApplicationCode/ReservoirDataModel/RigNncConnection.cpp @@ -18,7 +18,7 @@ #include "RigNncConnection.h" -#include "cvfMath.h" +#include "cvfAssert.h" //-------------------------------------------------------------------------------------------------- /// @@ -26,7 +26,7 @@ RigConnection::RigConnection() : m_c1GlobIdx( cvf::UNDEFINED_UINT ) , m_c2GlobIdx( cvf::UNDEFINED_UINT ) - , m_c1Face( cvf::StructGridInterface::NO_FACE ) + , m_c1Face( static_cast( cvf::StructGridInterface::NO_FACE ) ) { } @@ -39,11 +39,26 @@ RigConnection::RigConnection( unsigned c1GlobIdx, const std::vector& polygon ) : m_c1GlobIdx( c1GlobIdx ) , m_c2GlobIdx( c2GlobIdx ) - , m_c1Face( c1Face ) + , m_c1Face( static_cast( c1Face ) ) , m_polygon( polygon ) { } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigConnection::RigConnection( size_t c1GlobIdx, + size_t c2GlobIdx, + cvf::StructGridInterface::FaceType c1Face, + const std::vector& polygon ) + : m_c1GlobIdx( static_cast( c1GlobIdx ) ) + , m_c2GlobIdx( static_cast( c2GlobIdx ) ) + , m_c1Face( static_cast( c1Face ) ) + , m_polygon( polygon ) +{ + CVF_ASSERT( c1GlobIdx < std::numeric_limits::max() && c2GlobIdx < std::numeric_limits::max() ); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -58,7 +73,7 @@ RigConnection::RigConnection( const RigConnection& rhs ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RigConnection& RigConnection::operator=( RigConnection& rhs ) +RigConnection& RigConnection::operator=( const RigConnection& rhs ) { m_c1GlobIdx = rhs.m_c1GlobIdx; m_c2GlobIdx = rhs.m_c2GlobIdx; @@ -75,6 +90,14 @@ bool RigConnection::hasCommonArea() const return m_polygon.size() > 0; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RigConnection::operator==( const RigConnection& rhs ) +{ + return m_c1GlobIdx == rhs.m_c1GlobIdx && m_c2GlobIdx == rhs.m_c2GlobIdx; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -91,37 +114,17 @@ bool RigConnection::operator<( const RigConnection& other ) const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RigConnection RigConnectionContainer::operator[]( size_t i ) const +const RigConnection& RigConnectionContainer::operator[]( size_t i ) const { - const auto& globIndices = m_globalIndices[i]; - return RigConnection( globIndices.first, - globIndices.second, - static_cast( m_faces[i] ), - m_polygons[i] ); + return m_connections[i]; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::pair& RigConnectionContainer::indexPair( size_t i ) +RigConnection& RigConnectionContainer::operator[]( size_t i ) { - return m_globalIndices[i]; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -unsigned char& RigConnectionContainer::face( size_t i ) -{ - return m_faces[i]; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -std::vector& RigConnectionContainer::polygon( size_t i ) -{ - return m_polygons[i]; + return m_connections[i]; } //-------------------------------------------------------------------------------------------------- @@ -129,19 +132,15 @@ std::vector& RigConnectionContainer::polygon( size_t i ) //-------------------------------------------------------------------------------------------------- void RigConnectionContainer::push_back( const RigConnection& connection ) { - m_globalIndices.push_back( std::make_pair( connection.m_c1GlobIdx, connection.m_c2GlobIdx ) ); - m_faces.push_back( connection.m_c1Face ); - m_polygons.push_back( connection.m_polygon ); + m_connections.push_back( connection ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigConnectionContainer::insert( const RigConnectionContainer& other ) +void RigConnectionContainer::push_back( const RigConnectionContainer& other ) { - m_globalIndices.insert( m_globalIndices.end(), other.m_globalIndices.begin(), other.m_globalIndices.end() ); - m_faces.insert( m_faces.end(), other.m_faces.begin(), other.m_faces.end() ); - m_polygons.insert( m_polygons.end(), other.m_polygons.begin(), other.m_polygons.end() ); + m_connections.insert( m_connections.end(), other.m_connections.begin(), other.m_connections.end() ); } //-------------------------------------------------------------------------------------------------- @@ -149,7 +148,7 @@ void RigConnectionContainer::insert( const RigConnectionContainer& other ) //-------------------------------------------------------------------------------------------------- size_t RigConnectionContainer::size() const { - return m_globalIndices.size(); + return m_connections.size(); } //-------------------------------------------------------------------------------------------------- @@ -157,9 +156,7 @@ size_t RigConnectionContainer::size() const //-------------------------------------------------------------------------------------------------- void RigConnectionContainer::clear() { - m_globalIndices.clear(); - m_faces.clear(); - m_polygons.clear(); + m_connections.clear(); } //-------------------------------------------------------------------------------------------------- @@ -167,5 +164,25 @@ void RigConnectionContainer::clear() //-------------------------------------------------------------------------------------------------- bool RigConnectionContainer::empty() const { - return m_globalIndices.empty(); + return m_connections.empty(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigConnectionContainer::remove_duplicates() +{ + std::sort( m_connections.begin(), m_connections.end() ); + m_connections.erase( std::unique( m_connections.begin(), m_connections.end() ), m_connections.end() ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigConnectionContainer::reserve( size_t requiredSize ) +{ + if ( m_connections.capacity() < requiredSize ) + { + m_connections.reserve( requiredSize ); + } } diff --git a/ApplicationCode/ReservoirDataModel/RigNncConnection.h b/ApplicationCode/ReservoirDataModel/RigNncConnection.h index 8cbccb5c28..3cc215e614 100644 --- a/ApplicationCode/ReservoirDataModel/RigNncConnection.h +++ b/ApplicationCode/ReservoirDataModel/RigNncConnection.h @@ -33,38 +33,54 @@ public: RigConnection(); RigConnection( unsigned c1GlobIdx, unsigned c2GlobIdx, - cvf::StructGridInterface::FaceType c1Face, - const std::vector& polygon ); + cvf::StructGridInterface::FaceType c1Face = cvf::StructGridInterface::NO_FACE, + const std::vector& polygon = {} ); + + RigConnection( size_t c1GlobIdx, + size_t c2GlobIdx, + cvf::StructGridInterface::FaceType c1Face = cvf::StructGridInterface::NO_FACE, + const std::vector& polygon = {} ); RigConnection( const RigConnection& rhs ); - RigConnection& operator=( RigConnection& rhs ); + RigConnection& operator=( const RigConnection& rhs ); + bool operator==( const RigConnection& rhs ); bool operator<( const RigConnection& other ) const; bool hasCommonArea() const; - unsigned m_c1GlobIdx; - unsigned m_c2GlobIdx; - cvf::StructGridInterface::FaceType m_c1Face; - std::vector m_polygon; + inline size_t c1GlobIdx() const { return m_c1GlobIdx; } + inline size_t c2GlobIdx() const { return m_c2GlobIdx; } + inline cvf::StructGridInterface::FaceType face() const + { + return static_cast( m_c1Face ); + } + inline void setFace( cvf::StructGridInterface::FaceType face ) { m_c1Face = static_cast( face ); } + inline const std::vector& polygon() const { return m_polygon; } + inline void setPolygon( const std::vector& polygon ) { m_polygon = polygon; } + +private: + unsigned m_c1GlobIdx; + unsigned m_c2GlobIdx; + unsigned char m_c1Face; + std::vector m_polygon; }; class RigConnectionContainer { public: - RigConnection operator[]( size_t i ) const; + RigConnectionContainer() = default; - std::pair& indexPair( size_t i ); - unsigned char& face( size_t i ); - std::vector& polygon( size_t i ); + const RigConnection& operator[]( size_t i ) const; + RigConnection& operator[]( size_t i ); void push_back( const RigConnection& connection ); - void insert( const RigConnectionContainer& other ); + void push_back( const RigConnectionContainer& connection ); size_t size() const; void clear(); bool empty() const; + void remove_duplicates(); + void reserve( size_t requiredSize ); private: - std::vector> m_globalIndices; - std::vector m_faces; - std::vector> m_polygons; + std::vector m_connections; }; diff --git a/ApplicationCode/ReservoirDataModel/RigNumberOfFloodedPoreVolumesCalculator.cpp b/ApplicationCode/ReservoirDataModel/RigNumberOfFloodedPoreVolumesCalculator.cpp index 7d4cddec2e..fd9db5e59e 100644 --- a/ApplicationCode/ReservoirDataModel/RigNumberOfFloodedPoreVolumesCalculator.cpp +++ b/ApplicationCode/ReservoirDataModel/RigNumberOfFloodedPoreVolumesCalculator.cpp @@ -306,10 +306,10 @@ void RigNumberOfFloodedPoreVolumesCalculator::distributeNNCflow( const RigConnec RigConnection connection = connections[connectionIndex]; double connectionValue = flowrateNNC->at( connectionIndex ); - size_t cell1Index = connection.m_c1GlobIdx; + size_t cell1Index = connection.c1GlobIdx(); size_t cell1ResultIndex = actCellInfo->cellResultIndex( cell1Index ); - size_t cell2Index = connection.m_c2GlobIdx; + size_t cell2Index = connection.c2GlobIdx(); size_t cell2ResultIndex = actCellInfo->cellResultIndex( cell2Index ); if ( connectionValue > 0 ) diff --git a/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.cpp b/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.cpp index 5a27d4f4a3..9d74c6c00d 100644 --- a/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.cpp +++ b/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.cpp @@ -591,9 +591,7 @@ void RigReservoirBuilderMock::addNnc( RigMainGrid* grid, size_t c1GlobalIndex = grid->cellIndexFromIJK( i1, j1, k1 ); size_t c2GlobalIndex = grid->cellIndexFromIJK( i2, j2, k2 ); - RigConnection conn; - conn.m_c1GlobIdx = static_cast( c1GlobalIndex ); - conn.m_c2GlobIdx = static_cast( c2GlobalIndex ); + RigConnection conn( c1GlobalIndex, c2GlobalIndex ); nncConnections.push_back( conn ); } diff --git a/ApplicationCode/SocketInterface/RiaNNCCommands.cpp b/ApplicationCode/SocketInterface/RiaNNCCommands.cpp index dbda8325fb..d7fe98f97f 100644 --- a/ApplicationCode/SocketInterface/RiaNNCCommands.cpp +++ b/ApplicationCode/SocketInterface/RiaNNCCommands.cpp @@ -74,8 +74,8 @@ public: { RigConnection connection = mainGrid->nncData()->connections()[i]; - const RigCell& cell1 = mainGrid->globalCellArray()[connection.m_c1GlobIdx]; - const RigCell& cell2 = mainGrid->globalCellArray()[connection.m_c2GlobIdx]; + const RigCell& cell1 = mainGrid->globalCellArray()[connection.c1GlobIdx()]; + const RigCell& cell2 = mainGrid->globalCellArray()[connection.c2GlobIdx()]; sendCellInfo( socketStream, cell1 ); sendCellInfo( socketStream, cell2 ); diff --git a/ApplicationCode/UserInterface/RiuCellAndNncPickEventHandler.cpp b/ApplicationCode/UserInterface/RiuCellAndNncPickEventHandler.cpp index a09a4e2e95..3240ccbd25 100644 --- a/ApplicationCode/UserInterface/RiuCellAndNncPickEventHandler.cpp +++ b/ApplicationCode/UserInterface/RiuCellAndNncPickEventHandler.cpp @@ -221,7 +221,7 @@ bool RiuCellAndNncPickEventHandler::handle3dPickEvent( const Ric3dPickEvent& eve RigMainGrid* mainGrid = eclipseView->eclipseCase()->eclipseCaseData()->mainGrid(); const RigConnection& nncConn = mainGrid->nncData()->connections()[nncIndex]; - mainGrid->gridAndGridLocalIdxFromGlobalCellIdx( nncConn.m_c1GlobIdx, &gridLocalCellIndex ); + mainGrid->gridAndGridLocalIdxFromGlobalCellIdx( nncConn.c1GlobIdx(), &gridLocalCellIndex ); } } else @@ -298,10 +298,10 @@ bool RiuCellAndNncPickEventHandler::handle3dPickEvent( const Ric3dPickEvent& eve const RigConnection& nncConn = mainGrid->nncData()->connections()[nncIndex]; size_t c1LocalIdx = cvf::UNDEFINED_SIZE_T; - const RigGridBase* grid1 = mainGrid->gridAndGridLocalIdxFromGlobalCellIdx(nncConn.m_c1GlobIdx, &c1LocalIdx); + const RigGridBase* grid1 = mainGrid->gridAndGridLocalIdxFromGlobalCellIdx(nncConn.c1GlobIdx(), &c1LocalIdx); size_t c1GridIdx = grid1->gridIndex(); size_t c2LocalIdx = cvf::UNDEFINED_SIZE_T; - const RigGridBase* grid2 = mainGrid->gridAndGridLocalIdxFromGlobalCellIdx(nncConn.m_c2GlobIdx, &c2LocalIdx); + const RigGridBase* grid2 = mainGrid->gridAndGridLocalIdxFromGlobalCellIdx(nncConn.c2GlobIdx(), &c2LocalIdx); size_t c2GridIdx = grid2->gridIndex(); if (gridLocalCellIndex == c1LocalIdx && gridIndex == c1GridIdx) @@ -311,7 +311,7 @@ bool RiuCellAndNncPickEventHandler::handle3dPickEvent( const Ric3dPickEvent& eve if (face == cvf::StructGridInterface::NO_FACE) { - face = nncConn.m_c1Face; + face = nncConn.face(); } else { @@ -324,7 +324,7 @@ bool RiuCellAndNncPickEventHandler::handle3dPickEvent( const Ric3dPickEvent& eve gridIndex = c1GridIdx; if (face == cvf::StructGridInterface::NO_FACE) { - face = cvf::StructGridInterface::oppositeFace(nncConn.m_c1Face); + face = cvf::StructGridInterface::oppositeFace(nncConn.face()); } else { diff --git a/ApplicationCode/UserInterface/RiuResultTextBuilder.cpp b/ApplicationCode/UserInterface/RiuResultTextBuilder.cpp index 0f345f1a35..538e33a662 100644 --- a/ApplicationCode/UserInterface/RiuResultTextBuilder.cpp +++ b/ApplicationCode/UserInterface/RiuResultTextBuilder.cpp @@ -446,7 +446,7 @@ QString RiuResultTextBuilder::nncResultText() { const RigConnection& conn = nncData->connections()[m_nncIndex]; - cvf::StructGridInterface::FaceEnum face( conn.m_c1Face ); + cvf::StructGridInterface::FaceEnum face( conn.face() ); if ( m_viewWithFaultsSettings && m_viewWithFaultsSettings->currentFaultResultColors() ) { @@ -801,12 +801,12 @@ QString RiuResultTextBuilder::nncDetails() text += "-- NNC details --\n"; { const RigConnection& conn = nncData->connections()[m_nncIndex]; - cvf::StructGridInterface::FaceEnum face( conn.m_c1Face ); + cvf::StructGridInterface::FaceEnum face( conn.face() ); // First cell of NNC { - CVF_ASSERT( conn.m_c1GlobIdx < grid->globalCellArray().size() ); - const RigCell& cell = grid->globalCellArray()[conn.m_c1GlobIdx]; + CVF_ASSERT( conn.c1GlobIdx() < grid->globalCellArray().size() ); + const RigCell& cell = grid->globalCellArray()[conn.c1GlobIdx()]; RigGridBase* hostGrid = cell.hostGrid(); size_t gridLocalCellIndex = cell.gridLocalCellIndex(); @@ -831,8 +831,8 @@ QString RiuResultTextBuilder::nncDetails() // Second cell of NNC { - CVF_ASSERT( conn.m_c2GlobIdx < grid->globalCellArray().size() ); - const RigCell& cell = grid->globalCellArray()[conn.m_c2GlobIdx]; + CVF_ASSERT( conn.c2GlobIdx() < grid->globalCellArray().size() ); + const RigCell& cell = grid->globalCellArray()[conn.c2GlobIdx()]; RigGridBase* hostGrid = cell.hostGrid(); size_t gridLocalCellIndex = cell.gridLocalCellIndex(); From 04243dfa64de099f1680de66d8bb87df152cd16f Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 15 May 2020 11:45:50 +0200 Subject: [PATCH 20/46] NNC : Add settings to preferences and compute on demand Ported several commits from dev #5913 Import NNC : Do not compute NNCs if importNNCs is disabled in preferences #5914 Import faults : Avoid computation of faults if turned off in preferences #5925 NNC computations : Add flag in preferences to include inactive cells Allan : Do not test for cached data in pytest #5925 Simplify computation of fault data #5932 NNC data : Compute geometry when NNC data is asked for Remove obsolete parameters --- .../FileInterface/RifReaderEclipseOutput.cpp | 24 +++--- .../FileInterface/RifReaderInterface.cpp | 8 ++ .../FileInterface/RifReaderInterface.h | 1 + .../FileInterface/RifReaderSettings.cpp | 18 +++- .../FileInterface/RifReaderSettings.h | 1 + .../Python/rips/tests/test_nnc_properties.py | 12 +-- .../RivNNCGeometryGenerator.cpp | 2 +- .../RivNNCGeometryGenerator.h | 4 +- .../RivReservoirFaultsPartMgr.cpp | 3 + .../ProjectDataModel/RimEclipseCase.cpp | 20 ++++- .../ProjectDataModel/RimEclipseCase.h | 2 + .../RimEclipseCaseCollection.cpp | 16 ++-- .../RimEclipseCaseCollection.h | 2 +- .../RimEclipseResultDefinition.cpp | 2 + .../RimFaultInViewCollection.cpp | 78 ----------------- .../RimFaultInViewCollection.h | 2 - .../RigCaseCellResultsData.cpp | 38 +++++++-- .../RigCaseCellResultsData.h | 3 +- .../RigCellFaceGeometryTools.cpp | 7 +- .../RigCellFaceGeometryTools.h | 3 +- .../ReservoirDataModel/RigMainGrid.cpp | 8 +- .../ReservoirDataModel/RigMainGrid.h | 3 +- .../ReservoirDataModel/RigNNCData.cpp | 84 +++++++++++++++++-- .../ReservoirDataModel/RigNNCData.h | 21 ++++- .../RigReservoirBuilderMock.cpp | 2 +- 25 files changed, 219 insertions(+), 145 deletions(-) diff --git a/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp b/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp index f394c580c2..1a255c1462 100644 --- a/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp +++ b/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp @@ -446,23 +446,27 @@ bool RifReaderEclipseOutput::open( const QString& fileName, RigEclipseCaseData* if ( isNNCsEnabled() ) { caf::ProgressInfo nncProgress( 10, "" ); + RigMainGrid* mainGrid = eclipseCase->mainGrid(); { auto subNncTask = nncProgress.task( "Reading static NNC data" ); - transferStaticNNCData( mainEclGrid, m_ecl_init_file, eclipseCase->mainGrid() ); + transferStaticNNCData( mainEclGrid, m_ecl_init_file, mainGrid ); } // This test should probably be improved to test more directly for presence of NNC data if ( m_eclipseCase->results( RiaDefines::MATRIX_MODEL )->hasFlowDiagUsableFluxes() ) { auto subNncTask = nncProgress.task( "Reading dynamic NNC data" ); - transferDynamicNNCData( mainEclGrid, eclipseCase->mainGrid() ); + transferDynamicNNCData( mainEclGrid, mainGrid ); } - { - auto subNncTask = nncProgress.task( "Processing connections", 8 ); - eclipseCase->mainGrid()->nncData()->processNativeConnections( *( eclipseCase->mainGrid() ) ); - } + RigActiveCellInfo* activeCellInfo = + m_eclipseCase->activeCellInfo( RiaDefines::PorosityModelType::MATRIX_MODEL ); + + bool includeInactiveCells = + RiaApplication::instance()->preferences()->readerSettings()->includeInactiveCellsInFaultGeometry; + + mainGrid->nncData()->setSourceDataForProcessing( mainGrid, activeCellInfo, includeInactiveCells ); } } @@ -741,11 +745,9 @@ void RifReaderEclipseOutput::transferStaticNNCData( const ecl_grid_type* mainEcl transmissibilityValuesTemp.push_back( transValues[nIdx] ); } - mainGrid->nncData()->setConnections( nncConnections ); - - std::vector& transmissibilityValues = - mainGrid->nncData()->makeStaticConnectionScalarResult( RiaDefines::propertyNameCombTrans() ); - transmissibilityValues = transmissibilityValuesTemp; + mainGrid->nncData()->setNativeConnections( nncConnections ); + mainGrid->nncData()->makeScalarResultAndSetValues( RiaDefines::propertyNameCombTrans(), + transmissibilityValuesTemp ); } ecl_nnc_data_free( tran_data ); diff --git a/ApplicationCode/FileInterface/RifReaderInterface.cpp b/ApplicationCode/FileInterface/RifReaderInterface.cpp index 2d315e3c0b..fcffe111e1 100644 --- a/ApplicationCode/FileInterface/RifReaderInterface.cpp +++ b/ApplicationCode/FileInterface/RifReaderInterface.cpp @@ -48,6 +48,14 @@ bool RifReaderInterface::isNNCsEnabled() return readerSettings()->importNNCs; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RifReaderInterface::includeInactiveCellsInFaultGeometry() +{ + return readerSettings()->includeInactiveCellsInFaultGeometry(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/FileInterface/RifReaderInterface.h b/ApplicationCode/FileInterface/RifReaderInterface.h index 7f204ed5fc..d57dc71fc3 100644 --- a/ApplicationCode/FileInterface/RifReaderInterface.h +++ b/ApplicationCode/FileInterface/RifReaderInterface.h @@ -50,6 +50,7 @@ public: bool isFaultImportEnabled(); bool isImportOfCompleteMswDataEnabled(); bool isNNCsEnabled(); + bool includeInactiveCellsInFaultGeometry(); const QString faultIncludeFileAbsolutePathPrefix(); virtual bool open( const QString& fileName, RigEclipseCaseData* eclipseCase ) = 0; diff --git a/ApplicationCode/FileInterface/RifReaderSettings.cpp b/ApplicationCode/FileInterface/RifReaderSettings.cpp index 0d8b2d3210..995b8e30e2 100644 --- a/ApplicationCode/FileInterface/RifReaderSettings.cpp +++ b/ApplicationCode/FileInterface/RifReaderSettings.cpp @@ -36,6 +36,15 @@ RifReaderSettings::RifReaderSettings() CAF_PDM_InitField( &importNNCs, "importSimulationNNCs", true, "Import NNCs", "", "", "" ); importNNCs.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); + CAF_PDM_InitField( &includeInactiveCellsInFaultGeometry, + "includeInactiveCellsInFaultGeometry", + false, + "Include Inactive Cells", + "", + "", + "" ); + includeInactiveCellsInFaultGeometry.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); + CAF_PDM_InitField( &importAdvancedMswData, "importAdvancedMswData", false, "Import Advanced MSW Data", "", "", "" ); importAdvancedMswData.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); @@ -73,7 +82,7 @@ void RifReaderSettings::defineEditorAttribute( const caf::PdmFieldHandle* field, caf::PdmUiEditorAttribute* attribute ) { if ( field == &importFaults || field == &importAdvancedMswData || field == &importNNCs || - field == &useResultIndexFile || field == &skipWellData ) + field == &useResultIndexFile || field == &skipWellData || field == &includeInactiveCellsInFaultGeometry ) { caf::PdmUiCheckBoxEditorAttribute* myAttr = dynamic_cast( attribute ); if ( myAttr ) @@ -89,6 +98,7 @@ void RifReaderSettings::defineEditorAttribute( const caf::PdmFieldHandle* field, void RifReaderSettings::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) { uiOrdering.add( &importFaults ); + uiOrdering.add( &includeInactiveCellsInFaultGeometry ); #ifdef WIN32 uiOrdering.add( &includeFileAbsolutePathPrefix ); #endif @@ -96,4 +106,10 @@ void RifReaderSettings::defineUiOrdering( QString uiConfigName, caf::PdmUiOrderi uiOrdering.add( &importAdvancedMswData ); uiOrdering.add( &useResultIndexFile ); uiOrdering.add( &skipWellData ); + + bool setFaultImportSettingsReadOnly = !importFaults(); + + includeInactiveCellsInFaultGeometry.uiCapability()->setUiReadOnly( setFaultImportSettingsReadOnly ); + includeFileAbsolutePathPrefix.uiCapability()->setUiReadOnly( setFaultImportSettingsReadOnly ); + importNNCs.uiCapability()->setUiReadOnly( setFaultImportSettingsReadOnly ); } diff --git a/ApplicationCode/FileInterface/RifReaderSettings.h b/ApplicationCode/FileInterface/RifReaderSettings.h index 640c796fc9..d4ec4e25f4 100644 --- a/ApplicationCode/FileInterface/RifReaderSettings.h +++ b/ApplicationCode/FileInterface/RifReaderSettings.h @@ -37,6 +37,7 @@ public: caf::PdmField importFaults; caf::PdmField importNNCs; + caf::PdmField includeInactiveCellsInFaultGeometry; caf::PdmField importAdvancedMswData; caf::PdmField includeFileAbsolutePathPrefix; caf::PdmField useResultIndexFile; diff --git a/ApplicationCode/GrpcInterface/Python/rips/tests/test_nnc_properties.py b/ApplicationCode/GrpcInterface/Python/rips/tests/test_nnc_properties.py index 279f9c529a..0f542eb37f 100644 --- a/ApplicationCode/GrpcInterface/Python/rips/tests/test_nnc_properties.py +++ b/ApplicationCode/GrpcInterface/Python/rips/tests/test_nnc_properties.py @@ -16,14 +16,10 @@ def test_10kSync(rips_instance, initialize_test): case = rips_instance.project.load_case(path=casePath) properties = case.available_nnc_properties() - assert(len(properties) == 3) + assert(len(properties) == 1) assert("TRAN" == properties[0].name) assert(NNCProperties_pb2.NNCPropertyType.Value('NNC_STATIC') == properties[0].property_type) - assert("Binary Formation Allan" == properties[1].name) - assert(NNCProperties_pb2.NNCPropertyType.Value('NNC_GENERATED') == properties[1].property_type) - assert("Formation Allan" == properties[2].name) - assert(NNCProperties_pb2.NNCPropertyType.Value('NNC_GENERATED') == properties[2].property_type) nnc_connections = case.nnc_connections() assert(len(nnc_connections) == 3416) @@ -40,12 +36,6 @@ def test_10kSync(rips_instance, initialize_test): for t in tran_vals: assert(isinstance(t, float)) - allan_vals = case.nnc_connections_generated_values("Formation Allan", 0) - assert(len(allan_vals) == len(nnc_connections)) - - for a in allan_vals: - assert(isinstance(a, float)) - # Generate some data new_data = [] for (c, _) in enumerate(nnc_connections): diff --git a/ApplicationCode/ModelVisualization/RivNNCGeometryGenerator.cpp b/ApplicationCode/ModelVisualization/RivNNCGeometryGenerator.cpp index cd3998fca0..642166b24e 100644 --- a/ApplicationCode/ModelVisualization/RivNNCGeometryGenerator.cpp +++ b/ApplicationCode/ModelVisualization/RivNNCGeometryGenerator.cpp @@ -32,7 +32,7 @@ /// //-------------------------------------------------------------------------------------------------- RivNNCGeometryGenerator::RivNNCGeometryGenerator( bool includeAllan, - const RigNNCData* nncData, + RigNNCData* nncData, const cvf::Vec3d& offset, const cvf::Array* nncIndexes ) : m_includeAllanDiagramGeometry( includeAllan ) diff --git a/ApplicationCode/ModelVisualization/RivNNCGeometryGenerator.h b/ApplicationCode/ModelVisualization/RivNNCGeometryGenerator.h index 548911d61a..1919a9ffea 100644 --- a/ApplicationCode/ModelVisualization/RivNNCGeometryGenerator.h +++ b/ApplicationCode/ModelVisualization/RivNNCGeometryGenerator.h @@ -43,7 +43,7 @@ class RivNNCGeometryGenerator : public cvf::Object { public: RivNNCGeometryGenerator( bool includeAllan, - const RigNNCData* nncData, + RigNNCData* nncData, const cvf::Vec3d& offset, const cvf::Array* nncIndexes ); @@ -70,7 +70,7 @@ private: bool m_includeAllanDiagramGeometry; // Input - cvf::cref m_nncData; + cvf::ref m_nncData; cvf::cref> m_nncIndexes; cvf::cref m_cellVisibility; cvf::cref m_grid; diff --git a/ApplicationCode/ModelVisualization/RivReservoirFaultsPartMgr.cpp b/ApplicationCode/ModelVisualization/RivReservoirFaultsPartMgr.cpp index 878df82b25..ad1e7af630 100644 --- a/ApplicationCode/ModelVisualization/RivReservoirFaultsPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivReservoirFaultsPartMgr.cpp @@ -201,6 +201,9 @@ void RivReservoirFaultsPartMgr::appendPartsToModel( cvf::ModelBasicList* model ) if ( showNncs ) { + RigMainGrid* mainGrid = m_reservoirView->mainGrid(); + mainGrid->nncData()->ensureConnectionDataIsProcecced(); + if ( showCompleteNncGeo ) { rivFaultPart->appendCompleteNNCFacesToModel( &parts ); diff --git a/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp b/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp index 8ad8230413..44e1830b2d 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp @@ -608,7 +608,8 @@ void RimEclipseCase::computeCachedData() { auto task = pInf.task( "Calculating faults", 17 ); - rigEclipseCase->mainGrid()->calculateFaults( rigEclipseCase->activeCellInfo( RiaDefines::MATRIX_MODEL ) ); + + ensureFaultDataIsComputed(); } { @@ -689,6 +690,23 @@ void RimEclipseCase::loadAndSyncronizeInputProperties( bool includeGridFileName RifEclipseInputPropertyLoader::loadAndSyncronizeInputProperties( inputPropertyCollection(), eclipseCaseData(), filenames ); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEclipseCase::ensureFaultDataIsComputed() +{ + RigEclipseCaseData* rigEclipseCase = eclipseCaseData(); + if ( rigEclipseCase ) + { + bool computeFaults = RiaApplication::instance()->preferences()->readerSettings()->importFaults(); + if ( computeFaults ) + { + RigActiveCellInfo* actCellInfo = rigEclipseCase->activeCellInfo( RiaDefines::PorosityModelType::MATRIX_MODEL ); + rigEclipseCase->mainGrid()->calculateFaults( actCellInfo ); + } + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimEclipseCase.h b/ApplicationCode/ProjectDataModel/RimEclipseCase.h index e9239009c3..5f9a34a952 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseCase.h +++ b/ApplicationCode/ProjectDataModel/RimEclipseCase.h @@ -115,6 +115,8 @@ public: void loadAndSyncronizeInputProperties( bool includeGridFileName ); + void ensureFaultDataIsComputed(); + protected: void initAfterRead() override; void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; diff --git a/ApplicationCode/ProjectDataModel/RimEclipseCaseCollection.cpp b/ApplicationCode/ProjectDataModel/RimEclipseCaseCollection.cpp index dcf239a1c9..17202f83ca 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseCaseCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseCaseCollection.cpp @@ -21,6 +21,9 @@ #include "RimEclipseCaseCollection.h" #include "RiaApplication.h" +#include "RiaPreferences.h" + +#include "RifReaderSettings.h" #include "RigEclipseCaseData.h" #include "RigGridManager.h" @@ -75,8 +78,7 @@ RimIdenticalGridCaseGroup* RimEclipseCaseCollection::createIdenticalCaseGroupFro { CVF_ASSERT( mainCase ); - RigEclipseCaseData* rigEclipseCase = mainCase->eclipseCaseData(); - RigMainGrid* equalGrid = registerCaseInGridCollection( rigEclipseCase ); + RigMainGrid* equalGrid = registerCaseInGridCollection( mainCase ); CVF_ASSERT( equalGrid ); RimIdenticalGridCaseGroup* group = new RimIdenticalGridCaseGroup; @@ -113,9 +115,10 @@ void RimEclipseCaseCollection::removeCaseFromAllGroups( RimEclipseCase* reservoi //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RigMainGrid* RimEclipseCaseCollection::registerCaseInGridCollection( RigEclipseCaseData* rigEclipseCase ) +RigMainGrid* RimEclipseCaseCollection::registerCaseInGridCollection( RimEclipseCase* rimEclipseCase ) { - CVF_ASSERT( rigEclipseCase ); + CVF_ASSERT( rimEclipseCase && rimEclipseCase->eclipseCaseData() ); + RigEclipseCaseData* rigEclipseCase = rimEclipseCase->eclipseCaseData(); RigMainGrid* equalGrid = m_gridCollection->findEqualGrid( rigEclipseCase->mainGrid() ); @@ -129,7 +132,7 @@ RigMainGrid* RimEclipseCaseCollection::registerCaseInGridCollection( RigEclipseC // This is the first insertion of this grid, compute cached data rigEclipseCase->mainGrid()->computeCachedData(); - rigEclipseCase->mainGrid()->calculateFaults( rigEclipseCase->activeCellInfo( RiaDefines::MATRIX_MODEL ) ); + rimEclipseCase->ensureFaultDataIsComputed(); equalGrid = rigEclipseCase->mainGrid(); } @@ -146,8 +149,7 @@ void RimEclipseCaseCollection::insertCaseInCaseGroup( RimIdenticalGridCaseGroup* { CVF_ASSERT( rimReservoir ); - RigEclipseCaseData* rigEclipseCase = rimReservoir->eclipseCaseData(); - registerCaseInGridCollection( rigEclipseCase ); + registerCaseInGridCollection( rimReservoir ); caseGroup->addCase( rimReservoir ); } diff --git a/ApplicationCode/ProjectDataModel/RimEclipseCaseCollection.h b/ApplicationCode/ProjectDataModel/RimEclipseCaseCollection.h index afdd44e6ac..a6451b5cae 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseCaseCollection.h +++ b/ApplicationCode/ProjectDataModel/RimEclipseCaseCollection.h @@ -58,6 +58,6 @@ public: void recomputeStatisticsForAllCaseGroups(); private: - RigMainGrid* registerCaseInGridCollection( RigEclipseCaseData* rigEclipseCase ); + RigMainGrid* registerCaseInGridCollection( RimEclipseCase* rimEclipseCase ); cvf::ref m_gridCollection; }; diff --git a/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.cpp b/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.cpp index b054d4b966..b2def83ded 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.cpp @@ -1933,6 +1933,8 @@ void RimEclipseResultDefinition::updateRangesForExplicitLegends( RimRegularLegen int frmIdx2 = it->first.second; int combIndex = it->second; + if ( frmIdx1 >= fnVector.size() || frmIdx2 >= fnVector.size() ) continue; + QString frmName1 = fnVector[frmIdx1]; QString frmName2 = fnVector[frmIdx2]; diff --git a/ApplicationCode/ProjectDataModel/RimFaultInViewCollection.cpp b/ApplicationCode/ProjectDataModel/RimFaultInViewCollection.cpp index 50a3026b2f..fc761145d3 100644 --- a/ApplicationCode/ProjectDataModel/RimFaultInViewCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimFaultInViewCollection.cpp @@ -89,15 +89,6 @@ RimFaultInViewCollection::RimFaultInViewCollection() "", "" ); - CAF_PDM_InitFieldNoDefault( &noCommonAreaNnncCollection, - "NoCommonAreaNnncCollection", - "NNCs With No Common Area", - "", - "", - "" ); - noCommonAreaNnncCollection = new RimNoCommonAreaNncCollection; - noCommonAreaNnncCollection.uiCapability()->setUiHidden( true ); - CAF_PDM_InitFieldNoDefault( &faults, "Faults", "Faults", "", "", "" ); faults.uiCapability()->setUiHidden( true ); } @@ -108,8 +99,6 @@ RimFaultInViewCollection::RimFaultInViewCollection() RimFaultInViewCollection::~RimFaultInViewCollection() { faults.deleteAllChildObjects(); - - delete noCommonAreaNnncCollection(); } //-------------------------------------------------------------------------------------------------- @@ -262,73 +251,6 @@ void RimFaultInViewCollection::syncronizeFaults() QString toolTip = QString( "Fault count (%1)" ).arg( newFaults.size() ); setUiToolTip( toolTip ); - - // NNCs - this->noCommonAreaNnncCollection()->noCommonAreaNncs().deleteAllChildObjects(); - - RigMainGrid* mainGrid = parentView()->mainGrid(); - const RigConnectionContainer& nncConnections = mainGrid->nncData()->connections(); - for ( size_t connIndex = 0; connIndex < nncConnections.size(); connIndex++ ) - { - if ( !nncConnections[connIndex].hasCommonArea() ) - { - RimNoCommonAreaNNC* noCommonAreaNnc = new RimNoCommonAreaNNC(); - - QString firstConnectionText; - QString secondConnectionText; - - { - size_t gridLocalCellIndex; - const RigGridBase* hostGrid = - mainGrid->gridAndGridLocalIdxFromGlobalCellIdx( nncConnections[connIndex].c1GlobIdx(), - &gridLocalCellIndex ); - - size_t i, j, k; - if ( hostGrid->ijkFromCellIndex( gridLocalCellIndex, &i, &j, &k ) ) - { - // Adjust to 1-based Eclipse indexing - i++; - j++; - k++; - - if ( !hostGrid->isMainGrid() ) - { - QString gridName = QString::fromStdString( hostGrid->gridName() ); - firstConnectionText = gridName + " "; - } - firstConnectionText += QString( "[%1 %2 %3] - " ).arg( i ).arg( j ).arg( k ); - } - } - - { - size_t gridLocalCellIndex; - const RigGridBase* hostGrid = - mainGrid->gridAndGridLocalIdxFromGlobalCellIdx( nncConnections[connIndex].c2GlobIdx(), - &gridLocalCellIndex ); - - size_t i, j, k; - if ( hostGrid->ijkFromCellIndex( gridLocalCellIndex, &i, &j, &k ) ) - { - // Adjust to 1-based Eclipse indexing - i++; - j++; - k++; - - if ( !hostGrid->isMainGrid() ) - { - QString gridName = QString::fromStdString( hostGrid->gridName() ); - secondConnectionText = gridName + " "; - } - secondConnectionText += QString( "[%1 %2 %3]" ).arg( i ).arg( j ).arg( k ); - } - } - - noCommonAreaNnc->name = firstConnectionText + secondConnectionText; - this->noCommonAreaNnncCollection()->noCommonAreaNncs().push_back( noCommonAreaNnc ); - } - - this->noCommonAreaNnncCollection()->updateName(); - } } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimFaultInViewCollection.h b/ApplicationCode/ProjectDataModel/RimFaultInViewCollection.h index 766a349c90..5da5a6840e 100644 --- a/ApplicationCode/ProjectDataModel/RimFaultInViewCollection.h +++ b/ApplicationCode/ProjectDataModel/RimFaultInViewCollection.h @@ -77,8 +77,6 @@ public: caf::PdmChildArrayField faults; RimFaultInView* findFaultByName( QString name ); - caf::PdmChildField noCommonAreaNnncCollection; - void uiOrderingFaults( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ); private: diff --git a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp index 8640c4fafb..43460e3ae8 100644 --- a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp +++ b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp @@ -1230,7 +1230,12 @@ size_t RigCaseCellResultsData::findOrLoadKnownScalarResult( const RigEclipseResu else if ( resultName == RiaDefines::formationAllanResultName() || resultName == RiaDefines::formationBinaryAllanResultName() ) { - computeAllanResults( this, m_ownerMainGrid ); + bool includeInactiveCells = false; + if ( m_readerInterface.notNull() ) + { + includeInactiveCells = m_readerInterface->includeInactiveCellsInFaultGeometry(); + } + computeAllanResults( this, m_ownerMainGrid, includeInactiveCells ); } } else if ( type == RiaDefines::DYNAMIC_NATIVE ) @@ -1371,6 +1376,18 @@ size_t RigCaseCellResultsData::findOrLoadKnownScalarResult( const RigEclipseResu computeOilVolumes(); } + // Allan results + if ( resultName == RiaDefines::formationAllanResultName() || resultName == RiaDefines::formationBinaryAllanResultName() ) + { + bool includeInactiveCells = false; + if ( m_readerInterface.notNull() ) + { + includeInactiveCells = m_readerInterface->includeInactiveCellsInFaultGeometry(); + } + + computeAllanResults( this, m_ownerMainGrid, includeInactiveCells ); + } + // Handle SourSimRL reading if ( type == RiaDefines::SOURSIMRL ) @@ -2895,7 +2912,11 @@ void RigCaseCellResultsData::setActiveFormationNames( RigFormationNames* activeF } } - computeAllanResults( this, m_ownerMainGrid ); + // As the Allan formation diagram is depending on formation results, we need to clear the data set + // Will be recomputed when required + auto fnNamesResAddr = + RigEclipseResultAddress( RiaDefines::ResultCatType::ALLAN_DIAGRAMS, RiaDefines::formationAllanResultName() ); + clearScalarResult( fnNamesResAddr ); } //-------------------------------------------------------------------------------------------------- @@ -3007,17 +3028,18 @@ RigStatisticsDataCache* RigCaseCellResultsData::statistics( const RigEclipseResu //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigCaseCellResultsData::computeAllanResults( RigCaseCellResultsData* cellResultsData, RigMainGrid* mainGrid ) +void RigCaseCellResultsData::computeAllanResults( RigCaseCellResultsData* cellResultsData, + RigMainGrid* mainGrid, + bool includeInactiveCells ) { CVF_ASSERT( mainGrid ); CVF_ASSERT( cellResultsData ); - auto fnNamesResAddr = - RigEclipseResultAddress( RiaDefines::FORMATION_NAMES, RiaDefines::activeFormationNamesResultName() ); - bool hasFormationData = cellResultsData->hasResultEntry( fnNamesResAddr ); - - if ( hasFormationData ) + if ( cellResultsData && cellResultsData->activeFormationNames() && + !cellResultsData->activeFormationNames()->formationNames().empty() ) { + auto fnNamesResAddr = RigEclipseResultAddress( RiaDefines::ResultCatType::FORMATION_NAMES, + RiaDefines::activeFormationNamesResultName() ); auto fnAllanResultResAddr = RigEclipseResultAddress( RiaDefines::ALLAN_DIAGRAMS, RiaDefines::formationAllanResultName() ); auto fnBinAllanResAddr = diff --git a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.h b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.h index a8f2e023b3..a07ed68925 100644 --- a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.h +++ b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.h @@ -190,7 +190,8 @@ private: RigStatisticsDataCache* statistics( const RigEclipseResultAddress& resVarAddr ); - static void computeAllanResults( RigCaseCellResultsData* cellResultsData, RigMainGrid* mainGrid ); + static void + computeAllanResults( RigCaseCellResultsData* cellResultsData, RigMainGrid* mainGrid, bool includeInactiveCells ); private: cvf::ref m_readerInterface; diff --git a/ApplicationCode/ReservoirDataModel/RigCellFaceGeometryTools.cpp b/ApplicationCode/ReservoirDataModel/RigCellFaceGeometryTools.cpp index 4a40a28e3e..ab920f4f05 100644 --- a/ApplicationCode/ReservoirDataModel/RigCellFaceGeometryTools.cpp +++ b/ApplicationCode/ReservoirDataModel/RigCellFaceGeometryTools.cpp @@ -43,7 +43,7 @@ cvf::StructGridInterface::FaceType { // Try to find the shared face - bool isPossibleNeighborInDirection[6] = { true, true, true, true, true, true }; + bool isPossibleNeighborInDirection[6] = {true, true, true, true, true, true}; if ( c1.hostGrid() == c2.hostGrid() ) { @@ -132,7 +132,8 @@ void assignThreadConnections( RigConnectionContainer& allConnections, RigConnect //-------------------------------------------------------------------------------------------------- RigConnectionContainer RigCellFaceGeometryTools::computeOtherNncs( const RigMainGrid* mainGrid, const RigConnectionContainer& nativeConnections, - const RigActiveCellInfo* activeCellInfo ) + const RigActiveCellInfo* activeCellInfo, + bool includeInactiveCells ) { // Compute Non-Neighbor Connections (NNC) not reported by Eclipse. NNCs with zero transmissibility are not reported // by Eclipse. Use faults as basis for subset of cells to find NNC connection for. The imported connections from @@ -173,7 +174,7 @@ RigConnectionContainer RigCellFaceGeometryTools::computeOtherNncs( const RigMain const RigFault::FaultFace& f = faultFaces[faceIdx]; bool atLeastOneCellActive = true; - if ( activeCellInfo && activeCellInfo->reservoirActiveCellCount() > 0u ) + if ( !includeInactiveCells && activeCellInfo && activeCellInfo->reservoirActiveCellCount() > 0u ) { atLeastOneCellActive = activeCellInfo->isActive( f.m_nativeReservoirCellIndex ) || activeCellInfo->isActive( f.m_oppositeReservoirCellIndex ); diff --git a/ApplicationCode/ReservoirDataModel/RigCellFaceGeometryTools.h b/ApplicationCode/ReservoirDataModel/RigCellFaceGeometryTools.h index c0d4be189b..243a0fd80c 100644 --- a/ApplicationCode/ReservoirDataModel/RigCellFaceGeometryTools.h +++ b/ApplicationCode/ReservoirDataModel/RigCellFaceGeometryTools.h @@ -48,7 +48,8 @@ public: static RigConnectionContainer computeOtherNncs( const RigMainGrid* mainGrid, const RigConnectionContainer& nativeConnections, - const RigActiveCellInfo* activeCellInfo ); + const RigActiveCellInfo* activeCellInfo, + bool includeInactiveCells ); static void extractConnectionsForFace( const RigFault::FaultFace& face, const RigMainGrid* mainGrid, diff --git a/ApplicationCode/ReservoirDataModel/RigMainGrid.cpp b/ApplicationCode/ReservoirDataModel/RigMainGrid.cpp index 0515e667a4..294cf82cd0 100644 --- a/ApplicationCode/ReservoirDataModel/RigMainGrid.cpp +++ b/ApplicationCode/ReservoirDataModel/RigMainGrid.cpp @@ -555,10 +555,6 @@ void RigMainGrid::calculateFaults( const RigActiveCellInfo* activeCellInfo ) } } } - - this->nncData()->computeCompleteSetOfNncs( this, activeCellInfo ); - - distributeNNCsToFaults(); } //-------------------------------------------------------------------------------------------------- @@ -566,6 +562,8 @@ void RigMainGrid::calculateFaults( const RigActiveCellInfo* activeCellInfo ) //-------------------------------------------------------------------------------------------------- void RigMainGrid::distributeNNCsToFaults() { + if ( m_faultsPrCellAcc.isNull() ) return; + const RigConnectionContainer& nncs = this->nncData()->connections(); for ( size_t nncIdx = 0; nncIdx < nncs.size(); ++nncIdx ) { @@ -652,7 +650,7 @@ bool RigMainGrid::isFaceNormalsOutwards() const const RigFault* RigMainGrid::findFaultFromCellIndexAndCellFace( size_t reservoirCellIndex, cvf::StructGridInterface::FaceType face ) const { - CVF_TIGHT_ASSERT( m_faultsPrCellAcc.notNull() ); + if ( m_faultsPrCellAcc.isNull() ) return nullptr; if ( face == cvf::StructGridInterface::NO_FACE ) return nullptr; diff --git a/ApplicationCode/ReservoirDataModel/RigMainGrid.h b/ApplicationCode/ReservoirDataModel/RigMainGrid.h index 033f3d8fef..8ba09d3340 100644 --- a/ApplicationCode/ReservoirDataModel/RigMainGrid.h +++ b/ApplicationCode/ReservoirDataModel/RigMainGrid.h @@ -66,7 +66,8 @@ public: size_t totalTemporaryGridCellCount() const; - RigNNCData* nncData(); + RigNNCData* nncData(); + void setFaults( const cvf::Collection& faults ); const cvf::Collection& faults() const; cvf::Collection& faults(); diff --git a/ApplicationCode/ReservoirDataModel/RigNNCData.cpp b/ApplicationCode/ReservoirDataModel/RigNNCData.cpp index d9ec761d5e..11b0970d71 100644 --- a/ApplicationCode/ReservoirDataModel/RigNNCData.cpp +++ b/ApplicationCode/ReservoirDataModel/RigNNCData.cpp @@ -23,15 +23,39 @@ #include "RigEclipseResultAddress.h" #include "RigMainGrid.h" +#include "RiaLogging.h" + +#include "cafProgressInfo.h" + #include "cvfGeometryTools.h" +#include + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- RigNNCData::RigNNCData() + : m_connectionsAreProcessed( false ) + , m_mainGrid( nullptr ) + , m_activeCellInfo( nullptr ) + , m_computeNncForInactiveCells( false ) { } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigNNCData::setSourceDataForProcessing( RigMainGrid* mainGrid, + const RigActiveCellInfo* activeCellInfo, + bool includeInactiveCells ) +{ + m_mainGrid = mainGrid; + m_activeCellInfo = activeCellInfo; + m_computeNncForInactiveCells = includeInactiveCells; + + m_connectionsAreProcessed = false; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -63,11 +87,12 @@ void RigNNCData::processNativeConnections( const RigMainGrid& mainGrid ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigNNCData::computeCompleteSetOfNncs( const RigMainGrid* mainGrid, const RigActiveCellInfo* activeCellInfo ) +void RigNNCData::computeCompleteSetOfNncs( const RigMainGrid* mainGrid, + const RigActiveCellInfo* activeCellInfo, + bool includeInactiveCells ) { - m_nativeConnectionCount = m_connections.size(); RigConnectionContainer otherConnections = - RigCellFaceGeometryTools::computeOtherNncs( mainGrid, m_connections, activeCellInfo ); + RigCellFaceGeometryTools::computeOtherNncs( mainGrid, m_connections, activeCellInfo, includeInactiveCells ); if ( !otherConnections.empty() ) { @@ -89,9 +114,42 @@ void RigNNCData::computeCompleteSetOfNncs( const RigMainGrid* mainGrid, const Ri //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigNNCData::setConnections( RigConnectionContainer& connections ) +void RigNNCData::ensureConnectionDataIsProcecced() { - m_connections = connections; + if ( m_connectionsAreProcessed ) return; + + if ( m_mainGrid ) + { + caf::ProgressInfo progressInfo( 3, "Computing NNC Data" ); + + RiaLogging::info( "NNC geometry computation - starting process" ); + + processNativeConnections( *m_mainGrid ); + progressInfo.incrementProgress(); + + computeCompleteSetOfNncs( m_mainGrid, m_activeCellInfo, m_computeNncForInactiveCells ); + progressInfo.incrementProgress(); + + m_connectionsAreProcessed = true; + + m_mainGrid->distributeNNCsToFaults(); + + RiaLogging::info( "NNC geometry computation - completed process" ); + + RiaLogging::info( QString( "Native NNC count : %1" ).arg( nativeConnectionCount() ) ); + RiaLogging::info( QString( "Computed NNC count : %2" ).arg( m_connections.size() ) ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigNNCData::setNativeConnections( RigConnectionContainer& connections ) +{ + m_connections = connections; + m_nativeConnectionCount = m_connections.size(); + + m_connectionsAreProcessed = false; } //-------------------------------------------------------------------------------------------------- @@ -105,8 +163,10 @@ size_t RigNNCData::nativeConnectionCount() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -const RigConnectionContainer& RigNNCData::connections() const +RigConnectionContainer& RigNNCData::connections() { + ensureConnectionDataIsProcecced(); + return m_connections; } @@ -115,12 +175,24 @@ const RigConnectionContainer& RigNNCData::connections() const //-------------------------------------------------------------------------------------------------- std::vector& RigNNCData::makeStaticConnectionScalarResult( QString nncDataType ) { + ensureConnectionDataIsProcecced(); + std::vector>& results = m_connectionResults[nncDataType]; results.resize( 1 ); results[0].resize( m_connections.size(), HUGE_VAL ); return results[0]; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigNNCData::makeScalarResultAndSetValues( const QString& nncDataType, const std::vector& values ) +{ + std::vector>& results = m_connectionResults[nncDataType]; + results.resize( 1 ); + results[0] = values; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ReservoirDataModel/RigNNCData.h b/ApplicationCode/ReservoirDataModel/RigNNCData.h index 06f53f3e26..05440ffde7 100644 --- a/ApplicationCode/ReservoirDataModel/RigNNCData.h +++ b/ApplicationCode/ReservoirDataModel/RigNNCData.h @@ -49,17 +49,20 @@ public: RigNNCData(); - void processNativeConnections( const RigMainGrid& mainGrid ); - void computeCompleteSetOfNncs( const RigMainGrid* mainGrid, const RigActiveCellInfo* activeCellInfo ); + void ensureConnectionDataIsProcecced(); + void setSourceDataForProcessing( RigMainGrid* mainGrid, + const RigActiveCellInfo* activeCellInfo, + bool includeInactiveCells ); - void setConnections( RigConnectionContainer& connections ); + void setNativeConnections( RigConnectionContainer& connections ); size_t nativeConnectionCount() const; - const RigConnectionContainer& connections() const; + RigConnectionContainer& connections(); std::vector& makeStaticConnectionScalarResult( QString nncDataType ); const std::vector* staticConnectionScalarResult( const RigEclipseResultAddress& resVarAddr ) const; const std::vector* staticConnectionScalarResultByName( const QString& nncDataType ) const; + void makeScalarResultAndSetValues( const QString& nncDataType, const std::vector& values ); std::vector>& makeDynamicConnectionScalarResult( QString nncDataType, size_t timeStepCount ); const std::vector>* dynamicConnectionScalarResult( const RigEclipseResultAddress& resVarAddr ) const; @@ -89,9 +92,19 @@ private: const QString getNNCDataTypeFromScalarResultIndex( const RigEclipseResultAddress& resVarAddr ) const; bool isNative( QString nncDataType ) const; + void processNativeConnections( const RigMainGrid& mainGrid ); + void computeCompleteSetOfNncs( const RigMainGrid* mainGrid, + const RigActiveCellInfo* activeCellInfo, + bool includeInactiveCells ); + private: RigConnectionContainer m_connections; size_t m_nativeConnectionCount; std::map>> m_connectionResults; std::map m_resultAddrToNNCDataType; + + bool m_connectionsAreProcessed; + RigMainGrid* m_mainGrid; + const RigActiveCellInfo* m_activeCellInfo; + bool m_computeNncForInactiveCells; }; diff --git a/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.cpp b/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.cpp index 9d74c6c00d..ed9ff4cdb3 100644 --- a/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.cpp +++ b/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.cpp @@ -558,7 +558,7 @@ void RigReservoirBuilderMock::addFaults( RigEclipseCaseData* eclipseCase ) addNnc( grid, i1, j1, k1, i2, j2, k2, nncConnections ); } - grid->nncData()->setConnections( nncConnections ); + grid->nncData()->setNativeConnections( nncConnections ); std::vector& tranVals = grid->nncData()->makeStaticConnectionScalarResult( RiaDefines::propertyNameCombTrans() ); From 9be0e0ba591bf80f247688b70461d987e69f5370 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 15 May 2020 12:15:30 +0200 Subject: [PATCH 21/46] NNC info : Count NNCs with no overlap area, and display first 20 --- .../ReservoirDataModel/RigNNCData.cpp | 91 ++++++++++++++++++- .../ReservoirDataModel/RigNNCData.h | 3 + 2 files changed, 93 insertions(+), 1 deletion(-) diff --git a/ApplicationCode/ReservoirDataModel/RigNNCData.cpp b/ApplicationCode/ReservoirDataModel/RigNNCData.cpp index 11b0970d71..130e980345 100644 --- a/ApplicationCode/ReservoirDataModel/RigNNCData.cpp +++ b/ApplicationCode/ReservoirDataModel/RigNNCData.cpp @@ -111,6 +111,78 @@ void RigNNCData::computeCompleteSetOfNncs( const RigMainGrid* mainGrid, } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t RigNNCData::connectionsWithNoCommonArea( QStringList& connectionTextFirstItems, size_t maxItemCount ) +{ + size_t connectionWithNoCommonAreaCount = 0; + + for ( size_t connIndex = 0; connIndex < m_connections.size(); connIndex++ ) + { + if ( !m_connections[connIndex].hasCommonArea() ) + { + connectionWithNoCommonAreaCount++; + + if ( connectionTextFirstItems.size() < maxItemCount ) + { + QString firstConnectionText; + QString secondConnectionText; + + { + size_t gridLocalCellIndex; + const RigGridBase* hostGrid = + m_mainGrid->gridAndGridLocalIdxFromGlobalCellIdx( m_connections[connIndex].c1GlobIdx(), + &gridLocalCellIndex ); + + size_t i, j, k; + if ( hostGrid->ijkFromCellIndex( gridLocalCellIndex, &i, &j, &k ) ) + { + // Adjust to 1-based Eclipse indexing + i++; + j++; + k++; + + if ( !hostGrid->isMainGrid() ) + { + QString gridName = QString::fromStdString( hostGrid->gridName() ); + firstConnectionText = gridName + " "; + } + firstConnectionText += QString( "[%1 %2 %3] - " ).arg( i ).arg( j ).arg( k ); + } + } + + { + size_t gridLocalCellIndex; + const RigGridBase* hostGrid = + m_mainGrid->gridAndGridLocalIdxFromGlobalCellIdx( m_connections[connIndex].c2GlobIdx(), + &gridLocalCellIndex ); + + size_t i, j, k; + if ( hostGrid->ijkFromCellIndex( gridLocalCellIndex, &i, &j, &k ) ) + { + // Adjust to 1-based Eclipse indexing + i++; + j++; + k++; + + if ( !hostGrid->isMainGrid() ) + { + QString gridName = QString::fromStdString( hostGrid->gridName() ); + secondConnectionText = gridName + " "; + } + secondConnectionText += QString( "[%1 %2 %3]" ).arg( i ).arg( j ).arg( k ); + } + } + + connectionTextFirstItems.push_back( firstConnectionText + secondConnectionText ); + } + } + } + + return connectionWithNoCommonAreaCount; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -134,10 +206,27 @@ void RigNNCData::ensureConnectionDataIsProcecced() m_mainGrid->distributeNNCsToFaults(); + QStringList noCommonAreaText; + const size_t maxItemCount = 20; + + size_t noCommonAreaCount = connectionsWithNoCommonArea( noCommonAreaText, maxItemCount ); + RiaLogging::info( "NNC geometry computation - completed process" ); RiaLogging::info( QString( "Native NNC count : %1" ).arg( nativeConnectionCount() ) ); - RiaLogging::info( QString( "Computed NNC count : %2" ).arg( m_connections.size() ) ); + RiaLogging::info( QString( "Computed NNC count : %1" ).arg( m_connections.size() ) ); + + RiaLogging::info( QString( "NNCs with no common area count : %1" ).arg( noCommonAreaCount ) ); + + if ( !noCommonAreaText.isEmpty() ) + { + RiaLogging::info( QString( "Listing first %1 NNCs with no common area " ).arg( noCommonAreaText.size() ) ); + + for ( const auto& s : noCommonAreaText ) + { + RiaLogging::info( s ); + } + } } } diff --git a/ApplicationCode/ReservoirDataModel/RigNNCData.h b/ApplicationCode/ReservoirDataModel/RigNNCData.h index 05440ffde7..008114a25b 100644 --- a/ApplicationCode/ReservoirDataModel/RigNNCData.h +++ b/ApplicationCode/ReservoirDataModel/RigNNCData.h @@ -36,6 +36,7 @@ class RigActiveCellInfo; class RigMainGrid; class RigCell; class RigEclipseResultAddress; +class QStringList; class RigNNCData : public cvf::Object { @@ -97,6 +98,8 @@ private: const RigActiveCellInfo* activeCellInfo, bool includeInactiveCells ); + size_t connectionsWithNoCommonArea( QStringList& connectionTextFirstItems, size_t maxItemCount ); + private: RigConnectionContainer m_connections; size_t m_nativeConnectionCount; From ce5b88405bcbf2a330afa98110dc48d81444f52c Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Fri, 15 May 2020 12:35:29 +0200 Subject: [PATCH 22/46] #5936 Fix use of LAS for PP Non-Reservoir --- .../RigGeoMechWellLogExtractor.cpp | 11 +++++++---- .../ReservoirDataModel/RigWbsParameter.cpp | 14 +++++++------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/ApplicationCode/ReservoirDataModel/RigGeoMechWellLogExtractor.cpp b/ApplicationCode/ReservoirDataModel/RigGeoMechWellLogExtractor.cpp index 627498c7de..b9ca8e9a9f 100644 --- a/ApplicationCode/ReservoirDataModel/RigGeoMechWellLogExtractor.cpp +++ b/ApplicationCode/ReservoirDataModel/RigGeoMechWellLogExtractor.cpp @@ -237,7 +237,8 @@ std::vector return finalSourcesPerSegment; } - bool isPPresult = parameter == RigWbsParameter::PP_Reservoir() || parameter == RigWbsParameter::PP_NonReservoir(); + bool isPPResResult = parameter == RigWbsParameter::PP_Reservoir(); + bool isPPresult = isPPResResult || parameter == RigWbsParameter::PP_NonReservoir(); std::vector allSources = parameter.sources(); auto primary_it = std::find( allSources.begin(), allSources.end(), primarySource ); @@ -315,9 +316,11 @@ std::vector { if ( !lasFileValues.empty() ) { - double lasValue = getWellLogIntersectionValue( intersectionIdx, lasFileValues ); - if ( lasValue != std::numeric_limits::infinity() && intersectionIdx < gridValues.size() && - gridValues[intersectionIdx] != std::numeric_limits::infinity() ) + double lasValue = getWellLogIntersectionValue( intersectionIdx, lasFileValues ); + // Only accept las-values for reservoir if the result is PP Reservoir + bool invalidLasRegion = isPPResResult && intersectionIdx < gridValues.size() && + gridValues[intersectionIdx] != std::numeric_limits::infinity(); + if ( lasValue != std::numeric_limits::infinity() && !invalidLasRegion ) { unscaledValues[intersectionIdx] = lasValue; finalSourcesPerSegment[intersectionIdx] = RigWbsParameter::LAS_FILE; diff --git a/ApplicationCode/ReservoirDataModel/RigWbsParameter.cpp b/ApplicationCode/ReservoirDataModel/RigWbsParameter.cpp index 40d9daf24b..307aecbdab 100644 --- a/ApplicationCode/ReservoirDataModel/RigWbsParameter.cpp +++ b/ApplicationCode/ReservoirDataModel/RigWbsParameter.cpp @@ -245,7 +245,7 @@ RigWbsParameter RigWbsParameter::PP_Reservoir() {LAS_FILE, SourceAddress( "POR_RES_INP", "", RiaWellLogUnitTools::gPerCm3UnitString() )}, {ELEMENT_PROPERTY_TABLE, SourceAddress( "POR_INP", "", RiaWellLogUnitTools::pascalUnitString() )}, {ELEMENT_PROPERTY_TABLE, SourceAddress( "PP_INP", "", RiaWellLogUnitTools::sg_emwUnitString() )}}; - return RigWbsParameter( "PP Reservoir", true, sources ); + return RigWbsParameter( "PP_Reservoir", true, sources ); } //-------------------------------------------------------------------------------------------------- @@ -260,7 +260,7 @@ RigWbsParameter RigWbsParameter::PP_NonReservoir() {ELEMENT_PROPERTY_TABLE, SourceAddress( "PP_NONRES_INP", "", RiaWellLogUnitTools::sg_emwUnitString() )}, {HYDROSTATIC, SourceAddress( "Hydrostatic", "", RiaWellLogUnitTools::barUnitString() )}}; - return RigWbsParameter( "PP Non-Reservoir", true, sources ); + return RigWbsParameter( "PP_Non-Reservoir", true, sources ); } //-------------------------------------------------------------------------------------------------- @@ -268,7 +268,7 @@ RigWbsParameter RigWbsParameter::PP_NonReservoir() //-------------------------------------------------------------------------------------------------- RigWbsParameter RigWbsParameter::poissonRatio() { - return RigWbsParameter( "Poisson Ratio", + return RigWbsParameter( "Poisson_Ratio", false, {{LAS_FILE, SourceAddress( "POISSON_RATIO_INP" )}, {ELEMENT_PROPERTY_TABLE, SourceAddress( "POISSON_RATIO_INP" )}, @@ -296,7 +296,7 @@ RigWbsParameter RigWbsParameter::OBG() std::vector> sources = {{GRID, SourceAddress( "ST", "S33", RiaWellLogUnitTools::barUnitString() )}, {LAS_FILE, SourceAddress( "OBG_INP", "", RiaWellLogUnitTools::barUnitString() )}}; - return RigWbsParameter( "OBG Input", true, sources ); + return RigWbsParameter( "OBG_Input", true, sources ); } //-------------------------------------------------------------------------------------------------- @@ -317,7 +317,7 @@ RigWbsParameter RigWbsParameter::SH() { std::vector> sources = { {GRID, SourceAddress( "ST", "S3", RiaWellLogUnitTools::barUnitString() )}}; - return RigWbsParameter( "SH Input", true, sources ); + return RigWbsParameter( "SH_Input", true, sources ); } //-------------------------------------------------------------------------------------------------- @@ -361,7 +361,7 @@ RigWbsParameter RigWbsParameter::K0_SH() //-------------------------------------------------------------------------------------------------- RigWbsParameter RigWbsParameter::FG_Shale() { - RigWbsParameter param( "FG Shale", + RigWbsParameter param( "FG_Shale", false, {{DERIVED_FROM_K0FG, SourceAddress()}, {PROPORTIONAL_TO_SH, SourceAddress()}, @@ -376,7 +376,7 @@ RigWbsParameter RigWbsParameter::FG_Shale() //-------------------------------------------------------------------------------------------------- RigWbsParameter RigWbsParameter::waterDensity() { - RigWbsParameter param( "Density of Sea Water", + RigWbsParameter param( "WaterDensity", false, {{USER_DEFINED, SourceAddress()}, {LAS_FILE, SourceAddress( "RHO_INP", "", RiaWellLogUnitTools::gPerCm3UnitString() )}} ); From 9682d126e943ec5c548a50c12f010382d645ae57 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 15 May 2020 15:20:59 +0200 Subject: [PATCH 23/46] Set version to patch release 02 --- ResInsightVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ResInsightVersion.cmake b/ResInsightVersion.cmake index 1e4c38f616..3fb2234f66 100644 --- a/ResInsightVersion.cmake +++ b/ResInsightVersion.cmake @@ -4,7 +4,7 @@ set(RESINSIGHT_MINOR_VERSION 04) set(RESINSIGHT_PATCH_VERSION 1) # Opional text with no restrictions -set(RESINSIGHT_VERSION_TEXT "-RC01") +set(RESINSIGHT_VERSION_TEXT "-RC02") # Optional text # Must be unique and increasing within one combination of major/minor/patch version From b41df5a62a72d169ff8252749d9be79fec228707 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Sat, 16 May 2020 15:51:59 +0200 Subject: [PATCH 24/46] NNC: Compute data on demand --- ApplicationCode/Application/RiaDefines.cpp | 16 ++++++++++ ApplicationCode/Application/RiaDefines.h | 6 ++-- .../Commands/RicCreateTemporaryLgrFeature.cpp | 11 +------ .../ProjectDataModel/RimEclipseCase.cpp | 32 +++++++++++++++++++ .../ProjectDataModel/RimEclipseCase.h | 2 ++ .../RimEclipseResultDefinition.cpp | 14 ++++++++ .../ReservoirDataModel/RigNNCData.cpp | 6 ++-- .../ReservoirDataModel/RigNNCData.h | 2 +- 8 files changed, 74 insertions(+), 15 deletions(-) diff --git a/ApplicationCode/Application/RiaDefines.cpp b/ApplicationCode/Application/RiaDefines.cpp index f459d77fc0..5423722e30 100644 --- a/ApplicationCode/Application/RiaDefines.cpp +++ b/ApplicationCode/Application/RiaDefines.cpp @@ -386,6 +386,22 @@ QString RiaDefines::formationAllanResultName() return "Formation Allan"; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::set RiaDefines::nncResultNames() +{ + return {combinedTransmissibilityResultName(), + formationAllanResultName(), + formationBinaryAllanResultName(), + combinedWaterFluxResultName(), + combinedGasFluxResultName(), + combinedOilFluxResultName(), + combinedRiAreaNormTranResultName(), + combinedRiMultResultName(), + combinedRiTranResultName()}; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Application/RiaDefines.h b/ApplicationCode/Application/RiaDefines.h index 04385e6e40..e88528c590 100644 --- a/ApplicationCode/Application/RiaDefines.h +++ b/ApplicationCode/Application/RiaDefines.h @@ -21,6 +21,7 @@ #pragma once #include +#include #include namespace RiaDefines @@ -106,8 +107,9 @@ QString mobilePoreVolumeName(); QString completionTypeResultName(); // Fault results -QString formationBinaryAllanResultName(); -QString formationAllanResultName(); +QString formationBinaryAllanResultName(); +QString formationAllanResultName(); +std::set nncResultNames(); // Mock model text identifiers QString mockModelBasic(); diff --git a/ApplicationCode/Commands/RicCreateTemporaryLgrFeature.cpp b/ApplicationCode/Commands/RicCreateTemporaryLgrFeature.cpp index c91bd91cfe..2da099ffda 100644 --- a/ApplicationCode/Commands/RicCreateTemporaryLgrFeature.cpp +++ b/ApplicationCode/Commands/RicCreateTemporaryLgrFeature.cpp @@ -124,16 +124,7 @@ void RicCreateTemporaryLgrFeature::updateViews( RimEclipseCase* eclipseCase ) RiaApplication::instance()->project()->mainPlotCollection()->wellLogPlotCollection()->reloadAllPlots(); - for ( const auto& v : eclipseCase->views() ) - { - RimEclipseView* eclipseView = dynamic_cast( v ); - if ( eclipseView ) - { - eclipseView->scheduleReservoirGridGeometryRegen(); - } - - v->loadDataAndUpdate(); - } + eclipseCase->createDisplayModelAndUpdateAllViews(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp b/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp index 44e1830b2d..ac1fe571ad 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp @@ -707,6 +707,38 @@ void RimEclipseCase::ensureFaultDataIsComputed() } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimEclipseCase::ensureNncDataIsComputed() +{ + bool computedData = false; + RigEclipseCaseData* rigEclipseCase = eclipseCaseData(); + if ( rigEclipseCase && rigEclipseCase->mainGrid() ) + { + computedData = rigEclipseCase->mainGrid()->nncData()->ensureConnectionDataIsProcecced(); + } + + return computedData; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEclipseCase::createDisplayModelAndUpdateAllViews() +{ + for ( const auto& v : views() ) + { + RimEclipseView* eclipseView = dynamic_cast( v ); + if ( eclipseView ) + { + eclipseView->scheduleReservoirGridGeometryRegen(); + } + + v->loadDataAndUpdate(); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimEclipseCase.h b/ApplicationCode/ProjectDataModel/RimEclipseCase.h index 5f9a34a952..7c25b52856 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseCase.h +++ b/ApplicationCode/ProjectDataModel/RimEclipseCase.h @@ -116,6 +116,8 @@ public: void loadAndSyncronizeInputProperties( bool includeGridFileName ); void ensureFaultDataIsComputed(); + bool ensureNncDataIsComputed(); + void createDisplayModelAndUpdateAllViews(); protected: void initAfterRead() override; diff --git a/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.cpp b/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.cpp index b2def83ded..619df2822f 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.cpp @@ -23,6 +23,7 @@ #include "RiaApplication.h" #include "RiaColorTables.h" #include "RiaLogging.h" +#include "RiaNncDefines.h" #include "RiaQDateTimeTools.h" #include "RicfCommandObject.h" @@ -1141,6 +1142,19 @@ void RimEclipseResultDefinition::loadResult() gridCellResults->createResultEntry( this->eclipseResultAddress(), false ); } + QString resultName = m_resultVariable(); + std::set eclipseResultNamesWithNncData = RiaDefines::nncResultNames(); + if ( eclipseResultNamesWithNncData.find( resultName ) != eclipseResultNamesWithNncData.end() ) + { + eclipseCase()->ensureFaultDataIsComputed(); + + bool dataWasComputed = eclipseCase()->ensureNncDataIsComputed(); + if ( dataWasComputed ) + { + eclipseCase()->createDisplayModelAndUpdateAllViews(); + } + } + gridCellResults->ensureKnownResultLoaded( this->eclipseResultAddress() ); } } diff --git a/ApplicationCode/ReservoirDataModel/RigNNCData.cpp b/ApplicationCode/ReservoirDataModel/RigNNCData.cpp index 130e980345..dc70fb88de 100644 --- a/ApplicationCode/ReservoirDataModel/RigNNCData.cpp +++ b/ApplicationCode/ReservoirDataModel/RigNNCData.cpp @@ -186,9 +186,9 @@ size_t RigNNCData::connectionsWithNoCommonArea( QStringList& connectionTextFirst //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigNNCData::ensureConnectionDataIsProcecced() +bool RigNNCData::ensureConnectionDataIsProcecced() { - if ( m_connectionsAreProcessed ) return; + if ( m_connectionsAreProcessed ) return false; if ( m_mainGrid ) { @@ -228,6 +228,8 @@ void RigNNCData::ensureConnectionDataIsProcecced() } } } + + return true; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ReservoirDataModel/RigNNCData.h b/ApplicationCode/ReservoirDataModel/RigNNCData.h index 008114a25b..90f5d6bd33 100644 --- a/ApplicationCode/ReservoirDataModel/RigNNCData.h +++ b/ApplicationCode/ReservoirDataModel/RigNNCData.h @@ -50,7 +50,7 @@ public: RigNNCData(); - void ensureConnectionDataIsProcecced(); + bool ensureConnectionDataIsProcecced(); void setSourceDataForProcessing( RigMainGrid* mainGrid, const RigActiveCellInfo* activeCellInfo, bool includeInactiveCells ); From c8420d59629ab073fc29a1465df2941694d87db0 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 18 May 2020 12:06:42 +0200 Subject: [PATCH 25/46] NNC : Fix visual artifacts for some models --- .../ReservoirDataModel/RigNncConnection.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/ApplicationCode/ReservoirDataModel/RigNncConnection.cpp b/ApplicationCode/ReservoirDataModel/RigNncConnection.cpp index 2d0f93f28f..81bcd24066 100644 --- a/ApplicationCode/ReservoirDataModel/RigNncConnection.cpp +++ b/ApplicationCode/ReservoirDataModel/RigNncConnection.cpp @@ -42,6 +42,14 @@ RigConnection::RigConnection( unsigned c1GlobIdx, , m_c1Face( static_cast( c1Face ) ) , m_polygon( polygon ) { + if ( c1GlobIdx >= c2GlobIdx ) + { + // Ensure the smallest cell index is the first index + // TODO : The face type is related to cell 1, so face should be changed to opposite face + // This causes visual artifacts for some models, so this change will require more investigation + m_c1GlobIdx = c2GlobIdx; + m_c2GlobIdx = c1GlobIdx; + } } //-------------------------------------------------------------------------------------------------- @@ -57,6 +65,15 @@ RigConnection::RigConnection( size_t c1GlobIdx, , m_polygon( polygon ) { CVF_ASSERT( c1GlobIdx < std::numeric_limits::max() && c2GlobIdx < std::numeric_limits::max() ); + + if ( c1GlobIdx >= c2GlobIdx ) + { + // Ensure the smallest cell index is the first index + // TODO : The face type is related to cell 1, so face should be changed to opposite face + // This causes visual artifacts for some models, so this change will require more investigation + m_c1GlobIdx = static_cast( c2GlobIdx ); + m_c2GlobIdx = static_cast( c1GlobIdx ); + } } //-------------------------------------------------------------------------------------------------- From 2df4def7b17a797e74b004af82b08b173cc12f9c Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 18 May 2020 15:21:45 +0200 Subject: [PATCH 26/46] NNC : Fix pytest --- .../GrpcInterface/Python/rips/tests/test_nnc_properties.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ApplicationCode/GrpcInterface/Python/rips/tests/test_nnc_properties.py b/ApplicationCode/GrpcInterface/Python/rips/tests/test_nnc_properties.py index 0f542eb37f..10be9a05e8 100644 --- a/ApplicationCode/GrpcInterface/Python/rips/tests/test_nnc_properties.py +++ b/ApplicationCode/GrpcInterface/Python/rips/tests/test_nnc_properties.py @@ -22,7 +22,7 @@ def test_10kSync(rips_instance, initialize_test): assert(NNCProperties_pb2.NNCPropertyType.Value('NNC_STATIC') == properties[0].property_type) nnc_connections = case.nnc_connections() - assert(len(nnc_connections) == 3416) + assert(len(nnc_connections) == 3627) connection = nnc_connections[0] assert(connection.cell1.i == 33) From 67b5dc8615b69b0a176529591fbe7fdf04f5e28d Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Tue, 19 May 2020 12:45:14 +0200 Subject: [PATCH 27/46] #5950 Wbs: Fix wrong behaviour for LAS-file PP_INP --- .../RigGeoMechWellLogExtractor.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/ApplicationCode/ReservoirDataModel/RigGeoMechWellLogExtractor.cpp b/ApplicationCode/ReservoirDataModel/RigGeoMechWellLogExtractor.cpp index b9ca8e9a9f..c2da7f247a 100644 --- a/ApplicationCode/ReservoirDataModel/RigGeoMechWellLogExtractor.cpp +++ b/ApplicationCode/ReservoirDataModel/RigGeoMechWellLogExtractor.cpp @@ -317,10 +317,15 @@ std::vector if ( !lasFileValues.empty() ) { double lasValue = getWellLogIntersectionValue( intersectionIdx, lasFileValues ); - // Only accept las-values for reservoir if the result is PP Reservoir - bool invalidLasRegion = isPPResResult && intersectionIdx < gridValues.size() && - gridValues[intersectionIdx] != std::numeric_limits::infinity(); - if ( lasValue != std::numeric_limits::infinity() && !invalidLasRegion ) + // Only accept las-values for PP_reservoir if the grid result is valid + bool validLasRegion = true; + if (isPPResResult) + { + validLasRegion = intersectionIdx < gridValues.size() && + gridValues[intersectionIdx] != std::numeric_limits::infinity(); + } + + if ( validLasRegion && lasValue != std::numeric_limits::infinity()) { unscaledValues[intersectionIdx] = lasValue; finalSourcesPerSegment[intersectionIdx] = RigWbsParameter::LAS_FILE; From df596a5f6aba19c7b78fd6c1f284fe65b78b0219 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Wed, 20 May 2020 08:35:56 +0200 Subject: [PATCH 28/46] Fix signed/unsigned warning --- .../ReservoirDataModel/RigGeoMechWellLogExtractor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ApplicationCode/ReservoirDataModel/RigGeoMechWellLogExtractor.cpp b/ApplicationCode/ReservoirDataModel/RigGeoMechWellLogExtractor.cpp index c2da7f247a..145dd8ccc7 100644 --- a/ApplicationCode/ReservoirDataModel/RigGeoMechWellLogExtractor.cpp +++ b/ApplicationCode/ReservoirDataModel/RigGeoMechWellLogExtractor.cpp @@ -321,7 +321,7 @@ std::vector bool validLasRegion = true; if (isPPResResult) { - validLasRegion = intersectionIdx < gridValues.size() && + validLasRegion = intersectionIdx < (int64_t) gridValues.size() && gridValues[intersectionIdx] != std::numeric_limits::infinity(); } From ba497bebdf9673f38167ab70e3f55645f672cf8e Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Wed, 20 May 2020 09:16:49 +0200 Subject: [PATCH 29/46] #5945 Make the new default ensemble curve set feature take the preferences into account --- .../RicNewSummaryEnsembleCurveSetFeature.cpp | 61 +++++++++++++------ .../RicNewSummaryEnsembleCurveSetFeature.h | 2 +- 2 files changed, 43 insertions(+), 20 deletions(-) diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryEnsembleCurveSetFeature.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryEnsembleCurveSetFeature.cpp index a9f9b10acb..a3e3e51311 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryEnsembleCurveSetFeature.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryEnsembleCurveSetFeature.cpp @@ -20,6 +20,7 @@ #include "RiaColorTables.h" #include "RiaGuiApplication.h" +#include "RiaPreferences.h" #include "RiaSummaryTools.h" #include "RimEnsembleCurveFilterCollection.h" @@ -49,30 +50,45 @@ CAF_CMD_SOURCE_INIT( RicNewSummaryEnsembleCurveSetFeature, "RicNewSummaryEnsembl //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimEnsembleCurveSet* RicNewSummaryEnsembleCurveSetFeature::addDefaultCurveSet( RimSummaryPlot* plot, - RimSummaryCaseCollection* ensemble ) +std::vector RicNewSummaryEnsembleCurveSetFeature::addDefaultCurveSets( RimSummaryPlot* plot, + RimSummaryCaseCollection* ensemble ) { - CVF_ASSERT( plot && ensemble ); + CVF_ASSERT( plot && ensemble ); RimProject* project = RiaApplication::instance()->project(); CVF_ASSERT( project ); - RimEnsembleCurveSet* curveSet = new RimEnsembleCurveSet(); + QString curvesTextFilter = RiaApplication::instance()->preferences()->defaultSummaryCurvesTextFilter; + QStringList curveFilters = curvesTextFilter.split( ";", QString::SkipEmptyParts ); - // Use same counting as RicNewSummaryCurveFeature::onActionTriggered - auto colorIndex = plot->singleColorCurveCount(); - curveSet->setColor( RiaColorTables::summaryCurveDefaultPaletteColors().cycledColor3f( colorIndex ) ); - curveSet->legendConfig()->setColorRange( - RimEnsembleCurveSetColorManager::cycledEnsembleColorRange( static_cast( colorIndex ) ) ); + std::set addrs = ensemble->ensembleSummaryAddresses(); - curveSet->setSummaryCaseCollection( ensemble ); - curveSet->setSummaryAddress( RifEclipseSummaryAddress::fieldAddress( "FOPT" ) ); + std::vector curveSets; + for ( const auto& addr : addrs ) + { + for (auto filter : curveFilters) + { + if ( addr.isUiTextMatchingFilterText( filter ) ) + { + RimEnsembleCurveSet* curveSet = new RimEnsembleCurveSet(); - curveSet->filterCollection()->addFilter(); + // Use same counting as RicNewSummaryCurveFeature::onActionTriggered + auto colorIndex = plot->singleColorCurveCount(); + curveSet->setColor( RiaColorTables::summaryCurveDefaultPaletteColors().cycledColor3f( colorIndex ) ); + curveSet->legendConfig()->setColorRange( + RimEnsembleCurveSetColorManager::cycledEnsembleColorRange( static_cast( colorIndex ) ) ); - plot->ensembleCurveSetCollection()->addCurveSet( curveSet ); + curveSet->setSummaryCaseCollection( ensemble ); + curveSet->setSummaryAddress( addr ); + curveSet->filterCollection()->addFilter(); - return curveSet; + plot->ensembleCurveSetCollection()->addCurveSet( curveSet ); + curveSets.push_back( curveSet ); + } + } + } + + return curveSets; } //-------------------------------------------------------------------------------------------------- @@ -84,14 +100,16 @@ RimSummaryPlot* RiaGuiApplication* app = RiaGuiApplication::instance(); RimProject* proj = app->project(); + if ( RiaApplication::instance()->preferences()->defaultSummaryCurvesTextFilter().isEmpty() ) return nullptr; + RimSummaryPlotCollection* summaryPlotCollection = proj->mainPlotCollection->summaryPlotCollection(); RimSummaryPlot* plot = summaryPlotCollection->createSummaryPlotWithAutoTitle(); RimEnsembleCurveSet* firstCurveSetCreated = nullptr; for ( RimSummaryCaseCollection* ensemble : ensembles ) { - RimEnsembleCurveSet* curveSet = RicNewSummaryEnsembleCurveSetFeature::addDefaultCurveSet( plot, ensemble ); - if ( !firstCurveSetCreated ) firstCurveSetCreated = curveSet; + std::vector curveSets = RicNewSummaryEnsembleCurveSetFeature::addDefaultCurveSets( plot, ensemble ); + if ( !firstCurveSetCreated && !curveSets.empty() ) firstCurveSetCreated = curveSets.front(); } plot->loadDataAndUpdate(); @@ -138,15 +156,20 @@ void RicNewSummaryEnsembleCurveSetFeature::onActionTriggered( bool isChecked ) CVF_ASSERT( !project->summaryGroups().empty() ); auto ensemble = project->summaryGroups().back(); - auto curveSet = RicNewSummaryEnsembleCurveSetFeature::addDefaultCurveSet( plot, ensemble ); + RimEnsembleCurveSet* firstCurveSet = nullptr; + if (!RiaApplication::instance()->preferences()->defaultSummaryCurvesTextFilter().isEmpty()) + { + auto curveSets = RicNewSummaryEnsembleCurveSetFeature::addDefaultCurveSets(plot, ensemble); + if ( !curveSets.empty() ) firstCurveSet = curveSets.front(); + } plot->loadDataAndUpdate(); plot->updateConnectedEditors(); RiaGuiApplication* app = RiaGuiApplication::instance(); RiuPlotMainWindow* mainPlotWindow = app->getOrCreateAndShowMainPlotWindow(); - if ( mainPlotWindow ) + if ( mainPlotWindow && firstCurveSet) { - mainPlotWindow->selectAsCurrentItem( curveSet ); + mainPlotWindow->selectAsCurrentItem(firstCurveSet); mainPlotWindow->updateSummaryPlotToolBar(); } } diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryEnsembleCurveSetFeature.h b/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryEnsembleCurveSetFeature.h index 85606d572f..f9166a06b4 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryEnsembleCurveSetFeature.h +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryEnsembleCurveSetFeature.h @@ -43,7 +43,7 @@ protected: void setupActionLook( QAction* actionToSetup ) override; private: - static RimEnsembleCurveSet* addDefaultCurveSet( RimSummaryPlot* plot, RimSummaryCaseCollection* ensemble ); + static std::vector addDefaultCurveSets( RimSummaryPlot* plot, RimSummaryCaseCollection* ensemble ); private: RimSummaryPlot* selectedSummaryPlot() const; From fb763483a22e5405aeeffdd0cc62232f70bf8985 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 20 May 2020 18:33:36 +0200 Subject: [PATCH 30/46] Always try to import well path from well path cache --- .../ProjectDataModel/RimFileWellPath.cpp | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimFileWellPath.cpp b/ApplicationCode/ProjectDataModel/RimFileWellPath.cpp index b00a03e971..031cdbc5a7 100644 --- a/ApplicationCode/ProjectDataModel/RimFileWellPath.cpp +++ b/ApplicationCode/ProjectDataModel/RimFileWellPath.cpp @@ -260,19 +260,10 @@ bool RimFileWellPath::isStoredInCache() const //-------------------------------------------------------------------------------------------------- void RimFileWellPath::updateFilePathsFromProjectPath( const QString& newProjectPath, const QString& oldProjectPath ) { - // RimWellPath::updateFilePathsFromProjectPath( newProjectPath, oldProjectPath ); + QString newCacheFileName = getCacheFileName(); - if ( isStoredInCache() ) + if ( caf::Utils::fileExists( newCacheFileName ) ) { - QString newCacheFileName = getCacheFileName(); - - if ( caf::Utils::fileExists( newCacheFileName ) ) - { - m_filePathInCache = newCacheFileName; - } + m_filePathInCache = newCacheFileName; } - // else - // { - // m_filepath = RimTools::relocateFile( m_filepath(), newProjectPath, oldProjectPath, nullptr, nullptr ); - // } } From cc1f157e09503abec3350397eee68528583c4dd6 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Wed, 20 May 2020 10:38:28 +0200 Subject: [PATCH 31/46] #5905 Fix wrong percentile calculation * We sent in percent values (0-100) instead of the fractional values (0 - 1) that RigHistogramCalculator::calculatePercentile required. * It has been like this for years AFAICT. --- .../ProjectDataModel/RimEclipseStatisticsCaseEvaluator.cpp | 6 +++--- ApplicationCode/ResultStatisticsCache/RigStatisticsMath.cpp | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimEclipseStatisticsCaseEvaluator.cpp b/ApplicationCode/ProjectDataModel/RimEclipseStatisticsCaseEvaluator.cpp index 3fdf91c6b6..7f93747cec 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseStatisticsCaseEvaluator.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseStatisticsCaseEvaluator.cpp @@ -298,9 +298,9 @@ void RimEclipseStatisticsCaseEvaluator::evaluateForResults( const QList std::vector histogram; RigHistogramCalculator histCalc( statParams[MIN], statParams[MAX], 100, &histogram ); histCalc.addData( values ); - statParams[PMIN] = histCalc.calculatePercentil( m_statisticsConfig.m_pMinPos ); - statParams[PMID] = histCalc.calculatePercentil( m_statisticsConfig.m_pMidPos ); - statParams[PMAX] = histCalc.calculatePercentil( m_statisticsConfig.m_pMaxPos ); + statParams[PMIN] = histCalc.calculatePercentil( m_statisticsConfig.m_pMinPos / 100.0 ); + statParams[PMID] = histCalc.calculatePercentil( m_statisticsConfig.m_pMidPos / 100.0 ); + statParams[PMAX] = histCalc.calculatePercentil( m_statisticsConfig.m_pMaxPos / 100.0 ); } else if ( m_statisticsConfig.m_pValMethod == RimEclipseStatisticsCase::INTERPOLATED_OBSERVATION ) diff --git a/ApplicationCode/ResultStatisticsCache/RigStatisticsMath.cpp b/ApplicationCode/ResultStatisticsCache/RigStatisticsMath.cpp index e768a7ba6e..cf8d32c0fa 100644 --- a/ApplicationCode/ResultStatisticsCache/RigStatisticsMath.cpp +++ b/ApplicationCode/ResultStatisticsCache/RigStatisticsMath.cpp @@ -317,9 +317,10 @@ double RigHistogramCalculator::calculatePercentil( double pVal ) { assert( m_histogram ); assert( m_histogram->size() ); - assert( 0.0 <= pVal && pVal <= 1.0 ); + auto pValClamped = cvf::Math::clamp( pVal, 0.0, 1.0 ); + assert( 0.0 <= pValClamped && pValClamped <= 1.0 ); - double pValObservationCount = pVal * m_observationCount; + double pValObservationCount = pValClamped * m_observationCount; if ( pValObservationCount == 0.0 ) return m_min; size_t accObsCount = 0; From 52a2ed545e1a55f20cc37d6ec8351318b69fb707 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Wed, 20 May 2020 15:42:48 +0200 Subject: [PATCH 32/46] #5830 Fix auto-generated target at sea level --- .../RimWellPathGeometryDef.cpp | 44 +++++++++++-------- .../ProjectDataModel/RimWellPathGeometryDef.h | 7 +-- 2 files changed, 30 insertions(+), 21 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimWellPathGeometryDef.cpp b/ApplicationCode/ProjectDataModel/RimWellPathGeometryDef.cpp index e0103a5a67..5c75b04872 100644 --- a/ApplicationCode/ProjectDataModel/RimWellPathGeometryDef.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellPathGeometryDef.cpp @@ -75,11 +75,12 @@ RimWellPathGeometryDef::RimWellPathGeometryDef() "", "" ); + CAF_PDM_InitFieldNoDefault( &m_autoTargetAtSeaLevel, "AutoGeneratedTarget", "Auto Generated Target", "", "", "" ); + m_autoTargetAtSeaLevel = new RimWellPathTarget; + m_autoTargetAtSeaLevel->setEnabled( false ); + CAF_PDM_InitField( &m_pickPointsEnabled, "m_pickPointsEnabled", false, "", "", "", "" ); caf::PdmUiPushButtonEditor::configureEditorForField( &m_pickPointsEnabled ); - - m_autoTargetAtSeaLevel.reset( new RimWellPathTarget ); - m_autoTargetAtSeaLevel->setEnabled( false ); } //-------------------------------------------------------------------------------------------------- @@ -148,6 +149,11 @@ cvf::ref RimWellPathGeometryDef::createWellPathGeometry() { cvf::ref wellPathGeometry = new RigWellPath; + if ( m_useAutoGeneratedTargetAtSeaLevel ) + { + updateTargetAtSeaLevel(); + } + RiaLineArcWellPathCalculator wellPathCalculator = lineArcWellPathCalculator(); if ( wellPathCalculator.lineArcEndpoints().size() < 2 ) return wellPathGeometry; @@ -163,7 +169,6 @@ cvf::ref RimWellPathGeometryDef::createWellPathGeometry() { wellPathGeometry->setDatumElevation( m_airGap ); } - updateTargetAtSeaLevel(); return wellPathGeometry; } @@ -211,7 +216,7 @@ std::pair if ( wt->isEnabled() && !foundTarget ) before = wt; } - return { before, after }; + return {before, after}; } //-------------------------------------------------------------------------------------------------- @@ -365,7 +370,7 @@ std::vector RimWellPathGeometryDef::activeWellTargets() cons if ( m_useAutoGeneratedTargetAtSeaLevel && !m_wellTargets.empty() && m_autoTargetAtSeaLevel ) { - active.push_back( m_autoTargetAtSeaLevel.get() ); + active.push_back( m_autoTargetAtSeaLevel ); } for ( const auto& wt : m_wellTargets ) @@ -386,7 +391,9 @@ RiaLineArcWellPathCalculator RimWellPathGeometryDef::lineArcWellPathCalculator() { std::vector targetDatas; - for ( auto wellTarget : m_wellTargets ) + std::vector wellTargets = activeWellTargets(); + + for ( auto wellTarget : wellTargets ) { if ( wellTarget->isEnabled() ) { @@ -400,27 +407,27 @@ RiaLineArcWellPathCalculator RimWellPathGeometryDef::lineArcWellPathCalculator() for ( size_t tIdx = 0; tIdx < m_wellTargets.size(); ++tIdx ) { - m_wellTargets[tIdx]->flagRadius1AsIncorrect( targetStatuses[tIdx].isRadius1Editable, false, 0 ); - m_wellTargets[tIdx]->flagRadius2AsIncorrect( targetStatuses[tIdx].isRadius2Editable, false, 0 ); + wellTargets[tIdx]->flagRadius1AsIncorrect( targetStatuses[tIdx].isRadius1Editable, false, 0 ); + wellTargets[tIdx]->flagRadius2AsIncorrect( targetStatuses[tIdx].isRadius2Editable, false, 0 ); if ( targetStatuses[tIdx].hasDerivedTangent ) { - m_wellTargets[tIdx]->setDerivedTangent( targetStatuses[tIdx].resultAzimuth, - targetStatuses[tIdx].resultInclination ); + wellTargets[tIdx]->setDerivedTangent( targetStatuses[tIdx].resultAzimuth, + targetStatuses[tIdx].resultInclination ); } if ( targetStatuses[tIdx].hasOverriddenRadius1 ) { - m_wellTargets[tIdx]->flagRadius1AsIncorrect( targetStatuses[tIdx].isRadius1Editable, - true, - targetStatuses[tIdx].resultRadius1 ); + wellTargets[tIdx]->flagRadius1AsIncorrect( targetStatuses[tIdx].isRadius1Editable, + true, + targetStatuses[tIdx].resultRadius1 ); } if ( targetStatuses[tIdx].hasOverriddenRadius2 ) { - m_wellTargets[tIdx]->flagRadius2AsIncorrect( targetStatuses[tIdx].isRadius2Editable, - true, - targetStatuses[tIdx].resultRadius2 ); + wellTargets[tIdx]->flagRadius2AsIncorrect( targetStatuses[tIdx].isRadius2Editable, + true, + targetStatuses[tIdx].resultRadius2 ); } } @@ -452,7 +459,8 @@ void RimWellPathGeometryDef::updateTargetAtSeaLevel() newPos = firstTarget->targetPointXYZ() - horizontalLengthFromTarget * tangentInHorizontalPlane; newPos.z() = -referencePointXyz().z(); - m_autoTargetAtSeaLevel->setAsPointXYZAndTangentTarget( { newPos[0], newPos[1], newPos[2] }, 0, 0 ); + m_autoTargetAtSeaLevel->setAsPointXYZAndTangentTarget( {newPos[0], newPos[1], newPos[2]}, 0, 0 ); + m_autoTargetAtSeaLevel->setEnabled( true ); } } diff --git a/ApplicationCode/ProjectDataModel/RimWellPathGeometryDef.h b/ApplicationCode/ProjectDataModel/RimWellPathGeometryDef.h index e72b1071ee..ce9b8049a2 100644 --- a/ApplicationCode/ProjectDataModel/RimWellPathGeometryDef.h +++ b/ApplicationCode/ProjectDataModel/RimWellPathGeometryDef.h @@ -22,6 +22,7 @@ #include "cafAppEnum.h" #include "cafPdmChildArrayField.h" +#include "cafPdmChildField.h" #include "cafPdmField.h" #include "cafPdmFieldCvfVec3d.h" #include "cafPdmObject.h" @@ -89,6 +90,7 @@ private: RiaLineArcWellPathCalculator lineArcWellPathCalculator() const; void updateTargetAtSeaLevel(); + void test(); private: caf::PdmField m_referencePointUtmXyd; @@ -98,9 +100,8 @@ private: caf::PdmField m_mdAtFirstTarget; caf::PdmChildArrayField m_wellTargets; caf::PdmField m_useAutoGeneratedTargetAtSeaLevel; - - caf::PdmField m_pickPointsEnabled; + caf::PdmChildField m_autoTargetAtSeaLevel; + caf::PdmField m_pickPointsEnabled; std::shared_ptr m_pickTargetsEventHandler; - std::unique_ptr m_autoTargetAtSeaLevel; }; From 6b64ab7982e3e7888347ba43d86385e4b677a8dc Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 22 May 2020 09:57:32 +0200 Subject: [PATCH 33/46] Well Target : Show "MD at first target" as disabled instead of hidden --- .../ProjectDataModel/RimWellPathGeometryDef.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimWellPathGeometryDef.cpp b/ApplicationCode/ProjectDataModel/RimWellPathGeometryDef.cpp index 5c75b04872..01e5cde35d 100644 --- a/ApplicationCode/ProjectDataModel/RimWellPathGeometryDef.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellPathGeometryDef.cpp @@ -342,14 +342,13 @@ void RimWellPathGeometryDef::defineUiOrdering( QString uiConfigName, caf::PdmUiO { uiOrdering.add( &m_referencePointUtmXyd ); uiOrdering.add( &m_airGap ); - if ( !m_useAutoGeneratedTargetAtSeaLevel() ) - { - uiOrdering.add( &m_mdAtFirstTarget ); - } - + uiOrdering.add( &m_mdAtFirstTarget ); uiOrdering.add( &m_useAutoGeneratedTargetAtSeaLevel ); uiOrdering.add( &m_wellTargets ); uiOrdering.add( &m_pickPointsEnabled ); + + m_mdAtFirstTarget.uiCapability()->setUiReadOnly( m_useAutoGeneratedTargetAtSeaLevel() ); + uiOrdering.skipRemainingFields( true ); } From 82969c3523a82bf2869a7af5c7f0106d63d92452 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 22 May 2020 10:28:42 +0200 Subject: [PATCH 34/46] #5898 Postfix fault direction instead of prefix --- .../FileInterface/RifEclipseInputFileTools.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ApplicationCode/FileInterface/RifEclipseInputFileTools.cpp b/ApplicationCode/FileInterface/RifEclipseInputFileTools.cpp index 5cd530d117..cadc9c49e3 100644 --- a/ApplicationCode/FileInterface/RifEclipseInputFileTools.cpp +++ b/ApplicationCode/FileInterface/RifEclipseInputFileTools.cpp @@ -1320,17 +1320,17 @@ QString RifEclipseInputFileTools::faultFaceText( cvf::StructGridInterface::FaceT switch ( faceType ) { case cvf::StructGridInterface::POS_I: - return QString( " I" ); + return QString( "I " ); case cvf::StructGridInterface::NEG_I: - return QString( "-I" ); + return QString( "I-" ); case cvf::StructGridInterface::POS_J: - return QString( " J" ); + return QString( "J " ); case cvf::StructGridInterface::NEG_J: - return QString( "-J" ); + return QString( "J-" ); case cvf::StructGridInterface::POS_K: - return QString( " K" ); + return QString( "K " ); case cvf::StructGridInterface::NEG_K: - return QString( "-K" ); + return QString( "K-" ); default: CVF_ASSERT( false ); } From 79d32d599336d68ee203364ae78fcfea5602ede0 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 22 May 2020 12:04:43 +0200 Subject: [PATCH 35/46] #5917 Export Completion: Use export name in comments --- .../RicFishbonesTransmissibilityCalculationFeatureImp.cpp | 2 +- .../RicWellPathFractureTextReportFeatureImpl.cpp | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicFishbonesTransmissibilityCalculationFeatureImp.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicFishbonesTransmissibilityCalculationFeatureImp.cpp index 62b3f01b04..0577247615 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicFishbonesTransmissibilityCalculationFeatureImp.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicFishbonesTransmissibilityCalculationFeatureImp.cpp @@ -349,7 +349,7 @@ void RicFishbonesTransmissibilityCalculationFeatureImp::appendMainWellBoreParts( for ( const auto& cellIntersectionInfo : intersectedCellsIntersectionInfo ) { - QString completionMetaData = wellPath->name() + " main bore"; + QString completionMetaData = wellPath->completions()->wellNameForExport() + " main bore"; WellBorePartForTransCalc wellBorePart = WellBorePartForTransCalc( cellIntersectionInfo.intersectionLengthsInCellCS, holeRadius, skinFactor, diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathFractureTextReportFeatureImpl.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathFractureTextReportFeatureImpl.cpp index ea8e4da7b2..854a984139 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathFractureTextReportFeatureImpl.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathFractureTextReportFeatureImpl.cpp @@ -41,6 +41,7 @@ #include "RimTools.h" #include "RimWellPath.h" #include "RimWellPathCollection.h" +#include "RimWellPathCompletions.h" #include "RimWellPathFracture.h" #include "RimWellPathFractureCollection.h" @@ -253,7 +254,7 @@ QString RicWellPathFractureTextReportFeatureImpl::createWellFileLocationText( co auto fileWellPath = dynamic_cast( wellPath ); if ( fileWellPath ) { - formatter.add( wellPath->name() ); + formatter.add( wellPath->completions()->wellNameForExport() ); formatter.add( fileWellPath->filePath() ); formatter.rowCompleted(); } @@ -564,7 +565,7 @@ QString RicWellPathFractureTextReportFeatureImpl::createFractureInstancesText( fracture->firstAncestorOrThisOfType( wellPath ); if ( wellPath ) { - wellName = wellPath->name(); + wellName = wellPath->completions()->wellNameForExport(); } formatter.add( wellName ); From 2dc9d1c10bc616e6f4ef610483b1b5ded4727dfb Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 22 May 2020 12:25:25 +0200 Subject: [PATCH 36/46] #5917 Export Completion: Avoid overwrite of export completion well name --- ApplicationCode/ProjectDataModel/RimFileWellPath.cpp | 12 ++++++++++-- ApplicationCode/ProjectDataModel/RimFileWellPath.h | 2 +- ApplicationCode/ProjectDataModel/RimWellPath.cpp | 11 ++++++++++- ApplicationCode/ProjectDataModel/RimWellPath.h | 1 + .../ProjectDataModel/RimWellPathCollection.cpp | 6 +++--- 5 files changed, 25 insertions(+), 7 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimFileWellPath.cpp b/ApplicationCode/ProjectDataModel/RimFileWellPath.cpp index 031cdbc5a7..c45d435c87 100644 --- a/ApplicationCode/ProjectDataModel/RimFileWellPath.cpp +++ b/ApplicationCode/ProjectDataModel/RimFileWellPath.cpp @@ -139,7 +139,7 @@ void RimFileWellPath::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering //-------------------------------------------------------------------------------------------------- /// Read JSON or ascii file containing well path data //-------------------------------------------------------------------------------------------------- -bool RimFileWellPath::readWellPathFile( QString* errorMessage, RifWellPathImporter* wellPathImporter ) +bool RimFileWellPath::readWellPathFile( QString* errorMessage, RifWellPathImporter* wellPathImporter, bool setWellNameForExport ) { if ( caf::Utils::fileExists( this->filePath() ) ) { @@ -150,7 +150,15 @@ bool RimFileWellPath::readWellPathFile( QString* errorMessage, RifWellPathImport wellPathImporter->readWellMetaData( this->filePath(), m_wellPathIndexInFile() ); // General well info - setName( wellData.m_name ); + if ( setWellNameForExport ) + { + setName( wellData.m_name ); + } + else + { + setNameNoUpdateOfExportName( wellData.m_name ); + } + id = wellMetaData.m_id; sourceSystem = wellMetaData.m_sourceSystem; utmZone = wellMetaData.m_utmZone; diff --git a/ApplicationCode/ProjectDataModel/RimFileWellPath.h b/ApplicationCode/ProjectDataModel/RimFileWellPath.h index fc359db5ea..81b6b5c291 100644 --- a/ApplicationCode/ProjectDataModel/RimFileWellPath.h +++ b/ApplicationCode/ProjectDataModel/RimFileWellPath.h @@ -28,7 +28,7 @@ public: QString filePath() const; void setFilepath( const QString& path ); - bool readWellPathFile( QString* errorMessage, RifWellPathImporter* wellPathImporter ); + bool readWellPathFile( QString* errorMessage, RifWellPathImporter* wellPathImporter, bool setWellNameForExport ); int wellPathIndexInFile() const; // -1 means none. void setWellPathIndexInFile( int index ); void updateFilePathsFromProjectPath( const QString& newProjectPath, const QString& oldProjectPath ) override; diff --git a/ApplicationCode/ProjectDataModel/RimWellPath.cpp b/ApplicationCode/ProjectDataModel/RimWellPath.cpp index c8c0555a42..6d3f10e632 100644 --- a/ApplicationCode/ProjectDataModel/RimWellPath.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellPath.cpp @@ -440,8 +440,17 @@ QString RimWellPath::name() const //-------------------------------------------------------------------------------------------------- void RimWellPath::setName( const QString& name ) { - m_name = name; + setNameNoUpdateOfExportName( name ); + m_completions->setWellNameForExport( name ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellPath::setNameNoUpdateOfExportName( const QString& name ) +{ + m_name = name; tryAssociateWithSimulationWell(); } diff --git a/ApplicationCode/ProjectDataModel/RimWellPath.h b/ApplicationCode/ProjectDataModel/RimWellPath.h index 10389520dc..480687e9eb 100644 --- a/ApplicationCode/ProjectDataModel/RimWellPath.h +++ b/ApplicationCode/ProjectDataModel/RimWellPath.h @@ -74,6 +74,7 @@ public: QString name() const; void setName( const QString& name ); + void setNameNoUpdateOfExportName( const QString& name ); const QString associatedSimulationWellName() const; int associatedSimulationWellBranch() const; diff --git a/ApplicationCode/ProjectDataModel/RimWellPathCollection.cpp b/ApplicationCode/ProjectDataModel/RimWellPathCollection.cpp index 0abf9dfa92..2438341e2c 100644 --- a/ApplicationCode/ProjectDataModel/RimWellPathCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellPathCollection.cpp @@ -152,7 +152,7 @@ void RimWellPathCollection::loadDataAndUpdate() if ( !fWPath->filePath().isEmpty() ) { QString errorMessage; - if ( !fWPath->readWellPathFile( &errorMessage, m_wellPathImporter ) ) + if ( !fWPath->readWellPathFile( &errorMessage, m_wellPathImporter, false ) ) { RiaLogging::warning( errorMessage ); } @@ -260,7 +260,7 @@ void RimWellPathCollection::readAndAddWellPaths( std::vector& for ( size_t wpIdx = 0; wpIdx < wellPathArray.size(); wpIdx++ ) { RimFileWellPath* wellPath = wellPathArray[wpIdx]; - wellPath->readWellPathFile( nullptr, m_wellPathImporter ); + wellPath->readWellPathFile( nullptr, m_wellPathImporter, true ); progress.setProgressDescription( QString( "Reading file %1" ).arg( wellPath->name() ) ); @@ -270,7 +270,7 @@ void RimWellPathCollection::readAndAddWellPaths( std::vector& { existingWellPath->setFilepath( wellPath->filePath() ); existingWellPath->setWellPathIndexInFile( wellPath->wellPathIndexInFile() ); - existingWellPath->readWellPathFile( nullptr, m_wellPathImporter ); + existingWellPath->readWellPathFile( nullptr, m_wellPathImporter, true ); // Let name from well path file override name from well log file existingWellPath->setName( wellPath->name() ); From 73c1f97431a9032c7545f06c4fb5d7ab85232c01 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 22 May 2020 12:52:21 +0200 Subject: [PATCH 37/46] #5808 Summary Plot : Exclude *WCT vectors as cumulative vectors --- ApplicationCode/FileInterface/RifEclipseSummaryAddress.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ApplicationCode/FileInterface/RifEclipseSummaryAddress.cpp b/ApplicationCode/FileInterface/RifEclipseSummaryAddress.cpp index c69ae81a5f..c8597499d4 100644 --- a/ApplicationCode/FileInterface/RifEclipseSummaryAddress.cpp +++ b/ApplicationCode/FileInterface/RifEclipseSummaryAddress.cpp @@ -810,6 +810,13 @@ bool RifEclipseSummaryAddress::hasAccumulatedData() const } QString qBaseName = baseQuantityName( quantityForInspection ); + + if ( qBaseName.endsWith( "WCT" ) || qBaseName.endsWith( "WCTH" ) ) + { + // https://github.com/OPM/ResInsight/issues/5808 + return false; + } + return qBaseName.endsWith( "T" ) || qBaseName.endsWith( "TH" ); } From 718c1ac8270d2fb6deae85f2bd336f50a107af99 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 22 May 2020 14:25:07 +0200 Subject: [PATCH 38/46] #5929 Separate Fault Result: Missing fault coloring when Cell Result is defined "None" --- ApplicationCode/ProjectDataModel/RimEclipseView.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp index fee857e5c2..52576090ad 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp @@ -616,6 +616,11 @@ void RimEclipseView::onCreateDisplayModel() onUpdateLegends(); } + if ( m_faultResultSettings && m_faultResultSettings->hasValidCustomResult() ) + { + updateFaultColors(); + } + std::vector characteristicsPlots; this->objectsWithReferringPtrFieldsOfType( characteristicsPlots ); for ( auto plot : characteristicsPlots ) From 8370bd901e92094351ec97a499a72d4911b79649 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 22 May 2020 14:37:21 +0200 Subject: [PATCH 39/46] #5885 3D viewer: Clear grid cell selection when clicking outside visual objects --- ApplicationCode/UserInterface/RiuViewerCommands.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ApplicationCode/UserInterface/RiuViewerCommands.cpp b/ApplicationCode/UserInterface/RiuViewerCommands.cpp index c182044eb3..ce03e2b9d2 100644 --- a/ApplicationCode/UserInterface/RiuViewerCommands.cpp +++ b/ApplicationCode/UserInterface/RiuViewerCommands.cpp @@ -691,6 +691,10 @@ void RiuViewerCommands::handlePickAction( int winPosX, int winPosY, Qt::Keyboard } } } + else + { + Riu3dSelectionManager::instance()->deleteAllItems(); + } // Old pick handling. Todo: Encapsulate in pickEventHandlers { From 3f889afd4aaeb3ad08079d7db9be71b77f4fb78b Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Mon, 25 May 2020 08:59:00 +0200 Subject: [PATCH 40/46] Remove WBS parameter track color coding --- .../RicNewWellBoreStabilityPlotFeature.cpp | 1 - .../ProjectDataModel/RimWellLogTrack.cpp | 23 +++---------------- .../UserInterface/RiuPlotAnnotationTool.h | 2 +- 3 files changed, 4 insertions(+), 22 deletions(-) diff --git a/ApplicationCode/Commands/WellLogCommands/RicNewWellBoreStabilityPlotFeature.cpp b/ApplicationCode/Commands/WellLogCommands/RicNewWellBoreStabilityPlotFeature.cpp index ce6c374372..659c4c8c46 100644 --- a/ApplicationCode/Commands/WellLogCommands/RicNewWellBoreStabilityPlotFeature.cpp +++ b/ApplicationCode/Commands/WellLogCommands/RicNewWellBoreStabilityPlotFeature.cpp @@ -259,7 +259,6 @@ void RicNewWellBoreStabilityPlotFeature::createParametersTrack( RimWellBoreStabi paramCurvesTrack->setXAxisGridVisibility( RimWellLogPlot::AXIS_GRID_MAJOR_AND_MINOR ); paramCurvesTrack->setFormationWellPath( wellPath ); paramCurvesTrack->setFormationCase( geoMechCase ); - paramCurvesTrack->setAnnotationType( RiuPlotAnnotationTool::CURVE_ANNOTATIONS ); paramCurvesTrack->setShowRegionLabels( true ); paramCurvesTrack->setShowWindow( false ); std::set parameters = RigWbsParameter::allParameters(); diff --git a/ApplicationCode/ProjectDataModel/RimWellLogTrack.cpp b/ApplicationCode/ProjectDataModel/RimWellLogTrack.cpp index 81e8c96eaa..0973bd20f6 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogTrack.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellLogTrack.cpp @@ -132,10 +132,9 @@ void AppEnum::setUp() template <> void AppEnum::setUp() { - addItem( RiuPlotAnnotationTool::NO_ANNOTATIONS, "NO_ANNOTATIONS", "No Annotations" ); - addItem( RiuPlotAnnotationTool::FORMATION_ANNOTATIONS, "FORMATIONS", "Formations" ); - addItem( RiuPlotAnnotationTool::CURVE_ANNOTATIONS, "CURVE_DATA", "Curve Data Annotations" ); - setDefault( RiuPlotAnnotationTool::NO_ANNOTATIONS ); + addItem( RiuPlotAnnotationTool::RegionAnnotationType::NO_ANNOTATIONS, "NO_ANNOTATIONS", "No Annotations" ); + addItem( RiuPlotAnnotationTool::RegionAnnotationType::FORMATION_ANNOTATIONS, "FORMATIONS", "Formations" ); + setDefault( RiuPlotAnnotationTool::RegionAnnotationType::NO_ANNOTATIONS ); } template <> @@ -943,22 +942,6 @@ QList RimWellLogTrack::calculateValueOptions( const caf: { QList options; - if ( fieldNeedingOptions == &m_regionAnnotationType ) - { - options.push_back( caf::PdmOptionItemInfo( RegionAnnotationTypeEnum::uiText( RiuPlotAnnotationTool::NO_ANNOTATIONS ), - RiuPlotAnnotationTool::NO_ANNOTATIONS ) ); - options.push_back( - caf::PdmOptionItemInfo( RegionAnnotationTypeEnum::uiText( RiuPlotAnnotationTool::FORMATION_ANNOTATIONS ), - RiuPlotAnnotationTool::FORMATION_ANNOTATIONS ) ); - RimWellBoreStabilityPlot* wellBoreStabilityPlot = nullptr; - this->firstAncestorOrThisOfType( wellBoreStabilityPlot ); - if ( wellBoreStabilityPlot ) - { - options.push_back( - caf::PdmOptionItemInfo( RegionAnnotationTypeEnum::uiText( RiuPlotAnnotationTool::CURVE_ANNOTATIONS ), - RiuPlotAnnotationTool::CURVE_ANNOTATIONS ) ); - } - } if ( fieldNeedingOptions == &m_formationWellPathForSourceCase ) { RimTools::wellPathOptionItems( &options ); diff --git a/ApplicationCode/UserInterface/RiuPlotAnnotationTool.h b/ApplicationCode/UserInterface/RiuPlotAnnotationTool.h index 3cafed8e31..f4c36a33dd 100644 --- a/ApplicationCode/UserInterface/RiuPlotAnnotationTool.h +++ b/ApplicationCode/UserInterface/RiuPlotAnnotationTool.h @@ -37,7 +37,7 @@ public: { NO_ANNOTATIONS = 0, FORMATION_ANNOTATIONS = 1, - CURVE_ANNOTATIONS = 2 + // Used to have Wbs-parameter coding as 2 }; enum RegionDisplay { From f11d7d38328fefe049aee4b1dd70b0c7d77bdadf Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 25 May 2020 14:39:35 +0200 Subject: [PATCH 41/46] #5980 Grid Group Statistics : Swap names for P10 and P90 and skip underscore --- .../ProjectDataModel/RimEclipseStatisticsCaseEvaluator.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ApplicationCode/ProjectDataModel/RimEclipseStatisticsCaseEvaluator.cpp b/ApplicationCode/ProjectDataModel/RimEclipseStatisticsCaseEvaluator.cpp index 7f93747cec..6e33cc4224 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseStatisticsCaseEvaluator.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseStatisticsCaseEvaluator.cpp @@ -97,7 +97,10 @@ QString createResultNameRange( const QString& resultName ) } QString createResultNamePVal( const QString& resultName, double pValPos ) { - return resultName + "_P_" + QString::number( pValPos ); + // Invert the number for display text + double valueForDisplay = 100.0 - pValPos; + + return resultName + "_P" + QString::number( valueForDisplay ); } //-------------------------------------------------------------------------------------------------- From 6bef85ba4c503c6cf4ae395e3fc1f50abb6e4af1 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 25 May 2020 20:43:59 +0200 Subject: [PATCH 42/46] #5899 Fracture: Use robust way to find diff between two angles --- .../Completions/RimFracture.cpp | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp b/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp index ad17883ba1..05a01e7774 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp @@ -381,13 +381,29 @@ double RimFracture::endMD() const } } +//-------------------------------------------------------------------------------------------------- +/// https://stackoverflow.com/a/52432897 +//-------------------------------------------------------------------------------------------------- +double getAbsoluteDiff2Angles( const double x, const double y, const double c ) +{ + // c can be PI (for radians) or 180.0 (for degrees); + return c - fabs( fmod( fabs( x - y ), 2 * c ) - c ); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- double RimFracture::wellFractureAzimuthDiff() const { - double wellDifference = fabs( wellAzimuthAtFracturePosition() - m_azimuth ); - return wellDifference; + // Compute the relative difference between two lines + // See https://github.com/OPM/ResInsight/issues/5899 + + double angle1 = wellAzimuthAtFracturePosition(); + double angle2 = m_azimuth; + + double smallestDiffDegrees = getAbsoluteDiff2Angles( angle1, angle2, 180.0 ); + + return smallestDiffDegrees; } //-------------------------------------------------------------------------------------------------- @@ -399,6 +415,9 @@ QString RimFracture::wellFractureAzimuthDiffText() const return QString::number( wellDifference, 'f', 2 ); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- QString RimFracture::wellAzimuthAtFracturePositionText() const { double wellAzimuth = wellAzimuthAtFracturePosition(); From 1aea1adf3485e53c5b5b26406a70f0211034f3d8 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 25 May 2020 21:02:36 +0200 Subject: [PATCH 43/46] #5899 Fracture: Make sure the angle is in 0..90 interval --- ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp b/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp index 05a01e7774..33ccaf865a 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp @@ -401,9 +401,10 @@ double RimFracture::wellFractureAzimuthDiff() const double angle1 = wellAzimuthAtFracturePosition(); double angle2 = m_azimuth; - double smallestDiffDegrees = getAbsoluteDiff2Angles( angle1, angle2, 180.0 ); + double diffDegrees = getAbsoluteDiff2Angles( angle1, angle2, 180.0 ); + double smallesDiffDegrees = std::min( 180.0 - diffDegrees, diffDegrees ); - return smallestDiffDegrees; + return smallesDiffDegrees; } //-------------------------------------------------------------------------------------------------- From 5ed010f32269e49b45b22fcbd8574b0b72ca9df2 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Tue, 26 May 2020 11:37:52 +0200 Subject: [PATCH 44/46] Wbs: Make sure last LAS-value is used if within a threshold --- .../RigGeoMechWellLogExtractor.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/ApplicationCode/ReservoirDataModel/RigGeoMechWellLogExtractor.cpp b/ApplicationCode/ReservoirDataModel/RigGeoMechWellLogExtractor.cpp index 145dd8ccc7..791a00dcab 100644 --- a/ApplicationCode/ReservoirDataModel/RigGeoMechWellLogExtractor.cpp +++ b/ApplicationCode/ReservoirDataModel/RigGeoMechWellLogExtractor.cpp @@ -103,7 +103,7 @@ void RigGeoMechWellLogExtractor::performCurveDataSmoothing( int if ( !mds->empty() && !values->empty() ) { - std::vector*> dependentValues = { tvds, &interfaceShValuesDbl, &interfacePorePressuresDbl }; + std::vector*> dependentValues = {tvds, &interfaceShValuesDbl, &interfacePorePressuresDbl}; std::vector smoothOrFilterSegments = determineFilteringOrSmoothing( interfacePorePressuresDbl ); @@ -296,7 +296,6 @@ std::vector double waterDensityGCM3 = m_userDefinedValues[RigWbsParameter::waterDensity()]; -#pragma omp parallel for for ( int64_t intersectionIdx = 0; intersectionIdx < (int64_t)m_intersections.size(); ++intersectionIdx ) { // Loop from primary source and out for each value @@ -1171,6 +1170,21 @@ double RigGeoMechWellLogExtractor::getWellLogIntersectionValue( size_t intersect } } } + + // If we found no match, check first and last value within a threshold. + if ( !wellLogValues.empty() ) + { + const double relativeEps = 1.0e-3 * std::max( 1.0, intersection_md ); + if ( std::abs( wellLogValues.front().first - intersection_md ) < relativeEps ) + { + return wellLogValues.front().second; + } + else if ( std::abs( wellLogValues.back().first - intersection_md ) < relativeEps ) + { + return wellLogValues.back().second; + } + } + return std::numeric_limits::infinity(); } From 77c0f46c1c2928345352dc3bee4e37bc87ef6da3 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 27 May 2020 08:57:47 +0200 Subject: [PATCH 45/46] Prepare version number for patch release --- ResInsightVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ResInsightVersion.cmake b/ResInsightVersion.cmake index 3fb2234f66..29bfad7152 100644 --- a/ResInsightVersion.cmake +++ b/ResInsightVersion.cmake @@ -4,7 +4,7 @@ set(RESINSIGHT_MINOR_VERSION 04) set(RESINSIGHT_PATCH_VERSION 1) # Opional text with no restrictions -set(RESINSIGHT_VERSION_TEXT "-RC02") +set(RESINSIGHT_VERSION_TEXT "-RC03") # Optional text # Must be unique and increasing within one combination of major/minor/patch version From 3613e7f0258c4cbbd47d4310600e33924e612026 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 27 May 2020 12:53:12 +0200 Subject: [PATCH 46/46] Update to release 2020.04.1 --- ResInsightVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ResInsightVersion.cmake b/ResInsightVersion.cmake index 29bfad7152..e592ffef24 100644 --- a/ResInsightVersion.cmake +++ b/ResInsightVersion.cmake @@ -4,7 +4,7 @@ set(RESINSIGHT_MINOR_VERSION 04) set(RESINSIGHT_PATCH_VERSION 1) # Opional text with no restrictions -set(RESINSIGHT_VERSION_TEXT "-RC03") +#set(RESINSIGHT_VERSION_TEXT "-RC03") # Optional text # Must be unique and increasing within one combination of major/minor/patch version