From 6761a71798bd1b126ddec563996a357fdcd7b466 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 13 Jan 2020 14:45:39 +0100 Subject: [PATCH 1/7] #5273 Allen Diagrams: Move result names to RiaNccDefines --- .../Application/CMakeLists_files.cmake | 2 + ApplicationCode/Application/RiaNncDefines.cpp | 75 +++++++++++++++++++ ApplicationCode/Application/RiaNncDefines.h | 32 ++++++++ .../FileInterface/RifReaderEclipseOutput.cpp | 8 +- .../ProjectDataModel/RimEclipseCase.cpp | 8 +- .../RigCaseCellResultsData.cpp | 12 +-- .../ReservoirDataModel/RigNNCData.cpp | 8 +- .../ReservoirDataModel/RigNNCData.h | 31 +------- ...igNumberOfFloodedPoreVolumesCalculator.cpp | 4 +- .../RigReservoirBuilderMock.cpp | 2 +- 10 files changed, 132 insertions(+), 50 deletions(-) create mode 100644 ApplicationCode/Application/RiaNncDefines.cpp create mode 100644 ApplicationCode/Application/RiaNncDefines.h diff --git a/ApplicationCode/Application/CMakeLists_files.cmake b/ApplicationCode/Application/CMakeLists_files.cmake index e248cc1d8d..4dfd8fc7ca 100644 --- a/ApplicationCode/Application/CMakeLists_files.cmake +++ b/ApplicationCode/Application/CMakeLists_files.cmake @@ -18,6 +18,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RiaFontCache.h ${CMAKE_CURRENT_LIST_DIR}/RiaEclipseFileNameTools.h ${CMAKE_CURRENT_LIST_DIR}/RiaFeatureCommandContext.h ${CMAKE_CURRENT_LIST_DIR}/RiaStringListSerializer.h +${CMAKE_CURRENT_LIST_DIR}/RiaNncDefines.h ) set (SOURCE_GROUP_SOURCE_FILES @@ -40,6 +41,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RiaFontCache.cpp ${CMAKE_CURRENT_LIST_DIR}/RiaEclipseFileNameTools.cpp ${CMAKE_CURRENT_LIST_DIR}/RiaFeatureCommandContext.cpp ${CMAKE_CURRENT_LIST_DIR}/RiaStringListSerializer.cpp +${CMAKE_CURRENT_LIST_DIR}/RiaNncDefines.cpp ) list(APPEND CODE_HEADER_FILES diff --git a/ApplicationCode/Application/RiaNncDefines.cpp b/ApplicationCode/Application/RiaNncDefines.cpp new file mode 100644 index 0000000000..4727a5f02e --- /dev/null +++ b/ApplicationCode/Application/RiaNncDefines.cpp @@ -0,0 +1,75 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2020 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RiaNncDefines.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaDefines::propertyNameFluxWat() +{ + return "FLRWAT"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaDefines::propertyNameFluxOil() +{ + return "FLROIL"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaDefines::propertyNameFluxGas() +{ + return "FLRGAS"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaDefines::propertyNameCombTrans() +{ + return "TRAN"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaDefines::propertyNameRiCombTrans() +{ + return "riTRAN"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaDefines::propertyNameRiCombTransByArea() +{ + return "riTRANbyArea"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaDefines::propertyNameRiCombMult() +{ + return "riMULT"; +} diff --git a/ApplicationCode/Application/RiaNncDefines.h b/ApplicationCode/Application/RiaNncDefines.h new file mode 100644 index 0000000000..d5437a2e05 --- /dev/null +++ b/ApplicationCode/Application/RiaNncDefines.h @@ -0,0 +1,32 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2020 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include + +namespace RiaDefines +{ +QString propertyNameFluxWat(); +QString propertyNameFluxOil(); +QString propertyNameFluxGas(); +QString propertyNameCombTrans(); +QString propertyNameRiCombTrans(); +QString propertyNameRiCombTransByArea(); +QString propertyNameRiCombMult(); +}; // namespace RiaDefines diff --git a/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp b/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp index 7e696deace..d873d79483 100644 --- a/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp +++ b/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp @@ -731,7 +731,7 @@ void RifReaderEclipseOutput::transferStaticNNCData( const ecl_grid_type* mainEcl mainGrid->nncData()->connections().resize( numNNC ); std::vector& transmissibilityValues = mainGrid->nncData()->makeStaticConnectionScalarResult( - RigNNCData::propertyNameCombTrans() ); + RiaDefines::propertyNameCombTrans() ); const double* transValues = ecl_nnc_data_get_values( tran_data ); for ( int nIdx = 0; nIdx < numNNC; ++nIdx ) @@ -767,11 +767,11 @@ void RifReaderEclipseOutput::transferDynamicNNCData( const ecl_grid_type* mainEc size_t timeStepCount = m_dynamicResultsAccess->timeStepCount(); std::vector>& waterFluxData = - mainGrid->nncData()->makeDynamicConnectionScalarResult( RigNNCData::propertyNameFluxWat(), timeStepCount ); + mainGrid->nncData()->makeDynamicConnectionScalarResult( RiaDefines::propertyNameFluxWat(), timeStepCount ); std::vector>& oilFluxData = - mainGrid->nncData()->makeDynamicConnectionScalarResult( RigNNCData::propertyNameFluxOil(), timeStepCount ); + mainGrid->nncData()->makeDynamicConnectionScalarResult( RiaDefines::propertyNameFluxOil(), timeStepCount ); std::vector>& gasFluxData = - mainGrid->nncData()->makeDynamicConnectionScalarResult( RigNNCData::propertyNameFluxGas(), timeStepCount ); + mainGrid->nncData()->makeDynamicConnectionScalarResult( RiaDefines::propertyNameFluxGas(), timeStepCount ); for ( size_t timeStep = 0; timeStep < timeStepCount; ++timeStep ) { diff --git a/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp b/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp index 4eb165db35..a9631fae5d 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp @@ -828,7 +828,7 @@ bool RimEclipseCase::openReserviorCase() RiaDefines::combinedTransmissibilityResultName() ); if ( results->hasResultEntry( combinedTransmissibilityResAddr ) ) { - eclipseCaseData()->mainGrid()->nncData()->setEclResultAddress( RigNNCData::propertyNameCombTrans(), + eclipseCaseData()->mainGrid()->nncData()->setEclResultAddress( RiaDefines::propertyNameCombTrans(), combinedTransmissibilityResAddr ); } @@ -836,7 +836,7 @@ bool RimEclipseCase::openReserviorCase() RiaDefines::combinedWaterFluxResultName() ); if ( results->hasResultEntry( combinedWaterFluxResAddr ) ) { - eclipseCaseData()->mainGrid()->nncData()->setEclResultAddress( RigNNCData::propertyNameFluxWat(), + eclipseCaseData()->mainGrid()->nncData()->setEclResultAddress( RiaDefines::propertyNameFluxWat(), combinedWaterFluxResAddr ); } @@ -844,7 +844,7 @@ bool RimEclipseCase::openReserviorCase() RiaDefines::combinedOilFluxResultName() ); if ( results->hasResultEntry( combinedOilFluxResAddr ) ) { - eclipseCaseData()->mainGrid()->nncData()->setEclResultAddress( RigNNCData::propertyNameFluxOil(), + eclipseCaseData()->mainGrid()->nncData()->setEclResultAddress( RiaDefines::propertyNameFluxOil(), combinedOilFluxResAddr ); } RigEclipseResultAddress combinedGasFluxResAddr( RiaDefines::DYNAMIC_NATIVE, @@ -852,7 +852,7 @@ bool RimEclipseCase::openReserviorCase() if ( results->hasResultEntry( combinedGasFluxResAddr ) ) { - eclipseCaseData()->mainGrid()->nncData()->setEclResultAddress( RigNNCData::propertyNameFluxGas(), + eclipseCaseData()->mainGrid()->nncData()->setEclResultAddress( RiaDefines::propertyNameFluxGas(), combinedGasFluxResAddr ); } } diff --git a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp index 10c50f8ae9..1b6aceb982 100644 --- a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp +++ b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp @@ -2196,8 +2196,8 @@ void RigCaseCellResultsData::computeNncCombRiTrans() std::vector& permYResults = m_cellScalarResults[permYResultIdx][0]; std::vector& permZResults = m_cellScalarResults[permZResultIdx][0]; std::vector& riCombTransResults = m_ownerMainGrid->nncData()->makeStaticConnectionScalarResult( - RigNNCData::propertyNameRiCombTrans() ); - m_ownerMainGrid->nncData()->setEclResultAddress( RigNNCData::propertyNameRiCombTrans(), riCombTransEclResAddr ); + RiaDefines::propertyNameRiCombTrans() ); + m_ownerMainGrid->nncData()->setEclResultAddress( RiaDefines::propertyNameRiCombTrans(), riCombTransEclResAddr ); std::vector* ntgResults = nullptr; if ( hasNTGResults ) @@ -2444,7 +2444,7 @@ void RigCaseCellResultsData::computeNncCombRiMULT() if ( m_ownerMainGrid->nncData()->staticConnectionScalarResult( riCombMultEclResAddr ) ) return; std::vector& riMultResults = m_ownerMainGrid->nncData()->makeStaticConnectionScalarResult( - RigNNCData::propertyNameRiCombMult() ); + RiaDefines::propertyNameRiCombMult() ); const std::vector* riTransResults = m_ownerMainGrid->nncData()->staticConnectionScalarResult( riCombTransEclResAddr ); @@ -2452,7 +2452,7 @@ void RigCaseCellResultsData::computeNncCombRiMULT() const std::vector* transResults = m_ownerMainGrid->nncData()->staticConnectionScalarResult( combTransEclResAddr ); - m_ownerMainGrid->nncData()->setEclResultAddress( RigNNCData::propertyNameRiCombMult(), riCombMultEclResAddr ); + m_ownerMainGrid->nncData()->setEclResultAddress( RiaDefines::propertyNameRiCombMult(), riCombMultEclResAddr ); for ( size_t nncConIdx = 0; nncConIdx < riMultResults.size(); ++nncConIdx ) { @@ -2585,9 +2585,9 @@ void RigCaseCellResultsData::computeNncCombRiTRANSbyArea() if ( m_ownerMainGrid->nncData()->staticConnectionScalarResult( riCombTransByAreaEclResAddr ) ) return; std::vector& riAreaNormTransResults = m_ownerMainGrid->nncData()->makeStaticConnectionScalarResult( - RigNNCData::propertyNameRiCombTransByArea() ); + RiaDefines::propertyNameRiCombTransByArea() ); - m_ownerMainGrid->nncData()->setEclResultAddress( RigNNCData::propertyNameRiCombTransByArea(), + m_ownerMainGrid->nncData()->setEclResultAddress( RiaDefines::propertyNameRiCombTransByArea(), riCombTransByAreaEclResAddr ); const std::vector* transResults = m_ownerMainGrid->nncData()->staticConnectionScalarResult( diff --git a/ApplicationCode/ReservoirDataModel/RigNNCData.cpp b/ApplicationCode/ReservoirDataModel/RigNNCData.cpp index c8f792aaff..686e39141c 100644 --- a/ApplicationCode/ReservoirDataModel/RigNNCData.cpp +++ b/ApplicationCode/ReservoirDataModel/RigNNCData.cpp @@ -529,10 +529,10 @@ const QString RigNNCData::getNNCDataTypeFromScalarResultIndex( const RigEclipseR //-------------------------------------------------------------------------------------------------- bool RigNNCData::isNative( QString nncDataType ) const { - if ( nncDataType == RigNNCData::propertyNameCombTrans() || nncDataType == RigNNCData::propertyNameFluxGas() || - nncDataType == RigNNCData::propertyNameFluxOil() || nncDataType == RigNNCData::propertyNameFluxWat() || - nncDataType == RigNNCData::propertyNameRiCombMult() || nncDataType == RigNNCData::propertyNameRiCombTrans() || - nncDataType == RigNNCData::propertyNameRiCombTransByArea() ) + if ( nncDataType == RiaDefines::propertyNameCombTrans() || nncDataType == RiaDefines::propertyNameFluxGas() || + nncDataType == RiaDefines::propertyNameFluxOil() || nncDataType == RiaDefines::propertyNameFluxWat() || + nncDataType == RiaDefines::propertyNameRiCombMult() || nncDataType == RiaDefines::propertyNameRiCombTrans() || + nncDataType == RiaDefines::propertyNameRiCombTransByArea() ) { return true; } diff --git a/ApplicationCode/ReservoirDataModel/RigNNCData.h b/ApplicationCode/ReservoirDataModel/RigNNCData.h index f9370b0aea..b643124cd1 100644 --- a/ApplicationCode/ReservoirDataModel/RigNNCData.h +++ b/ApplicationCode/ReservoirDataModel/RigNNCData.h @@ -19,6 +19,8 @@ #pragma once +#include "RiaNncDefines.h" + #include "cvfObject.h" #include "cvfStructGrid.h" #include "cvfVector3.h" @@ -63,35 +65,6 @@ public: NNC_GENERATED }; - static QString propertyNameFluxWat() - { - return "FLRWAT"; - } - static QString propertyNameFluxOil() - { - return "FLROIL"; - } - static QString propertyNameFluxGas() - { - return "FLRGAS"; - } - static QString propertyNameCombTrans() - { - return "TRAN"; - } - static QString propertyNameRiCombTrans() - { - return "riTRAN"; - } - static QString propertyNameRiCombTransByArea() - { - return "riTRANbyArea"; - } - static QString propertyNameRiCombMult() - { - return "riMULT"; - } - RigNNCData(); void processConnections( const RigMainGrid& mainGrid ); diff --git a/ApplicationCode/ReservoirDataModel/RigNumberOfFloodedPoreVolumesCalculator.cpp b/ApplicationCode/ReservoirDataModel/RigNumberOfFloodedPoreVolumesCalculator.cpp index 25e9b75cce..786e3c62d1 100644 --- a/ApplicationCode/ReservoirDataModel/RigNumberOfFloodedPoreVolumesCalculator.cpp +++ b/ApplicationCode/ReservoirDataModel/RigNumberOfFloodedPoreVolumesCalculator.cpp @@ -103,9 +103,9 @@ RigNumberOfFloodedPoreVolumesCalculator::RigNumberOfFloodedPoreVolumesCalculator progress.incrementProgress(); - // TODO: oil or gas flowrate + // TODO: oil or gas flow rate std::vector*> flowrateNNCatAllTimeSteps; - QString nncConnectionProperty = mainGrid->nncData()->propertyNameFluxWat(); + QString nncConnectionProperty = RiaDefines::propertyNameFluxWat(); progress.incrementProgress(); diff --git a/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.cpp b/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.cpp index b58d5659a6..306b60e708 100644 --- a/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.cpp +++ b/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.cpp @@ -562,7 +562,7 @@ void RigReservoirBuilderMock::addFaults( RigEclipseCaseData* eclipseCase ) } std::vector& tranVals = grid->nncData()->makeStaticConnectionScalarResult( - RigNNCData::propertyNameCombTrans() ); + RiaDefines::propertyNameCombTrans() ); for ( size_t cIdx = 0; cIdx < tranVals.size(); ++cIdx ) { tranVals[cIdx] = 0.2; From 0abd8396695b5c386d8e59c0bbad02d36b3ddfac Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 13 Jan 2020 15:06:16 +0100 Subject: [PATCH 2/7] #5273 Allen Diagrams: Use const access to Nnc connections --- .../FileInterface/RifReaderEclipseOutput.cpp | 25 ++++++++++++------- .../RimFaultInViewCollection.cpp | 4 +-- .../RigCaseCellResultsData.cpp | 2 +- .../ReservoirDataModel/RigNNCData.cpp | 16 ++++++++++++ .../ReservoirDataModel/RigNNCData.h | 11 +++----- .../RigReservoirBuilderMock.cpp | 4 ++- 6 files changed, 41 insertions(+), 21 deletions(-) diff --git a/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp b/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp index d873d79483..0a11e13f55 100644 --- a/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp +++ b/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp @@ -728,24 +728,31 @@ void RifReaderEclipseOutput::transferStaticNNCData( const ecl_grid_type* mainEcl if ( numNNC > 0 ) { // Transform to our own data structures + std::vector nncConnections; + std::vector transmissibilityValuesTemp; - mainGrid->nncData()->connections().resize( numNNC ); - std::vector& transmissibilityValues = mainGrid->nncData()->makeStaticConnectionScalarResult( - RiaDefines::propertyNameCombTrans() ); const double* transValues = ecl_nnc_data_get_values( tran_data ); for ( int nIdx = 0; nIdx < numNNC; ++nIdx ) { const ecl_nnc_pair_type* geometry_pair = ecl_nnc_geometry_iget( nnc_geo, nIdx ); RigGridBase* grid1 = mainGrid->gridByIndex( geometry_pair->grid_nr1 ); - mainGrid->nncData()->connections()[nIdx].m_c1GlobIdx = grid1->reservoirCellIndex( - geometry_pair->global_index1 ); - RigGridBase* grid2 = mainGrid->gridByIndex( geometry_pair->grid_nr2 ); - mainGrid->nncData()->connections()[nIdx].m_c2GlobIdx = grid2->reservoirCellIndex( - geometry_pair->global_index2 ); + RigGridBase* grid2 = mainGrid->gridByIndex( geometry_pair->grid_nr2 ); - transmissibilityValues[nIdx] = transValues[nIdx]; + RigConnection nncConnection; + nncConnection.m_c1GlobIdx = grid1->reservoirCellIndex( geometry_pair->global_index1 ); + nncConnection.m_c2GlobIdx = grid2->reservoirCellIndex( geometry_pair->global_index2 ); + + nncConnections.push_back( nncConnection ); + + transmissibilityValuesTemp.push_back( transValues[nIdx] ); } + + mainGrid->nncData()->setConnections( nncConnections ); + + std::vector& transmissibilityValues = mainGrid->nncData()->makeStaticConnectionScalarResult( + RiaDefines::propertyNameCombTrans() ); + transmissibilityValues = transmissibilityValuesTemp; } ecl_nnc_data_free( tran_data ); diff --git a/ApplicationCode/ProjectDataModel/RimFaultInViewCollection.cpp b/ApplicationCode/ProjectDataModel/RimFaultInViewCollection.cpp index c6178e7c19..ee8d220188 100644 --- a/ApplicationCode/ProjectDataModel/RimFaultInViewCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimFaultInViewCollection.cpp @@ -272,8 +272,8 @@ void RimFaultInViewCollection::syncronizeFaults() // NNCs this->noCommonAreaNnncCollection()->noCommonAreaNncs().deleteAllChildObjects(); - RigMainGrid* mainGrid = parentView()->mainGrid(); - std::vector& nncConnections = mainGrid->nncData()->connections(); + RigMainGrid* mainGrid = parentView()->mainGrid(); + const std::vector& 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 1b6aceb982..d3d180fc68 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 - std::vector& nncConnections = m_ownerMainGrid->nncData()->connections(); + const std::vector& nncConnections = m_ownerMainGrid->nncData()->connections(); for ( size_t connIdx = 0; connIdx < nncConnections.size(); connIdx++ ) { size_t nativeResvCellIndex = nncConnections[connIdx].m_c1GlobIdx; diff --git a/ApplicationCode/ReservoirDataModel/RigNNCData.cpp b/ApplicationCode/ReservoirDataModel/RigNNCData.cpp index 686e39141c..3294caa092 100644 --- a/ApplicationCode/ReservoirDataModel/RigNNCData.cpp +++ b/ApplicationCode/ReservoirDataModel/RigNNCData.cpp @@ -179,6 +179,22 @@ cvf::StructGridInterface::FaceType RigNNCData::calculateCellFaceOverlap( const R return cvf::StructGridInterface::NO_FACE; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigNNCData::setConnections( std::vector& connections ) +{ + m_connections = connections; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const std::vector& RigNNCData::connections() const +{ + return m_connections; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ReservoirDataModel/RigNNCData.h b/ApplicationCode/ReservoirDataModel/RigNNCData.h index b643124cd1..13059ea2e8 100644 --- a/ApplicationCode/ReservoirDataModel/RigNNCData.h +++ b/ApplicationCode/ReservoirDataModel/RigNNCData.h @@ -75,14 +75,9 @@ public: std::vector* connectionPolygon, std::vector* connectionIntersections ); - std::vector& connections() - { - return m_connections; - } - const std::vector& connections() const - { - return m_connections; - } + void setConnections( std::vector& connections ); + + const std::vector& connections() const; std::vector& makeStaticConnectionScalarResult( QString nncDataType ); const std::vector* staticConnectionScalarResult( const RigEclipseResultAddress& resVarAddr ) const; diff --git a/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.cpp b/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.cpp index 306b60e708..2c455910bb 100644 --- a/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.cpp +++ b/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.cpp @@ -536,7 +536,7 @@ void RigReservoirBuilderMock::addFaults( RigEclipseCaseData* eclipseCase ) grid->setFaults( faults ); // NNCs - std::vector& nncConnections = grid->nncData()->connections(); + std::vector nncConnections; { size_t i1 = 2; size_t j1 = 2; @@ -561,6 +561,8 @@ void RigReservoirBuilderMock::addFaults( RigEclipseCaseData* eclipseCase ) addNnc( grid, i1, j1, k1, i2, j2, k2, nncConnections ); } + grid->nncData()->setConnections( nncConnections ); + std::vector& tranVals = grid->nncData()->makeStaticConnectionScalarResult( RiaDefines::propertyNameCombTrans() ); for ( size_t cIdx = 0; cIdx < tranVals.size(); ++cIdx ) From 360893817e3989675bdd85c389666d5f9fc6761a Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 14 Jan 2020 09:34:27 +0100 Subject: [PATCH 3/7] #5273 Allen Diagrams: Add RigCellFaceGeometryTools --- .../ReservoirDataModel/CMakeLists_files.cmake | 2 + .../RigCellFaceGeometryTools.cpp | 112 +++++++++++++++++ .../RigCellFaceGeometryTools.h | 41 ++++++ .../ReservoirDataModel/RigNNCData.cpp | 117 ++---------------- .../ReservoirDataModel/RigNNCData.h | 6 - .../RigSimulationWellCenterLineCalculator.cpp | 12 +- .../RigSimulationWellCenterLineCalculator.h | 1 + 7 files changed, 171 insertions(+), 120 deletions(-) create mode 100644 ApplicationCode/ReservoirDataModel/RigCellFaceGeometryTools.cpp create mode 100644 ApplicationCode/ReservoirDataModel/RigCellFaceGeometryTools.h diff --git a/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake b/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake index 03fc9e1c83..001434a952 100644 --- a/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake +++ b/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake @@ -75,6 +75,7 @@ ${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}/RigCellFaceGeometryTools.h ) @@ -147,6 +148,7 @@ ${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}/RigCellFaceGeometryTools.cpp ) list(APPEND CODE_HEADER_FILES diff --git a/ApplicationCode/ReservoirDataModel/RigCellFaceGeometryTools.cpp b/ApplicationCode/ReservoirDataModel/RigCellFaceGeometryTools.cpp new file mode 100644 index 0000000000..72fd60b40b --- /dev/null +++ b/ApplicationCode/ReservoirDataModel/RigCellFaceGeometryTools.cpp @@ -0,0 +1,112 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2020 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RigCellFaceGeometryTools.h" + +#include "RigCell.h" +#include "RigMainGrid.h" + +#include "cvfGeometryTools.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::StructGridInterface::FaceType + RigCellFaceGeometryTools::calculateCellFaceOverlap( const RigCell& c1, + const RigCell& c2, + const RigMainGrid& mainGrid, + std::vector* connectionPolygon, + std::vector* connectionIntersections ) +{ + // Try to find the shared face + + bool isPossibleNeighborInDirection[6] = {true, true, true, true, true, true}; + + if ( c1.hostGrid() == c2.hostGrid() ) + { + char hasNeighbourInAnyDirection = 0; + + size_t i1, j1, k1; + c1.hostGrid()->ijkFromCellIndex( c1.gridLocalCellIndex(), &i1, &j1, &k1 ); + size_t i2, j2, k2; + c2.hostGrid()->ijkFromCellIndex( c2.gridLocalCellIndex(), &i2, &j2, &k2 ); + + isPossibleNeighborInDirection[cvf::StructGridInterface::POS_I] = ( ( i1 + 1 ) == i2 ); + isPossibleNeighborInDirection[cvf::StructGridInterface::NEG_I] = ( ( i2 + 1 ) == i1 ); + isPossibleNeighborInDirection[cvf::StructGridInterface::POS_J] = ( ( j1 + 1 ) == j2 ); + isPossibleNeighborInDirection[cvf::StructGridInterface::NEG_J] = ( ( j2 + 1 ) == j1 ); + isPossibleNeighborInDirection[cvf::StructGridInterface::POS_K] = ( ( k1 + 1 ) == k2 ); + isPossibleNeighborInDirection[cvf::StructGridInterface::NEG_K] = ( ( k2 + 1 ) == k1 ); + + hasNeighbourInAnyDirection = isPossibleNeighborInDirection[cvf::StructGridInterface::POS_I] + + isPossibleNeighborInDirection[cvf::StructGridInterface::NEG_I] + + isPossibleNeighborInDirection[cvf::StructGridInterface::POS_J] + + isPossibleNeighborInDirection[cvf::StructGridInterface::NEG_J] + + isPossibleNeighborInDirection[cvf::StructGridInterface::POS_K] + + isPossibleNeighborInDirection[cvf::StructGridInterface::NEG_K]; + + // If cell 2 is not adjancent with respect to any of the six ijk directions, + // assume that we have no overlapping area. + + if ( !hasNeighbourInAnyDirection ) + { + // Add to search map + // m_cellIdxToFaceToConnectionIdxMap[m_connections[cnIdx].m_c1GlobIdx][cvf::StructGridInterface::NO_FACE].push_back(cnIdx); + // m_cellIdxToFaceToConnectionIdxMap[m_connections[cnIdx].m_c2GlobIdx][cvf::StructGridInterface::NO_FACE].push_back(cnIdx); + + // cvf::Trace::show("NNC: No direct neighbors : C1: " + cvf::String((int)m_connections[cnIdx].m_c1GlobIdx) + + // " C2: " + cvf::String((int)m_connections[cnIdx].m_c2GlobIdx)); + return cvf::StructGridInterface::NO_FACE; + } + } + + for ( unsigned char fIdx = 0; fIdx < 6; ++fIdx ) + { + if ( !isPossibleNeighborInDirection[fIdx] ) + { + continue; + } + + // Calculate connection polygon + + std::vector polygon; + std::vector intersections; + std::array face1; + std::array face2; + c1.faceIndices( ( cvf::StructGridInterface::FaceType )( fIdx ), &face1 ); + c2.faceIndices( cvf::StructGridInterface::oppositeFace( ( cvf::StructGridInterface::FaceType )( fIdx ) ), &face2 ); + + bool foundOverlap = + cvf::GeometryTools::calculateOverlapPolygonOfTwoQuads( &polygon, + &intersections, + (cvf::EdgeIntersectStorage*)nullptr, + cvf::wrapArrayConst( &mainGrid.nodes() ), + face1.data(), + face2.data(), + 1e-6 ); + + if ( foundOverlap ) + { + if ( connectionPolygon ) ( *connectionPolygon ) = polygon; + if ( connectionIntersections ) ( *connectionIntersections ) = intersections; + return ( cvf::StructGridInterface::FaceType )( fIdx ); + } + } + + return cvf::StructGridInterface::NO_FACE; +} diff --git a/ApplicationCode/ReservoirDataModel/RigCellFaceGeometryTools.h b/ApplicationCode/ReservoirDataModel/RigCellFaceGeometryTools.h new file mode 100644 index 0000000000..0c3eac5d56 --- /dev/null +++ b/ApplicationCode/ReservoirDataModel/RigCellFaceGeometryTools.h @@ -0,0 +1,41 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2020 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cvfCollection.h" +#include "cvfStructGrid.h" +#include "cvfVector3.h" + +#include + +class RigCell; +class RigMainGrid; + +//================================================================================================== +/// +//================================================================================================== +class RigCellFaceGeometryTools +{ +public: + static cvf::StructGridInterface::FaceType calculateCellFaceOverlap( const RigCell& c1, + const RigCell& c2, + const RigMainGrid& mainGrid, + std::vector* connectionPolygon, + std::vector* connectionIntersections ); +}; diff --git a/ApplicationCode/ReservoirDataModel/RigNNCData.cpp b/ApplicationCode/ReservoirDataModel/RigNNCData.cpp index 3294caa092..0d3d8ef0bd 100644 --- a/ApplicationCode/ReservoirDataModel/RigNNCData.cpp +++ b/ApplicationCode/ReservoirDataModel/RigNNCData.cpp @@ -18,8 +18,11 @@ ///////////////////////////////////////////////////////////////////////////////// #include "RigNNCData.h" + +#include "RigCellFaceGeometryTools.h" #include "RigEclipseResultAddress.h" #include "RigMainGrid.h" + #include "cvfGeometryTools.h" //-------------------------------------------------------------------------------------------------- @@ -43,7 +46,11 @@ void RigNNCData::processConnections( const RigMainGrid& mainGrid ) std::vector connectionIntersections; cvf::StructGridInterface::FaceType connectionFace = cvf::StructGridInterface::NO_FACE; - connectionFace = calculateCellFaceOverlap( c1, c2, mainGrid, &connectionPolygon, &connectionIntersections ); + connectionFace = RigCellFaceGeometryTools::calculateCellFaceOverlap( c1, + c2, + mainGrid, + &connectionPolygon, + &connectionIntersections ); if ( connectionFace != cvf::StructGridInterface::NO_FACE ) { @@ -71,114 +78,6 @@ void RigNNCData::processConnections( const RigMainGrid& mainGrid ) } } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -cvf::StructGridInterface::FaceType RigNNCData::calculateCellFaceOverlap( const RigCell& c1, - const RigCell& c2, - const RigMainGrid& mainGrid, - std::vector* connectionPolygon, - std::vector* connectionIntersections ) -{ - // Try to find the shared face - - bool isPossibleNeighborInDirection[6] = {true, true, true, true, true, true}; - - if ( c1.hostGrid() == c2.hostGrid() ) - { - char hasNeighbourInAnyDirection = 0; - - size_t i1, j1, k1; - c1.hostGrid()->ijkFromCellIndex( c1.gridLocalCellIndex(), &i1, &j1, &k1 ); - size_t i2, j2, k2; - c2.hostGrid()->ijkFromCellIndex( c2.gridLocalCellIndex(), &i2, &j2, &k2 ); - - isPossibleNeighborInDirection[cvf::StructGridInterface::POS_I] = ( ( i1 + 1 ) == i2 ); - isPossibleNeighborInDirection[cvf::StructGridInterface::NEG_I] = ( ( i2 + 1 ) == i1 ); - isPossibleNeighborInDirection[cvf::StructGridInterface::POS_J] = ( ( j1 + 1 ) == j2 ); - isPossibleNeighborInDirection[cvf::StructGridInterface::NEG_J] = ( ( j2 + 1 ) == j1 ); - isPossibleNeighborInDirection[cvf::StructGridInterface::POS_K] = ( ( k1 + 1 ) == k2 ); - isPossibleNeighborInDirection[cvf::StructGridInterface::NEG_K] = ( ( k2 + 1 ) == k1 ); - - hasNeighbourInAnyDirection = isPossibleNeighborInDirection[cvf::StructGridInterface::POS_I] + - isPossibleNeighborInDirection[cvf::StructGridInterface::NEG_I] + - isPossibleNeighborInDirection[cvf::StructGridInterface::POS_J] + - isPossibleNeighborInDirection[cvf::StructGridInterface::NEG_J] + - isPossibleNeighborInDirection[cvf::StructGridInterface::POS_K] + - isPossibleNeighborInDirection[cvf::StructGridInterface::NEG_K]; - - // If cell 2 is not adjancent with respect to any of the six ijk directions, - // assume that we have no overlapping area. - - if ( !hasNeighbourInAnyDirection ) - { - // Add to search map - // m_cellIdxToFaceToConnectionIdxMap[m_connections[cnIdx].m_c1GlobIdx][cvf::StructGridInterface::NO_FACE].push_back(cnIdx); - // m_cellIdxToFaceToConnectionIdxMap[m_connections[cnIdx].m_c2GlobIdx][cvf::StructGridInterface::NO_FACE].push_back(cnIdx); - - // cvf::Trace::show("NNC: No direct neighbors : C1: " + cvf::String((int)m_connections[cnIdx].m_c1GlobIdx) + - // " C2: " + cvf::String((int)m_connections[cnIdx].m_c2GlobIdx)); - return cvf::StructGridInterface::NO_FACE; - } - } - -#if 0 - // Possibly do some testing to avoid unneccesary overlap calculations - cvf::Vec3d normal; - for ( char fIdx = 0; fIdx < 6; ++fIdx ) - { - if ( isPossibleNeighborInDirection[fIdx] ) - { - cvf::Vec3d fc1 = c1.faceCenter((cvf::StructGridInterface::FaceType)(fIdx)); - cvf::Vec3d fc2 = c2.faceCenter(cvf::StructGridInterface::oppositeFace((cvf::StructGridInterface::FaceType)(fIdx))); - cvf::Vec3d fc1ToFc2 = fc2 - fc1; - normal = c1.faceNormalWithAreaLenght((cvf::StructGridInterface::FaceType)(fIdx)); - normal.normalize(); - // Check that face centers are approx in the face plane - if ( normal.dot(fc1ToFc2) < 0.01*fc1ToFc2.length() ) - { - - } - } - } -#endif - - for ( unsigned char fIdx = 0; fIdx < 6; ++fIdx ) - { - if ( !isPossibleNeighborInDirection[fIdx] ) - { - continue; - } - - // Calculate connection polygon - - std::vector polygon; - std::vector intersections; - std::array face1; - std::array face2; - c1.faceIndices( ( cvf::StructGridInterface::FaceType )( fIdx ), &face1 ); - c2.faceIndices( cvf::StructGridInterface::oppositeFace( ( cvf::StructGridInterface::FaceType )( fIdx ) ), &face2 ); - - bool foundOverlap = - cvf::GeometryTools::calculateOverlapPolygonOfTwoQuads( &polygon, - &intersections, - (cvf::EdgeIntersectStorage*)nullptr, - cvf::wrapArrayConst( &mainGrid.nodes() ), - face1.data(), - face2.data(), - 1e-6 ); - - if ( foundOverlap ) - { - if ( connectionPolygon ) ( *connectionPolygon ) = polygon; - if ( connectionIntersections ) ( *connectionIntersections ) = intersections; - return ( cvf::StructGridInterface::FaceType )( fIdx ); - } - } - - return cvf::StructGridInterface::NO_FACE; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ReservoirDataModel/RigNNCData.h b/ApplicationCode/ReservoirDataModel/RigNNCData.h index 13059ea2e8..93132e8237 100644 --- a/ApplicationCode/ReservoirDataModel/RigNNCData.h +++ b/ApplicationCode/ReservoirDataModel/RigNNCData.h @@ -69,12 +69,6 @@ public: void processConnections( const RigMainGrid& mainGrid ); - static cvf::StructGridInterface::FaceType calculateCellFaceOverlap( const RigCell& c1, - const RigCell& c2, - const RigMainGrid& mainGrid, - std::vector* connectionPolygon, - std::vector* connectionIntersections ); - void setConnections( std::vector& connections ); const std::vector& connections() const; diff --git a/ApplicationCode/ReservoirDataModel/RigSimulationWellCenterLineCalculator.cpp b/ApplicationCode/ReservoirDataModel/RigSimulationWellCenterLineCalculator.cpp index 26249621b1..94b4c275d5 100644 --- a/ApplicationCode/ReservoirDataModel/RigSimulationWellCenterLineCalculator.cpp +++ b/ApplicationCode/ReservoirDataModel/RigSimulationWellCenterLineCalculator.cpp @@ -20,6 +20,7 @@ #include "RigSimulationWellCenterLineCalculator.h" #include "RigCell.h" +#include "RigCellFaceGeometryTools.h" #include "RigEclipseCaseData.h" #include "RigMainGrid.h" @@ -800,11 +801,12 @@ private: std::vector poygonIndices; std::vector intersections; - auto contactFace = RigNNCData::calculateCellFaceOverlap( c1, - c2, - *( m_eclipseCaseData->mainGrid() ), - &poygonIndices, - &intersections ); + auto contactFace = + RigCellFaceGeometryTools::calculateCellFaceOverlap( c1, + c2, + *( m_eclipseCaseData->mainGrid() ), + &poygonIndices, + &intersections ); if ( contactFace != cvf::StructGridInterface::NO_FACE ) { diff --git a/ApplicationCode/ReservoirDataModel/RigSimulationWellCenterLineCalculator.h b/ApplicationCode/ReservoirDataModel/RigSimulationWellCenterLineCalculator.h index bd1d757b35..b99d8ba2e2 100644 --- a/ApplicationCode/ReservoirDataModel/RigSimulationWellCenterLineCalculator.h +++ b/ApplicationCode/ReservoirDataModel/RigSimulationWellCenterLineCalculator.h @@ -16,6 +16,7 @@ // for more details. // ///////////////////////////////////////////////////////////////////////////////// + #pragma once #include "RigSimWellData.h" From fa791d0568fe1e8b8efbca5d1f087824d2fe55a0 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 15 Jan 2020 08:45:40 +0100 Subject: [PATCH 4/7] #5273 Allen Diagrams: Compute complete set of NNCs Add class RigNncConnection Implement algorithm to compute the complete set of Nncs --- .../RivNNCGeometryGenerator.cpp | 13 +- .../ReservoirDataModel/CMakeLists_files.cmake | 2 + .../RigCellFaceGeometryTools.cpp | 229 ++++++++++++++++++ .../RigCellFaceGeometryTools.h | 8 + .../ReservoirDataModel/RigMainGrid.cpp | 2 + .../ReservoirDataModel/RigNNCData.cpp | 24 +- .../ReservoirDataModel/RigNNCData.h | 26 +- .../ReservoirDataModel/RigNncConnection.cpp | 39 +++ .../ReservoirDataModel/RigNncConnection.h | 41 ++++ 9 files changed, 352 insertions(+), 32 deletions(-) create mode 100644 ApplicationCode/ReservoirDataModel/RigNncConnection.cpp create mode 100644 ApplicationCode/ReservoirDataModel/RigNncConnection.h diff --git a/ApplicationCode/ModelVisualization/RivNNCGeometryGenerator.cpp b/ApplicationCode/ModelVisualization/RivNNCGeometryGenerator.cpp index 2423dada44..bb6557a1b2 100644 --- a/ApplicationCode/ModelVisualization/RivNNCGeometryGenerator.cpp +++ b/ApplicationCode/ModelVisualization/RivNNCGeometryGenerator.cpp @@ -177,8 +177,17 @@ void RivNNCGeometryGenerator::textureCoordinates( cvf::Vec2fArray* #pragma omp parallel for for ( int tIdx = 0; tIdx < static_cast( m_triangleIndexToNNCIndex->size() ); tIdx++ ) { - double cellScalarValue = ( *nncResultVals )[( *m_triangleIndexToNNCIndex )[tIdx]]; - cvf::Vec2f texCoord = mapper->mapToTextureCoord( cellScalarValue ); + double cellScalarValue = HUGE_VAL; + size_t resultIndex = ( *m_triangleIndexToNNCIndex )[tIdx]; + + // The nnc connections can have more connections than reported from Eclipse, clamp the result index to Eclipse Results + + if ( resultIndex < nncResultVals->size() ) + { + cellScalarValue = ( *nncResultVals )[resultIndex]; + } + + cvf::Vec2f texCoord = mapper->mapToTextureCoord( cellScalarValue ); if ( cellScalarValue == HUGE_VAL || cellScalarValue != cellScalarValue ) // a != a is true for NAN's { texCoord[1] = 1.0f; diff --git a/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake b/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake index 001434a952..dc1df6eb5f 100644 --- a/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake +++ b/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake @@ -76,6 +76,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RigEquil.h ${CMAKE_CURRENT_LIST_DIR}/RigWbsParameter.h ${CMAKE_CURRENT_LIST_DIR}/RigEclipseAllenFaultsStatCalc.h ${CMAKE_CURRENT_LIST_DIR}/RigCellFaceGeometryTools.h +${CMAKE_CURRENT_LIST_DIR}/RigNncConnection.h ) @@ -149,6 +150,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RigEquil.cpp ${CMAKE_CURRENT_LIST_DIR}/RigWbsParameter.cpp ${CMAKE_CURRENT_LIST_DIR}/RigEclipseAllenFaultsStatCalc.cpp ${CMAKE_CURRENT_LIST_DIR}/RigCellFaceGeometryTools.cpp +${CMAKE_CURRENT_LIST_DIR}/RigNncConnection.cpp ) list(APPEND CODE_HEADER_FILES diff --git a/ApplicationCode/ReservoirDataModel/RigCellFaceGeometryTools.cpp b/ApplicationCode/ReservoirDataModel/RigCellFaceGeometryTools.cpp index 72fd60b40b..3a39b7ce00 100644 --- a/ApplicationCode/ReservoirDataModel/RigCellFaceGeometryTools.cpp +++ b/ApplicationCode/ReservoirDataModel/RigCellFaceGeometryTools.cpp @@ -20,9 +20,14 @@ #include "RigCell.h" #include "RigMainGrid.h" +#include "RigNncConnection.h" #include "cvfGeometryTools.h" +#include "cafAssert.h" + +#include + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -110,3 +115,227 @@ cvf::StructGridInterface::FaceType return cvf::StructGridInterface::NO_FACE; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RigCellFaceGeometryTools::computeOtherNncs( const RigMainGrid* mainGrid, + const std::vector& nativeConnections ) +{ + // 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; + + class CellPair + { + 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 ) ); + } + + if ( nativeConnections.size() != nativeCellPairs.size() ) + { + QString message = QString( "Nnc connection imported from Eclipse are not unique\nNNC count : %1\nUnique : %2" ) + .arg( nativeConnections.size() ) + .arg( nativeCellPairs.size() ); + qDebug() << message; + } + + std::set otherCellPairs; + + const cvf::Collection& faults = mainGrid->faults(); + for ( size_t faultIdx = 0; faultIdx < faults.size(); faultIdx++ ) + { + const RigFault* fault = faults.at( faultIdx ); + + const std::vector& faultFaces = fault->faultFaces(); + for ( const auto& f : faultFaces ) + { + size_t sourceReservoirCellIndex = f.m_nativeReservoirCellIndex; + cvf::StructGridInterface::FaceType sourceCellFace = f.m_nativeFace; + + 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 ( 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 ); + + if ( sourceCellFace == cvf::StructGridInterface::POS_I || + sourceCellFace == cvf::StructGridInterface::NEG_I ) + { + if ( ni != ci ) + { + continue; + } + } + else if ( sourceCellFace == cvf::StructGridInterface::POS_J || + sourceCellFace == cvf::StructGridInterface::NEG_J ) + { + if ( nj != cj ) + { + continue; + } + } + else if ( sourceCellFace == cvf::StructGridInterface::POS_K || + sourceCellFace == cvf::StructGridInterface::NEG_K ) + { + if ( nk != ck ) + { + continue; + } + } + } + + CellPair candidate( sourceReservoirCellIndex, candidateCellIndex ); + + if ( nativeCellPairs.count( candidate ) > 0 ) + { + continue; + } + + if ( otherCellPairs.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 ) + { + otherCellPairs.emplace( candidate ); + + RigConnection conn; + conn.m_c1GlobIdx = sourceReservoirCellIndex; + conn.m_c1Face = sourceCellFace; + conn.m_c2GlobIdx = candidateCellIndex; + + conn.m_polygon = RigCellFaceGeometryTools::extractPolygon( mainGridNodes, polygon, intersections ); + + otherConnections.emplace_back( conn ); + } + } + } + } + + return otherConnections; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RigCellFaceGeometryTools::extractPolygon( const std::vector& nativeNodes, + const std::vector& connectionPolygon, + const std::vector& connectionIntersections ) +{ + std::vector allPolygonNodes; + + for ( size_t polygonIndex : connectionPolygon ) + { + if ( polygonIndex < nativeNodes.size() ) + allPolygonNodes.push_back( nativeNodes[polygonIndex] ); + else + allPolygonNodes.push_back( connectionIntersections[polygonIndex - nativeNodes.size()] ); + } + + return allPolygonNodes; +} diff --git a/ApplicationCode/ReservoirDataModel/RigCellFaceGeometryTools.h b/ApplicationCode/ReservoirDataModel/RigCellFaceGeometryTools.h index 0c3eac5d56..5d3343d8ab 100644 --- a/ApplicationCode/ReservoirDataModel/RigCellFaceGeometryTools.h +++ b/ApplicationCode/ReservoirDataModel/RigCellFaceGeometryTools.h @@ -26,6 +26,7 @@ class RigCell; class RigMainGrid; +class RigConnection; //================================================================================================== /// @@ -38,4 +39,11 @@ public: const RigMainGrid& mainGrid, std::vector* connectionPolygon, std::vector* connectionIntersections ); + + static std::vector computeOtherNncs( const RigMainGrid* mainGrid, + const std::vector& nativeConnections ); + + 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 c879e3998d..5eef0a73c7 100644 --- a/ApplicationCode/ReservoirDataModel/RigMainGrid.cpp +++ b/ApplicationCode/ReservoirDataModel/RigMainGrid.cpp @@ -556,6 +556,8 @@ void RigMainGrid::calculateFaults( const RigActiveCellInfo* activeCellInfo ) } } + this->nncData()->computeNncsFromFaults( this ); + distributeNNCsToFaults(); } diff --git a/ApplicationCode/ReservoirDataModel/RigNNCData.cpp b/ApplicationCode/ReservoirDataModel/RigNNCData.cpp index 0d3d8ef0bd..2da3216935 100644 --- a/ApplicationCode/ReservoirDataModel/RigNNCData.cpp +++ b/ApplicationCode/ReservoirDataModel/RigNNCData.cpp @@ -57,14 +57,10 @@ void RigNNCData::processConnections( const RigMainGrid& mainGrid ) // Found an overlap polygon. Store data about connection m_connections[cnIdx].m_c1Face = connectionFace; - for ( size_t pIdx = 0; pIdx < connectionPolygon.size(); ++pIdx ) - { - if ( connectionPolygon[pIdx] < mainGrid.nodes().size() ) - m_connections[cnIdx].m_polygon.push_back( mainGrid.nodes()[connectionPolygon[pIdx]] ); - else - m_connections[cnIdx].m_polygon.push_back( - connectionIntersections[connectionPolygon[pIdx] - mainGrid.nodes().size()] ); - } + + m_connections[cnIdx].m_polygon = RigCellFaceGeometryTools::extractPolygon( mainGrid.nodes(), + connectionPolygon, + connectionIntersections ); // Add to search map, possibly not needed // m_cellIdxToFaceToConnectionIdxMap[m_connections[cnIdx].m_c1GlobIdx][connectionFace].push_back(cnIdx); @@ -78,6 +74,18 @@ void RigNNCData::processConnections( const RigMainGrid& mainGrid ) } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigNNCData::computeNncsFromFaults( const RigMainGrid* mainGrid ) +{ + m_nativeConnectionCount = m_connections.size(); + + std::vector otherConnections = RigCellFaceGeometryTools::computeOtherNncs( mainGrid, m_connections ); + + m_connections.insert( m_connections.end(), otherConnections.begin(), otherConnections.end() ); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ReservoirDataModel/RigNNCData.h b/ApplicationCode/ReservoirDataModel/RigNNCData.h index 93132e8237..8a73d69a63 100644 --- a/ApplicationCode/ReservoirDataModel/RigNNCData.h +++ b/ApplicationCode/ReservoirDataModel/RigNNCData.h @@ -21,6 +21,8 @@ #include "RiaNncDefines.h" +#include "RigNncConnection.h" + #include "cvfObject.h" #include "cvfStructGrid.h" #include "cvfVector3.h" @@ -33,28 +35,6 @@ class RigMainGrid; class RigCell; class RigEclipseResultAddress; -class RigConnection -{ -public: - RigConnection() - : m_c1GlobIdx( cvf::UNDEFINED_SIZE_T ) - , m_c1Face( cvf::StructGridInterface::NO_FACE ) - , m_c2GlobIdx( cvf::UNDEFINED_SIZE_T ) - { - } - - bool hasCommonArea() const - { - return m_polygon.size() > 0; - } - - size_t m_c1GlobIdx; - cvf::StructGridInterface::FaceType m_c1Face; - size_t m_c2GlobIdx; - - std::vector m_polygon; -}; - class RigNNCData : public cvf::Object { public: @@ -68,6 +48,7 @@ public: RigNNCData(); void processConnections( const RigMainGrid& mainGrid ); + void computeNncsFromFaults( const RigMainGrid* mainGrid ); void setConnections( std::vector& connections ); @@ -108,6 +89,7 @@ private: private: std::vector 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 new file mode 100644 index 0000000000..7f9069b471 --- /dev/null +++ b/ApplicationCode/ReservoirDataModel/RigNncConnection.cpp @@ -0,0 +1,39 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2020 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RigNncConnection.h" + +#include "cvfMath.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigConnection::RigConnection() + : m_c1GlobIdx( cvf::UNDEFINED_SIZE_T ) + , m_c1Face( cvf::StructGridInterface::NO_FACE ) + , m_c2GlobIdx( cvf::UNDEFINED_SIZE_T ) +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RigConnection::hasCommonArea() const +{ + return m_polygon.size() > 0; +} diff --git a/ApplicationCode/ReservoirDataModel/RigNncConnection.h b/ApplicationCode/ReservoirDataModel/RigNncConnection.h new file mode 100644 index 0000000000..1c05bd703c --- /dev/null +++ b/ApplicationCode/ReservoirDataModel/RigNncConnection.h @@ -0,0 +1,41 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2020 Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cvfStructGrid.h" +#include "cvfVector3.h" + +#include + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +class RigConnection +{ +public: + RigConnection(); + + bool hasCommonArea() const; + + size_t m_c1GlobIdx; + cvf::StructGridInterface::FaceType m_c1Face; + size_t m_c2GlobIdx; + + std::vector m_polygon; +}; From 3eb43342afa4336602d9ce9e0633958eaf4689c5 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 17 Jan 2020 08:39:06 +0100 Subject: [PATCH 5/7] #5273 Allen Diagrams: Rename --- ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp | 2 +- ApplicationCode/ReservoirDataModel/RigMainGrid.cpp | 2 +- ApplicationCode/ReservoirDataModel/RigNNCData.cpp | 4 ++-- ApplicationCode/ReservoirDataModel/RigNNCData.h | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp b/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp index 0a11e13f55..a8bf27e8d0 100644 --- a/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp +++ b/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp @@ -464,7 +464,7 @@ bool RifReaderEclipseOutput::open( const QString& fileName, RigEclipseCaseData* { auto subNncTask = nncProgress.task( "Processing connections", 8 ); - eclipseCase->mainGrid()->nncData()->processConnections( *( eclipseCase->mainGrid() ) ); + eclipseCase->mainGrid()->nncData()->processNativeConnections( *( eclipseCase->mainGrid() ) ); } } } diff --git a/ApplicationCode/ReservoirDataModel/RigMainGrid.cpp b/ApplicationCode/ReservoirDataModel/RigMainGrid.cpp index 5eef0a73c7..f9e9716393 100644 --- a/ApplicationCode/ReservoirDataModel/RigMainGrid.cpp +++ b/ApplicationCode/ReservoirDataModel/RigMainGrid.cpp @@ -556,7 +556,7 @@ void RigMainGrid::calculateFaults( const RigActiveCellInfo* activeCellInfo ) } } - this->nncData()->computeNncsFromFaults( this ); + this->nncData()->computeCompleteSetOfNncs( this ); distributeNNCsToFaults(); } diff --git a/ApplicationCode/ReservoirDataModel/RigNNCData.cpp b/ApplicationCode/ReservoirDataModel/RigNNCData.cpp index 2da3216935..4e71d558e7 100644 --- a/ApplicationCode/ReservoirDataModel/RigNNCData.cpp +++ b/ApplicationCode/ReservoirDataModel/RigNNCData.cpp @@ -33,7 +33,7 @@ RigNNCData::RigNNCData() {} //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigNNCData::processConnections( const RigMainGrid& mainGrid ) +void RigNNCData::processNativeConnections( const RigMainGrid& mainGrid ) { // cvf::Trace::show("NNC: Total number: " + cvf::String((int)m_connections.size())); @@ -77,7 +77,7 @@ void RigNNCData::processConnections( const RigMainGrid& mainGrid ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigNNCData::computeNncsFromFaults( const RigMainGrid* mainGrid ) +void RigNNCData::computeCompleteSetOfNncs( const RigMainGrid* mainGrid ) { m_nativeConnectionCount = m_connections.size(); diff --git a/ApplicationCode/ReservoirDataModel/RigNNCData.h b/ApplicationCode/ReservoirDataModel/RigNNCData.h index 8a73d69a63..fceecd086a 100644 --- a/ApplicationCode/ReservoirDataModel/RigNNCData.h +++ b/ApplicationCode/ReservoirDataModel/RigNNCData.h @@ -47,8 +47,8 @@ public: RigNNCData(); - void processConnections( const RigMainGrid& mainGrid ); - void computeNncsFromFaults( const RigMainGrid* mainGrid ); + void processNativeConnections( const RigMainGrid& mainGrid ); + void computeCompleteSetOfNncs( const RigMainGrid* mainGrid ); void setConnections( std::vector& connections ); From 71b118e7fb2874cf2405df3b71038e2c04e63071 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 17 Jan 2020 14:44:36 +0100 Subject: [PATCH 6/7] #5273 Allen Diagrams: Create special geometry for Allen NNC results --- .../ModelVisualization/RivFaultPartMgr.cpp | 77 +++++++++++++++++-- .../ModelVisualization/RivFaultPartMgr.h | 8 +- .../RivNNCGeometryGenerator.cpp | 11 ++- .../RivNNCGeometryGenerator.h | 8 +- .../RivReservoirFaultsPartMgr.cpp | 18 ++++- .../ReservoirDataModel/RigNNCData.cpp | 8 ++ .../ReservoirDataModel/RigNNCData.h | 3 +- 7 files changed, 119 insertions(+), 14 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivFaultPartMgr.cpp b/ApplicationCode/ModelVisualization/RivFaultPartMgr.cpp index efd6ea40bf..93fa4a2058 100644 --- a/ApplicationCode/ModelVisualization/RivFaultPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivFaultPartMgr.cpp @@ -72,13 +72,22 @@ RivFaultPartMgr::RivFaultPartMgr( const RigGridBase* grid, m_nativeFaultGenerator = new RivFaultGeometryGenerator( grid, rimFault->faultGeometry(), true ); m_oppositeFaultGenerator = new RivFaultGeometryGenerator( grid, rimFault->faultGeometry(), false ); - m_NNCGenerator = new RivNNCGeometryGenerator( grid->mainGrid()->nncData(), + m_nativeFaultFacesTextureCoords = new cvf::Vec2fArray; + m_oppositeFaultFacesTextureCoords = new cvf::Vec2fArray; + + m_NNCGenerator = new RivNNCGeometryGenerator( false, + grid->mainGrid()->nncData(), grid->mainGrid()->displayModelOffset(), connIdxes.p() ); - m_nativeFaultFacesTextureCoords = new cvf::Vec2fArray; - m_oppositeFaultFacesTextureCoords = new cvf::Vec2fArray; - m_NNCTextureCoords = new cvf::Vec2fArray; + m_NNCTextureCoords = new cvf::Vec2fArray; + + m_allenNNCGenerator = new RivNNCGeometryGenerator( true, + grid->mainGrid()->nncData(), + grid->mainGrid()->displayModelOffset(), + connIdxes.p() ); + + m_allenNNCTextureCoords = new cvf::Vec2fArray; } //-------------------------------------------------------------------------------------------------- @@ -89,6 +98,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() ); generatePartGeometry(); } @@ -397,6 +407,34 @@ void RivFaultPartMgr::generatePartGeometry() } } + { + 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 ); + + m_allenNNCFaces = part; + } + } + createLabelWithAnchorLine( m_nativeFaultFaces.p() ); updatePartEffect(); @@ -449,7 +487,9 @@ void RivFaultPartMgr::updatePartEffect() m_nativeFaultFaces->setPriority( RivPartPriority::PartType::TransparentFault ); if ( m_oppositeFaultFaces.notNull() ) 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_nativeFaultGridLines.notNull() ) { @@ -643,7 +683,15 @@ void RivFaultPartMgr::appendMeshLinePartsToModel( cvf::ModelBasicList* model ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivFaultPartMgr::appendNNCFacesToModel( cvf::ModelBasicList* model ) +void RivFaultPartMgr::appendCompleteNNCFacesToModel( cvf::ModelBasicList* model ) +{ + if ( m_allenNNCFaces.notNull() ) model->addPart( m_allenNNCFaces.p() ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivFaultPartMgr::appendNativeNNCFacesToModel( cvf::ModelBasicList* model ) { if ( m_NNCFaces.notNull() ) model->addPart( m_NNCFaces.p() ); } @@ -730,6 +778,12 @@ void RivFaultPartMgr::updateNNCColors( size_t timeStepIndex, RimEclipseCellColor resultType, eclResAddr, nativeTimeStepIndex ); + + m_allenNNCGenerator->textureCoordinates( m_allenNNCTextureCoords.p(), + mapper, + resultType, + eclResAddr, + nativeTimeStepIndex ); } } @@ -750,10 +804,18 @@ void RivFaultPartMgr::updateNNCColors( size_t timeStepIndex, RimEclipseCellColor nncEffect = nncEffgen.generateCachedEffect(); } - cvf::DrawableGeo* dg = dynamic_cast( m_NNCFaces->drawable() ); - if ( dg ) dg->setTextureCoordArray( m_NNCTextureCoords.p() ); + { + cvf::DrawableGeo* dg = dynamic_cast( m_NNCFaces->drawable() ); + if ( dg ) dg->setTextureCoordArray( m_NNCTextureCoords.p() ); + } + + { + cvf::DrawableGeo* dg = dynamic_cast( m_allenNNCFaces->drawable() ); + if ( dg ) dg->setTextureCoordArray( m_allenNNCTextureCoords.p() ); + } m_NNCFaces->setEffect( nncEffect.p() ); + m_allenNNCFaces->setEffect( nncEffect.p() ); } else { @@ -780,5 +842,6 @@ void RivFaultPartMgr::updateNNCColors( size_t timeStepIndex, RimEclipseCellColor } m_NNCFaces->setEffect( nncEffect.p() ); + m_allenNNCFaces->setEffect( nncEffect.p() ); } } diff --git a/ApplicationCode/ModelVisualization/RivFaultPartMgr.h b/ApplicationCode/ModelVisualization/RivFaultPartMgr.h index d7b7cd57a5..c39a6d2759 100644 --- a/ApplicationCode/ModelVisualization/RivFaultPartMgr.h +++ b/ApplicationCode/ModelVisualization/RivFaultPartMgr.h @@ -68,10 +68,12 @@ public: void appendNativeFaultFacesToModel( cvf::ModelBasicList* model ); void appendOppositeFaultFacesToModel( cvf::ModelBasicList* model ); - void appendNNCFacesToModel( cvf::ModelBasicList* model ); void appendLabelPartsToModel( cvf::ModelBasicList* model ); void appendMeshLinePartsToModel( cvf::ModelBasicList* model ); + void appendNativeNNCFacesToModel( cvf::ModelBasicList* model ); + void appendCompleteNNCFacesToModel( cvf::ModelBasicList* model ); + private: void generatePartGeometry(); void updatePartEffect(); @@ -108,6 +110,10 @@ private: cvf::ref m_NNCFaces; cvf::ref m_NNCTextureCoords; + cvf::ref m_allenNNCGenerator; + cvf::ref m_allenNNCFaces; + cvf::ref m_allenNNCTextureCoords; + cvf::ref m_faultLabelPart; cvf::ref m_faultLabelLinePart; }; diff --git a/ApplicationCode/ModelVisualization/RivNNCGeometryGenerator.cpp b/ApplicationCode/ModelVisualization/RivNNCGeometryGenerator.cpp index bb6557a1b2..b9e9b633e5 100644 --- a/ApplicationCode/ModelVisualization/RivNNCGeometryGenerator.cpp +++ b/ApplicationCode/ModelVisualization/RivNNCGeometryGenerator.cpp @@ -31,10 +31,12 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RivNNCGeometryGenerator::RivNNCGeometryGenerator( const RigNNCData* nncData, +RivNNCGeometryGenerator::RivNNCGeometryGenerator( bool includeAllen, + const RigNNCData* nncData, const cvf::Vec3d& offset, const cvf::Array* nncIndexes ) - : m_nncData( nncData ) + : m_includeAllenDiagramGeometry( includeAllen ) + , m_nncData( nncData ) , m_nncIndexes( nncIndexes ) , m_offset( offset ) { @@ -86,6 +88,11 @@ void RivNNCGeometryGenerator::computeArrays() { size_t conIdx = m_nncIndexes.isNull() ? nIdx : ( *m_nncIndexes )[nIdx]; + if ( !m_includeAllenDiagramGeometry && conIdx >= m_nncData->nativeConnectionCount() ) + { + continue; + } + const RigConnection& conn = m_nncData->connections()[conIdx]; if ( conn.m_polygon.size() ) diff --git a/ApplicationCode/ModelVisualization/RivNNCGeometryGenerator.h b/ApplicationCode/ModelVisualization/RivNNCGeometryGenerator.h index dcf611763a..d0c254b67a 100644 --- a/ApplicationCode/ModelVisualization/RivNNCGeometryGenerator.h +++ b/ApplicationCode/ModelVisualization/RivNNCGeometryGenerator.h @@ -42,7 +42,11 @@ class RigEclipseResultAddress; class RivNNCGeometryGenerator : public cvf::Object { public: - RivNNCGeometryGenerator( const RigNNCData* nncData, const cvf::Vec3d& offset, const cvf::Array* nncIndexes ); + RivNNCGeometryGenerator( bool includeAllen, + const RigNNCData* nncData, + const cvf::Vec3d& offset, + const cvf::Array* nncIndexes ); + ~RivNNCGeometryGenerator() override; void setCellVisibility( const cvf::UByteArray* cellVisibilities, const RigGridBase* grid ); @@ -63,6 +67,8 @@ private: void computeArrays(); private: + bool m_includeAllenDiagramGeometry; + // Input cvf::cref m_nncData; cvf::cref> m_nncIndexes; diff --git a/ApplicationCode/ModelVisualization/RivReservoirFaultsPartMgr.cpp b/ApplicationCode/ModelVisualization/RivReservoirFaultsPartMgr.cpp index b262418706..4618f32454 100644 --- a/ApplicationCode/ModelVisualization/RivReservoirFaultsPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivReservoirFaultsPartMgr.cpp @@ -154,7 +154,9 @@ void RivReservoirFaultsPartMgr::appendPartsToModel( cvf::ModelBasicList* model ) { if ( faultCollection->showNNCs() ) { - bool showNncs = true; + bool showNncs = true; + bool showAllenNncGeometry = false; + if ( faultCollection->hideNncsWhenNoResultIsAvailable() ) { RigEclipseResultAddress eclipseResultAddress; @@ -167,6 +169,11 @@ void RivReservoirFaultsPartMgr::appendPartsToModel( cvf::ModelBasicList* model ) eclipseResultAddress = cellResultColors->eclipseResultAddress(); } + if ( eclipseResultAddress.m_resultCatType == RiaDefines::ALLEN_DIAGRAMS ) + { + showAllenNncGeometry = true; + } + RigMainGrid* mainGrid = m_reservoirView->mainGrid(); if ( !( mainGrid && mainGrid->nncData()->hasScalarValues( eclipseResultAddress ) ) ) { @@ -176,7 +183,14 @@ void RivReservoirFaultsPartMgr::appendPartsToModel( cvf::ModelBasicList* model ) if ( showNncs ) { - rivFaultPart->appendNNCFacesToModel( &parts ); + if ( showAllenNncGeometry ) + { + rivFaultPart->appendCompleteNNCFacesToModel( &parts ); + } + else + { + rivFaultPart->appendNativeNNCFacesToModel( &parts ); + } } } } diff --git a/ApplicationCode/ReservoirDataModel/RigNNCData.cpp b/ApplicationCode/ReservoirDataModel/RigNNCData.cpp index 4e71d558e7..d48771aa18 100644 --- a/ApplicationCode/ReservoirDataModel/RigNNCData.cpp +++ b/ApplicationCode/ReservoirDataModel/RigNNCData.cpp @@ -94,6 +94,14 @@ void RigNNCData::setConnections( std::vector& connections ) m_connections = connections; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t RigNNCData::nativeConnectionCount() const +{ + return m_nativeConnectionCount; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ReservoirDataModel/RigNNCData.h b/ApplicationCode/ReservoirDataModel/RigNNCData.h index fceecd086a..b92b6b277a 100644 --- a/ApplicationCode/ReservoirDataModel/RigNNCData.h +++ b/ApplicationCode/ReservoirDataModel/RigNNCData.h @@ -50,7 +50,8 @@ public: void processNativeConnections( const RigMainGrid& mainGrid ); void computeCompleteSetOfNncs( const RigMainGrid* mainGrid ); - void setConnections( std::vector& connections ); + void setConnections( std::vector& connections ); + size_t nativeConnectionCount() const; const std::vector& connections() const; From 7dcfdfbc9a5f00e5a96e234c57afaec28469d248 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 17 Jan 2020 15:09:19 +0100 Subject: [PATCH 7/7] #5273 Allen Diagrams: Always add an effect to generated parts Causing crash in some hard to reproduce cases when opening project file --- ApplicationCode/ModelVisualization/RivFaultPartMgr.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ApplicationCode/ModelVisualization/RivFaultPartMgr.cpp b/ApplicationCode/ModelVisualization/RivFaultPartMgr.cpp index 93fa4a2058..e6453e639d 100644 --- a/ApplicationCode/ModelVisualization/RivFaultPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivFaultPartMgr.cpp @@ -403,6 +403,9 @@ void RivFaultPartMgr::generatePartGeometry() part->setEnableMask( faultBit ); part->setPriority( RivPartPriority::PartType::Nnc ); + cvf::ref eff = new cvf::Effect; + part->setEffect( eff.p() ); + m_NNCFaces = part; } } @@ -431,6 +434,9 @@ void RivFaultPartMgr::generatePartGeometry() part->setEnableMask( faultBit ); part->setPriority( RivPartPriority::PartType::Nnc ); + cvf::ref eff = new cvf::Effect; + part->setEffect( eff.p() ); + m_allenNNCFaces = part; } }