From 2423dc977bd44d5efef3f7e3e0b9b6a6c395105c Mon Sep 17 00:00:00 2001 From: rubenthoms Date: Thu, 17 Sep 2020 14:39:22 +0200 Subject: [PATCH] First iteration showing vectors for NNC data. --- .../RivElementVectorResultPartMgr.cpp | 46 ++++++++++++++++++- .../RimElementVectorResult.cpp | 10 ++++ .../ProjectDataModel/RimElementVectorResult.h | 2 + 3 files changed, 56 insertions(+), 2 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivElementVectorResultPartMgr.cpp b/ApplicationCode/ModelVisualization/RivElementVectorResultPartMgr.cpp index b98faf475b..d92eb2c500 100644 --- a/ApplicationCode/ModelVisualization/RivElementVectorResultPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivElementVectorResultPartMgr.cpp @@ -110,6 +110,7 @@ void RivElementVectorResultPartMgr::appendDynamicGeometryPartsToModel( cvf::Mode std::vector directions; std::vector resultAddresses; + if ( result->showVectorI() ) { directions.push_back( cvf::StructGridInterface::POS_I ); @@ -127,8 +128,18 @@ void RivElementVectorResultPartMgr::appendDynamicGeometryPartsToModel( cvf::Mode } RigCaseCellResultsData* resultsData = eclipseCaseData->results( RiaDefines::PorosityModelType::MATRIX_MODEL ); + RigNNCData* nncData = eclipseCaseData->mainGrid()->nncData(); RigActiveCellInfo* activeCellInfo = eclipseCaseData->activeCellInfo( RiaDefines::PorosityModelType::MATRIX_MODEL ); + const std::vector>* nncResultVals = nullptr; + if ( result->showNncData() ) + { + if ( result->resultAddressCombined().m_resultCatType == RiaDefines::ResultCatType::DYNAMIC_NATIVE ) + { + nncResultVals = nncData->dynamicConnectionScalarResult( result->resultAddressCombined() ); + } + } + const cvf::Vec3d offset = eclipseCase->mainGrid()->displayModelOffset(); const std::vector& cells = eclipseCase->mainGrid()->globalCellArray(); @@ -136,11 +147,10 @@ void RivElementVectorResultPartMgr::appendDynamicGeometryPartsToModel( cvf::Mode { if ( !cells[gcIdx].isInvalid() && activeCellInfo->isActive( gcIdx ) ) { + size_t resultIdx = activeCellInfo->cellResultIndex( gcIdx ); for ( int dir = 0; dir < static_cast( directions.size() ); dir++ ) { - size_t resultIdx = activeCellInfo->cellResultIndex( gcIdx ); double resultValue = resultsData->cellScalarResults( resultAddresses[dir], timeStepIndex ).at( resultIdx ); - if ( std::abs( resultValue ) >= result->threshold() ) { cvf::Vec3d faceCenter = cells[gcIdx].faceCenter( directions[dir] ) - offset; @@ -159,6 +169,38 @@ void RivElementVectorResultPartMgr::appendDynamicGeometryPartsToModel( cvf::Mode std::cbrt( cells[gcIdx].volume() / 3.0 ) ) ); } } + + if ( nncResultVals && nncResultVals->size() > 0 && nncResultVals->at( timeStepIndex ).size() > 0 ) + { + // The nnc connections can have more connections than reported from Eclipse, clamp the result index to + // Eclipse Results + + double resultValue = 0.0; + if ( resultIdx < nncResultVals->at( timeStepIndex ).size() ) + { + resultValue = ( *nncResultVals )[timeStepIndex][resultIdx]; + } + if ( std::abs( resultValue ) >= result->threshold() ) + { + for ( int dir = 0; dir < static_cast( directions.size() ); dir++ ) + { + cvf::Vec3d faceCenter = cells[gcIdx].faceCenter( directions[dir] ) - offset; + cvf::Vec3d cellCenter = cells[gcIdx].center() - offset; + cvf::Vec3d faceNormal = ( faceCenter - cellCenter ).getNormalized() * arrowScaling; + + if ( result->scaleMethod() == RimElementVectorResult::RESULT ) + { + faceNormal *= std::abs( resultValue ); + } + + tensorVisualizations.push_back( + ElementVectorResultVisualization( faceCenter, + faceNormal, + resultValue, + std::cbrt( cells[gcIdx].volume() / 3.0 ) ) ); + } + } + } } } diff --git a/ApplicationCode/ProjectDataModel/RimElementVectorResult.cpp b/ApplicationCode/ProjectDataModel/RimElementVectorResult.cpp index 483fabb314..2911cc3aba 100644 --- a/ApplicationCode/ProjectDataModel/RimElementVectorResult.cpp +++ b/ApplicationCode/ProjectDataModel/RimElementVectorResult.cpp @@ -74,6 +74,7 @@ RimElementVectorResult::RimElementVectorResult() CAF_PDM_InitField( &m_showVectorI, "ShowVectorI", true, "I", "", "", "" ); CAF_PDM_InitField( &m_showVectorJ, "ShowVectorJ", true, "J", "", "", "" ); CAF_PDM_InitField( &m_showVectorK, "ShowVectorK", true, "K", "", "", "" ); + CAF_PDM_InitField( &m_showNncData, "ShowNncData", true, "Show NNC data", "", "", "" ); CAF_PDM_InitField( &m_threshold, "Threshold", 0.0f, "Threshold", "", "", "" ); CAF_PDM_InitFieldNoDefault( &m_vectorColor, "VectorColor", "Color", "", "", "" ); @@ -136,6 +137,14 @@ bool RimElementVectorResult::showVectorK() const return m_showVectorK(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimElementVectorResult::showNncData() const +{ + return m_showNncData(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -315,6 +324,7 @@ void RimElementVectorResult::defineUiOrdering( QString uiConfigName, caf::PdmUiO visibilityGroup->add( &m_showVectorI ); visibilityGroup->add( &m_showVectorJ ); visibilityGroup->add( &m_showVectorK ); + visibilityGroup->add( &m_showNncData ); visibilityGroup->add( &m_threshold ); caf::PdmUiGroup* vectorColorsGroup = uiOrdering.addNewGroup( "Vector Colors" ); diff --git a/ApplicationCode/ProjectDataModel/RimElementVectorResult.h b/ApplicationCode/ProjectDataModel/RimElementVectorResult.h index d772ff4fd6..7556282957 100644 --- a/ApplicationCode/ProjectDataModel/RimElementVectorResult.h +++ b/ApplicationCode/ProjectDataModel/RimElementVectorResult.h @@ -65,6 +65,7 @@ public: bool showVectorI() const; bool showVectorJ() const; bool showVectorK() const; + bool showNncData() const; float threshold() const; float sizeScale() const; TensorColors vectorColors() const; @@ -102,6 +103,7 @@ private: caf::PdmField m_showVectorI; caf::PdmField m_showVectorJ; caf::PdmField m_showVectorK; + caf::PdmField m_showNncData; caf::PdmField m_threshold; caf::PdmField> m_vectorColor; caf::PdmField m_uniformVectorColor;