From 85f1b004cb9c6cb2c942d0f204033bf45ac533d7 Mon Sep 17 00:00:00 2001 From: jonjenssen <69144954+jonjenssen@users.noreply.github.com> Date: Wed, 18 Jan 2023 14:42:33 +0100 Subject: [PATCH] Geomech frames support (#9678) Support for showing frames in geomech data. --- .../GeoMechDataModel/RigFemNativeStatCalc.cpp | 30 +- .../RigFemNativeVisibleCellsStatCalc.cpp | 2 +- .../RigFemNativeVisibleCellsStatCalc.h | 40 +- ...RigFemPartResultCalculatorBarConverted.cpp | 33 +- .../RigFemPartResultCalculatorCompaction.cpp | 84 ++- .../RigFemPartResultCalculatorDSM.cpp | 42 +- .../RigFemPartResultCalculatorED.cpp | 39 +- .../RigFemPartResultCalculatorEV.cpp | 33 +- .../RigFemPartResultCalculatorEnIpPorBar.cpp | 53 +- .../RigFemPartResultCalculatorFOS.cpp | 35 +- ...emPartResultCalculatorFormationIndices.cpp | 14 +- .../RigFemPartResultCalculatorGamma.cpp | 89 ++-- .../RigFemPartResultCalculatorGamma.h | 2 +- ...FemPartResultCalculatorInitialPorosity.cpp | 75 +-- .../RigFemPartResultCalculatorKIndices.cpp | 10 +- ...FemPartResultCalculatorMudWeightWindow.cpp | 485 +++++++++--------- ...igFemPartResultCalculatorMudWeightWindow.h | 1 + .../RigFemPartResultCalculatorNE.cpp | 33 +- ...gFemPartResultCalculatorNodalGradients.cpp | 145 +++--- .../RigFemPartResultCalculatorNormalSE.cpp | 74 +-- .../RigFemPartResultCalculatorNormalST.cpp | 85 +-- .../RigFemPartResultCalculatorNormalized.cpp | 112 ++-- ...artResultCalculatorPoreCompressibility.cpp | 260 +++++----- ...rtResultCalculatorPorosityPermeability.cpp | 224 ++++---- ...FemPartResultCalculatorPrincipalStrain.cpp | 58 ++- ...FemPartResultCalculatorPrincipalStress.cpp | 169 +++--- .../RigFemPartResultCalculatorQ.cpp | 59 ++- .../RigFemPartResultCalculatorSFI.cpp | 51 +- .../RigFemPartResultCalculatorSM.cpp | 33 +- .../RigFemPartResultCalculatorShearSE.cpp | 64 +-- .../RigFemPartResultCalculatorShearST.cpp | 33 +- ...PartResultCalculatorShearSlipIndicator.cpp | 113 ++-- ...emPartResultCalculatorStressAnisotropy.cpp | 152 +++--- ...FemPartResultCalculatorStressGradients.cpp | 91 ++-- ...rtResultCalculatorSurfaceAlignedStress.cpp | 225 ++++---- ...igFemPartResultCalculatorSurfaceAngles.cpp | 93 ++-- .../RigFemPartResultCalculatorTimeLapse.cpp | 58 ++- .../RigFemPartResultsCollection.cpp | 225 +++++--- .../RigFemPartResultsCollection.h | 45 +- .../RigFemScalarResultFrames.cpp | 72 ++- .../RigFemScalarResultFrames.h | 16 +- .../GeoMechDataModel/RigGeoMechCaseData.cpp | 4 +- .../GeoMechDataModel/RigGeoMechCaseData.h | 6 +- .../RivFemElmVisibilityCalculator.cpp | 3 +- .../RivFemElmVisibilityCalculator.h | 1 + .../RivFemPartPartMgr.cpp | 4 +- .../GeoMechVisualization/RivFemPartPartMgr.h | 2 +- .../RivGeoMechPartMgr.cpp | 4 +- .../GeoMechVisualization/RivGeoMechPartMgr.h | 2 +- .../RivGeoMechPartMgrCache.cpp | 14 +- .../RivGeoMechPartMgrCache.h | 10 +- .../RivGeoMechVizLogic.cpp | 52 +- .../GeoMechVisualization/RivGeoMechVizLogic.h | 12 +- .../OdbReader/RifGeoMechReaderInterface.h | 1 + .../GeoMech/OdbReader/RifOdbReader.cpp | 8 + .../GeoMech/OdbReader/RifOdbReader.h | 1 + .../RivBoxIntersectionPartMgr.cpp | 2 +- .../Intersections/RivBoxIntersectionPartMgr.h | 2 +- .../RivExtrudedCurveIntersectionPartMgr.cpp | 2 +- .../RivExtrudedCurveIntersectionPartMgr.h | 2 +- .../RivIntersectionResultsColoringTools.cpp | 22 +- .../RivIntersectionResultsColoringTools.h | 6 +- .../RivTensorResultPartMgr.cpp | 10 +- .../RivTensorResultPartMgr.h | 5 +- .../Surfaces/RivSurfacePartMgr.cpp | 2 +- .../Surfaces/RivSurfacePartMgr.h | 2 +- .../CellFilters/RimPolygonFilter.cpp | 20 +- .../GeoMech/RimGeoMechCase.cpp | 47 +- .../ProjectDataModel/GeoMech/RimGeoMechCase.h | 2 +- .../RimGeoMechContourMapProjection.cpp | 53 +- .../GeoMech/RimGeoMechContourMapProjection.h | 8 +- .../GeoMech/RimGeoMechContourMapView.cpp | 2 +- .../GeoMech/RimGeoMechResultDefinition.cpp | 24 +- .../GeoMech/RimGeoMechView.cpp | 72 ++- .../ProjectDataModel/GeoMech/RimGeoMechView.h | 13 +- .../RimIntersectionCollection.cpp | 2 +- .../Intersections/RimIntersectionCollection.h | 2 +- .../RimContourMapProjection.h | 7 +- .../RimHistogramCalculator.cpp | 21 +- .../ProjectDataModel/RimTensorResults.cpp | 6 +- .../ProjectDataModel/RimWbsParameters.cpp | 13 +- .../ProjectDataModel/RimWbsParameters.h | 2 + .../RimWellBoreStabilityPlot.cpp | 7 +- .../RimWellBoreStabilityPlot.h | 3 +- .../Surfaces/RimSurfaceInViewCollection.cpp | 2 +- .../Surfaces/RimSurfaceInViewCollection.h | 2 +- .../WellLog/Rim3dWellLogCurve.cpp | 2 +- .../WellLog/Rim3dWellLogExtractionCurve.cpp | 11 +- .../WellLog/RimWellLogExtractionCurve.cpp | 20 +- .../WellLog/RimWellLogTrack.cpp | 11 +- .../WellPath/RimWellIADataAccess.cpp | 10 +- .../WellPath/RimWellIADataAccess.h | 6 +- .../WellPath/RimWellIASettings.cpp | 14 +- .../RigGeoMechWellLogExtractor.cpp | 112 ++-- .../RigGeoMechWellLogExtractor.h | 25 +- .../UserInterface/Riu3dSelectionManager.cpp | 8 +- .../UserInterface/Riu3dSelectionManager.h | 9 +- .../RiuCellAndNncPickEventHandler.cpp | 30 +- .../UserInterface/RiuFemResultTextBuilder.cpp | 25 +- .../UserInterface/RiuFemResultTextBuilder.h | 5 +- .../RiuFemTimeHistoryResultAccessor.cpp | 40 +- .../RiuGeoMechXfTensorResultAccessor.cpp | 16 +- .../RiuGeoMechXfTensorResultAccessor.h | 4 +- .../UserInterface/RiuMohrsCirclePlot.cpp | 18 +- .../UserInterface/RiuMohrsCirclePlot.h | 3 +- .../RiuSelectionChangedHandler.cpp | 3 +- 106 files changed, 2468 insertions(+), 1948 deletions(-) diff --git a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemNativeStatCalc.cpp b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemNativeStatCalc.cpp index 1889220180..198ddd0278 100644 --- a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemNativeStatCalc.cpp +++ b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemNativeStatCalc.cpp @@ -40,7 +40,10 @@ void RigFemNativeStatCalc::minMaxCellScalarValues( size_t timeStepIndex, double& { for ( int pIdx = 0; pIdx < m_resultsData->partCount(); ++pIdx ) { - const std::vector& values = m_resultsData->resultValues( m_resVarAddr, pIdx, (int)timeStepIndex ); + auto frames = m_resultsData->findOrLoadScalarResult( pIdx, m_resVarAddr ); + + auto [stepIdx, frameIdx] = m_resultsData->stepListIndexToTimeStepAndDataFrameIndex( timeStepIndex ); + const std::vector& values = frames->frameData( stepIdx, frameIdx ); size_t i; for ( i = 0; i < values.size(); i++ ) @@ -49,7 +52,6 @@ void RigFemNativeStatCalc::minMaxCellScalarValues( size_t timeStepIndex, double& { continue; } - if ( values[i] < min ) { min = values[i]; @@ -70,7 +72,10 @@ void RigFemNativeStatCalc::posNegClosestToZero( size_t timeStepIndex, double& po { for ( int pIdx = 0; pIdx < m_resultsData->partCount(); ++pIdx ) { - const std::vector& values = m_resultsData->resultValues( m_resVarAddr, pIdx, (int)timeStepIndex ); + auto frames = m_resultsData->findOrLoadScalarResult( pIdx, m_resVarAddr ); + + auto [stepIdx, frameIdx] = m_resultsData->stepListIndexToTimeStepAndDataFrameIndex( timeStepIndex ); + const std::vector& values = frames->frameData( stepIdx, frameIdx ); for ( size_t i = 0; i < values.size(); i++ ) { @@ -97,12 +102,14 @@ void RigFemNativeStatCalc::posNegClosestToZero( size_t timeStepIndex, double& po //-------------------------------------------------------------------------------------------------- void RigFemNativeStatCalc::valueSumAndSampleCount( size_t timeStepIndex, double& valueSum, size_t& sampleCount ) { - int tsIdx = static_cast( timeStepIndex ); int partCount = m_resultsData->partCount(); for ( int pIdx = 0; pIdx < partCount; ++pIdx ) { - const std::vector& values = m_resultsData->resultValues( m_resVarAddr, pIdx, tsIdx ); + auto frames = m_resultsData->findOrLoadScalarResult( pIdx, m_resVarAddr ); + auto [stepIdx, frameIdx] = m_resultsData->stepListIndexToTimeStepAndDataFrameIndex( timeStepIndex ); + + const std::vector& values = frames->frameData( stepIdx, frameIdx ); size_t undefValueCount = 0; for ( size_t cIdx = 0; cIdx < values.size(); ++cIdx ) { @@ -129,8 +136,10 @@ void RigFemNativeStatCalc::addDataToHistogramCalculator( size_t timeStepIndex, R int partCount = m_resultsData->partCount(); for ( int pIdx = 0; pIdx < partCount; ++pIdx ) { - const std::vector& values = - m_resultsData->resultValues( m_resVarAddr, pIdx, static_cast( timeStepIndex ) ); + auto frames = m_resultsData->findOrLoadScalarResult( pIdx, m_resVarAddr ); + + auto [stepIdx, frameIdx] = m_resultsData->stepListIndexToTimeStepAndDataFrameIndex( timeStepIndex ); + const std::vector& values = frames->frameData( stepIdx, frameIdx ); histogramCalculator.addData( values ); } @@ -143,7 +152,10 @@ void RigFemNativeStatCalc::uniqueValues( size_t timeStepIndex, std::set& va { for ( int pIdx = 0; pIdx < m_resultsData->partCount(); ++pIdx ) { - const std::vector& floatValues = m_resultsData->resultValues( m_resVarAddr, pIdx, (int)timeStepIndex ); + auto frames = m_resultsData->findOrLoadScalarResult( pIdx, m_resVarAddr ); + + auto [stepIdx, frameIdx] = m_resultsData->stepListIndexToTimeStepAndDataFrameIndex( timeStepIndex ); + const std::vector& floatValues = frames->frameData( stepIdx, frameIdx ); for ( size_t i = 0; i < floatValues.size(); i++ ) { @@ -157,5 +169,5 @@ void RigFemNativeStatCalc::uniqueValues( size_t timeStepIndex, std::set& va //-------------------------------------------------------------------------------------------------- size_t RigFemNativeStatCalc::timeStepCount() { - return m_resultsData->frameCount(); + return m_resultsData->totalSteps(); } diff --git a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemNativeVisibleCellsStatCalc.cpp b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemNativeVisibleCellsStatCalc.cpp index eeabf5477c..6d55cf5034 100644 --- a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemNativeVisibleCellsStatCalc.cpp +++ b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemNativeVisibleCellsStatCalc.cpp @@ -97,5 +97,5 @@ void RigFemNativeVisibleCellsStatCalc::uniqueValues( size_t timeStepIndex, std:: //-------------------------------------------------------------------------------------------------- size_t RigFemNativeVisibleCellsStatCalc::timeStepCount() { - return m_resultsData->frameCount(); + return m_resultsData->totalSteps(); } diff --git a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemNativeVisibleCellsStatCalc.h b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemNativeVisibleCellsStatCalc.h index 004d4524d0..d743e39b43 100644 --- a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemNativeVisibleCellsStatCalc.h +++ b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemNativeVisibleCellsStatCalc.h @@ -57,18 +57,24 @@ private: { int partCount = m_caseData->femParts()->partCount(); - if ( m_resVarAddr.resultPosType == RIG_NODAL ) + for ( int pIdx = 0; pIdx < partCount; ++pIdx ) { - for ( int pIdx = 0; pIdx < partCount; ++pIdx ) - { - RigFemPart* part = m_caseData->femParts()->part( pIdx ); - const std::vector& values = m_resultsData->resultValues( m_resVarAddr, pIdx, (int)timeStepIndex ); + RigFemPart* part = m_caseData->femParts()->part( pIdx ); + int elmCount = part->elementCount(); + auto frames = m_resultsData->findOrLoadScalarResult( pIdx, m_resVarAddr ); + auto [stepIdx, frameIdx] = m_resultsData->stepListIndexToTimeStepAndDataFrameIndex( timeStepIndex ); + + const std::vector& values = m_resultsData->resultValues( m_resVarAddr, pIdx, stepIdx, frameIdx ); + + if ( values.empty() ) continue; + + if ( m_resVarAddr.resultPosType == RIG_NODAL ) + { size_t nodeCount = values.size(); cvf::UByteArray nodeVisibilities( nodeCount ); nodeVisibilities.setAll( false ); - int elmCount = part->elementCount(); for ( int elmIdx = 0; elmIdx < elmCount; ++elmIdx ) { if ( !( *m_cellVisibilities )[elmIdx] ) continue; @@ -90,15 +96,9 @@ private: } } } - } - else if ( m_resVarAddr.resultPosType == RIG_ELEMENT ) - { - for ( int pIdx = 0; pIdx < partCount; ++pIdx ) - { - RigFemPart* part = m_caseData->femParts()->part( pIdx ); - const std::vector& values = m_resultsData->resultValues( m_resVarAddr, pIdx, (int)timeStepIndex ); - int elmCount = part->elementCount(); + else if ( m_resVarAddr.resultPosType == RIG_ELEMENT ) + { for ( int elmIdx = 0; elmIdx < elmCount; ++elmIdx ) { if ( !( *m_cellVisibilities )[elmIdx] ) continue; @@ -106,17 +106,9 @@ private: accumulator.addValue( values[elmIdx] ); } } - } - else - { - for ( int pIdx = 0; pIdx < partCount; ++pIdx ) + + else { - RigFemPart* part = m_caseData->femParts()->part( pIdx ); - const std::vector& values = m_resultsData->resultValues( m_resVarAddr, pIdx, (int)timeStepIndex ); - int elmCount = part->elementCount(); - - if ( values.empty() ) continue; - for ( int elmIdx = 0; elmIdx < elmCount; ++elmIdx ) { if ( !( *m_cellVisibilities )[elmIdx] ) continue; diff --git a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorBarConverted.cpp b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorBarConverted.cpp index ae8d54e6ac..353a712e69 100644 --- a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorBarConverted.cpp +++ b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorBarConverted.cpp @@ -70,33 +70,36 @@ bool RigFemPartResultCalculatorBarConverted::isMatching( const RigFemResultAddre RigFemScalarResultFrames* RigFemPartResultCalculatorBarConverted::calculate( int partIndex, const RigFemResultAddress& resVarAddr ) { - caf::ProgressInfo frameCountProgress( m_resultCollection->frameCount() * 2, "" ); - frameCountProgress.setProgressDescription( + caf::ProgressInfo stepCountProgress( m_resultCollection->timeStepCount() * 2, "" ); + stepCountProgress.setProgressDescription( "Calculating " + QString::fromStdString( resVarAddr.fieldName + ": " + resVarAddr.componentName ) ); - frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); + stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() ); RigFemResultAddress unconvertedResultAddr( resVarAddr.resultPosType, m_fieldNameToConvert, resVarAddr.componentName ); RigFemScalarResultFrames* srcDataFrames = m_resultCollection->findOrLoadScalarResult( partIndex, unconvertedResultAddr ); RigFemScalarResultFrames* dstDataFrames = m_resultCollection->createScalarResult( partIndex, resVarAddr ); - frameCountProgress.incrementProgress(); + stepCountProgress.incrementProgress(); - int frameCount = srcDataFrames->frameCount(); - for ( int fIdx = 0; fIdx < frameCount; ++fIdx ) + const int timeSteps = srcDataFrames->timeStepCount(); + for ( int stepIdx = 0; stepIdx < timeSteps; stepIdx++ ) { - const std::vector& srcFrameData = srcDataFrames->frameData( fIdx ); - std::vector& dstFrameData = dstDataFrames->frameData( fIdx ); - size_t valCount = srcFrameData.size(); - dstFrameData.resize( valCount ); + const int frameCount = srcDataFrames->frameCount( stepIdx ); + for ( int fIdx = 0; fIdx < frameCount; fIdx++ ) + { + const std::vector& srcFrameData = srcDataFrames->frameData( stepIdx, fIdx ); + std::vector& dstFrameData = dstDataFrames->frameData( stepIdx, fIdx ); + size_t valCount = srcFrameData.size(); + dstFrameData.resize( valCount ); #pragma omp parallel for - for ( long vIdx = 0; vIdx < static_cast( valCount ); ++vIdx ) - { - dstFrameData[vIdx] = 1.0e-5 * srcFrameData[vIdx]; + for ( long vIdx = 0; vIdx < static_cast( valCount ); ++vIdx ) + { + dstFrameData[vIdx] = 1.0e-5 * srcFrameData[vIdx]; + } } - - frameCountProgress.incrementProgress(); + stepCountProgress.incrementProgress(); } m_resultCollection->deleteResult( unconvertedResultAddr ); return dstDataFrames; diff --git a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorCompaction.cpp b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorCompaction.cpp index 4546329140..5bee18d0ad 100644 --- a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorCompaction.cpp +++ b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorCompaction.cpp @@ -80,72 +80,68 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorCompaction::calculate( int { CVF_ASSERT( resVarAddr.fieldName == RigFemPartResultsCollection::FIELD_NAME_COMPACTION ); - caf::ProgressInfo frameCountProgress( m_resultCollection->frameCount() + 1, "" ); - frameCountProgress.setProgressDescription( "Calculating " + QString::fromStdString( resVarAddr.fieldName ) ); + caf::ProgressInfo stepCountProgress( m_resultCollection->timeStepCount() + 1, "" ); + stepCountProgress.setProgressDescription( "Calculating " + QString::fromStdString( resVarAddr.fieldName ) ); RigFemScalarResultFrames* u3Frames = m_resultCollection->findOrLoadScalarResult( partIndex, RigFemResultAddress( resVarAddr.resultPosType, "U", "U3" ) ); - frameCountProgress.incrementProgress(); + stepCountProgress.incrementProgress(); RigFemScalarResultFrames* compactionFrames = m_resultCollection->createScalarResult( partIndex, resVarAddr ); const RigFemPart* part = m_resultCollection->parts()->part( partIndex ); + // Make sure AABB tree and struct grid is created part->ensureIntersectionSearchTreeIsBuilt(); + part->getOrCreateStructGrid(); - for ( int t = 0; t < u3Frames->frameCount(); t++ ) + int timeSteps = u3Frames->timeStepCount(); + for ( int stepIdx = 0; stepIdx < timeSteps; stepIdx++ ) { - std::vector& compactionFrame = compactionFrames->frameData( t ); - size_t nodeCount = part->nodes().nodeIds.size(); - - frameCountProgress.incrementProgress(); - - compactionFrame.resize( nodeCount ); - + const int frameCount = u3Frames->frameCount( stepIdx ); + for ( int fIdx = 0; fIdx < frameCount; fIdx++ ) { - // Make sure the AABB-tree is created before using OpenMP - cvf::BoundingBox bb; - std::vector refElementCandidates; + std::vector& compactionFrame = compactionFrames->frameData( stepIdx, fIdx ); + size_t nodeCount = part->nodes().nodeIds.size(); - part->findIntersectingCells( bb, &refElementCandidates ); - - // Also make sure the struct grid is created, as this is required before using OpenMP - part->getOrCreateStructGrid(); - } + compactionFrame.resize( nodeCount ); #pragma omp parallel for - for ( long n = 0; n < static_cast( nodeCount ); n++ ) - { - RefElement refElement; - findReferenceElementForNode( *part, n, resVarAddr.refKLayerIndex, &refElement ); - - if ( refElement.elementIdx != cvf::UNDEFINED_SIZE_T ) + for ( long n = 0; n < static_cast( nodeCount ); n++ ) { - float shortestDist = std::numeric_limits::infinity(); - size_t closestRefNodeIdx = cvf::UNDEFINED_SIZE_T; + RefElement refElement; + findReferenceElementForNode( *part, n, resVarAddr.refKLayerIndex, &refElement ); - for ( size_t nodeIdx : refElement.elementFaceNodeIdxs ) + if ( refElement.elementIdx != cvf::UNDEFINED_SIZE_T ) { - float dist = horizontalDistance( refElement.intersectionPoint, part->nodes().coordinates[nodeIdx] ); - if ( dist < shortestDist ) - { - shortestDist = dist; - closestRefNodeIdx = nodeIdx; - } - } + float shortestDist = std::numeric_limits::infinity(); + size_t closestRefNodeIdx = cvf::UNDEFINED_SIZE_T; - cvf::Vec3f currentNodeCoord = part->nodes().coordinates[n]; - if ( currentNodeCoord.z() >= refElement.intersectionPoint.z() ) - compactionFrame[n] = -( u3Frames->frameData( t )[n] - u3Frames->frameData( t )[closestRefNodeIdx] ); + for ( size_t nodeIdx : refElement.elementFaceNodeIdxs ) + { + float dist = horizontalDistance( refElement.intersectionPoint, part->nodes().coordinates[nodeIdx] ); + if ( dist < shortestDist ) + { + shortestDist = dist; + closestRefNodeIdx = nodeIdx; + } + } + + cvf::Vec3f currentNodeCoord = part->nodes().coordinates[n]; + if ( currentNodeCoord.z() >= refElement.intersectionPoint.z() ) + compactionFrame[n] = -( u3Frames->frameData( stepIdx, fIdx )[n] - + u3Frames->frameData( stepIdx, fIdx )[closestRefNodeIdx] ); + else + compactionFrame[n] = -( u3Frames->frameData( stepIdx, fIdx )[closestRefNodeIdx] - + u3Frames->frameData( stepIdx, fIdx )[n] ); + } else - compactionFrame[n] = -( u3Frames->frameData( t )[closestRefNodeIdx] - u3Frames->frameData( t )[n] ); - } - else - { - compactionFrame[n] = HUGE_VAL; + { + compactionFrame[n] = HUGE_VAL; + } } } + stepCountProgress.incrementProgress(); } - RigFemScalarResultFrames* requestedPrincipal = m_resultCollection->findOrLoadScalarResult( partIndex, resVarAddr ); return requestedPrincipal; } diff --git a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorDSM.cpp b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorDSM.cpp index 2da64dd074..aab61f6afb 100644 --- a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorDSM.cpp +++ b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorDSM.cpp @@ -58,41 +58,45 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorDSM::calculate( int partInde { CVF_ASSERT( resVarAddr.fieldName == "SE" && resVarAddr.componentName == "DSM" ); - caf::ProgressInfo frameCountProgress( m_resultCollection->frameCount() * 3, "" ); - frameCountProgress.setProgressDescription( + caf::ProgressInfo stepCountProgress( m_resultCollection->timeStepCount() * 3, "" ); + stepCountProgress.setProgressDescription( "Calculating " + QString::fromStdString( resVarAddr.fieldName + ": " + resVarAddr.componentName ) ); - frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); + stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() ); RigFemScalarResultFrames* se1Frames = m_resultCollection->findOrLoadScalarResult( partIndex, RigFemResultAddress( resVarAddr.resultPosType, "SE", "S1" ) ); - frameCountProgress.incrementProgress(); - frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); + stepCountProgress.incrementProgress(); + stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() ); RigFemScalarResultFrames* se3Frames = m_resultCollection->findOrLoadScalarResult( partIndex, RigFemResultAddress( resVarAddr.resultPosType, "SE", "S3" ) ); RigFemScalarResultFrames* dstDataFrames = m_resultCollection->createScalarResult( partIndex, resVarAddr ); - frameCountProgress.incrementProgress(); + stepCountProgress.incrementProgress(); float tanFricAng = tan( m_resultCollection->parameterFrictionAngleRad() ); float cohPrTanFricAngle = (float)( m_resultCollection->parameterCohesion() / tanFricAng ); - int frameCount = se1Frames->frameCount(); - for ( int fIdx = 0; fIdx < frameCount; ++fIdx ) - { - const std::vector& se1Data = se1Frames->frameData( fIdx ); - const std::vector& se3Data = se3Frames->frameData( fIdx ); - std::vector& dstFrameData = dstDataFrames->frameData( fIdx ); - size_t valCount = se1Data.size(); - dstFrameData.resize( valCount ); + const int timeSteps = se1Frames->timeStepCount(); + for ( int stepIdx = 0; stepIdx < timeSteps; stepIdx++ ) + { + const int frameCount = se1Frames->frameCount( stepIdx ); + for ( int fIdx = 0; fIdx < frameCount; fIdx++ ) + { + const std::vector& se1Data = se1Frames->frameData( stepIdx, fIdx ); + const std::vector& se3Data = se3Frames->frameData( stepIdx, fIdx ); + + std::vector& dstFrameData = dstDataFrames->frameData( stepIdx, fIdx ); + size_t valCount = se1Data.size(); + dstFrameData.resize( valCount ); #pragma omp parallel for - for ( long vIdx = 0; vIdx < static_cast( valCount ); ++vIdx ) - { - dstFrameData[vIdx] = dsm( se1Data[vIdx], se3Data[vIdx], tanFricAng, cohPrTanFricAngle ); + for ( long vIdx = 0; vIdx < static_cast( valCount ); ++vIdx ) + { + dstFrameData[vIdx] = dsm( se1Data[vIdx], se3Data[vIdx], tanFricAng, cohPrTanFricAngle ); + } } - - frameCountProgress.incrementProgress(); + stepCountProgress.incrementProgress(); } return dstDataFrames; diff --git a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorED.cpp b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorED.cpp index 4be71982cd..7102a2f021 100644 --- a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorED.cpp +++ b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorED.cpp @@ -58,43 +58,46 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorED::calculate( int partIndex { CVF_ASSERT( resVarAddr.fieldName == "NE" && resVarAddr.componentName == "ED" ); - caf::ProgressInfo frameCountProgress( m_resultCollection->frameCount() * 3, "" ); - frameCountProgress.setProgressDescription( + caf::ProgressInfo stepCountProgress( m_resultCollection->timeStepCount() * 3, "" ); + stepCountProgress.setProgressDescription( "Calculating " + QString::fromStdString( resVarAddr.fieldName + ": " + resVarAddr.componentName ) ); - frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); + stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() ); RigFemScalarResultFrames* ea11 = nullptr; RigFemScalarResultFrames* ea33 = nullptr; { ea11 = m_resultCollection->findOrLoadScalarResult( partIndex, RigFemResultAddress( resVarAddr.resultPosType, "NE", "E1" ) ); - frameCountProgress.incrementProgress(); - frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); + stepCountProgress.incrementProgress(); + stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() ); ea33 = m_resultCollection->findOrLoadScalarResult( partIndex, RigFemResultAddress( resVarAddr.resultPosType, "NE", "E3" ) ); } RigFemScalarResultFrames* dstDataFrames = m_resultCollection->createScalarResult( partIndex, resVarAddr ); - frameCountProgress.incrementProgress(); + stepCountProgress.incrementProgress(); - int frameCount = ea11->frameCount(); - for ( int fIdx = 0; fIdx < frameCount; ++fIdx ) + const int timeSteps = ea11->timeStepCount(); + for ( int stepIdx = 0; stepIdx < timeSteps; stepIdx++ ) { - const std::vector& ea11Data = ea11->frameData( fIdx ); - const std::vector& ea33Data = ea33->frameData( fIdx ); + const int frameCount = ea11->frameCount( stepIdx ); + for ( int fIdx = 0; fIdx < frameCount; fIdx++ ) + { + const std::vector& ea11Data = ea11->frameData( stepIdx, fIdx ); + const std::vector& ea33Data = ea33->frameData( stepIdx, fIdx ); - std::vector& dstFrameData = dstDataFrames->frameData( fIdx ); - size_t valCount = ea11Data.size(); - dstFrameData.resize( valCount ); + std::vector& dstFrameData = dstDataFrames->frameData( stepIdx, fIdx ); + size_t valCount = ea11Data.size(); + dstFrameData.resize( valCount ); #pragma omp parallel for - for ( long vIdx = 0; vIdx < static_cast( valCount ); ++vIdx ) - { - dstFrameData[vIdx] = 0.666666666666667f * ( ea11Data[vIdx] - ea33Data[vIdx] ); + for ( long vIdx = 0; vIdx < static_cast( valCount ); ++vIdx ) + { + dstFrameData[vIdx] = 0.666666666666667f * ( ea11Data[vIdx] - ea33Data[vIdx] ); + } } - - frameCountProgress.incrementProgress(); + stepCountProgress.incrementProgress(); } return dstDataFrames; diff --git a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorEV.cpp b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorEV.cpp index 72f5cb6a0a..d943628f32 100644 --- a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorEV.cpp +++ b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorEV.cpp @@ -60,10 +60,10 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorEV::calculate( int partIndex QString progressText = "Calculating " + QString::fromStdString( resAddr.fieldName + ": " + resAddr.componentName ); - caf::ProgressInfo frameCountProgress( static_cast( m_resultCollection->frameCount() ) * 4, progressText ); + caf::ProgressInfo stepCountProgress( static_cast( m_resultCollection->timeStepCount() ) * 4, progressText ); auto loadFrameLambda = [&]( const QString& component ) { - auto task = frameCountProgress.task( "Loading " + component, m_resultCollection->frameCount() ); + auto task = stepCountProgress.task( "Loading " + component, m_resultCollection->timeStepCount() ); return m_resultCollection->findOrLoadScalarResult( partIndex, resAddr.copyWithComponent( component.toStdString() ) ); }; @@ -73,25 +73,28 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorEV::calculate( int partIndex RigFemScalarResultFrames* dstDataFrames = m_resultCollection->createScalarResult( partIndex, resAddr ); - int frameCount = ea11->frameCount(); - for ( int fIdx = 0; fIdx < frameCount; ++fIdx ) + const int timeSteps = ea11->timeStepCount(); + for ( int stepIdx = 0; stepIdx < timeSteps; stepIdx++ ) { - auto task = frameCountProgress.task( QString( "Frame %1" ).arg( fIdx ) ); + auto task = stepCountProgress.task( QString( "Step %1" ).arg( stepIdx ) ); - const std::vector& ea11Data = ea11->frameData( fIdx ); - const std::vector& ea22Data = ea22->frameData( fIdx ); - const std::vector& ea33Data = ea33->frameData( fIdx ); + const int frameCount = ea11->frameCount( stepIdx ); + for ( int fIdx = 0; fIdx < frameCount; fIdx++ ) + { + const std::vector& ea11Data = ea11->frameData( stepIdx, fIdx ); + const std::vector& ea22Data = ea22->frameData( stepIdx, fIdx ); + const std::vector& ea33Data = ea33->frameData( stepIdx, fIdx ); - std::vector& dstFrameData = dstDataFrames->frameData( fIdx ); - size_t valCount = ea11Data.size(); - dstFrameData.resize( valCount ); + std::vector& dstFrameData = dstDataFrames->frameData( stepIdx, fIdx ); + size_t valCount = ea11Data.size(); + dstFrameData.resize( valCount ); #pragma omp parallel for - for ( long vIdx = 0; vIdx < static_cast( valCount ); ++vIdx ) - { - dstFrameData[vIdx] = ( ea11Data[vIdx] + ea22Data[vIdx] + ea33Data[vIdx] ); + for ( long vIdx = 0; vIdx < static_cast( valCount ); ++vIdx ) + { + dstFrameData[vIdx] = ( ea11Data[vIdx] + ea22Data[vIdx] + ea33Data[vIdx] ); + } } } - return dstDataFrames; } diff --git a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorEnIpPorBar.cpp b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorEnIpPorBar.cpp index 8432dd87e2..ce19ab032d 100644 --- a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorEnIpPorBar.cpp +++ b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorEnIpPorBar.cpp @@ -57,52 +57,55 @@ bool RigFemPartResultCalculatorEnIpPorBar::isMatching( const RigFemResultAddress RigFemScalarResultFrames* RigFemPartResultCalculatorEnIpPorBar::calculate( int partIndex, const RigFemResultAddress& resVarAddr ) { - caf::ProgressInfo frameCountProgress( m_resultCollection->frameCount() * 2, "" ); - frameCountProgress.setProgressDescription( + caf::ProgressInfo stepCountProgress( m_resultCollection->timeStepCount() * 2, "" ); + stepCountProgress.setProgressDescription( "Calculating " + QString::fromStdString( resVarAddr.fieldName + ": " + resVarAddr.componentName ) ); - frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); + stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() ); RigFemResultAddress unconvertedResultAddr( RIG_NODAL, "POR", "" ); RigFemScalarResultFrames* srcDataFrames = m_resultCollection->findOrLoadScalarResult( partIndex, unconvertedResultAddr ); RigFemScalarResultFrames* dstDataFrames = m_resultCollection->createScalarResult( partIndex, resVarAddr ); - frameCountProgress.incrementProgress(); + stepCountProgress.incrementProgress(); const RigFemPart* femPart = m_resultCollection->parts()->part( partIndex ); - float inf = std::numeric_limits::infinity(); + constexpr float inf = std::numeric_limits::infinity(); - int frameCount = srcDataFrames->frameCount(); - for ( int fIdx = 0; fIdx < frameCount; ++fIdx ) + const int timeSteps = srcDataFrames->timeStepCount(); + for ( int stepIdx = 0; stepIdx < timeSteps; stepIdx++ ) { - const std::vector& srcFrameData = srcDataFrames->frameData( fIdx ); - std::vector& dstFrameData = dstDataFrames->frameData( fIdx ); + const int frameCount = srcDataFrames->frameCount( stepIdx ); + for ( int fIdx = 0; fIdx < frameCount; fIdx++ ) + { + const std::vector& srcFrameData = srcDataFrames->frameData( stepIdx, fIdx ); + std::vector& dstFrameData = dstDataFrames->frameData( stepIdx, fIdx ); - if ( srcFrameData.empty() ) continue; // Create empty results if we have no POR result. + if ( srcFrameData.empty() ) continue; // Create empty results if we have no POR result. - size_t valCount = femPart->elementNodeResultCount(); - dstFrameData.resize( valCount, inf ); + size_t valCount = femPart->elementNodeResultCount(); + dstFrameData.resize( valCount, inf ); - int elementCount = femPart->elementCount(); + int elementCount = femPart->elementCount(); #pragma omp parallel for schedule( dynamic ) - for ( int elmIdx = 0; elmIdx < elementCount; ++elmIdx ) - { - RigElementType elmType = femPart->elementType( elmIdx ); - - if ( elmType == HEX8P ) + for ( int elmIdx = 0; elmIdx < elementCount; ++elmIdx ) { - int elmNodeCount = RigFemTypes::elementNodeCount( elmType ); - for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx ) + RigElementType elmType = femPart->elementType( elmIdx ); + + if ( elmType == HEX8P ) { - size_t elmNodResIdx = femPart->elementNodeResultIdx( elmIdx, elmNodIdx ); - int nodeIdx = femPart->nodeIdxFromElementNodeResultIdx( elmNodResIdx ); - dstFrameData[elmNodResIdx] = 1.0e-5 * srcFrameData[nodeIdx]; + int elmNodeCount = RigFemTypes::elementNodeCount( elmType ); + for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx ) + { + size_t elmNodResIdx = femPart->elementNodeResultIdx( elmIdx, elmNodIdx ); + int nodeIdx = femPart->nodeIdxFromElementNodeResultIdx( elmNodResIdx ); + dstFrameData[elmNodResIdx] = 1.0e-5 * srcFrameData[nodeIdx]; + } } } } - - frameCountProgress.incrementProgress(); + stepCountProgress.incrementProgress(); } m_resultCollection->deleteResult( unconvertedResultAddr ); diff --git a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorFOS.cpp b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorFOS.cpp index ea3ee7a578..d78e3b164f 100644 --- a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorFOS.cpp +++ b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorFOS.cpp @@ -58,10 +58,10 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorFOS::calculate( int partInde { CVF_ASSERT( resVarAddr.fieldName == "SE" && resVarAddr.componentName == "FOS" ); - caf::ProgressInfo frameCountProgress( m_resultCollection->frameCount() * 2, "" ); - frameCountProgress.setProgressDescription( + caf::ProgressInfo stepCountProgress( m_resultCollection->timeStepCount() * 2, "" ); + stepCountProgress.setProgressDescription( "Calculating " + QString::fromStdString( resVarAddr.fieldName + ": " + resVarAddr.componentName ) ); - frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); + stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() ); RigFemScalarResultFrames* dsmFrames = m_resultCollection->findOrLoadScalarResult( partIndex, @@ -69,25 +69,28 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorFOS::calculate( int partInde RigFemScalarResultFrames* dstDataFrames = m_resultCollection->createScalarResult( partIndex, resVarAddr ); - frameCountProgress.incrementProgress(); + stepCountProgress.incrementProgress(); - int frameCount = dsmFrames->frameCount(); - for ( int fIdx = 0; fIdx < frameCount; ++fIdx ) + const int timeSteps = dsmFrames->timeStepCount(); + for ( int stepIdx = 0; stepIdx < timeSteps; stepIdx++ ) { - const std::vector& dsmData = dsmFrames->frameData( fIdx ); + const int frameCount = dsmFrames->frameCount( stepIdx ); + for ( int fIdx = 0; fIdx < frameCount; fIdx++ ) + { + const std::vector& dsmData = dsmFrames->frameData( stepIdx, fIdx ); - std::vector& dstFrameData = dstDataFrames->frameData( fIdx ); - size_t valCount = dsmData.size(); - dstFrameData.resize( valCount ); + std::vector& dstFrameData = dstDataFrames->frameData( stepIdx, fIdx ); + size_t valCount = dsmData.size(); + dstFrameData.resize( valCount ); #pragma omp parallel for - for ( long vIdx = 0; vIdx < static_cast( valCount ); ++vIdx ) - { - float dsm = dsmData[vIdx]; - dstFrameData[vIdx] = 1.0f / dsm; + for ( long vIdx = 0; vIdx < static_cast( valCount ); ++vIdx ) + { + float dsm = dsmData[vIdx]; + dstFrameData[vIdx] = 1.0f / dsm; + } } - - frameCountProgress.incrementProgress(); + stepCountProgress.incrementProgress(); } return dstDataFrames; diff --git a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorFormationIndices.cpp b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorFormationIndices.cpp index fd14256b89..96a9aa5c8e 100644 --- a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorFormationIndices.cpp +++ b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorFormationIndices.cpp @@ -59,23 +59,23 @@ bool RigFemPartResultCalculatorFormationIndices::isMatching( const RigFemResultA RigFemScalarResultFrames* RigFemPartResultCalculatorFormationIndices::calculate( int partIndex, const RigFemResultAddress& resVarAddr ) { - caf::ProgressInfo frameCountProgress( 2, "" ); - frameCountProgress.setProgressDescription( + caf::ProgressInfo stepCountProgress( 2, "" ); + stepCountProgress.setProgressDescription( "Calculating " + QString::fromStdString( resVarAddr.fieldName + ": " + resVarAddr.componentName ) ); RigFemScalarResultFrames* resFrames = m_resultCollection->createScalarResult( partIndex, resVarAddr ); - resFrames->enableAsSingleFrameResult(); + resFrames->enableAsSingleStepResult(); const RigFemPart* femPart = m_resultCollection->parts()->part( partIndex ); - std::vector& dstFrameData = resFrames->frameData( 0 ); + std::vector& dstFrameData = resFrames->frameData( 0, 0 ); - size_t valCount = femPart->elementNodeResultCount(); - float inf = std::numeric_limits::infinity(); + size_t valCount = femPart->elementNodeResultCount(); + constexpr float inf = std::numeric_limits::infinity(); dstFrameData.resize( valCount, inf ); const RigFormationNames* activeFormNames = m_resultCollection->activeFormationNames(); - frameCountProgress.incrementProgress(); + stepCountProgress.incrementProgress(); if ( activeFormNames ) { diff --git a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorGamma.cpp b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorGamma.cpp index 5c6ac17892..c3c60c4ddc 100644 --- a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorGamma.cpp +++ b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorGamma.cpp @@ -59,10 +59,10 @@ bool RigFemPartResultCalculatorGamma::isMatching( const RigFemResultAddress& res //-------------------------------------------------------------------------------------------------- RigFemScalarResultFrames* RigFemPartResultCalculatorGamma::calculate( int partIndex, const RigFemResultAddress& resVarAddr ) { - caf::ProgressInfo frameCountProgress( m_resultCollection->frameCount() * 3, "" ); - frameCountProgress.setProgressDescription( + caf::ProgressInfo stepCountProgress( m_resultCollection->timeStepCount() * 3, "" ); + stepCountProgress.setProgressDescription( "Calculating " + QString::fromStdString( resVarAddr.fieldName + ": " + resVarAddr.componentName ) ); - frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); + stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() ); RigFemResultAddress totStressCompAddr( resVarAddr.resultPosType, "ST", "" ); { @@ -85,21 +85,21 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorGamma::calculate( int partIn RigFemScalarResultFrames* srcDataFrames = m_resultCollection->findOrLoadScalarResult( partIndex, totStressCompAddr ); - frameCountProgress.incrementProgress(); - frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); + stepCountProgress.incrementProgress(); + stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() ); RigFemScalarResultFrames* srcPORDataFrames = m_resultCollection->findOrLoadScalarResult( partIndex, RigFemResultAddress( RIG_NODAL, "POR-Bar", "" ) ); RigFemScalarResultFrames* dstDataFrames = m_resultCollection->createScalarResult( partIndex, resVarAddr ); - frameCountProgress.incrementProgress(); + stepCountProgress.incrementProgress(); calculateGammaFromFrames( partIndex, m_resultCollection->parts(), srcDataFrames, srcPORDataFrames, dstDataFrames, - &frameCountProgress ); + &stepCountProgress ); return dstDataFrames; } @@ -112,62 +112,65 @@ void RigFemPartResultCalculatorGamma::calculateGammaFromFrames( int const RigFemScalarResultFrames* totalStressComponentDataFrames, const RigFemScalarResultFrames* srcPORDataFrames, RigFemScalarResultFrames* dstDataFrames, - caf::ProgressInfo* frameCountProgress ) + caf::ProgressInfo* stepCountProgress ) { - const RigFemPart* femPart = femParts->part( partIndex ); - int frameCount = totalStressComponentDataFrames->frameCount(); - float inf = std::numeric_limits::infinity(); + const RigFemPart* femPart = femParts->part( partIndex ); + float inf = std::numeric_limits::infinity(); - for ( int fIdx = 0; fIdx < frameCount; ++fIdx ) + const int timeSteps = totalStressComponentDataFrames->timeStepCount(); + for ( int stepIdx = 0; stepIdx < timeSteps; stepIdx++ ) { - const std::vector& srcSTFrameData = totalStressComponentDataFrames->frameData( fIdx ); - const std::vector& srcPORFrameData = srcPORDataFrames->frameData( fIdx ); + const int frameCount = totalStressComponentDataFrames->frameCount( stepIdx ); + for ( int fIdx = 0; fIdx < frameCount; fIdx++ ) + { + const std::vector& srcSTFrameData = totalStressComponentDataFrames->frameData( stepIdx, fIdx ); + const std::vector& srcPORFrameData = srcPORDataFrames->frameData( stepIdx, fIdx ); - std::vector& dstFrameData = dstDataFrames->frameData( fIdx ); + std::vector& dstFrameData = dstDataFrames->frameData( stepIdx, fIdx ); - size_t valCount = srcSTFrameData.size(); - dstFrameData.resize( valCount ); + size_t valCount = srcSTFrameData.size(); + dstFrameData.resize( valCount ); - int elementCount = femPart->elementCount(); + int elementCount = femPart->elementCount(); #pragma omp parallel for - for ( int elmIdx = 0; elmIdx < elementCount; ++elmIdx ) - { - RigElementType elmType = femPart->elementType( elmIdx ); - - int elmNodeCount = RigFemTypes::elementNodeCount( femPart->elementType( elmIdx ) ); - - if ( elmType == HEX8P ) + for ( int elmIdx = 0; elmIdx < elementCount; ++elmIdx ) { - for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx ) + RigElementType elmType = femPart->elementType( elmIdx ); + + int elmNodeCount = RigFemTypes::elementNodeCount( femPart->elementType( elmIdx ) ); + + if ( elmType == HEX8P ) { - size_t elmNodResIdx = femPart->elementNodeResultIdx( elmIdx, elmNodIdx ); - if ( elmNodResIdx < srcSTFrameData.size() ) + for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx ) { - int nodeIdx = femPart->nodeIdxFromElementNodeResultIdx( elmNodResIdx ); + size_t elmNodResIdx = femPart->elementNodeResultIdx( elmIdx, elmNodIdx ); + if ( elmNodResIdx < srcSTFrameData.size() ) + { + int nodeIdx = femPart->nodeIdxFromElementNodeResultIdx( elmNodResIdx ); - float por = srcPORFrameData[nodeIdx]; + float por = srcPORFrameData[nodeIdx]; - if ( por == inf || fabs( por ) < 0.01e6 * 1.0e-5 ) - dstFrameData[elmNodResIdx] = inf; - else - dstFrameData[elmNodResIdx] = srcSTFrameData[elmNodResIdx] / por; + if ( por == inf || fabs( por ) < 0.01e6 * 1.0e-5 ) + dstFrameData[elmNodResIdx] = inf; + else + dstFrameData[elmNodResIdx] = srcSTFrameData[elmNodResIdx] / por; + } } } - } - else - { - for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx ) + else { - size_t elmNodResIdx = femPart->elementNodeResultIdx( elmIdx, elmNodIdx ); - if ( elmNodResIdx < dstFrameData.size() ) + for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx ) { - dstFrameData[elmNodResIdx] = inf; + size_t elmNodResIdx = femPart->elementNodeResultIdx( elmIdx, elmNodIdx ); + if ( elmNodResIdx < dstFrameData.size() ) + { + dstFrameData[elmNodResIdx] = inf; + } } } } } - - frameCountProgress->incrementProgress(); + stepCountProgress->incrementProgress(); } } diff --git a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorGamma.h b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorGamma.h index a866966f2b..28938a89e1 100644 --- a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorGamma.h +++ b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorGamma.h @@ -46,5 +46,5 @@ public: const RigFemScalarResultFrames* totalStressComponentDataFrames, const RigFemScalarResultFrames* srcPORDataFrames, RigFemScalarResultFrames* dstDataFrames, - caf::ProgressInfo* frameCountProgress ); + caf::ProgressInfo* stepCountProgress ); }; diff --git a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorInitialPorosity.cpp b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorInitialPorosity.cpp index bc528c6be5..410a3b8fd7 100644 --- a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorInitialPorosity.cpp +++ b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorInitialPorosity.cpp @@ -57,10 +57,10 @@ bool RigFemPartResultCalculatorInitialPorosity::isMatching( const RigFemResultAd RigFemScalarResultFrames* RigFemPartResultCalculatorInitialPorosity::calculate( int partIndex, const RigFemResultAddress& resVarAddr ) { - caf::ProgressInfo frameCountProgress( m_resultCollection->frameCount() * 2, "" ); - frameCountProgress.setProgressDescription( "Calculating Initial Porosity" ); + caf::ProgressInfo stepCountProgress( m_resultCollection->timeStepCount() * 2, "" ); + stepCountProgress.setProgressDescription( "Calculating Initial Porosity" ); - frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); + stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() ); RigFemScalarResultFrames* voidRatioFrames = m_resultCollection->findOrLoadScalarResult( partIndex, @@ -69,62 +69,65 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorInitialPorosity::calculate( RigFemScalarResultFrames* porosityFrames = m_resultCollection->createScalarResult( partIndex, RigFemResultAddress( resVarAddr.resultPosType, resVarAddr.fieldName, "PHI0" ) ); - frameCountProgress.incrementProgress(); + stepCountProgress.incrementProgress(); const RigFemPart* femPart = m_resultCollection->parts()->part( partIndex ); float inf = std::numeric_limits::infinity(); - frameCountProgress.setNextProgressIncrement( 1u ); + stepCountProgress.setNextProgressIncrement( 1u ); - int frameCount = voidRatioFrames->frameCount(); - for ( int fIdx = 0; fIdx < frameCount; ++fIdx ) + const int timeSteps = voidRatioFrames->timeStepCount(); + for ( int stepIdx = 0; stepIdx < timeSteps; stepIdx++ ) { - const std::vector& voidRatioData = voidRatioFrames->frameData( 0 ); - std::vector& porosityFrameData = porosityFrames->frameData( fIdx ); + const int frameCount = voidRatioFrames->frameCount( stepIdx ); + for ( int fIdx = 0; fIdx < frameCount; fIdx++ ) + { + const std::vector& voidRatioData = voidRatioFrames->frameData( 0, 0 ); + std::vector& porosityFrameData = porosityFrames->frameData( stepIdx, fIdx ); - size_t valCount = voidRatioData.size(); - porosityFrameData.resize( valCount ); + size_t valCount = voidRatioData.size(); + porosityFrameData.resize( valCount ); - int elementCount = femPart->elementCount(); + int elementCount = femPart->elementCount(); #pragma omp parallel for - for ( int elmIdx = 0; elmIdx < elementCount; ++elmIdx ) - { - RigElementType elmType = femPart->elementType( elmIdx ); - - int elmNodeCount = RigFemTypes::elementNodeCount( femPart->elementType( elmIdx ) ); - - if ( elmType == HEX8P ) + for ( int elmIdx = 0; elmIdx < elementCount; ++elmIdx ) { - for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx ) + RigElementType elmType = femPart->elementType( elmIdx ); + + int elmNodeCount = RigFemTypes::elementNodeCount( femPart->elementType( elmIdx ) ); + + if ( elmType == HEX8P ) { - size_t elmNodResIdx = femPart->elementNodeResultIdx( elmIdx, elmNodIdx ); - if ( elmNodResIdx < voidRatioData.size() ) + for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx ) { - int nodeIdx = femPart->nodeIdxFromElementNodeResultIdx( elmNodResIdx ); + size_t elmNodResIdx = femPart->elementNodeResultIdx( elmIdx, elmNodIdx ); + if ( elmNodResIdx < voidRatioData.size() ) + { + int nodeIdx = femPart->nodeIdxFromElementNodeResultIdx( elmNodResIdx ); - // Calculate initial porosity - double voidr = voidRatioData[elmNodResIdx]; - double initialPorosity = voidr / ( 1.0 + voidr ); + // Calculate initial porosity + double voidr = voidRatioData[elmNodResIdx]; + double initialPorosity = voidr / ( 1.0 + voidr ); - porosityFrameData[elmNodResIdx] = initialPorosity; + porosityFrameData[elmNodResIdx] = initialPorosity; + } } } - } - else - { - for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx ) + else { - size_t elmNodResIdx = femPart->elementNodeResultIdx( elmIdx, elmNodIdx ); - if ( elmNodResIdx < voidRatioData.size() ) + for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx ) { - porosityFrameData[elmNodResIdx] = inf; + size_t elmNodResIdx = femPart->elementNodeResultIdx( elmIdx, elmNodIdx ); + if ( elmNodResIdx < voidRatioData.size() ) + { + porosityFrameData[elmNodResIdx] = inf; + } } } } } - - frameCountProgress.incrementProgress(); + stepCountProgress.incrementProgress(); } RigFemScalarResultFrames* requestedResultFrames = m_resultCollection->findOrLoadScalarResult( partIndex, resVarAddr ); diff --git a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorKIndices.cpp b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorKIndices.cpp index 25c00127f9..ec3ffd3289 100644 --- a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorKIndices.cpp +++ b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorKIndices.cpp @@ -59,22 +59,22 @@ bool RigFemPartResultCalculatorKIndices::isMatching( const RigFemResultAddress& RigFemScalarResultFrames* RigFemPartResultCalculatorKIndices::calculate( int partIndex, const RigFemResultAddress& resVarAddr ) { - caf::ProgressInfo frameCountProgress( 2, "" ); - frameCountProgress.setProgressDescription( + caf::ProgressInfo stepCountProgress( 2, "" ); + stepCountProgress.setProgressDescription( "Calculating " + QString::fromStdString( resVarAddr.fieldName + ": " + resVarAddr.componentName ) ); RigFemScalarResultFrames* resFrames = m_resultCollection->createScalarResult( partIndex, resVarAddr ); - resFrames->enableAsSingleFrameResult(); + resFrames->enableAsSingleStepResult(); const RigFemPart* femPart = m_resultCollection->parts()->part( partIndex ); - std::vector& dstFrameData = resFrames->frameData( 0 ); + std::vector& dstFrameData = resFrames->frameData( 0, 0 ); const size_t valCount = femPart->elementNodeResultCount(); dstFrameData.resize( valCount, std::numeric_limits::infinity() ); const RigFormationNames* activeFormNames = m_resultCollection->activeFormationNames(); - frameCountProgress.incrementProgress(); + stepCountProgress.incrementProgress(); if ( activeFormNames ) { diff --git a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorMudWeightWindow.cpp b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorMudWeightWindow.cpp index 7fc4f63fe6..c9562a10a5 100644 --- a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorMudWeightWindow.cpp +++ b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorMudWeightWindow.cpp @@ -77,8 +77,8 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorMudWeightWindow::calculate( RimMudWeightWindowParameters::ParameterType::K0_FG, RimMudWeightWindowParameters::ParameterType::OBG0 }; - caf::ProgressInfo frameCountProgress( m_resultCollection->frameCount() * ( 5 + parameterTypes.size() ), "" ); - frameCountProgress.setProgressDescription( "Calculating Mud Weight Window" ); + caf::ProgressInfo stepCountProgress( m_resultCollection->timeStepCount() * ( 5 + parameterTypes.size() ), "" ); + stepCountProgress.setProgressDescription( "Calculating Mud Weight Window" ); std::map parameterFrames; std::map parameterValues; @@ -86,9 +86,9 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorMudWeightWindow::calculate( for ( auto parameterType : parameterTypes ) { auto task = - frameCountProgress.task( "Loading parameter: " + - caf::AppEnum::uiText( parameterType ), - m_resultCollection->frameCount() ); + stepCountProgress.task( "Loading parameter: " + + caf::AppEnum::uiText( parameterType ), + m_resultCollection->timeStepCount() ); loadParameterFramesOrValue( parameterType, partIndex, parameterFrames, parameterValues ); } @@ -105,7 +105,7 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorMudWeightWindow::calculate( // Pore pressure RigFemScalarResultFrames* porePressureDataFrames = nullptr; { - auto task = frameCountProgress.task( "Loading POR-Bar.", m_resultCollection->frameCount() ); + auto task = stepCountProgress.task( "Loading POR-Bar.", m_resultCollection->timeStepCount() ); porePressureDataFrames = m_resultCollection->findOrLoadScalarResult( partIndex, RigFemResultAddress( RIG_ELEMENT_NODAL, "POR-Bar", "" ) ); } @@ -113,7 +113,7 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorMudWeightWindow::calculate( // Stress (ST.S3) RigFemScalarResultFrames* stressDataFrames = nullptr; { - auto task = frameCountProgress.task( "Loading ST.S3", m_resultCollection->frameCount() ); + auto task = stepCountProgress.task( "Loading ST.S3", m_resultCollection->timeStepCount() ); stressDataFrames = m_resultCollection->findOrLoadScalarResult( partIndex, RigFemResultAddress( resVarAddr.resultPosType, "ST", "S3" ) ); @@ -122,7 +122,7 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorMudWeightWindow::calculate( // Initial overburden gradient (ST.S33) RigFemScalarResultFrames* obg0DataFrames = nullptr; { - auto task = frameCountProgress.task( "Loading ST.S33", m_resultCollection->frameCount() ); + auto task = stepCountProgress.task( "Loading ST.S33", m_resultCollection->timeStepCount() ); obg0DataFrames = m_resultCollection->findOrLoadScalarResult( partIndex, RigFemResultAddress( resVarAddr.resultPosType, "ST", "S33" ) ); @@ -156,7 +156,7 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorMudWeightWindow::calculate( if ( PP_NonReservoirType != RimMudWeightWindowParameters::NonReservoirPorePressureType::HYDROSTATIC && !nonReservoirAddress.isEmpty() ) { - auto task = frameCountProgress.task( "Loading non-reservoir pore pressure.", m_resultCollection->frameCount() ); + auto task = stepCountProgress.task( "Loading non-reservoir pore pressure.", m_resultCollection->timeStepCount() ); nonReservoirResultFrames = m_resultCollection->findOrLoadScalarResult( partIndex, RigFemResultAddress( RIG_ELEMENT, @@ -166,294 +166,300 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorMudWeightWindow::calculate( float inf = std::numeric_limits::infinity(); - frameCountProgress.setNextProgressIncrement( 1u ); - frameCountProgress.setProgressDescription( "Calculating Mud Weight Window." ); + stepCountProgress.setNextProgressIncrement( 1u ); + stepCountProgress.setProgressDescription( "Calculating Mud Weight Window." ); - int frameCount = stressDataFrames->frameCount(); - for ( int fIdx = 0; fIdx < frameCount; ++fIdx ) + const int timeSteps = stressDataFrames->timeStepCount(); + for ( int stepIdx = 0; stepIdx < timeSteps; stepIdx++ ) { - const std::vector& porFrameData = porePressureDataFrames->frameData( fIdx ); - if ( porFrameData.empty() ) continue; - - const std::vector& initialPorFrameData = porePressureDataFrames->frameData( 0 ); - if ( initialPorFrameData.empty() ) continue; - - const std::vector& stressFrameData = stressDataFrames->frameData( fIdx ); - const std::vector& obg0FrameData = obg0DataFrames->frameData( 0 ); - - std::vector& mudWeightWindowFrameData = mudWeightWindowFrames->frameData( fIdx ); - std::vector& mudWeightMiddleFrameData = mudWeightMiddleFrames->frameData( fIdx ); - std::vector& upperMudWeightLimitFrameData = upperMudWeightLimitFrames->frameData( fIdx ); - std::vector& lowerMudWeightLimitFrameData = lowerMudWeightLimitFrames->frameData( fIdx ); - - size_t valCount = stressFrameData.size(); - mudWeightWindowFrameData.resize( valCount ); - mudWeightMiddleFrameData.resize( valCount ); - upperMudWeightLimitFrameData.resize( valCount ); - lowerMudWeightLimitFrameData.resize( valCount ); - - int elementCount = femPart->elementCount(); - - std::map> parameterFrameData; - for ( auto parameterType : parameterTypes ) + const int frameCount = stressDataFrames->frameCount( stepIdx ); + for ( int fIdx = 0; fIdx < frameCount; fIdx++ ) { - parameterFrameData[parameterType] = loadDataForFrame( parameterType, parameterFrames, fIdx ); - } + const std::vector& porFrameData = porePressureDataFrames->frameData( stepIdx, fIdx ); + if ( porFrameData.empty() ) continue; - std::vector nonReservoirPP; - if ( nonReservoirResultFrames ) - { - nonReservoirPP = nonReservoirResultFrames->frameData( 0 ); - } + const std::vector& initialPorFrameData = porePressureDataFrames->frameData( 0, 0 ); + if ( initialPorFrameData.empty() ) continue; - // Load stress - RigFemResultAddress stressResAddr( RIG_ELEMENT_NODAL, "ST", "" ); - std::vector vertexStressesFloat = m_resultCollection->tensors( stressResAddr, partIndex, fIdx ); + const std::vector& stressFrameData = stressDataFrames->frameData( stepIdx, fIdx ); + const std::vector& obg0FrameData = obg0DataFrames->frameData( 0, 0 ); - std::vector vertexStresses; - vertexStresses.reserve( vertexStressesFloat.size() ); - for ( const caf::Ten3f& floatTensor : vertexStressesFloat ) - { - vertexStresses.push_back( caf::Ten3d( floatTensor ) ); - } + std::vector& mudWeightWindowFrameData = mudWeightWindowFrames->frameData( stepIdx, fIdx ); + std::vector& mudWeightMiddleFrameData = mudWeightMiddleFrames->frameData( stepIdx, fIdx ); + std::vector& upperMudWeightLimitFrameData = upperMudWeightLimitFrames->frameData( stepIdx, fIdx ); + std::vector& lowerMudWeightLimitFrameData = lowerMudWeightLimitFrames->frameData( stepIdx, fIdx ); + + size_t valCount = stressFrameData.size(); + mudWeightWindowFrameData.resize( valCount ); + mudWeightMiddleFrameData.resize( valCount ); + upperMudWeightLimitFrameData.resize( valCount ); + lowerMudWeightLimitFrameData.resize( valCount ); + + int elementCount = femPart->elementCount(); + + std::map> parameterFrameData; + for ( auto parameterType : parameterTypes ) + { + parameterFrameData[parameterType] = loadDataForFrame( parameterType, parameterFrames, stepIdx, fIdx ); + } + + std::vector nonReservoirPP; + if ( nonReservoirResultFrames ) + { + nonReservoirPP = nonReservoirResultFrames->frameData( 0, 0 ); + } + + // Load stress + RigFemResultAddress stressResAddr( RIG_ELEMENT_NODAL, "ST", "" ); + std::vector vertexStressesFloat = + m_resultCollection->tensors( stressResAddr, partIndex, stepIdx, fIdx ); + + std::vector vertexStresses; + vertexStresses.reserve( vertexStressesFloat.size() ); + for ( const caf::Ten3f& floatTensor : vertexStressesFloat ) + { + vertexStresses.push_back( caf::Ten3d( floatTensor ) ); + } #pragma omp parallel for - for ( int elmIdx = 0; elmIdx < elementCount; ++elmIdx ) - { - bool isHexahedron = femPart->isHexahedron( elmIdx ); - int elmNodeCount = RigFemTypes::elementNodeCount( femPart->elementType( elmIdx ) ); - - // Use hydrostatic pressure from cell centroid. - // Use centroid to avoid intra-element differences - cvf::Vec3d cellCentroid = femPartGrid->cellCentroid( elmIdx ); - double cellCentroidTvdRKB = -cellCentroid.z() + airGap; - double waterDensityGCM3 = 1.03; - double hydroStaticPressure = - RigGeoMechWellLogExtractor::hydroStaticPorePressureAtDepth( cellCentroidTvdRKB, waterDensityGCM3 ); - double hydroStaticPressureForNormalization = - RigGeoMechWellLogExtractor::hydroStaticPorePressureAtDepth( cellCentroidTvdRKB, 1.0 ); - - if ( isHexahedron && hydroStaticPressureForNormalization != 0.0 ) + for ( int elmIdx = 0; elmIdx < elementCount; ++elmIdx ) { - double wellPathDeviation = getValueForElement( RimMudWeightWindowParameters::ParameterType::WELL_DEVIATION, + bool isHexahedron = femPart->isHexahedron( elmIdx ); + int elmNodeCount = RigFemTypes::elementNodeCount( femPart->elementType( elmIdx ) ); + + // Use hydrostatic pressure from cell centroid. + // Use centroid to avoid intra-element differences + cvf::Vec3d cellCentroid = femPartGrid->cellCentroid( elmIdx ); + double cellCentroidTvdRKB = -cellCentroid.z() + airGap; + double waterDensityGCM3 = 1.03; + double hydroStaticPressure = + RigGeoMechWellLogExtractor::hydroStaticPorePressureAtDepth( cellCentroidTvdRKB, waterDensityGCM3 ); + double hydroStaticPressureForNormalization = + RigGeoMechWellLogExtractor::hydroStaticPorePressureAtDepth( cellCentroidTvdRKB, 1.0 ); + + if ( isHexahedron && hydroStaticPressureForNormalization != 0.0 ) + { + double wellPathDeviation = + getValueForElement( RimMudWeightWindowParameters::ParameterType::WELL_DEVIATION, + parameterFrameData, + parameterValues, + elmIdx ); + + double wellPathAzimuth = getValueForElement( RimMudWeightWindowParameters::ParameterType::WELL_AZIMUTH, + parameterFrameData, + parameterValues, + elmIdx ); + + double ucsBar = getValueForElement( RimMudWeightWindowParameters::ParameterType::UCS, + parameterFrameData, + parameterValues, + elmIdx ); + + double poissonsRatio = getValueForElement( RimMudWeightWindowParameters::ParameterType::POISSONS_RATIO, parameterFrameData, parameterValues, elmIdx ); - double wellPathAzimuth = getValueForElement( RimMudWeightWindowParameters::ParameterType::WELL_AZIMUTH, - parameterFrameData, - parameterValues, - elmIdx ); + double K0_FG = getValueForElement( RimMudWeightWindowParameters::ParameterType::K0_FG, + parameterFrameData, + parameterValues, + elmIdx ); - double ucsBar = getValueForElement( RimMudWeightWindowParameters::ParameterType::UCS, - parameterFrameData, - parameterValues, - elmIdx ); - - double poissonsRatio = getValueForElement( RimMudWeightWindowParameters::ParameterType::POISSONS_RATIO, - parameterFrameData, - parameterValues, - elmIdx ); - - double K0_FG = getValueForElement( RimMudWeightWindowParameters::ParameterType::K0_FG, + double OBG0 = 0.0; + if ( !OBG0FromGrid ) + { + OBG0 = getValueForElement( RimMudWeightWindowParameters::ParameterType::OBG0, parameterFrameData, parameterValues, elmIdx ); + } - double OBG0 = 0.0; - if ( !OBG0FromGrid ) - { - OBG0 = getValueForElement( RimMudWeightWindowParameters::ParameterType::OBG0, - parameterFrameData, - parameterValues, - elmIdx ); - } - - for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx ) - { - size_t elmNodResIdx = femPart->elementNodeResultIdx( elmIdx, elmNodIdx ); - if ( elmNodResIdx < stressFrameData.size() ) + for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx ) { - // Pore pressure (unit: Bar) - float porePressureBar = porFrameData[elmNodResIdx]; - float initialPorePressureBar = initialPorFrameData[elmNodResIdx]; - - // Initial overburden gradient - if ( OBG0FromGrid ) + size_t elmNodResIdx = femPart->elementNodeResultIdx( elmIdx, elmNodIdx ); + if ( elmNodResIdx < stressFrameData.size() ) { - OBG0 = obg0FrameData[elmNodResIdx]; - } + // Pore pressure (unit: Bar) + float porePressureBar = porFrameData[elmNodResIdx]; + float initialPorePressureBar = initialPorFrameData[elmNodResIdx]; - // FG is for sands, SFG for shale. Sands has valid PP, shale does not. - bool isSand = ( porePressureBar != inf ); + // Initial overburden gradient + if ( OBG0FromGrid ) + { + OBG0 = obg0FrameData[elmNodResIdx]; + } + + // FG is for sands, SFG for shale. Sands has valid PP, shale does not. + bool isSand = ( porePressureBar != inf ); - // - if ( porePressureBar == inf ) - { // - if ( PP_NonReservoirType == - RimMudWeightWindowParameters::NonReservoirPorePressureType::HYDROSTATIC ) + if ( porePressureBar == inf ) { - porePressureBar = hydroStaticPressure * hydrostaticMultiplier; - initialPorePressureBar = hydroStaticPressure * hydrostaticMultiplier; + // + if ( PP_NonReservoirType == + RimMudWeightWindowParameters::NonReservoirPorePressureType::HYDROSTATIC ) + { + porePressureBar = hydroStaticPressure * hydrostaticMultiplier; + initialPorePressureBar = hydroStaticPressure * hydrostaticMultiplier; + } + else if ( !nonReservoirPP.empty() ) + { + // Get from element table + porePressureBar = nonReservoirPP[elmIdx]; + initialPorePressureBar = nonReservoirPP[elmIdx]; + } } - else if ( !nonReservoirPP.empty() ) - { - // Get from element table - porePressureBar = nonReservoirPP[elmIdx]; - initialPorePressureBar = nonReservoirPP[elmIdx]; - } - } - caf::Ten3d segmentStress = caf::Ten3d( vertexStressesFloat[elmNodResIdx] ); + caf::Ten3d segmentStress = caf::Ten3d( vertexStressesFloat[elmNodResIdx] ); - cvf::Vec3d wellPathTangent = calculateWellPathTangent( wellPathAzimuth, wellPathDeviation ); - caf::Ten3d wellPathStressFloat = - RigGeoMechWellLogExtractor::transformTensorToWellPathOrientation( wellPathTangent, - segmentStress ); - caf::Ten3d wellPathStressDouble( wellPathStressFloat ); + cvf::Vec3d wellPathTangent = calculateWellPathTangent( wellPathAzimuth, wellPathDeviation ); + caf::Ten3d wellPathStressFloat = + RigGeoMechWellLogExtractor::transformTensorToWellPathOrientation( wellPathTangent, + segmentStress ); + caf::Ten3d wellPathStressDouble( wellPathStressFloat ); - // Calculate upper limit - float upperLimit = inf; - if ( upperLimitParameter == RimMudWeightWindowParameters::UpperLimitType::FG && isSand ) - { - RigGeoMechBoreHoleStressCalculator sigmaCalculator( wellPathStressDouble, - porePressureBar, - poissonsRatio, - ucsBar, - 32 ); - upperLimit = sigmaCalculator.solveFractureGradient() / hydroStaticPressureForNormalization; - } - else if ( upperLimitParameter == RimMudWeightWindowParameters::UpperLimitType::SH_MIN ) - { - upperLimit = stressFrameData[elmNodResIdx] / hydroStaticPressureForNormalization; - } - - // - if ( upperLimit == inf ) - { - if ( fractureGradientCalculationType == - RimMudWeightWindowParameters::FractureGradientCalculationType::DERIVED_FROM_K0FG ) - { - float PP0 = initialPorePressureBar / hydroStaticPressureForNormalization; - float normalizedOBG0 = OBG0 / hydroStaticPressureForNormalization; - upperLimit = K0_FG * ( normalizedOBG0 - PP0 ) + PP0; - } - else - { - upperLimit = - stressFrameData[elmNodResIdx] * shMultiplier / hydroStaticPressureForNormalization; - } - } - - // Calculate lower limit - float lowerLimit = inf; - if ( lowerLimitParameter == RimMudWeightWindowParameters::LowerLimitType::PORE_PRESSURE ) - { - lowerLimit = porePressureBar; - } - else if ( lowerLimitParameter == - RimMudWeightWindowParameters::LowerLimitType::MAX_OF_PORE_PRESSURE_AND_SFG ) - { - if ( isSand ) - { - lowerLimit = porePressureBar; - } - else + // Calculate upper limit + float upperLimit = inf; + if ( upperLimitParameter == RimMudWeightWindowParameters::UpperLimitType::FG && isSand ) { RigGeoMechBoreHoleStressCalculator sigmaCalculator( wellPathStressDouble, - hydroStaticPressureForNormalization, + porePressureBar, poissonsRatio, ucsBar, 32 ); - - double SFG = sigmaCalculator.solveStassiDalia(); - lowerLimit = std::max( porePressureBar, static_cast( SFG ) ); + upperLimit = sigmaCalculator.solveFractureGradient() / hydroStaticPressureForNormalization; } + else if ( upperLimitParameter == RimMudWeightWindowParameters::UpperLimitType::SH_MIN ) + { + upperLimit = stressFrameData[elmNodResIdx] / hydroStaticPressureForNormalization; + } + + // + if ( upperLimit == inf ) + { + if ( fractureGradientCalculationType == + RimMudWeightWindowParameters::FractureGradientCalculationType::DERIVED_FROM_K0FG ) + { + float PP0 = initialPorePressureBar / hydroStaticPressureForNormalization; + float normalizedOBG0 = OBG0 / hydroStaticPressureForNormalization; + upperLimit = K0_FG * ( normalizedOBG0 - PP0 ) + PP0; + } + else + { + upperLimit = stressFrameData[elmNodResIdx] * shMultiplier / + hydroStaticPressureForNormalization; + } + } + + // Calculate lower limit + float lowerLimit = inf; + if ( lowerLimitParameter == RimMudWeightWindowParameters::LowerLimitType::PORE_PRESSURE ) + { + lowerLimit = porePressureBar; + } + else if ( lowerLimitParameter == + RimMudWeightWindowParameters::LowerLimitType::MAX_OF_PORE_PRESSURE_AND_SFG ) + { + if ( isSand ) + { + lowerLimit = porePressureBar; + } + else + { + RigGeoMechBoreHoleStressCalculator sigmaCalculator( wellPathStressDouble, + hydroStaticPressureForNormalization, + poissonsRatio, + ucsBar, + 32 ); + + double SFG = sigmaCalculator.solveStassiDalia(); + lowerLimit = std::max( porePressureBar, static_cast( SFG ) ); + } + } + + // Upper limit values have already been normalized where appropriate + upperMudWeightLimitFrameData[elmNodResIdx] = upperLimit; + + // Normalize by hydrostatic pore pressure + lowerMudWeightLimitFrameData[elmNodResIdx] = lowerLimit / hydroStaticPressureForNormalization; } - - // Upper limit values have already been normalized where appropriate - upperMudWeightLimitFrameData[elmNodResIdx] = upperLimit; - - // Normalize by hydrostatic pore pressure - lowerMudWeightLimitFrameData[elmNodResIdx] = lowerLimit / hydroStaticPressureForNormalization; } } - } - else - { - for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx ) + else { - size_t elmNodResIdx = femPart->elementNodeResultIdx( elmIdx, elmNodIdx ); - if ( elmNodResIdx < stressFrameData.size() ) + for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx ) { - mudWeightWindowFrameData[elmNodResIdx] = inf; - mudWeightMiddleFrameData[elmNodResIdx] = inf; - upperMudWeightLimitFrameData[elmNodResIdx] = inf; - lowerMudWeightLimitFrameData[elmNodResIdx] = inf; + size_t elmNodResIdx = femPart->elementNodeResultIdx( elmIdx, elmNodIdx ); + if ( elmNodResIdx < stressFrameData.size() ) + { + mudWeightWindowFrameData[elmNodResIdx] = inf; + mudWeightMiddleFrameData[elmNodResIdx] = inf; + upperMudWeightLimitFrameData[elmNodResIdx] = inf; + lowerMudWeightLimitFrameData[elmNodResIdx] = inf; + } } } } - } - size_t kRefLayer = m_resultCollection->referenceLayerMudWeightWindow(); + size_t kRefLayer = m_resultCollection->referenceLayerMudWeightWindow(); #pragma omp parallel for - for ( int elmIdx = 0; elmIdx < elementCount; ++elmIdx ) - { - bool isHexahedron = femPart->isHexahedron( elmIdx ); - - int elmNodeCount = RigFemTypes::elementNodeCount( femPart->elementType( elmIdx ) ); - - size_t i, j, k; - bool validIndex = femPartGrid->ijkFromCellIndex( elmIdx, &i, &j, &k ); - size_t kMin = std::min( k, kRefLayer ); - size_t kMax = std::max( k, kRefLayer ); - - if ( isHexahedron && validIndex ) + for ( int elmIdx = 0; elmIdx < elementCount; ++elmIdx ) { - for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx ) + bool isHexahedron = femPart->isHexahedron( elmIdx ); + + int elmNodeCount = RigFemTypes::elementNodeCount( femPart->elementType( elmIdx ) ); + + size_t i, j, k; + bool validIndex = femPartGrid->ijkFromCellIndex( elmIdx, &i, &j, &k ); + size_t kMin = std::min( k, kRefLayer ); + size_t kMax = std::max( k, kRefLayer ); + + if ( isHexahedron && validIndex ) { - size_t elmNodResIdx = femPart->elementNodeResultIdx( elmIdx, elmNodIdx ); - - float maxLowerMudWeightLimit = lowerMudWeightLimitFrameData[elmNodResIdx]; - float minUpperMudWeightLimit = upperMudWeightLimitFrameData[elmNodResIdx]; - - for ( size_t currentK = kMin; currentK < kMax; currentK++ ) + for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx ) { - size_t kElmIdx = femPartGrid->cellIndexFromIJK( i, j, currentK ); - if ( kElmIdx != cvf::UNDEFINED_SIZE_T && femPart->isHexahedron( kElmIdx ) ) + size_t elmNodResIdx = femPart->elementNodeResultIdx( elmIdx, elmNodIdx ); + + float maxLowerMudWeightLimit = lowerMudWeightLimitFrameData[elmNodResIdx]; + float minUpperMudWeightLimit = upperMudWeightLimitFrameData[elmNodResIdx]; + + for ( size_t currentK = kMin; currentK < kMax; currentK++ ) { - size_t kElmNodResIdx = femPart->elementNodeResultIdx( static_cast( kElmIdx ), elmNodIdx ); - - float currentLowerMudWeightLimit = lowerMudWeightLimitFrameData[kElmNodResIdx]; - if ( currentLowerMudWeightLimit > maxLowerMudWeightLimit ) + size_t kElmIdx = femPartGrid->cellIndexFromIJK( i, j, currentK ); + if ( kElmIdx != cvf::UNDEFINED_SIZE_T && femPart->isHexahedron( kElmIdx ) ) { - maxLowerMudWeightLimit = currentLowerMudWeightLimit; - } + size_t kElmNodResIdx = + femPart->elementNodeResultIdx( static_cast( kElmIdx ), elmNodIdx ); - float currentUpperMudWeightLimit = upperMudWeightLimitFrameData[kElmNodResIdx]; - if ( currentUpperMudWeightLimit < minUpperMudWeightLimit ) - { - minUpperMudWeightLimit = currentUpperMudWeightLimit; + float currentLowerMudWeightLimit = lowerMudWeightLimitFrameData[kElmNodResIdx]; + if ( currentLowerMudWeightLimit > maxLowerMudWeightLimit ) + { + maxLowerMudWeightLimit = currentLowerMudWeightLimit; + } + + float currentUpperMudWeightLimit = upperMudWeightLimitFrameData[kElmNodResIdx]; + if ( currentUpperMudWeightLimit < minUpperMudWeightLimit ) + { + minUpperMudWeightLimit = currentUpperMudWeightLimit; + } } } - } - float mudWeightWindow = minUpperMudWeightLimit - maxLowerMudWeightLimit; - mudWeightWindowFrameData[elmNodResIdx] = mudWeightWindow; + float mudWeightWindow = minUpperMudWeightLimit - maxLowerMudWeightLimit; + mudWeightWindowFrameData[elmNodResIdx] = mudWeightWindow; - float mudWeightMiddle = inf; - if ( mudWeightWindow > 0.0 ) - { - mudWeightMiddle = maxLowerMudWeightLimit + mudWeightWindow / 2.0; + float mudWeightMiddle = inf; + if ( mudWeightWindow > 0.0 ) + { + mudWeightMiddle = maxLowerMudWeightLimit + mudWeightWindow / 2.0; + } + mudWeightMiddleFrameData[elmNodResIdx] = mudWeightMiddle; } - mudWeightMiddleFrameData[elmNodResIdx] = mudWeightMiddle; } } } - - frameCountProgress.incrementProgress(); + stepCountProgress.incrementProgress(); } RigFemScalarResultFrames* requestedResultFrames = m_resultCollection->findOrLoadScalarResult( partIndex, resVarAddr ); @@ -499,13 +505,14 @@ void RigFemPartResultCalculatorMudWeightWindow::loadParameterFramesOrValue( std::vector RigFemPartResultCalculatorMudWeightWindow::loadDataForFrame( RimMudWeightWindowParameters::ParameterType parameterType, std::map& parameterFrames, + int stepIndex, int frameIndex ) { auto it = parameterFrames.find( parameterType ); if ( it != parameterFrames.end() ) { RigFemScalarResultFrames* frame = it->second; - std::vector dataForFrame = frame->frameData( frameIndex ); + std::vector dataForFrame = frame->frameData( stepIndex, frameIndex ); return dataForFrame; } else diff --git a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorMudWeightWindow.h b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorMudWeightWindow.h index 489d244cfd..d6b3a89f5d 100644 --- a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorMudWeightWindow.h +++ b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorMudWeightWindow.h @@ -52,6 +52,7 @@ private: static std::vector loadDataForFrame( RimMudWeightWindowParameters::ParameterType parameterType, std::map& parameterFrames, + int stepIndex, int frameIndex ); static float diff --git a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorNE.cpp b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorNE.cpp index 3f35bf0148..f405a141b0 100644 --- a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorNE.cpp +++ b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorNE.cpp @@ -59,10 +59,10 @@ bool RigFemPartResultCalculatorNE::isMatching( const RigFemResultAddress& resVar //-------------------------------------------------------------------------------------------------- RigFemScalarResultFrames* RigFemPartResultCalculatorNE::calculate( int partIndex, const RigFemResultAddress& resVarAddr ) { - caf::ProgressInfo frameCountProgress( m_resultCollection->frameCount() * 2, "" ); - frameCountProgress.setProgressDescription( + caf::ProgressInfo stepCountProgress( m_resultCollection->timeStepCount() * 2, "" ); + stepCountProgress.setProgressDescription( "Calculating " + QString::fromStdString( resVarAddr.fieldName + ": " + resVarAddr.componentName ) ); - frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); + stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() ); RigFemScalarResultFrames* srcDataFrames = m_resultCollection->findOrLoadScalarResult( partIndex, @@ -71,23 +71,26 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorNE::calculate( int partIndex resVarAddr.componentName ) ); RigFemScalarResultFrames* dstDataFrames = m_resultCollection->createScalarResult( partIndex, resVarAddr ); - frameCountProgress.incrementProgress(); + stepCountProgress.incrementProgress(); - int frameCount = srcDataFrames->frameCount(); - for ( int fIdx = 0; fIdx < frameCount; ++fIdx ) + const int timeSteps = srcDataFrames->timeStepCount(); + for ( int stepIdx = 0; stepIdx < timeSteps; stepIdx++ ) { - const std::vector& srcFrameData = srcDataFrames->frameData( fIdx ); - std::vector& dstFrameData = dstDataFrames->frameData( fIdx ); - size_t valCount = srcFrameData.size(); - dstFrameData.resize( valCount ); + const int frameCount = srcDataFrames->frameCount( stepIdx ); + for ( int fIdx = 0; fIdx < frameCount; fIdx++ ) + { + const std::vector& srcFrameData = srcDataFrames->frameData( stepIdx, fIdx ); + std::vector& dstFrameData = dstDataFrames->frameData( stepIdx, fIdx ); + size_t valCount = srcFrameData.size(); + dstFrameData.resize( valCount ); #pragma omp parallel for - for ( long vIdx = 0; vIdx < static_cast( valCount ); ++vIdx ) - { - dstFrameData[vIdx] = -srcFrameData[vIdx]; + for ( long vIdx = 0; vIdx < static_cast( valCount ); ++vIdx ) + { + dstFrameData[vIdx] = -srcFrameData[vIdx]; + } } - - frameCountProgress.incrementProgress(); + stepCountProgress.incrementProgress(); } return dstDataFrames; diff --git a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorNodalGradients.cpp b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorNodalGradients.cpp index 522f823e69..790bb7517c 100644 --- a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorNodalGradients.cpp +++ b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorNodalGradients.cpp @@ -62,111 +62,116 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorNodalGradients::calculate( i CVF_ASSERT( resVarAddr.fieldName == "POR-Bar" ); CVF_ASSERT( resVarAddr.componentName == "X" || resVarAddr.componentName == "Y" || resVarAddr.componentName == "Z" ); - caf::ProgressInfo frameCountProgress( m_resultCollection->frameCount() * 5, "" ); - frameCountProgress.setProgressDescription( + caf::ProgressInfo stepCountProgress( m_resultCollection->timeStepCount() * 5, "" ); + stepCountProgress.setProgressDescription( "Calculating gradient: " + QString::fromStdString( resVarAddr.fieldName + ": " + resVarAddr.componentName ) ); - frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); + stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() ); RigFemScalarResultFrames* dataFramesX = m_resultCollection->createScalarResult( partIndex, RigFemResultAddress( RIG_NODAL, resVarAddr.fieldName, "X" ) ); - frameCountProgress.incrementProgress(); - frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); + stepCountProgress.incrementProgress(); + stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() ); RigFemScalarResultFrames* dataFramesY = m_resultCollection->createScalarResult( partIndex, RigFemResultAddress( RIG_NODAL, resVarAddr.fieldName, "Y" ) ); - frameCountProgress.incrementProgress(); - frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); + stepCountProgress.incrementProgress(); + stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() ); RigFemScalarResultFrames* dataFramesZ = m_resultCollection->createScalarResult( partIndex, RigFemResultAddress( RIG_NODAL, resVarAddr.fieldName, "Z" ) ); - frameCountProgress.incrementProgress(); - frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); + stepCountProgress.incrementProgress(); + stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() ); RigFemResultAddress porResultAddr( RIG_NODAL, "POR-Bar", "" ); RigFemScalarResultFrames* srcDataFrames = m_resultCollection->findOrLoadScalarResult( partIndex, porResultAddr ); - frameCountProgress.incrementProgress(); + stepCountProgress.incrementProgress(); const RigFemPart* femPart = m_resultCollection->parts()->part( partIndex ); - float inf = std::numeric_limits::infinity(); + constexpr float inf = std::numeric_limits::infinity(); const std::vector& nodeCoords = femPart->nodes().coordinates; size_t nodeCount = femPart->nodes().nodeIds.size(); - int frameCount = srcDataFrames->frameCount(); - for ( int fIdx = 0; fIdx < frameCount; ++fIdx ) + const int timeSteps = srcDataFrames->timeStepCount(); + for ( int stepIdx = 0; stepIdx < timeSteps; stepIdx++ ) { - const std::vector& srcFrameData = srcDataFrames->frameData( fIdx ); - std::vector& dstFrameDataX = dataFramesX->frameData( fIdx ); - std::vector& dstFrameDataY = dataFramesY->frameData( fIdx ); - std::vector& dstFrameDataZ = dataFramesZ->frameData( fIdx ); + const int frameCount = srcDataFrames->frameCount( stepIdx ); + for ( int fIdx = 0; fIdx < frameCount; fIdx++ ) + { + const std::vector& srcFrameData = srcDataFrames->frameData( stepIdx, fIdx ); + std::vector& dstFrameDataX = dataFramesX->frameData( stepIdx, fIdx ); + std::vector& dstFrameDataY = dataFramesY->frameData( stepIdx, fIdx ); + std::vector& dstFrameDataZ = dataFramesZ->frameData( stepIdx, fIdx ); - if ( srcFrameData.empty() ) continue; // Create empty results if we have no POR result. + if ( srcFrameData.empty() ) continue; // Create empty results if we have no POR result. - size_t valCount = femPart->elementNodeResultCount(); - dstFrameDataX.resize( valCount, inf ); - dstFrameDataY.resize( valCount, inf ); - dstFrameDataZ.resize( valCount, inf ); + size_t valCount = femPart->elementNodeResultCount(); + dstFrameDataX.resize( valCount, inf ); + dstFrameDataY.resize( valCount, inf ); + dstFrameDataZ.resize( valCount, inf ); - int elementCount = femPart->elementCount(); + int elementCount = femPart->elementCount(); #pragma omp parallel for schedule( dynamic ) - for ( long nodeIdx = 0; nodeIdx < static_cast( nodeCount ); nodeIdx++ ) - { - const std::vector elements = femPart->elementsUsingNode( nodeIdx ); - - // Compute the average of the elements contributing to this node - cvf::Vec3d result = cvf::Vec3d::ZERO; - int nValidElements = 0; - for ( int elmIdx : elements ) + for ( long nodeIdx = 0; nodeIdx < static_cast( nodeCount ); nodeIdx++ ) { - RigElementType elmType = femPart->elementType( elmIdx ); - if ( elmType == HEX8P ) + const std::vector elements = femPart->elementsUsingNode( nodeIdx ); + + // Compute the average of the elements contributing to this node + cvf::Vec3d result = cvf::Vec3d::ZERO; + int nValidElements = 0; + for ( int elmIdx : elements ) { - // Find the corner coordinates and values for the node - std::array hexCorners; - std::array cornerValues; - - int elmNodeCount = RigFemTypes::elementNodeCount( elmType ); - for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx ) + RigElementType elmType = femPart->elementType( elmIdx ); + if ( elmType == HEX8P ) { - size_t elmNodResIdx = femPart->elementNodeResultIdx( elmIdx, elmNodIdx ); - size_t resultValueIdx = femPart->resultValueIdxFromResultPosType( RIG_NODAL, elmIdx, elmNodIdx ); + // Find the corner coordinates and values for the node + std::array hexCorners; + std::array cornerValues; - cornerValues[elmNodIdx] = srcFrameData[resultValueIdx]; - hexCorners[elmNodIdx] = cvf::Vec3d( nodeCoords[resultValueIdx] ); - } - - std::array gradients = RigHexGradientTools::gradients( hexCorners, cornerValues ); - - for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx ) - { - size_t elmNodResIdx = femPart->elementNodeResultIdx( elmIdx, elmNodIdx ); - size_t resultValueIdx = femPart->resultValueIdxFromResultPosType( RIG_NODAL, elmIdx, elmNodIdx ); - // Only use the gradient for particular corner corresponding to the node - if ( static_cast( nodeIdx ) == resultValueIdx ) + int elmNodeCount = RigFemTypes::elementNodeCount( elmType ); + for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx ) { - result.add( gradients[elmNodIdx] ); - } - } + size_t elmNodResIdx = femPart->elementNodeResultIdx( elmIdx, elmNodIdx ); + size_t resultValueIdx = + femPart->resultValueIdxFromResultPosType( RIG_NODAL, elmIdx, elmNodIdx ); - nValidElements++; + cornerValues[elmNodIdx] = srcFrameData[resultValueIdx]; + hexCorners[elmNodIdx] = cvf::Vec3d( nodeCoords[resultValueIdx] ); + } + + std::array gradients = RigHexGradientTools::gradients( hexCorners, cornerValues ); + + for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx ) + { + size_t elmNodResIdx = femPart->elementNodeResultIdx( elmIdx, elmNodIdx ); + size_t resultValueIdx = + femPart->resultValueIdxFromResultPosType( RIG_NODAL, elmIdx, elmNodIdx ); + // Only use the gradient for particular corner corresponding to the node + if ( static_cast( nodeIdx ) == resultValueIdx ) + { + result.add( gradients[elmNodIdx] ); + } + } + + nValidElements++; + } + } + + if ( nValidElements > 0 ) + { + // Round very small values to zero to avoid ugly coloring when gradients + // are dominated by floating point math artifacts. + double epsilon = 1.0e-6; + result /= static_cast( nValidElements ); + dstFrameDataX[nodeIdx] = std::abs( result.x() ) > epsilon ? result.x() : 0.0; + dstFrameDataY[nodeIdx] = std::abs( result.y() ) > epsilon ? result.y() : 0.0; + dstFrameDataZ[nodeIdx] = std::abs( result.z() ) > epsilon ? result.z() : 0.0; } } - - if ( nValidElements > 0 ) - { - // Round very small values to zero to avoid ugly coloring when gradients - // are dominated by floating point math artifacts. - double epsilon = 1.0e-6; - result /= static_cast( nValidElements ); - dstFrameDataX[nodeIdx] = std::abs( result.x() ) > epsilon ? result.x() : 0.0; - dstFrameDataY[nodeIdx] = std::abs( result.y() ) > epsilon ? result.y() : 0.0; - dstFrameDataZ[nodeIdx] = std::abs( result.z() ) > epsilon ? result.z() : 0.0; - } } - - frameCountProgress.incrementProgress(); + stepCountProgress.incrementProgress(); } RigFemScalarResultFrames* requestedGradient = m_resultCollection->findOrLoadScalarResult( partIndex, resVarAddr ); diff --git a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorNormalSE.cpp b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorNormalSE.cpp index ad77723307..1854c9fc9b 100644 --- a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorNormalSE.cpp +++ b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorNormalSE.cpp @@ -58,69 +58,71 @@ bool RigFemPartResultCalculatorNormalSE::isMatching( const RigFemResultAddress& RigFemScalarResultFrames* RigFemPartResultCalculatorNormalSE::calculate( int partIndex, const RigFemResultAddress& resVarAddr ) { - caf::ProgressInfo frameCountProgress( m_resultCollection->frameCount() * 3, "" ); - frameCountProgress.setProgressDescription( + caf::ProgressInfo stepCountProgress( m_resultCollection->timeStepCount() * 3, "" ); + stepCountProgress.setProgressDescription( "Calculating " + QString::fromStdString( resVarAddr.fieldName + ": " + resVarAddr.componentName ) ); - frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); + stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() ); RigFemScalarResultFrames* srcDataFrames = m_resultCollection->findOrLoadScalarResult( partIndex, RigFemResultAddress( resVarAddr.resultPosType, "S-Bar", resVarAddr.componentName ) ); - frameCountProgress.incrementProgress(); - frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); + stepCountProgress.incrementProgress(); + stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() ); RigFemScalarResultFrames* dstDataFrames = m_resultCollection->createScalarResult( partIndex, resVarAddr ); - frameCountProgress.incrementProgress(); + stepCountProgress.incrementProgress(); const RigFemPart* femPart = m_resultCollection->parts()->part( partIndex ); - float inf = std::numeric_limits::infinity(); + constexpr float inf = std::numeric_limits::infinity(); - int frameCount = srcDataFrames->frameCount(); - - for ( int fIdx = 0; fIdx < frameCount; ++fIdx ) + const int timeSteps = srcDataFrames->timeStepCount(); + for ( int stepIdx = 0; stepIdx < timeSteps; stepIdx++ ) { - const std::vector& srcSFrameData = srcDataFrames->frameData( fIdx ); - std::vector& dstFrameData = dstDataFrames->frameData( fIdx ); - size_t valCount = srcSFrameData.size(); - dstFrameData.resize( valCount ); + const int frameCount = srcDataFrames->frameCount( stepIdx ); + for ( int fIdx = 0; fIdx < frameCount; fIdx++ ) + { + const std::vector& srcSFrameData = srcDataFrames->frameData( stepIdx, fIdx ); + std::vector& dstFrameData = dstDataFrames->frameData( stepIdx, fIdx ); + size_t valCount = srcSFrameData.size(); + dstFrameData.resize( valCount ); - int elementCount = femPart->elementCount(); + int elementCount = femPart->elementCount(); #pragma omp parallel for - for ( int elmIdx = 0; elmIdx < elementCount; ++elmIdx ) - { - RigElementType elmType = femPart->elementType( elmIdx ); - - int elmNodeCount = RigFemTypes::elementNodeCount( femPart->elementType( elmIdx ) ); - - if ( elmType == HEX8P ) + for ( int elmIdx = 0; elmIdx < elementCount; ++elmIdx ) { - for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx ) + RigElementType elmType = femPart->elementType( elmIdx ); + + int elmNodeCount = RigFemTypes::elementNodeCount( femPart->elementType( elmIdx ) ); + + if ( elmType == HEX8P ) { - size_t elmNodResIdx = femPart->elementNodeResultIdx( elmIdx, elmNodIdx ); - if ( elmNodResIdx < srcSFrameData.size() ) + for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx ) { - // SE from abacus in opposite direction - dstFrameData[elmNodResIdx] = -srcSFrameData[elmNodResIdx]; + size_t elmNodResIdx = femPart->elementNodeResultIdx( elmIdx, elmNodIdx ); + if ( elmNodResIdx < srcSFrameData.size() ) + { + // SE from abacus in opposite direction + dstFrameData[elmNodResIdx] = -srcSFrameData[elmNodResIdx]; + } } } - } - else - { - for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx ) + else { - size_t elmNodResIdx = femPart->elementNodeResultIdx( elmIdx, elmNodIdx ); - if ( elmNodResIdx < dstFrameData.size() ) + for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx ) { - dstFrameData[elmNodResIdx] = inf; + size_t elmNodResIdx = femPart->elementNodeResultIdx( elmIdx, elmNodIdx ); + if ( elmNodResIdx < dstFrameData.size() ) + { + dstFrameData[elmNodResIdx] = inf; + } } } } } - - frameCountProgress.incrementProgress(); + stepCountProgress.incrementProgress(); } return dstDataFrames; diff --git a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorNormalST.cpp b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorNormalST.cpp index 2f0155f4f1..880b71fe79 100644 --- a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorNormalST.cpp +++ b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorNormalST.cpp @@ -58,82 +58,85 @@ bool RigFemPartResultCalculatorNormalST::isMatching( const RigFemResultAddress& RigFemScalarResultFrames* RigFemPartResultCalculatorNormalST::calculate( int partIndex, const RigFemResultAddress& resVarAddr ) { - caf::ProgressInfo frameCountProgress( m_resultCollection->frameCount() * 3, "" ); - frameCountProgress.setProgressDescription( + caf::ProgressInfo stepCountProgress( m_resultCollection->timeStepCount() * 3, "" ); + stepCountProgress.setProgressDescription( "Calculating " + QString::fromStdString( resVarAddr.fieldName + ": " + resVarAddr.componentName ) ); - frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); + stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() ); RigFemScalarResultFrames* srcSDataFrames = m_resultCollection->findOrLoadScalarResult( partIndex, RigFemResultAddress( resVarAddr.resultPosType, "S-Bar", resVarAddr.componentName ) ); - frameCountProgress.incrementProgress(); - frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); + stepCountProgress.incrementProgress(); + stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() ); RigFemScalarResultFrames* srcPORDataFrames = m_resultCollection->findOrLoadScalarResult( partIndex, RigFemResultAddress( RIG_NODAL, "POR-Bar", "" ) ); RigFemScalarResultFrames* dstDataFrames = m_resultCollection->createScalarResult( partIndex, resVarAddr ); const RigFemPart* femPart = m_resultCollection->parts()->part( partIndex ); - int frameCount = srcSDataFrames->frameCount(); - frameCountProgress.incrementProgress(); + stepCountProgress.incrementProgress(); - const float inf = std::numeric_limits::infinity(); + constexpr float inf = std::numeric_limits::infinity(); - for ( int fIdx = 0; fIdx < frameCount; ++fIdx ) + const int timeSteps = srcPORDataFrames->timeStepCount(); + for ( int stepIdx = 0; stepIdx < timeSteps; stepIdx++ ) { - const std::vector& srcSFrameData = srcSDataFrames->frameData( fIdx ); - const std::vector& srcPORFrameData = srcPORDataFrames->frameData( fIdx ); + const int frameCount = srcPORDataFrames->frameCount( stepIdx ); + for ( int fIdx = 0; fIdx < frameCount; fIdx++ ) + { + const std::vector& srcSFrameData = srcSDataFrames->frameData( stepIdx, fIdx ); + const std::vector& srcPORFrameData = srcPORDataFrames->frameData( stepIdx, fIdx ); - int elementCount = femPart->elementCount(); + int elementCount = femPart->elementCount(); - std::vector& dstFrameData = dstDataFrames->frameData( fIdx ); + std::vector& dstFrameData = dstDataFrames->frameData( stepIdx, fIdx ); - size_t valCount = srcSFrameData.size(); - dstFrameData.resize( valCount ); + size_t valCount = srcSFrameData.size(); + dstFrameData.resize( valCount ); #pragma omp parallel for - for ( int elmIdx = 0; elmIdx < elementCount; ++elmIdx ) - { - RigElementType elmType = femPart->elementType( elmIdx ); - - int elmNodeCount = RigFemTypes::elementNodeCount( femPart->elementType( elmIdx ) ); - - if ( elmType == HEX8P ) + for ( int elmIdx = 0; elmIdx < elementCount; ++elmIdx ) { - for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx ) + RigElementType elmType = femPart->elementType( elmIdx ); + + int elmNodeCount = RigFemTypes::elementNodeCount( femPart->elementType( elmIdx ) ); + + if ( elmType == HEX8P ) { - size_t elmNodResIdx = femPart->elementNodeResultIdx( elmIdx, elmNodIdx ); - if ( elmNodResIdx < srcSFrameData.size() ) + for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx ) { - int nodeIdx = femPart->nodeIdxFromElementNodeResultIdx( elmNodResIdx ); + size_t elmNodResIdx = femPart->elementNodeResultIdx( elmIdx, elmNodIdx ); + if ( elmNodResIdx < srcSFrameData.size() ) + { + int nodeIdx = femPart->nodeIdxFromElementNodeResultIdx( elmNodResIdx ); - float por = srcPORFrameData[nodeIdx]; - if ( por == inf ) por = 0.0f; + float por = srcPORFrameData[nodeIdx]; + if ( por == inf ) por = 0.0f; - // ST = SE_abacus + porePressure - // porePressure is POR-Bar. - double SE_abacus = -srcSFrameData[elmNodResIdx]; - dstFrameData[elmNodResIdx] = SE_abacus + por; + // ST = SE_abacus + porePressure + // porePressure is POR-Bar. + double SE_abacus = -srcSFrameData[elmNodResIdx]; + dstFrameData[elmNodResIdx] = SE_abacus + por; + } } } - } - else - { - for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx ) + else { - size_t elmNodResIdx = femPart->elementNodeResultIdx( elmIdx, elmNodIdx ); - if ( elmNodResIdx < srcSFrameData.size() ) + for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx ) { - dstFrameData[elmNodResIdx] = -srcSFrameData[elmNodResIdx]; + size_t elmNodResIdx = femPart->elementNodeResultIdx( elmIdx, elmNodIdx ); + if ( elmNodResIdx < srcSFrameData.size() ) + { + dstFrameData[elmNodResIdx] = -srcSFrameData[elmNodResIdx]; + } } } } } - - frameCountProgress.incrementProgress(); + stepCountProgress.incrementProgress(); } return dstDataFrames; diff --git a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorNormalized.cpp b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorNormalized.cpp index 9725190e95..0b3d8e1e70 100644 --- a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorNormalized.cpp +++ b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorNormalized.cpp @@ -70,94 +70,100 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorNormalized::calculate( int CAF_ASSERT( unscaledResult.resultPosType == RIG_ELEMENT_NODAL ); - caf::ProgressInfo frameCountProgress( m_resultCollection->frameCount() * 4, "Calculating Normalized Result" ); + caf::ProgressInfo stepCountProgress( m_resultCollection->timeStepCount() * 4, "Calculating Normalized Result" ); RigFemScalarResultFrames* porDataFrames = nullptr; RigFemScalarResultFrames* srcDataFrames = nullptr; RigFemScalarResultFrames* dstDataFrames = nullptr; { - auto task = frameCountProgress.task( "Loading POR Result", m_resultCollection->frameCount() ); + auto task = stepCountProgress.task( "Loading POR Result", m_resultCollection->timeStepCount() ); porDataFrames = m_resultCollection->findOrLoadScalarResult( partIndex, RigFemResultAddress( RIG_ELEMENT_NODAL, "POR-Bar", "" ) ); if ( !porDataFrames ) return nullptr; } { - auto task = frameCountProgress.task( "Loading Unscaled Result", m_resultCollection->frameCount() ); + auto task = stepCountProgress.task( "Loading Unscaled Result", m_resultCollection->timeStepCount() ); srcDataFrames = m_resultCollection->findOrLoadScalarResult( partIndex, unscaledResult ); if ( !srcDataFrames ) return nullptr; } { - auto task = frameCountProgress.task( "Creating Space for Normalized Result", m_resultCollection->frameCount() ); + auto task = stepCountProgress.task( "Creating Space for Normalized Result", m_resultCollection->timeStepCount() ); dstDataFrames = m_resultCollection->createScalarResult( partIndex, RigFemResultAddress( resVarAddr ) ); if ( !dstDataFrames ) return nullptr; } - frameCountProgress.setProgressDescription( "Normalizing Result" ); - frameCountProgress.setNextProgressIncrement( 1u ); + stepCountProgress.setProgressDescription( "Normalizing Result" ); + stepCountProgress.setNextProgressIncrement( 1u ); const RigFemPart* femPart = m_resultCollection->parts()->part( partIndex ); const RigFemPartGrid* femPartGrid = femPart->getOrCreateStructGrid(); - const float inf = std::numeric_limits::infinity(); + constexpr float inf = std::numeric_limits::infinity(); int elmNodeCount = femPart->elementCount(); const std::vector& nodeCoords = femPart->nodes().coordinates; - int frameCount = srcDataFrames->frameCount(); - for ( int fIdx = 0; fIdx < frameCount; ++fIdx ) + const int timeSteps = srcDataFrames->timeStepCount(); + for ( int stepIdx = 0; stepIdx < timeSteps; stepIdx++ ) { - const std::vector& porFrameData = porDataFrames->frameData( fIdx ); - if ( porFrameData.empty() ) continue; - const std::vector& srcFrameData = srcDataFrames->frameData( fIdx ); - std::vector& dstFrameData = dstDataFrames->frameData( fIdx ); - - size_t resultCount = srcFrameData.size(); - dstFrameData.resize( resultCount ); - - if ( unscaledResult.resultPosType == RIG_ELEMENT_NODAL ) + const int frameCount = srcDataFrames->frameCount( stepIdx ); + for ( int fIdx = 0; fIdx < frameCount; fIdx++ ) { -#pragma omp parallel for schedule( dynamic ) - for ( int elmIdx = 0; elmIdx < femPart->elementCount(); ++elmIdx ) + const std::vector& porFrameData = porDataFrames->frameData( stepIdx, fIdx ); + if ( porFrameData.empty() ) continue; + const std::vector& srcFrameData = srcDataFrames->frameData( stepIdx, fIdx ); + std::vector& dstFrameData = dstDataFrames->frameData( stepIdx, fIdx ); + + size_t resultCount = srcFrameData.size(); + dstFrameData.resize( resultCount ); + + if ( unscaledResult.resultPosType == RIG_ELEMENT_NODAL ) { - RigElementType elmType = femPart->elementType( elmIdx ); - if ( !( elmType == HEX8 || elmType == HEX8P ) ) continue; +#pragma omp parallel for schedule( dynamic ) + for ( int elmIdx = 0; elmIdx < femPart->elementCount(); ++elmIdx ) + { + RigElementType elmType = femPart->elementType( elmIdx ); + if ( !( elmType == HEX8 || elmType == HEX8P ) ) continue; - bool porRegion = false; - for ( int elmLocalNodeIdx = 0; elmLocalNodeIdx < 8; ++elmLocalNodeIdx ) - { - size_t elmNodeResIdx = femPart->elementNodeResultIdx( elmIdx, elmLocalNodeIdx ); - const int nodeIdx = femPart->nodeIdxFromElementNodeResultIdx( elmNodeResIdx ); - dstFrameData[elmNodeResIdx] = srcFrameData[elmNodeResIdx]; - if ( porFrameData[elmNodeResIdx] != std::numeric_limits::infinity() ) - { - porRegion = true; - } - } - if ( porRegion ) - { - // This is in the POR-region. Use hydrostatic pressure from the individual nodes + bool porRegion = false; for ( int elmLocalNodeIdx = 0; elmLocalNodeIdx < 8; ++elmLocalNodeIdx ) { - size_t elmNodeResIdx = femPart->elementNodeResultIdx( elmIdx, elmLocalNodeIdx ); - const int nodeIdx = femPart->nodeIdxFromElementNodeResultIdx( elmNodeResIdx ); - double tvdRKB = std::abs( nodeCoords[nodeIdx].z() ) + m_resultCollection->normalizationAirGap(); - double hydrostaticPressure = RiaWellLogUnitTools::hydrostaticPorePressureBar( tvdRKB ); - dstFrameData[elmNodeResIdx] /= hydrostaticPressure; + size_t elmNodeResIdx = femPart->elementNodeResultIdx( elmIdx, elmLocalNodeIdx ); + const int nodeIdx = femPart->nodeIdxFromElementNodeResultIdx( elmNodeResIdx ); + dstFrameData[elmNodeResIdx] = srcFrameData[elmNodeResIdx]; + if ( porFrameData[elmNodeResIdx] != std::numeric_limits::infinity() ) + { + porRegion = true; + } } - } - else - { - // Over/under/sideburden. Use hydrostatic pressure from cell centroid. - cvf::Vec3d cellCentroid = femPartGrid->cellCentroid( elmIdx ); - double cellCentroidTvdRKB = std::abs( cellCentroid.z() ) + m_resultCollection->normalizationAirGap(); - double cellCenterHydroStaticPressure = - RiaWellLogUnitTools::hydrostaticPorePressureBar( cellCentroidTvdRKB ); - - for ( int elmLocalNodeIdx = 0; elmLocalNodeIdx < 8; ++elmLocalNodeIdx ) + if ( porRegion ) { - size_t elmNodeResIdx = femPart->elementNodeResultIdx( elmIdx, elmLocalNodeIdx ); - dstFrameData[elmNodeResIdx] /= cellCenterHydroStaticPressure; + // This is in the POR-region. Use hydrostatic pressure from the individual nodes + for ( int elmLocalNodeIdx = 0; elmLocalNodeIdx < 8; ++elmLocalNodeIdx ) + { + size_t elmNodeResIdx = femPart->elementNodeResultIdx( elmIdx, elmLocalNodeIdx ); + const int nodeIdx = femPart->nodeIdxFromElementNodeResultIdx( elmNodeResIdx ); + double tvdRKB = std::abs( nodeCoords[nodeIdx].z() ) + + m_resultCollection->normalizationAirGap(); + double hydrostaticPressure = RiaWellLogUnitTools::hydrostaticPorePressureBar( tvdRKB ); + dstFrameData[elmNodeResIdx] /= hydrostaticPressure; + } + } + else + { + // Over/under/sideburden. Use hydrostatic pressure from cell centroid. + cvf::Vec3d cellCentroid = femPartGrid->cellCentroid( elmIdx ); + double cellCentroidTvdRKB = std::abs( cellCentroid.z() ) + + m_resultCollection->normalizationAirGap(); + double cellCenterHydroStaticPressure = + RiaWellLogUnitTools::hydrostaticPorePressureBar( cellCentroidTvdRKB ); + + for ( int elmLocalNodeIdx = 0; elmLocalNodeIdx < 8; ++elmLocalNodeIdx ) + { + size_t elmNodeResIdx = femPart->elementNodeResultIdx( elmIdx, elmLocalNodeIdx ); + dstFrameData[elmNodeResIdx] /= cellCenterHydroStaticPressure; + } } } } diff --git a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorPoreCompressibility.cpp b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorPoreCompressibility.cpp index c8bac827f3..fcc8762d7b 100644 --- a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorPoreCompressibility.cpp +++ b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorPoreCompressibility.cpp @@ -63,16 +63,16 @@ bool RigFemPartResultCalculatorPoreCompressibility::isMatching( const RigFemResu RigFemScalarResultFrames* RigFemPartResultCalculatorPoreCompressibility::calculate( int partIndex, const RigFemResultAddress& resAddr ) { - caf::ProgressInfo frameCountProgress( static_cast( m_resultCollection->frameCount() ) * 7, - "Calculating Pore Compressibility" ); + caf::ProgressInfo stepCountProgress( static_cast( m_resultCollection->timeStepCount() ) * 7, + "Calculating Pore Compressibility" ); auto loadFrameLambda = [&]( RigFemResultAddress addr, const QString& errMsg = "" ) -> RigFemScalarResultFrames* { - auto task = frameCountProgress.task( QString( "Loading %1: %2" ) - .arg( QString::fromStdString( addr.fieldName ) ) - .arg( QString::fromStdString( addr.componentName ) ), - m_resultCollection->frameCount() ); + auto task = stepCountProgress.task( QString( "Loading %1: %2" ) + .arg( QString::fromStdString( addr.fieldName ) ) + .arg( QString::fromStdString( addr.componentName ) ), + m_resultCollection->timeStepCount() ); auto result = m_resultCollection->findOrLoadScalarResult( partIndex, addr ); - if ( result->frameData( 0 ).empty() ) + if ( result->frameData( 0, 0 ).empty() ) { if ( !errMsg.isEmpty() ) Riu3DMainWindowTools::reportAndShowWarning( "Required data missing", errMsg ); return nullptr; @@ -130,154 +130,162 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorPoreCompressibility::calcula const RigFemPart* femPart = m_resultCollection->parts()->part( partIndex ); float inf = std::numeric_limits::infinity(); - int referenceFrameIdx = m_resultCollection->referenceTimeStep(); + int refStepIdx, refFrameIdx; + std::tie( refStepIdx, refFrameIdx ) = m_resultCollection->referenceStepAndFrameIndex(); - int frameCount = srcEVDataFrames->frameCount(); - for ( int fIdx = 0; fIdx < frameCount; ++fIdx ) + const int timeSteps = srcEVDataFrames->timeStepCount(); + for ( int stepIdx = 0; stepIdx < timeSteps; stepIdx++ ) { - auto task = frameCountProgress.task( QString( "Frame %1" ).arg( fIdx ) ); + auto task = stepCountProgress.task( QString( "Step %1" ).arg( stepIdx ) ); - const std::vector& evData = srcEVDataFrames->frameData( fIdx ); - const std::vector& referenceEvData = srcEVDataFrames->frameData( referenceFrameIdx ); - const std::vector& verticalStrainData = verticalStrainDataFrames->frameData( fIdx ); - const std::vector& referenceVerticalStrainData = verticalStrainDataFrames->frameData( referenceFrameIdx ); - const std::vector& youngsModuliData = youngsModuliFrames->frameData( fIdx ); - const std::vector& poissonRatioData = poissonRatioFrames->frameData( fIdx ); - const std::vector& voidRatioData = voidRatioFrames->frameData( 0 ); - const std::vector& referencePorFrameData = srcPORDataFrames->frameData( referenceFrameIdx ); - const std::vector& porFrameData = srcPORDataFrames->frameData( fIdx ); - - std::vector& poreCompressibilityFrameData = poreCompressibilityFrames->frameData( fIdx ); - std::vector& verticalCompressibilityFrameData = verticalCompressibilityFrames->frameData( fIdx ); - std::vector& verticalCompressibilityRatioFrameData = verticalCompressibilityRatioFrames->frameData( fIdx ); - - size_t valCount = evData.size(); - poreCompressibilityFrameData.resize( valCount ); - verticalCompressibilityFrameData.resize( valCount ); - verticalCompressibilityRatioFrameData.resize( valCount ); - - int elementCount = femPart->elementCount(); - - std::vector biotData; - if ( biotCoefficient ) + const int frameCount = srcEVDataFrames->frameCount( stepIdx ); + for ( int fIdx = 0; fIdx < frameCount; fIdx++ ) { - biotData = biotCoefficient->frameData( fIdx ); - if ( !m_resultCollection->isValidBiotData( biotData, elementCount ) ) + const std::vector& evData = srcEVDataFrames->frameData( stepIdx, fIdx ); + const std::vector& referenceEvData = srcEVDataFrames->frameData( refStepIdx, refFrameIdx ); + const std::vector& verticalStrainData = verticalStrainDataFrames->frameData( stepIdx, fIdx ); + const std::vector& referenceVerticalStrainData = + verticalStrainDataFrames->frameData( refStepIdx, refFrameIdx ); + + const std::vector& youngsModuliData = youngsModuliFrames->frameData( stepIdx, fIdx ); + const std::vector& poissonRatioData = poissonRatioFrames->frameData( stepIdx, fIdx ); + const std::vector& voidRatioData = voidRatioFrames->frameData( 0, 0 ); + const std::vector& referencePorFrameData = srcPORDataFrames->frameData( refStepIdx, refFrameIdx ); + const std::vector& porFrameData = srcPORDataFrames->frameData( stepIdx, fIdx ); + + std::vector& poreCompressibilityFrameData = poreCompressibilityFrames->frameData( stepIdx, fIdx ); + std::vector& verticalCompressibilityFrameData = + verticalCompressibilityFrames->frameData( stepIdx, fIdx ); + std::vector& verticalCompressibilityRatioFrameData = + verticalCompressibilityRatioFrames->frameData( stepIdx, fIdx ); + + size_t valCount = evData.size(); + poreCompressibilityFrameData.resize( valCount ); + verticalCompressibilityFrameData.resize( valCount ); + verticalCompressibilityRatioFrameData.resize( valCount ); + + int elementCount = femPart->elementCount(); + + std::vector biotData; + if ( biotCoefficient ) { - m_resultCollection->deleteResult( resAddr ); - return nullptr; + biotData = biotCoefficient->frameData( stepIdx, fIdx ); + if ( !m_resultCollection->isValidBiotData( biotData, elementCount ) ) + { + m_resultCollection->deleteResult( resAddr ); + return nullptr; + } } - } #pragma omp parallel for - for ( int elmIdx = 0; elmIdx < elementCount; ++elmIdx ) - { - RigElementType elmType = femPart->elementType( elmIdx ); - - int elmNodeCount = RigFemTypes::elementNodeCount( femPart->elementType( elmIdx ) ); - - if ( elmType == HEX8P ) + for ( int elmIdx = 0; elmIdx < elementCount; ++elmIdx ) { - for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx ) + RigElementType elmType = femPart->elementType( elmIdx ); + + int elmNodeCount = RigFemTypes::elementNodeCount( femPart->elementType( elmIdx ) ); + + if ( elmType == HEX8P ) { - size_t elmNodResIdx = femPart->elementNodeResultIdx( elmIdx, elmNodIdx ); - if ( elmNodResIdx < evData.size() ) + for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx ) { - if ( fIdx == referenceFrameIdx ) + size_t elmNodResIdx = femPart->elementNodeResultIdx( elmIdx, elmNodIdx ); + if ( elmNodResIdx < evData.size() ) { - // The time step and the reference time step are the same: results undefined - poreCompressibilityFrameData[elmNodResIdx] = inf; - verticalCompressibilityFrameData[elmNodResIdx] = inf; - verticalCompressibilityRatioFrameData[elmNodResIdx] = inf; - } - else - { - // Use biot coefficient for all timesteps - double biotCoefficient = 1.0; - if ( biotData.empty() ) + if ( ( fIdx == refFrameIdx ) && ( stepIdx == refStepIdx ) ) { - biotCoefficient = m_resultCollection->biotFixedFactor(); + // The time step and the reference time step are the same: results undefined + poreCompressibilityFrameData[elmNodResIdx] = inf; + verticalCompressibilityFrameData[elmNodResIdx] = inf; + verticalCompressibilityRatioFrameData[elmNodResIdx] = inf; } else { - // Use coefficient from element property table - biotCoefficient = biotData[elmIdx]; - } - - int nodeIdx = femPart->nodeIdxFromElementNodeResultIdx( elmNodResIdx ); - - // Calculate bulk modulus for solids (grains). - // Incoming unit for Young's Modulus is GPa: convert to Pa. - double poissonRatio = poissonRatioData[elmIdx]; - double youngsModuli = RiaEclipseUnitTools::gigaPascalToPascal( youngsModuliData[elmIdx] ); - double bulkModulusFrame = youngsModuli / ( 3.0 * ( 1.0 - 2.0 * poissonRatio ) ); - double bulkModulus = bulkModulusFrame / ( 1.0 - biotCoefficient ); - - // Calculate initial porosity (always from geostatic timestep) - double voidr = voidRatioData[elmNodResIdx]; - double porosity = voidr / ( 1.0 + voidr ); - - // Calculate difference in pore pressure between reference state and this state, - // and convert unit from Bar to Pascal. - double referencePorePressure = referencePorFrameData[nodeIdx]; - double framePorePressure = porFrameData[nodeIdx]; - double deltaPorePressure = - RiaEclipseUnitTools::barToPascal( framePorePressure - referencePorePressure ); - - // Calculate pore compressibility - double poreCompressibility = inf; - if ( deltaPorePressure != 0.0 && porosity != 0.0 ) - { - double deltaEv = evData[elmNodResIdx] - referenceEvData[elmNodResIdx]; - poreCompressibility = -( biotCoefficient * deltaEv ) / ( deltaPorePressure * porosity ); - // Guard against divide by zero: second term can be ignored when bulk modulus is zero, - // which can happens when biot coefficient is 1.0 - if ( biotCoefficient != 1.0 && porosity != 1.0 ) + // Use biot coefficient for all timesteps + double biotCoefficient = 1.0; + if ( biotData.empty() ) { - poreCompressibility += ( 1.0 / bulkModulus ) * ( biotCoefficient / porosity - 1.0 ); + biotCoefficient = m_resultCollection->biotFixedFactor(); } + else + { + // Use coefficient from element property table + biotCoefficient = biotData[elmIdx]; + } + + int nodeIdx = femPart->nodeIdxFromElementNodeResultIdx( elmNodResIdx ); + + // Calculate bulk modulus for solids (grains). + // Incoming unit for Young's Modulus is GPa: convert to Pa. + double poissonRatio = poissonRatioData[elmIdx]; + double youngsModuli = RiaEclipseUnitTools::gigaPascalToPascal( youngsModuliData[elmIdx] ); + double bulkModulusFrame = youngsModuli / ( 3.0 * ( 1.0 - 2.0 * poissonRatio ) ); + double bulkModulus = bulkModulusFrame / ( 1.0 - biotCoefficient ); + + // Calculate initial porosity (always from geostatic timestep) + double voidr = voidRatioData[elmNodResIdx]; + double porosity = voidr / ( 1.0 + voidr ); + + // Calculate difference in pore pressure between reference state and this state, + // and convert unit from Bar to Pascal. + double referencePorePressure = referencePorFrameData[nodeIdx]; + double framePorePressure = porFrameData[nodeIdx]; + double deltaPorePressure = + RiaEclipseUnitTools::barToPascal( framePorePressure - referencePorePressure ); + + // Calculate pore compressibility + double poreCompressibility = inf; + if ( deltaPorePressure != 0.0 && porosity != 0.0 ) + { + double deltaEv = evData[elmNodResIdx] - referenceEvData[elmNodResIdx]; + poreCompressibility = -( biotCoefficient * deltaEv ) / ( deltaPorePressure * porosity ); + // Guard against divide by zero: second term can be ignored when bulk modulus is + // zero, which can happens when biot coefficient is 1.0 + if ( biotCoefficient != 1.0 && porosity != 1.0 ) + { + poreCompressibility += ( 1.0 / bulkModulus ) * ( biotCoefficient / porosity - 1.0 ); + } + } + // Convert from 1/Pa to 1/GPa + poreCompressibilityFrameData[elmNodResIdx] = poreCompressibility * 1.0e9; + + double verticalCompressibility = inf; + double verticalCompressibilityRatio = inf; + + if ( biotCoefficient != 0.0 && deltaPorePressure != 0.0 ) + { + double deltaStrain = verticalStrainData[elmNodResIdx] - + referenceVerticalStrainData[elmNodResIdx]; + + // Calculate vertical compressibility (unit: 1/Pa) + verticalCompressibility = -deltaStrain / ( biotCoefficient * deltaPorePressure ); + + // Calculate vertical compressibility ratio + verticalCompressibilityRatio = + ( verticalCompressibility * youngsModuli * ( 1.0 - poissonRatio ) ) / + ( ( 1.0 + poissonRatio ) * ( 1.0 - 2.0 * poissonRatio ) ); + } + + // Convert from 1/Pa to 1/GPa + verticalCompressibilityFrameData[elmNodResIdx] = verticalCompressibility * 1.0e9; + verticalCompressibilityRatioFrameData[elmNodResIdx] = verticalCompressibilityRatio; } - // Convert from 1/Pa to 1/GPa - poreCompressibilityFrameData[elmNodResIdx] = poreCompressibility * 1.0e9; - - double verticalCompressibility = inf; - double verticalCompressibilityRatio = inf; - - if ( biotCoefficient != 0.0 && deltaPorePressure != 0.0 ) - { - double deltaStrain = verticalStrainData[elmNodResIdx] - - referenceVerticalStrainData[elmNodResIdx]; - - // Calculate vertical compressibility (unit: 1/Pa) - verticalCompressibility = -deltaStrain / ( biotCoefficient * deltaPorePressure ); - - // Calculate vertical compressibility ratio - verticalCompressibilityRatio = - ( verticalCompressibility * youngsModuli * ( 1.0 - poissonRatio ) ) / - ( ( 1.0 + poissonRatio ) * ( 1.0 - 2.0 * poissonRatio ) ); - } - - // Convert from 1/Pa to 1/GPa - verticalCompressibilityFrameData[elmNodResIdx] = verticalCompressibility * 1.0e9; - verticalCompressibilityRatioFrameData[elmNodResIdx] = verticalCompressibilityRatio; } } } - } - else - { - for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx ) + else { - size_t elmNodResIdx = femPart->elementNodeResultIdx( elmIdx, elmNodIdx ); - if ( elmNodResIdx < poreCompressibilityFrameData.size() ) + for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx ) { - poreCompressibilityFrameData[elmNodResIdx] = inf; + size_t elmNodResIdx = femPart->elementNodeResultIdx( elmIdx, elmNodIdx ); + if ( elmNodResIdx < poreCompressibilityFrameData.size() ) + { + poreCompressibilityFrameData[elmNodResIdx] = inf; + } } } } } } - RigFemScalarResultFrames* requestedResultFrames = m_resultCollection->findOrLoadScalarResult( partIndex, resAddr ); return requestedResultFrames; } diff --git a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorPorosityPermeability.cpp b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorPorosityPermeability.cpp index 50c89670e8..bef44bbbb1 100644 --- a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorPorosityPermeability.cpp +++ b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorPorosityPermeability.cpp @@ -64,28 +64,28 @@ bool RigFemPartResultCalculatorPorosityPermeability::isMatching( const RigFemRes RigFemScalarResultFrames* RigFemPartResultCalculatorPorosityPermeability::calculate( int partIndex, const RigFemResultAddress& resVarAddr ) { - caf::ProgressInfo frameCountProgress( m_resultCollection->frameCount() * 6, "" ); - frameCountProgress.setProgressDescription( "Calculating Porosity/Permeability" ); + caf::ProgressInfo stepCountProgress( m_resultCollection->timeStepCount() * 6, "" ); + stepCountProgress.setProgressDescription( "Calculating Porosity/Permeability" ); - frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); + stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() ); RigFemScalarResultFrames* srcPorePressureDataFrames = m_resultCollection->findOrLoadScalarResult( partIndex, RigFemResultAddress( RIG_NODAL, "POR-Bar", "" ) ); - frameCountProgress.incrementProgress(); + stepCountProgress.incrementProgress(); // Volumetric Strain - frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); + stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() ); RigFemScalarResultFrames* srcEVDataFrames = m_resultCollection->findOrLoadScalarResult( partIndex, RigFemResultAddress( resVarAddr.resultPosType, "NE", "EV" ) ); - frameCountProgress.incrementProgress(); + stepCountProgress.incrementProgress(); // Pore Compressibility - frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); + stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() ); RigFemScalarResultFrames* poreCompressibilityFrames = m_resultCollection->findOrLoadScalarResult( partIndex, RigFemResultAddress( resVarAddr.resultPosType, "COMPRESSIBILITY", "PORE" ) ); - if ( poreCompressibilityFrames->frameData( 0 ).empty() ) + if ( poreCompressibilityFrames->frameData( 0, 0 ).empty() ) { QString txt = QString( "Failed to compute %1\n" ).arg( QString::fromStdString( resVarAddr.componentName ) ); txt += "Missing pore compressibility data"; @@ -95,10 +95,10 @@ RigFemScalarResultFrames* return nullptr; } - frameCountProgress.incrementProgress(); + stepCountProgress.incrementProgress(); // Initial permeability (k0) - frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); + stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() ); RigFemScalarResultFrames* initialPermeabilityFrames = nullptr; if ( !m_resultCollection->initialPermeabilityAddress().isEmpty() ) { @@ -109,9 +109,9 @@ RigFemScalarResultFrames* m_resultCollection->initialPermeabilityAddress().toStdString(), "" ) ); } - frameCountProgress.incrementProgress(); + stepCountProgress.incrementProgress(); - frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); + stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() ); RigFemScalarResultFrames* voidRatioFrames = m_resultCollection->findOrLoadScalarResult( partIndex, @@ -126,127 +126,131 @@ RigFemScalarResultFrames* RigFemScalarResultFrames* permeabilityFrames = m_resultCollection->createScalarResult( partIndex, RigFemResultAddress( resVarAddr.resultPosType, resVarAddr.fieldName, "PERM" ) ); - frameCountProgress.incrementProgress(); + stepCountProgress.incrementProgress(); const RigFemPart* femPart = m_resultCollection->parts()->part( partIndex ); float inf = std::numeric_limits::infinity(); - frameCountProgress.setNextProgressIncrement( 1u ); + stepCountProgress.setNextProgressIncrement( 1u ); - int referenceFrameIdx = m_resultCollection->referenceTimeStep(); + int refStepIdx, refFrameIdx; + std::tie( refStepIdx, refFrameIdx ) = m_resultCollection->referenceStepAndFrameIndex(); - int frameCount = srcEVDataFrames->frameCount(); - for ( int fIdx = 0; fIdx < frameCount; ++fIdx ) + const int timeSteps = srcEVDataFrames->timeStepCount(); + for ( int stepIdx = 0; stepIdx < timeSteps; stepIdx++ ) { - const std::vector& evData = srcEVDataFrames->frameData( fIdx ); - const std::vector& referenceEvData = srcEVDataFrames->frameData( referenceFrameIdx ); - const std::vector& voidRatioData = voidRatioFrames->frameData( 0 ); - const std::vector& referencePorFrameData = srcPorePressureDataFrames->frameData( referenceFrameIdx ); - const std::vector& porFrameData = srcPorePressureDataFrames->frameData( fIdx ); - const std::vector& poreCompressibilityFrameData = poreCompressibilityFrames->frameData( fIdx ); - - std::vector& porosityFrameData = porosityFrames->frameData( fIdx ); - std::vector& porosityDeltaFrameData = porosityDeltaFrames->frameData( fIdx ); - std::vector& permeabilityFrameData = permeabilityFrames->frameData( fIdx ); - - size_t valCount = evData.size(); - porosityFrameData.resize( valCount ); - porosityDeltaFrameData.resize( valCount ); - permeabilityFrameData.resize( valCount ); - - int elementCount = femPart->elementCount(); - - std::vector initialPermeabilityData; - if ( initialPermeabilityFrames ) + const int frameCount = srcEVDataFrames->frameCount( stepIdx ); + for ( int fIdx = 0; fIdx < frameCount; fIdx++ ) { - initialPermeabilityData = initialPermeabilityFrames->frameData( fIdx ); - } + const std::vector& evData = srcEVDataFrames->frameData( stepIdx, fIdx ); + const std::vector& referenceEvData = srcEVDataFrames->frameData( refStepIdx, refFrameIdx ); + const std::vector& voidRatioData = voidRatioFrames->frameData( 0, 0 ); + const std::vector& refPorFrameData = srcPorePressureDataFrames->frameData( refStepIdx, refFrameIdx ); + const std::vector& porFrameData = srcPorePressureDataFrames->frameData( stepIdx, fIdx ); + const std::vector& poreCompressibilityFrameData = poreCompressibilityFrames->frameData( stepIdx, fIdx ); + + std::vector& porosityFrameData = porosityFrames->frameData( stepIdx, fIdx ); + std::vector& porosityDeltaFrameData = porosityDeltaFrames->frameData( stepIdx, fIdx ); + std::vector& permeabilityFrameData = permeabilityFrames->frameData( stepIdx, fIdx ); + + size_t valCount = evData.size(); + porosityFrameData.resize( valCount ); + porosityDeltaFrameData.resize( valCount ); + permeabilityFrameData.resize( valCount ); + + int elementCount = femPart->elementCount(); + + std::vector initialPermeabilityData; + if ( initialPermeabilityFrames ) + { + initialPermeabilityData = initialPermeabilityFrames->frameData( stepIdx, fIdx ); + } #pragma omp parallel for - for ( int elmIdx = 0; elmIdx < elementCount; ++elmIdx ) - { - RigElementType elmType = femPart->elementType( elmIdx ); - - int elmNodeCount = RigFemTypes::elementNodeCount( femPart->elementType( elmIdx ) ); - - if ( elmType == HEX8P ) + for ( int elmIdx = 0; elmIdx < elementCount; ++elmIdx ) { - for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx ) + RigElementType elmType = femPart->elementType( elmIdx ); + + int elmNodeCount = RigFemTypes::elementNodeCount( femPart->elementType( elmIdx ) ); + + if ( elmType == HEX8P ) { - size_t elmNodResIdx = femPart->elementNodeResultIdx( elmIdx, elmNodIdx ); - if ( elmNodResIdx < evData.size() ) + for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx ) { - // User provides initial permeability - double initialPermeability = 1.0; - if ( initialPermeabilityData.empty() ) + size_t elmNodResIdx = femPart->elementNodeResultIdx( elmIdx, elmNodIdx ); + if ( elmNodResIdx < evData.size() ) { - // 1. Same value for all cells - initialPermeability = m_resultCollection->initialPermeabilityFixed(); + // User provides initial permeability + double initialPermeability = 1.0; + if ( initialPermeabilityData.empty() ) + { + // 1. Same value for all cells + initialPermeability = m_resultCollection->initialPermeabilityFixed(); + } + else + { + // 2. From element property table + initialPermeability = initialPermeabilityData[elmIdx]; + } + + int nodeIdx = femPart->nodeIdxFromElementNodeResultIdx( elmNodResIdx ); + + // Calculate initial porosity + double voidr = voidRatioData[elmNodResIdx]; + double initialPorosity = voidr / ( 1.0 + voidr ); + + // Calculate porosity change. + // No change for geostatic timestep + double deltaPorosity = 0.0; + if ( fIdx != 0 ) + { + // Calculate difference in pore pressure between reference state and this state, + // and convert unit from Bar to Pascal. + double referencePorePressure = refPorFrameData[nodeIdx]; + double framePorePressure = porFrameData[nodeIdx]; + double deltaPorePressure = + RiaEclipseUnitTools::barToPascal( framePorePressure - referencePorePressure ); + + // Pore compressibility. Convert from 1/GPa to 1/Pa. + double poreCompressibility = poreCompressibilityFrameData[elmNodResIdx] / 1.0e9; + + // Volumetric strain + double deltaEv = evData[elmNodResIdx] - referenceEvData[elmNodResIdx]; + + // Porosity change between reference state and initial state (geostatic). + deltaPorosity = initialPorosity * ( poreCompressibility * deltaPorePressure + deltaEv ); + } + + // Current porosity + double currentPorosity = initialPorosity + deltaPorosity; + + // Permeability. Formula from Petunin, 2011. + double permeabilityExponent = m_resultCollection->permeabilityExponent(); + double permeability = initialPermeability * + std::pow( currentPorosity / initialPorosity, permeabilityExponent ); + + porosityFrameData[elmNodResIdx] = currentPorosity; + porosityDeltaFrameData[elmNodResIdx] = deltaPorosity; + permeabilityFrameData[elmNodResIdx] = permeability; } - else - { - // 2. From element property table - initialPermeability = initialPermeabilityData[elmIdx]; - } - - int nodeIdx = femPart->nodeIdxFromElementNodeResultIdx( elmNodResIdx ); - - // Calculate initial porosity - double voidr = voidRatioData[elmNodResIdx]; - double initialPorosity = voidr / ( 1.0 + voidr ); - - // Calculate porosity change. - // No change for geostatic timestep - double deltaPorosity = 0.0; - if ( fIdx != 0 ) - { - // Calculate difference in pore pressure between reference state and this state, - // and convert unit from Bar to Pascal. - double referencePorePressure = referencePorFrameData[nodeIdx]; - double framePorePressure = porFrameData[nodeIdx]; - double deltaPorePressure = - RiaEclipseUnitTools::barToPascal( framePorePressure - referencePorePressure ); - - // Pore compressibility. Convert from 1/GPa to 1/Pa. - double poreCompressibility = poreCompressibilityFrameData[elmNodResIdx] / 1.0e9; - - // Volumetric strain - double deltaEv = evData[elmNodResIdx] - referenceEvData[elmNodResIdx]; - - // Porosity change between reference state and initial state (geostatic). - deltaPorosity = initialPorosity * ( poreCompressibility * deltaPorePressure + deltaEv ); - } - - // Current porosity - double currentPorosity = initialPorosity + deltaPorosity; - - // Permeability. Formula from Petunin, 2011. - double permeabilityExponent = m_resultCollection->permeabilityExponent(); - double permeability = - initialPermeability * std::pow( currentPorosity / initialPorosity, permeabilityExponent ); - - porosityFrameData[elmNodResIdx] = currentPorosity; - porosityDeltaFrameData[elmNodResIdx] = deltaPorosity; - permeabilityFrameData[elmNodResIdx] = permeability; } } - } - else - { - for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx ) + else { - size_t elmNodResIdx = femPart->elementNodeResultIdx( elmIdx, elmNodIdx ); - if ( elmNodResIdx < poreCompressibilityFrameData.size() ) + for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx ) { - porosityFrameData[elmNodResIdx] = inf; - porosityDeltaFrameData[elmNodResIdx] = inf; - permeabilityFrameData[elmNodResIdx] = inf; + size_t elmNodResIdx = femPart->elementNodeResultIdx( elmIdx, elmNodIdx ); + if ( elmNodResIdx < poreCompressibilityFrameData.size() ) + { + porosityFrameData[elmNodResIdx] = inf; + porosityDeltaFrameData[elmNodResIdx] = inf; + permeabilityFrameData[elmNodResIdx] = inf; + } } } } } - - frameCountProgress.incrementProgress(); + stepCountProgress.incrementProgress(); } RigFemScalarResultFrames* requestedResultFrames = m_resultCollection->findOrLoadScalarResult( partIndex, resVarAddr ); diff --git a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorPrincipalStrain.cpp b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorPrincipalStrain.cpp index 1e6bcc9150..1741ca321f 100644 --- a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorPrincipalStrain.cpp +++ b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorPrincipalStrain.cpp @@ -75,11 +75,11 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorPrincipalStrain::calculate( QString progressText = "Calculating " + QString::fromStdString( resAddr.fieldName + ": " + resAddr.componentName ); - caf::ProgressInfo frameCountProgress( static_cast( m_resultCollection->frameCount() ) * 7, progressText ); + caf::ProgressInfo stepCountProgress( static_cast( m_resultCollection->timeStepCount() ) * 7, progressText ); auto loadFrameLambda = [&]( const std::string& component ) { - auto task = frameCountProgress.task( QString::fromStdString( "Loading " + component ), - m_resultCollection->frameCount() ); + auto task = stepCountProgress.task( QString::fromStdString( "Loading " + component ), + m_resultCollection->timeStepCount() ); return m_resultCollection->findOrLoadScalarResult( partIndex, resAddr.copyWithComponent( component ) ); }; @@ -97,37 +97,41 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorPrincipalStrain::calculate( RigFemScalarResultFrames* e3Frames = m_resultCollection->createScalarResult( partIndex, resAddr.copyWithComponent( m_componentNames[2] ) ); - int frameCount = e11Frames->frameCount(); - for ( int fIdx = 0; fIdx < frameCount; ++fIdx ) + const int timeSteps = e11Frames->timeStepCount(); + for ( int stepIdx = 0; stepIdx < timeSteps; stepIdx++ ) { - auto task = frameCountProgress.task( QString( "Frame %1" ).arg( fIdx ) ); + auto task = stepCountProgress.task( QString( "Step %1" ).arg( stepIdx ) ); - const std::vector& e11 = e11Frames->frameData( fIdx ); - const std::vector& e22 = e22Frames->frameData( fIdx ); - const std::vector& e33 = e33Frames->frameData( fIdx ); - const std::vector& e12 = e12Frames->frameData( fIdx ); - const std::vector& e13 = e13Frames->frameData( fIdx ); - const std::vector& e23 = e23Frames->frameData( fIdx ); + const int frameCount = e11Frames->frameCount( stepIdx ); + for ( int fIdx = 0; fIdx < frameCount; fIdx++ ) + { + const std::vector& e11 = e11Frames->frameData( stepIdx, fIdx ); + const std::vector& e22 = e22Frames->frameData( stepIdx, fIdx ); + const std::vector& e33 = e33Frames->frameData( stepIdx, fIdx ); + const std::vector& e12 = e12Frames->frameData( stepIdx, fIdx ); + const std::vector& e13 = e13Frames->frameData( stepIdx, fIdx ); + const std::vector& e23 = e23Frames->frameData( stepIdx, fIdx ); - std::vector& e1 = e1Frames->frameData( fIdx ); - std::vector& e2 = e2Frames->frameData( fIdx ); - std::vector& e3 = e3Frames->frameData( fIdx ); + std::vector& e1 = e1Frames->frameData( stepIdx, fIdx ); + std::vector& e2 = e2Frames->frameData( stepIdx, fIdx ); + std::vector& e3 = e3Frames->frameData( stepIdx, fIdx ); - size_t valCount = e11.size(); + size_t valCount = e11.size(); - e1.resize( valCount ); - e2.resize( valCount ); - e3.resize( valCount ); + e1.resize( valCount ); + e2.resize( valCount ); + e3.resize( valCount ); #pragma omp parallel for - for ( long vIdx = 0; vIdx < static_cast( valCount ); ++vIdx ) - { - caf::Ten3f T( e11[vIdx], e22[vIdx], e33[vIdx], e12[vIdx], e23[vIdx], e13[vIdx] ); - cvf::Vec3f principalDirs[3]; - cvf::Vec3f principals = T.calculatePrincipals( principalDirs ); - e1[vIdx] = principals[0]; - e2[vIdx] = principals[1]; - e3[vIdx] = principals[2]; + for ( long vIdx = 0; vIdx < static_cast( valCount ); ++vIdx ) + { + caf::Ten3f T( e11[vIdx], e22[vIdx], e33[vIdx], e12[vIdx], e23[vIdx], e13[vIdx] ); + cvf::Vec3f principalDirs[3]; + cvf::Vec3f principals = T.calculatePrincipals( principalDirs ); + e1[vIdx] = principals[0]; + e2[vIdx] = principals[1]; + e3[vIdx] = principals[2]; + } } } diff --git a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorPrincipalStress.cpp b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorPrincipalStress.cpp index eb5227e184..cc540a4673 100644 --- a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorPrincipalStress.cpp +++ b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorPrincipalStress.cpp @@ -68,46 +68,46 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorPrincipalStress::calculate( resVarAddr.componentName == "S2inc" || resVarAddr.componentName == "S2azi" || resVarAddr.componentName == "S3inc" || resVarAddr.componentName == "S3azi" ); - caf::ProgressInfo frameCountProgress( m_resultCollection->frameCount() * 7, "" ); - frameCountProgress.setProgressDescription( + caf::ProgressInfo stepCountProgress( m_resultCollection->timeStepCount() * 7, "" ); + stepCountProgress.setProgressDescription( "Calculating " + QString::fromStdString( resVarAddr.fieldName + ": " + resVarAddr.componentName ) ); - frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); + stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() ); RigFemScalarResultFrames* s11Frames = m_resultCollection->findOrLoadScalarResult( partIndex, RigFemResultAddress( resVarAddr.resultPosType, resVarAddr.fieldName, "S11" ) ); - frameCountProgress.incrementProgress(); - frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); + stepCountProgress.incrementProgress(); + stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() ); RigFemScalarResultFrames* s22Frames = m_resultCollection->findOrLoadScalarResult( partIndex, RigFemResultAddress( resVarAddr.resultPosType, resVarAddr.fieldName, "S22" ) ); - frameCountProgress.incrementProgress(); - frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); + stepCountProgress.incrementProgress(); + stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() ); RigFemScalarResultFrames* s33Frames = m_resultCollection->findOrLoadScalarResult( partIndex, RigFemResultAddress( resVarAddr.resultPosType, resVarAddr.fieldName, "S33" ) ); - frameCountProgress.incrementProgress(); - frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); + stepCountProgress.incrementProgress(); + stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() ); RigFemScalarResultFrames* s12Frames = m_resultCollection->findOrLoadScalarResult( partIndex, RigFemResultAddress( resVarAddr.resultPosType, resVarAddr.fieldName, "S12" ) ); - frameCountProgress.incrementProgress(); - frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); + stepCountProgress.incrementProgress(); + stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() ); RigFemScalarResultFrames* s13Frames = m_resultCollection->findOrLoadScalarResult( partIndex, RigFemResultAddress( resVarAddr.resultPosType, resVarAddr.fieldName, "S13" ) ); - frameCountProgress.incrementProgress(); - frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); + stepCountProgress.incrementProgress(); + stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() ); RigFemScalarResultFrames* s23Frames = m_resultCollection->findOrLoadScalarResult( partIndex, RigFemResultAddress( resVarAddr.resultPosType, @@ -143,89 +143,92 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorPrincipalStress::calculate( m_resultCollection->createScalarResult( partIndex, RigFemResultAddress( resVarAddr.resultPosType, resVarAddr.fieldName, "S3azi" ) ); - frameCountProgress.incrementProgress(); + stepCountProgress.incrementProgress(); - int frameCount = s11Frames->frameCount(); - for ( int fIdx = 0; fIdx < frameCount; ++fIdx ) + const int timeSteps = s11Frames->timeStepCount(); + for ( int stepIdx = 0; stepIdx < timeSteps; stepIdx++ ) { - const std::vector& s11 = s11Frames->frameData( fIdx ); - const std::vector& s22 = s22Frames->frameData( fIdx ); - const std::vector& s33 = s33Frames->frameData( fIdx ); - const std::vector& s12 = s12Frames->frameData( fIdx ); - const std::vector& s13 = s13Frames->frameData( fIdx ); - const std::vector& s23 = s23Frames->frameData( fIdx ); + const int frameCount = s11Frames->frameCount( stepIdx ); + for ( int fIdx = 0; fIdx < frameCount; fIdx++ ) + { + const std::vector& s11 = s11Frames->frameData( stepIdx, fIdx ); + const std::vector& s22 = s22Frames->frameData( stepIdx, fIdx ); + const std::vector& s33 = s33Frames->frameData( stepIdx, fIdx ); + const std::vector& s12 = s12Frames->frameData( stepIdx, fIdx ); + const std::vector& s13 = s13Frames->frameData( stepIdx, fIdx ); + const std::vector& s23 = s23Frames->frameData( stepIdx, fIdx ); - std::vector& s1 = s1Frames->frameData( fIdx ); - std::vector& s2 = s2Frames->frameData( fIdx ); - std::vector& s3 = s3Frames->frameData( fIdx ); + std::vector& s1 = s1Frames->frameData( stepIdx, fIdx ); + std::vector& s2 = s2Frames->frameData( stepIdx, fIdx ); + std::vector& s3 = s3Frames->frameData( stepIdx, fIdx ); - std::vector& s1inc = s1IncFrames->frameData( fIdx ); - std::vector& s1azi = s1AziFrames->frameData( fIdx ); - std::vector& s2inc = s2IncFrames->frameData( fIdx ); - std::vector& s2azi = s2AziFrames->frameData( fIdx ); - std::vector& s3inc = s3IncFrames->frameData( fIdx ); - std::vector& s3azi = s3AziFrames->frameData( fIdx ); + std::vector& s1inc = s1IncFrames->frameData( stepIdx, fIdx ); + std::vector& s1azi = s1AziFrames->frameData( stepIdx, fIdx ); + std::vector& s2inc = s2IncFrames->frameData( stepIdx, fIdx ); + std::vector& s2azi = s2AziFrames->frameData( stepIdx, fIdx ); + std::vector& s3inc = s3IncFrames->frameData( stepIdx, fIdx ); + std::vector& s3azi = s3AziFrames->frameData( stepIdx, fIdx ); - size_t valCount = s11.size(); + size_t valCount = s11.size(); - s1.resize( valCount ); - s2.resize( valCount ); - s3.resize( valCount ); - s1inc.resize( valCount ); - s1azi.resize( valCount ); - s2inc.resize( valCount ); - s2azi.resize( valCount ); - s3inc.resize( valCount ); - s3azi.resize( valCount ); + s1.resize( valCount ); + s2.resize( valCount ); + s3.resize( valCount ); + s1inc.resize( valCount ); + s1azi.resize( valCount ); + s2inc.resize( valCount ); + s2azi.resize( valCount ); + s3inc.resize( valCount ); + s3azi.resize( valCount ); #pragma omp parallel for schedule( dynamic ) - for ( long vIdx = 0; vIdx < static_cast( valCount ); ++vIdx ) - { - caf::Ten3f T( s11[vIdx], s22[vIdx], s33[vIdx], s12[vIdx], s23[vIdx], s13[vIdx] ); - cvf::Vec3f principalDirs[3]; - cvf::Vec3f principals = T.calculatePrincipals( principalDirs ); - s1[vIdx] = principals[0]; - s2[vIdx] = principals[1]; - s3[vIdx] = principals[2]; + for ( long vIdx = 0; vIdx < static_cast( valCount ); ++vIdx ) + { + caf::Ten3f T( s11[vIdx], s22[vIdx], s33[vIdx], s12[vIdx], s23[vIdx], s13[vIdx] ); + cvf::Vec3f principalDirs[3]; + cvf::Vec3f principals = T.calculatePrincipals( principalDirs ); + s1[vIdx] = principals[0]; + s2[vIdx] = principals[1]; + s3[vIdx] = principals[2]; - if ( principals[0] != std::numeric_limits::infinity() ) - { - RiaOffshoreSphericalCoords sphCoord1( principalDirs[0] ); - s1inc[vIdx] = cvf::Math::toDegrees( sphCoord1.inc() ); - s1azi[vIdx] = cvf::Math::toDegrees( sphCoord1.azi() ); - } - else - { - s1inc[vIdx] = std::numeric_limits::infinity(); - s1azi[vIdx] = std::numeric_limits::infinity(); - } + if ( principals[0] != std::numeric_limits::infinity() ) + { + RiaOffshoreSphericalCoords sphCoord1( principalDirs[0] ); + s1inc[vIdx] = cvf::Math::toDegrees( sphCoord1.inc() ); + s1azi[vIdx] = cvf::Math::toDegrees( sphCoord1.azi() ); + } + else + { + s1inc[vIdx] = std::numeric_limits::infinity(); + s1azi[vIdx] = std::numeric_limits::infinity(); + } - if ( principals[1] != std::numeric_limits::infinity() ) - { - RiaOffshoreSphericalCoords sphCoord2( principalDirs[1] ); - s2inc[vIdx] = cvf::Math::toDegrees( sphCoord2.inc() ); - s2azi[vIdx] = cvf::Math::toDegrees( sphCoord2.azi() ); - } - else - { - s2inc[vIdx] = std::numeric_limits::infinity(); - s2azi[vIdx] = std::numeric_limits::infinity(); - } + if ( principals[1] != std::numeric_limits::infinity() ) + { + RiaOffshoreSphericalCoords sphCoord2( principalDirs[1] ); + s2inc[vIdx] = cvf::Math::toDegrees( sphCoord2.inc() ); + s2azi[vIdx] = cvf::Math::toDegrees( sphCoord2.azi() ); + } + else + { + s2inc[vIdx] = std::numeric_limits::infinity(); + s2azi[vIdx] = std::numeric_limits::infinity(); + } - if ( principals[2] != std::numeric_limits::infinity() ) - { - RiaOffshoreSphericalCoords sphCoord3( principalDirs[2] ); - s3inc[vIdx] = cvf::Math::toDegrees( sphCoord3.inc() ); - s3azi[vIdx] = cvf::Math::toDegrees( sphCoord3.azi() ); - } - else - { - s3inc[vIdx] = std::numeric_limits::infinity(); - s3azi[vIdx] = std::numeric_limits::infinity(); + if ( principals[2] != std::numeric_limits::infinity() ) + { + RiaOffshoreSphericalCoords sphCoord3( principalDirs[2] ); + s3inc[vIdx] = cvf::Math::toDegrees( sphCoord3.inc() ); + s3azi[vIdx] = cvf::Math::toDegrees( sphCoord3.azi() ); + } + else + { + s3inc[vIdx] = std::numeric_limits::infinity(); + s3azi[vIdx] = std::numeric_limits::infinity(); + } } } - - frameCountProgress.incrementProgress(); + stepCountProgress.incrementProgress(); } RigFemScalarResultFrames* requestedPrincipal = m_resultCollection->findOrLoadScalarResult( partIndex, resVarAddr ); diff --git a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorQ.cpp b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorQ.cpp index 301ac50e1f..7e09aa0e51 100644 --- a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorQ.cpp +++ b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorQ.cpp @@ -58,56 +58,59 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorQ::calculate( int partIndex, { CVF_ASSERT( resVarAddr.fieldName == "ST" && resVarAddr.componentName == "Q" ); - caf::ProgressInfo frameCountProgress( m_resultCollection->frameCount() * 5, "" ); - frameCountProgress.setProgressDescription( + caf::ProgressInfo stepCountProgress( m_resultCollection->timeStepCount() * 5, "" ); + stepCountProgress.setProgressDescription( "Calculating " + QString::fromStdString( resVarAddr.fieldName + ": " + resVarAddr.componentName ) ); - frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); + stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() ); RigFemScalarResultFrames* st11 = m_resultCollection->findOrLoadScalarResult( partIndex, RigFemResultAddress( resVarAddr.resultPosType, "ST", "S1" ) ); - frameCountProgress.incrementProgress(); - frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); + stepCountProgress.incrementProgress(); + stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() ); RigFemScalarResultFrames* st22 = m_resultCollection->findOrLoadScalarResult( partIndex, RigFemResultAddress( resVarAddr.resultPosType, "ST", "S2" ) ); - frameCountProgress.incrementProgress(); - frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); + stepCountProgress.incrementProgress(); + stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() ); RigFemScalarResultFrames* st33 = m_resultCollection->findOrLoadScalarResult( partIndex, RigFemResultAddress( resVarAddr.resultPosType, "ST", "S3" ) ); - frameCountProgress.incrementProgress(); - frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); + stepCountProgress.incrementProgress(); + stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() ); RigFemScalarResultFrames* stm = m_resultCollection->findOrLoadScalarResult( partIndex, RigFemResultAddress( resVarAddr.resultPosType, "ST", "SM" ) ); RigFemScalarResultFrames* dstDataFrames = m_resultCollection->createScalarResult( partIndex, resVarAddr ); - frameCountProgress.incrementProgress(); + stepCountProgress.incrementProgress(); - int frameCount = st11->frameCount(); - for ( int fIdx = 0; fIdx < frameCount; ++fIdx ) + const int timeSteps = st11->timeStepCount(); + for ( int stepIdx = 0; stepIdx < timeSteps; stepIdx++ ) { - const std::vector& st11Data = st11->frameData( fIdx ); - const std::vector& st22Data = st22->frameData( fIdx ); - const std::vector& st33Data = st33->frameData( fIdx ); + const int frameCount = st11->frameCount( stepIdx ); + for ( int fIdx = 0; fIdx < frameCount; fIdx++ ) + { + const std::vector& st11Data = st11->frameData( stepIdx, fIdx ); + const std::vector& st22Data = st22->frameData( stepIdx, fIdx ); + const std::vector& st33Data = st33->frameData( stepIdx, fIdx ); - const std::vector& stmData = stm->frameData( fIdx ); + const std::vector& stmData = stm->frameData( stepIdx, fIdx ); - std::vector& dstFrameData = dstDataFrames->frameData( fIdx ); - size_t valCount = st11Data.size(); - dstFrameData.resize( valCount ); + std::vector& dstFrameData = dstDataFrames->frameData( stepIdx, fIdx ); + size_t valCount = st11Data.size(); + dstFrameData.resize( valCount ); #pragma omp parallel for - for ( long vIdx = 0; vIdx < static_cast( valCount ); ++vIdx ) - { - float stmVal = stmData[vIdx]; - float st11Corr = st11Data[vIdx] - stmVal; - float st22Corr = st22Data[vIdx] - stmVal; - float st33Corr = st33Data[vIdx] - stmVal; + for ( long vIdx = 0; vIdx < static_cast( valCount ); ++vIdx ) + { + float stmVal = stmData[vIdx]; + float st11Corr = st11Data[vIdx] - stmVal; + float st22Corr = st22Data[vIdx] - stmVal; + float st33Corr = st33Data[vIdx] - stmVal; - dstFrameData[vIdx] = sqrt( 1.5 * ( st11Corr * st11Corr + st22Corr * st22Corr + st33Corr * st33Corr ) ); + dstFrameData[vIdx] = sqrt( 1.5 * ( st11Corr * st11Corr + st22Corr * st22Corr + st33Corr * st33Corr ) ); + } } - - frameCountProgress.incrementProgress(); + stepCountProgress.incrementProgress(); } return dstDataFrames; diff --git a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorSFI.cpp b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorSFI.cpp index a280f5fcfb..c50827adbf 100644 --- a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorSFI.cpp +++ b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorSFI.cpp @@ -60,10 +60,10 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorSFI::calculate( int partInde QString progressText = "Calculating " + QString::fromStdString( resAddr.fieldName + ": " + resAddr.componentName ); - caf::ProgressInfo frameCountProgress( static_cast( m_resultCollection->frameCount() ) * 3, progressText ); + caf::ProgressInfo stepCountProgress( static_cast( m_resultCollection->timeStepCount() ) * 3, progressText ); auto loadFrameLambda = [&]( const QString& component ) { - auto task = frameCountProgress.task( "Loading " + component, m_resultCollection->frameCount() ); + auto task = stepCountProgress.task( "Loading " + component, m_resultCollection->timeStepCount() ); return m_resultCollection->findOrLoadScalarResult( partIndex, resAddr.copyWithComponent( component.toStdString() ) ); }; @@ -76,36 +76,39 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorSFI::calculate( int partInde (float)( m_resultCollection->parameterCohesion() / tan( m_resultCollection->parameterFrictionAngleRad() ) ); float sinFricAng = sin( m_resultCollection->parameterFrictionAngleRad() ); - int frameCount = se1Frames->frameCount(); - for ( int fIdx = 0; fIdx < frameCount; ++fIdx ) + const int timeSteps = se1Frames->timeStepCount(); + for ( int stepIdx = 0; stepIdx < timeSteps; stepIdx++ ) { - auto task = frameCountProgress.task( QString( "Frame %1" ).arg( fIdx ) ); + auto task = stepCountProgress.task( QString( "Step %1" ).arg( stepIdx ) ); - const std::vector& se1Data = se1Frames->frameData( fIdx ); - const std::vector& se3Data = se3Frames->frameData( fIdx ); + const int frameCount = se1Frames->frameCount( stepIdx ); + for ( int fIdx = 0; fIdx < frameCount; fIdx++ ) + { + const std::vector& se1Data = se1Frames->frameData( stepIdx, fIdx ); + const std::vector& se3Data = se3Frames->frameData( stepIdx, fIdx ); - std::vector& dstFrameData = dstDataFrames->frameData( fIdx ); - size_t valCount = se1Data.size(); - dstFrameData.resize( valCount ); + std::vector& dstFrameData = dstDataFrames->frameData( stepIdx, fIdx ); + size_t valCount = se1Data.size(); + dstFrameData.resize( valCount ); #pragma omp parallel for - for ( long vIdx = 0; vIdx < static_cast( valCount ); ++vIdx ) - { - float se1 = se1Data[vIdx]; - float se3 = se3Data[vIdx]; - float se1Se3Diff = se1 - se3; + for ( long vIdx = 0; vIdx < static_cast( valCount ); ++vIdx ) + { + float se1 = se1Data[vIdx]; + float se3 = se3Data[vIdx]; + float se1Se3Diff = se1 - se3; - if ( fabs( se1Se3Diff ) < 1e-7 ) - { - dstFrameData[vIdx] = std::numeric_limits::infinity(); - } - else - { - dstFrameData[vIdx] = ( ( cohPrFricAngle + 0.5 * ( se1Data[vIdx] + se3Data[vIdx] ) ) * sinFricAng ) / - ( 0.5 * ( se1Data[vIdx] - se3Data[vIdx] ) ); + if ( fabs( se1Se3Diff ) < 1e-7 ) + { + dstFrameData[vIdx] = std::numeric_limits::infinity(); + } + else + { + dstFrameData[vIdx] = ( ( cohPrFricAngle + 0.5 * ( se1Data[vIdx] + se3Data[vIdx] ) ) * sinFricAng ) / + ( 0.5 * ( se1Data[vIdx] - se3Data[vIdx] ) ); + } } } } - return dstDataFrames; } diff --git a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorSM.cpp b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorSM.cpp index dcab7c0e61..6ba239d074 100644 --- a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorSM.cpp +++ b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorSM.cpp @@ -61,10 +61,10 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorSM::calculate( int partIndex QString progressText = "Calculating " + QString::fromStdString( resVarAddr.fieldName + ": " + resVarAddr.componentName ); - caf::ProgressInfo frameCountProgress( static_cast( m_resultCollection->frameCount() ) * 4, progressText ); + caf::ProgressInfo stepCountProgress( static_cast( m_resultCollection->timeStepCount() ) * 4, progressText ); auto loadFrameLambda = [&]( const QString& component ) { - auto task = frameCountProgress.task( component ); + auto task = stepCountProgress.task( component ); return m_resultCollection->findOrLoadScalarResult( partIndex, resVarAddr.copyWithComponent( component.toStdString() ) ); }; @@ -75,25 +75,28 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorSM::calculate( int partIndex RigFemScalarResultFrames* dstDataFrames = m_resultCollection->createScalarResult( partIndex, resVarAddr ); - int frameCount = st11->frameCount(); - for ( int fIdx = 0; fIdx < frameCount; ++fIdx ) + const int timeSteps = st11->timeStepCount(); + for ( int stepIdx = 0; stepIdx < timeSteps; stepIdx++ ) { - auto task = frameCountProgress.task( QString( "Frame %1" ).arg( fIdx ) ); + auto task = stepCountProgress.task( QString( "Step %1" ).arg( stepIdx ) ); - const std::vector& st11Data = st11->frameData( fIdx ); - const std::vector& st22Data = st22->frameData( fIdx ); - const std::vector& st33Data = st33->frameData( fIdx ); + const int frameCount = st11->frameCount( stepIdx ); + for ( int fIdx = 0; fIdx < frameCount; fIdx++ ) + { + const std::vector& st11Data = st11->frameData( stepIdx, fIdx ); + const std::vector& st22Data = st22->frameData( stepIdx, fIdx ); + const std::vector& st33Data = st33->frameData( stepIdx, fIdx ); - std::vector& dstFrameData = dstDataFrames->frameData( fIdx ); - size_t valCount = st11Data.size(); - dstFrameData.resize( valCount ); + std::vector& dstFrameData = dstDataFrames->frameData( stepIdx, fIdx ); + size_t valCount = st11Data.size(); + dstFrameData.resize( valCount ); #pragma omp parallel for - for ( long vIdx = 0; vIdx < static_cast( valCount ); ++vIdx ) - { - dstFrameData[vIdx] = ( st11Data[vIdx] + st22Data[vIdx] + st33Data[vIdx] ) / 3.0f; + for ( long vIdx = 0; vIdx < static_cast( valCount ); ++vIdx ) + { + dstFrameData[vIdx] = ( st11Data[vIdx] + st22Data[vIdx] + st33Data[vIdx] ) / 3.0f; + } } } - return dstDataFrames; } diff --git a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorShearSE.cpp b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorShearSE.cpp index acf12a05f4..5abae098f5 100644 --- a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorShearSE.cpp +++ b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorShearSE.cpp @@ -59,13 +59,13 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorShearSE::calculate( int part { QString progressText = "Calculating " + QString::fromStdString( resAddr.fieldName + ": " + resAddr.componentName ); - caf::ProgressInfo frameCountProgress( static_cast( m_resultCollection->frameCount() ) * 2, progressText ); + caf::ProgressInfo stepCountProgress( static_cast( m_resultCollection->timeStepCount() ) * 2, progressText ); RigFemScalarResultFrames* dstDataFrames = m_resultCollection->createScalarResult( partIndex, resAddr ); RigFemScalarResultFrames* srcDataFrames = nullptr; { - auto task = frameCountProgress.task( "S-Bar", m_resultCollection->frameCount() ); + auto task = stepCountProgress.task( "S-Bar", m_resultCollection->timeStepCount() ); srcDataFrames = m_resultCollection->findOrLoadScalarResult( partIndex, RigFemResultAddress( resAddr.resultPosType, "S-Bar", @@ -73,52 +73,54 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorShearSE::calculate( int part } const RigFemPart* femPart = m_resultCollection->parts()->part( partIndex ); - float inf = std::numeric_limits::infinity(); + constexpr float inf = std::numeric_limits::infinity(); - int frameCount = srcDataFrames->frameCount(); - - for ( int fIdx = 0; fIdx < frameCount; ++fIdx ) + const int timeSteps = srcDataFrames->timeStepCount(); + for ( int stepIdx = 0; stepIdx < timeSteps; stepIdx++ ) { - auto task = frameCountProgress.task( QString( "Frame %1" ).arg( fIdx ) ); + auto task = stepCountProgress.task( QString( "Step %1" ).arg( stepIdx ) ); - const std::vector& srcSFrameData = srcDataFrames->frameData( fIdx ); - std::vector& dstFrameData = dstDataFrames->frameData( fIdx ); - size_t valCount = srcSFrameData.size(); - dstFrameData.resize( valCount ); + const int frameCount = srcDataFrames->frameCount( stepIdx ); + for ( int fIdx = 0; fIdx < frameCount; fIdx++ ) + { + const std::vector& srcSFrameData = srcDataFrames->frameData( stepIdx, fIdx ); + std::vector& dstFrameData = dstDataFrames->frameData( stepIdx, fIdx ); + size_t valCount = srcSFrameData.size(); + dstFrameData.resize( valCount ); - int elementCount = femPart->elementCount(); + int elementCount = femPart->elementCount(); #pragma omp parallel for - for ( int elmIdx = 0; elmIdx < elementCount; ++elmIdx ) - { - RigElementType elmType = femPart->elementType( elmIdx ); - - int elmNodeCount = RigFemTypes::elementNodeCount( femPart->elementType( elmIdx ) ); - - if ( elmType == HEX8P ) + for ( int elmIdx = 0; elmIdx < elementCount; ++elmIdx ) { - for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx ) + RigElementType elmType = femPart->elementType( elmIdx ); + + int elmNodeCount = RigFemTypes::elementNodeCount( femPart->elementType( elmIdx ) ); + + if ( elmType == HEX8P ) { - size_t elmNodResIdx = femPart->elementNodeResultIdx( elmIdx, elmNodIdx ); - if ( elmNodResIdx < srcSFrameData.size() ) + for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx ) { - dstFrameData[elmNodResIdx] = -srcSFrameData[elmNodResIdx]; + size_t elmNodResIdx = femPart->elementNodeResultIdx( elmIdx, elmNodIdx ); + if ( elmNodResIdx < srcSFrameData.size() ) + { + dstFrameData[elmNodResIdx] = -srcSFrameData[elmNodResIdx]; + } } } - } - else - { - for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx ) + else { - size_t elmNodResIdx = femPart->elementNodeResultIdx( elmIdx, elmNodIdx ); - if ( elmNodResIdx < dstFrameData.size() ) + for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx ) { - dstFrameData[elmNodResIdx] = inf; + size_t elmNodResIdx = femPart->elementNodeResultIdx( elmIdx, elmNodIdx ); + if ( elmNodResIdx < dstFrameData.size() ) + { + dstFrameData[elmNodResIdx] = inf; + } } } } } } - return dstDataFrames; } diff --git a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorShearST.cpp b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorShearST.cpp index eb7ca09a6a..b29274301a 100644 --- a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorShearST.cpp +++ b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorShearST.cpp @@ -57,10 +57,10 @@ bool RigFemPartResultCalculatorShearST::isMatching( const RigFemResultAddress& r //-------------------------------------------------------------------------------------------------- RigFemScalarResultFrames* RigFemPartResultCalculatorShearST::calculate( int partIndex, const RigFemResultAddress& resVarAddr ) { - caf::ProgressInfo frameCountProgress( m_resultCollection->frameCount() * 2, "" ); - frameCountProgress.setProgressDescription( + caf::ProgressInfo stepCountProgress( m_resultCollection->timeStepCount() * 2, "" ); + stepCountProgress.setProgressDescription( "Calculating " + QString::fromStdString( resVarAddr.fieldName + ": " + resVarAddr.componentName ) ); - frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); + stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() ); RigFemScalarResultFrames* srcSDataFrames = m_resultCollection->findOrLoadScalarResult( partIndex, @@ -69,24 +69,27 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorShearST::calculate( int part resVarAddr.componentName ) ); RigFemScalarResultFrames* dstDataFrames = m_resultCollection->createScalarResult( partIndex, resVarAddr ); - frameCountProgress.incrementProgress(); + stepCountProgress.incrementProgress(); - int frameCount = srcSDataFrames->frameCount(); - for ( int fIdx = 0; fIdx < frameCount; ++fIdx ) + const int timeSteps = srcSDataFrames->timeStepCount(); + for ( int stepIdx = 0; stepIdx < timeSteps; stepIdx++ ) { - const std::vector& srcSFrameData = srcSDataFrames->frameData( fIdx ); - std::vector& dstFrameData = dstDataFrames->frameData( fIdx ); + const int frameCount = srcSDataFrames->frameCount( stepIdx ); + for ( int fIdx = 0; fIdx < frameCount; fIdx++ ) + { + const std::vector& srcSFrameData = srcSDataFrames->frameData( stepIdx, fIdx ); + std::vector& dstFrameData = dstDataFrames->frameData( stepIdx, fIdx ); - size_t valCount = srcSFrameData.size(); - dstFrameData.resize( valCount ); + size_t valCount = srcSFrameData.size(); + dstFrameData.resize( valCount ); #pragma omp parallel for - for ( long vIdx = 0; vIdx < static_cast( valCount ); ++vIdx ) - { - dstFrameData[vIdx] = -srcSFrameData[vIdx]; + for ( long vIdx = 0; vIdx < static_cast( valCount ); ++vIdx ) + { + dstFrameData[vIdx] = -srcSFrameData[vIdx]; + } } - - frameCountProgress.incrementProgress(); + stepCountProgress.incrementProgress(); } return dstDataFrames; diff --git a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorShearSlipIndicator.cpp b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorShearSlipIndicator.cpp index 298ab3d953..8ffb7e0ba8 100644 --- a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorShearSlipIndicator.cpp +++ b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorShearSlipIndicator.cpp @@ -61,24 +61,24 @@ RigFemScalarResultFrames* { CVF_ASSERT( isMatching( resVarAddr ) ); - caf::ProgressInfo frameCountProgress( m_resultCollection->frameCount() * 3, "" ); - frameCountProgress.setProgressDescription( "Calculating Shear Slip Indicator." ); + caf::ProgressInfo stepCountProgress( m_resultCollection->timeStepCount() * 3, "" ); + stepCountProgress.setProgressDescription( "Calculating Shear Slip Indicator." ); // Pore pressure - frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); + stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() ); RigFemScalarResultFrames* porePressureDataFrames = m_resultCollection->findOrLoadScalarResult( partIndex, RigFemResultAddress( resVarAddr.resultPosType, "POR-Bar", "" ) ); - frameCountProgress.incrementProgress(); + stepCountProgress.incrementProgress(); // Total vertical stress (ST.S33) - frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); + stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() ); RigFemScalarResultFrames* stressDataFrames = m_resultCollection->findOrLoadScalarResult( partIndex, RigFemResultAddress( resVarAddr.resultPosType, "ST", "S33" ) ); - frameCountProgress.incrementProgress(); + stepCountProgress.incrementProgress(); - frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); + stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() ); RigFemScalarResultFrames* shearSlipIndicatorFrames = m_resultCollection->createScalarResult( partIndex, RigFemResultAddress( resVarAddr.resultPosType, "ST", "DPN" ) ); @@ -88,76 +88,79 @@ RigFemScalarResultFrames* float inf = std::numeric_limits::infinity(); - frameCountProgress.setNextProgressIncrement( 1u ); + stepCountProgress.setNextProgressIncrement( 1u ); - int frameCount = stressDataFrames->frameCount(); - for ( int fIdx = 0; fIdx < frameCount; ++fIdx ) + const int timeSteps = stressDataFrames->timeStepCount(); + for ( int stepIdx = 0; stepIdx < timeSteps; stepIdx++ ) { - const std::vector& porFrameData = porePressureDataFrames->frameData( fIdx ); - if ( porFrameData.empty() ) continue; + const int frameCount = stressDataFrames->frameCount( stepIdx ); + for ( int fIdx = 0; fIdx < frameCount; fIdx++ ) + { + const std::vector& porFrameData = porePressureDataFrames->frameData( stepIdx, fIdx ); + if ( porFrameData.empty() ) continue; - const std::vector& stressFrameData = stressDataFrames->frameData( fIdx ); - if ( stressFrameData.empty() ) continue; + const std::vector& stressFrameData = stressDataFrames->frameData( stepIdx, fIdx ); + if ( stressFrameData.empty() ) continue; - std::vector& shearSlipIndicatorFrameData = shearSlipIndicatorFrames->frameData( fIdx ); + std::vector& shearSlipIndicatorFrameData = shearSlipIndicatorFrames->frameData( stepIdx, fIdx ); - size_t valCount = stressFrameData.size(); - shearSlipIndicatorFrameData.resize( valCount ); + size_t valCount = stressFrameData.size(); + shearSlipIndicatorFrameData.resize( valCount ); - int elementCount = femPart->elementCount(); + int elementCount = femPart->elementCount(); #pragma omp parallel for - for ( int elmIdx = 0; elmIdx < elementCount; ++elmIdx ) - { - RigElementType elmType = femPart->elementType( elmIdx ); - - int elmNodeCount = RigFemTypes::elementNodeCount( femPart->elementType( elmIdx ) ); - - if ( femPart->isHexahedron( elmIdx ) ) + for ( int elmIdx = 0; elmIdx < elementCount; ++elmIdx ) { - for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx ) + RigElementType elmType = femPart->elementType( elmIdx ); + + int elmNodeCount = RigFemTypes::elementNodeCount( femPart->elementType( elmIdx ) ); + + if ( femPart->isHexahedron( elmIdx ) ) { - // Use hydrostatic pressure from cell centroid. - // Use centroid to avoid intra-element differences - cvf::Vec3d cellCentroid = femPartGrid->cellCentroid( elmIdx ); - double cellCentroidTvdMSL = -cellCentroid.z(); - - double waterDensity = m_resultCollection->waterDensityShearSlipIndicator(); - double cellCenterHydroStaticPressure = - RigGeoMechWellLogExtractor::hydroStaticPorePressureAtDepth( cellCentroidTvdMSL, waterDensity ); - - size_t elmNodResIdx = femPart->elementNodeResultIdx( elmIdx, elmNodIdx ); - if ( elmNodResIdx < stressFrameData.size() ) + for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx ) { - // Pore pressure (unit: Bar) - float porePressureBar = porFrameData[elmNodResIdx]; - float totalVerticalStress = stressFrameData[elmNodResIdx]; + // Use hydrostatic pressure from cell centroid. + // Use centroid to avoid intra-element differences + cvf::Vec3d cellCentroid = femPartGrid->cellCentroid( elmIdx ); + double cellCentroidTvdMSL = -cellCentroid.z(); - float shearSlipIndicator = inf; - if ( porePressureBar != inf && totalVerticalStress - cellCenterHydroStaticPressure != 0.0 ) + double waterDensity = m_resultCollection->waterDensityShearSlipIndicator(); + double cellCenterHydroStaticPressure = + RigGeoMechWellLogExtractor::hydroStaticPorePressureAtDepth( cellCentroidTvdMSL, waterDensity ); + + size_t elmNodResIdx = femPart->elementNodeResultIdx( elmIdx, elmNodIdx ); + if ( elmNodResIdx < stressFrameData.size() ) { - shearSlipIndicator = ( porePressureBar - cellCenterHydroStaticPressure ) / - ( totalVerticalStress - cellCenterHydroStaticPressure ); - } + // Pore pressure (unit: Bar) + float porePressureBar = porFrameData[elmNodResIdx]; + float totalVerticalStress = stressFrameData[elmNodResIdx]; - shearSlipIndicatorFrameData[elmNodResIdx] = shearSlipIndicator; + float shearSlipIndicator = inf; + if ( porePressureBar != inf && totalVerticalStress - cellCenterHydroStaticPressure != 0.0 ) + { + shearSlipIndicator = ( porePressureBar - cellCenterHydroStaticPressure ) / + ( totalVerticalStress - cellCenterHydroStaticPressure ); + } + + shearSlipIndicatorFrameData[elmNodResIdx] = shearSlipIndicator; + } } } - } - else - { - for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx ) + else { - size_t elmNodResIdx = femPart->elementNodeResultIdx( elmIdx, elmNodIdx ); - if ( elmNodResIdx < stressFrameData.size() ) + for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx ) { - shearSlipIndicatorFrameData[elmNodResIdx] = inf; + size_t elmNodResIdx = femPart->elementNodeResultIdx( elmIdx, elmNodIdx ); + if ( elmNodResIdx < stressFrameData.size() ) + { + shearSlipIndicatorFrameData[elmNodResIdx] = inf; + } } } } } - - frameCountProgress.incrementProgress(); + stepCountProgress.incrementProgress(); } RigFemScalarResultFrames* requestedResultFrames = m_resultCollection->findOrLoadScalarResult( partIndex, resVarAddr ); diff --git a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorStressAnisotropy.cpp b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorStressAnisotropy.cpp index f2f61fe102..da942a0686 100644 --- a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorStressAnisotropy.cpp +++ b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorStressAnisotropy.cpp @@ -59,13 +59,13 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorStressAnisotropy::calculate( { CVF_ASSERT( isMatching( resVarAddr ) ); - caf::ProgressInfo frameCountProgress( m_resultCollection->frameCount() * 4, "" ); - frameCountProgress.setProgressDescription( + caf::ProgressInfo stepCountProgress( m_resultCollection->timeStepCount() * 4, "" ); + stepCountProgress.setProgressDescription( "Calculating " + QString::fromStdString( resVarAddr.fieldName + ": " + resVarAddr.componentName ) ); RigFemScalarResultFrames* s1Frames = nullptr; { - auto task = frameCountProgress.task( "Loading S1.", m_resultCollection->frameCount() ); + auto task = stepCountProgress.task( "Loading S1.", m_resultCollection->timeStepCount() ); s1Frames = m_resultCollection->findOrLoadScalarResult( partIndex, RigFemResultAddress( resVarAddr.resultPosType, resVarAddr.fieldName, @@ -74,7 +74,7 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorStressAnisotropy::calculate( RigFemScalarResultFrames* s2Frames = nullptr; { - auto task = frameCountProgress.task( "Loading S2.", m_resultCollection->frameCount() ); + auto task = stepCountProgress.task( "Loading S2.", m_resultCollection->timeStepCount() ); s2Frames = m_resultCollection->findOrLoadScalarResult( partIndex, RigFemResultAddress( resVarAddr.resultPosType, resVarAddr.fieldName, @@ -83,7 +83,7 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorStressAnisotropy::calculate( RigFemScalarResultFrames* s3Frames = nullptr; { - auto task = frameCountProgress.task( "Loading S3.", m_resultCollection->frameCount() ); + auto task = stepCountProgress.task( "Loading S3.", m_resultCollection->timeStepCount() ); s3Frames = m_resultCollection->findOrLoadScalarResult( partIndex, RigFemResultAddress( resVarAddr.resultPosType, resVarAddr.fieldName, @@ -100,34 +100,37 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorStressAnisotropy::calculate( m_resultCollection->createScalarResult( partIndex, RigFemResultAddress( resVarAddr.resultPosType, resVarAddr.fieldName, "SA23" ) ); - int frameCount = s1Frames->frameCount(); - for ( int fIdx = 0; fIdx < frameCount; ++fIdx ) + const int timeSteps = s1Frames->timeStepCount(); + for ( int stepIdx = 0; stepIdx < timeSteps; stepIdx++ ) { - auto task = frameCountProgress.task( QString( "Calculating %1/%2." ).arg( fIdx ).arg( frameCount - 1 ) ); + auto task = stepCountProgress.task( QString( "Calculating %1/%2." ).arg( stepIdx ).arg( timeSteps - 1 ) ); - const std::vector& s1 = s1Frames->frameData( fIdx ); - const std::vector& s2 = s2Frames->frameData( fIdx ); - const std::vector& s3 = s3Frames->frameData( fIdx ); + const int frameCount = s1Frames->frameCount( stepIdx ); + for ( int fIdx = 0; fIdx < frameCount; fIdx++ ) + { + const std::vector& s1 = s1Frames->frameData( stepIdx, fIdx ); + const std::vector& s2 = s2Frames->frameData( stepIdx, fIdx ); + const std::vector& s3 = s3Frames->frameData( stepIdx, fIdx ); - std::vector& s12 = s12Frames->frameData( fIdx ); - std::vector& s13 = s13Frames->frameData( fIdx ); - std::vector& s23 = s23Frames->frameData( fIdx ); + std::vector& s12 = s12Frames->frameData( stepIdx, fIdx ); + std::vector& s13 = s13Frames->frameData( stepIdx, fIdx ); + std::vector& s23 = s23Frames->frameData( stepIdx, fIdx ); - size_t valCount = s1.size(); + size_t valCount = s1.size(); - s12.resize( valCount ); - s13.resize( valCount ); - s23.resize( valCount ); + s12.resize( valCount ); + s13.resize( valCount ); + s23.resize( valCount ); #pragma omp parallel for schedule( dynamic ) - for ( long vIdx = 0; vIdx < static_cast( valCount ); ++vIdx ) - { - s12[vIdx] = 2.0 * ( s1[vIdx] - s2[vIdx] ) / ( s1[vIdx] + s2[vIdx] ); - s13[vIdx] = 2.0 * ( s1[vIdx] - s3[vIdx] ) / ( s1[vIdx] + s3[vIdx] ); - s23[vIdx] = 2.0 * ( s2[vIdx] - s3[vIdx] ) / ( s2[vIdx] + s3[vIdx] ); + for ( long vIdx = 0; vIdx < static_cast( valCount ); ++vIdx ) + { + s12[vIdx] = 2.0 * ( s1[vIdx] - s2[vIdx] ) / ( s1[vIdx] + s2[vIdx] ); + s13[vIdx] = 2.0 * ( s1[vIdx] - s3[vIdx] ) / ( s1[vIdx] + s3[vIdx] ); + s23[vIdx] = 2.0 * ( s2[vIdx] - s3[vIdx] ) / ( s2[vIdx] + s3[vIdx] ); + } } } - RigFemScalarResultFrames* requestedStress = m_resultCollection->findOrLoadScalarResult( partIndex, resVarAddr ); return requestedStress; } @@ -140,13 +143,13 @@ RigFemScalarResultFrames* { CVF_ASSERT( isMatching( resVarAddr ) ); - caf::ProgressInfo frameCountProgress( m_resultCollection->frameCount() * 4, "" ); - frameCountProgress.setProgressDescription( + caf::ProgressInfo stepCountProgress( m_resultCollection->timeStepCount() * 4, "" ); + stepCountProgress.setProgressDescription( "Calculating " + QString::fromStdString( resVarAddr.fieldName + ": " + resVarAddr.componentName ) ); RigFemScalarResultFrames* s1Frames = nullptr; { - auto task = frameCountProgress.task( "Loading S1.", m_resultCollection->frameCount() ); + auto task = stepCountProgress.task( "Loading S1.", m_resultCollection->timeStepCount() ); s1Frames = m_resultCollection->findOrLoadScalarResult( partIndex, RigFemResultAddress( resVarAddr.resultPosType, resVarAddr.fieldName, @@ -155,7 +158,7 @@ RigFemScalarResultFrames* RigFemScalarResultFrames* s2Frames = nullptr; { - auto task = frameCountProgress.task( "Loading S2.", m_resultCollection->frameCount() ); + auto task = stepCountProgress.task( "Loading S2.", m_resultCollection->timeStepCount() ); s2Frames = m_resultCollection->findOrLoadScalarResult( partIndex, RigFemResultAddress( resVarAddr.resultPosType, resVarAddr.fieldName, @@ -164,7 +167,7 @@ RigFemScalarResultFrames* RigFemScalarResultFrames* s3Frames = nullptr; { - auto task = frameCountProgress.task( "Loading S3.", m_resultCollection->frameCount() ); + auto task = stepCountProgress.task( "Loading S3.", m_resultCollection->timeStepCount() ); s3Frames = m_resultCollection->findOrLoadScalarResult( partIndex, RigFemResultAddress( resVarAddr.resultPosType, resVarAddr.fieldName, @@ -190,59 +193,64 @@ RigFemScalarResultFrames* "SA23", resVarAddr.timeLapseBaseStepIdx ) ); - float inf = std::numeric_limits::infinity(); - int frameCount = s1Frames->frameCount(); - int baseTimeStep = resVarAddr.timeLapseBaseStepIdx; + constexpr float inf = std::numeric_limits::infinity(); + int baseTimeStep, baseFrame; + std::tie( baseTimeStep, baseFrame ) = + m_resultCollection->stepListIndexToTimeStepAndDataFrameIndex( resVarAddr.timeLapseBaseStepIdx ); - for ( int fIdx = 0; fIdx < frameCount; ++fIdx ) + const int timeSteps = s1Frames->timeStepCount(); + for ( int stepIdx = 0; stepIdx < timeSteps; stepIdx++ ) { - auto task = frameCountProgress.task( QString( "Calculating %1/%2." ).arg( fIdx ).arg( frameCount - 1 ) ); + auto task = stepCountProgress.task( QString( "Calculating %1 of %2." ).arg( stepIdx ).arg( timeSteps - 1 ) ); - const std::vector& s1t = s1Frames->frameData( fIdx ); - const std::vector& s2t = s2Frames->frameData( fIdx ); - const std::vector& s3t = s3Frames->frameData( fIdx ); - - const std::vector& s1b = s1Frames->frameData( baseTimeStep ); - const std::vector& s2b = s2Frames->frameData( baseTimeStep ); - const std::vector& s3b = s3Frames->frameData( baseTimeStep ); - - std::vector& s12 = s12Frames->frameData( fIdx ); - std::vector& s13 = s13Frames->frameData( fIdx ); - std::vector& s23 = s23Frames->frameData( fIdx ); - - size_t valCount = s1t.size(); - - s12.resize( valCount, 0.0 ); - s13.resize( valCount, 0.0 ); - s23.resize( valCount, 0.0 ); - - double epsilon = 0.0000001; -#pragma omp parallel for schedule( dynamic ) - for ( long vIdx = 0; vIdx < static_cast( valCount ); ++vIdx ) + const int frameCount = s1Frames->frameCount( stepIdx ); + for ( int fIdx = 0; fIdx < frameCount; fIdx++ ) { - if ( fIdx != baseTimeStep ) + const std::vector& s1t = s1Frames->frameData( stepIdx, fIdx ); + const std::vector& s2t = s2Frames->frameData( stepIdx, fIdx ); + const std::vector& s3t = s3Frames->frameData( stepIdx, fIdx ); + + const std::vector& s1b = s1Frames->frameData( baseTimeStep, baseFrame ); + const std::vector& s2b = s2Frames->frameData( baseTimeStep, baseFrame ); + const std::vector& s3b = s3Frames->frameData( baseTimeStep, baseFrame ); + + std::vector& s12 = s12Frames->frameData( stepIdx, fIdx ); + std::vector& s13 = s13Frames->frameData( stepIdx, fIdx ); + std::vector& s23 = s23Frames->frameData( stepIdx, fIdx ); + + size_t valCount = s1t.size(); + + s12.resize( valCount, 0.0 ); + s13.resize( valCount, 0.0 ); + s23.resize( valCount, 0.0 ); + + double epsilon = 0.0000001; +#pragma omp parallel for schedule( dynamic ) + for ( long vIdx = 0; vIdx < static_cast( valCount ); ++vIdx ) { - double diffS1 = s1t[vIdx] - s1b[vIdx]; - double diffS2 = s2t[vIdx] - s2b[vIdx]; - double diffS3 = s3t[vIdx] - s3b[vIdx]; - if ( std::abs( diffS1 + diffS2 ) > epsilon ) - s12[vIdx] = 2.0 * ( diffS1 - diffS2 ) / ( diffS1 + diffS2 ); - else - s12[vIdx] = inf; + if ( fIdx != baseTimeStep ) + { + double diffS1 = s1t[vIdx] - s1b[vIdx]; + double diffS2 = s2t[vIdx] - s2b[vIdx]; + double diffS3 = s3t[vIdx] - s3b[vIdx]; + if ( std::abs( diffS1 + diffS2 ) > epsilon ) + s12[vIdx] = 2.0 * ( diffS1 - diffS2 ) / ( diffS1 + diffS2 ); + else + s12[vIdx] = inf; - if ( std::abs( diffS1 + diffS3 ) > epsilon ) - s13[vIdx] = 2.0 * ( diffS1 - diffS3 ) / ( diffS1 + diffS3 ); - else - s13[vIdx] = inf; + if ( std::abs( diffS1 + diffS3 ) > epsilon ) + s13[vIdx] = 2.0 * ( diffS1 - diffS3 ) / ( diffS1 + diffS3 ); + else + s13[vIdx] = inf; - if ( std::abs( diffS2 + diffS3 ) > epsilon ) - s23[vIdx] = 2.0 * ( diffS2 - diffS3 ) / ( diffS2 + diffS3 ); - else - s23[vIdx] = inf; + if ( std::abs( diffS2 + diffS3 ) > epsilon ) + s23[vIdx] = 2.0 * ( diffS2 - diffS3 ) / ( diffS2 + diffS3 ); + else + s23[vIdx] = inf; + } } } } - RigFemScalarResultFrames* requestedStress = m_resultCollection->findOrLoadScalarResult( partIndex, resVarAddr ); return requestedStress; } diff --git a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorStressGradients.cpp b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorStressGradients.cpp index 83a66c5c39..361bfc027b 100644 --- a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorStressGradients.cpp +++ b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorStressGradients.cpp @@ -74,10 +74,10 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorStressGradients::calculate( { CVF_ASSERT( resVarAddr.fieldName == "ST" || resVarAddr.fieldName == "SE" ); - caf::ProgressInfo frameCountProgress( m_resultCollection->frameCount() * 2, "" ); - frameCountProgress.setProgressDescription( + caf::ProgressInfo stepCountProgress( m_resultCollection->timeStepCount() * 2, "" ); + stepCountProgress.setProgressDescription( "Calculating gradient: " + QString::fromStdString( resVarAddr.fieldName + ": " + resVarAddr.componentName ) ); - frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); + stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() ); QString origFieldName = QString::fromStdString( resVarAddr.fieldName ); QString origComponentName = QString::fromStdString( resVarAddr.componentName ); @@ -105,64 +105,67 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorStressGradients::calculate( RigFemResultAddress( resVarAddr.resultPosType, resVarAddr.fieldName, componentName.toStdString() + "-Z" ) ); - frameCountProgress.incrementProgress(); + stepCountProgress.incrementProgress(); const RigFemPart* femPart = m_resultCollection->parts()->part( partIndex ); int elementCount = femPart->elementCount(); const std::vector& nodeCoords = femPart->nodes().coordinates; - int frameCount = inputResultFrames->frameCount(); - for ( int fIdx = 0; fIdx < frameCount; ++fIdx ) + const int timeSteps = inputResultFrames->timeStepCount(); + for ( int stepIdx = 0; stepIdx < timeSteps; stepIdx++ ) { - const std::vector& inputData = inputResultFrames->frameData( fIdx ); + const int frameCount = inputResultFrames->frameCount( stepIdx ); + for ( int fIdx = 0; fIdx < frameCount; fIdx++ ) + { + const std::vector& inputData = inputResultFrames->frameData( stepIdx, fIdx ); - std::vector& dstFrameDataX = dataFramesX->frameData( fIdx ); - std::vector& dstFrameDataY = dataFramesY->frameData( fIdx ); - std::vector& dstFrameDataZ = dataFramesZ->frameData( fIdx ); - size_t valCount = inputData.size(); - if ( valCount == 0 ) continue; + std::vector& dstFrameDataX = dataFramesX->frameData( stepIdx, fIdx ); + std::vector& dstFrameDataY = dataFramesY->frameData( stepIdx, fIdx ); + std::vector& dstFrameDataZ = dataFramesZ->frameData( stepIdx, fIdx ); + size_t valCount = inputData.size(); + if ( valCount == 0 ) continue; - dstFrameDataX.resize( valCount ); - dstFrameDataY.resize( valCount ); - dstFrameDataZ.resize( valCount ); + dstFrameDataX.resize( valCount ); + dstFrameDataY.resize( valCount ); + dstFrameDataZ.resize( valCount ); #pragma omp parallel for schedule( dynamic ) - for ( int elmIdx = 0; elmIdx < elementCount; ++elmIdx ) - { - const int* cornerIndices = femPart->connectivities( elmIdx ); - RigElementType elmType = femPart->elementType( elmIdx ); - - if ( !( elmType == HEX8P || elmType == HEX8 ) ) continue; - - // Find the corner coordinates for element - std::array hexCorners; - for ( int i = 0; i < 8; i++ ) + for ( int elmIdx = 0; elmIdx < elementCount; ++elmIdx ) { - hexCorners[i] = cvf::Vec3d( nodeCoords[cornerIndices[i]] ); - } + const int* cornerIndices = femPart->connectivities( elmIdx ); + RigElementType elmType = femPart->elementType( elmIdx ); - // Find the corresponding corner values for the element - std::array cornerValues; + if ( !( elmType == HEX8P || elmType == HEX8 ) ) continue; - int elmNodeCount = RigFemTypes::elementNodeCount( elmType ); - for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx ) - { - size_t elmNodResIdx = femPart->elementNodeResultIdx( elmIdx, elmNodIdx ); - cornerValues[elmNodIdx] = inputData[elmNodResIdx]; - } + // Find the corner coordinates for element + std::array hexCorners; + for ( int i = 0; i < 8; i++ ) + { + hexCorners[i] = cvf::Vec3d( nodeCoords[cornerIndices[i]] ); + } - std::array gradients = RigHexGradientTools::gradients( hexCorners, cornerValues ); + // Find the corresponding corner values for the element + std::array cornerValues; - for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx ) - { - size_t elmNodResIdx = femPart->elementNodeResultIdx( elmIdx, elmNodIdx ); - dstFrameDataX[elmNodResIdx] = gradients[elmNodIdx].x(); - dstFrameDataY[elmNodResIdx] = gradients[elmNodIdx].y(); - dstFrameDataZ[elmNodResIdx] = gradients[elmNodIdx].z(); + int elmNodeCount = RigFemTypes::elementNodeCount( elmType ); + for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx ) + { + size_t elmNodResIdx = femPart->elementNodeResultIdx( elmIdx, elmNodIdx ); + cornerValues[elmNodIdx] = inputData[elmNodResIdx]; + } + + std::array gradients = RigHexGradientTools::gradients( hexCorners, cornerValues ); + + for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx ) + { + size_t elmNodResIdx = femPart->elementNodeResultIdx( elmIdx, elmNodIdx ); + dstFrameDataX[elmNodResIdx] = gradients[elmNodIdx].x(); + dstFrameDataY[elmNodResIdx] = gradients[elmNodIdx].y(); + dstFrameDataZ[elmNodResIdx] = gradients[elmNodIdx].z(); + } } } - - frameCountProgress.incrementProgress(); + stepCountProgress.incrementProgress(); } RigFemScalarResultFrames* requestedStress = m_resultCollection->findOrLoadScalarResult( partIndex, resVarAddr ); diff --git a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorSurfaceAlignedStress.cpp b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorSurfaceAlignedStress.cpp index 2837a9f112..b56f47f837 100644 --- a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorSurfaceAlignedStress.cpp +++ b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorSurfaceAlignedStress.cpp @@ -67,36 +67,36 @@ RigFemScalarResultFrames* resVarAddr.componentName == "TP" || resVarAddr.componentName == "TPinc" || resVarAddr.componentName == "FAULTMOB" || resVarAddr.componentName == "PCRIT" ); - caf::ProgressInfo frameCountProgress( m_resultCollection->frameCount() * 7, "" ); - frameCountProgress.setProgressDescription( + caf::ProgressInfo stepCountProgress( m_resultCollection->timeStepCount() * 7, "" ); + stepCountProgress.setProgressDescription( "Calculating " + QString::fromStdString( resVarAddr.fieldName + ": " + resVarAddr.componentName ) ); - frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); + stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() ); RigFemScalarResultFrames* s11Frames = m_resultCollection->findOrLoadScalarResult( partIndex, RigFemResultAddress( RIG_ELEMENT_NODAL, resVarAddr.fieldName, "S11" ) ); - frameCountProgress.incrementProgress(); - frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); + stepCountProgress.incrementProgress(); + stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() ); RigFemScalarResultFrames* s22Frames = m_resultCollection->findOrLoadScalarResult( partIndex, RigFemResultAddress( RIG_ELEMENT_NODAL, resVarAddr.fieldName, "S22" ) ); - frameCountProgress.incrementProgress(); - frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); + stepCountProgress.incrementProgress(); + stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() ); RigFemScalarResultFrames* s33Frames = m_resultCollection->findOrLoadScalarResult( partIndex, RigFemResultAddress( RIG_ELEMENT_NODAL, resVarAddr.fieldName, "S33" ) ); - frameCountProgress.incrementProgress(); - frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); + stepCountProgress.incrementProgress(); + stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() ); RigFemScalarResultFrames* s12Frames = m_resultCollection->findOrLoadScalarResult( partIndex, RigFemResultAddress( RIG_ELEMENT_NODAL, resVarAddr.fieldName, "S12" ) ); - frameCountProgress.incrementProgress(); - frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); + stepCountProgress.incrementProgress(); + stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() ); RigFemScalarResultFrames* s23Frames = m_resultCollection->findOrLoadScalarResult( partIndex, RigFemResultAddress( RIG_ELEMENT_NODAL, resVarAddr.fieldName, "S23" ) ); - frameCountProgress.incrementProgress(); - frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); + stepCountProgress.incrementProgress(); + stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() ); RigFemScalarResultFrames* s13Frames = m_resultCollection->findOrLoadScalarResult( partIndex, RigFemResultAddress( RIG_ELEMENT_NODAL, resVarAddr.fieldName, "S13" ) ); @@ -134,7 +134,7 @@ RigFemScalarResultFrames* m_resultCollection->createScalarResult( partIndex, RigFemResultAddress( resVarAddr.resultPosType, resVarAddr.fieldName, "PCRIT" ) ); - frameCountProgress.incrementProgress(); + stepCountProgress.incrementProgress(); const RigFemPart* femPart = m_resultCollection->parts()->part( partIndex ); const std::vector& nodeCoordinates = femPart->nodes().coordinates; @@ -142,124 +142,127 @@ RigFemScalarResultFrames* float tanFricAng = tan( m_resultCollection->parameterFrictionAngleRad() ); float cohPrTanFricAngle = (float)( m_resultCollection->parameterCohesion() / tanFricAng ); - int frameCount = s11Frames->frameCount(); - for ( int fIdx = 0; fIdx < frameCount; ++fIdx ) + const int timeSteps = s11Frames->timeStepCount(); + for ( int stepIdx = 0; stepIdx < timeSteps; stepIdx++ ) { - const std::vector& s11 = s11Frames->frameData( fIdx ); - if ( s11.empty() ) continue; + const int frameCount = s11Frames->frameCount( stepIdx ); + for ( int fIdx = 0; fIdx < frameCount; fIdx++ ) + { + const std::vector& s11 = s11Frames->frameData( stepIdx, fIdx ); + if ( s11.empty() ) continue; - const std::vector& s22 = s22Frames->frameData( fIdx ); - const std::vector& s33 = s33Frames->frameData( fIdx ); - const std::vector& s12 = s12Frames->frameData( fIdx ); - const std::vector& s23 = s23Frames->frameData( fIdx ); - const std::vector& s13 = s13Frames->frameData( fIdx ); + const std::vector& s22 = s22Frames->frameData( stepIdx, fIdx ); + const std::vector& s33 = s33Frames->frameData( stepIdx, fIdx ); + const std::vector& s12 = s12Frames->frameData( stepIdx, fIdx ); + const std::vector& s23 = s23Frames->frameData( stepIdx, fIdx ); + const std::vector& s13 = s13Frames->frameData( stepIdx, fIdx ); - std::vector& SNDat = SNFrames->frameData( fIdx ); - std::vector& STHDat = STHFrames->frameData( fIdx ); - std::vector& STQVDat = STQVFrames->frameData( fIdx ); - std::vector& TNHDat = TNHFrames->frameData( fIdx ); - std::vector& TNQVDat = TNQVFrames->frameData( fIdx ); - std::vector& THQVDat = THQVFrames->frameData( fIdx ); - std::vector& TPDat = TPFrames->frameData( fIdx ); - std::vector& TincDat = TPincFrames->frameData( fIdx ); - std::vector& FAULTMOBDat = FAULTMOBFrames->frameData( fIdx ); - std::vector& PCRITDat = PCRITFrames->frameData( fIdx ); + std::vector& SNDat = SNFrames->frameData( stepIdx, fIdx ); + std::vector& STHDat = STHFrames->frameData( stepIdx, fIdx ); + std::vector& STQVDat = STQVFrames->frameData( stepIdx, fIdx ); + std::vector& TNHDat = TNHFrames->frameData( stepIdx, fIdx ); + std::vector& TNQVDat = TNQVFrames->frameData( stepIdx, fIdx ); + std::vector& THQVDat = THQVFrames->frameData( stepIdx, fIdx ); + std::vector& TPDat = TPFrames->frameData( stepIdx, fIdx ); + std::vector& TincDat = TPincFrames->frameData( stepIdx, fIdx ); + std::vector& FAULTMOBDat = FAULTMOBFrames->frameData( stepIdx, fIdx ); + std::vector& PCRITDat = PCRITFrames->frameData( stepIdx, fIdx ); - // HACK ! Todo : make it robust against other elements than Hex8 - size_t valCount = s11.size() * 3; // Number of Elm Node Face results 24 = 4 * num faces = 3* numElmNodes + // HACK ! Todo : make it robust against other elements than Hex8 + size_t valCount = s11.size() * 3; // Number of Elm Node Face results 24 = 4 * num faces = 3* numElmNodes - SNDat.resize( valCount ); - STHDat.resize( valCount ); - STQVDat.resize( valCount ); - TNHDat.resize( valCount ); - TNQVDat.resize( valCount ); - THQVDat.resize( valCount ); - TPDat.resize( valCount ); - TincDat.resize( valCount ); - FAULTMOBDat.resize( valCount ); - PCRITDat.resize( valCount ); + SNDat.resize( valCount ); + STHDat.resize( valCount ); + STQVDat.resize( valCount ); + TNHDat.resize( valCount ); + TNQVDat.resize( valCount ); + THQVDat.resize( valCount ); + TPDat.resize( valCount ); + TincDat.resize( valCount ); + FAULTMOBDat.resize( valCount ); + PCRITDat.resize( valCount ); - int elementCount = femPart->elementCount(); + int elementCount = femPart->elementCount(); #pragma omp parallel for - for ( int elmIdx = 0; elmIdx < elementCount; ++elmIdx ) - { - RigElementType elmType = femPart->elementType( elmIdx ); - int faceCount = RigFemTypes::elementFaceCount( elmType ); - const int* elmNodeIndices = femPart->connectivities( elmIdx ); - - int elmNodFaceResIdxElmStart = elmIdx * 24; // HACK should get from part - - for ( int lfIdx = 0; lfIdx < faceCount; ++lfIdx ) + for ( int elmIdx = 0; elmIdx < elementCount; ++elmIdx ) { - int faceNodeCount = 0; - const int* localElmNodeIndicesForFace = - RigFemTypes::localElmNodeIndicesForFace( elmType, lfIdx, &faceNodeCount ); - if ( faceNodeCount == 4 ) + RigElementType elmType = femPart->elementType( elmIdx ); + int faceCount = RigFemTypes::elementFaceCount( elmType ); + const int* elmNodeIndices = femPart->connectivities( elmIdx ); + + int elmNodFaceResIdxElmStart = elmIdx * 24; // HACK should get from part + + for ( int lfIdx = 0; lfIdx < faceCount; ++lfIdx ) { - int elmNodFaceResIdxFaceStart = elmNodFaceResIdxElmStart + lfIdx * 4; // HACK - cvf::Vec3f quadVxs[4]; - - quadVxs[0] = ( nodeCoordinates[elmNodeIndices[localElmNodeIndicesForFace[0]]] ); - quadVxs[1] = ( nodeCoordinates[elmNodeIndices[localElmNodeIndicesForFace[1]]] ); - quadVxs[2] = ( nodeCoordinates[elmNodeIndices[localElmNodeIndicesForFace[2]]] ); - quadVxs[3] = ( nodeCoordinates[elmNodeIndices[localElmNodeIndicesForFace[3]]] ); - - cvf::Mat3f rotMx = cvf::GeometryTools::computePlaneHorizontalRotationMx( quadVxs[2] - quadVxs[0], - quadVxs[3] - quadVxs[1] ); - - size_t qElmNodeResIdx[4]; - qElmNodeResIdx[0] = femPart->elementNodeResultIdx( elmIdx, localElmNodeIndicesForFace[0] ); - qElmNodeResIdx[1] = femPart->elementNodeResultIdx( elmIdx, localElmNodeIndicesForFace[1] ); - qElmNodeResIdx[2] = femPart->elementNodeResultIdx( elmIdx, localElmNodeIndicesForFace[2] ); - qElmNodeResIdx[3] = femPart->elementNodeResultIdx( elmIdx, localElmNodeIndicesForFace[3] ); - - for ( int qIdx = 0; qIdx < 4; ++qIdx ) + int faceNodeCount = 0; + const int* localElmNodeIndicesForFace = + RigFemTypes::localElmNodeIndicesForFace( elmType, lfIdx, &faceNodeCount ); + if ( faceNodeCount == 4 ) { - size_t elmNodResIdx = qElmNodeResIdx[qIdx]; - float t11 = s11[elmNodResIdx]; - float t22 = s22[elmNodResIdx]; - float t33 = s33[elmNodResIdx]; - float t12 = s12[elmNodResIdx]; - float t23 = s23[elmNodResIdx]; - float t13 = s13[elmNodResIdx]; + int elmNodFaceResIdxFaceStart = elmNodFaceResIdxElmStart + lfIdx * 4; // HACK + cvf::Vec3f quadVxs[4]; - caf::Ten3f tensor( t11, t22, t33, t12, t23, t13 ); - caf::Ten3f xfTen = tensor.rotated( rotMx ); - int elmNodFaceResIdx = elmNodFaceResIdxFaceStart + qIdx; + quadVxs[0] = ( nodeCoordinates[elmNodeIndices[localElmNodeIndicesForFace[0]]] ); + quadVxs[1] = ( nodeCoordinates[elmNodeIndices[localElmNodeIndicesForFace[1]]] ); + quadVxs[2] = ( nodeCoordinates[elmNodeIndices[localElmNodeIndicesForFace[2]]] ); + quadVxs[3] = ( nodeCoordinates[elmNodeIndices[localElmNodeIndicesForFace[3]]] ); - float szx = xfTen[caf::Ten3f::SZX]; - float syz = xfTen[caf::Ten3f::SYZ]; - float szz = xfTen[caf::Ten3f::SZZ]; + cvf::Mat3f rotMx = cvf::GeometryTools::computePlaneHorizontalRotationMx( quadVxs[2] - quadVxs[0], + quadVxs[3] - quadVxs[1] ); - STHDat[elmNodFaceResIdx] = xfTen[caf::Ten3f::SXX]; - STQVDat[elmNodFaceResIdx] = xfTen[caf::Ten3f::SYY]; - SNDat[elmNodFaceResIdx] = xfTen[caf::Ten3f::SZZ]; + size_t qElmNodeResIdx[4]; + qElmNodeResIdx[0] = femPart->elementNodeResultIdx( elmIdx, localElmNodeIndicesForFace[0] ); + qElmNodeResIdx[1] = femPart->elementNodeResultIdx( elmIdx, localElmNodeIndicesForFace[1] ); + qElmNodeResIdx[2] = femPart->elementNodeResultIdx( elmIdx, localElmNodeIndicesForFace[2] ); + qElmNodeResIdx[3] = femPart->elementNodeResultIdx( elmIdx, localElmNodeIndicesForFace[3] ); - TNHDat[elmNodFaceResIdx] = xfTen[caf::Ten3f::SZX]; - TNQVDat[elmNodFaceResIdx] = xfTen[caf::Ten3f::SYZ]; - THQVDat[elmNodFaceResIdx] = xfTen[caf::Ten3f::SXY]; - - float TP = sqrt( szx * szx + syz * syz ); - TPDat[elmNodFaceResIdx] = TP; - - if ( TP > 1e-5 ) + for ( int qIdx = 0; qIdx < 4; ++qIdx ) { - TincDat[elmNodFaceResIdx] = cvf::Math::toDegrees( acos( syz / TP ) ); - } - else - { - TincDat[elmNodFaceResIdx] = std::numeric_limits::infinity(); - } + size_t elmNodResIdx = qElmNodeResIdx[qIdx]; + float t11 = s11[elmNodResIdx]; + float t22 = s22[elmNodResIdx]; + float t33 = s33[elmNodResIdx]; + float t12 = s12[elmNodResIdx]; + float t23 = s23[elmNodResIdx]; + float t13 = s13[elmNodResIdx]; - FAULTMOBDat[elmNodFaceResIdx] = TP / ( tanFricAng * ( szz + cohPrTanFricAngle ) ); - PCRITDat[elmNodFaceResIdx] = szz - TP / tanFricAng; + caf::Ten3f tensor( t11, t22, t33, t12, t23, t13 ); + caf::Ten3f xfTen = tensor.rotated( rotMx ); + int elmNodFaceResIdx = elmNodFaceResIdxFaceStart + qIdx; + + float szx = xfTen[caf::Ten3f::SZX]; + float syz = xfTen[caf::Ten3f::SYZ]; + float szz = xfTen[caf::Ten3f::SZZ]; + + STHDat[elmNodFaceResIdx] = xfTen[caf::Ten3f::SXX]; + STQVDat[elmNodFaceResIdx] = xfTen[caf::Ten3f::SYY]; + SNDat[elmNodFaceResIdx] = xfTen[caf::Ten3f::SZZ]; + + TNHDat[elmNodFaceResIdx] = xfTen[caf::Ten3f::SZX]; + TNQVDat[elmNodFaceResIdx] = xfTen[caf::Ten3f::SYZ]; + THQVDat[elmNodFaceResIdx] = xfTen[caf::Ten3f::SXY]; + + float TP = sqrt( szx * szx + syz * syz ); + TPDat[elmNodFaceResIdx] = TP; + + if ( TP > 1e-5 ) + { + TincDat[elmNodFaceResIdx] = cvf::Math::toDegrees( acos( syz / TP ) ); + } + else + { + TincDat[elmNodFaceResIdx] = std::numeric_limits::infinity(); + } + + FAULTMOBDat[elmNodFaceResIdx] = TP / ( tanFricAng * ( szz + cohPrTanFricAngle ) ); + PCRITDat[elmNodFaceResIdx] = szz - TP / tanFricAng; + } } } } } - - frameCountProgress.incrementProgress(); + stepCountProgress.incrementProgress(); } RigFemScalarResultFrames* requestedSurfStress = m_resultCollection->findOrLoadScalarResult( partIndex, resVarAddr ); diff --git a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorSurfaceAngles.cpp b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorSurfaceAngles.cpp index c876545148..92c07564cc 100644 --- a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorSurfaceAngles.cpp +++ b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorSurfaceAngles.cpp @@ -65,8 +65,8 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorSurfaceAngles::calculate( in { CVF_ASSERT( resVarAddr.componentName == "Pazi" || resVarAddr.componentName == "Pinc" ); - caf::ProgressInfo frameCountProgress( m_resultCollection->frameCount() * 1, "" ); - frameCountProgress.setProgressDescription( + caf::ProgressInfo stepCountProgress( m_resultCollection->timeStepCount() * 1, "" ); + stepCountProgress.setProgressDescription( "Calculating " + QString::fromStdString( resVarAddr.fieldName + ": " + resVarAddr.componentName ) ); RigFemScalarResultFrames* PaziFrames = @@ -78,65 +78,68 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorSurfaceAngles::calculate( in const RigFemPart* femPart = m_resultCollection->parts()->part( partIndex ); const std::vector& nodeCoordinates = femPart->nodes().coordinates; - int frameCount = m_resultCollection->frameCount(); // HACK ! Todo : make it robust against other elements than Hex8 size_t valCount = femPart->elementCount() * 24; // Number of Elm Node Face results 24 = 4 * num faces = 3* // numElmNodes - for ( int fIdx = 0; fIdx < frameCount; ++fIdx ) + const int timeSteps = PaziFrames->timeStepCount(); + for ( int stepIdx = 0; stepIdx < timeSteps; stepIdx++ ) { - std::vector& Pazi = PaziFrames->frameData( fIdx ); - std::vector& Pinc = PincFrames->frameData( fIdx ); - - Pazi.resize( valCount ); - Pinc.resize( valCount ); - - int elementCount = femPart->elementCount(); -#pragma omp parallel for - for ( int elmIdx = 0; elmIdx < elementCount; ++elmIdx ) + const int frameCount = PaziFrames->frameCount( stepIdx ); + for ( int fIdx = 0; fIdx < frameCount; fIdx++ ) { - RigElementType elmType = femPart->elementType( elmIdx ); - int faceCount = RigFemTypes::elementFaceCount( elmType ); - const int* elmNodeIndices = femPart->connectivities( elmIdx ); + std::vector& Pazi = PaziFrames->frameData( stepIdx, fIdx ); + std::vector& Pinc = PincFrames->frameData( stepIdx, fIdx ); - int elmNodFaceResIdxElmStart = elmIdx * 24; // HACK should get from part + Pazi.resize( valCount ); + Pinc.resize( valCount ); - for ( int lfIdx = 0; lfIdx < faceCount; ++lfIdx ) + int elementCount = femPart->elementCount(); +#pragma omp parallel for + for ( int elmIdx = 0; elmIdx < elementCount; ++elmIdx ) { - int faceNodeCount = 0; - const int* localElmNodeIndicesForFace = - RigFemTypes::localElmNodeIndicesForFace( elmType, lfIdx, &faceNodeCount ); - if ( faceNodeCount == 4 ) + RigElementType elmType = femPart->elementType( elmIdx ); + int faceCount = RigFemTypes::elementFaceCount( elmType ); + const int* elmNodeIndices = femPart->connectivities( elmIdx ); + + int elmNodFaceResIdxElmStart = elmIdx * 24; // HACK should get from part + + for ( int lfIdx = 0; lfIdx < faceCount; ++lfIdx ) { - int elmNodFaceResIdxFaceStart = elmNodFaceResIdxElmStart + lfIdx * 4; // HACK - cvf::Vec3f quadVxs[4]; - - quadVxs[0] = ( nodeCoordinates[elmNodeIndices[localElmNodeIndicesForFace[0]]] ); - quadVxs[1] = ( nodeCoordinates[elmNodeIndices[localElmNodeIndicesForFace[1]]] ); - quadVxs[2] = ( nodeCoordinates[elmNodeIndices[localElmNodeIndicesForFace[2]]] ); - quadVxs[3] = ( nodeCoordinates[elmNodeIndices[localElmNodeIndicesForFace[3]]] ); - - cvf::Mat3f rotMx = cvf::GeometryTools::computePlaneHorizontalRotationMx( quadVxs[2] - quadVxs[0], - quadVxs[3] - quadVxs[1] ); - RiaOffshoreSphericalCoords sphCoord( - cvf::Vec3f( rotMx.rowCol( 2, 0 ), rotMx.rowCol( 2, 1 ), rotMx.rowCol( 2, 2 ) ) ); // Use Ez - // from the - // matrix - // as plane - // normal - - for ( int qIdx = 0; qIdx < 4; ++qIdx ) + int faceNodeCount = 0; + const int* localElmNodeIndicesForFace = + RigFemTypes::localElmNodeIndicesForFace( elmType, lfIdx, &faceNodeCount ); + if ( faceNodeCount == 4 ) { - int elmNodFaceResIdx = elmNodFaceResIdxFaceStart + qIdx; - Pazi[elmNodFaceResIdx] = cvf::Math::toDegrees( sphCoord.azi() ); - Pinc[elmNodFaceResIdx] = cvf::Math::toDegrees( sphCoord.inc() ); + int elmNodFaceResIdxFaceStart = elmNodFaceResIdxElmStart + lfIdx * 4; // HACK + cvf::Vec3f quadVxs[4]; + + quadVxs[0] = ( nodeCoordinates[elmNodeIndices[localElmNodeIndicesForFace[0]]] ); + quadVxs[1] = ( nodeCoordinates[elmNodeIndices[localElmNodeIndicesForFace[1]]] ); + quadVxs[2] = ( nodeCoordinates[elmNodeIndices[localElmNodeIndicesForFace[2]]] ); + quadVxs[3] = ( nodeCoordinates[elmNodeIndices[localElmNodeIndicesForFace[3]]] ); + + cvf::Mat3f rotMx = cvf::GeometryTools::computePlaneHorizontalRotationMx( quadVxs[2] - quadVxs[0], + quadVxs[3] - quadVxs[1] ); + RiaOffshoreSphericalCoords sphCoord( + cvf::Vec3f( rotMx.rowCol( 2, 0 ), rotMx.rowCol( 2, 1 ), rotMx.rowCol( 2, 2 ) ) ); // Use Ez + // from the + // matrix + // as plane + // normal + + for ( int qIdx = 0; qIdx < 4; ++qIdx ) + { + int elmNodFaceResIdx = elmNodFaceResIdxFaceStart + qIdx; + Pazi[elmNodFaceResIdx] = cvf::Math::toDegrees( sphCoord.azi() ); + Pinc[elmNodFaceResIdx] = cvf::Math::toDegrees( sphCoord.inc() ); + } } } } } - - frameCountProgress.incrementProgress(); + stepCountProgress.incrementProgress(); } RigFemScalarResultFrames* requestedPlaneAngle = m_resultCollection->findOrLoadScalarResult( partIndex, resVarAddr ); diff --git a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorTimeLapse.cpp b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorTimeLapse.cpp index 115e8903d1..ba37c4917b 100644 --- a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorTimeLapse.cpp +++ b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorTimeLapse.cpp @@ -83,10 +83,10 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorTimeLapse::calculate( int RigFemScalarResultFrames* RigFemPartResultCalculatorTimeLapse::calculateTimeLapse( int partIndex, const RigFemResultAddress& resVarAddr ) { - caf::ProgressInfo frameCountProgress( m_resultCollection->frameCount() * 2, "" ); - frameCountProgress.setProgressDescription( + caf::ProgressInfo stepCountProgress( m_resultCollection->timeStepCount() * 2, "" ); + stepCountProgress.setProgressDescription( "Calculating " + QString::fromStdString( resVarAddr.fieldName + ": " + resVarAddr.componentName ) ); - frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); + stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() ); RigFemResultAddress resVarNative( resVarAddr.resultPosType, resVarAddr.fieldName, @@ -109,30 +109,36 @@ RigFemScalarResultFrames* srcDataFrames = m_resultCollection->findOrLoadScalarResult( partIndex, resVarNative ); } - frameCountProgress.incrementProgress(); + stepCountProgress.incrementProgress(); - int frameCount = srcDataFrames->frameCount(); - int baseFrameIdx = resVarAddr.timeLapseBaseStepIdx; - if ( baseFrameIdx >= frameCount ) return dstDataFrames; - const std::vector& baseFrameData = srcDataFrames->frameData( baseFrameIdx ); + const int timeSteps = srcDataFrames->timeStepCount(); + auto [baseStepIdx, baseFrameIdx] = + m_resultCollection->stepListIndexToTimeStepAndDataFrameIndex( resVarAddr.timeLapseBaseStepIdx ); + + if ( baseStepIdx >= timeSteps ) return dstDataFrames; + + const std::vector& baseFrameData = srcDataFrames->frameData( baseStepIdx, baseFrameIdx ); if ( baseFrameData.empty() ) return dstDataFrames; - for ( int fIdx = 0; fIdx < frameCount; ++fIdx ) + for ( int stepIdx = 0; stepIdx < timeSteps; stepIdx++ ) { - const std::vector& srcFrameData = srcDataFrames->frameData( fIdx ); - if ( srcFrameData.empty() ) continue; // Create empty results + const int frameCount = srcDataFrames->frameCount( stepIdx ); + for ( int fIdx = 0; fIdx < frameCount; fIdx++ ) + { + const std::vector& srcFrameData = srcDataFrames->frameData( stepIdx, fIdx ); + if ( srcFrameData.empty() ) continue; // Create empty results - std::vector& dstFrameData = dstDataFrames->frameData( fIdx ); - size_t valCount = srcFrameData.size(); - dstFrameData.resize( valCount ); + std::vector& dstFrameData = dstDataFrames->frameData( stepIdx, fIdx ); + size_t valCount = srcFrameData.size(); + dstFrameData.resize( valCount ); #pragma omp parallel for - for ( long vIdx = 0; vIdx < static_cast( valCount ); ++vIdx ) - { - dstFrameData[vIdx] = srcFrameData[vIdx] - baseFrameData[vIdx]; + for ( long vIdx = 0; vIdx < static_cast( valCount ); ++vIdx ) + { + dstFrameData[vIdx] = srcFrameData[vIdx] - baseFrameData[vIdx]; + } } - - frameCountProgress.incrementProgress(); + stepCountProgress.incrementProgress(); } return dstDataFrames; @@ -147,10 +153,10 @@ RigFemScalarResultFrames* // Gamma time lapse needs to be calculated as ST_dt / POR_dt and not Gamma - Gamma_baseFrame see github // issue #937 - caf::ProgressInfo frameCountProgress( m_resultCollection->frameCount() * 3, "" ); - frameCountProgress.setProgressDescription( + caf::ProgressInfo stepCountProgress( m_resultCollection->timeStepCount() * 3, "" ); + stepCountProgress.setProgressDescription( "Calculating " + QString::fromStdString( resVarAddr.fieldName + ": " + resVarAddr.componentName ) ); - frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); + stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() ); RigFemResultAddress totStressCompAddr( resVarAddr.resultPosType, "ST", "", resVarAddr.timeLapseBaseStepIdx ); { @@ -172,22 +178,22 @@ RigFemScalarResultFrames* } RigFemScalarResultFrames* srcDataFrames = m_resultCollection->findOrLoadScalarResult( partIndex, totStressCompAddr ); - frameCountProgress.incrementProgress(); - frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); + stepCountProgress.incrementProgress(); + stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() ); RigFemScalarResultFrames* srcPORDataFrames = m_resultCollection ->findOrLoadScalarResult( partIndex, RigFemResultAddress( RIG_NODAL, "POR-Bar", "", resVarAddr.timeLapseBaseStepIdx ) ); RigFemScalarResultFrames* dstDataFrames = m_resultCollection->createScalarResult( partIndex, resVarAddr ); - frameCountProgress.incrementProgress(); + stepCountProgress.incrementProgress(); RigFemPartResultCalculatorGamma::calculateGammaFromFrames( partIndex, m_resultCollection->parts(), srcDataFrames, srcPORDataFrames, dstDataFrames, - &frameCountProgress ); + &stepCountProgress ); if ( resVarAddr.normalizeByHydrostaticPressure() && RigFemPartResultsCollection::isNormalizableResult( resVarAddr ) ) { RigFemPartResultCalculatorNormalized normalizedCalculator( *m_resultCollection ); diff --git a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp index 4bfc28c6ca..38c30e99a5 100644 --- a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp +++ b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp @@ -112,6 +112,22 @@ RigFemPartResultsCollection::RigFemPartResultsCollection( RifGeoMechReaderInterf femPartResult->initResultSteps( filteredStepNames ); } + // initialize step cache + { + int stepIdx = 0; + for ( auto& stepName : filteredStepNames ) + { + int frameIdx = 0; + for ( auto& frame : m_readerInterface->frameTimes( stepIdx ) ) + { + m_stepNames.emplace_back( stepName + " (" + std::to_string( frame ) + ")" ); + m_stepList.emplace_back( stepIdx, frameIdx ); + frameIdx++; + } + stepIdx++; + } + } + m_cohesion = 10.0; m_frictionAngleRad = cvf::Math::toRadians( 30.0 ); m_normalizationAirGap = 0.0; @@ -388,9 +404,9 @@ void RigFemPartResultsCollection::setReferenceTimeStep( int referenceTimeStep ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -int RigFemPartResultsCollection::referenceTimeStep() const +std::pair RigFemPartResultsCollection::referenceStepAndFrameIndex() const { - return m_referenceTimeStep; + return stepListIndexToTimeStepAndDataFrameIndex( m_referenceTimeStep ); } //-------------------------------------------------------------------------------------------------- @@ -405,7 +421,7 @@ void RigFemPartResultsCollection::setPermeabilityParameters( double fixe m_permeabilityExponent = permeabilityExponent; std::set results = initialPermeabilityDependentResults(); - for ( auto result : results ) + for ( auto& result : results ) { deleteResult( result ); } @@ -459,12 +475,12 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::findOrLoadScalarResult( i std::map> elementProperties = m_elementPropertyReader->readAllElementPropertiesInFileContainingField( resVarAddr.fieldName ); - for ( auto [addrString, values] : elementProperties ) + for ( auto& [addrString, values] : elementProperties ) { RigFemResultAddress addressForElement( RIG_ELEMENT, addrString, "" ); RigFemScalarResultFrames* currentFrames = m_femPartResults[partIndex]->createScalarResult( addressForElement ); - currentFrames->enableAsSingleFrameResult(); - currentFrames->frameData( 0 ).swap( values ); + currentFrames->enableAsSingleStepResult(); + currentFrames->frameData( 0, 0 ).swap( values ); } frames = m_femPartResults[partIndex]->findScalarResult( resVarAddr ); @@ -490,46 +506,50 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::findOrLoadScalarResult( i resultsForEachComponent.push_back( m_femPartResults[partIndex]->createScalarResult( resultAddressOfComponent ) ); } - int frameCount = this->frameCount(); - caf::ProgressInfo progress( frameCount, "" ); + int timeSteps = this->timeStepCount(); + caf::ProgressInfo progress( timeSteps, "" ); progress.setProgressDescription( QString( "Loading Native Result %1 %2" ).arg( resVarAddr.fieldName.c_str(), resVarAddr.componentName.c_str() ) ); - for ( int stepIndex = 0; stepIndex < frameCount; ++stepIndex ) + for ( int stepIndex = 0; stepIndex < timeSteps; ++stepIndex ) { std::vector frameTimes = m_readerInterface->frameTimes( stepIndex ); - int fIdx = (int)( frameTimes.size() - 1 ); - - std::vector*> componentDataVectors; - for ( auto& componentResult : resultsForEachComponent ) + for ( int frameIndex = 0; frameIndex < int( frameTimes.size() ); frameIndex++ ) { - componentDataVectors.push_back( &( componentResult->frameData( stepIndex ) ) ); - } + std::vector*> componentDataVectors; + for ( auto& componentResult : resultsForEachComponent ) + { + componentDataVectors.push_back( &( componentResult->frameData( stepIndex, frameIndex ) ) ); + } - switch ( resVarAddr.resultPosType ) - { - case RIG_NODAL: - m_readerInterface->readNodeField( resVarAddr.fieldName, partIndex, stepIndex, fIdx, &componentDataVectors ); - break; - case RIG_ELEMENT_NODAL: - m_readerInterface->readElementNodeField( resVarAddr.fieldName, - partIndex, - stepIndex, - fIdx, - &componentDataVectors ); - break; - case RIG_INTEGRATION_POINT: - m_readerInterface->readIntegrationPointField( resVarAddr.fieldName, - partIndex, - stepIndex, - fIdx, - &componentDataVectors ); - break; - default: - break; + switch ( resVarAddr.resultPosType ) + { + case RIG_NODAL: + m_readerInterface->readNodeField( resVarAddr.fieldName, + partIndex, + stepIndex, + frameIndex, + &componentDataVectors ); + break; + case RIG_ELEMENT_NODAL: + m_readerInterface->readElementNodeField( resVarAddr.fieldName, + partIndex, + stepIndex, + frameIndex, + &componentDataVectors ); + break; + case RIG_INTEGRATION_POINT: + m_readerInterface->readIntegrationPointField( resVarAddr.fieldName, + partIndex, + stepIndex, + frameIndex, + &componentDataVectors ); + break; + default: + break; + } } - progress.incrementProgress(); } @@ -940,7 +960,7 @@ std::vector //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RigFemPartResultsCollection::filteredStepNames() const +std::vector RigFemPartResultsCollection::filteredTimeStepNames() const { CVF_ASSERT( m_readerInterface.notNull() ); return m_readerInterface->filteredStepNames(); @@ -949,9 +969,52 @@ std::vector RigFemPartResultsCollection::filteredStepNames() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -int RigFemPartResultsCollection::frameCount() +int RigFemPartResultsCollection::timeStepCount() const { - return static_cast( filteredStepNames().size() ); + return static_cast( filteredTimeStepNames().size() ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +int RigFemPartResultsCollection::frameCount( int timeStepIndex ) const +{ + CVF_ASSERT( m_readerInterface.notNull() ); + return m_readerInterface->frameCount( timeStepIndex ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const std::vector>& RigFemPartResultsCollection::stepList() +{ + return m_stepList; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +int RigFemPartResultsCollection::totalSteps() +{ + return int( stepList().size() ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RigFemPartResultsCollection::stepNames() const +{ + return m_stepNames; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const std::pair RigFemPartResultsCollection::stepListIndexToTimeStepAndDataFrameIndex( int stepIndex ) const +{ + if ( stepIndex < 0 ) return std::make_pair( stepIndex, -1 ); + CVF_ASSERT( stepIndex < static_cast( m_stepList.size() ) ); + return m_stepList[stepIndex]; } //-------------------------------------------------------------------------------------------------- @@ -968,9 +1031,14 @@ bool RigFemPartResultsCollection::assertResultsLoaded( const RigFemResultAddress if ( m_femPartResults[pIdx].notNull() ) { RigFemScalarResultFrames* scalarResults = findOrLoadScalarResult( pIdx, resVarAddr ); - for ( int fIdx = 0; fIdx < scalarResults->frameCount(); ++fIdx ) + const int stepCount = scalarResults->timeStepCount(); + for ( int stepIdx = 0; stepIdx < stepCount; stepIdx++ ) { - foundResults = foundResults || !scalarResults->frameData( fIdx ).empty(); + const int frameCount = scalarResults->frameCount( stepIdx ); + for ( int fIdx = 0; fIdx < frameCount; ++fIdx ) + { + foundResults = foundResults || !scalarResults->frameData( stepIdx, fIdx ).empty(); + } } } } @@ -1029,19 +1097,6 @@ void RigFemPartResultsCollection::deleteResultForAllTimeSteps( const std::vector } } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RigFemPartResultsCollection::deleteResultFrame( const RigFemResultAddress& resVarAddr, int partIndex, int frameIndex ) -{ - CVF_ASSERT( resVarAddr.isValid() ); - RigFemScalarResultFrames* frames = m_femPartResults[partIndex]->findScalarResult( resVarAddr ); - if ( frames ) - { - std::vector().swap( frames->frameData( frameIndex ) ); - } -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -1059,13 +1114,15 @@ std::vector RigFemPartResultsCollection::loadedResults() co //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -const std::vector& - RigFemPartResultsCollection::resultValues( const RigFemResultAddress& resVarAddr, int partIndex, int frameIndex ) +const std::vector& RigFemPartResultsCollection::resultValues( const RigFemResultAddress& resVarAddr, + int partIndex, + int stepIndex, + int frameIndex ) { CVF_ASSERT( resVarAddr.isValid() ); RigFemScalarResultFrames* scalarResults = findOrLoadScalarResult( partIndex, resVarAddr ); - return scalarResults->frameData( frameIndex ); + return scalarResults->frameData( stepIndex, frameIndex ); } //-------------------------------------------------------------------------------------------------- @@ -1073,13 +1130,14 @@ const std::vector& //-------------------------------------------------------------------------------------------------- void RigFemPartResultsCollection::globalResultValues( const RigFemResultAddress& resVarAddr, int timeStepIndex, + int frameIndex, std::vector& resultValues ) { CVF_ASSERT( resVarAddr.isValid() ); for ( int i = 0; i < partCount(); i++ ) { - const std::vector& partResults = this->resultValues( resVarAddr, i, (int)timeStepIndex ); + const std::vector& partResults = this->resultValues( resVarAddr, i, timeStepIndex, frameIndex ); if ( partResults.empty() ) { size_t expectedSize = 0; @@ -1120,7 +1178,7 @@ void RigFemPartResultsCollection::globalResultValues( const RigFemResultAddress& /// //-------------------------------------------------------------------------------------------------- std::vector - RigFemPartResultsCollection::tensors( const RigFemResultAddress& resVarAddr, int partIndex, int frameIndex ) + RigFemPartResultsCollection::tensors( const RigFemResultAddress& resVarAddr, int partIndex, int stepIndex, int frameIndex ) { CVF_ASSERT( resVarAddr.resultPosType == RIG_ELEMENT_NODAL || resVarAddr.resultPosType == RIG_INTEGRATION_POINT ); @@ -1133,12 +1191,12 @@ std::vector return outputTensors; } - const std::vector& v11 = resultValues( addresses[caf::Ten3f::SXX], partIndex, frameIndex ); - const std::vector& v22 = resultValues( addresses[caf::Ten3f::SYY], partIndex, frameIndex ); - const std::vector& v33 = resultValues( addresses[caf::Ten3f::SZZ], partIndex, frameIndex ); - const std::vector& v12 = resultValues( addresses[caf::Ten3f::SXY], partIndex, frameIndex ); - const std::vector& v13 = resultValues( addresses[caf::Ten3f::SZX], partIndex, frameIndex ); - const std::vector& v23 = resultValues( addresses[caf::Ten3f::SYZ], partIndex, frameIndex ); + const std::vector& v11 = resultValues( addresses[caf::Ten3f::SXX], partIndex, stepIndex, frameIndex ); + const std::vector& v22 = resultValues( addresses[caf::Ten3f::SYY], partIndex, stepIndex, frameIndex ); + const std::vector& v33 = resultValues( addresses[caf::Ten3f::SZZ], partIndex, stepIndex, frameIndex ); + const std::vector& v12 = resultValues( addresses[caf::Ten3f::SXY], partIndex, stepIndex, frameIndex ); + const std::vector& v13 = resultValues( addresses[caf::Ten3f::SZX], partIndex, stepIndex, frameIndex ); + const std::vector& v23 = resultValues( addresses[caf::Ten3f::SYZ], partIndex, stepIndex, frameIndex ); size_t valCount = v11.size(); outputTensors.resize( valCount ); @@ -1173,11 +1231,12 @@ RigStatisticsDataCache* RigFemPartResultsCollection::statistics( const RigFemRes /// //-------------------------------------------------------------------------------------------------- void RigFemPartResultsCollection::minMaxScalarValues( const RigFemResultAddress& resVarAddr, + int stepIndex, int frameIndex, double* localMin, double* localMax ) { - this->statistics( resVarAddr )->minMaxCellScalarValues( frameIndex, *localMin, *localMax ); + this->statistics( resVarAddr )->minMaxCellScalarValues( stepIndex, *localMin, *localMax ); } //-------------------------------------------------------------------------------------------------- @@ -1195,10 +1254,11 @@ void RigFemPartResultsCollection::minMaxScalarValues( const RigFemResultAddress& //-------------------------------------------------------------------------------------------------- void RigFemPartResultsCollection::posNegClosestToZero( const RigFemResultAddress& resVarAddr, int frameIndex, + int stepIndex, double* localPosClosestToZero, double* localNegClosestToZero ) { - this->statistics( resVarAddr )->posNegClosestToZero( frameIndex, *localPosClosestToZero, *localNegClosestToZero ); + this->statistics( resVarAddr )->posNegClosestToZero( stepIndex, *localPosClosestToZero, *localNegClosestToZero ); } //-------------------------------------------------------------------------------------------------- @@ -1224,9 +1284,12 @@ void RigFemPartResultsCollection::meanScalarValue( const RigFemResultAddress& re //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigFemPartResultsCollection::meanScalarValue( const RigFemResultAddress& resVarAddr, int frameIndex, double* meanValue ) +void RigFemPartResultsCollection::meanScalarValue( const RigFemResultAddress& resVarAddr, + int stepIndex, + int frameIndex, + double* meanValue ) { - this->statistics( resVarAddr )->meanCellScalarValues( frameIndex, *meanValue ); + this->statistics( resVarAddr )->meanCellScalarValues( stepIndex, *meanValue ); } //-------------------------------------------------------------------------------------------------- @@ -1241,11 +1304,12 @@ void RigFemPartResultsCollection::p10p90ScalarValues( const RigFemResultAddress& /// //-------------------------------------------------------------------------------------------------- void RigFemPartResultsCollection::p10p90ScalarValues( const RigFemResultAddress& resVarAddr, + int stepIndex, int frameIndex, double* p10, double* p90 ) { - this->statistics( resVarAddr )->p10p90CellScalarValues( frameIndex, *p10, *p90 ); + this->statistics( resVarAddr )->p10p90CellScalarValues( stepIndex, *p10, *p90 ); } //-------------------------------------------------------------------------------------------------- @@ -1261,11 +1325,14 @@ void RigFemPartResultsCollection::sumScalarValue( const RigFemResultAddress& res //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigFemPartResultsCollection::sumScalarValue( const RigFemResultAddress& resVarAddr, int frameIndex, double* sum ) +void RigFemPartResultsCollection::sumScalarValue( const RigFemResultAddress& resVarAddr, + int stepIndex, + int frameIndex, + double* sum ) { CVF_ASSERT( sum ); - this->statistics( resVarAddr )->sumCellScalarValues( frameIndex, *sum ); + this->statistics( resVarAddr )->sumCellScalarValues( stepIndex, *sum ); } //-------------------------------------------------------------------------------------------------- @@ -1280,11 +1347,15 @@ const std::vector& RigFemPartResultsCollection::scalarValuesHistogram( c /// //-------------------------------------------------------------------------------------------------- const std::vector& RigFemPartResultsCollection::scalarValuesHistogram( const RigFemResultAddress& resVarAddr, + int stepIndex, int frameIndex ) { - return this->statistics( resVarAddr )->cellScalarValuesHistogram( frameIndex ); + return this->statistics( resVarAddr )->cellScalarValuesHistogram( stepIndex ); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- std::vector RigFemPartResultsCollection::tensorPrincipalComponentAdresses( const RigFemResultAddress& resVarAddr ) { @@ -1458,6 +1529,7 @@ double RigFemPartResultsCollection::normalizationAirGap() const /// //-------------------------------------------------------------------------------------------------- void RigFemPartResultsCollection::minMaxScalarValuesOverAllTensorComponents( const RigFemResultAddress& resVarAddr, + int stepIndex, int frameIndex, double* localMin, double* localMax ) @@ -1469,7 +1541,7 @@ void RigFemPartResultsCollection::minMaxScalarValuesOverAllTensorComponents( con for ( const auto& address : tensorPrincipalComponentAdresses( resVarAddr ) ) { - this->statistics( address )->minMaxCellScalarValues( frameIndex, min, max ); + this->statistics( address )->minMaxCellScalarValues( stepIndex, min, max ); if ( min < currentMin ) { currentMin = min; @@ -1517,6 +1589,7 @@ void RigFemPartResultsCollection::minMaxScalarValuesOverAllTensorComponents( con /// //-------------------------------------------------------------------------------------------------- void RigFemPartResultsCollection::posNegClosestToZeroOverAllTensorComponents( const RigFemResultAddress& resVarAddr, + int stepIndex, int frameIndex, double* localPosClosestToZero, double* localNegClosestToZero ) @@ -1528,7 +1601,7 @@ void RigFemPartResultsCollection::posNegClosestToZeroOverAllTensorComponents( co for ( const auto& address : tensorPrincipalComponentAdresses( resVarAddr ) ) { - this->statistics( address )->posNegClosestToZero( frameIndex, pos, neg ); + this->statistics( address )->posNegClosestToZero( stepIndex, pos, neg ); if ( pos < currentPosClosestToZero ) { currentPosClosestToZero = pos; diff --git a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.h b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.h index a940e8b7f9..0364f4248d 100644 --- a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.h +++ b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.h @@ -115,27 +115,41 @@ public: void setWaterDensityShearSlipIndicator( double waterDensity ); std::map> scalarFieldAndComponentNames( RigFemResultPosEnum resPos ); - std::vector filteredStepNames() const; bool assertResultsLoaded( const RigFemResultAddress& resVarAddr ); void deleteResult( const RigFemResultAddress& resVarAddr ); void deleteResultForAllTimeSteps( const std::vector& addresses ); - void deleteResultFrame( const RigFemResultAddress& resVarAddr, int partIndex, int frameIndex ); std::vector loadedResults() const; - const std::vector& resultValues( const RigFemResultAddress& resVarAddr, int partIndex, int frameIndex ); - void globalResultValues( const RigFemResultAddress& resVarAddr, int timeStepIndex, std::vector& resultValues ); + const std::vector& + resultValues( const RigFemResultAddress& resVarAddr, int partIndex, int stepIndex, int frameIndex ); - std::vector tensors( const RigFemResultAddress& resVarAddr, int partIndex, int frameIndex ); + void globalResultValues( const RigFemResultAddress& resVarAddr, + int timeStepIndex, + int frameIndex, + std::vector& resultValues ); + + std::vector tensors( const RigFemResultAddress& resVarAddr, int partIndex, int stepIndex, int frameIndex ); const RigFemPartCollection* parts() const; int partCount() const; - int frameCount(); + int timeStepCount() const; + int frameCount( int timeStepIndex ) const; - void minMaxScalarValues( const RigFemResultAddress& resVarAddr, int frameIndex, double* localMin, double* localMax ); + int totalSteps(); + const std::vector>& stepList(); + std::vector stepNames() const; + const std::pair stepListIndexToTimeStepAndDataFrameIndex( int stepIndex ) const; + + void minMaxScalarValues( const RigFemResultAddress& resVarAddr, + int stepIndex, + int frameIndex, + double* localMin, + double* localMax ); void minMaxScalarValues( const RigFemResultAddress& resVarAddr, double* globalMin, double* globalMax ); void posNegClosestToZero( const RigFemResultAddress& resVarAddr, + int stepIndex, int frameIndex, double* localPosClosestToZero, double* localNegClosestToZero ); @@ -143,15 +157,16 @@ public: double* globalPosClosestToZero, double* globalNegClosestToZero ); void meanScalarValue( const RigFemResultAddress& resVarAddr, double* meanValue ); - void meanScalarValue( const RigFemResultAddress& resVarAddr, int frameIndex, double* meanValue ); + void meanScalarValue( const RigFemResultAddress& resVarAddr, int stepIndex, int frameIndex, double* meanValue ); void p10p90ScalarValues( const RigFemResultAddress& resVarAddr, double* p10, double* p90 ); - void p10p90ScalarValues( const RigFemResultAddress& resVarAddr, int frameIndex, double* p10, double* p90 ); + void p10p90ScalarValues( const RigFemResultAddress& resVarAddr, int stepIndex, int frameIndex, double* p10, double* p90 ); void sumScalarValue( const RigFemResultAddress& resVarAddr, double* sum ); - void sumScalarValue( const RigFemResultAddress& resVarAddr, int frameIndex, double* sum ); + void sumScalarValue( const RigFemResultAddress& resVarAddr, int stepIndex, int frameIndex, double* sum ); const std::vector& scalarValuesHistogram( const RigFemResultAddress& resVarAddr ); - const std::vector& scalarValuesHistogram( const RigFemResultAddress& resVarAddr, int frameIndex ); + const std::vector& scalarValuesHistogram( const RigFemResultAddress& resVarAddr, int stepIndex, int frameIndex ); void minMaxScalarValuesOverAllTensorComponents( const RigFemResultAddress& resVarAddr, + int stepIndex, int frameIndex, double* localMin, double* localMax ); @@ -159,6 +174,7 @@ public: double* globalMin, double* globalMax ); void posNegClosestToZeroOverAllTensorComponents( const RigFemResultAddress& resVarAddr, + int stepIndex, int frameIndex, double* localPosClosestToZero, double* localNegClosestToZero ); @@ -177,7 +193,8 @@ public: double normalizationAirGap() const; void setReferenceTimeStep( int referenceTimeStep ); - int referenceTimeStep() const; + + std::pair referenceStepAndFrameIndex() const; static std::set referenceCaseDependentResults(); static bool isReferenceCaseDependentResult( const RigFemResultAddress& result ); @@ -197,6 +214,7 @@ public: private: RigFemScalarResultFrames* calculateDerivedResult( int partIndex, const RigFemResultAddress& resVarAddr ); + std::vector filteredTimeStepNames() const; private: cvf::Collection m_femPartResults; @@ -239,4 +257,7 @@ private: RigStatisticsDataCache* statistics( const RigFemResultAddress& resVarAddr ); std::vector getResAddrToComponentsToRead( const RigFemResultAddress& resVarAddr ); std::map> m_resultStatistics; + + std::vector> m_stepList; + std::vector m_stepNames; }; diff --git a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemScalarResultFrames.cpp b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemScalarResultFrames.cpp index 9ad3c06f1b..3615310b96 100644 --- a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemScalarResultFrames.cpp +++ b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemScalarResultFrames.cpp @@ -24,10 +24,10 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RigFemScalarResultFrames::RigFemScalarResultFrames( int frameCount ) +RigFemScalarResultFrames::RigFemScalarResultFrames( int timeStepCount ) { - m_dataForEachFrame.resize( frameCount ); - m_isSingleFrameResult = false; + m_dataForEachFrame.resize( timeStepCount ); + m_isSingleStepResult = false; } //-------------------------------------------------------------------------------------------------- @@ -40,15 +40,15 @@ RigFemScalarResultFrames::~RigFemScalarResultFrames() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigFemScalarResultFrames::enableAsSingleFrameResult() +void RigFemScalarResultFrames::enableAsSingleStepResult() { - m_isSingleFrameResult = true; + m_isSingleStepResult = true; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -int RigFemScalarResultFrames::frameCount() const +int RigFemScalarResultFrames::timeStepCount() const { return static_cast( m_dataForEachFrame.size() ); } @@ -56,29 +56,57 @@ int RigFemScalarResultFrames::frameCount() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector& RigFemScalarResultFrames::frameData( size_t frameIndex ) +int RigFemScalarResultFrames::frameCount( int timeStepIndex ) const { - if ( m_isSingleFrameResult ) - { - return m_dataForEachFrame[0]; - } - else - { - return m_dataForEachFrame[frameIndex]; - } + if ( timeStepIndex >= timeStepCount() ) return 0; + + return static_cast( m_dataForEachFrame[timeStepIndex].size() ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -const std::vector& RigFemScalarResultFrames::frameData( size_t frameIndex ) const +std::vector& RigFemScalarResultFrames::frameData( int timeStepIndex, int frameIndex ) { - if ( m_isSingleFrameResult ) + CVF_ASSERT( timeStepIndex < timeStepCount() ); + + if ( m_isSingleStepResult ) timeStepIndex = 0; + + int availFrames = int( m_dataForEachFrame[timeStepIndex].size() ); + + // frame index == -1 means last available frame + if ( frameIndex == -1 ) frameIndex = availFrames - 1; + + CVF_ASSERT( frameIndex >= 0 ); + + if ( frameIndex >= availFrames ) { - return m_dataForEachFrame[0]; - } - else - { - return m_dataForEachFrame[frameIndex]; + m_dataForEachFrame[timeStepIndex].resize( size_t( frameIndex + 1 ) ); } + + return m_dataForEachFrame[timeStepIndex][frameIndex]; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const std::vector& RigFemScalarResultFrames::frameData( int timeStepIndex, int frameIndex ) const +{ + CVF_ASSERT( timeStepIndex < timeStepCount() ); + + if ( m_isSingleStepResult ) timeStepIndex = 0; + + int availFrames = int( m_dataForEachFrame[timeStepIndex].size() ); + + // frame index == -1 means last available frame + if ( frameIndex == -1 ) frameIndex = availFrames - 1; + + if ( frameIndex < 0 ) return m_noData; + + if ( frameIndex >= availFrames ) + { + return m_noData; + } + + return m_dataForEachFrame[timeStepIndex][frameIndex]; } diff --git a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemScalarResultFrames.h b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemScalarResultFrames.h index 271414d5c9..3ad5508bc0 100644 --- a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemScalarResultFrames.h +++ b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemScalarResultFrames.h @@ -28,16 +28,18 @@ class RigFemScalarResultFrames : public cvf::Object { public: - explicit RigFemScalarResultFrames( int frameCount ); + explicit RigFemScalarResultFrames( int timeStepCount ); ~RigFemScalarResultFrames() override; - void enableAsSingleFrameResult(); + void enableAsSingleStepResult(); - std::vector& frameData( size_t frameIndex ); - const std::vector& frameData( size_t frameIndex ) const; - int frameCount() const; + std::vector& frameData( int timeStepIndex, int frameIndex ); + const std::vector& frameData( int timeStepIndex, int frameIndex ) const; + int timeStepCount() const; + int frameCount( int timeStepIndex ) const; private: - std::vector> m_dataForEachFrame; - bool m_isSingleFrameResult; + std::vector>> m_dataForEachFrame; + std::vector m_noData; + bool m_isSingleStepResult; }; diff --git a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigGeoMechCaseData.cpp b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigGeoMechCaseData.cpp index a0e6940ef8..a143f991cd 100644 --- a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigGeoMechCaseData.cpp +++ b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigGeoMechCaseData.cpp @@ -162,14 +162,14 @@ bool RigGeoMechCaseData::readFemParts( std::string* errorMessage, const std::vec bool RigGeoMechCaseData::readDisplacements( std::string* errorMessage, int partId, int timeStep, + int frameIndex, std::vector* displacements ) { CVF_ASSERT( errorMessage ); #ifdef USE_ODB_API if ( m_readerInterface.notNull() && m_readerInterface->isOpen() ) { - const auto& frames = m_readerInterface->frameTimes( timeStep ); - m_readerInterface->readDisplacements( partId, timeStep, (int)frames.size() - 1, displacements ); + m_readerInterface->readDisplacements( partId, timeStep, frameIndex, displacements ); return true; } diff --git a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigGeoMechCaseData.h b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigGeoMechCaseData.h index 741f162744..144101dd84 100644 --- a/ApplicationLibCode/GeoMech/GeoMechDataModel/RigGeoMechCaseData.h +++ b/ApplicationLibCode/GeoMech/GeoMechDataModel/RigGeoMechCaseData.h @@ -41,7 +41,11 @@ public: bool open( std::string* errorMessage ); bool readTimeSteps( std::string* errorMessage, std::vector* stepNames ); bool readFemParts( std::string* errorMessage, const std::vector& timeStepFilter = std::vector() ); - bool readDisplacements( std::string* errorMessage, int partId, int timeStep, std::vector* displacements ); + bool readDisplacements( std::string* errorMessage, + int partId, + int timeStep, + int frameIndex, + std::vector* displacements ); RigFemPartCollection* femParts(); const RigFemPartCollection* femParts() const; diff --git a/ApplicationLibCode/GeoMech/GeoMechVisualization/RivFemElmVisibilityCalculator.cpp b/ApplicationLibCode/GeoMech/GeoMechVisualization/RivFemElmVisibilityCalculator.cpp index 691413e3f5..a8b9f940d1 100644 --- a/ApplicationLibCode/GeoMech/GeoMechVisualization/RivFemElmVisibilityCalculator.cpp +++ b/ApplicationLibCode/GeoMech/GeoMechVisualization/RivFemElmVisibilityCalculator.cpp @@ -91,6 +91,7 @@ void RivFemElmVisibilityCalculator::computeRangeVisibility( cvf::UByteArray* void RivFemElmVisibilityCalculator::computePropertyVisibility( cvf::UByteArray* cellVisibility, const RigFemPart* part, int timeStepIndex, + int frameIndex, const cvf::UByteArray* rangeFilterVisibility, RimGeoMechPropertyFilterCollection* propFilterColl ) { @@ -124,7 +125,7 @@ void RivFemElmVisibilityCalculator::computePropertyVisibility( cvf::UByteArray* resVarAddress.resultPosType = RIG_ELEMENT_NODAL; const std::vector& resVals = - caseData->femPartResults()->resultValues( resVarAddress, part->elementPartId(), timeStepIndex ); + caseData->femPartResults()->resultValues( resVarAddress, part->elementPartId(), timeStepIndex, frameIndex ); if ( !propertyFilter->isActive() ) continue; if ( !propertyFilter->resultDefinition->hasResult() ) continue; diff --git a/ApplicationLibCode/GeoMech/GeoMechVisualization/RivFemElmVisibilityCalculator.h b/ApplicationLibCode/GeoMech/GeoMechVisualization/RivFemElmVisibilityCalculator.h index d7d20b4e1e..00ce33210a 100644 --- a/ApplicationLibCode/GeoMech/GeoMechVisualization/RivFemElmVisibilityCalculator.h +++ b/ApplicationLibCode/GeoMech/GeoMechVisualization/RivFemElmVisibilityCalculator.h @@ -43,6 +43,7 @@ public: static void computePropertyVisibility( cvf::UByteArray* cellVisibility, const RigFemPart* grid, int timeStepIndex, + int frameIndex, const cvf::UByteArray* rangeFilterVisibility, RimGeoMechPropertyFilterCollection* propFilterColl ); diff --git a/ApplicationLibCode/GeoMech/GeoMechVisualization/RivFemPartPartMgr.cpp b/ApplicationLibCode/GeoMech/GeoMechVisualization/RivFemPartPartMgr.cpp index bed64fcf4c..24d6eaf60e 100644 --- a/ApplicationLibCode/GeoMech/GeoMechVisualization/RivFemPartPartMgr.cpp +++ b/ApplicationLibCode/GeoMech/GeoMechVisualization/RivFemPartPartMgr.cpp @@ -271,7 +271,7 @@ void RivFemPartPartMgr::updateCellColor( cvf::Color4f color ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivFemPartPartMgr::updateCellResultColor( size_t timeStepIndex, RimGeoMechCellColors* cellResultColors ) +void RivFemPartPartMgr::updateCellResultColor( int timeStepIndex, int frameIndex, RimGeoMechCellColors* cellResultColors ) { CVF_ASSERT( cellResultColors ); @@ -297,7 +297,7 @@ void RivFemPartPartMgr::updateCellResultColor( size_t timeStepIndex, RimGeoMechC } const std::vector& resultValues = - caseData->femPartResults()->resultValues( resVarAddress, m_partIdx, (int)timeStepIndex ); + caseData->femPartResults()->resultValues( resVarAddress, m_partIdx, timeStepIndex, frameIndex ); const std::vector* vxToResultMapping = nullptr; int vxCount = 0; diff --git a/ApplicationLibCode/GeoMech/GeoMechVisualization/RivFemPartPartMgr.h b/ApplicationLibCode/GeoMech/GeoMechVisualization/RivFemPartPartMgr.h index 56c40cd771..8ba8b50991 100644 --- a/ApplicationLibCode/GeoMech/GeoMechVisualization/RivFemPartPartMgr.h +++ b/ApplicationLibCode/GeoMech/GeoMechVisualization/RivFemPartPartMgr.h @@ -58,7 +58,7 @@ public: void setDisplacements( bool useDisplacements, double scalingFactor, const std::vector& displacements ); void updateCellColor( cvf::Color4f color ); - void updateCellResultColor( size_t timeStepIndex, RimGeoMechCellColors* cellResultColors ); + void updateCellResultColor( int timeStepIndex, int frameIndex, RimGeoMechCellColors* cellResultColors ); void appendPartsToModel( cvf::ModelBasicList* model ); diff --git a/ApplicationLibCode/GeoMech/GeoMechVisualization/RivGeoMechPartMgr.cpp b/ApplicationLibCode/GeoMech/GeoMechVisualization/RivGeoMechPartMgr.cpp index c7c147144c..e1a01ee0db 100644 --- a/ApplicationLibCode/GeoMech/GeoMechVisualization/RivGeoMechPartMgr.cpp +++ b/ApplicationLibCode/GeoMech/GeoMechVisualization/RivGeoMechPartMgr.cpp @@ -116,11 +116,11 @@ void RivGeoMechPartMgr::updateCellColor( cvf::Color4f color ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivGeoMechPartMgr::updateCellResultColor( size_t timeStepIndex, RimGeoMechCellColors* cellResultColors ) +void RivGeoMechPartMgr::updateCellResultColor( int timeStepIndex, int frameIndex, RimGeoMechCellColors* cellResultColors ) { for ( size_t i = 0; i < m_femPartPartMgrs.size(); ++i ) { - m_femPartPartMgrs[i]->updateCellResultColor( timeStepIndex, cellResultColors ); + m_femPartPartMgrs[i]->updateCellResultColor( timeStepIndex, frameIndex, cellResultColors ); } } diff --git a/ApplicationLibCode/GeoMech/GeoMechVisualization/RivGeoMechPartMgr.h b/ApplicationLibCode/GeoMech/GeoMechVisualization/RivGeoMechPartMgr.h index 4bfcd5a797..e5c5cb0938 100644 --- a/ApplicationLibCode/GeoMech/GeoMechVisualization/RivGeoMechPartMgr.h +++ b/ApplicationLibCode/GeoMech/GeoMechVisualization/RivGeoMechPartMgr.h @@ -57,7 +57,7 @@ public: cvf::ref cellVisibility( size_t partIndex ); void updateCellColor( cvf::Color4f color ); - void updateCellResultColor( size_t timeStepIndex, RimGeoMechCellColors* cellResultColors ); + void updateCellResultColor( int timeStepIndex, int frameIndex, RimGeoMechCellColors* cellResultColors ); void appendGridPartsToModel( cvf::ModelBasicList* model, const std::vector& partIndices ); void appendGridPartsToModel( cvf::ModelBasicList* model ); diff --git a/ApplicationLibCode/GeoMech/GeoMechVisualization/RivGeoMechPartMgrCache.cpp b/ApplicationLibCode/GeoMech/GeoMechVisualization/RivGeoMechPartMgrCache.cpp index 92f10a0adc..cb0f72d52c 100644 --- a/ApplicationLibCode/GeoMech/GeoMechVisualization/RivGeoMechPartMgrCache.cpp +++ b/ApplicationLibCode/GeoMech/GeoMechVisualization/RivGeoMechPartMgrCache.cpp @@ -87,10 +87,10 @@ RivGeoMechPartMgr* RivGeoMechPartMgrCache::partMgr( const Key& key ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivGeoMechPartMgrCache::Key::set( RivCellSetEnum aGeometryType, int aFrameIndex ) +void RivGeoMechPartMgrCache::Key::set( RivCellSetEnum aGeometryType, int aViewerTimeStep ) { - m_frameIndex = aFrameIndex; - m_geometryType = aGeometryType; + m_viewerStepIndex = aViewerTimeStep; + m_geometryType = aGeometryType; } //-------------------------------------------------------------------------------------------------- @@ -98,9 +98,9 @@ void RivGeoMechPartMgrCache::Key::set( RivCellSetEnum aGeometryType, int aFrameI //-------------------------------------------------------------------------------------------------- bool RivGeoMechPartMgrCache::Key::operator<( const Key& other ) const { - if ( m_frameIndex != other.m_frameIndex ) + if ( m_viewerStepIndex != other.m_viewerStepIndex ) { - return ( m_frameIndex < other.m_frameIndex ); + return ( m_viewerStepIndex < other.m_viewerStepIndex ); } return ( m_geometryType < other.m_geometryType ); } @@ -108,8 +108,8 @@ bool RivGeoMechPartMgrCache::Key::operator<( const Key& other ) const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RivGeoMechPartMgrCache::Key::Key( RivCellSetEnum aGeometryType, int aFrameIndex ) +RivGeoMechPartMgrCache::Key::Key( RivCellSetEnum aGeometryType, int aViewerTimeStep ) : m_geometryType( aGeometryType ) - , m_frameIndex( aFrameIndex ) + , m_viewerStepIndex( aViewerTimeStep ) { } diff --git a/ApplicationLibCode/GeoMech/GeoMechVisualization/RivGeoMechPartMgrCache.h b/ApplicationLibCode/GeoMech/GeoMechVisualization/RivGeoMechPartMgrCache.h index 8e02ca9026..86d656a010 100644 --- a/ApplicationLibCode/GeoMech/GeoMechVisualization/RivGeoMechPartMgrCache.h +++ b/ApplicationLibCode/GeoMech/GeoMechVisualization/RivGeoMechPartMgrCache.h @@ -40,21 +40,21 @@ public: public: Key() : m_geometryType( -1 ) - , m_frameIndex( -1 ) + , m_viewerStepIndex( -1 ) { } - Key( RivCellSetEnum aGeometryType, int aFrameIndex ); + Key( RivCellSetEnum aGeometryType, int aViewerTimeStep ); - void set( RivCellSetEnum aGeometryType, int aFrameIndex ); + void set( RivCellSetEnum aGeometryType, int aViewerTimeStep ); - int frameIndex() const { return m_frameIndex; } + int viewerStepIndex() const { return m_viewerStepIndex; } unsigned short geometryType() const { return m_geometryType; } bool operator<( const Key& other ) const; private: - int m_frameIndex; + int m_viewerStepIndex; unsigned short m_geometryType; }; diff --git a/ApplicationLibCode/GeoMech/GeoMechVisualization/RivGeoMechVizLogic.cpp b/ApplicationLibCode/GeoMech/GeoMechVisualization/RivGeoMechVizLogic.cpp index ad8005492e..6eb0cb1253 100644 --- a/ApplicationLibCode/GeoMech/GeoMechVisualization/RivGeoMechVizLogic.cpp +++ b/ApplicationLibCode/GeoMech/GeoMechVisualization/RivGeoMechVizLogic.cpp @@ -69,9 +69,9 @@ void RivGeoMechVizLogic::appendNoAnimPartsToModel( cvf::ModelBasicList* model ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivGeoMechVizLogic::appendPartsToModel( int timeStepIndex, cvf::ModelBasicList* model ) +void RivGeoMechVizLogic::appendPartsToModel( int viewerStepIndex, cvf::ModelBasicList* model ) { - std::vector visiblePartMgrs = keysToVisiblePartMgrs( timeStepIndex ); + std::vector visiblePartMgrs = keysToVisiblePartMgrs( viewerStepIndex ); for ( size_t pmIdx = 0; pmIdx < visiblePartMgrs.size(); ++pmIdx ) { RivGeoMechPartMgr* partMgr = getUpdatedPartMgr( visiblePartMgrs[pmIdx] ); @@ -83,22 +83,25 @@ void RivGeoMechVizLogic::appendPartsToModel( int timeStepIndex, cvf::ModelBasicL //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivGeoMechVizLogic::updateCellResultColor( int timeStepIndex, RimGeoMechCellColors* cellResultColors ) +void RivGeoMechVizLogic::updateCellResultColor( int viewerStepIndex, + int timeStepIndex, + int frameIndex, + RimGeoMechCellColors* cellResultColors ) { - std::vector visiblePartMgrs = keysToVisiblePartMgrs( timeStepIndex ); + std::vector visiblePartMgrs = keysToVisiblePartMgrs( viewerStepIndex ); for ( size_t pmIdx = 0; pmIdx < visiblePartMgrs.size(); ++pmIdx ) { RivGeoMechPartMgr* partMgr = m_partMgrCache->partMgr( visiblePartMgrs[pmIdx] ); - partMgr->updateCellResultColor( timeStepIndex, cellResultColors ); + partMgr->updateCellResultColor( timeStepIndex, frameIndex, cellResultColors ); } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivGeoMechVizLogic::updateStaticCellColors( int timeStepIndex ) +void RivGeoMechVizLogic::updateStaticCellColors( int viewerStepIndex ) { - std::vector visiblePartMgrs = keysToVisiblePartMgrs( timeStepIndex ); + std::vector visiblePartMgrs = keysToVisiblePartMgrs( viewerStepIndex ); for ( size_t pmIdx = 0; pmIdx < visiblePartMgrs.size(); ++pmIdx ) { RivGeoMechPartMgr* partMgr = m_partMgrCache->partMgr( visiblePartMgrs[pmIdx] ); @@ -114,15 +117,18 @@ void RivGeoMechVizLogic::scheduleGeometryRegen( RivCellSetEnum geometryType ) { this->scheduleRegenOfDirectlyDependentGeometry( geometryType ); - int frameCount = 0; - if ( m_geomechView->geoMechCase() && m_geomechView->geoMechCase()->geoMechData() ) + bool resultsOk = ( m_geomechView->geoMechCase() && m_geomechView->geoMechCase()->geoMechData() && + m_geomechView->geoMechCase()->geoMechData()->femPartResults() ); + + int stepCount = 0; + if ( resultsOk ) { - frameCount = m_geomechView->geoMechCase()->geoMechData()->femPartResults()->frameCount(); + stepCount = m_geomechView->geoMechCase()->geoMechData()->femPartResults()->totalSteps(); } - for ( int fIdx = -1; fIdx < frameCount; ++fIdx ) + for ( int stepIdx = -1; stepIdx < stepCount; stepIdx++ ) { - RivGeoMechPartMgrCache::Key geomToRegen( geometryType, fIdx ); + RivGeoMechPartMgrCache::Key geomToRegen( geometryType, stepIdx ); m_partMgrCache->scheduleRegeneration( geomToRegen ); } } @@ -130,9 +136,9 @@ void RivGeoMechVizLogic::scheduleGeometryRegen( RivCellSetEnum geometryType ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivGeoMechVizLogic::scheduleGeometryRegenOfVisiblePartMgrs( int timeStepIndex ) +void RivGeoMechVizLogic::scheduleGeometryRegenOfVisiblePartMgrs( int viewerStepIndex ) { - std::vector visiblePartMgrs = keysToVisiblePartMgrs( timeStepIndex ); + std::vector visiblePartMgrs = keysToVisiblePartMgrs( viewerStepIndex ); for ( size_t pmIdx = 0; pmIdx < visiblePartMgrs.size(); ++pmIdx ) { m_partMgrCache->scheduleRegeneration( visiblePartMgrs[pmIdx] ); @@ -153,7 +159,7 @@ void RivGeoMechVizLogic::scheduleRegenOfDirectlyDependentGeometry( RivCellSetEnu //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RivGeoMechVizLogic::keysToVisiblePartMgrs( int timeStepIndex ) const +std::vector RivGeoMechVizLogic::keysToVisiblePartMgrs( int viewerStepIndex ) const { std::vector visiblePartMgrs; if ( m_geomechView->viewController() && m_geomechView->viewController()->isVisibleCellsOveridden() ) @@ -162,9 +168,9 @@ std::vector RivGeoMechVizLogic::keysToVisiblePartMg } else if ( m_geomechView->isGridVisualizationMode() ) { - if ( timeStepIndex >= 0 && m_geomechView->geoMechPropertyFilterCollection()->hasActiveFilters() ) + if ( viewerStepIndex >= 0 && m_geomechView->geoMechPropertyFilterCollection()->hasActiveFilters() ) { - visiblePartMgrs.push_back( RivGeoMechPartMgrCache::Key( PROPERTY_FILTERED, timeStepIndex ) ); + visiblePartMgrs.push_back( RivGeoMechPartMgrCache::Key( PROPERTY_FILTERED, viewerStepIndex ) ); } else if ( m_geomechView->cellFilterCollection()->hasActiveFilters() ) { @@ -207,10 +213,15 @@ RivGeoMechPartMgr* RivGeoMechVizLogic::getUpdatedPartMgr( RivGeoMechPartMgrCache RivGeoMechPartMgr* partMgrToUpdate = m_partMgrCache->partMgr( pMgrKey ); int partCount = 0; RigGeoMechCaseData* caseData = nullptr; + int timeStepIdx = -1; + int frameIdx = -1; + if ( m_geomechView->geoMechCase() ) { caseData = m_geomechView->geoMechCase()->geoMechData(); partCount = caseData->femParts()->partCount(); + std::tie( timeStepIdx, frameIdx ) = + caseData->femPartResults()->stepListIndexToTimeStepAndDataFrameIndex( pMgrKey.viewerStepIndex() ); } if ( partMgrToUpdate->initializedFemPartCount() != partCount ) @@ -251,7 +262,8 @@ RivGeoMechPartMgr* RivGeoMechVizLogic::getUpdatedPartMgr( RivGeoMechPartMgrCache RivFemElmVisibilityCalculator::computePropertyVisibility( elmVisibility.p(), caseData->femParts()->part( femPartIdx ), - pMgrKey.frameIndex(), + timeStepIdx, + frameIdx, rangeFiltVisibility.p(), m_geomechView->geoMechPropertyFilterCollection() ); } @@ -282,7 +294,7 @@ RivGeoMechPartMgr* RivGeoMechVizLogic::getUpdatedPartMgr( RivGeoMechPartMgrCache //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivGeoMechVizLogic::calculateCurrentTotalCellVisibility( cvf::UByteArray* totalVisibility, int timeStepIndex ) +void RivGeoMechVizLogic::calculateCurrentTotalCellVisibility( cvf::UByteArray* totalVisibility, int viewerStepIndex ) { if ( !m_geomechView->geoMechCase() ) return; @@ -298,7 +310,7 @@ void RivGeoMechVizLogic::calculateCurrentTotalCellVisibility( cvf::UByteArray* t totalVisibility->resize( elmCount ); totalVisibility->setAll( false ); - std::vector visiblePartMgrs = keysToVisiblePartMgrs( timeStepIndex ); + std::vector visiblePartMgrs = keysToVisiblePartMgrs( viewerStepIndex ); for ( size_t pmIdx = 0; pmIdx < visiblePartMgrs.size(); ++pmIdx ) { RivGeoMechPartMgr* partMgr = getUpdatedPartMgr( visiblePartMgrs[pmIdx] ); diff --git a/ApplicationLibCode/GeoMech/GeoMechVisualization/RivGeoMechVizLogic.h b/ApplicationLibCode/GeoMech/GeoMechVisualization/RivGeoMechVizLogic.h index 15e66a116b..db02f69fc2 100644 --- a/ApplicationLibCode/GeoMech/GeoMechVisualization/RivGeoMechVizLogic.h +++ b/ApplicationLibCode/GeoMech/GeoMechVisualization/RivGeoMechVizLogic.h @@ -43,13 +43,13 @@ public: ~RivGeoMechVizLogic() override; void appendNoAnimPartsToModel( cvf::ModelBasicList* model ); - void appendPartsToModel( int timeStepIndex, cvf::ModelBasicList* model ); - void updateCellResultColor( int timeStepIndex, RimGeoMechCellColors* cellResultColors ); - void updateStaticCellColors( int timeStepIndex ); + void appendPartsToModel( int viewerStepIndex, cvf::ModelBasicList* model ); + void updateCellResultColor( int viewerStepIndex, int timeStepIndex, int frameIndex, RimGeoMechCellColors* cellResultColors ); + void updateStaticCellColors( int viewerStepIndex ); void scheduleGeometryRegen( RivCellSetEnum geometryType ); - void scheduleGeometryRegenOfVisiblePartMgrs( int timeStepIndex ); - void calculateCurrentTotalCellVisibility( cvf::UByteArray* totalVisibility, int timeStepIndex ); - std::vector keysToVisiblePartMgrs( int timeStepIndex ) const; + void scheduleGeometryRegenOfVisiblePartMgrs( int viewerStepIndex ); + void calculateCurrentTotalCellVisibility( cvf::UByteArray* totalVisibility, int viewerStepIndex ); + std::vector keysToVisiblePartMgrs( int viewerStepIndex ) const; const cvf::ref partMgrCache() const; static cvf::Color3f staticCellColor(); diff --git a/ApplicationLibCode/GeoMech/OdbReader/RifGeoMechReaderInterface.h b/ApplicationLibCode/GeoMech/OdbReader/RifGeoMechReaderInterface.h index 5b328f6be4..72a66a5d84 100644 --- a/ApplicationLibCode/GeoMech/OdbReader/RifGeoMechReaderInterface.h +++ b/ApplicationLibCode/GeoMech/OdbReader/RifGeoMechReaderInterface.h @@ -45,6 +45,7 @@ public: virtual std::vector allStepNames() const = 0; virtual std::vector filteredStepNames() const = 0; virtual std::vector frameTimes( int stepIndex ) const = 0; + virtual int frameCount( int stepIndex ) const = 0; virtual std::vector elementSetNames( int partIndex ) = 0; virtual std::vector elementSet( int partIndex, int setIndex ) = 0; diff --git a/ApplicationLibCode/GeoMech/OdbReader/RifOdbReader.cpp b/ApplicationLibCode/GeoMech/OdbReader/RifOdbReader.cpp index 8e37883ba1..88bdd3cb12 100644 --- a/ApplicationLibCode/GeoMech/OdbReader/RifOdbReader.cpp +++ b/ApplicationLibCode/GeoMech/OdbReader/RifOdbReader.cpp @@ -480,6 +480,14 @@ std::vector RifOdbReader::frameTimes( int stepIndex ) const return frameValues; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +int RifOdbReader::frameCount( int stepIndex ) const +{ + return frameTimes( stepIndex ).size(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/GeoMech/OdbReader/RifOdbReader.h b/ApplicationLibCode/GeoMech/OdbReader/RifOdbReader.h index f9efbd9954..de66eaaf92 100644 --- a/ApplicationLibCode/GeoMech/OdbReader/RifOdbReader.h +++ b/ApplicationLibCode/GeoMech/OdbReader/RifOdbReader.h @@ -47,6 +47,7 @@ public: std::vector allStepNames() const override; std::vector filteredStepNames() const override; std::vector frameTimes( int stepIndex ) const override; + int frameCount( int stepIndex ) const override; std::vector elementSetNames( int partIndex ) override; std::vector elementSet( int partIndex, int setIndex ) override; diff --git a/ApplicationLibCode/ModelVisualization/Intersections/RivBoxIntersectionPartMgr.cpp b/ApplicationLibCode/ModelVisualization/Intersections/RivBoxIntersectionPartMgr.cpp index 42b00f7241..287dc07c4f 100644 --- a/ApplicationLibCode/ModelVisualization/Intersections/RivBoxIntersectionPartMgr.cpp +++ b/ApplicationLibCode/ModelVisualization/Intersections/RivBoxIntersectionPartMgr.cpp @@ -81,7 +81,7 @@ void RivBoxIntersectionPartMgr::applySingleColorEffect() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivBoxIntersectionPartMgr::updateCellResultColor( size_t timeStepIndex ) +void RivBoxIntersectionPartMgr::updateCellResultColor( int timeStepIndex ) { RivIntersectionResultsColoringTools::calculateIntersectionResultColors( timeStepIndex, true, diff --git a/ApplicationLibCode/ModelVisualization/Intersections/RivBoxIntersectionPartMgr.h b/ApplicationLibCode/ModelVisualization/Intersections/RivBoxIntersectionPartMgr.h index 9bcfaeffeb..90f94c9ea1 100644 --- a/ApplicationLibCode/ModelVisualization/Intersections/RivBoxIntersectionPartMgr.h +++ b/ApplicationLibCode/ModelVisualization/Intersections/RivBoxIntersectionPartMgr.h @@ -56,7 +56,7 @@ public: explicit RivBoxIntersectionPartMgr( RimBoxIntersection* intersectionBox ); void applySingleColorEffect(); - void updateCellResultColor( size_t timeStepIndex ); + void updateCellResultColor( int timeStepIndex ); void appendNativeIntersectionFacesToModel( cvf::ModelBasicList* model, cvf::Transform* scaleTransform ); void appendMeshLinePartsToModel( cvf::ModelBasicList* model, cvf::Transform* scaleTransform ); diff --git a/ApplicationLibCode/ModelVisualization/Intersections/RivExtrudedCurveIntersectionPartMgr.cpp b/ApplicationLibCode/ModelVisualization/Intersections/RivExtrudedCurveIntersectionPartMgr.cpp index e5ef915e91..bb613f14d5 100644 --- a/ApplicationLibCode/ModelVisualization/Intersections/RivExtrudedCurveIntersectionPartMgr.cpp +++ b/ApplicationLibCode/ModelVisualization/Intersections/RivExtrudedCurveIntersectionPartMgr.cpp @@ -154,7 +154,7 @@ void RivExtrudedCurveIntersectionPartMgr::applySingleColorEffect() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivExtrudedCurveIntersectionPartMgr::updateCellResultColor( size_t timeStepIndex, +void RivExtrudedCurveIntersectionPartMgr::updateCellResultColor( int timeStepIndex, const cvf::ScalarMapper* explicitScalarColorMapper, const RivTernaryScalarMapper* explicitTernaryColorMapper ) { diff --git a/ApplicationLibCode/ModelVisualization/Intersections/RivExtrudedCurveIntersectionPartMgr.h b/ApplicationLibCode/ModelVisualization/Intersections/RivExtrudedCurveIntersectionPartMgr.h index 22ea6f91c3..f5d00599f8 100644 --- a/ApplicationLibCode/ModelVisualization/Intersections/RivExtrudedCurveIntersectionPartMgr.h +++ b/ApplicationLibCode/ModelVisualization/Intersections/RivExtrudedCurveIntersectionPartMgr.h @@ -69,7 +69,7 @@ public: explicit RivExtrudedCurveIntersectionPartMgr( RimExtrudedCurveIntersection* rimIntersection, bool isFlattened = false ); void applySingleColorEffect(); - void updateCellResultColor( size_t timeStepIndex, + void updateCellResultColor( int timeStepIndex, const cvf::ScalarMapper* explicitScalarColorMapper, const RivTernaryScalarMapper* explicitTernaryColorMapper ); diff --git a/ApplicationLibCode/ModelVisualization/Intersections/RivIntersectionResultsColoringTools.cpp b/ApplicationLibCode/ModelVisualization/Intersections/RivIntersectionResultsColoringTools.cpp index 7692c46199..c35949b8b0 100644 --- a/ApplicationLibCode/ModelVisualization/Intersections/RivIntersectionResultsColoringTools.cpp +++ b/ApplicationLibCode/ModelVisualization/Intersections/RivIntersectionResultsColoringTools.cpp @@ -51,7 +51,7 @@ /// //-------------------------------------------------------------------------------------------------- void RivIntersectionResultsColoringTools::calculateIntersectionResultColors( - size_t timeStepIndex, + int timeStepIndex, bool useSeparateIntersectionResDefTimeStep, RimIntersection* rimIntersectionHandle, const RivIntersectionGeometryGeneratorInterface* intersectionGeomGenIF, @@ -227,7 +227,7 @@ void RivIntersectionResultsColoringTools::updateEclipseTernaryCellResultColors( //-------------------------------------------------------------------------------------------------- void RivIntersectionResultsColoringTools::updateGeoMechCellResultColors( const RimGeoMechResultDefinition* geomResultDef, - size_t timeStepIndex, + int viewerTimeStepIndex, const cvf::ScalarMapper* scalarColorMapper, bool isLightingDisabled, const RivIntersectionGeometryGeneratorInterface* geomGenerator, @@ -243,6 +243,8 @@ void RivIntersectionResultsColoringTools::updateGeoMechCellResultColors( if ( !caseData ) return; + auto [stepIdx, frameIdx] = caseData->femPartResults()->stepListIndexToTimeStepAndDataFrameIndex( viewerTimeStepIndex ); + const std::vector& triangleToCellIdx = geomGenerator->triangleToCellIndex(); const cvf::Vec3fArray* triangelVxes = geomGenerator->triangleVxes(); const std::vector& vertexWeights = @@ -253,7 +255,7 @@ void RivIntersectionResultsColoringTools::updateGeoMechCellResultColors( if ( caseData->femPartResults()->partCount() == 1 ) { const std::vector& resultValues = - caseData->femPartResults()->resultValues( resVarAddress, 0, (int)timeStepIndex ); + caseData->femPartResults()->resultValues( resVarAddress, 0, stepIdx, frameIdx ); RivIntersectionResultsColoringTools::calculateElementBasedGeoMechTextureCoords( intersectionFacesTextureCoords, resultValues, @@ -263,7 +265,7 @@ void RivIntersectionResultsColoringTools::updateGeoMechCellResultColors( else { std::vector resultValues; - caseData->femPartResults()->globalResultValues( resVarAddress, (int)timeStepIndex, resultValues ); + caseData->femPartResults()->globalResultValues( resVarAddress, stepIdx, frameIdx, resultValues ); RivIntersectionResultsColoringTools::calculateElementBasedGeoMechTextureCoords( intersectionFacesTextureCoords, resultValues, @@ -291,7 +293,9 @@ void RivIntersectionResultsColoringTools::updateGeoMechCellResultColors( vertexWeights, caseData, resVarAddress, - (int)timeStepIndex, + 0, + stepIdx, + frameIdx, scalarColorMapper ); } } @@ -311,7 +315,7 @@ void RivIntersectionResultsColoringTools::updateGeoMechCellResultColors( if ( caseData->femPartResults()->partCount() == 1 ) { const std::vector& resultValues = - caseData->femPartResults()->resultValues( resVarAddress, 0, (int)timeStepIndex ); + caseData->femPartResults()->resultValues( resVarAddress, 0, stepIdx, frameIdx ); RivIntersectionResultsColoringTools::calculateNodeOrElementNodeBasedGeoMechTextureCoords( intersectionFacesTextureCoords, vertexWeights, resultValues, @@ -322,7 +326,7 @@ void RivIntersectionResultsColoringTools::updateGeoMechCellResultColors( else { std::vector resultValues; - caseData->femPartResults()->globalResultValues( resVarAddress, (int)timeStepIndex, resultValues ); + caseData->femPartResults()->globalResultValues( resVarAddress, stepIdx, frameIdx, resultValues ); RivIntersectionResultsColoringTools::calculateNodeOrElementNodeBasedGeoMechTextureCoords( intersectionFacesTextureCoords, vertexWeights, @@ -427,10 +431,12 @@ void RivIntersectionResultsColoringTools::calculateGeoMechTensorXfTextureCoords( const std::vector& vertexWeights, RigGeoMechCaseData* caseData, const RigFemResultAddress& resVarAddress, + int partIdx, int timeStepIdx, + int frameIdx, const cvf::ScalarMapper* mapper ) { - RiuGeoMechXfTensorResultAccessor accessor( caseData->femPartResults(), resVarAddress, timeStepIdx ); + RiuGeoMechXfTensorResultAccessor accessor( caseData->femPartResults(), resVarAddress, partIdx, timeStepIdx, frameIdx ); textureCoords->resize( vertexWeights.size() ); cvf::Vec2f* rawPtr = textureCoords->ptr(); diff --git a/ApplicationLibCode/ModelVisualization/Intersections/RivIntersectionResultsColoringTools.h b/ApplicationLibCode/ModelVisualization/Intersections/RivIntersectionResultsColoringTools.h index ef9d4b84a8..c46fbe1051 100644 --- a/ApplicationLibCode/ModelVisualization/Intersections/RivIntersectionResultsColoringTools.h +++ b/ApplicationLibCode/ModelVisualization/Intersections/RivIntersectionResultsColoringTools.h @@ -42,7 +42,7 @@ class ScalarMapper; class RivIntersectionResultsColoringTools { public: - static void calculateIntersectionResultColors( size_t timeStepIndex, + static void calculateIntersectionResultColors( int timeStepIndex, bool useSeparateIntersectionResDefTimeStep, RimIntersection* rimIntersectionHandle, const RivIntersectionGeometryGeneratorInterface* intersectionGeomGenIF, @@ -69,7 +69,7 @@ private: cvf::Vec2fArray* m_intersectionBoxFacesTextureCoords ); static void updateGeoMechCellResultColors( const RimGeoMechResultDefinition* geomResultDef, - size_t timeStepIndex, + int timeStepIndex, const cvf::ScalarMapper* scalarColorMapper, bool isLightingDisabled, const RivIntersectionGeometryGeneratorInterface* geomGenerator, @@ -99,7 +99,9 @@ private: const std::vector& vertexWeights, RigGeoMechCaseData* caseData, const RigFemResultAddress& resVarAddress, + int partIdx, int timeStepIdx, + int frameIdx, const cvf::ScalarMapper* mapper ); static void calculatePlaneAngleTextureCoords( cvf::Vec2fArray* textureCoords, diff --git a/ApplicationLibCode/ModelVisualization/RivTensorResultPartMgr.cpp b/ApplicationLibCode/ModelVisualization/RivTensorResultPartMgr.cpp index 9b83679601..e6dd060721 100644 --- a/ApplicationLibCode/ModelVisualization/RivTensorResultPartMgr.cpp +++ b/ApplicationLibCode/ModelVisualization/RivTensorResultPartMgr.cpp @@ -70,7 +70,10 @@ RivTensorResultPartMgr::~RivTensorResultPartMgr() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivTensorResultPartMgr::appendDynamicGeometryPartsToModel( cvf::ModelBasicList* model, size_t frameIndex ) const +void RivTensorResultPartMgr::appendDynamicGeometryPartsToModel( cvf::ModelBasicList* model, + int viewerStepIndex, + int localTimeStepIndex, + int frameIndex ) const { CVF_ASSERT( model ); @@ -93,7 +96,8 @@ void RivTensorResultPartMgr::appendDynamicGeometryPartsToModel( cvf::ModelBasicL for ( int partIdx = 0; partIdx < femParts->partCount(); partIdx++ ) { - std::vector vertexTensors = resultCollection->tensors( address, partIdx, (int)frameIndex ); + std::vector vertexTensors = + resultCollection->tensors( address, partIdx, localTimeStepIndex, frameIndex ); if ( vertexTensors.empty() ) continue; const RigFemPart* part = femParts->part( partIdx ); @@ -108,7 +112,7 @@ void RivTensorResultPartMgr::appendDynamicGeometryPartsToModel( cvf::ModelBasicL calculatePrincipalsAndDirections( elmTensors, &elmPrincipals, &elmPrincipalDirections ); std::vector partKeys = - m_rimReservoirView->vizLogic()->keysToVisiblePartMgrs( (int)frameIndex ); + m_rimReservoirView->vizLogic()->keysToVisiblePartMgrs( viewerStepIndex ); RigFemPartNodes nodes = part->nodes(); diff --git a/ApplicationLibCode/ModelVisualization/RivTensorResultPartMgr.h b/ApplicationLibCode/ModelVisualization/RivTensorResultPartMgr.h index 5600d058f7..b07b78f201 100644 --- a/ApplicationLibCode/ModelVisualization/RivTensorResultPartMgr.h +++ b/ApplicationLibCode/ModelVisualization/RivTensorResultPartMgr.h @@ -50,7 +50,10 @@ public: RivTensorResultPartMgr( RimGeoMechView* reservoirView ); ~RivTensorResultPartMgr() override; - void appendDynamicGeometryPartsToModel( cvf::ModelBasicList* model, size_t frameIndex ) const; + void appendDynamicGeometryPartsToModel( cvf::ModelBasicList* model, + int viewerStepIndex, + int localTimeStepIndex, + int frameIndex ) const; private: struct TensorVisualization diff --git a/ApplicationLibCode/ModelVisualization/Surfaces/RivSurfacePartMgr.cpp b/ApplicationLibCode/ModelVisualization/Surfaces/RivSurfacePartMgr.cpp index 27b67a6fb5..644840d3f2 100644 --- a/ApplicationLibCode/ModelVisualization/Surfaces/RivSurfacePartMgr.cpp +++ b/ApplicationLibCode/ModelVisualization/Surfaces/RivSurfacePartMgr.cpp @@ -89,7 +89,7 @@ void RivSurfacePartMgr::appendNativeGeometryPartsToModel( cvf::ModelBasicList* m //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivSurfacePartMgr::updateCellResultColor( size_t timeStepIndex ) +void RivSurfacePartMgr::updateCellResultColor( int timeStepIndex ) { if ( m_intersectionFaces.notNull() ) { diff --git a/ApplicationLibCode/ModelVisualization/Surfaces/RivSurfacePartMgr.h b/ApplicationLibCode/ModelVisualization/Surfaces/RivSurfacePartMgr.h index d1e221b5ae..7fadf92acd 100644 --- a/ApplicationLibCode/ModelVisualization/Surfaces/RivSurfacePartMgr.h +++ b/ApplicationLibCode/ModelVisualization/Surfaces/RivSurfacePartMgr.h @@ -44,7 +44,7 @@ public: explicit RivSurfacePartMgr( RimSurfaceInView* surface ); void updateNativeSurfaceColors(); - void updateCellResultColor( size_t timeStepIndex ); + void updateCellResultColor( int timeStepIndex ); void appendIntersectionGeometryPartsToModel( cvf::ModelBasicList* model, cvf::Transform* scaleTransform ); void appendNativeGeometryPartsToModel( cvf::ModelBasicList* model, cvf::Transform* scaleTransform ); diff --git a/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.cpp b/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.cpp index 301946ca7b..cbb45532d3 100644 --- a/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.cpp +++ b/ApplicationLibCode/ProjectDataModel/CellFilters/RimPolygonFilter.cpp @@ -792,15 +792,19 @@ void RimPolygonFilter::updateCellsForGeoMech( const std::vector& poi { if ( gCase->geoMechData() && gCase->geoMechData()->femParts()->partCount() > 0 ) { - const RigFemPartGrid* grid = gCase->geoMechData()->femParts()->part( 0 )->getOrCreateStructGrid(); + int partCount = gCase->geoMechData()->femParts()->partCount(); + for ( int i = 0; i < partCount; i++ ) + { + const RigFemPartGrid* grid = gCase->geoMechData()->femParts()->part( i )->getOrCreateStructGrid(); - if ( m_polyFilterMode == PolygonFilterModeType::DEPTH_Z ) - { - updateCellsDepthGeoMech( points, grid ); - } - else if ( m_polyFilterMode == PolygonFilterModeType::INDEX_K ) - { - updateCellsKIndexGeoMech( points, grid ); + if ( m_polyFilterMode == PolygonFilterModeType::DEPTH_Z ) + { + updateCellsDepthGeoMech( points, grid ); + } + else if ( m_polyFilterMode == PolygonFilterModeType::INDEX_K ) + { + updateCellsKIndexGeoMech( points, grid ); + } } } } diff --git a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechCase.cpp b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechCase.cpp index e5781d0e4d..65478a32c8 100644 --- a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechCase.cpp +++ b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechCase.cpp @@ -483,7 +483,7 @@ QStringList RimGeoMechCase::timeStepStrings() const const RigGeoMechCaseData* rigCaseData = geoMechData(); if ( rigCaseData && rigCaseData->femPartResults() ) { - std::vector stepNames = rigCaseData->femPartResults()->filteredStepNames(); + std::vector stepNames = rigCaseData->femPartResults()->stepNames(); for ( size_t i = 0; i < stepNames.size(); i++ ) { stringList += QString::fromStdString( stepNames[i] ); @@ -496,15 +496,15 @@ QStringList RimGeoMechCase::timeStepStrings() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RimGeoMechCase::timeStepName( int frameIdx ) const +QString RimGeoMechCase::timeStepName( int timeStepIdx ) const { const RigGeoMechCaseData* rigCaseData = geoMechData(); if ( rigCaseData && rigCaseData->femPartResults() ) { - std::vector stepNames = rigCaseData->femPartResults()->filteredStepNames(); - if ( frameIdx < static_cast( stepNames.size() ) ) + std::vector stepNames = rigCaseData->femPartResults()->stepNames(); + if ( timeStepIdx < static_cast( stepNames.size() ) ) { - return QString::fromStdString( stepNames[frameIdx] ); + return QString::fromStdString( stepNames[timeStepIdx] ); } } @@ -519,28 +519,31 @@ cvf::BoundingBox RimGeoMechCase::reservoirBoundingBox() cvf::BoundingBox boundingBox; RigGeoMechCaseData* rigCaseData = this->geoMechData(); - if ( rigCaseData && rigCaseData->femPartResults() && rigCaseData->femParts()->part( 0 ) ) + if ( rigCaseData && rigCaseData->femPartResults() && rigCaseData->femParts() ) { - RigFemPart* femPart = rigCaseData->femParts()->part( 0 ); - const RigFemPartGrid* femPartGrid = femPart->getOrCreateStructGrid(); - - RigFemResultAddress porBarAddr( RigFemResultPosEnum::RIG_ELEMENT_NODAL, "POR-Bar", "" ); - const std::vector& resultValues = rigCaseData->femPartResults()->resultValues( porBarAddr, 0, 0 ); - - for ( int i = 0; i < femPart->elementCount(); ++i ) + for ( int p = 0; p < rigCaseData->femParts()->partCount(); p++ ) { - size_t resValueIdx = femPart->elementNodeResultIdx( (int)i, 0 ); - CVF_ASSERT( resValueIdx < resultValues.size() ); - double scalarValue = resultValues[resValueIdx]; - bool validPorValue = scalarValue != std::numeric_limits::infinity(); + RigFemPart* femPart = rigCaseData->femParts()->part( p ); + const RigFemPartGrid* femPartGrid = femPart->getOrCreateStructGrid(); - if ( validPorValue ) + RigFemResultAddress porBarAddr( RigFemResultPosEnum::RIG_ELEMENT_NODAL, "POR-Bar", "" ); + const std::vector& resultValues = rigCaseData->femPartResults()->resultValues( porBarAddr, p, 0, 0 ); + + for ( int i = 0; i < femPart->elementCount(); ++i ) { - std::array hexCorners; - femPartGrid->cellCornerVertices( i, hexCorners.data() ); - for ( size_t c = 0; c < 8; ++c ) + size_t resValueIdx = femPart->elementNodeResultIdx( (int)i, 0 ); + CVF_ASSERT( resValueIdx < resultValues.size() ); + double scalarValue = resultValues[resValueIdx]; + bool validPorValue = scalarValue != std::numeric_limits::infinity(); + + if ( validPorValue ) { - boundingBox.add( hexCorners[c] ); + std::array hexCorners; + femPartGrid->cellCornerVertices( i, hexCorners.data() ); + for ( size_t c = 0; c < 8; ++c ) + { + boundingBox.add( hexCorners[c] ); + } } } } diff --git a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechCase.h b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechCase.h index e2452b3a35..2ca0b77870 100644 --- a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechCase.h +++ b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechCase.h @@ -87,7 +87,7 @@ public: std::vector timeStepDates() const override; QStringList timeStepStrings() const override; - QString timeStepName( int frameIdx ) const override; + QString timeStepName( int timeStepIdx ) const override; cvf::BoundingBox reservoirBoundingBox() override; cvf::BoundingBox activeCellsBoundingBox() const override; diff --git a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechContourMapProjection.cpp b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechContourMapProjection.cpp index 006d4cfc86..8d1cb95836 100644 --- a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechContourMapProjection.cpp +++ b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechContourMapProjection.cpp @@ -159,9 +159,12 @@ cvf::ref RimGeoMechContourMapProjection::getCellVisibility() co } if ( view()->propertyFilterCollection()->isActive() ) { + auto [stepIdx, frameIdx] = view()->currentStepAndDataFrame(); + RivFemElmVisibilityCalculator::computePropertyVisibility( cellGridIdxVisibility.p(), m_femPart.p(), - view()->currentTimeStep(), + stepIdx, + frameIdx, cellGridIdxVisibility.p(), view()->geoMechPropertyFilterCollection() ); } @@ -172,7 +175,7 @@ cvf::ref RimGeoMechContourMapProjection::getCellVisibility() co //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -cvf::BoundingBox RimGeoMechContourMapProjection::calculateExpandedPorBarBBox( int timeStep ) const +cvf::BoundingBox RimGeoMechContourMapProjection::calculateExpandedPorBarBBox( int timeStep, int frameIndex ) const { RigFemResultAddress porBarAddr( RigFemResultPosEnum::RIG_ELEMENT_NODAL, "POR-Bar", @@ -180,7 +183,7 @@ cvf::BoundingBox RimGeoMechContourMapProjection::calculateExpandedPorBarBBox( in RigGeoMechCaseData* caseData = geoMechCase()->geoMechData(); RigFemPartResultsCollection* resultCollection = caseData->femPartResults(); - const std::vector& resultValues = resultCollection->resultValues( porBarAddr, 0, timeStep ); + const std::vector& resultValues = resultCollection->resultValues( porBarAddr, 0, timeStep, frameIndex ); cvf::BoundingBox boundingBox; if ( resultValues.empty() ) @@ -230,7 +233,9 @@ void RimGeoMechContourMapProjection::updateGridInformation() if ( m_limitToPorePressureRegions ) { - m_expandedBoundingBox = calculateExpandedPorBarBBox( view()->currentTimeStep() ); + auto [stepIdx, frameIdx] = view()->currentStepAndDataFrame(); + + m_expandedBoundingBox = calculateExpandedPorBarBBox( stepIdx, frameIdx ); if ( !m_expandedBoundingBox.isValid() ) { m_limitToPorePressureRegions = false; @@ -333,12 +338,13 @@ std::vector RimGeoMechContourMapProjection::retrieveParameterWeights() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RimGeoMechContourMapProjection::generateResults( int timeStep ) +std::vector RimGeoMechContourMapProjection::generateResults( int viewerStepIndex ) { RimGeoMechCellColors* cellColors = view()->cellResult(); RigFemResultAddress resultAddress = cellColors->resultAddress(); - std::vector aggregatedResults = generateResultsFromAddress( resultAddress, m_mapCellVisibility, timeStep ); + std::vector aggregatedResults = + generateResultsFromAddress( resultAddress, m_mapCellVisibility, viewerStepIndex ); return aggregatedResults; } @@ -348,13 +354,15 @@ std::vector RimGeoMechContourMapProjection::generateResults( int timeSte //-------------------------------------------------------------------------------------------------- std::vector RimGeoMechContourMapProjection::generateResultsFromAddress( RigFemResultAddress resultAddress, const std::vector& mapCellVisibility, - int timeStep ) + int viewerStepIndex ) { RigGeoMechCaseData* caseData = geoMechCase()->geoMechData(); RigFemPartResultsCollection* resultCollection = caseData->femPartResults(); size_t nCells = numberOfCells(); std::vector aggregatedResults = std::vector( nCells, std::numeric_limits::infinity() ); + auto [stepIdx, frameIdx] = caseData->femPartResults()->stepListIndexToTimeStepAndDataFrameIndex( viewerStepIndex ); + bool wasInvalid = false; if ( !resultAddress.isValid() ) { @@ -375,7 +383,7 @@ std::vector RimGeoMechContourMapProjection::generateResultsFromAddress( resultAddress.resultPosType = RIG_ELEMENT_NODAL; // formation indices are stored per element node result. } - std::vector resultValuesF = resultCollection->resultValues( resultAddress, 0, timeStep ); + std::vector resultValuesF = resultCollection->resultValues( resultAddress, 0, stepIdx, frameIdx ); if ( resultValuesF.empty() ) return aggregatedResults; std::vector resultValues = gridCellValues( resultAddress, resultValuesF ); @@ -672,3 +680,32 @@ void RimGeoMechContourMapProjection::defineEditorAttribute( const caf::PdmFieldH } } } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::pair RimGeoMechContourMapProjection::minmaxValuesAllTimeSteps() +{ + if ( !resultRangeIsValid() ) + { + clearTimeStepRange(); + + m_minResultAllTimeSteps = std::min( m_minResultAllTimeSteps, minValue( m_aggregatedResults ) ); + m_maxResultAllTimeSteps = std::max( m_maxResultAllTimeSteps, maxValue( m_aggregatedResults ) ); + + if ( geoMechCase() && geoMechCase()->geoMechData() && geoMechCase()->geoMechData()->femPartResults() ) + { + int steps = geoMechCase()->geoMechData()->femPartResults()->totalSteps(); + + for ( int stepIdx = 0; stepIdx < steps; stepIdx++ ) + { + if ( stepIdx == m_currentResultTimestep ) continue; + + std::vector aggregatedResults = generateResults( stepIdx ); + m_minResultAllTimeSteps = std::min( m_minResultAllTimeSteps, minValue( aggregatedResults ) ); + m_maxResultAllTimeSteps = std::max( m_maxResultAllTimeSteps, maxValue( aggregatedResults ) ); + } + } + } + return std::make_pair( m_minResultAllTimeSteps, m_maxResultAllTimeSteps ); +} diff --git a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechContourMapProjection.h b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechContourMapProjection.h index e8f92773c5..c90bebe207 100644 --- a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechContourMapProjection.h +++ b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechContourMapProjection.h @@ -62,14 +62,14 @@ protected: // GeoMech implementation specific data generation methods cvf::ref getCellVisibility() const override; - cvf::BoundingBox calculateExpandedPorBarBBox( int timeStep ) const; + cvf::BoundingBox calculateExpandedPorBarBBox( int timeStep, int frameIndex ) const; void updateGridInformation() override; std::vector getMapCellVisibility() override; std::vector retrieveParameterWeights() override; - std::vector generateResults( int timeStep ) override; + std::vector generateResults( int viewerStepIndex ) override; std::vector generateResultsFromAddress( RigFemResultAddress resultAddress, const std::vector& mapCellVisibility, - int timeStep ); + int viewerStepIndex ); bool resultVariableChanged() const override; void clearResultVariable() override; RimGridView* baseView() const override; @@ -85,6 +85,8 @@ protected: RimGeoMechCase* geoMechCase() const; RimGeoMechContourMapView* view() const; + std::pair minmaxValuesAllTimeSteps() override; + void updateAfterResultGeneration( int timeStep ) override; protected: diff --git a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechContourMapView.cpp b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechContourMapView.cpp index 1420fc92b8..48d5e34dcb 100644 --- a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechContourMapView.cpp +++ b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechContourMapView.cpp @@ -260,7 +260,7 @@ void RimGeoMechContourMapView::updateGeometry() { // Step 1: generate results. About 30% of the time. if ( m_contourMapProjection->isChecked() ) { - m_contourMapProjection->generateResultsIfNecessary( m_currentTimeStep() ); + m_contourMapProjection->generateResultsIfNecessary( m_currentTimeStep ); } onUpdateLegends(); diff --git a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechResultDefinition.cpp b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechResultDefinition.cpp index 4d2da14dbc..44a263c429 100644 --- a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechResultDefinition.cpp +++ b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechResultDefinition.cpp @@ -249,7 +249,7 @@ QList std::vector stepNames; if ( m_geomCase->geoMechData() ) { - stepNames = m_geomCase->geoMechData()->femPartResults()->filteredStepNames(); + stepNames = m_geomCase->geoMechData()->femPartResults()->stepNames(); } options.push_back( caf::PdmOptionItemInfo( QString( "Disabled" ), RigFemResultAddress::noTimeLapseValue() ) ); @@ -265,7 +265,7 @@ QList std::vector stepNames; if ( m_geomCase->geoMechData() ) { - stepNames = m_geomCase->geoMechData()->femPartResults()->filteredStepNames(); + stepNames = m_geomCase->geoMechData()->femPartResults()->stepNames(); } for ( size_t stepIdx = 0; stepIdx < stepNames.size(); ++stepIdx ) @@ -698,14 +698,14 @@ QString RimGeoMechResultDefinition::diffResultUiName() const { if ( referenceCaseDependentResultSelected() ) { - std::vector stepNames = m_geomCase->geoMechData()->femPartResults()->filteredStepNames(); - QString timeStepString = QString::fromStdString( stepNames[m_referenceTimeStep()] ); + std::vector timeStepNames = m_geomCase->geoMechData()->femPartResults()->stepNames(); + QString timeStepString = QString::fromStdString( timeStepNames[m_referenceTimeStep()] ); diffResultString += QString( "Reference Time Step: %1" ).arg( timeStepString ); } else if ( m_timeLapseBaseTimestep != RigFemResultAddress::noTimeLapseValue() ) { - std::vector stepNames = m_geomCase->geoMechData()->femPartResults()->filteredStepNames(); - QString timeStepString = QString::fromStdString( stepNames[m_timeLapseBaseTimestep()] ); + std::vector timeStepNames = m_geomCase->geoMechData()->femPartResults()->stepNames(); + QString timeStepString = QString::fromStdString( timeStepNames[m_timeLapseBaseTimestep()] ); diffResultString += QString( "Base Time Step: %1" ).arg( timeStepString ); } } @@ -943,7 +943,7 @@ void RimGeoMechResultDefinition::setResultAddress( const RigFemResultAddress& re //-------------------------------------------------------------------------------------------------- void RimGeoMechResultDefinition::updateLegendTextAndRanges( RimRegularLegendConfig* legendConfigToUpdate, const QString& legendHeading, - int timeStepIndex ) + int viewerStepIndex ) { if ( !this->ownerCaseData() || !( this->resultAddress().isValid() ) ) { @@ -960,8 +960,14 @@ void RimGeoMechResultDefinition::updateLegendTextAndRanges( RimRegularLegendConf RigFemResultAddress resVarAddress = this->resultAddress(); - gmCase->femPartResults()->minMaxScalarValues( resVarAddress, timeStepIndex, &localMin, &localMax ); - gmCase->femPartResults()->posNegClosestToZero( resVarAddress, timeStepIndex, &localPosClosestToZero, &localNegClosestToZero ); + auto [stepIdx, frameIdx] = gmCase->femPartResults()->stepListIndexToTimeStepAndDataFrameIndex( viewerStepIndex ); + + gmCase->femPartResults()->minMaxScalarValues( resVarAddress, stepIdx, frameIdx, &localMin, &localMax ); + gmCase->femPartResults()->posNegClosestToZero( resVarAddress, + stepIdx, + frameIdx, + &localPosClosestToZero, + &localNegClosestToZero ); gmCase->femPartResults()->minMaxScalarValues( resVarAddress, &globalMin, &globalMax ); gmCase->femPartResults()->posNegClosestToZero( resVarAddress, &globalPosClosestToZero, &globalNegClosestToZero ); diff --git a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechView.cpp b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechView.cpp index f280e98222..0ab39a085b 100644 --- a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechView.cpp +++ b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechView.cpp @@ -83,6 +83,8 @@ CAF_PDM_SOURCE_INIT( RimGeoMechView, "GeoMechView" ); /// //-------------------------------------------------------------------------------------------------- RimGeoMechView::RimGeoMechView( void ) + : m_currentInternalTimeStep( 0 ) + , m_currentDataFrameIndex( -1 ) { CAF_PDM_InitScriptableObject( "Geomechanical View", ":/3DViewGeoMech16x16.png", "", "The Geomechanical 3d View" ); @@ -277,10 +279,9 @@ void RimGeoMechView::onCreateDisplayModel() if ( isTimeStepDependentDataVisibleInThisOrComparisonView() ) { - // Create empty frames in the viewer - - int frameCount = geoMechCase()->geoMechData()->femPartResults()->frameCount(); - for ( int frameIndex = 0; frameIndex < frameCount; frameIndex++ ) + // Create empty frames in the viewer, one per global timestep + const int totalSteps = geoMechCase()->geoMechData()->femPartResults()->totalSteps(); + for ( int timeStepIndex = 0; timeStepIndex < totalSteps; timeStepIndex++ ) { cvf::ref scene = new cvf::Scene; cvf::ref emptyModel = new cvf::ModelBasicList; @@ -370,7 +371,11 @@ void RimGeoMechView::updateElementDisplacements() { std::string errmsg; std::vector displacements; - m_geomechCase->geoMechData()->readDisplacements( &errmsg, part->partId(), m_currentTimeStep, &displacements ); + m_geomechCase->geoMechData()->readDisplacements( &errmsg, + part->partId(), + m_currentInternalTimeStep, + m_currentDataFrameIndex, + &displacements ); part->setDisplacements( displacements ); } } @@ -381,6 +386,15 @@ void RimGeoMechView::updateElementDisplacements() m_vizLogic->scheduleGeometryRegenOfVisiblePartMgrs( m_currentTimeStep ); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::pair RimGeoMechView::viewerStepToTimeStepAndFrameIndex( int viewerTimeStep ) +{ + // assuming callers check if the case etc. exists + return m_geomechCase->geoMechData()->femPartResults()->stepListIndexToTimeStepAndDataFrameIndex( viewerTimeStep ); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -431,7 +445,10 @@ void RimGeoMechView::onUpdateDisplayModelForCurrentTimeStep() cvf::ref frameParts = new cvf::ModelBasicList; frameParts->setName( name ); - m_tensorPartMgr->appendDynamicGeometryPartsToModel( frameParts.p(), m_currentTimeStep ); + m_tensorPartMgr->appendDynamicGeometryPartsToModel( frameParts.p(), + m_currentTimeStep, + m_currentInternalTimeStep, + m_currentDataFrameIndex ); frameParts->updateBoundingBoxesRecursive(); if ( frameParts->partCount() != 0 ) @@ -445,7 +462,10 @@ void RimGeoMechView::onUpdateDisplayModelForCurrentTimeStep() bool hasGeneralCellResult = this->cellResult()->hasResult(); if ( hasGeneralCellResult ) - m_vizLogic->updateCellResultColor( m_currentTimeStep(), this->cellResult() ); + m_vizLogic->updateCellResultColor( m_currentTimeStep(), + m_currentInternalTimeStep, + m_currentDataFrameIndex, + this->cellResult() ); else m_vizLogic->updateStaticCellColors( m_currentTimeStep() ); @@ -466,8 +486,8 @@ void RimGeoMechView::onUpdateDisplayModelForCurrentTimeStep() { m_vizLogic->updateStaticCellColors( -1 ); - m_intersectionCollection->updateCellResultColor( false, m_currentTimeStep ); - if ( m_surfaceCollection ) m_surfaceCollection->updateCellResultColor( false, m_currentTimeStep ); + m_intersectionCollection->updateCellResultColor( false, m_currentInternalTimeStep ); + if ( m_surfaceCollection ) m_surfaceCollection->updateCellResultColor( false, m_currentInternalTimeStep ); nativeOrOverrideViewer()->animationControl()->slotPause(); // To avoid animation timer spinning in the background } @@ -589,7 +609,7 @@ void RimGeoMechView::onUpdateLegends() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimGeoMechView::updateTensorLegendTextAndRanges( RimRegularLegendConfig* legendConfig, int timeStepIndex ) +void RimGeoMechView::updateTensorLegendTextAndRanges( RimRegularLegendConfig* legendConfig, int viewerTimeStep ) { if ( !m_geomechCase || !m_geomechCase->geoMechData() ) return; @@ -606,9 +626,16 @@ void RimGeoMechView::updateTensorLegendTextAndRanges( RimRegularLegendConfig* le RigFemResultAddress resVarAddress( resPos, resFieldName.toStdString(), "" ); - gmCase->femPartResults()->minMaxScalarValuesOverAllTensorComponents( resVarAddress, timeStepIndex, &localMin, &localMax ); + auto [timeStepIndex, frameIndex] = gmCase->femPartResults()->stepListIndexToTimeStepAndDataFrameIndex( viewerTimeStep ); + + gmCase->femPartResults()->minMaxScalarValuesOverAllTensorComponents( resVarAddress, + timeStepIndex, + frameIndex, + &localMin, + &localMax ); gmCase->femPartResults()->posNegClosestToZeroOverAllTensorComponents( resVarAddress, timeStepIndex, + frameIndex, &localPosClosestToZero, &localNegClosestToZero ); @@ -793,15 +820,16 @@ RimGeoMechCase* RimGeoMechView::geoMechCase() const //-------------------------------------------------------------------------------------------------- void RimGeoMechView::onClampCurrentTimestep() { - int maxFrameCount = 0; + int maxSteps = 0; if ( m_geomechCase ) { - maxFrameCount = m_geomechCase->geoMechData()->femPartResults()->frameCount(); + maxSteps = m_geomechCase->geoMechData()->femPartResults()->totalSteps(); } - - if ( m_currentTimeStep >= maxFrameCount ) m_currentTimeStep = maxFrameCount - 1; + if ( m_currentTimeStep >= maxSteps ) m_currentTimeStep = maxSteps - 1; if ( m_currentTimeStep < 0 ) m_currentTimeStep = 0; + + std::tie( m_currentInternalTimeStep, m_currentDataFrameIndex ) = viewerStepToTimeStepAndFrameIndex( m_currentTimeStep ); } //-------------------------------------------------------------------------------------------------- @@ -811,7 +839,7 @@ size_t RimGeoMechView::onTimeStepCountRequested() { if ( m_geomechCase && m_geomechCase->geoMechData() && m_geomechCase->geoMechData()->femPartResults() ) { - return m_geomechCase->geoMechData()->femPartResults()->frameCount(); + return m_geomechCase->geoMechData()->femPartResults()->totalSteps(); } return 0; @@ -963,9 +991,9 @@ const RimGeoMechPropertyFilterCollection* RimGeoMechView::geoMechPropertyFilterC //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimGeoMechView::calculateCurrentTotalCellVisibility( cvf::UByteArray* totalVisibility, int timeStep ) +void RimGeoMechView::calculateCurrentTotalCellVisibility( cvf::UByteArray* totalVisibility, int viewerTimeStep ) { - m_vizLogic->calculateCurrentTotalCellVisibility( totalVisibility, timeStep ); + m_vizLogic->calculateCurrentTotalCellVisibility( totalVisibility, viewerTimeStep ); } //-------------------------------------------------------------------------------------------------- @@ -1063,6 +1091,14 @@ const RimGeoMechPartCollection* RimGeoMechView::partsCollection() const return m_partsCollection(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::pair RimGeoMechView::currentStepAndDataFrame() const +{ + return std::make_pair( m_currentInternalTimeStep, m_currentDataFrameIndex ); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechView.h b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechView.h index 0fd8f6b4ba..05ce4565fc 100644 --- a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechView.h +++ b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechView.h @@ -93,9 +93,9 @@ public: bool isUsingFormationNames() const override; - void calculateCurrentTotalCellVisibility( cvf::UByteArray* totalVisibility, int timeStep ) override; + void calculateCurrentTotalCellVisibility( cvf::UByteArray* totalVisibility, int viewerTimeStep ) override; - void updateLegendTextAndRanges( RimRegularLegendConfig* legendConfig, int timeStepIndex ); + void updateLegendTextAndRanges( RimRegularLegendConfig* legendConfig, int viewerTimeStep ); const cvf::ref vizLogic() const; const RimTensorResults* tensorResults() const; @@ -112,6 +112,8 @@ public: bool showDisplacements() const; void setShowDisplacementsAndUpdate( bool show ); + std::pair currentStepAndDataFrame() const; + protected: void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "" ) override; @@ -138,10 +140,12 @@ private: void onUpdateLegends() override; - void updateTensorLegendTextAndRanges( RimRegularLegendConfig* legendConfig, int timeStepIndex ); + void updateTensorLegendTextAndRanges( RimRegularLegendConfig* legendConfig, int viewerTimeStep ); void updateElementDisplacements(); + std::pair viewerStepToTimeStepAndFrameIndex( int viewerTimeStep ); + caf::PdmChildField m_tensorResults; caf::PdmChildField m_propertyFilterCollection; caf::PdmPointer m_overridePropertyFilterCollection; @@ -154,4 +158,7 @@ private: cvf::ref m_scaleTransform; cvf::ref m_tensorPartMgr; + + int m_currentInternalTimeStep; + int m_currentDataFrameIndex; }; diff --git a/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionCollection.cpp b/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionCollection.cpp index af6b931d30..b98ab0cf97 100644 --- a/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionCollection.cpp @@ -134,7 +134,7 @@ void RimIntersectionCollection::applySingleColorEffect() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimIntersectionCollection::updateCellResultColor( bool hasGeneralCellResult, size_t timeStepIndex ) +void RimIntersectionCollection::updateCellResultColor( bool hasGeneralCellResult, int timeStepIndex ) { if ( !this->isActive() ) return; diff --git a/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionCollection.h b/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionCollection.h index cb48b86ecc..95a888e125 100644 --- a/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionCollection.h +++ b/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionCollection.h @@ -73,7 +73,7 @@ public: // Visualization interface void applySingleColorEffect(); - void updateCellResultColor( bool hasGeneralCellResult, size_t timeStepIndex ); + void updateCellResultColor( bool hasGeneralCellResult, int timeStepIndex ); void appendPartsToModel( Rim3dView& view, cvf::ModelBasicList* model, cvf::Transform* scaleTransform ); void rebuildGeometry(); diff --git a/ApplicationLibCode/ProjectDataModel/RimContourMapProjection.h b/ApplicationLibCode/ProjectDataModel/RimContourMapProjection.h index ae08b77e8f..857f4b5316 100644 --- a/ApplicationLibCode/ProjectDataModel/RimContourMapProjection.h +++ b/ApplicationLibCode/ProjectDataModel/RimContourMapProjection.h @@ -157,9 +157,10 @@ protected: void clearResults(); void clearTimeStepRange(); - double maxValue( const std::vector& aggregatedResults ) const; - double minValue( const std::vector& aggregatedResults ) const; - std::pair minmaxValuesAllTimeSteps(); + double maxValue( const std::vector& aggregatedResults ) const; + double minValue( const std::vector& aggregatedResults ) const; + + virtual std::pair minmaxValuesAllTimeSteps(); virtual cvf::ref getCellVisibility() const; virtual std::vector getMapCellVisibility(); diff --git a/ApplicationLibCode/ProjectDataModel/RimHistogramCalculator.cpp b/ApplicationLibCode/ProjectDataModel/RimHistogramCalculator.cpp index 788c8aaad1..c20d387540 100644 --- a/ApplicationLibCode/ProjectDataModel/RimHistogramCalculator.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimHistogramCalculator.cpp @@ -288,13 +288,22 @@ RigHistogramData RimHistogramCalculator::histogramData( RimGeoMechView* } else if ( timeRange == StatisticsTimeRangeType::CURRENT_TIMESTEP ) { - int timeStepIdx = geoMechView->currentTimeStep(); - caseData->femPartResults()->meanScalarValue( resAddress, timeStepIdx, &histData.mean ); - caseData->femPartResults()->minMaxScalarValues( resAddress, timeStepIdx, &histData.min, &histData.max ); - caseData->femPartResults()->p10p90ScalarValues( resAddress, timeStepIdx, &histData.p10, &histData.p90 ); - caseData->femPartResults()->sumScalarValue( resAddress, timeStepIdx, &histData.sum ); + auto [timeStepIdx, frameIdx] = geoMechView->currentStepAndDataFrame(); + caseData->femPartResults()->meanScalarValue( resAddress, timeStepIdx, frameIdx, &histData.mean ); + caseData->femPartResults()->minMaxScalarValues( resAddress, + timeStepIdx, + frameIdx, + &histData.min, + &histData.max ); + caseData->femPartResults()->p10p90ScalarValues( resAddress, + timeStepIdx, + frameIdx, + &histData.p10, + &histData.p90 ); + caseData->femPartResults()->sumScalarValue( resAddress, timeStepIdx, frameIdx, &histData.sum ); - histData.histogram = caseData->femPartResults()->scalarValuesHistogram( resAddress, timeStepIdx ); + histData.histogram = + caseData->femPartResults()->scalarValuesHistogram( resAddress, timeStepIdx, frameIdx ); } } else if ( cellRange == StatisticsCellRangeType::VISIBLE_CELLS ) diff --git a/ApplicationLibCode/ProjectDataModel/RimTensorResults.cpp b/ApplicationLibCode/ProjectDataModel/RimTensorResults.cpp index 088f09b077..17623cd8be 100644 --- a/ApplicationLibCode/ProjectDataModel/RimTensorResults.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimTensorResults.cpp @@ -199,19 +199,19 @@ void RimTensorResults::mappingRange( double* min, double* max ) const Rim3dView* view = nullptr; firstAncestorOrThisOfType( view ); - int currentTimeStep = view->currentTimeStep(); - RimGeoMechView* geoMechView = dynamic_cast( view ); RigFemPartResultsCollection* resultCollection = geoMechView->geoMechCase()->geoMechData()->femPartResults(); if ( !resultCollection ) return; + auto [stepIdx, frameIdx] = geoMechView->currentStepAndDataFrame(); + if ( m_rangeMode == RimRegularLegendConfig::RangeModeType::AUTOMATIC_ALLTIMESTEPS ) { resultCollection->minMaxScalarValuesOverAllTensorComponents( selectedTensorResult(), min, max ); } else if ( m_rangeMode == RimRegularLegendConfig::RangeModeType::AUTOMATIC_CURRENT_TIMESTEP ) { - resultCollection->minMaxScalarValuesOverAllTensorComponents( selectedTensorResult(), currentTimeStep, min, max ); + resultCollection->minMaxScalarValuesOverAllTensorComponents( selectedTensorResult(), stepIdx, frameIdx, min, max ); } } } diff --git a/ApplicationLibCode/ProjectDataModel/RimWbsParameters.cpp b/ApplicationLibCode/ProjectDataModel/RimWbsParameters.cpp index 843ad0a902..06eb3ae794 100644 --- a/ApplicationLibCode/ProjectDataModel/RimWbsParameters.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimWbsParameters.cpp @@ -135,6 +135,8 @@ RimWbsParameters::RimWbsParameters() m_wellPath.uiCapability()->setUiHidden( true ); CAF_PDM_InitField( &m_timeStep, "TimeStep", -1, "TimeStep" ); m_timeStep.uiCapability()->setUiHidden( true ); + CAF_PDM_InitField( &m_frameIndex, "FrameIndex", -1, "FrameIndex" ); + m_frameIndex.uiCapability()->setUiHidden( true ); m_parameterSourceFields = { { RigWbsParameter::PP_Reservoir(), &m_porePressureSource }, { RigWbsParameter::PP_NonReservoir(), &m_porePressureNonReservoirSource }, @@ -182,6 +184,7 @@ RimWbsParameters& RimWbsParameters::operator=( const RimWbsParameters& copyFrom m_geoMechCase = copyFrom.m_geoMechCase(); m_wellPath = copyFrom.m_wellPath(); m_timeStep = copyFrom.m_timeStep(); + m_frameIndex = copyFrom.m_frameIndex(); for ( auto parameterSourcePair : m_parameterSourceFields ) { @@ -230,6 +233,14 @@ void RimWbsParameters::setTimeStep( int timeStep ) m_timeStep = timeStep; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWbsParameters::setFrameIndex( int frameIndex ) +{ + m_frameIndex = frameIndex; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -425,7 +436,7 @@ bool RimWbsParameters::hasElementPropertyEntry( const RigFemResultAddress& resAd femPartResults = m_geoMechCase->geoMechData()->femPartResults(); if ( femPartResults ) { - return !femPartResults->resultValues( resAddr, 0, m_timeStep ).empty(); + return !femPartResults->resultValues( resAddr, 0, m_timeStep, m_frameIndex ).empty(); } } return false; diff --git a/ApplicationLibCode/ProjectDataModel/RimWbsParameters.h b/ApplicationLibCode/ProjectDataModel/RimWbsParameters.h index d3df743bf2..7669188a59 100644 --- a/ApplicationLibCode/ProjectDataModel/RimWbsParameters.h +++ b/ApplicationLibCode/ProjectDataModel/RimWbsParameters.h @@ -47,6 +47,7 @@ public: void setGeoMechCase( RimGeoMechCase* geoMechCase ); void setWellPath( RimWellPath* wellPath ); void setTimeStep( int timeStep ); + void setFrameIndex( int frameIndex ); void applyWbsParametersToExtractor( RigGeoMechWellLogExtractor* extractor ); @@ -98,6 +99,7 @@ private: caf::PdmPtrField m_geoMechCase; caf::PdmPtrField m_wellPath; caf::PdmField m_timeStep; + caf::PdmField m_frameIndex; std::map*> m_parameterSourceFields; std::map*> m_userDefinedValueFields; diff --git a/ApplicationLibCode/ProjectDataModel/RimWellBoreStabilityPlot.cpp b/ApplicationLibCode/ProjectDataModel/RimWellBoreStabilityPlot.cpp index b8e0743add..8c3ea53e88 100644 --- a/ApplicationLibCode/ProjectDataModel/RimWellBoreStabilityPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimWellBoreStabilityPlot.cpp @@ -111,11 +111,15 @@ void RimWellBoreStabilityPlot::copyWbsParameters( const RimWbsParameters* wbsPar //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimWellBoreStabilityPlot::setCaseWellPathAndTimeStep( RimGeoMechCase* geoMechCase, RimWellPath* wellPath, int timeStep ) +void RimWellBoreStabilityPlot::setCaseWellPathAndTimeStep( RimGeoMechCase* geoMechCase, + RimWellPath* wellPath, + int timeStep, + int frameIndex /* = -1 */ ) { m_wbsParameters->setGeoMechCase( geoMechCase ); m_wbsParameters->setWellPath( wellPath ); m_wbsParameters->setTimeStep( timeStep ); + m_wbsParameters->setFrameIndex( frameIndex ); } //-------------------------------------------------------------------------------------------------- @@ -215,6 +219,7 @@ void RimWellBoreStabilityPlot::applyDataSource() m_wbsParameters->setGeoMechCase( dynamic_cast( m_commonDataSource->caseToApply() ) ); m_wbsParameters->setWellPath( m_commonDataSource->wellPathToApply() ); m_wbsParameters->setTimeStep( m_commonDataSource->timeStepToApply() ); + m_wbsParameters->setFrameIndex( -1 ); this->updateReferenceWellPathInCurves(); this->updateConnectedEditors(); diff --git a/ApplicationLibCode/ProjectDataModel/RimWellBoreStabilityPlot.h b/ApplicationLibCode/ProjectDataModel/RimWellBoreStabilityPlot.h index 55dedb1393..c0afc1b465 100644 --- a/ApplicationLibCode/ProjectDataModel/RimWellBoreStabilityPlot.h +++ b/ApplicationLibCode/ProjectDataModel/RimWellBoreStabilityPlot.h @@ -39,7 +39,8 @@ public: void applyWbsParametersToExtractor( RigGeoMechWellLogExtractor* extractor ); double userDefinedValue( const RigWbsParameter& parameter ) const; void copyWbsParameters( const RimWbsParameters* wbsParameters ); - void setCaseWellPathAndTimeStep( RimGeoMechCase* geoMechCase, RimWellPath* wellPath, int timeStep ); + + void setCaseWellPathAndTimeStep( RimGeoMechCase* geoMechCase, RimWellPath* wellPath, int timeStep, int frameIndex = -1 ); protected: void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; diff --git a/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurfaceInViewCollection.cpp b/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurfaceInViewCollection.cpp index 7107800e88..de82e42c58 100644 --- a/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurfaceInViewCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurfaceInViewCollection.cpp @@ -367,7 +367,7 @@ RimSurfaceInViewCollection* //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSurfaceInViewCollection::updateCellResultColor( bool hasGeneralCellResult, size_t timeStepIndex ) +void RimSurfaceInViewCollection::updateCellResultColor( bool hasGeneralCellResult, int timeStepIndex ) { if ( !this->isChecked() ) return; diff --git a/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurfaceInViewCollection.h b/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurfaceInViewCollection.h index 3da396645a..aeb25fe83e 100644 --- a/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurfaceInViewCollection.h +++ b/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurfaceInViewCollection.h @@ -58,7 +58,7 @@ public: void clearGeometry(); void appendPartsToModel( cvf::ModelBasicList* surfaceVizModel, cvf::Transform* scaleTransform ); - void updateCellResultColor( bool hasGeneralCellResult, size_t timeStepIndex ); + void updateCellResultColor( bool hasGeneralCellResult, int timeStepIndex ); void applySingleColorEffect(); bool hasAnyActiveSeparateResults(); diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/Rim3dWellLogCurve.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/Rim3dWellLogCurve.cpp index 2e64283d16..c91b734318 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/Rim3dWellLogCurve.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/Rim3dWellLogCurve.cpp @@ -154,7 +154,7 @@ void Rim3dWellLogCurve::curveValuesAndMdsAtTimeStep( std::vector* values std::vector* measuredDepthValues, int timeStep ) const { - return this->curveValuesAndMds( values, measuredDepthValues ); + curveValuesAndMds( values, measuredDepthValues ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/Rim3dWellLogExtractionCurve.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/Rim3dWellLogExtractionCurve.cpp index d703adc36c..7defa5a26d 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/Rim3dWellLogExtractionCurve.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/Rim3dWellLogExtractionCurve.cpp @@ -170,7 +170,7 @@ void Rim3dWellLogExtractionCurve::curveValuesAndMds( std::vector* values { CVF_ASSERT( m_timeStep() >= 0 ); - return this->curveValuesAndMdsAtTimeStep( values, measuredDepthValues, m_timeStep() ); + return this->curveValuesAndMdsAtTimeStep( values, measuredDepthValues, m_timeStep ); } //-------------------------------------------------------------------------------------------------- @@ -223,7 +223,11 @@ void Rim3dWellLogExtractionCurve::curveValuesAndMdsAtTimeStep( std::vectorloadResult(); - geomExtractor->curveData( m_geomResultDefinition->resultAddress(), timeStep, values ); + + auto [stepIndex, frameIndex] = + geomCase->geoMechData()->femPartResults()->stepListIndexToTimeStepAndDataFrameIndex( timeStep ); + + geomExtractor->curveData( m_geomResultDefinition->resultAddress(), stepIndex, frameIndex, values ); } } } @@ -338,7 +342,7 @@ QString Rim3dWellLogExtractionCurve::createAutoName() const RigGeoMechCaseData* data = geomCase->geoMechData(); if ( data ) { - maxTimeStep = data->femPartResults()->frameCount(); + maxTimeStep = data->femPartResults()->totalSteps(); } } @@ -450,6 +454,7 @@ void Rim3dWellLogExtractionCurve::fieldChangedByUi( const caf::PdmFieldHandle* c this->resetMinMaxValues(); this->updateConnectedEditors(); } + Rim3dWellLogCurve::fieldChangedByUi( changedField, oldValue, newValue ); } diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogExtractionCurve.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogExtractionCurve.cpp index f95ccb1da6..cc8afac2fd 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogExtractionCurve.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogExtractionCurve.cpp @@ -607,6 +607,9 @@ RimWellLogExtractionCurve::WellLogExtractionCurveData cvf::ref refWellExtractor = wellLogCollection->findOrCreateExtractor( m_refWellPath, geomCase ); + auto [timeStepIdx, frameIdx] = + geomCase->geoMechData()->femPartResults()->stepListIndexToTimeStepAndDataFrameIndex( m_timeStep ); + if ( wellExtractor.notNull() ) { curveData.measuredDepthValues = wellExtractor->cellIntersectionMDs(); @@ -628,7 +631,7 @@ RimWellLogExtractionCurve::WellLogExtractionCurveData m_geomResultDefinition->loadResult(); curveData.xUnits = - wellExtractor->curveData( m_geomResultDefinition->resultAddress(), m_timeStep, &curveData.values ); + wellExtractor->curveData( m_geomResultDefinition->resultAddress(), timeStepIdx, frameIdx, &curveData.values ); } // Do not adjust depth values of Azimuth and Inclination as they are dependent @@ -640,7 +643,6 @@ RimWellLogExtractionCurve::WellLogExtractionCurveData { RigFemResultAddress indexKResAdr( RigFemResultPosEnum::RIG_ELEMENT_NODAL, "INDEX", "INDEX_K" ); - const size_t frameIdx = 0; std::vector refWellMeasuredDepthValues = refWellExtractor->cellIntersectionMDs(); std::vector refWellTvDepthValues = refWellExtractor->cellIntersectionTVDs(); std::vector refWellPropertyValues; @@ -648,9 +650,9 @@ RimWellLogExtractionCurve::WellLogExtractionCurveData std::vector wellIndexKValues; if ( indexKResAdr.isValid() ) { - wellExtractor->curveData( indexKResAdr, frameIdx, &wellIndexKValues ); - refWellExtractor->curveData( indexKResAdr, frameIdx, &refWellIndexKValues ); - refWellExtractor->curveData( m_geomResultDefinition->resultAddress(), frameIdx, &refWellPropertyValues ); + wellExtractor->curveData( indexKResAdr, timeStepIdx, frameIdx, &wellIndexKValues ); + refWellExtractor->curveData( indexKResAdr, timeStepIdx, frameIdx, &refWellIndexKValues ); + refWellExtractor->curveData( m_geomResultDefinition->resultAddress(), timeStepIdx, frameIdx, &refWellPropertyValues ); } if ( !wellIndexKValues.empty() && !refWellIndexKValues.empty() && !refWellPropertyValues.empty() ) @@ -666,7 +668,8 @@ RimWellLogExtractionCurve::WellLogExtractionCurveData } if ( performDataSmoothing ) { - refWellExtractor->performCurveDataSmoothing( frameIdx, + refWellExtractor->performCurveDataSmoothing( timeStepIdx, + frameIdx, &curveData.measuredDepthValues, &curveData.tvDepthValues, &curveData.values, @@ -677,7 +680,8 @@ RimWellLogExtractionCurve::WellLogExtractionCurveData if ( wellExtractor.notNull() && performDataSmoothing ) { - wellExtractor->performCurveDataSmoothing( m_timeStep, + wellExtractor->performCurveDataSmoothing( timeStepIdx, + frameIdx, &curveData.measuredDepthValues, &curveData.tvDepthValues, &curveData.values, @@ -1148,7 +1152,7 @@ QString RimWellLogExtractionCurve::createCurveAutoName() { if ( geomCase->geoMechData() ) { - maxTimeStep = geomCase->geoMechData()->femPartResults()->frameCount(); + maxTimeStep = geomCase->geoMechData()->femPartResults()->totalSteps(); } } diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogTrack.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogTrack.cpp index 81b6bc57cc..ba5196d55d 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogTrack.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogTrack.cpp @@ -2604,7 +2604,7 @@ CurveSamplingPointData RimWellLogTrack::curveSamplingPointData( RigGeoMechWellLo curveData.tvd = extractor->cellIntersectionTVDs(); curveData.rkbDiff = extractor->wellPathGeometry()->rkbDiff(); - extractor->curveData( resultAddress, 0, &curveData.data ); + extractor->curveData( resultAddress, 0, 0, &curveData.data ); return curveData; } @@ -3190,6 +3190,9 @@ void RimWellLogTrack::updateCurveDataRegionsOnPlot() int timeStep = wellBoreStabilityPlot->commonDataSource()->timeStepToApply(); if ( geoMechCase && wellPath && timeStep >= 0 ) { + auto [stepIdx, frameIdx] = + geoMechCase->geoMechData()->femPartResults()->stepListIndexToTimeStepAndDataFrameIndex( timeStep ); + RigGeoMechWellLogExtractor* geoMechWellLogExtractor = nullptr; geoMechWellLogExtractor = RiaExtractionTools::findOrCreateWellLogExtractor( wellPath, dynamic_cast( geoMechCase ) ); @@ -3207,9 +3210,9 @@ void RimWellLogTrack::updateCurveDataRegionsOnPlot() wbsPlot->applyWbsParametersToExtractor( geoMechWellLogExtractor ); } - std::vector ppSourceRegions = geoMechWellLogExtractor->porePressureSourceRegions( timeStep ); - std::vector poissonSourceRegions = geoMechWellLogExtractor->poissonSourceRegions( timeStep ); - std::vector ucsSourceRegions = geoMechWellLogExtractor->ucsSourceRegions( timeStep ); + std::vector ppSourceRegions = geoMechWellLogExtractor->porePressureSourceRegions( stepIdx, frameIdx ); + std::vector poissonSourceRegions = geoMechWellLogExtractor->poissonSourceRegions( stepIdx, frameIdx ); + std::vector ucsSourceRegions = geoMechWellLogExtractor->ucsSourceRegions( stepIdx, frameIdx ); { caf::ColorTable colorTable( m_colorShadingLegend->colorArray() ); diff --git a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellIADataAccess.cpp b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellIADataAccess.cpp index 7d48dbf649..92b49c930d 100644 --- a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellIADataAccess.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellIADataAccess.cpp @@ -81,11 +81,12 @@ double RimWellIADataAccess::resultValue( QString fieldName, QString componentName, RigFemResultPosEnum resultType, size_t resultIndex, - int timeStep ) + int timeStep, + int frameId ) { RigFemResultAddress address( resultType, fieldName.toStdString(), componentName.toStdString() ); - const std::vector& scalarResults = m_caseData->femPartResults()->resultValues( address, 0, timeStep ); + const std::vector& scalarResults = m_caseData->femPartResults()->resultValues( address, 0, timeStep, frameId ); if ( resultIndex < scalarResults.size() ) return scalarResults[resultIndex]; @@ -99,7 +100,8 @@ double RimWellIADataAccess::interpolatedResultValue( QString fieldNa QString componentName, RigFemResultPosEnum resultType, cvf::Vec3d position, - int timeStep ) + int timeStep, + int frameId ) { RigFemResultAddress address( resultType, fieldName.toStdString(), componentName.toStdString() ); @@ -110,7 +112,7 @@ double RimWellIADataAccess::interpolatedResultValue( QString fieldNa const int* elementConn = femPart->connectivities( elmIdx ); int elmNodeCount = RigFemTypes::elementNodeCount( elmType ); - const std::vector& scalarResults = m_caseData->femPartResults()->resultValues( address, 0, timeStep ); + const std::vector& scalarResults = m_caseData->femPartResults()->resultValues( address, 0, timeStep, frameId ); std::array nodeResults; std::array nodeCorners; diff --git a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellIADataAccess.h b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellIADataAccess.h index 9b1c64f280..a22d2501e5 100644 --- a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellIADataAccess.h +++ b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellIADataAccess.h @@ -45,12 +45,14 @@ public: QString componentName, RigFemResultPosEnum resultType, size_t resultIndex, - int timeStep ); + int timeStep, + int frameId ); double interpolatedResultValue( QString fieldname, QString componentName, RigFemResultPosEnum resultType, cvf::Vec3d position, - int timeStep ); + int timeStep, + int frameId ); private: RimGeoMechCase* m_case; diff --git a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellIASettings.cpp b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellIASettings.cpp index bca6d5a65b..8d56bbdb22 100644 --- a/ApplicationLibCode/ProjectDataModel/WellPath/RimWellIASettings.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellPath/RimWellIASettings.cpp @@ -473,7 +473,7 @@ bool RimWellIASettings::updateResInsightParameters() for ( size_t i = 0; i < nativeKeys.size(); i++ ) { double stressValue = - dataAccess.interpolatedResultValue( "ST", nativeKeys[i], RigFemResultPosEnum::RIG_ELEMENT_NODAL, position, 0 ); + dataAccess.interpolatedResultValue( "ST", nativeKeys[i], RigFemResultPosEnum::RIG_ELEMENT_NODAL, position, 0, 0 ); if ( std::isfinite( stressValue ) ) { initialStress->addParameter( paramKeys[i], stressValue * 100000.0 ); @@ -484,7 +484,7 @@ bool RimWellIASettings::updateResInsightParameters() } } - double ppValue = dataAccess.interpolatedResultValue( "POR-Bar", "", RigFemResultPosEnum::RIG_NODAL, position, 0 ); + double ppValue = dataAccess.interpolatedResultValue( "POR-Bar", "", RigFemResultPosEnum::RIG_NODAL, position, 0, 0 ); if ( std::isfinite( ppValue ) ) { initialStress->addParameter( "PP", ppValue * 100000.0 ); @@ -673,9 +673,13 @@ std::vector RimWellIASettings::extractDisplacements( std::vector* mds, std::vector* tvds, std::vector* values, @@ -89,11 +90,13 @@ void RigGeoMechWellLogExtractor::performCurveDataSmoothing( int RigFemResultAddress shAddr( RIG_ELEMENT_NODAL, "ST", "S3" ); RigFemResultAddress porBarResAddr( RIG_ELEMENT_NODAL, "POR-Bar", "" ); - const std::vector& unscaledShValues = resultCollection->resultValues( shAddr, 0, frameIndex ); - const std::vector& porePressures = resultCollection->resultValues( porBarResAddr, 0, frameIndex ); + const std::vector& unscaledShValues = resultCollection->resultValues( shAddr, 0, timeStepIndex, frameIndex ); + const std::vector& porePressures = resultCollection->resultValues( porBarResAddr, 0, timeStepIndex, frameIndex ); - std::vector interfaceShValues = interpolateInterfaceValues( shAddr, frameIndex, unscaledShValues ); - std::vector interfacePorePressures = interpolateInterfaceValues( porBarResAddr, frameIndex, porePressures ); + std::vector interfaceShValues = + interpolateInterfaceValues( shAddr, timeStepIndex, frameIndex, unscaledShValues ); + std::vector interfacePorePressures = + interpolateInterfaceValues( porBarResAddr, timeStepIndex, frameIndex, porePressures ); std::vector interfaceShValuesDbl( interfaceShValues.size(), std::numeric_limits::infinity() ); std::vector interfacePorePressuresDbl( interfacePorePressures.size(), std::numeric_limits::infinity() ); @@ -116,7 +119,10 @@ void RigGeoMechWellLogExtractor::performCurveDataSmoothing( int //-------------------------------------------------------------------------------------------------- /// Get curve data for a given parameter. Returns the output units of the data. //-------------------------------------------------------------------------------------------------- -QString RigGeoMechWellLogExtractor::curveData( const RigFemResultAddress& resAddr, int frameIndex, std::vector* values ) +QString RigGeoMechWellLogExtractor::curveData( const RigFemResultAddress& resAddr, + int timeStepIndex, + int frameIndex, + std::vector* values ) { CVF_TIGHT_ASSERT( values ); @@ -138,20 +144,20 @@ QString RigGeoMechWellLogExtractor::curveData( const RigFemResultAddress& resAdd if ( resAddr.fieldName == RiaResultNames::wbsFGResult().toStdString() ) { - wellBoreWallCurveData( resAddr, frameIndex, values ); + wellBoreWallCurveData( resAddr, timeStepIndex, frameIndex, values ); // Try to replace invalid values with Shale-values - wellBoreFGShale( frameIndex, values ); + wellBoreFGShale( timeStepIndex, frameIndex, values ); values->front() = wbsCurveValuesAtMsl(); } else if ( resAddr.fieldName == RiaResultNames::wbsSFGResult().toStdString() ) { - wellBoreWallCurveData( resAddr, frameIndex, values ); + wellBoreWallCurveData( resAddr, timeStepIndex, frameIndex, values ); } else if ( resAddr.fieldName == RiaResultNames::wbsPPResult().toStdString() || resAddr.fieldName == RiaResultNames::wbsOBGResult().toStdString() || resAddr.fieldName == RiaResultNames::wbsSHResult().toStdString() ) { - wellPathScaledCurveData( resAddr, frameIndex, values ); + wellPathScaledCurveData( resAddr, timeStepIndex, frameIndex, values ); values->front() = wbsCurveValuesAtMsl(); } else if ( resAddr.fieldName == RiaResultNames::wbsAzimuthResult().toStdString() || @@ -161,7 +167,7 @@ QString RigGeoMechWellLogExtractor::curveData( const RigFemResultAddress& resAdd } else if ( resAddr.fieldName == RiaResultNames::wbsSHMkResult().toStdString() ) { - wellBoreSH_MatthewsKelly( frameIndex, values ); + wellBoreSH_MatthewsKelly( timeStepIndex, frameIndex, values ); values->front() = wbsCurveValuesAtMsl(); } else @@ -172,7 +178,7 @@ QString RigGeoMechWellLogExtractor::curveData( const RigFemResultAddress& resAdd { if ( param == RigWbsParameter::FG_Shale() ) { - wellBoreFGShale( frameIndex, values ); + wellBoreFGShale( timeStepIndex, frameIndex, values ); } else { @@ -180,7 +186,7 @@ QString RigGeoMechWellLogExtractor::curveData( const RigFemResultAddress& resAdd { frameIndex = 0; } - calculateWbsParameterForAllSegments( param, frameIndex, values, true ); + calculateWbsParameterForAllSegments( param, timeStepIndex, frameIndex, values, true ); if ( param == RigWbsParameter::UCS() ) // UCS is reported as UCS/100 { for ( double& value : *values ) @@ -209,11 +215,13 @@ QString RigGeoMechWellLogExtractor::curveData( const RigFemResultAddress& resAdd CVF_ASSERT( resAddr.resultPosType != RIG_WELLPATH_DERIVED ); - const std::vector& resultValues = m_caseData->femPartResults()->resultValues( convResAddr, 0, frameIndex ); + const std::vector& resultValues = + m_caseData->femPartResults()->resultValues( convResAddr, 0, timeStepIndex, frameIndex ); if ( !resultValues.empty() ) { - std::vector interfaceValues = interpolateInterfaceValues( convResAddr, frameIndex, resultValues ); + std::vector interfaceValues = + interpolateInterfaceValues( convResAddr, timeStepIndex, frameIndex, resultValues ); values->resize( interfaceValues.size(), std::numeric_limits::infinity() ); @@ -233,6 +241,7 @@ QString RigGeoMechWellLogExtractor::curveData( const RigFemResultAddress& resAdd std::vector RigGeoMechWellLogExtractor::calculateWbsParameterForAllSegments( const RigWbsParameter& parameter, WbsParameterSource primarySource, + int timeStepIndex, int frameIndex, std::vector* outputValues, bool allowNormalization ) @@ -259,9 +268,10 @@ std::vector { RigFemResultAddress nativeAddr = parameter.femAddress( RigWbsParameter::GRID ); - const std::vector& unscaledResultValues = resultCollection->resultValues( nativeAddr, 0, frameIndex ); - std::vector interpolatedInterfaceValues = - interpolateInterfaceValues( nativeAddr, frameIndex, unscaledResultValues ); + const std::vector& unscaledResultValues = + resultCollection->resultValues( nativeAddr, 0, timeStepIndex, frameIndex ); + std::vector interpolatedInterfaceValues = + interpolateInterfaceValues( nativeAddr, timeStepIndex, frameIndex, unscaledResultValues ); gridValues.resize( m_intersections.size(), std::numeric_limits::infinity() ); #pragma omp parallel for @@ -290,7 +300,8 @@ std::vector tvdRKBs.push_back( tvdValue + m_wellPathGeometry->rkbDiff() ); } RigFemResultAddress elementPropertyAddr = parameter.femAddress( RigWbsParameter::ELEMENT_PROPERTY_TABLE ); - elementPropertyValuesInput = &( resultCollection->resultValues( elementPropertyAddr, 0, frameIndex ) ); + elementPropertyValuesInput = + &( resultCollection->resultValues( elementPropertyAddr, 0, timeStepIndex, frameIndex ) ); if ( elementPropertyValuesInput ) { RiaWellLogUnitTools::convertValues( tvdRKBs, @@ -403,12 +414,14 @@ std::vector //-------------------------------------------------------------------------------------------------- std::vector RigGeoMechWellLogExtractor::calculateWbsParameterForAllSegments( const RigWbsParameter& parameter, + int timeStepIndex, int frameIndex, std::vector* outputValues, bool allowNormalization ) { return calculateWbsParameterForAllSegments( parameter, m_parameterSources.at( parameter ), + timeStepIndex, frameIndex, outputValues, allowNormalization ); @@ -419,6 +432,7 @@ std::vector //-------------------------------------------------------------------------------------------------- std::vector RigGeoMechWellLogExtractor::calculateWbsParametersForAllSegments( const RigFemResultAddress& resAddr, + int timeStepIndex, int frameIndex, std::vector* values, bool allowNormalization ) @@ -431,7 +445,7 @@ std::vector CVF_ASSERT( false && "wbsParameters() called on something that isn't a wbs parameter" ); } - return calculateWbsParameterForAllSegments( param, m_userDefinedValues.at( param ), values, allowNormalization ); + return calculateWbsParameterForAllSegments( param, m_userDefinedValues.at( param ), frameIndex, values, allowNormalization ); } //-------------------------------------------------------------------------------------------------- @@ -503,6 +517,7 @@ void RigGeoMechWellLogExtractor::wellPathAngles( const RigFemResultAddress& resA //-------------------------------------------------------------------------------------------------- std::vector RigGeoMechWellLogExtractor::wellPathScaledCurveData( const RigFemResultAddress& resAddr, + int timeStepIndex, int frameIndex, std::vector* values, bool forceGridSourceForPPReservoir /*=false*/ ) @@ -529,12 +544,15 @@ std::vector } else { - ppSandSources = - calculateWbsParameterForAllSegments( RigWbsParameter::PP_Reservoir(), frameIndex, &ppSandValues, true ); + ppSandSources = calculateWbsParameterForAllSegments( RigWbsParameter::PP_Reservoir(), + timeStepIndex, + frameIndex, + &ppSandValues, + true ); } std::vector ppShaleSources = - calculateWbsParameterForAllSegments( RigWbsParameter::PP_NonReservoir(), 0, &ppShaleValues, true ); + calculateWbsParameterForAllSegments( RigWbsParameter::PP_NonReservoir(), 0, 0, &ppShaleValues, true ); #pragma omp parallel for for ( int64_t intersectionIdx = 0; intersectionIdx < (int64_t)m_intersections.size(); ++intersectionIdx ) @@ -561,11 +579,11 @@ std::vector } else if ( resAddr.fieldName == RiaResultNames::wbsOBGResult().toStdString() ) { - sources = calculateWbsParameterForAllSegments( RigWbsParameter::OBG(), frameIndex, values, true ); + sources = calculateWbsParameterForAllSegments( RigWbsParameter::OBG(), timeStepIndex, frameIndex, values, true ); } else { - sources = calculateWbsParameterForAllSegments( RigWbsParameter::SH(), frameIndex, values, true ); + sources = calculateWbsParameterForAllSegments( RigWbsParameter::SH(), timeStepIndex, frameIndex, values, true ); } return sources; @@ -575,6 +593,7 @@ std::vector /// //-------------------------------------------------------------------------------------------------- void RigGeoMechWellLogExtractor::wellBoreWallCurveData( const RigFemResultAddress& resAddr, + int timeStepIndex, int frameIndex, std::vector* values ) { @@ -589,7 +608,7 @@ void RigGeoMechWellLogExtractor::wellBoreWallCurveData( const RigFemResultAddres RigFemPartResultsCollection* resultCollection = m_caseData->femPartResults(); // Load results - std::vector vertexStressesFloat = resultCollection->tensors( stressResAddr, 0, frameIndex ); + std::vector vertexStressesFloat = resultCollection->tensors( stressResAddr, 0, timeStepIndex, frameIndex ); if ( !vertexStressesFloat.size() ) return; std::vector vertexStresses; @@ -600,7 +619,7 @@ void RigGeoMechWellLogExtractor::wellBoreWallCurveData( const RigFemResultAddres } std::vector interpolatedInterfaceStressBar = - interpolateInterfaceValues( stressResAddr, frameIndex, vertexStresses ); + interpolateInterfaceValues( stressResAddr, timeStepIndex, frameIndex, vertexStresses ); values->resize( m_intersections.size(), std::numeric_limits::infinity() ); @@ -612,10 +631,10 @@ void RigGeoMechWellLogExtractor::wellBoreWallCurveData( const RigFemResultAddres false ); std::vector poissonAllSegments( m_intersections.size(), std::numeric_limits::infinity() ); - calculateWbsParameterForAllSegments( RigWbsParameter::poissonRatio(), frameIndex, &poissonAllSegments, false ); + calculateWbsParameterForAllSegments( RigWbsParameter::poissonRatio(), timeStepIndex, frameIndex, &poissonAllSegments, false ); std::vector ucsAllSegments( m_intersections.size(), std::numeric_limits::infinity() ); - calculateWbsParameterForAllSegments( RigWbsParameter::UCS(), frameIndex, &ucsAllSegments, false ); + calculateWbsParameterForAllSegments( RigWbsParameter::UCS(), timeStepIndex, frameIndex, &ucsAllSegments, false ); #pragma omp parallel for for ( int64_t intersectionIdx = 0; intersectionIdx < (int64_t)m_intersections.size(); ++intersectionIdx ) @@ -675,7 +694,7 @@ void RigGeoMechWellLogExtractor::wellBoreWallCurveData( const RigFemResultAddres //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigGeoMechWellLogExtractor::wellBoreFGShale( int frameIndex, std::vector* values ) +void RigGeoMechWellLogExtractor::wellBoreFGShale( int timeStepIndex, int frameIndex, std::vector* values ) { if ( values->empty() ) values->resize( m_intersections.size(), std::numeric_limits::infinity() ); @@ -686,10 +705,10 @@ void RigGeoMechWellLogExtractor::wellBoreFGShale( int frameIndex, std::vector K0_FG, OBG0; // parameters RigFemResultAddress ppAddr( RIG_WELLPATH_DERIVED, RiaResultNames::wbsPPResult().toStdString(), "" ); - wellPathScaledCurveData( ppAddr, 0, &PP0, true ); + wellPathScaledCurveData( ppAddr, 0, 0, &PP0, true ); - calculateWbsParameterForAllSegments( RigWbsParameter::K0_FG(), frameIndex, &K0_FG, true ); - calculateWbsParameterForAllSegments( RigWbsParameter::OBG0(), 0, &OBG0, true ); + calculateWbsParameterForAllSegments( RigWbsParameter::K0_FG(), timeStepIndex, frameIndex, &K0_FG, true ); + calculateWbsParameterForAllSegments( RigWbsParameter::OBG0(), 0, 0, &OBG0, true ); #pragma omp parallel for for ( int64_t intersectionIdx = 0; intersectionIdx < (int64_t)m_intersections.size(); ++intersectionIdx ) @@ -708,7 +727,7 @@ void RigGeoMechWellLogExtractor::wellBoreFGShale( int frameIndex, std::vector SH; - calculateWbsParameterForAllSegments( RigWbsParameter::SH(), frameIndex, &SH, true ); + calculateWbsParameterForAllSegments( RigWbsParameter::SH(), timeStepIndex, frameIndex, &SH, true ); CVF_ASSERT( SH.size() == m_intersections.size() ); double multiplier = m_userDefinedValues.at( RigWbsParameter::FG_Shale() ); CVF_ASSERT( multiplier != std::numeric_limits::infinity() ); @@ -729,19 +748,19 @@ void RigGeoMechWellLogExtractor::wellBoreFGShale( int frameIndex, std::vector* values ) +void RigGeoMechWellLogExtractor::wellBoreSH_MatthewsKelly( int timeStepIndex, int frameIndex, std::vector* values ) { std::vector PP, PP0; // results std::vector K0_SH, OBG0, DF; // parameters RigFemResultAddress ppAddr( RIG_WELLPATH_DERIVED, RiaResultNames::wbsPPResult().toStdString(), "" ); - curveData( ppAddr, frameIndex, &PP ); - curveData( ppAddr, 0, &PP0 ); + curveData( ppAddr, timeStepIndex, frameIndex, &PP ); + curveData( ppAddr, 0, 0, &PP0 ); - calculateWbsParameterForAllSegments( RigWbsParameter::K0_SH(), frameIndex, &K0_SH, true ); - calculateWbsParameterForAllSegments( RigWbsParameter::OBG0(), 0, &OBG0, true ); - calculateWbsParameterForAllSegments( RigWbsParameter::DF(), frameIndex, &DF, true ); + calculateWbsParameterForAllSegments( RigWbsParameter::K0_SH(), timeStepIndex, frameIndex, &K0_SH, true ); + calculateWbsParameterForAllSegments( RigWbsParameter::OBG0(), 0, 0, &OBG0, true ); + calculateWbsParameterForAllSegments( RigWbsParameter::DF(), timeStepIndex, frameIndex, &DF, true ); values->resize( m_intersections.size(), std::numeric_limits::infinity() ); @@ -815,12 +834,12 @@ QString RigGeoMechWellLogExtractor::parameterInputUnits( const RigWbsParameter& //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RigGeoMechWellLogExtractor::porePressureSourceRegions( int frameIndex ) +std::vector RigGeoMechWellLogExtractor::porePressureSourceRegions( int timeStepIndex, int frameIndex ) { RigFemResultAddress ppResAddr( RIG_ELEMENT_NODAL, RiaResultNames::wbsPPResult().toStdString(), "" ); std::vector values; - std::vector sources = wellPathScaledCurveData( ppResAddr, frameIndex, &values ); + std::vector sources = wellPathScaledCurveData( ppResAddr, timeStepIndex, frameIndex, &values ); std::vector doubleSources( sources.size(), 0.0 ); #pragma omp parallel for @@ -833,11 +852,11 @@ std::vector RigGeoMechWellLogExtractor::porePressureSourceRegions( int f //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RigGeoMechWellLogExtractor::poissonSourceRegions( int frameIndex ) +std::vector RigGeoMechWellLogExtractor::poissonSourceRegions( int timeStepIndex, int frameIndex ) { std::vector outputValues; std::vector sources = - calculateWbsParameterForAllSegments( RigWbsParameter::poissonRatio(), frameIndex, &outputValues, false ); + calculateWbsParameterForAllSegments( RigWbsParameter::poissonRatio(), timeStepIndex, frameIndex, &outputValues, false ); std::vector doubleSources( sources.size(), 0.0 ); #pragma omp parallel for @@ -851,11 +870,11 @@ std::vector RigGeoMechWellLogExtractor::poissonSourceRegions( int frameI //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RigGeoMechWellLogExtractor::ucsSourceRegions( int frameIndex ) +std::vector RigGeoMechWellLogExtractor::ucsSourceRegions( int timeStepIndex, int frameIndex ) { std::vector outputValues; std::vector sources = - calculateWbsParameterForAllSegments( RigWbsParameter::UCS(), frameIndex, &outputValues, true ); + calculateWbsParameterForAllSegments( RigWbsParameter::UCS(), timeStepIndex, frameIndex, &outputValues, true ); std::vector doubleSources( sources.size(), 0.0 ); #pragma omp parallel for @@ -1251,6 +1270,7 @@ bool RigGeoMechWellLogExtractor::averageIntersectionValuesToSegmentValue( size_t //-------------------------------------------------------------------------------------------------- template std::vector RigGeoMechWellLogExtractor::interpolateInterfaceValues( RigFemResultAddress nativeAddr, + int timeStepIndex, int frameIndex, const std::vector& unscaledResultValues ) { diff --git a/ApplicationLibCode/ReservoirDataModel/RigGeoMechWellLogExtractor.h b/ApplicationLibCode/ReservoirDataModel/RigGeoMechWellLogExtractor.h index ae17e20a57..28d295596d 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigGeoMechWellLogExtractor.h +++ b/ApplicationLibCode/ReservoirDataModel/RigGeoMechWellLogExtractor.h @@ -61,13 +61,14 @@ public: gsl::not_null wellpath, const std::string& wellCaseErrorMsgName ); - void performCurveDataSmoothing( int frameIndex, + void performCurveDataSmoothing( int timeStepIndex, + int frameIndex, std::vector* mds, std::vector* tvds, std::vector* values, const double smoothingTreshold ); - QString curveData( const RigFemResultAddress& resAddr, int frameIndex, std::vector* values ); + QString curveData( const RigFemResultAddress& resAddr, int timeStepIndex, int frameIndex, std::vector* values ); const RigGeoMechCaseData* caseData(); void setWbsLasValues( const RigWbsParameter& parameter, const std::vector>& values ); @@ -76,9 +77,9 @@ public: static QString parameterInputUnits( const RigWbsParameter& parameter ); - std::vector porePressureSourceRegions( int frameIndex ); - std::vector poissonSourceRegions( int frameIndex ); - std::vector ucsSourceRegions( int frameIndex ); + std::vector porePressureSourceRegions( int timeStepIndex, int frameIndex ); + std::vector poissonSourceRegions( int timeStepIndex, int frameIndex ); + std::vector ucsSourceRegions( int timeStepIndex, int frameIndex ); static caf::Ten3d transformTensorToWellPathOrientation( const cvf::Vec3d& wellPathTangent, const caf::Ten3d& wellPathTensor ); @@ -98,27 +99,34 @@ private: std::vector calculateWbsParameterForAllSegments( const RigWbsParameter& parameter, WbsParameterSource primarySource, + int timeStepIndex, int frameIndex, std::vector* outputValues, bool allowNormalization ); std::vector calculateWbsParameterForAllSegments( const RigWbsParameter& parameter, + int timeStepIndex, int frameIndex, std::vector* outputValues, bool allowNormalization ); std::vector calculateWbsParametersForAllSegments( const RigFemResultAddress& resAddr, + int timeStepIndex, int frameIndex, std::vector* values, bool allowNormalization ); void wellPathAngles( const RigFemResultAddress& resAddr, std::vector* values ); std::vector wellPathScaledCurveData( const RigFemResultAddress& resAddr, + int timeStepIndex, int frameIndex, std::vector* values, bool forceGridSourceforPPReservoir = false ); - void wellBoreWallCurveData( const RigFemResultAddress& resAddr, int frameIndex, std::vector* values ); + void wellBoreWallCurveData( const RigFemResultAddress& resAddr, + int timeStepIndex, + int frameIndex, + std::vector* values ); - void wellBoreFGShale( int frameIndex, std::vector* values ); - void wellBoreSH_MatthewsKelly( int frameIndex, std::vector* values ); + void wellBoreFGShale( int timeStepIndex, int frameIndex, std::vector* values ); + void wellBoreSH_MatthewsKelly( int timeStepIndex, int frameIndex, std::vector* values ); template T interpolateGridResultValue( RigFemResultPosEnum resultPosType, @@ -144,6 +152,7 @@ private: template std::vector interpolateInterfaceValues( RigFemResultAddress nativeAddr, + int timeStepIndex, int frameIndex, const std::vector& unscaledResultValues ); diff --git a/ApplicationLibCode/UserInterface/Riu3dSelectionManager.cpp b/ApplicationLibCode/UserInterface/Riu3dSelectionManager.cpp index 6f19f93986..e94889208b 100644 --- a/ApplicationLibCode/UserInterface/Riu3dSelectionManager.cpp +++ b/ApplicationLibCode/UserInterface/Riu3dSelectionManager.cpp @@ -183,7 +183,8 @@ RiuEclipseSelectionItem::RiuEclipseSelectionItem( RimGridView* //-------------------------------------------------------------------------------------------------- RiuGeoMechSelectionItem::RiuGeoMechSelectionItem( RimGridView* view, RimGeoMechResultDefinition* resultDefinition, - size_t timestepIdx, + int timestepIdx, + int frameIdx, size_t gridIndex, size_t cellIndex, cvf::Color3f color, @@ -192,6 +193,7 @@ RiuGeoMechSelectionItem::RiuGeoMechSelectionItem( RimGridView* vi : m_view( view ) , m_resultDefinition( resultDefinition ) , m_timestepIdx( timestepIdx ) + , m_frameIdx( frameIdx ) , m_gridIndex( gridIndex ) , m_cellIndex( cellIndex ) , m_color( color ) @@ -206,7 +208,8 @@ RiuGeoMechSelectionItem::RiuGeoMechSelectionItem( RimGridView* vi //-------------------------------------------------------------------------------------------------- RiuGeoMechSelectionItem::RiuGeoMechSelectionItem( RimGridView* view, RimGeoMechResultDefinition* resultDefinition, - size_t timestepIdx, + int timestepIdx, + int frameIdx, size_t gridIndex, size_t cellIndex, cvf::Color3f color, @@ -216,6 +219,7 @@ RiuGeoMechSelectionItem::RiuGeoMechSelectionItem( RimGridView* : m_view( view ) , m_resultDefinition( resultDefinition ) , m_timestepIdx( timestepIdx ) + , m_frameIdx( frameIdx ) , m_gridIndex( gridIndex ) , m_cellIndex( cellIndex ) , m_color( color ) diff --git a/ApplicationLibCode/UserInterface/Riu3dSelectionManager.h b/ApplicationLibCode/UserInterface/Riu3dSelectionManager.h index 96dfc44fc9..0ad1924443 100644 --- a/ApplicationLibCode/UserInterface/Riu3dSelectionManager.h +++ b/ApplicationLibCode/UserInterface/Riu3dSelectionManager.h @@ -174,7 +174,8 @@ class RiuGeoMechSelectionItem : public RiuSelectionItem public: explicit RiuGeoMechSelectionItem( RimGridView* view, RimGeoMechResultDefinition* resultDefinition, - size_t timestepIdx, + int timestepIdx, + int frameIdx, size_t gridIndex, size_t cellIndex, cvf::Color3f color, @@ -183,7 +184,8 @@ public: explicit RiuGeoMechSelectionItem( RimGridView* view, RimGeoMechResultDefinition* resultDefinition, - size_t timestepIdx, + int timestepIdx, + int frameIdx, size_t gridIndex, size_t cellIndex, cvf::Color3f color, @@ -197,7 +199,8 @@ public: public: caf::PdmPointer m_view; caf::PdmPointer m_resultDefinition; - size_t m_timestepIdx; + int m_timestepIdx; + int m_frameIdx; size_t m_gridIndex; size_t m_cellIndex; cvf::Color3f m_color; diff --git a/ApplicationLibCode/UserInterface/RiuCellAndNncPickEventHandler.cpp b/ApplicationLibCode/UserInterface/RiuCellAndNncPickEventHandler.cpp index 8e564ce488..06c5e7974a 100644 --- a/ApplicationLibCode/UserInterface/RiuCellAndNncPickEventHandler.cpp +++ b/ApplicationLibCode/UserInterface/RiuCellAndNncPickEventHandler.cpp @@ -26,6 +26,7 @@ #include "RimEclipseCellColors.h" #include "RimEclipseView.h" #include "RimExtrudedCurveIntersection.h" +#include "RimGeoMechCase.h" #include "RimGeoMechCellColors.h" #include "RimGeoMechView.h" #include "RimIntersectionResultDefinition.h" @@ -42,6 +43,8 @@ #include "RivSourceInfo.h" #include "RigEclipseCaseData.h" +#include "RigFemPartResultsCollection.h" +#include "RigGeoMechCaseData.h" #include "RigMainGrid.h" #include "RigNNCData.h" @@ -133,7 +136,9 @@ bool RiuCellAndNncPickEventHandler::handle3dPickEvent( const Ric3dPickEvent& eve RimGeoMechResultDefinition* geomResDef = nullptr; RimEclipseResultDefinition* eclResDef = nullptr; size_t timestepIndex = cvf::UNDEFINED_SIZE_T; - RimIntersectionResultDefinition* sepInterResDef = nullptr; + int dataFrameIndex = -2; // needs to be less than -1, as -1 means last step + + RimIntersectionResultDefinition* sepInterResDef = nullptr; // clang-format off if ( const RivSourceInfo* rivSourceInfo = dynamic_cast( firstHitPart->sourceInfo() ) ) @@ -199,14 +204,23 @@ bool RiuCellAndNncPickEventHandler::handle3dPickEvent( const Ric3dPickEvent& eve { if ( sepInterResDef->isEclipseResultDefinition() ) { - eclResDef = sepInterResDef->eclipseResultDefinition(); + eclResDef = sepInterResDef->eclipseResultDefinition(); + timestepIndex = sepInterResDef->timeStep(); } else { + RimGeoMechView* geomView = dynamic_cast( mainOrComparisonView ); + if ( geomView ) + { + if ( geomView->geoMechCase() && geomView->geoMechCase()->geoMechData() ) + { + std::tie( timestepIndex, dataFrameIndex ) = + geomView->geoMechCase()->geoMechData()->femPartResults()->stepListIndexToTimeStepAndDataFrameIndex( + sepInterResDef->timeStep() ); + } + } geomResDef = sepInterResDef->geoMechResultDefinition(); } - - timestepIndex = sepInterResDef->timeStep(); } if ( gridLocalCellIndex == cvf::UNDEFINED_SIZE_T ) @@ -286,7 +300,11 @@ bool RiuCellAndNncPickEventHandler::handle3dPickEvent( const Ric3dPickEvent& eve if ( geomView ) { if ( !geomResDef ) geomResDef = geomView->cellResult(); - if ( timestepIndex == cvf::UNDEFINED_SIZE_T ) timestepIndex = geomView->currentTimeStep(); + + auto [stepIdx, frameIdx] = geomView->currentStepAndDataFrame(); + + if ( timestepIndex == cvf::UNDEFINED_SIZE_T ) timestepIndex = stepIdx; + if ( dataFrameIndex < -1 ) dataFrameIndex = frameIdx; } } @@ -370,6 +388,7 @@ bool RiuCellAndNncPickEventHandler::handle3dPickEvent( const Ric3dPickEvent& eve selItem = new RiuGeoMechSelectionItem( associatedGridView, geomResDef, timestepIndex, + dataFrameIndex, gridIndex, gridLocalCellIndex, curveColor, @@ -380,6 +399,7 @@ bool RiuCellAndNncPickEventHandler::handle3dPickEvent( const Ric3dPickEvent& eve selItem = new RiuGeoMechSelectionItem( associatedGridView, geomResDef, timestepIndex, + dataFrameIndex, gridIndex, gridLocalCellIndex, curveColor, diff --git a/ApplicationLibCode/UserInterface/RiuFemResultTextBuilder.cpp b/ApplicationLibCode/UserInterface/RiuFemResultTextBuilder.cpp index 7175cd94b3..aaa20662aa 100644 --- a/ApplicationLibCode/UserInterface/RiuFemResultTextBuilder.cpp +++ b/ApplicationLibCode/UserInterface/RiuFemResultTextBuilder.cpp @@ -46,7 +46,8 @@ RiuFemResultTextBuilder::RiuFemResultTextBuilder( RimGridView* di RimGeoMechResultDefinition* geomResDef, int gridIndex, int cellIndex, - int timeStepIndex ) + int timeStepIndex, + int frameIndex ) : m_isIntersectionTriangleSet( false ) { m_displayCoordView = displayCoordView; @@ -54,6 +55,7 @@ RiuFemResultTextBuilder::RiuFemResultTextBuilder( RimGridView* di m_gridIndex = gridIndex; m_cellIndex = cellIndex; m_timeStepIndex = timeStepIndex; + m_frameIndex = frameIndex; m_intersectionPointInDisplay = cvf::Vec3d::UNDEFINED; m_face = cvf::StructGridInterface::NO_FACE; @@ -198,7 +200,13 @@ QString RiuFemResultTextBuilder::gridResultDetails() { RigGeoMechCaseData* eclipseCaseData = m_geomResDef->geoMechCase()->geoMechData(); - this->appendTextFromResultColors( eclipseCaseData, m_gridIndex, m_cellIndex, m_timeStepIndex, m_geomResDef, &text ); + this->appendTextFromResultColors( eclipseCaseData, + m_gridIndex, + m_cellIndex, + m_timeStepIndex, + m_frameIndex, + m_geomResDef, + &text ); if ( !text.isEmpty() ) { @@ -261,6 +269,7 @@ void RiuFemResultTextBuilder::appendTextFromResultColors( RigGeoMechCaseData* int gridIndex, int cellIndex, int timeStepIndex, + int frameIndex, RimGeoMechResultDefinition* resultDefinition, QString* resultInfoText ) { @@ -272,7 +281,7 @@ void RiuFemResultTextBuilder::appendTextFromResultColors( RigGeoMechCaseData* if ( resultDefinition->hasResult() ) { const std::vector& scalarResults = - geomData->femPartResults()->resultValues( resultDefinition->resultAddress(), gridIndex, timeStepIndex ); + geomData->femPartResults()->resultValues( resultDefinition->resultAddress(), gridIndex, timeStepIndex, frameIndex ); if ( scalarResults.size() ) { caf::AppEnum resPosAppEnum = resultDefinition->resultPositionType(); @@ -399,8 +408,10 @@ QString RiuFemResultTextBuilder::closestNodeResultText( RimGeoMechResultDefiniti RigGeoMechCaseData* geomData = m_geomResDef->geoMechCase()->geoMechData(); - const std::vector& scalarResults = - geomData->femPartResults()->resultValues( resultColors->resultAddress(), m_gridIndex, m_timeStepIndex ); + const std::vector& scalarResults = geomData->femPartResults()->resultValues( resultColors->resultAddress(), + m_gridIndex, + m_timeStepIndex, + m_frameIndex ); if ( scalarResults.size() && m_displayCoordView ) { @@ -441,7 +452,9 @@ QString RiuFemResultTextBuilder::closestNodeResultText( RimGeoMechResultDefiniti { RiuGeoMechXfTensorResultAccessor tensAccessor( geomData->femPartResults(), resultColors->resultAddress(), - m_timeStepIndex ); + m_gridIndex, + m_timeStepIndex, + m_frameIndex ); float tensValue = tensAccessor.calculateElmNodeValue( m_intersectionTriangle, closestElmNodResIdx ); text.append( QString( "Closest result: N[%1], in Element[%2] transformed onto intersection: %3 \n" ) diff --git a/ApplicationLibCode/UserInterface/RiuFemResultTextBuilder.h b/ApplicationLibCode/UserInterface/RiuFemResultTextBuilder.h index 1e5249449b..c19aaf4ce5 100644 --- a/ApplicationLibCode/UserInterface/RiuFemResultTextBuilder.h +++ b/ApplicationLibCode/UserInterface/RiuFemResultTextBuilder.h @@ -48,7 +48,8 @@ public: RimGeoMechResultDefinition* geomResDef, int gridIndex, int cellIndex, - int timeStepIndex ); + int timeStepIndex, + int frameIndex ); void setFace( int face ); void setIntersectionPointInDisplay( cvf::Vec3d intersectionPointInDisplay ); void setIntersectionTriangle( const std::array& triangle ); @@ -70,6 +71,7 @@ private: int gridIndex, int cellIndex, int timeStepIndex, + int frameIndex, RimGeoMechResultDefinition* resultDefinition, QString* resultInfoText ); @@ -81,6 +83,7 @@ private: int m_gridIndex; int m_cellIndex; int m_timeStepIndex; + int m_frameIndex; int m_face; bool m_isIntersectionTriangleSet; diff --git a/ApplicationLibCode/UserInterface/RiuFemTimeHistoryResultAccessor.cpp b/ApplicationLibCode/UserInterface/RiuFemTimeHistoryResultAccessor.cpp index 31188b51b6..da673d9051 100644 --- a/ApplicationLibCode/UserInterface/RiuFemTimeHistoryResultAccessor.cpp +++ b/ApplicationLibCode/UserInterface/RiuFemTimeHistoryResultAccessor.cpp @@ -156,28 +156,44 @@ void RiuFemTimeHistoryResultAccessor::computeTimeHistoryData() { int closestElmNodeResIndex = closestCalc.closestElementNodeResIdx(); - for ( int frameIdx = 0; frameIdx < femPartResultsColl->frameCount(); frameIdx++ ) + const int timeSteps = femPartResultsColl->timeStepCount(); + for ( int stepIdx = 0; stepIdx < timeSteps; stepIdx++ ) { - RiuGeoMechXfTensorResultAccessor stressXfAccessor( femPartResultsColl, *m_femResultAddress, frameIdx ); - float scalarValue = stressXfAccessor.calculateElmNodeValue( m_intersectionTriangle, closestElmNodeResIndex ); - m_timeHistoryValues.push_back( scalarValue ); + const int frameCount = femPartResultsColl->frameCount( stepIdx ); + for ( int frameIdx = 0; frameIdx < frameCount; frameIdx++ ) + { + RiuGeoMechXfTensorResultAccessor stressXfAccessor( femPartResultsColl, + *m_femResultAddress, + m_gridIndex, + stepIdx, + frameIdx ); + float scalarValue = + stressXfAccessor.calculateElmNodeValue( m_intersectionTriangle, closestElmNodeResIndex ); + m_timeHistoryValues.push_back( scalarValue ); + } } } else { if ( scalarResultIndex < 0 ) return; - for ( int frameIdx = 0; frameIdx < femPartResultsColl->frameCount(); frameIdx++ ) + const int timeSteps = femPartResultsColl->timeStepCount(); + for ( int stepIdx = 0; stepIdx < timeSteps; stepIdx++ ) { - const std::vector& scalarResults = - m_geoMechCaseData->femPartResults()->resultValues( *m_femResultAddress, - static_cast( m_gridIndex ), - frameIdx ); - if ( scalarResults.size() ) + const int frameCount = femPartResultsColl->frameCount( stepIdx ); + for ( int frameIdx = 0; frameIdx < frameCount; frameIdx++ ) { - float scalarValue = scalarResults[scalarResultIndex]; + const std::vector& scalarResults = + m_geoMechCaseData->femPartResults()->resultValues( *m_femResultAddress, + static_cast( m_gridIndex ), + stepIdx, + frameIdx ); + if ( scalarResults.size() ) + { + float scalarValue = scalarResults[scalarResultIndex]; - m_timeHistoryValues.push_back( scalarValue ); + m_timeHistoryValues.push_back( scalarValue ); + } } } } diff --git a/ApplicationLibCode/UserInterface/RiuGeoMechXfTensorResultAccessor.cpp b/ApplicationLibCode/UserInterface/RiuGeoMechXfTensorResultAccessor.cpp index 1cf7c0965b..590be99d74 100644 --- a/ApplicationLibCode/UserInterface/RiuGeoMechXfTensorResultAccessor.cpp +++ b/ApplicationLibCode/UserInterface/RiuGeoMechXfTensorResultAccessor.cpp @@ -93,23 +93,25 @@ float RiuGeoMechXfTensorResultAccessor::PCRIT( const caf::Ten3f& t ) const //-------------------------------------------------------------------------------------------------- RiuGeoMechXfTensorResultAccessor::RiuGeoMechXfTensorResultAccessor( RigFemPartResultsCollection* femResCollection, const RigFemResultAddress& resVarAddress, - int timeStepIdx ) + int partIdx, + int timeStepIdx, + int frameIdx ) { RigFemResultAddress tensComp = resVarAddress; tensComp.resultPosType = RIG_ELEMENT_NODAL; tensComp.componentName = "S11"; - tens11 = &femResCollection->resultValues( tensComp, 0, timeStepIdx ); + tens11 = &femResCollection->resultValues( tensComp, partIdx, timeStepIdx, frameIdx ); tensComp.componentName = "S22"; - tens22 = &femResCollection->resultValues( tensComp, 0, timeStepIdx ); + tens22 = &femResCollection->resultValues( tensComp, partIdx, timeStepIdx, frameIdx ); tensComp.componentName = "S33"; - tens33 = &femResCollection->resultValues( tensComp, 0, timeStepIdx ); + tens33 = &femResCollection->resultValues( tensComp, partIdx, timeStepIdx, frameIdx ); tensComp.componentName = "S12"; - tens12 = &femResCollection->resultValues( tensComp, 0, timeStepIdx ); + tens12 = &femResCollection->resultValues( tensComp, partIdx, timeStepIdx, frameIdx ); tensComp.componentName = "S23"; - tens23 = &femResCollection->resultValues( tensComp, 0, timeStepIdx ); + tens23 = &femResCollection->resultValues( tensComp, partIdx, timeStepIdx, frameIdx ); tensComp.componentName = "S13"; - tens13 = &femResCollection->resultValues( tensComp, 0, timeStepIdx ); + tens13 = &femResCollection->resultValues( tensComp, partIdx, timeStepIdx, frameIdx ); if ( resVarAddress.componentName == "SN" ) { diff --git a/ApplicationLibCode/UserInterface/RiuGeoMechXfTensorResultAccessor.h b/ApplicationLibCode/UserInterface/RiuGeoMechXfTensorResultAccessor.h index ec743dbab4..dd6ba19736 100644 --- a/ApplicationLibCode/UserInterface/RiuGeoMechXfTensorResultAccessor.h +++ b/ApplicationLibCode/UserInterface/RiuGeoMechXfTensorResultAccessor.h @@ -32,7 +32,9 @@ class RiuGeoMechXfTensorResultAccessor public: RiuGeoMechXfTensorResultAccessor( RigFemPartResultsCollection* femResCollection, const RigFemResultAddress& resVarAddress, - int timeStepIdx ); + int partIdx, + int timeStepIdx, + int frameIdx ); void calculateInterpolatedValue( const cvf::Vec3f triangle[3], const RivIntersectionVertexWeights vertexWeights[3], diff --git a/ApplicationLibCode/UserInterface/RiuMohrsCirclePlot.cpp b/ApplicationLibCode/UserInterface/RiuMohrsCirclePlot.cpp index 478fe7d705..7a6d6e566b 100644 --- a/ApplicationLibCode/UserInterface/RiuMohrsCirclePlot.cpp +++ b/ApplicationLibCode/UserInterface/RiuMohrsCirclePlot.cpp @@ -116,6 +116,7 @@ void RiuMohrsCirclePlot::appendSelection( const RiuSelectionItem* selectionItem addOrUpdateCurves( geoMechSelectionItem->m_resultDefinition, geoMechSelectionItem->m_timestepIdx, + geoMechSelectionItem->m_frameIdx, gridIndex, cellIndex, cvf::Color3ub( color ) ); @@ -164,13 +165,15 @@ void RiuMohrsCirclePlot::updateOnTimeStepChanged( Rim3dView* changedView ) std::vector mohrsCiclesInfosCopy = m_mohrsCiclesInfos; deletePlotItems(); + RimGeoMechView* geomechView = dynamic_cast( changedView ); + + if ( geomechView == nullptr ) return; + + auto [stepIdx, frameIdx] = geomechView->currentStepAndDataFrame(); + for ( const MohrsCirclesInfo& mohrInfo : mohrsCiclesInfosCopy ) { - addOrUpdateCurves( mohrInfo.geomResDef, - changedView->currentTimeStep(), - mohrInfo.gridIndex, - mohrInfo.elmIndex, - mohrInfo.color ); + addOrUpdateCurves( mohrInfo.geomResDef, stepIdx, frameIdx, mohrInfo.gridIndex, mohrInfo.elmIndex, mohrInfo.color ); } updatePlot(); @@ -356,7 +359,8 @@ void RiuMohrsCirclePlot::deleteEnvelopes() /// //-------------------------------------------------------------------------------------------------- bool RiuMohrsCirclePlot::addOrUpdateCurves( const RimGeoMechResultDefinition* geomResDef, - size_t timeStepIndex, + int timeStepIndex, + int frameIndex, size_t gridIndex, size_t elmIndex, const cvf::Color3ub& color ) @@ -371,7 +375,7 @@ bool RiuMohrsCirclePlot::addOrUpdateCurves( const RimGeoMechResultDefinition* ge // TODO: All tensors are calculated every time this function is called. FIX - std::vector vertexTensors = resultCollection->tensors( address, 0, (int)timeStepIndex ); + std::vector vertexTensors = resultCollection->tensors( address, 0, timeStepIndex, frameIndex ); if ( vertexTensors.empty() ) { return false; diff --git a/ApplicationLibCode/UserInterface/RiuMohrsCirclePlot.h b/ApplicationLibCode/UserInterface/RiuMohrsCirclePlot.h index f84f79acc1..8bb6aa64b7 100644 --- a/ApplicationLibCode/UserInterface/RiuMohrsCirclePlot.h +++ b/ApplicationLibCode/UserInterface/RiuMohrsCirclePlot.h @@ -100,7 +100,8 @@ private: void deleteEnvelopes(); bool addOrUpdateCurves( const RimGeoMechResultDefinition* geomResDef, - size_t timeStepIndex, + int timeStepIndex, + int frameIndex, size_t gridIndex, size_t elmIndex, const cvf::Color3ub& color ); diff --git a/ApplicationLibCode/UserInterface/RiuSelectionChangedHandler.cpp b/ApplicationLibCode/UserInterface/RiuSelectionChangedHandler.cpp index 5e99329fd4..b6761b9ad8 100644 --- a/ApplicationLibCode/UserInterface/RiuSelectionChangedHandler.cpp +++ b/ApplicationLibCode/UserInterface/RiuSelectionChangedHandler.cpp @@ -391,7 +391,8 @@ void RiuSelectionChangedHandler::updateResultInfo( const RiuSelectionItem* itemA geomSelectionItem->m_resultDefinition, (int)geomSelectionItem->m_gridIndex, (int)geomSelectionItem->m_cellIndex, - (int)geomSelectionItem->m_timestepIdx ); + (int)geomSelectionItem->m_timestepIdx, + geomSelectionItem->m_frameIdx ); textBuilder.setIntersectionPointInDisplay( geomSelectionItem->m_localIntersectionPointInDisplay ); textBuilder.setFace( geomSelectionItem->m_elementFace );