Geomech frames support (#9678)

Support for showing frames in geomech data.
This commit is contained in:
jonjenssen 2023-01-18 14:42:33 +01:00 committed by GitHub
parent 95202ad36a
commit 85f1b004cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
106 changed files with 2468 additions and 1948 deletions

View File

@ -40,7 +40,10 @@ void RigFemNativeStatCalc::minMaxCellScalarValues( size_t timeStepIndex, double&
{ {
for ( int pIdx = 0; pIdx < m_resultsData->partCount(); ++pIdx ) for ( int pIdx = 0; pIdx < m_resultsData->partCount(); ++pIdx )
{ {
const std::vector<float>& 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<float>& values = frames->frameData( stepIdx, frameIdx );
size_t i; size_t i;
for ( i = 0; i < values.size(); i++ ) for ( i = 0; i < values.size(); i++ )
@ -49,7 +52,6 @@ void RigFemNativeStatCalc::minMaxCellScalarValues( size_t timeStepIndex, double&
{ {
continue; continue;
} }
if ( values[i] < min ) if ( values[i] < min )
{ {
min = values[i]; min = values[i];
@ -70,7 +72,10 @@ void RigFemNativeStatCalc::posNegClosestToZero( size_t timeStepIndex, double& po
{ {
for ( int pIdx = 0; pIdx < m_resultsData->partCount(); ++pIdx ) for ( int pIdx = 0; pIdx < m_resultsData->partCount(); ++pIdx )
{ {
const std::vector<float>& 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<float>& values = frames->frameData( stepIdx, frameIdx );
for ( size_t i = 0; i < values.size(); i++ ) 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 ) void RigFemNativeStatCalc::valueSumAndSampleCount( size_t timeStepIndex, double& valueSum, size_t& sampleCount )
{ {
int tsIdx = static_cast<int>( timeStepIndex );
int partCount = m_resultsData->partCount(); int partCount = m_resultsData->partCount();
for ( int pIdx = 0; pIdx < partCount; ++pIdx ) for ( int pIdx = 0; pIdx < partCount; ++pIdx )
{ {
const std::vector<float>& 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<float>& values = frames->frameData( stepIdx, frameIdx );
size_t undefValueCount = 0; size_t undefValueCount = 0;
for ( size_t cIdx = 0; cIdx < values.size(); ++cIdx ) 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(); int partCount = m_resultsData->partCount();
for ( int pIdx = 0; pIdx < partCount; ++pIdx ) for ( int pIdx = 0; pIdx < partCount; ++pIdx )
{ {
const std::vector<float>& values = auto frames = m_resultsData->findOrLoadScalarResult( pIdx, m_resVarAddr );
m_resultsData->resultValues( m_resVarAddr, pIdx, static_cast<int>( timeStepIndex ) );
auto [stepIdx, frameIdx] = m_resultsData->stepListIndexToTimeStepAndDataFrameIndex( timeStepIndex );
const std::vector<float>& values = frames->frameData( stepIdx, frameIdx );
histogramCalculator.addData( values ); histogramCalculator.addData( values );
} }
@ -143,7 +152,10 @@ void RigFemNativeStatCalc::uniqueValues( size_t timeStepIndex, std::set<int>& va
{ {
for ( int pIdx = 0; pIdx < m_resultsData->partCount(); ++pIdx ) for ( int pIdx = 0; pIdx < m_resultsData->partCount(); ++pIdx )
{ {
const std::vector<float>& 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<float>& floatValues = frames->frameData( stepIdx, frameIdx );
for ( size_t i = 0; i < floatValues.size(); i++ ) for ( size_t i = 0; i < floatValues.size(); i++ )
{ {
@ -157,5 +169,5 @@ void RigFemNativeStatCalc::uniqueValues( size_t timeStepIndex, std::set<int>& va
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
size_t RigFemNativeStatCalc::timeStepCount() size_t RigFemNativeStatCalc::timeStepCount()
{ {
return m_resultsData->frameCount(); return m_resultsData->totalSteps();
} }

View File

@ -97,5 +97,5 @@ void RigFemNativeVisibleCellsStatCalc::uniqueValues( size_t timeStepIndex, std::
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
size_t RigFemNativeVisibleCellsStatCalc::timeStepCount() size_t RigFemNativeVisibleCellsStatCalc::timeStepCount()
{ {
return m_resultsData->frameCount(); return m_resultsData->totalSteps();
} }

View File

@ -57,18 +57,24 @@ private:
{ {
int partCount = m_caseData->femParts()->partCount(); 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 );
{ int elmCount = part->elementCount();
RigFemPart* part = m_caseData->femParts()->part( pIdx ); auto frames = m_resultsData->findOrLoadScalarResult( pIdx, m_resVarAddr );
const std::vector<float>& values = m_resultsData->resultValues( m_resVarAddr, pIdx, (int)timeStepIndex );
auto [stepIdx, frameIdx] = m_resultsData->stepListIndexToTimeStepAndDataFrameIndex( timeStepIndex );
const std::vector<float>& values = m_resultsData->resultValues( m_resVarAddr, pIdx, stepIdx, frameIdx );
if ( values.empty() ) continue;
if ( m_resVarAddr.resultPosType == RIG_NODAL )
{
size_t nodeCount = values.size(); size_t nodeCount = values.size();
cvf::UByteArray nodeVisibilities( nodeCount ); cvf::UByteArray nodeVisibilities( nodeCount );
nodeVisibilities.setAll( false ); nodeVisibilities.setAll( false );
int elmCount = part->elementCount();
for ( int elmIdx = 0; elmIdx < elmCount; ++elmIdx ) for ( int elmIdx = 0; elmIdx < elmCount; ++elmIdx )
{ {
if ( !( *m_cellVisibilities )[elmIdx] ) continue; 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<float>& 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 ) for ( int elmIdx = 0; elmIdx < elmCount; ++elmIdx )
{ {
if ( !( *m_cellVisibilities )[elmIdx] ) continue; if ( !( *m_cellVisibilities )[elmIdx] ) continue;
@ -106,17 +106,9 @@ private:
accumulator.addValue( values[elmIdx] ); accumulator.addValue( values[elmIdx] );
} }
} }
}
else else
{
for ( int pIdx = 0; pIdx < partCount; ++pIdx )
{ {
RigFemPart* part = m_caseData->femParts()->part( pIdx );
const std::vector<float>& values = m_resultsData->resultValues( m_resVarAddr, pIdx, (int)timeStepIndex );
int elmCount = part->elementCount();
if ( values.empty() ) continue;
for ( int elmIdx = 0; elmIdx < elmCount; ++elmIdx ) for ( int elmIdx = 0; elmIdx < elmCount; ++elmIdx )
{ {
if ( !( *m_cellVisibilities )[elmIdx] ) continue; if ( !( *m_cellVisibilities )[elmIdx] ) continue;

View File

@ -70,33 +70,36 @@ bool RigFemPartResultCalculatorBarConverted::isMatching( const RigFemResultAddre
RigFemScalarResultFrames* RigFemPartResultCalculatorBarConverted::calculate( int partIndex, RigFemScalarResultFrames* RigFemPartResultCalculatorBarConverted::calculate( int partIndex,
const RigFemResultAddress& resVarAddr ) const RigFemResultAddress& resVarAddr )
{ {
caf::ProgressInfo frameCountProgress( m_resultCollection->frameCount() * 2, "" ); caf::ProgressInfo stepCountProgress( m_resultCollection->timeStepCount() * 2, "" );
frameCountProgress.setProgressDescription( stepCountProgress.setProgressDescription(
"Calculating " + QString::fromStdString( resVarAddr.fieldName + ": " + resVarAddr.componentName ) ); "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 ); RigFemResultAddress unconvertedResultAddr( resVarAddr.resultPosType, m_fieldNameToConvert, resVarAddr.componentName );
RigFemScalarResultFrames* srcDataFrames = RigFemScalarResultFrames* srcDataFrames =
m_resultCollection->findOrLoadScalarResult( partIndex, unconvertedResultAddr ); m_resultCollection->findOrLoadScalarResult( partIndex, unconvertedResultAddr );
RigFemScalarResultFrames* dstDataFrames = m_resultCollection->createScalarResult( partIndex, resVarAddr ); RigFemScalarResultFrames* dstDataFrames = m_resultCollection->createScalarResult( partIndex, resVarAddr );
frameCountProgress.incrementProgress(); stepCountProgress.incrementProgress();
int frameCount = srcDataFrames->frameCount(); const int timeSteps = srcDataFrames->timeStepCount();
for ( int fIdx = 0; fIdx < frameCount; ++fIdx ) for ( int stepIdx = 0; stepIdx < timeSteps; stepIdx++ )
{ {
const std::vector<float>& srcFrameData = srcDataFrames->frameData( fIdx ); const int frameCount = srcDataFrames->frameCount( stepIdx );
std::vector<float>& dstFrameData = dstDataFrames->frameData( fIdx ); for ( int fIdx = 0; fIdx < frameCount; fIdx++ )
size_t valCount = srcFrameData.size(); {
dstFrameData.resize( valCount ); const std::vector<float>& srcFrameData = srcDataFrames->frameData( stepIdx, fIdx );
std::vector<float>& dstFrameData = dstDataFrames->frameData( stepIdx, fIdx );
size_t valCount = srcFrameData.size();
dstFrameData.resize( valCount );
#pragma omp parallel for #pragma omp parallel for
for ( long vIdx = 0; vIdx < static_cast<long>( valCount ); ++vIdx ) for ( long vIdx = 0; vIdx < static_cast<long>( valCount ); ++vIdx )
{ {
dstFrameData[vIdx] = 1.0e-5 * srcFrameData[vIdx]; dstFrameData[vIdx] = 1.0e-5 * srcFrameData[vIdx];
}
} }
stepCountProgress.incrementProgress();
frameCountProgress.incrementProgress();
} }
m_resultCollection->deleteResult( unconvertedResultAddr ); m_resultCollection->deleteResult( unconvertedResultAddr );
return dstDataFrames; return dstDataFrames;

View File

@ -80,72 +80,68 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorCompaction::calculate( int
{ {
CVF_ASSERT( resVarAddr.fieldName == RigFemPartResultsCollection::FIELD_NAME_COMPACTION ); CVF_ASSERT( resVarAddr.fieldName == RigFemPartResultsCollection::FIELD_NAME_COMPACTION );
caf::ProgressInfo frameCountProgress( m_resultCollection->frameCount() + 1, "" ); caf::ProgressInfo stepCountProgress( m_resultCollection->timeStepCount() + 1, "" );
frameCountProgress.setProgressDescription( "Calculating " + QString::fromStdString( resVarAddr.fieldName ) ); stepCountProgress.setProgressDescription( "Calculating " + QString::fromStdString( resVarAddr.fieldName ) );
RigFemScalarResultFrames* u3Frames = RigFemScalarResultFrames* u3Frames =
m_resultCollection->findOrLoadScalarResult( partIndex, RigFemResultAddress( resVarAddr.resultPosType, "U", "U3" ) ); m_resultCollection->findOrLoadScalarResult( partIndex, RigFemResultAddress( resVarAddr.resultPosType, "U", "U3" ) );
frameCountProgress.incrementProgress(); stepCountProgress.incrementProgress();
RigFemScalarResultFrames* compactionFrames = m_resultCollection->createScalarResult( partIndex, resVarAddr ); RigFemScalarResultFrames* compactionFrames = m_resultCollection->createScalarResult( partIndex, resVarAddr );
const RigFemPart* part = m_resultCollection->parts()->part( partIndex ); const RigFemPart* part = m_resultCollection->parts()->part( partIndex );
// Make sure AABB tree and struct grid is created
part->ensureIntersectionSearchTreeIsBuilt(); 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<float>& compactionFrame = compactionFrames->frameData( t ); const int frameCount = u3Frames->frameCount( stepIdx );
size_t nodeCount = part->nodes().nodeIds.size(); for ( int fIdx = 0; fIdx < frameCount; fIdx++ )
frameCountProgress.incrementProgress();
compactionFrame.resize( nodeCount );
{ {
// Make sure the AABB-tree is created before using OpenMP std::vector<float>& compactionFrame = compactionFrames->frameData( stepIdx, fIdx );
cvf::BoundingBox bb; size_t nodeCount = part->nodes().nodeIds.size();
std::vector<size_t> refElementCandidates;
part->findIntersectingCells( bb, &refElementCandidates ); compactionFrame.resize( nodeCount );
// Also make sure the struct grid is created, as this is required before using OpenMP
part->getOrCreateStructGrid();
}
#pragma omp parallel for #pragma omp parallel for
for ( long n = 0; n < static_cast<long>( nodeCount ); n++ ) for ( long n = 0; n < static_cast<long>( nodeCount ); n++ )
{
RefElement refElement;
findReferenceElementForNode( *part, n, resVarAddr.refKLayerIndex, &refElement );
if ( refElement.elementIdx != cvf::UNDEFINED_SIZE_T )
{ {
float shortestDist = std::numeric_limits<float>::infinity(); RefElement refElement;
size_t closestRefNodeIdx = cvf::UNDEFINED_SIZE_T; 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] ); float shortestDist = std::numeric_limits<float>::infinity();
if ( dist < shortestDist ) size_t closestRefNodeIdx = cvf::UNDEFINED_SIZE_T;
{
shortestDist = dist;
closestRefNodeIdx = nodeIdx;
}
}
cvf::Vec3f currentNodeCoord = part->nodes().coordinates[n]; for ( size_t nodeIdx : refElement.elementFaceNodeIdxs )
if ( currentNodeCoord.z() >= refElement.intersectionPoint.z() ) {
compactionFrame[n] = -( u3Frames->frameData( t )[n] - u3Frames->frameData( t )[closestRefNodeIdx] ); 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 else
compactionFrame[n] = -( u3Frames->frameData( t )[closestRefNodeIdx] - u3Frames->frameData( t )[n] ); {
} compactionFrame[n] = HUGE_VAL;
else }
{
compactionFrame[n] = HUGE_VAL;
} }
} }
stepCountProgress.incrementProgress();
} }
RigFemScalarResultFrames* requestedPrincipal = m_resultCollection->findOrLoadScalarResult( partIndex, resVarAddr ); RigFemScalarResultFrames* requestedPrincipal = m_resultCollection->findOrLoadScalarResult( partIndex, resVarAddr );
return requestedPrincipal; return requestedPrincipal;
} }

View File

@ -58,41 +58,45 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorDSM::calculate( int partInde
{ {
CVF_ASSERT( resVarAddr.fieldName == "SE" && resVarAddr.componentName == "DSM" ); CVF_ASSERT( resVarAddr.fieldName == "SE" && resVarAddr.componentName == "DSM" );
caf::ProgressInfo frameCountProgress( m_resultCollection->frameCount() * 3, "" ); caf::ProgressInfo stepCountProgress( m_resultCollection->timeStepCount() * 3, "" );
frameCountProgress.setProgressDescription( stepCountProgress.setProgressDescription(
"Calculating " + QString::fromStdString( resVarAddr.fieldName + ": " + resVarAddr.componentName ) ); "Calculating " + QString::fromStdString( resVarAddr.fieldName + ": " + resVarAddr.componentName ) );
frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() );
RigFemScalarResultFrames* se1Frames = RigFemScalarResultFrames* se1Frames =
m_resultCollection->findOrLoadScalarResult( partIndex, RigFemResultAddress( resVarAddr.resultPosType, "SE", "S1" ) ); m_resultCollection->findOrLoadScalarResult( partIndex, RigFemResultAddress( resVarAddr.resultPosType, "SE", "S1" ) );
frameCountProgress.incrementProgress(); stepCountProgress.incrementProgress();
frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() );
RigFemScalarResultFrames* se3Frames = RigFemScalarResultFrames* se3Frames =
m_resultCollection->findOrLoadScalarResult( partIndex, RigFemResultAddress( resVarAddr.resultPosType, "SE", "S3" ) ); m_resultCollection->findOrLoadScalarResult( partIndex, RigFemResultAddress( resVarAddr.resultPosType, "SE", "S3" ) );
RigFemScalarResultFrames* dstDataFrames = m_resultCollection->createScalarResult( partIndex, resVarAddr ); RigFemScalarResultFrames* dstDataFrames = m_resultCollection->createScalarResult( partIndex, resVarAddr );
frameCountProgress.incrementProgress(); stepCountProgress.incrementProgress();
float tanFricAng = tan( m_resultCollection->parameterFrictionAngleRad() ); float tanFricAng = tan( m_resultCollection->parameterFrictionAngleRad() );
float cohPrTanFricAngle = (float)( m_resultCollection->parameterCohesion() / tanFricAng ); float cohPrTanFricAngle = (float)( m_resultCollection->parameterCohesion() / tanFricAng );
int frameCount = se1Frames->frameCount();
for ( int fIdx = 0; fIdx < frameCount; ++fIdx )
{
const std::vector<float>& se1Data = se1Frames->frameData( fIdx );
const std::vector<float>& se3Data = se3Frames->frameData( fIdx );
std::vector<float>& dstFrameData = dstDataFrames->frameData( fIdx ); const int timeSteps = se1Frames->timeStepCount();
size_t valCount = se1Data.size(); for ( int stepIdx = 0; stepIdx < timeSteps; stepIdx++ )
dstFrameData.resize( valCount ); {
const int frameCount = se1Frames->frameCount( stepIdx );
for ( int fIdx = 0; fIdx < frameCount; fIdx++ )
{
const std::vector<float>& se1Data = se1Frames->frameData( stepIdx, fIdx );
const std::vector<float>& se3Data = se3Frames->frameData( stepIdx, fIdx );
std::vector<float>& dstFrameData = dstDataFrames->frameData( stepIdx, fIdx );
size_t valCount = se1Data.size();
dstFrameData.resize( valCount );
#pragma omp parallel for #pragma omp parallel for
for ( long vIdx = 0; vIdx < static_cast<long>( valCount ); ++vIdx ) for ( long vIdx = 0; vIdx < static_cast<long>( valCount ); ++vIdx )
{ {
dstFrameData[vIdx] = dsm( se1Data[vIdx], se3Data[vIdx], tanFricAng, cohPrTanFricAngle ); dstFrameData[vIdx] = dsm( se1Data[vIdx], se3Data[vIdx], tanFricAng, cohPrTanFricAngle );
}
} }
stepCountProgress.incrementProgress();
frameCountProgress.incrementProgress();
} }
return dstDataFrames; return dstDataFrames;

View File

@ -58,43 +58,46 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorED::calculate( int partIndex
{ {
CVF_ASSERT( resVarAddr.fieldName == "NE" && resVarAddr.componentName == "ED" ); CVF_ASSERT( resVarAddr.fieldName == "NE" && resVarAddr.componentName == "ED" );
caf::ProgressInfo frameCountProgress( m_resultCollection->frameCount() * 3, "" ); caf::ProgressInfo stepCountProgress( m_resultCollection->timeStepCount() * 3, "" );
frameCountProgress.setProgressDescription( stepCountProgress.setProgressDescription(
"Calculating " + QString::fromStdString( resVarAddr.fieldName + ": " + resVarAddr.componentName ) ); "Calculating " + QString::fromStdString( resVarAddr.fieldName + ": " + resVarAddr.componentName ) );
frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() );
RigFemScalarResultFrames* ea11 = nullptr; RigFemScalarResultFrames* ea11 = nullptr;
RigFemScalarResultFrames* ea33 = nullptr; RigFemScalarResultFrames* ea33 = nullptr;
{ {
ea11 = m_resultCollection->findOrLoadScalarResult( partIndex, ea11 = m_resultCollection->findOrLoadScalarResult( partIndex,
RigFemResultAddress( resVarAddr.resultPosType, "NE", "E1" ) ); RigFemResultAddress( resVarAddr.resultPosType, "NE", "E1" ) );
frameCountProgress.incrementProgress(); stepCountProgress.incrementProgress();
frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() );
ea33 = m_resultCollection->findOrLoadScalarResult( partIndex, ea33 = m_resultCollection->findOrLoadScalarResult( partIndex,
RigFemResultAddress( resVarAddr.resultPosType, "NE", "E3" ) ); RigFemResultAddress( resVarAddr.resultPosType, "NE", "E3" ) );
} }
RigFemScalarResultFrames* dstDataFrames = m_resultCollection->createScalarResult( partIndex, resVarAddr ); RigFemScalarResultFrames* dstDataFrames = m_resultCollection->createScalarResult( partIndex, resVarAddr );
frameCountProgress.incrementProgress(); stepCountProgress.incrementProgress();
int frameCount = ea11->frameCount(); const int timeSteps = ea11->timeStepCount();
for ( int fIdx = 0; fIdx < frameCount; ++fIdx ) for ( int stepIdx = 0; stepIdx < timeSteps; stepIdx++ )
{ {
const std::vector<float>& ea11Data = ea11->frameData( fIdx ); const int frameCount = ea11->frameCount( stepIdx );
const std::vector<float>& ea33Data = ea33->frameData( fIdx ); for ( int fIdx = 0; fIdx < frameCount; fIdx++ )
{
const std::vector<float>& ea11Data = ea11->frameData( stepIdx, fIdx );
const std::vector<float>& ea33Data = ea33->frameData( stepIdx, fIdx );
std::vector<float>& dstFrameData = dstDataFrames->frameData( fIdx ); std::vector<float>& dstFrameData = dstDataFrames->frameData( stepIdx, fIdx );
size_t valCount = ea11Data.size(); size_t valCount = ea11Data.size();
dstFrameData.resize( valCount ); dstFrameData.resize( valCount );
#pragma omp parallel for #pragma omp parallel for
for ( long vIdx = 0; vIdx < static_cast<long>( valCount ); ++vIdx ) for ( long vIdx = 0; vIdx < static_cast<long>( valCount ); ++vIdx )
{ {
dstFrameData[vIdx] = 0.666666666666667f * ( ea11Data[vIdx] - ea33Data[vIdx] ); dstFrameData[vIdx] = 0.666666666666667f * ( ea11Data[vIdx] - ea33Data[vIdx] );
}
} }
stepCountProgress.incrementProgress();
frameCountProgress.incrementProgress();
} }
return dstDataFrames; return dstDataFrames;

View File

@ -60,10 +60,10 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorEV::calculate( int partIndex
QString progressText = "Calculating " + QString::fromStdString( resAddr.fieldName + ": " + resAddr.componentName ); QString progressText = "Calculating " + QString::fromStdString( resAddr.fieldName + ": " + resAddr.componentName );
caf::ProgressInfo frameCountProgress( static_cast<size_t>( m_resultCollection->frameCount() ) * 4, progressText ); caf::ProgressInfo stepCountProgress( static_cast<size_t>( m_resultCollection->timeStepCount() ) * 4, progressText );
auto loadFrameLambda = [&]( const QString& component ) { 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() ) ); 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 ); RigFemScalarResultFrames* dstDataFrames = m_resultCollection->createScalarResult( partIndex, resAddr );
int frameCount = ea11->frameCount(); const int timeSteps = ea11->timeStepCount();
for ( int fIdx = 0; fIdx < frameCount; ++fIdx ) 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<float>& ea11Data = ea11->frameData( fIdx ); const int frameCount = ea11->frameCount( stepIdx );
const std::vector<float>& ea22Data = ea22->frameData( fIdx ); for ( int fIdx = 0; fIdx < frameCount; fIdx++ )
const std::vector<float>& ea33Data = ea33->frameData( fIdx ); {
const std::vector<float>& ea11Data = ea11->frameData( stepIdx, fIdx );
const std::vector<float>& ea22Data = ea22->frameData( stepIdx, fIdx );
const std::vector<float>& ea33Data = ea33->frameData( stepIdx, fIdx );
std::vector<float>& dstFrameData = dstDataFrames->frameData( fIdx ); std::vector<float>& dstFrameData = dstDataFrames->frameData( stepIdx, fIdx );
size_t valCount = ea11Data.size(); size_t valCount = ea11Data.size();
dstFrameData.resize( valCount ); dstFrameData.resize( valCount );
#pragma omp parallel for #pragma omp parallel for
for ( long vIdx = 0; vIdx < static_cast<long>( valCount ); ++vIdx ) for ( long vIdx = 0; vIdx < static_cast<long>( valCount ); ++vIdx )
{ {
dstFrameData[vIdx] = ( ea11Data[vIdx] + ea22Data[vIdx] + ea33Data[vIdx] ); dstFrameData[vIdx] = ( ea11Data[vIdx] + ea22Data[vIdx] + ea33Data[vIdx] );
}
} }
} }
return dstDataFrames; return dstDataFrames;
} }

View File

@ -57,52 +57,55 @@ bool RigFemPartResultCalculatorEnIpPorBar::isMatching( const RigFemResultAddress
RigFemScalarResultFrames* RigFemPartResultCalculatorEnIpPorBar::calculate( int partIndex, RigFemScalarResultFrames* RigFemPartResultCalculatorEnIpPorBar::calculate( int partIndex,
const RigFemResultAddress& resVarAddr ) const RigFemResultAddress& resVarAddr )
{ {
caf::ProgressInfo frameCountProgress( m_resultCollection->frameCount() * 2, "" ); caf::ProgressInfo stepCountProgress( m_resultCollection->timeStepCount() * 2, "" );
frameCountProgress.setProgressDescription( stepCountProgress.setProgressDescription(
"Calculating " + QString::fromStdString( resVarAddr.fieldName + ": " + resVarAddr.componentName ) ); "Calculating " + QString::fromStdString( resVarAddr.fieldName + ": " + resVarAddr.componentName ) );
frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() );
RigFemResultAddress unconvertedResultAddr( RIG_NODAL, "POR", "" ); RigFemResultAddress unconvertedResultAddr( RIG_NODAL, "POR", "" );
RigFemScalarResultFrames* srcDataFrames = RigFemScalarResultFrames* srcDataFrames =
m_resultCollection->findOrLoadScalarResult( partIndex, unconvertedResultAddr ); m_resultCollection->findOrLoadScalarResult( partIndex, unconvertedResultAddr );
RigFemScalarResultFrames* dstDataFrames = m_resultCollection->createScalarResult( partIndex, resVarAddr ); RigFemScalarResultFrames* dstDataFrames = m_resultCollection->createScalarResult( partIndex, resVarAddr );
frameCountProgress.incrementProgress(); stepCountProgress.incrementProgress();
const RigFemPart* femPart = m_resultCollection->parts()->part( partIndex ); const RigFemPart* femPart = m_resultCollection->parts()->part( partIndex );
float inf = std::numeric_limits<float>::infinity(); constexpr float inf = std::numeric_limits<float>::infinity();
int frameCount = srcDataFrames->frameCount(); const int timeSteps = srcDataFrames->timeStepCount();
for ( int fIdx = 0; fIdx < frameCount; ++fIdx ) for ( int stepIdx = 0; stepIdx < timeSteps; stepIdx++ )
{ {
const std::vector<float>& srcFrameData = srcDataFrames->frameData( fIdx ); const int frameCount = srcDataFrames->frameCount( stepIdx );
std::vector<float>& dstFrameData = dstDataFrames->frameData( fIdx ); for ( int fIdx = 0; fIdx < frameCount; fIdx++ )
{
const std::vector<float>& srcFrameData = srcDataFrames->frameData( stepIdx, fIdx );
std::vector<float>& 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(); size_t valCount = femPart->elementNodeResultCount();
dstFrameData.resize( valCount, inf ); dstFrameData.resize( valCount, inf );
int elementCount = femPart->elementCount(); int elementCount = femPart->elementCount();
#pragma omp parallel for schedule( dynamic ) #pragma omp parallel for schedule( dynamic )
for ( int elmIdx = 0; elmIdx < elementCount; ++elmIdx ) for ( int elmIdx = 0; elmIdx < elementCount; ++elmIdx )
{
RigElementType elmType = femPart->elementType( elmIdx );
if ( elmType == HEX8P )
{ {
int elmNodeCount = RigFemTypes::elementNodeCount( elmType ); RigElementType elmType = femPart->elementType( elmIdx );
for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx )
if ( elmType == HEX8P )
{ {
size_t elmNodResIdx = femPart->elementNodeResultIdx( elmIdx, elmNodIdx ); int elmNodeCount = RigFemTypes::elementNodeCount( elmType );
int nodeIdx = femPart->nodeIdxFromElementNodeResultIdx( elmNodResIdx ); for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx )
dstFrameData[elmNodResIdx] = 1.0e-5 * srcFrameData[nodeIdx]; {
size_t elmNodResIdx = femPart->elementNodeResultIdx( elmIdx, elmNodIdx );
int nodeIdx = femPart->nodeIdxFromElementNodeResultIdx( elmNodResIdx );
dstFrameData[elmNodResIdx] = 1.0e-5 * srcFrameData[nodeIdx];
}
} }
} }
} }
stepCountProgress.incrementProgress();
frameCountProgress.incrementProgress();
} }
m_resultCollection->deleteResult( unconvertedResultAddr ); m_resultCollection->deleteResult( unconvertedResultAddr );

View File

@ -58,10 +58,10 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorFOS::calculate( int partInde
{ {
CVF_ASSERT( resVarAddr.fieldName == "SE" && resVarAddr.componentName == "FOS" ); CVF_ASSERT( resVarAddr.fieldName == "SE" && resVarAddr.componentName == "FOS" );
caf::ProgressInfo frameCountProgress( m_resultCollection->frameCount() * 2, "" ); caf::ProgressInfo stepCountProgress( m_resultCollection->timeStepCount() * 2, "" );
frameCountProgress.setProgressDescription( stepCountProgress.setProgressDescription(
"Calculating " + QString::fromStdString( resVarAddr.fieldName + ": " + resVarAddr.componentName ) ); "Calculating " + QString::fromStdString( resVarAddr.fieldName + ": " + resVarAddr.componentName ) );
frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() );
RigFemScalarResultFrames* dsmFrames = RigFemScalarResultFrames* dsmFrames =
m_resultCollection->findOrLoadScalarResult( partIndex, m_resultCollection->findOrLoadScalarResult( partIndex,
@ -69,25 +69,28 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorFOS::calculate( int partInde
RigFemScalarResultFrames* dstDataFrames = m_resultCollection->createScalarResult( partIndex, resVarAddr ); RigFemScalarResultFrames* dstDataFrames = m_resultCollection->createScalarResult( partIndex, resVarAddr );
frameCountProgress.incrementProgress(); stepCountProgress.incrementProgress();
int frameCount = dsmFrames->frameCount(); const int timeSteps = dsmFrames->timeStepCount();
for ( int fIdx = 0; fIdx < frameCount; ++fIdx ) for ( int stepIdx = 0; stepIdx < timeSteps; stepIdx++ )
{ {
const std::vector<float>& dsmData = dsmFrames->frameData( fIdx ); const int frameCount = dsmFrames->frameCount( stepIdx );
for ( int fIdx = 0; fIdx < frameCount; fIdx++ )
{
const std::vector<float>& dsmData = dsmFrames->frameData( stepIdx, fIdx );
std::vector<float>& dstFrameData = dstDataFrames->frameData( fIdx ); std::vector<float>& dstFrameData = dstDataFrames->frameData( stepIdx, fIdx );
size_t valCount = dsmData.size(); size_t valCount = dsmData.size();
dstFrameData.resize( valCount ); dstFrameData.resize( valCount );
#pragma omp parallel for #pragma omp parallel for
for ( long vIdx = 0; vIdx < static_cast<long>( valCount ); ++vIdx ) for ( long vIdx = 0; vIdx < static_cast<long>( valCount ); ++vIdx )
{ {
float dsm = dsmData[vIdx]; float dsm = dsmData[vIdx];
dstFrameData[vIdx] = 1.0f / dsm; dstFrameData[vIdx] = 1.0f / dsm;
}
} }
stepCountProgress.incrementProgress();
frameCountProgress.incrementProgress();
} }
return dstDataFrames; return dstDataFrames;

View File

@ -59,23 +59,23 @@ bool RigFemPartResultCalculatorFormationIndices::isMatching( const RigFemResultA
RigFemScalarResultFrames* RigFemPartResultCalculatorFormationIndices::calculate( int partIndex, RigFemScalarResultFrames* RigFemPartResultCalculatorFormationIndices::calculate( int partIndex,
const RigFemResultAddress& resVarAddr ) const RigFemResultAddress& resVarAddr )
{ {
caf::ProgressInfo frameCountProgress( 2, "" ); caf::ProgressInfo stepCountProgress( 2, "" );
frameCountProgress.setProgressDescription( stepCountProgress.setProgressDescription(
"Calculating " + QString::fromStdString( resVarAddr.fieldName + ": " + resVarAddr.componentName ) ); "Calculating " + QString::fromStdString( resVarAddr.fieldName + ": " + resVarAddr.componentName ) );
RigFemScalarResultFrames* resFrames = m_resultCollection->createScalarResult( partIndex, resVarAddr ); RigFemScalarResultFrames* resFrames = m_resultCollection->createScalarResult( partIndex, resVarAddr );
resFrames->enableAsSingleFrameResult(); resFrames->enableAsSingleStepResult();
const RigFemPart* femPart = m_resultCollection->parts()->part( partIndex ); const RigFemPart* femPart = m_resultCollection->parts()->part( partIndex );
std::vector<float>& dstFrameData = resFrames->frameData( 0 ); std::vector<float>& dstFrameData = resFrames->frameData( 0, 0 );
size_t valCount = femPart->elementNodeResultCount(); size_t valCount = femPart->elementNodeResultCount();
float inf = std::numeric_limits<float>::infinity(); constexpr float inf = std::numeric_limits<float>::infinity();
dstFrameData.resize( valCount, inf ); dstFrameData.resize( valCount, inf );
const RigFormationNames* activeFormNames = m_resultCollection->activeFormationNames(); const RigFormationNames* activeFormNames = m_resultCollection->activeFormationNames();
frameCountProgress.incrementProgress(); stepCountProgress.incrementProgress();
if ( activeFormNames ) if ( activeFormNames )
{ {

View File

@ -59,10 +59,10 @@ bool RigFemPartResultCalculatorGamma::isMatching( const RigFemResultAddress& res
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RigFemScalarResultFrames* RigFemPartResultCalculatorGamma::calculate( int partIndex, const RigFemResultAddress& resVarAddr ) RigFemScalarResultFrames* RigFemPartResultCalculatorGamma::calculate( int partIndex, const RigFemResultAddress& resVarAddr )
{ {
caf::ProgressInfo frameCountProgress( m_resultCollection->frameCount() * 3, "" ); caf::ProgressInfo stepCountProgress( m_resultCollection->timeStepCount() * 3, "" );
frameCountProgress.setProgressDescription( stepCountProgress.setProgressDescription(
"Calculating " + QString::fromStdString( resVarAddr.fieldName + ": " + resVarAddr.componentName ) ); "Calculating " + QString::fromStdString( resVarAddr.fieldName + ": " + resVarAddr.componentName ) );
frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() );
RigFemResultAddress totStressCompAddr( resVarAddr.resultPosType, "ST", "" ); RigFemResultAddress totStressCompAddr( resVarAddr.resultPosType, "ST", "" );
{ {
@ -85,21 +85,21 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorGamma::calculate( int partIn
RigFemScalarResultFrames* srcDataFrames = m_resultCollection->findOrLoadScalarResult( partIndex, totStressCompAddr ); RigFemScalarResultFrames* srcDataFrames = m_resultCollection->findOrLoadScalarResult( partIndex, totStressCompAddr );
frameCountProgress.incrementProgress(); stepCountProgress.incrementProgress();
frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() );
RigFemScalarResultFrames* srcPORDataFrames = RigFemScalarResultFrames* srcPORDataFrames =
m_resultCollection->findOrLoadScalarResult( partIndex, RigFemResultAddress( RIG_NODAL, "POR-Bar", "" ) ); m_resultCollection->findOrLoadScalarResult( partIndex, RigFemResultAddress( RIG_NODAL, "POR-Bar", "" ) );
RigFemScalarResultFrames* dstDataFrames = m_resultCollection->createScalarResult( partIndex, resVarAddr ); RigFemScalarResultFrames* dstDataFrames = m_resultCollection->createScalarResult( partIndex, resVarAddr );
frameCountProgress.incrementProgress(); stepCountProgress.incrementProgress();
calculateGammaFromFrames( partIndex, calculateGammaFromFrames( partIndex,
m_resultCollection->parts(), m_resultCollection->parts(),
srcDataFrames, srcDataFrames,
srcPORDataFrames, srcPORDataFrames,
dstDataFrames, dstDataFrames,
&frameCountProgress ); &stepCountProgress );
return dstDataFrames; return dstDataFrames;
} }
@ -112,62 +112,65 @@ void RigFemPartResultCalculatorGamma::calculateGammaFromFrames( int
const RigFemScalarResultFrames* totalStressComponentDataFrames, const RigFemScalarResultFrames* totalStressComponentDataFrames,
const RigFemScalarResultFrames* srcPORDataFrames, const RigFemScalarResultFrames* srcPORDataFrames,
RigFemScalarResultFrames* dstDataFrames, RigFemScalarResultFrames* dstDataFrames,
caf::ProgressInfo* frameCountProgress ) caf::ProgressInfo* stepCountProgress )
{ {
const RigFemPart* femPart = femParts->part( partIndex ); const RigFemPart* femPart = femParts->part( partIndex );
int frameCount = totalStressComponentDataFrames->frameCount(); float inf = std::numeric_limits<float>::infinity();
float inf = std::numeric_limits<float>::infinity();
for ( int fIdx = 0; fIdx < frameCount; ++fIdx ) const int timeSteps = totalStressComponentDataFrames->timeStepCount();
for ( int stepIdx = 0; stepIdx < timeSteps; stepIdx++ )
{ {
const std::vector<float>& srcSTFrameData = totalStressComponentDataFrames->frameData( fIdx ); const int frameCount = totalStressComponentDataFrames->frameCount( stepIdx );
const std::vector<float>& srcPORFrameData = srcPORDataFrames->frameData( fIdx ); for ( int fIdx = 0; fIdx < frameCount; fIdx++ )
{
const std::vector<float>& srcSTFrameData = totalStressComponentDataFrames->frameData( stepIdx, fIdx );
const std::vector<float>& srcPORFrameData = srcPORDataFrames->frameData( stepIdx, fIdx );
std::vector<float>& dstFrameData = dstDataFrames->frameData( fIdx ); std::vector<float>& dstFrameData = dstDataFrames->frameData( stepIdx, fIdx );
size_t valCount = srcSTFrameData.size(); size_t valCount = srcSTFrameData.size();
dstFrameData.resize( valCount ); dstFrameData.resize( valCount );
int elementCount = femPart->elementCount(); int elementCount = femPart->elementCount();
#pragma omp parallel for #pragma omp parallel for
for ( int elmIdx = 0; elmIdx < elementCount; ++elmIdx ) for ( int elmIdx = 0; elmIdx < elementCount; ++elmIdx )
{
RigElementType elmType = femPart->elementType( elmIdx );
int elmNodeCount = RigFemTypes::elementNodeCount( femPart->elementType( elmIdx ) );
if ( elmType == HEX8P )
{ {
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 ); for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx )
if ( elmNodResIdx < srcSTFrameData.size() )
{ {
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 ) if ( por == inf || fabs( por ) < 0.01e6 * 1.0e-5 )
dstFrameData[elmNodResIdx] = inf; dstFrameData[elmNodResIdx] = inf;
else else
dstFrameData[elmNodResIdx] = srcSTFrameData[elmNodResIdx] / por; dstFrameData[elmNodResIdx] = srcSTFrameData[elmNodResIdx] / por;
}
} }
} }
} else
else
{
for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx )
{ {
size_t elmNodResIdx = femPart->elementNodeResultIdx( elmIdx, elmNodIdx ); for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx )
if ( elmNodResIdx < dstFrameData.size() )
{ {
dstFrameData[elmNodResIdx] = inf; size_t elmNodResIdx = femPart->elementNodeResultIdx( elmIdx, elmNodIdx );
if ( elmNodResIdx < dstFrameData.size() )
{
dstFrameData[elmNodResIdx] = inf;
}
} }
} }
} }
} }
stepCountProgress->incrementProgress();
frameCountProgress->incrementProgress();
} }
} }

View File

@ -46,5 +46,5 @@ public:
const RigFemScalarResultFrames* totalStressComponentDataFrames, const RigFemScalarResultFrames* totalStressComponentDataFrames,
const RigFemScalarResultFrames* srcPORDataFrames, const RigFemScalarResultFrames* srcPORDataFrames,
RigFemScalarResultFrames* dstDataFrames, RigFemScalarResultFrames* dstDataFrames,
caf::ProgressInfo* frameCountProgress ); caf::ProgressInfo* stepCountProgress );
}; };

View File

@ -57,10 +57,10 @@ bool RigFemPartResultCalculatorInitialPorosity::isMatching( const RigFemResultAd
RigFemScalarResultFrames* RigFemPartResultCalculatorInitialPorosity::calculate( int partIndex, RigFemScalarResultFrames* RigFemPartResultCalculatorInitialPorosity::calculate( int partIndex,
const RigFemResultAddress& resVarAddr ) const RigFemResultAddress& resVarAddr )
{ {
caf::ProgressInfo frameCountProgress( m_resultCollection->frameCount() * 2, "" ); caf::ProgressInfo stepCountProgress( m_resultCollection->timeStepCount() * 2, "" );
frameCountProgress.setProgressDescription( "Calculating Initial Porosity" ); stepCountProgress.setProgressDescription( "Calculating Initial Porosity" );
frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() );
RigFemScalarResultFrames* voidRatioFrames = RigFemScalarResultFrames* voidRatioFrames =
m_resultCollection->findOrLoadScalarResult( partIndex, m_resultCollection->findOrLoadScalarResult( partIndex,
@ -69,62 +69,65 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorInitialPorosity::calculate(
RigFemScalarResultFrames* porosityFrames = RigFemScalarResultFrames* porosityFrames =
m_resultCollection->createScalarResult( partIndex, m_resultCollection->createScalarResult( partIndex,
RigFemResultAddress( resVarAddr.resultPosType, resVarAddr.fieldName, "PHI0" ) ); RigFemResultAddress( resVarAddr.resultPosType, resVarAddr.fieldName, "PHI0" ) );
frameCountProgress.incrementProgress(); stepCountProgress.incrementProgress();
const RigFemPart* femPart = m_resultCollection->parts()->part( partIndex ); const RigFemPart* femPart = m_resultCollection->parts()->part( partIndex );
float inf = std::numeric_limits<float>::infinity(); float inf = std::numeric_limits<float>::infinity();
frameCountProgress.setNextProgressIncrement( 1u ); stepCountProgress.setNextProgressIncrement( 1u );
int frameCount = voidRatioFrames->frameCount(); const int timeSteps = voidRatioFrames->timeStepCount();
for ( int fIdx = 0; fIdx < frameCount; ++fIdx ) for ( int stepIdx = 0; stepIdx < timeSteps; stepIdx++ )
{ {
const std::vector<float>& voidRatioData = voidRatioFrames->frameData( 0 ); const int frameCount = voidRatioFrames->frameCount( stepIdx );
std::vector<float>& porosityFrameData = porosityFrames->frameData( fIdx ); for ( int fIdx = 0; fIdx < frameCount; fIdx++ )
{
const std::vector<float>& voidRatioData = voidRatioFrames->frameData( 0, 0 );
std::vector<float>& porosityFrameData = porosityFrames->frameData( stepIdx, fIdx );
size_t valCount = voidRatioData.size(); size_t valCount = voidRatioData.size();
porosityFrameData.resize( valCount ); porosityFrameData.resize( valCount );
int elementCount = femPart->elementCount(); int elementCount = femPart->elementCount();
#pragma omp parallel for #pragma omp parallel for
for ( int elmIdx = 0; elmIdx < elementCount; ++elmIdx ) for ( int elmIdx = 0; elmIdx < elementCount; ++elmIdx )
{
RigElementType elmType = femPart->elementType( elmIdx );
int elmNodeCount = RigFemTypes::elementNodeCount( femPart->elementType( elmIdx ) );
if ( elmType == HEX8P )
{ {
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 ); for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx )
if ( elmNodResIdx < voidRatioData.size() )
{ {
int nodeIdx = femPart->nodeIdxFromElementNodeResultIdx( elmNodResIdx ); size_t elmNodResIdx = femPart->elementNodeResultIdx( elmIdx, elmNodIdx );
if ( elmNodResIdx < voidRatioData.size() )
{
int nodeIdx = femPart->nodeIdxFromElementNodeResultIdx( elmNodResIdx );
// Calculate initial porosity // Calculate initial porosity
double voidr = voidRatioData[elmNodResIdx]; double voidr = voidRatioData[elmNodResIdx];
double initialPorosity = voidr / ( 1.0 + voidr ); double initialPorosity = voidr / ( 1.0 + voidr );
porosityFrameData[elmNodResIdx] = initialPorosity; porosityFrameData[elmNodResIdx] = initialPorosity;
}
} }
} }
} else
else
{
for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx )
{ {
size_t elmNodResIdx = femPart->elementNodeResultIdx( elmIdx, elmNodIdx ); for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx )
if ( elmNodResIdx < voidRatioData.size() )
{ {
porosityFrameData[elmNodResIdx] = inf; size_t elmNodResIdx = femPart->elementNodeResultIdx( elmIdx, elmNodIdx );
if ( elmNodResIdx < voidRatioData.size() )
{
porosityFrameData[elmNodResIdx] = inf;
}
} }
} }
} }
} }
stepCountProgress.incrementProgress();
frameCountProgress.incrementProgress();
} }
RigFemScalarResultFrames* requestedResultFrames = m_resultCollection->findOrLoadScalarResult( partIndex, resVarAddr ); RigFemScalarResultFrames* requestedResultFrames = m_resultCollection->findOrLoadScalarResult( partIndex, resVarAddr );

View File

@ -59,22 +59,22 @@ bool RigFemPartResultCalculatorKIndices::isMatching( const RigFemResultAddress&
RigFemScalarResultFrames* RigFemPartResultCalculatorKIndices::calculate( int partIndex, RigFemScalarResultFrames* RigFemPartResultCalculatorKIndices::calculate( int partIndex,
const RigFemResultAddress& resVarAddr ) const RigFemResultAddress& resVarAddr )
{ {
caf::ProgressInfo frameCountProgress( 2, "" ); caf::ProgressInfo stepCountProgress( 2, "" );
frameCountProgress.setProgressDescription( stepCountProgress.setProgressDescription(
"Calculating " + QString::fromStdString( resVarAddr.fieldName + ": " + resVarAddr.componentName ) ); "Calculating " + QString::fromStdString( resVarAddr.fieldName + ": " + resVarAddr.componentName ) );
RigFemScalarResultFrames* resFrames = m_resultCollection->createScalarResult( partIndex, resVarAddr ); RigFemScalarResultFrames* resFrames = m_resultCollection->createScalarResult( partIndex, resVarAddr );
resFrames->enableAsSingleFrameResult(); resFrames->enableAsSingleStepResult();
const RigFemPart* femPart = m_resultCollection->parts()->part( partIndex ); const RigFemPart* femPart = m_resultCollection->parts()->part( partIndex );
std::vector<float>& dstFrameData = resFrames->frameData( 0 ); std::vector<float>& dstFrameData = resFrames->frameData( 0, 0 );
const size_t valCount = femPart->elementNodeResultCount(); const size_t valCount = femPart->elementNodeResultCount();
dstFrameData.resize( valCount, std::numeric_limits<float>::infinity() ); dstFrameData.resize( valCount, std::numeric_limits<float>::infinity() );
const RigFormationNames* activeFormNames = m_resultCollection->activeFormationNames(); const RigFormationNames* activeFormNames = m_resultCollection->activeFormationNames();
frameCountProgress.incrementProgress(); stepCountProgress.incrementProgress();
if ( activeFormNames ) if ( activeFormNames )
{ {

View File

@ -77,8 +77,8 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorMudWeightWindow::calculate(
RimMudWeightWindowParameters::ParameterType::K0_FG, RimMudWeightWindowParameters::ParameterType::K0_FG,
RimMudWeightWindowParameters::ParameterType::OBG0 }; RimMudWeightWindowParameters::ParameterType::OBG0 };
caf::ProgressInfo frameCountProgress( m_resultCollection->frameCount() * ( 5 + parameterTypes.size() ), "" ); caf::ProgressInfo stepCountProgress( m_resultCollection->timeStepCount() * ( 5 + parameterTypes.size() ), "" );
frameCountProgress.setProgressDescription( "Calculating Mud Weight Window" ); stepCountProgress.setProgressDescription( "Calculating Mud Weight Window" );
std::map<RimMudWeightWindowParameters::ParameterType, RigFemScalarResultFrames*> parameterFrames; std::map<RimMudWeightWindowParameters::ParameterType, RigFemScalarResultFrames*> parameterFrames;
std::map<RimMudWeightWindowParameters::ParameterType, float> parameterValues; std::map<RimMudWeightWindowParameters::ParameterType, float> parameterValues;
@ -86,9 +86,9 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorMudWeightWindow::calculate(
for ( auto parameterType : parameterTypes ) for ( auto parameterType : parameterTypes )
{ {
auto task = auto task =
frameCountProgress.task( "Loading parameter: " + stepCountProgress.task( "Loading parameter: " +
caf::AppEnum<RimMudWeightWindowParameters::ParameterType>::uiText( parameterType ), caf::AppEnum<RimMudWeightWindowParameters::ParameterType>::uiText( parameterType ),
m_resultCollection->frameCount() ); m_resultCollection->timeStepCount() );
loadParameterFramesOrValue( parameterType, partIndex, parameterFrames, parameterValues ); loadParameterFramesOrValue( parameterType, partIndex, parameterFrames, parameterValues );
} }
@ -105,7 +105,7 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorMudWeightWindow::calculate(
// Pore pressure // Pore pressure
RigFemScalarResultFrames* porePressureDataFrames = nullptr; RigFemScalarResultFrames* porePressureDataFrames = nullptr;
{ {
auto task = frameCountProgress.task( "Loading POR-Bar.", m_resultCollection->frameCount() ); auto task = stepCountProgress.task( "Loading POR-Bar.", m_resultCollection->timeStepCount() );
porePressureDataFrames = porePressureDataFrames =
m_resultCollection->findOrLoadScalarResult( partIndex, RigFemResultAddress( RIG_ELEMENT_NODAL, "POR-Bar", "" ) ); m_resultCollection->findOrLoadScalarResult( partIndex, RigFemResultAddress( RIG_ELEMENT_NODAL, "POR-Bar", "" ) );
} }
@ -113,7 +113,7 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorMudWeightWindow::calculate(
// Stress (ST.S3) // Stress (ST.S3)
RigFemScalarResultFrames* stressDataFrames = nullptr; RigFemScalarResultFrames* stressDataFrames = nullptr;
{ {
auto task = frameCountProgress.task( "Loading ST.S3", m_resultCollection->frameCount() ); auto task = stepCountProgress.task( "Loading ST.S3", m_resultCollection->timeStepCount() );
stressDataFrames = stressDataFrames =
m_resultCollection->findOrLoadScalarResult( partIndex, m_resultCollection->findOrLoadScalarResult( partIndex,
RigFemResultAddress( resVarAddr.resultPosType, "ST", "S3" ) ); RigFemResultAddress( resVarAddr.resultPosType, "ST", "S3" ) );
@ -122,7 +122,7 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorMudWeightWindow::calculate(
// Initial overburden gradient (ST.S33) // Initial overburden gradient (ST.S33)
RigFemScalarResultFrames* obg0DataFrames = nullptr; RigFemScalarResultFrames* obg0DataFrames = nullptr;
{ {
auto task = frameCountProgress.task( "Loading ST.S33", m_resultCollection->frameCount() ); auto task = stepCountProgress.task( "Loading ST.S33", m_resultCollection->timeStepCount() );
obg0DataFrames = obg0DataFrames =
m_resultCollection->findOrLoadScalarResult( partIndex, m_resultCollection->findOrLoadScalarResult( partIndex,
RigFemResultAddress( resVarAddr.resultPosType, "ST", "S33" ) ); RigFemResultAddress( resVarAddr.resultPosType, "ST", "S33" ) );
@ -156,7 +156,7 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorMudWeightWindow::calculate(
if ( PP_NonReservoirType != RimMudWeightWindowParameters::NonReservoirPorePressureType::HYDROSTATIC && if ( PP_NonReservoirType != RimMudWeightWindowParameters::NonReservoirPorePressureType::HYDROSTATIC &&
!nonReservoirAddress.isEmpty() ) !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 = nonReservoirResultFrames =
m_resultCollection->findOrLoadScalarResult( partIndex, m_resultCollection->findOrLoadScalarResult( partIndex,
RigFemResultAddress( RIG_ELEMENT, RigFemResultAddress( RIG_ELEMENT,
@ -166,294 +166,300 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorMudWeightWindow::calculate(
float inf = std::numeric_limits<float>::infinity(); float inf = std::numeric_limits<float>::infinity();
frameCountProgress.setNextProgressIncrement( 1u ); stepCountProgress.setNextProgressIncrement( 1u );
frameCountProgress.setProgressDescription( "Calculating Mud Weight Window." ); stepCountProgress.setProgressDescription( "Calculating Mud Weight Window." );
int frameCount = stressDataFrames->frameCount(); const int timeSteps = stressDataFrames->timeStepCount();
for ( int fIdx = 0; fIdx < frameCount; ++fIdx ) for ( int stepIdx = 0; stepIdx < timeSteps; stepIdx++ )
{ {
const std::vector<float>& porFrameData = porePressureDataFrames->frameData( fIdx ); const int frameCount = stressDataFrames->frameCount( stepIdx );
if ( porFrameData.empty() ) continue; for ( int fIdx = 0; fIdx < frameCount; fIdx++ )
const std::vector<float>& initialPorFrameData = porePressureDataFrames->frameData( 0 );
if ( initialPorFrameData.empty() ) continue;
const std::vector<float>& stressFrameData = stressDataFrames->frameData( fIdx );
const std::vector<float>& obg0FrameData = obg0DataFrames->frameData( 0 );
std::vector<float>& mudWeightWindowFrameData = mudWeightWindowFrames->frameData( fIdx );
std::vector<float>& mudWeightMiddleFrameData = mudWeightMiddleFrames->frameData( fIdx );
std::vector<float>& upperMudWeightLimitFrameData = upperMudWeightLimitFrames->frameData( fIdx );
std::vector<float>& 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<RimMudWeightWindowParameters::ParameterType, std::vector<float>> parameterFrameData;
for ( auto parameterType : parameterTypes )
{ {
parameterFrameData[parameterType] = loadDataForFrame( parameterType, parameterFrames, fIdx ); const std::vector<float>& porFrameData = porePressureDataFrames->frameData( stepIdx, fIdx );
} if ( porFrameData.empty() ) continue;
std::vector<float> nonReservoirPP; const std::vector<float>& initialPorFrameData = porePressureDataFrames->frameData( 0, 0 );
if ( nonReservoirResultFrames ) if ( initialPorFrameData.empty() ) continue;
{
nonReservoirPP = nonReservoirResultFrames->frameData( 0 );
}
// Load stress const std::vector<float>& stressFrameData = stressDataFrames->frameData( stepIdx, fIdx );
RigFemResultAddress stressResAddr( RIG_ELEMENT_NODAL, "ST", "" ); const std::vector<float>& obg0FrameData = obg0DataFrames->frameData( 0, 0 );
std::vector<caf::Ten3f> vertexStressesFloat = m_resultCollection->tensors( stressResAddr, partIndex, fIdx );
std::vector<caf::Ten3d> vertexStresses; std::vector<float>& mudWeightWindowFrameData = mudWeightWindowFrames->frameData( stepIdx, fIdx );
vertexStresses.reserve( vertexStressesFloat.size() ); std::vector<float>& mudWeightMiddleFrameData = mudWeightMiddleFrames->frameData( stepIdx, fIdx );
for ( const caf::Ten3f& floatTensor : vertexStressesFloat ) std::vector<float>& upperMudWeightLimitFrameData = upperMudWeightLimitFrames->frameData( stepIdx, fIdx );
{ std::vector<float>& lowerMudWeightLimitFrameData = lowerMudWeightLimitFrames->frameData( stepIdx, fIdx );
vertexStresses.push_back( caf::Ten3d( floatTensor ) );
} size_t valCount = stressFrameData.size();
mudWeightWindowFrameData.resize( valCount );
mudWeightMiddleFrameData.resize( valCount );
upperMudWeightLimitFrameData.resize( valCount );
lowerMudWeightLimitFrameData.resize( valCount );
int elementCount = femPart->elementCount();
std::map<RimMudWeightWindowParameters::ParameterType, std::vector<float>> parameterFrameData;
for ( auto parameterType : parameterTypes )
{
parameterFrameData[parameterType] = loadDataForFrame( parameterType, parameterFrames, stepIdx, fIdx );
}
std::vector<float> nonReservoirPP;
if ( nonReservoirResultFrames )
{
nonReservoirPP = nonReservoirResultFrames->frameData( 0, 0 );
}
// Load stress
RigFemResultAddress stressResAddr( RIG_ELEMENT_NODAL, "ST", "" );
std::vector<caf::Ten3f> vertexStressesFloat =
m_resultCollection->tensors( stressResAddr, partIndex, stepIdx, fIdx );
std::vector<caf::Ten3d> vertexStresses;
vertexStresses.reserve( vertexStressesFloat.size() );
for ( const caf::Ten3f& floatTensor : vertexStressesFloat )
{
vertexStresses.push_back( caf::Ten3d( floatTensor ) );
}
#pragma omp parallel for #pragma omp parallel for
for ( int elmIdx = 0; elmIdx < elementCount; ++elmIdx ) 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 )
{ {
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, parameterFrameData,
parameterValues, parameterValues,
elmIdx ); elmIdx );
double wellPathAzimuth = getValueForElement( RimMudWeightWindowParameters::ParameterType::WELL_AZIMUTH, double K0_FG = getValueForElement( RimMudWeightWindowParameters::ParameterType::K0_FG,
parameterFrameData, parameterFrameData,
parameterValues, parameterValues,
elmIdx ); elmIdx );
double ucsBar = getValueForElement( RimMudWeightWindowParameters::ParameterType::UCS, double OBG0 = 0.0;
parameterFrameData, if ( !OBG0FromGrid )
parameterValues, {
elmIdx ); OBG0 = getValueForElement( RimMudWeightWindowParameters::ParameterType::OBG0,
double poissonsRatio = getValueForElement( RimMudWeightWindowParameters::ParameterType::POISSONS_RATIO,
parameterFrameData,
parameterValues,
elmIdx );
double K0_FG = getValueForElement( RimMudWeightWindowParameters::ParameterType::K0_FG,
parameterFrameData, parameterFrameData,
parameterValues, parameterValues,
elmIdx ); elmIdx );
}
double OBG0 = 0.0; for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx )
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() )
{ {
// Pore pressure (unit: Bar) size_t elmNodResIdx = femPart->elementNodeResultIdx( elmIdx, elmNodIdx );
float porePressureBar = porFrameData[elmNodResIdx]; if ( elmNodResIdx < stressFrameData.size() )
float initialPorePressureBar = initialPorFrameData[elmNodResIdx];
// Initial overburden gradient
if ( OBG0FromGrid )
{ {
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. // Initial overburden gradient
bool isSand = ( porePressureBar != inf ); 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 == if ( porePressureBar == inf )
RimMudWeightWindowParameters::NonReservoirPorePressureType::HYDROSTATIC )
{ {
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 ); cvf::Vec3d wellPathTangent = calculateWellPathTangent( wellPathAzimuth, wellPathDeviation );
caf::Ten3d wellPathStressFloat = caf::Ten3d wellPathStressFloat =
RigGeoMechWellLogExtractor::transformTensorToWellPathOrientation( wellPathTangent, RigGeoMechWellLogExtractor::transformTensorToWellPathOrientation( wellPathTangent,
segmentStress ); segmentStress );
caf::Ten3d wellPathStressDouble( wellPathStressFloat ); caf::Ten3d wellPathStressDouble( wellPathStressFloat );
// Calculate upper limit // Calculate upper limit
float upperLimit = inf; float upperLimit = inf;
if ( upperLimitParameter == RimMudWeightWindowParameters::UpperLimitType::FG && isSand ) 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
{ {
RigGeoMechBoreHoleStressCalculator sigmaCalculator( wellPathStressDouble, RigGeoMechBoreHoleStressCalculator sigmaCalculator( wellPathStressDouble,
hydroStaticPressureForNormalization, porePressureBar,
poissonsRatio, poissonsRatio,
ucsBar, ucsBar,
32 ); 32 );
upperLimit = sigmaCalculator.solveFractureGradient() / hydroStaticPressureForNormalization;
double SFG = sigmaCalculator.solveStassiDalia();
lowerLimit = std::max( porePressureBar, static_cast<float>( SFG ) );
} }
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<float>( 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
else
{
for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx )
{ {
size_t elmNodResIdx = femPart->elementNodeResultIdx( elmIdx, elmNodIdx ); for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx )
if ( elmNodResIdx < stressFrameData.size() )
{ {
mudWeightWindowFrameData[elmNodResIdx] = inf; size_t elmNodResIdx = femPart->elementNodeResultIdx( elmIdx, elmNodIdx );
mudWeightMiddleFrameData[elmNodResIdx] = inf; if ( elmNodResIdx < stressFrameData.size() )
upperMudWeightLimitFrameData[elmNodResIdx] = inf; {
lowerMudWeightLimitFrameData[elmNodResIdx] = inf; 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 #pragma omp parallel for
for ( int elmIdx = 0; elmIdx < elementCount; ++elmIdx ) 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 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 ); for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx )
float maxLowerMudWeightLimit = lowerMudWeightLimitFrameData[elmNodResIdx];
float minUpperMudWeightLimit = upperMudWeightLimitFrameData[elmNodResIdx];
for ( size_t currentK = kMin; currentK < kMax; currentK++ )
{ {
size_t kElmIdx = femPartGrid->cellIndexFromIJK( i, j, currentK ); size_t elmNodResIdx = femPart->elementNodeResultIdx( elmIdx, elmNodIdx );
if ( kElmIdx != cvf::UNDEFINED_SIZE_T && femPart->isHexahedron( kElmIdx ) )
float maxLowerMudWeightLimit = lowerMudWeightLimitFrameData[elmNodResIdx];
float minUpperMudWeightLimit = upperMudWeightLimitFrameData[elmNodResIdx];
for ( size_t currentK = kMin; currentK < kMax; currentK++ )
{ {
size_t kElmNodResIdx = femPart->elementNodeResultIdx( static_cast<int>( kElmIdx ), elmNodIdx ); size_t kElmIdx = femPartGrid->cellIndexFromIJK( i, j, currentK );
if ( kElmIdx != cvf::UNDEFINED_SIZE_T && femPart->isHexahedron( kElmIdx ) )
float currentLowerMudWeightLimit = lowerMudWeightLimitFrameData[kElmNodResIdx];
if ( currentLowerMudWeightLimit > maxLowerMudWeightLimit )
{ {
maxLowerMudWeightLimit = currentLowerMudWeightLimit; size_t kElmNodResIdx =
} femPart->elementNodeResultIdx( static_cast<int>( kElmIdx ), elmNodIdx );
float currentUpperMudWeightLimit = upperMudWeightLimitFrameData[kElmNodResIdx]; float currentLowerMudWeightLimit = lowerMudWeightLimitFrameData[kElmNodResIdx];
if ( currentUpperMudWeightLimit < minUpperMudWeightLimit ) if ( currentLowerMudWeightLimit > maxLowerMudWeightLimit )
{ {
minUpperMudWeightLimit = currentUpperMudWeightLimit; maxLowerMudWeightLimit = currentLowerMudWeightLimit;
}
float currentUpperMudWeightLimit = upperMudWeightLimitFrameData[kElmNodResIdx];
if ( currentUpperMudWeightLimit < minUpperMudWeightLimit )
{
minUpperMudWeightLimit = currentUpperMudWeightLimit;
}
} }
} }
}
float mudWeightWindow = minUpperMudWeightLimit - maxLowerMudWeightLimit; float mudWeightWindow = minUpperMudWeightLimit - maxLowerMudWeightLimit;
mudWeightWindowFrameData[elmNodResIdx] = mudWeightWindow; mudWeightWindowFrameData[elmNodResIdx] = mudWeightWindow;
float mudWeightMiddle = inf; float mudWeightMiddle = inf;
if ( mudWeightWindow > 0.0 ) if ( mudWeightWindow > 0.0 )
{ {
mudWeightMiddle = maxLowerMudWeightLimit + mudWeightWindow / 2.0; mudWeightMiddle = maxLowerMudWeightLimit + mudWeightWindow / 2.0;
}
mudWeightMiddleFrameData[elmNodResIdx] = mudWeightMiddle;
} }
mudWeightMiddleFrameData[elmNodResIdx] = mudWeightMiddle;
} }
} }
} }
stepCountProgress.incrementProgress();
frameCountProgress.incrementProgress();
} }
RigFemScalarResultFrames* requestedResultFrames = m_resultCollection->findOrLoadScalarResult( partIndex, resVarAddr ); RigFemScalarResultFrames* requestedResultFrames = m_resultCollection->findOrLoadScalarResult( partIndex, resVarAddr );
@ -499,13 +505,14 @@ void RigFemPartResultCalculatorMudWeightWindow::loadParameterFramesOrValue(
std::vector<float> RigFemPartResultCalculatorMudWeightWindow::loadDataForFrame( std::vector<float> RigFemPartResultCalculatorMudWeightWindow::loadDataForFrame(
RimMudWeightWindowParameters::ParameterType parameterType, RimMudWeightWindowParameters::ParameterType parameterType,
std::map<RimMudWeightWindowParameters::ParameterType, RigFemScalarResultFrames*>& parameterFrames, std::map<RimMudWeightWindowParameters::ParameterType, RigFemScalarResultFrames*>& parameterFrames,
int stepIndex,
int frameIndex ) int frameIndex )
{ {
auto it = parameterFrames.find( parameterType ); auto it = parameterFrames.find( parameterType );
if ( it != parameterFrames.end() ) if ( it != parameterFrames.end() )
{ {
RigFemScalarResultFrames* frame = it->second; RigFemScalarResultFrames* frame = it->second;
std::vector<float> dataForFrame = frame->frameData( frameIndex ); std::vector<float> dataForFrame = frame->frameData( stepIndex, frameIndex );
return dataForFrame; return dataForFrame;
} }
else else

View File

@ -52,6 +52,7 @@ private:
static std::vector<float> static std::vector<float>
loadDataForFrame( RimMudWeightWindowParameters::ParameterType parameterType, loadDataForFrame( RimMudWeightWindowParameters::ParameterType parameterType,
std::map<RimMudWeightWindowParameters::ParameterType, RigFemScalarResultFrames*>& parameterFrames, std::map<RimMudWeightWindowParameters::ParameterType, RigFemScalarResultFrames*>& parameterFrames,
int stepIndex,
int frameIndex ); int frameIndex );
static float static float

View File

@ -59,10 +59,10 @@ bool RigFemPartResultCalculatorNE::isMatching( const RigFemResultAddress& resVar
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RigFemScalarResultFrames* RigFemPartResultCalculatorNE::calculate( int partIndex, const RigFemResultAddress& resVarAddr ) RigFemScalarResultFrames* RigFemPartResultCalculatorNE::calculate( int partIndex, const RigFemResultAddress& resVarAddr )
{ {
caf::ProgressInfo frameCountProgress( m_resultCollection->frameCount() * 2, "" ); caf::ProgressInfo stepCountProgress( m_resultCollection->timeStepCount() * 2, "" );
frameCountProgress.setProgressDescription( stepCountProgress.setProgressDescription(
"Calculating " + QString::fromStdString( resVarAddr.fieldName + ": " + resVarAddr.componentName ) ); "Calculating " + QString::fromStdString( resVarAddr.fieldName + ": " + resVarAddr.componentName ) );
frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() );
RigFemScalarResultFrames* srcDataFrames = RigFemScalarResultFrames* srcDataFrames =
m_resultCollection->findOrLoadScalarResult( partIndex, m_resultCollection->findOrLoadScalarResult( partIndex,
@ -71,23 +71,26 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorNE::calculate( int partIndex
resVarAddr.componentName ) ); resVarAddr.componentName ) );
RigFemScalarResultFrames* dstDataFrames = m_resultCollection->createScalarResult( partIndex, resVarAddr ); RigFemScalarResultFrames* dstDataFrames = m_resultCollection->createScalarResult( partIndex, resVarAddr );
frameCountProgress.incrementProgress(); stepCountProgress.incrementProgress();
int frameCount = srcDataFrames->frameCount(); const int timeSteps = srcDataFrames->timeStepCount();
for ( int fIdx = 0; fIdx < frameCount; ++fIdx ) for ( int stepIdx = 0; stepIdx < timeSteps; stepIdx++ )
{ {
const std::vector<float>& srcFrameData = srcDataFrames->frameData( fIdx ); const int frameCount = srcDataFrames->frameCount( stepIdx );
std::vector<float>& dstFrameData = dstDataFrames->frameData( fIdx ); for ( int fIdx = 0; fIdx < frameCount; fIdx++ )
size_t valCount = srcFrameData.size(); {
dstFrameData.resize( valCount ); const std::vector<float>& srcFrameData = srcDataFrames->frameData( stepIdx, fIdx );
std::vector<float>& dstFrameData = dstDataFrames->frameData( stepIdx, fIdx );
size_t valCount = srcFrameData.size();
dstFrameData.resize( valCount );
#pragma omp parallel for #pragma omp parallel for
for ( long vIdx = 0; vIdx < static_cast<long>( valCount ); ++vIdx ) for ( long vIdx = 0; vIdx < static_cast<long>( valCount ); ++vIdx )
{ {
dstFrameData[vIdx] = -srcFrameData[vIdx]; dstFrameData[vIdx] = -srcFrameData[vIdx];
}
} }
stepCountProgress.incrementProgress();
frameCountProgress.incrementProgress();
} }
return dstDataFrames; return dstDataFrames;

View File

@ -62,111 +62,116 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorNodalGradients::calculate( i
CVF_ASSERT( resVarAddr.fieldName == "POR-Bar" ); CVF_ASSERT( resVarAddr.fieldName == "POR-Bar" );
CVF_ASSERT( resVarAddr.componentName == "X" || resVarAddr.componentName == "Y" || resVarAddr.componentName == "Z" ); CVF_ASSERT( resVarAddr.componentName == "X" || resVarAddr.componentName == "Y" || resVarAddr.componentName == "Z" );
caf::ProgressInfo frameCountProgress( m_resultCollection->frameCount() * 5, "" ); caf::ProgressInfo stepCountProgress( m_resultCollection->timeStepCount() * 5, "" );
frameCountProgress.setProgressDescription( stepCountProgress.setProgressDescription(
"Calculating gradient: " + QString::fromStdString( resVarAddr.fieldName + ": " + resVarAddr.componentName ) ); "Calculating gradient: " + QString::fromStdString( resVarAddr.fieldName + ": " + resVarAddr.componentName ) );
frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() );
RigFemScalarResultFrames* dataFramesX = RigFemScalarResultFrames* dataFramesX =
m_resultCollection->createScalarResult( partIndex, RigFemResultAddress( RIG_NODAL, resVarAddr.fieldName, "X" ) ); m_resultCollection->createScalarResult( partIndex, RigFemResultAddress( RIG_NODAL, resVarAddr.fieldName, "X" ) );
frameCountProgress.incrementProgress(); stepCountProgress.incrementProgress();
frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() );
RigFemScalarResultFrames* dataFramesY = RigFemScalarResultFrames* dataFramesY =
m_resultCollection->createScalarResult( partIndex, RigFemResultAddress( RIG_NODAL, resVarAddr.fieldName, "Y" ) ); m_resultCollection->createScalarResult( partIndex, RigFemResultAddress( RIG_NODAL, resVarAddr.fieldName, "Y" ) );
frameCountProgress.incrementProgress(); stepCountProgress.incrementProgress();
frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() );
RigFemScalarResultFrames* dataFramesZ = RigFemScalarResultFrames* dataFramesZ =
m_resultCollection->createScalarResult( partIndex, RigFemResultAddress( RIG_NODAL, resVarAddr.fieldName, "Z" ) ); m_resultCollection->createScalarResult( partIndex, RigFemResultAddress( RIG_NODAL, resVarAddr.fieldName, "Z" ) );
frameCountProgress.incrementProgress(); stepCountProgress.incrementProgress();
frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() );
RigFemResultAddress porResultAddr( RIG_NODAL, "POR-Bar", "" ); RigFemResultAddress porResultAddr( RIG_NODAL, "POR-Bar", "" );
RigFemScalarResultFrames* srcDataFrames = m_resultCollection->findOrLoadScalarResult( partIndex, porResultAddr ); RigFemScalarResultFrames* srcDataFrames = m_resultCollection->findOrLoadScalarResult( partIndex, porResultAddr );
frameCountProgress.incrementProgress(); stepCountProgress.incrementProgress();
const RigFemPart* femPart = m_resultCollection->parts()->part( partIndex ); const RigFemPart* femPart = m_resultCollection->parts()->part( partIndex );
float inf = std::numeric_limits<float>::infinity(); constexpr float inf = std::numeric_limits<float>::infinity();
const std::vector<cvf::Vec3f>& nodeCoords = femPart->nodes().coordinates; const std::vector<cvf::Vec3f>& nodeCoords = femPart->nodes().coordinates;
size_t nodeCount = femPart->nodes().nodeIds.size(); size_t nodeCount = femPart->nodes().nodeIds.size();
int frameCount = srcDataFrames->frameCount(); const int timeSteps = srcDataFrames->timeStepCount();
for ( int fIdx = 0; fIdx < frameCount; ++fIdx ) for ( int stepIdx = 0; stepIdx < timeSteps; stepIdx++ )
{ {
const std::vector<float>& srcFrameData = srcDataFrames->frameData( fIdx ); const int frameCount = srcDataFrames->frameCount( stepIdx );
std::vector<float>& dstFrameDataX = dataFramesX->frameData( fIdx ); for ( int fIdx = 0; fIdx < frameCount; fIdx++ )
std::vector<float>& dstFrameDataY = dataFramesY->frameData( fIdx ); {
std::vector<float>& dstFrameDataZ = dataFramesZ->frameData( fIdx ); const std::vector<float>& srcFrameData = srcDataFrames->frameData( stepIdx, fIdx );
std::vector<float>& dstFrameDataX = dataFramesX->frameData( stepIdx, fIdx );
std::vector<float>& dstFrameDataY = dataFramesY->frameData( stepIdx, fIdx );
std::vector<float>& 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(); size_t valCount = femPart->elementNodeResultCount();
dstFrameDataX.resize( valCount, inf ); dstFrameDataX.resize( valCount, inf );
dstFrameDataY.resize( valCount, inf ); dstFrameDataY.resize( valCount, inf );
dstFrameDataZ.resize( valCount, inf ); dstFrameDataZ.resize( valCount, inf );
int elementCount = femPart->elementCount(); int elementCount = femPart->elementCount();
#pragma omp parallel for schedule( dynamic ) #pragma omp parallel for schedule( dynamic )
for ( long nodeIdx = 0; nodeIdx < static_cast<long>( nodeCount ); nodeIdx++ ) for ( long nodeIdx = 0; nodeIdx < static_cast<long>( nodeCount ); nodeIdx++ )
{
const std::vector<int> 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 )
{ {
RigElementType elmType = femPart->elementType( elmIdx ); const std::vector<int> elements = femPart->elementsUsingNode( nodeIdx );
if ( elmType == HEX8P )
// 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 RigElementType elmType = femPart->elementType( elmIdx );
std::array<cvf::Vec3d, 8> hexCorners; if ( elmType == HEX8P )
std::array<double, 8> cornerValues;
int elmNodeCount = RigFemTypes::elementNodeCount( elmType );
for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx )
{ {
size_t elmNodResIdx = femPart->elementNodeResultIdx( elmIdx, elmNodIdx ); // Find the corner coordinates and values for the node
size_t resultValueIdx = femPart->resultValueIdxFromResultPosType( RIG_NODAL, elmIdx, elmNodIdx ); std::array<cvf::Vec3d, 8> hexCorners;
std::array<double, 8> cornerValues;
cornerValues[elmNodIdx] = srcFrameData[resultValueIdx]; int elmNodeCount = RigFemTypes::elementNodeCount( elmType );
hexCorners[elmNodIdx] = cvf::Vec3d( nodeCoords[resultValueIdx] ); for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx )
}
std::array<cvf::Vec3d, 8> 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<size_t>( nodeIdx ) == resultValueIdx )
{ {
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<cvf::Vec3d, 8> 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<size_t>( 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<double>( 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<double>( 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;
}
} }
stepCountProgress.incrementProgress();
frameCountProgress.incrementProgress();
} }
RigFemScalarResultFrames* requestedGradient = m_resultCollection->findOrLoadScalarResult( partIndex, resVarAddr ); RigFemScalarResultFrames* requestedGradient = m_resultCollection->findOrLoadScalarResult( partIndex, resVarAddr );

View File

@ -58,69 +58,71 @@ bool RigFemPartResultCalculatorNormalSE::isMatching( const RigFemResultAddress&
RigFemScalarResultFrames* RigFemPartResultCalculatorNormalSE::calculate( int partIndex, RigFemScalarResultFrames* RigFemPartResultCalculatorNormalSE::calculate( int partIndex,
const RigFemResultAddress& resVarAddr ) const RigFemResultAddress& resVarAddr )
{ {
caf::ProgressInfo frameCountProgress( m_resultCollection->frameCount() * 3, "" ); caf::ProgressInfo stepCountProgress( m_resultCollection->timeStepCount() * 3, "" );
frameCountProgress.setProgressDescription( stepCountProgress.setProgressDescription(
"Calculating " + QString::fromStdString( resVarAddr.fieldName + ": " + resVarAddr.componentName ) ); "Calculating " + QString::fromStdString( resVarAddr.fieldName + ": " + resVarAddr.componentName ) );
frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() );
RigFemScalarResultFrames* srcDataFrames = RigFemScalarResultFrames* srcDataFrames =
m_resultCollection->findOrLoadScalarResult( partIndex, m_resultCollection->findOrLoadScalarResult( partIndex,
RigFemResultAddress( resVarAddr.resultPosType, RigFemResultAddress( resVarAddr.resultPosType,
"S-Bar", "S-Bar",
resVarAddr.componentName ) ); resVarAddr.componentName ) );
frameCountProgress.incrementProgress(); stepCountProgress.incrementProgress();
frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() );
RigFemScalarResultFrames* dstDataFrames = m_resultCollection->createScalarResult( partIndex, resVarAddr ); RigFemScalarResultFrames* dstDataFrames = m_resultCollection->createScalarResult( partIndex, resVarAddr );
frameCountProgress.incrementProgress(); stepCountProgress.incrementProgress();
const RigFemPart* femPart = m_resultCollection->parts()->part( partIndex ); const RigFemPart* femPart = m_resultCollection->parts()->part( partIndex );
float inf = std::numeric_limits<float>::infinity(); constexpr float inf = std::numeric_limits<float>::infinity();
int frameCount = srcDataFrames->frameCount(); const int timeSteps = srcDataFrames->timeStepCount();
for ( int stepIdx = 0; stepIdx < timeSteps; stepIdx++ )
for ( int fIdx = 0; fIdx < frameCount; ++fIdx )
{ {
const std::vector<float>& srcSFrameData = srcDataFrames->frameData( fIdx ); const int frameCount = srcDataFrames->frameCount( stepIdx );
std::vector<float>& dstFrameData = dstDataFrames->frameData( fIdx ); for ( int fIdx = 0; fIdx < frameCount; fIdx++ )
size_t valCount = srcSFrameData.size(); {
dstFrameData.resize( valCount ); const std::vector<float>& srcSFrameData = srcDataFrames->frameData( stepIdx, fIdx );
std::vector<float>& 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 #pragma omp parallel for
for ( int elmIdx = 0; elmIdx < elementCount; ++elmIdx ) for ( int elmIdx = 0; elmIdx < elementCount; ++elmIdx )
{
RigElementType elmType = femPart->elementType( elmIdx );
int elmNodeCount = RigFemTypes::elementNodeCount( femPart->elementType( elmIdx ) );
if ( elmType == HEX8P )
{ {
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 ); for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx )
if ( elmNodResIdx < srcSFrameData.size() )
{ {
// SE from abacus in opposite direction size_t elmNodResIdx = femPart->elementNodeResultIdx( elmIdx, elmNodIdx );
dstFrameData[elmNodResIdx] = -srcSFrameData[elmNodResIdx]; if ( elmNodResIdx < srcSFrameData.size() )
{
// SE from abacus in opposite direction
dstFrameData[elmNodResIdx] = -srcSFrameData[elmNodResIdx];
}
} }
} }
} else
else
{
for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx )
{ {
size_t elmNodResIdx = femPart->elementNodeResultIdx( elmIdx, elmNodIdx ); for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx )
if ( elmNodResIdx < dstFrameData.size() )
{ {
dstFrameData[elmNodResIdx] = inf; size_t elmNodResIdx = femPart->elementNodeResultIdx( elmIdx, elmNodIdx );
if ( elmNodResIdx < dstFrameData.size() )
{
dstFrameData[elmNodResIdx] = inf;
}
} }
} }
} }
} }
stepCountProgress.incrementProgress();
frameCountProgress.incrementProgress();
} }
return dstDataFrames; return dstDataFrames;

View File

@ -58,82 +58,85 @@ bool RigFemPartResultCalculatorNormalST::isMatching( const RigFemResultAddress&
RigFemScalarResultFrames* RigFemPartResultCalculatorNormalST::calculate( int partIndex, RigFemScalarResultFrames* RigFemPartResultCalculatorNormalST::calculate( int partIndex,
const RigFemResultAddress& resVarAddr ) const RigFemResultAddress& resVarAddr )
{ {
caf::ProgressInfo frameCountProgress( m_resultCollection->frameCount() * 3, "" ); caf::ProgressInfo stepCountProgress( m_resultCollection->timeStepCount() * 3, "" );
frameCountProgress.setProgressDescription( stepCountProgress.setProgressDescription(
"Calculating " + QString::fromStdString( resVarAddr.fieldName + ": " + resVarAddr.componentName ) ); "Calculating " + QString::fromStdString( resVarAddr.fieldName + ": " + resVarAddr.componentName ) );
frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() );
RigFemScalarResultFrames* srcSDataFrames = RigFemScalarResultFrames* srcSDataFrames =
m_resultCollection->findOrLoadScalarResult( partIndex, m_resultCollection->findOrLoadScalarResult( partIndex,
RigFemResultAddress( resVarAddr.resultPosType, RigFemResultAddress( resVarAddr.resultPosType,
"S-Bar", "S-Bar",
resVarAddr.componentName ) ); resVarAddr.componentName ) );
frameCountProgress.incrementProgress(); stepCountProgress.incrementProgress();
frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() );
RigFemScalarResultFrames* srcPORDataFrames = RigFemScalarResultFrames* srcPORDataFrames =
m_resultCollection->findOrLoadScalarResult( partIndex, RigFemResultAddress( RIG_NODAL, "POR-Bar", "" ) ); m_resultCollection->findOrLoadScalarResult( partIndex, RigFemResultAddress( RIG_NODAL, "POR-Bar", "" ) );
RigFemScalarResultFrames* dstDataFrames = m_resultCollection->createScalarResult( partIndex, resVarAddr ); RigFemScalarResultFrames* dstDataFrames = m_resultCollection->createScalarResult( partIndex, resVarAddr );
const RigFemPart* femPart = m_resultCollection->parts()->part( partIndex ); const RigFemPart* femPart = m_resultCollection->parts()->part( partIndex );
int frameCount = srcSDataFrames->frameCount();
frameCountProgress.incrementProgress(); stepCountProgress.incrementProgress();
const float inf = std::numeric_limits<float>::infinity(); constexpr float inf = std::numeric_limits<float>::infinity();
for ( int fIdx = 0; fIdx < frameCount; ++fIdx ) const int timeSteps = srcPORDataFrames->timeStepCount();
for ( int stepIdx = 0; stepIdx < timeSteps; stepIdx++ )
{ {
const std::vector<float>& srcSFrameData = srcSDataFrames->frameData( fIdx ); const int frameCount = srcPORDataFrames->frameCount( stepIdx );
const std::vector<float>& srcPORFrameData = srcPORDataFrames->frameData( fIdx ); for ( int fIdx = 0; fIdx < frameCount; fIdx++ )
{
const std::vector<float>& srcSFrameData = srcSDataFrames->frameData( stepIdx, fIdx );
const std::vector<float>& srcPORFrameData = srcPORDataFrames->frameData( stepIdx, fIdx );
int elementCount = femPart->elementCount(); int elementCount = femPart->elementCount();
std::vector<float>& dstFrameData = dstDataFrames->frameData( fIdx ); std::vector<float>& dstFrameData = dstDataFrames->frameData( stepIdx, fIdx );
size_t valCount = srcSFrameData.size(); size_t valCount = srcSFrameData.size();
dstFrameData.resize( valCount ); dstFrameData.resize( valCount );
#pragma omp parallel for #pragma omp parallel for
for ( int elmIdx = 0; elmIdx < elementCount; ++elmIdx ) for ( int elmIdx = 0; elmIdx < elementCount; ++elmIdx )
{
RigElementType elmType = femPart->elementType( elmIdx );
int elmNodeCount = RigFemTypes::elementNodeCount( femPart->elementType( elmIdx ) );
if ( elmType == HEX8P )
{ {
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 ); for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx )
if ( elmNodResIdx < srcSFrameData.size() )
{ {
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]; float por = srcPORFrameData[nodeIdx];
if ( por == inf ) por = 0.0f; if ( por == inf ) por = 0.0f;
// ST = SE_abacus + porePressure // ST = SE_abacus + porePressure
// porePressure is POR-Bar. // porePressure is POR-Bar.
double SE_abacus = -srcSFrameData[elmNodResIdx]; double SE_abacus = -srcSFrameData[elmNodResIdx];
dstFrameData[elmNodResIdx] = SE_abacus + por; dstFrameData[elmNodResIdx] = SE_abacus + por;
}
} }
} }
} else
else
{
for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx )
{ {
size_t elmNodResIdx = femPart->elementNodeResultIdx( elmIdx, elmNodIdx ); for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx )
if ( elmNodResIdx < srcSFrameData.size() )
{ {
dstFrameData[elmNodResIdx] = -srcSFrameData[elmNodResIdx]; size_t elmNodResIdx = femPart->elementNodeResultIdx( elmIdx, elmNodIdx );
if ( elmNodResIdx < srcSFrameData.size() )
{
dstFrameData[elmNodResIdx] = -srcSFrameData[elmNodResIdx];
}
} }
} }
} }
} }
stepCountProgress.incrementProgress();
frameCountProgress.incrementProgress();
} }
return dstDataFrames; return dstDataFrames;

View File

@ -70,94 +70,100 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorNormalized::calculate( int
CAF_ASSERT( unscaledResult.resultPosType == RIG_ELEMENT_NODAL ); 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* porDataFrames = nullptr;
RigFemScalarResultFrames* srcDataFrames = nullptr; RigFemScalarResultFrames* srcDataFrames = nullptr;
RigFemScalarResultFrames* dstDataFrames = 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 = porDataFrames =
m_resultCollection->findOrLoadScalarResult( partIndex, RigFemResultAddress( RIG_ELEMENT_NODAL, "POR-Bar", "" ) ); m_resultCollection->findOrLoadScalarResult( partIndex, RigFemResultAddress( RIG_ELEMENT_NODAL, "POR-Bar", "" ) );
if ( !porDataFrames ) return nullptr; 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 ); srcDataFrames = m_resultCollection->findOrLoadScalarResult( partIndex, unscaledResult );
if ( !srcDataFrames ) return nullptr; 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 ) ); dstDataFrames = m_resultCollection->createScalarResult( partIndex, RigFemResultAddress( resVarAddr ) );
if ( !dstDataFrames ) return nullptr; if ( !dstDataFrames ) return nullptr;
} }
frameCountProgress.setProgressDescription( "Normalizing Result" ); stepCountProgress.setProgressDescription( "Normalizing Result" );
frameCountProgress.setNextProgressIncrement( 1u ); stepCountProgress.setNextProgressIncrement( 1u );
const RigFemPart* femPart = m_resultCollection->parts()->part( partIndex ); const RigFemPart* femPart = m_resultCollection->parts()->part( partIndex );
const RigFemPartGrid* femPartGrid = femPart->getOrCreateStructGrid(); const RigFemPartGrid* femPartGrid = femPart->getOrCreateStructGrid();
const float inf = std::numeric_limits<float>::infinity(); constexpr float inf = std::numeric_limits<float>::infinity();
int elmNodeCount = femPart->elementCount(); int elmNodeCount = femPart->elementCount();
const std::vector<cvf::Vec3f>& nodeCoords = femPart->nodes().coordinates; const std::vector<cvf::Vec3f>& nodeCoords = femPart->nodes().coordinates;
int frameCount = srcDataFrames->frameCount(); const int timeSteps = srcDataFrames->timeStepCount();
for ( int fIdx = 0; fIdx < frameCount; ++fIdx ) for ( int stepIdx = 0; stepIdx < timeSteps; stepIdx++ )
{ {
const std::vector<float>& porFrameData = porDataFrames->frameData( fIdx ); const int frameCount = srcDataFrames->frameCount( stepIdx );
if ( porFrameData.empty() ) continue; for ( int fIdx = 0; fIdx < frameCount; fIdx++ )
const std::vector<float>& srcFrameData = srcDataFrames->frameData( fIdx );
std::vector<float>& dstFrameData = dstDataFrames->frameData( fIdx );
size_t resultCount = srcFrameData.size();
dstFrameData.resize( resultCount );
if ( unscaledResult.resultPosType == RIG_ELEMENT_NODAL )
{ {
#pragma omp parallel for schedule( dynamic ) const std::vector<float>& porFrameData = porDataFrames->frameData( stepIdx, fIdx );
for ( int elmIdx = 0; elmIdx < femPart->elementCount(); ++elmIdx ) if ( porFrameData.empty() ) continue;
const std::vector<float>& srcFrameData = srcDataFrames->frameData( stepIdx, fIdx );
std::vector<float>& dstFrameData = dstDataFrames->frameData( stepIdx, fIdx );
size_t resultCount = srcFrameData.size();
dstFrameData.resize( resultCount );
if ( unscaledResult.resultPosType == RIG_ELEMENT_NODAL )
{ {
RigElementType elmType = femPart->elementType( elmIdx ); #pragma omp parallel for schedule( dynamic )
if ( !( elmType == HEX8 || elmType == HEX8P ) ) continue; for ( int elmIdx = 0; elmIdx < femPart->elementCount(); ++elmIdx )
{
RigElementType elmType = femPart->elementType( elmIdx );
if ( !( elmType == HEX8 || elmType == HEX8P ) ) continue;
bool porRegion = false; 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<float>::infinity() )
{
porRegion = true;
}
}
if ( porRegion )
{
// This is in the POR-region. Use hydrostatic pressure from the individual nodes
for ( int elmLocalNodeIdx = 0; elmLocalNodeIdx < 8; ++elmLocalNodeIdx ) for ( int elmLocalNodeIdx = 0; elmLocalNodeIdx < 8; ++elmLocalNodeIdx )
{ {
size_t elmNodeResIdx = femPart->elementNodeResultIdx( elmIdx, elmLocalNodeIdx ); size_t elmNodeResIdx = femPart->elementNodeResultIdx( elmIdx, elmLocalNodeIdx );
const int nodeIdx = femPart->nodeIdxFromElementNodeResultIdx( elmNodeResIdx ); const int nodeIdx = femPart->nodeIdxFromElementNodeResultIdx( elmNodeResIdx );
double tvdRKB = std::abs( nodeCoords[nodeIdx].z() ) + m_resultCollection->normalizationAirGap(); dstFrameData[elmNodeResIdx] = srcFrameData[elmNodeResIdx];
double hydrostaticPressure = RiaWellLogUnitTools<double>::hydrostaticPorePressureBar( tvdRKB ); if ( porFrameData[elmNodeResIdx] != std::numeric_limits<float>::infinity() )
dstFrameData[elmNodeResIdx] /= hydrostaticPressure; {
porRegion = true;
}
} }
} if ( porRegion )
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<double>::hydrostaticPorePressureBar( cellCentroidTvdRKB );
for ( int elmLocalNodeIdx = 0; elmLocalNodeIdx < 8; ++elmLocalNodeIdx )
{ {
size_t elmNodeResIdx = femPart->elementNodeResultIdx( elmIdx, elmLocalNodeIdx ); // This is in the POR-region. Use hydrostatic pressure from the individual nodes
dstFrameData[elmNodeResIdx] /= cellCenterHydroStaticPressure; 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<double>::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<double>::hydrostaticPorePressureBar( cellCentroidTvdRKB );
for ( int elmLocalNodeIdx = 0; elmLocalNodeIdx < 8; ++elmLocalNodeIdx )
{
size_t elmNodeResIdx = femPart->elementNodeResultIdx( elmIdx, elmLocalNodeIdx );
dstFrameData[elmNodeResIdx] /= cellCenterHydroStaticPressure;
}
} }
} }
} }

View File

@ -63,16 +63,16 @@ bool RigFemPartResultCalculatorPoreCompressibility::isMatching( const RigFemResu
RigFemScalarResultFrames* RigFemPartResultCalculatorPoreCompressibility::calculate( int partIndex, RigFemScalarResultFrames* RigFemPartResultCalculatorPoreCompressibility::calculate( int partIndex,
const RigFemResultAddress& resAddr ) const RigFemResultAddress& resAddr )
{ {
caf::ProgressInfo frameCountProgress( static_cast<size_t>( m_resultCollection->frameCount() ) * 7, caf::ProgressInfo stepCountProgress( static_cast<size_t>( m_resultCollection->timeStepCount() ) * 7,
"Calculating Pore Compressibility" ); "Calculating Pore Compressibility" );
auto loadFrameLambda = [&]( RigFemResultAddress addr, const QString& errMsg = "" ) -> RigFemScalarResultFrames* { auto loadFrameLambda = [&]( RigFemResultAddress addr, const QString& errMsg = "" ) -> RigFemScalarResultFrames* {
auto task = frameCountProgress.task( QString( "Loading %1: %2" ) auto task = stepCountProgress.task( QString( "Loading %1: %2" )
.arg( QString::fromStdString( addr.fieldName ) ) .arg( QString::fromStdString( addr.fieldName ) )
.arg( QString::fromStdString( addr.componentName ) ), .arg( QString::fromStdString( addr.componentName ) ),
m_resultCollection->frameCount() ); m_resultCollection->timeStepCount() );
auto result = m_resultCollection->findOrLoadScalarResult( partIndex, addr ); 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 ); if ( !errMsg.isEmpty() ) Riu3DMainWindowTools::reportAndShowWarning( "Required data missing", errMsg );
return nullptr; return nullptr;
@ -130,154 +130,162 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorPoreCompressibility::calcula
const RigFemPart* femPart = m_resultCollection->parts()->part( partIndex ); const RigFemPart* femPart = m_resultCollection->parts()->part( partIndex );
float inf = std::numeric_limits<float>::infinity(); float inf = std::numeric_limits<float>::infinity();
int referenceFrameIdx = m_resultCollection->referenceTimeStep(); int refStepIdx, refFrameIdx;
std::tie( refStepIdx, refFrameIdx ) = m_resultCollection->referenceStepAndFrameIndex();
int frameCount = srcEVDataFrames->frameCount(); const int timeSteps = srcEVDataFrames->timeStepCount();
for ( int fIdx = 0; fIdx < frameCount; ++fIdx ) 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<float>& evData = srcEVDataFrames->frameData( fIdx ); const int frameCount = srcEVDataFrames->frameCount( stepIdx );
const std::vector<float>& referenceEvData = srcEVDataFrames->frameData( referenceFrameIdx ); for ( int fIdx = 0; fIdx < frameCount; fIdx++ )
const std::vector<float>& verticalStrainData = verticalStrainDataFrames->frameData( fIdx );
const std::vector<float>& referenceVerticalStrainData = verticalStrainDataFrames->frameData( referenceFrameIdx );
const std::vector<float>& youngsModuliData = youngsModuliFrames->frameData( fIdx );
const std::vector<float>& poissonRatioData = poissonRatioFrames->frameData( fIdx );
const std::vector<float>& voidRatioData = voidRatioFrames->frameData( 0 );
const std::vector<float>& referencePorFrameData = srcPORDataFrames->frameData( referenceFrameIdx );
const std::vector<float>& porFrameData = srcPORDataFrames->frameData( fIdx );
std::vector<float>& poreCompressibilityFrameData = poreCompressibilityFrames->frameData( fIdx );
std::vector<float>& verticalCompressibilityFrameData = verticalCompressibilityFrames->frameData( fIdx );
std::vector<float>& verticalCompressibilityRatioFrameData = verticalCompressibilityRatioFrames->frameData( fIdx );
size_t valCount = evData.size();
poreCompressibilityFrameData.resize( valCount );
verticalCompressibilityFrameData.resize( valCount );
verticalCompressibilityRatioFrameData.resize( valCount );
int elementCount = femPart->elementCount();
std::vector<float> biotData;
if ( biotCoefficient )
{ {
biotData = biotCoefficient->frameData( fIdx ); const std::vector<float>& evData = srcEVDataFrames->frameData( stepIdx, fIdx );
if ( !m_resultCollection->isValidBiotData( biotData, elementCount ) ) const std::vector<float>& referenceEvData = srcEVDataFrames->frameData( refStepIdx, refFrameIdx );
const std::vector<float>& verticalStrainData = verticalStrainDataFrames->frameData( stepIdx, fIdx );
const std::vector<float>& referenceVerticalStrainData =
verticalStrainDataFrames->frameData( refStepIdx, refFrameIdx );
const std::vector<float>& youngsModuliData = youngsModuliFrames->frameData( stepIdx, fIdx );
const std::vector<float>& poissonRatioData = poissonRatioFrames->frameData( stepIdx, fIdx );
const std::vector<float>& voidRatioData = voidRatioFrames->frameData( 0, 0 );
const std::vector<float>& referencePorFrameData = srcPORDataFrames->frameData( refStepIdx, refFrameIdx );
const std::vector<float>& porFrameData = srcPORDataFrames->frameData( stepIdx, fIdx );
std::vector<float>& poreCompressibilityFrameData = poreCompressibilityFrames->frameData( stepIdx, fIdx );
std::vector<float>& verticalCompressibilityFrameData =
verticalCompressibilityFrames->frameData( stepIdx, fIdx );
std::vector<float>& 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<float> biotData;
if ( biotCoefficient )
{ {
m_resultCollection->deleteResult( resAddr ); biotData = biotCoefficient->frameData( stepIdx, fIdx );
return nullptr; if ( !m_resultCollection->isValidBiotData( biotData, elementCount ) )
{
m_resultCollection->deleteResult( resAddr );
return nullptr;
}
} }
}
#pragma omp parallel for #pragma omp parallel for
for ( int elmIdx = 0; elmIdx < elementCount; ++elmIdx ) for ( int elmIdx = 0; elmIdx < elementCount; ++elmIdx )
{
RigElementType elmType = femPart->elementType( elmIdx );
int elmNodeCount = RigFemTypes::elementNodeCount( femPart->elementType( elmIdx ) );
if ( elmType == HEX8P )
{ {
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 ); for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx )
if ( elmNodResIdx < evData.size() )
{ {
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 if ( ( fIdx == refFrameIdx ) && ( stepIdx == refStepIdx ) )
poreCompressibilityFrameData[elmNodResIdx] = inf;
verticalCompressibilityFrameData[elmNodResIdx] = inf;
verticalCompressibilityRatioFrameData[elmNodResIdx] = inf;
}
else
{
// Use biot coefficient for all timesteps
double biotCoefficient = 1.0;
if ( biotData.empty() )
{ {
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 else
{ {
// Use coefficient from element property table // Use biot coefficient for all timesteps
biotCoefficient = biotData[elmIdx]; double biotCoefficient = 1.0;
} if ( biotData.empty() )
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 ); 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
else
{
for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx )
{ {
size_t elmNodResIdx = femPart->elementNodeResultIdx( elmIdx, elmNodIdx ); for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx )
if ( elmNodResIdx < poreCompressibilityFrameData.size() )
{ {
poreCompressibilityFrameData[elmNodResIdx] = inf; size_t elmNodResIdx = femPart->elementNodeResultIdx( elmIdx, elmNodIdx );
if ( elmNodResIdx < poreCompressibilityFrameData.size() )
{
poreCompressibilityFrameData[elmNodResIdx] = inf;
}
} }
} }
} }
} }
} }
RigFemScalarResultFrames* requestedResultFrames = m_resultCollection->findOrLoadScalarResult( partIndex, resAddr ); RigFemScalarResultFrames* requestedResultFrames = m_resultCollection->findOrLoadScalarResult( partIndex, resAddr );
return requestedResultFrames; return requestedResultFrames;
} }

View File

@ -64,28 +64,28 @@ bool RigFemPartResultCalculatorPorosityPermeability::isMatching( const RigFemRes
RigFemScalarResultFrames* RigFemScalarResultFrames*
RigFemPartResultCalculatorPorosityPermeability::calculate( int partIndex, const RigFemResultAddress& resVarAddr ) RigFemPartResultCalculatorPorosityPermeability::calculate( int partIndex, const RigFemResultAddress& resVarAddr )
{ {
caf::ProgressInfo frameCountProgress( m_resultCollection->frameCount() * 6, "" ); caf::ProgressInfo stepCountProgress( m_resultCollection->timeStepCount() * 6, "" );
frameCountProgress.setProgressDescription( "Calculating Porosity/Permeability" ); stepCountProgress.setProgressDescription( "Calculating Porosity/Permeability" );
frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() );
RigFemScalarResultFrames* srcPorePressureDataFrames = RigFemScalarResultFrames* srcPorePressureDataFrames =
m_resultCollection->findOrLoadScalarResult( partIndex, RigFemResultAddress( RIG_NODAL, "POR-Bar", "" ) ); m_resultCollection->findOrLoadScalarResult( partIndex, RigFemResultAddress( RIG_NODAL, "POR-Bar", "" ) );
frameCountProgress.incrementProgress(); stepCountProgress.incrementProgress();
// Volumetric Strain // Volumetric Strain
frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() );
RigFemScalarResultFrames* srcEVDataFrames = RigFemScalarResultFrames* srcEVDataFrames =
m_resultCollection->findOrLoadScalarResult( partIndex, RigFemResultAddress( resVarAddr.resultPosType, "NE", "EV" ) ); m_resultCollection->findOrLoadScalarResult( partIndex, RigFemResultAddress( resVarAddr.resultPosType, "NE", "EV" ) );
frameCountProgress.incrementProgress(); stepCountProgress.incrementProgress();
// Pore Compressibility // Pore Compressibility
frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() );
RigFemScalarResultFrames* poreCompressibilityFrames = RigFemScalarResultFrames* poreCompressibilityFrames =
m_resultCollection->findOrLoadScalarResult( partIndex, m_resultCollection->findOrLoadScalarResult( partIndex,
RigFemResultAddress( resVarAddr.resultPosType, "COMPRESSIBILITY", "PORE" ) ); 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 ) ); QString txt = QString( "Failed to compute %1\n" ).arg( QString::fromStdString( resVarAddr.componentName ) );
txt += "Missing pore compressibility data"; txt += "Missing pore compressibility data";
@ -95,10 +95,10 @@ RigFemScalarResultFrames*
return nullptr; return nullptr;
} }
frameCountProgress.incrementProgress(); stepCountProgress.incrementProgress();
// Initial permeability (k0) // Initial permeability (k0)
frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() );
RigFemScalarResultFrames* initialPermeabilityFrames = nullptr; RigFemScalarResultFrames* initialPermeabilityFrames = nullptr;
if ( !m_resultCollection->initialPermeabilityAddress().isEmpty() ) if ( !m_resultCollection->initialPermeabilityAddress().isEmpty() )
{ {
@ -109,9 +109,9 @@ RigFemScalarResultFrames*
m_resultCollection->initialPermeabilityAddress().toStdString(), m_resultCollection->initialPermeabilityAddress().toStdString(),
"" ) ); "" ) );
} }
frameCountProgress.incrementProgress(); stepCountProgress.incrementProgress();
frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() );
RigFemScalarResultFrames* voidRatioFrames = RigFemScalarResultFrames* voidRatioFrames =
m_resultCollection->findOrLoadScalarResult( partIndex, m_resultCollection->findOrLoadScalarResult( partIndex,
@ -126,127 +126,131 @@ RigFemScalarResultFrames*
RigFemScalarResultFrames* permeabilityFrames = RigFemScalarResultFrames* permeabilityFrames =
m_resultCollection->createScalarResult( partIndex, m_resultCollection->createScalarResult( partIndex,
RigFemResultAddress( resVarAddr.resultPosType, resVarAddr.fieldName, "PERM" ) ); RigFemResultAddress( resVarAddr.resultPosType, resVarAddr.fieldName, "PERM" ) );
frameCountProgress.incrementProgress(); stepCountProgress.incrementProgress();
const RigFemPart* femPart = m_resultCollection->parts()->part( partIndex ); const RigFemPart* femPart = m_resultCollection->parts()->part( partIndex );
float inf = std::numeric_limits<float>::infinity(); float inf = std::numeric_limits<float>::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(); const int timeSteps = srcEVDataFrames->timeStepCount();
for ( int fIdx = 0; fIdx < frameCount; ++fIdx ) for ( int stepIdx = 0; stepIdx < timeSteps; stepIdx++ )
{ {
const std::vector<float>& evData = srcEVDataFrames->frameData( fIdx ); const int frameCount = srcEVDataFrames->frameCount( stepIdx );
const std::vector<float>& referenceEvData = srcEVDataFrames->frameData( referenceFrameIdx ); for ( int fIdx = 0; fIdx < frameCount; fIdx++ )
const std::vector<float>& voidRatioData = voidRatioFrames->frameData( 0 );
const std::vector<float>& referencePorFrameData = srcPorePressureDataFrames->frameData( referenceFrameIdx );
const std::vector<float>& porFrameData = srcPorePressureDataFrames->frameData( fIdx );
const std::vector<float>& poreCompressibilityFrameData = poreCompressibilityFrames->frameData( fIdx );
std::vector<float>& porosityFrameData = porosityFrames->frameData( fIdx );
std::vector<float>& porosityDeltaFrameData = porosityDeltaFrames->frameData( fIdx );
std::vector<float>& permeabilityFrameData = permeabilityFrames->frameData( fIdx );
size_t valCount = evData.size();
porosityFrameData.resize( valCount );
porosityDeltaFrameData.resize( valCount );
permeabilityFrameData.resize( valCount );
int elementCount = femPart->elementCount();
std::vector<float> initialPermeabilityData;
if ( initialPermeabilityFrames )
{ {
initialPermeabilityData = initialPermeabilityFrames->frameData( fIdx ); const std::vector<float>& evData = srcEVDataFrames->frameData( stepIdx, fIdx );
} const std::vector<float>& referenceEvData = srcEVDataFrames->frameData( refStepIdx, refFrameIdx );
const std::vector<float>& voidRatioData = voidRatioFrames->frameData( 0, 0 );
const std::vector<float>& refPorFrameData = srcPorePressureDataFrames->frameData( refStepIdx, refFrameIdx );
const std::vector<float>& porFrameData = srcPorePressureDataFrames->frameData( stepIdx, fIdx );
const std::vector<float>& poreCompressibilityFrameData = poreCompressibilityFrames->frameData( stepIdx, fIdx );
std::vector<float>& porosityFrameData = porosityFrames->frameData( stepIdx, fIdx );
std::vector<float>& porosityDeltaFrameData = porosityDeltaFrames->frameData( stepIdx, fIdx );
std::vector<float>& 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<float> initialPermeabilityData;
if ( initialPermeabilityFrames )
{
initialPermeabilityData = initialPermeabilityFrames->frameData( stepIdx, fIdx );
}
#pragma omp parallel for #pragma omp parallel for
for ( int elmIdx = 0; elmIdx < elementCount; ++elmIdx ) for ( int elmIdx = 0; elmIdx < elementCount; ++elmIdx )
{
RigElementType elmType = femPart->elementType( elmIdx );
int elmNodeCount = RigFemTypes::elementNodeCount( femPart->elementType( elmIdx ) );
if ( elmType == HEX8P )
{ {
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 ); for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx )
if ( elmNodResIdx < evData.size() )
{ {
// User provides initial permeability size_t elmNodResIdx = femPart->elementNodeResultIdx( elmIdx, elmNodIdx );
double initialPermeability = 1.0; if ( elmNodResIdx < evData.size() )
if ( initialPermeabilityData.empty() )
{ {
// 1. Same value for all cells // User provides initial permeability
initialPermeability = m_resultCollection->initialPermeabilityFixed(); 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
else
{
for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx )
{ {
size_t elmNodResIdx = femPart->elementNodeResultIdx( elmIdx, elmNodIdx ); for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx )
if ( elmNodResIdx < poreCompressibilityFrameData.size() )
{ {
porosityFrameData[elmNodResIdx] = inf; size_t elmNodResIdx = femPart->elementNodeResultIdx( elmIdx, elmNodIdx );
porosityDeltaFrameData[elmNodResIdx] = inf; if ( elmNodResIdx < poreCompressibilityFrameData.size() )
permeabilityFrameData[elmNodResIdx] = inf; {
porosityFrameData[elmNodResIdx] = inf;
porosityDeltaFrameData[elmNodResIdx] = inf;
permeabilityFrameData[elmNodResIdx] = inf;
}
} }
} }
} }
} }
stepCountProgress.incrementProgress();
frameCountProgress.incrementProgress();
} }
RigFemScalarResultFrames* requestedResultFrames = m_resultCollection->findOrLoadScalarResult( partIndex, resVarAddr ); RigFemScalarResultFrames* requestedResultFrames = m_resultCollection->findOrLoadScalarResult( partIndex, resVarAddr );

View File

@ -75,11 +75,11 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorPrincipalStrain::calculate(
QString progressText = "Calculating " + QString::fromStdString( resAddr.fieldName + ": " + resAddr.componentName ); QString progressText = "Calculating " + QString::fromStdString( resAddr.fieldName + ": " + resAddr.componentName );
caf::ProgressInfo frameCountProgress( static_cast<size_t>( m_resultCollection->frameCount() ) * 7, progressText ); caf::ProgressInfo stepCountProgress( static_cast<size_t>( m_resultCollection->timeStepCount() ) * 7, progressText );
auto loadFrameLambda = [&]( const std::string& component ) { auto loadFrameLambda = [&]( const std::string& component ) {
auto task = frameCountProgress.task( QString::fromStdString( "Loading " + component ), auto task = stepCountProgress.task( QString::fromStdString( "Loading " + component ),
m_resultCollection->frameCount() ); m_resultCollection->timeStepCount() );
return m_resultCollection->findOrLoadScalarResult( partIndex, resAddr.copyWithComponent( component ) ); return m_resultCollection->findOrLoadScalarResult( partIndex, resAddr.copyWithComponent( component ) );
}; };
@ -97,37 +97,41 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorPrincipalStrain::calculate(
RigFemScalarResultFrames* e3Frames = RigFemScalarResultFrames* e3Frames =
m_resultCollection->createScalarResult( partIndex, resAddr.copyWithComponent( m_componentNames[2] ) ); m_resultCollection->createScalarResult( partIndex, resAddr.copyWithComponent( m_componentNames[2] ) );
int frameCount = e11Frames->frameCount(); const int timeSteps = e11Frames->timeStepCount();
for ( int fIdx = 0; fIdx < frameCount; ++fIdx ) 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<float>& e11 = e11Frames->frameData( fIdx ); const int frameCount = e11Frames->frameCount( stepIdx );
const std::vector<float>& e22 = e22Frames->frameData( fIdx ); for ( int fIdx = 0; fIdx < frameCount; fIdx++ )
const std::vector<float>& e33 = e33Frames->frameData( fIdx ); {
const std::vector<float>& e12 = e12Frames->frameData( fIdx ); const std::vector<float>& e11 = e11Frames->frameData( stepIdx, fIdx );
const std::vector<float>& e13 = e13Frames->frameData( fIdx ); const std::vector<float>& e22 = e22Frames->frameData( stepIdx, fIdx );
const std::vector<float>& e23 = e23Frames->frameData( fIdx ); const std::vector<float>& e33 = e33Frames->frameData( stepIdx, fIdx );
const std::vector<float>& e12 = e12Frames->frameData( stepIdx, fIdx );
const std::vector<float>& e13 = e13Frames->frameData( stepIdx, fIdx );
const std::vector<float>& e23 = e23Frames->frameData( stepIdx, fIdx );
std::vector<float>& e1 = e1Frames->frameData( fIdx ); std::vector<float>& e1 = e1Frames->frameData( stepIdx, fIdx );
std::vector<float>& e2 = e2Frames->frameData( fIdx ); std::vector<float>& e2 = e2Frames->frameData( stepIdx, fIdx );
std::vector<float>& e3 = e3Frames->frameData( fIdx ); std::vector<float>& e3 = e3Frames->frameData( stepIdx, fIdx );
size_t valCount = e11.size(); size_t valCount = e11.size();
e1.resize( valCount ); e1.resize( valCount );
e2.resize( valCount ); e2.resize( valCount );
e3.resize( valCount ); e3.resize( valCount );
#pragma omp parallel for #pragma omp parallel for
for ( long vIdx = 0; vIdx < static_cast<long>( valCount ); ++vIdx ) for ( long vIdx = 0; vIdx < static_cast<long>( valCount ); ++vIdx )
{ {
caf::Ten3f T( e11[vIdx], e22[vIdx], e33[vIdx], e12[vIdx], e23[vIdx], e13[vIdx] ); caf::Ten3f T( e11[vIdx], e22[vIdx], e33[vIdx], e12[vIdx], e23[vIdx], e13[vIdx] );
cvf::Vec3f principalDirs[3]; cvf::Vec3f principalDirs[3];
cvf::Vec3f principals = T.calculatePrincipals( principalDirs ); cvf::Vec3f principals = T.calculatePrincipals( principalDirs );
e1[vIdx] = principals[0]; e1[vIdx] = principals[0];
e2[vIdx] = principals[1]; e2[vIdx] = principals[1];
e3[vIdx] = principals[2]; e3[vIdx] = principals[2];
}
} }
} }

View File

@ -68,46 +68,46 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorPrincipalStress::calculate(
resVarAddr.componentName == "S2inc" || resVarAddr.componentName == "S2azi" || resVarAddr.componentName == "S2inc" || resVarAddr.componentName == "S2azi" ||
resVarAddr.componentName == "S3inc" || resVarAddr.componentName == "S3azi" ); resVarAddr.componentName == "S3inc" || resVarAddr.componentName == "S3azi" );
caf::ProgressInfo frameCountProgress( m_resultCollection->frameCount() * 7, "" ); caf::ProgressInfo stepCountProgress( m_resultCollection->timeStepCount() * 7, "" );
frameCountProgress.setProgressDescription( stepCountProgress.setProgressDescription(
"Calculating " + QString::fromStdString( resVarAddr.fieldName + ": " + resVarAddr.componentName ) ); "Calculating " + QString::fromStdString( resVarAddr.fieldName + ": " + resVarAddr.componentName ) );
frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() );
RigFemScalarResultFrames* s11Frames = RigFemScalarResultFrames* s11Frames =
m_resultCollection->findOrLoadScalarResult( partIndex, m_resultCollection->findOrLoadScalarResult( partIndex,
RigFemResultAddress( resVarAddr.resultPosType, RigFemResultAddress( resVarAddr.resultPosType,
resVarAddr.fieldName, resVarAddr.fieldName,
"S11" ) ); "S11" ) );
frameCountProgress.incrementProgress(); stepCountProgress.incrementProgress();
frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() );
RigFemScalarResultFrames* s22Frames = RigFemScalarResultFrames* s22Frames =
m_resultCollection->findOrLoadScalarResult( partIndex, m_resultCollection->findOrLoadScalarResult( partIndex,
RigFemResultAddress( resVarAddr.resultPosType, RigFemResultAddress( resVarAddr.resultPosType,
resVarAddr.fieldName, resVarAddr.fieldName,
"S22" ) ); "S22" ) );
frameCountProgress.incrementProgress(); stepCountProgress.incrementProgress();
frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() );
RigFemScalarResultFrames* s33Frames = RigFemScalarResultFrames* s33Frames =
m_resultCollection->findOrLoadScalarResult( partIndex, m_resultCollection->findOrLoadScalarResult( partIndex,
RigFemResultAddress( resVarAddr.resultPosType, RigFemResultAddress( resVarAddr.resultPosType,
resVarAddr.fieldName, resVarAddr.fieldName,
"S33" ) ); "S33" ) );
frameCountProgress.incrementProgress(); stepCountProgress.incrementProgress();
frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() );
RigFemScalarResultFrames* s12Frames = RigFemScalarResultFrames* s12Frames =
m_resultCollection->findOrLoadScalarResult( partIndex, m_resultCollection->findOrLoadScalarResult( partIndex,
RigFemResultAddress( resVarAddr.resultPosType, RigFemResultAddress( resVarAddr.resultPosType,
resVarAddr.fieldName, resVarAddr.fieldName,
"S12" ) ); "S12" ) );
frameCountProgress.incrementProgress(); stepCountProgress.incrementProgress();
frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() );
RigFemScalarResultFrames* s13Frames = RigFemScalarResultFrames* s13Frames =
m_resultCollection->findOrLoadScalarResult( partIndex, m_resultCollection->findOrLoadScalarResult( partIndex,
RigFemResultAddress( resVarAddr.resultPosType, RigFemResultAddress( resVarAddr.resultPosType,
resVarAddr.fieldName, resVarAddr.fieldName,
"S13" ) ); "S13" ) );
frameCountProgress.incrementProgress(); stepCountProgress.incrementProgress();
frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() );
RigFemScalarResultFrames* s23Frames = RigFemScalarResultFrames* s23Frames =
m_resultCollection->findOrLoadScalarResult( partIndex, m_resultCollection->findOrLoadScalarResult( partIndex,
RigFemResultAddress( resVarAddr.resultPosType, RigFemResultAddress( resVarAddr.resultPosType,
@ -143,89 +143,92 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorPrincipalStress::calculate(
m_resultCollection->createScalarResult( partIndex, m_resultCollection->createScalarResult( partIndex,
RigFemResultAddress( resVarAddr.resultPosType, resVarAddr.fieldName, "S3azi" ) ); RigFemResultAddress( resVarAddr.resultPosType, resVarAddr.fieldName, "S3azi" ) );
frameCountProgress.incrementProgress(); stepCountProgress.incrementProgress();
int frameCount = s11Frames->frameCount(); const int timeSteps = s11Frames->timeStepCount();
for ( int fIdx = 0; fIdx < frameCount; ++fIdx ) for ( int stepIdx = 0; stepIdx < timeSteps; stepIdx++ )
{ {
const std::vector<float>& s11 = s11Frames->frameData( fIdx ); const int frameCount = s11Frames->frameCount( stepIdx );
const std::vector<float>& s22 = s22Frames->frameData( fIdx ); for ( int fIdx = 0; fIdx < frameCount; fIdx++ )
const std::vector<float>& s33 = s33Frames->frameData( fIdx ); {
const std::vector<float>& s12 = s12Frames->frameData( fIdx ); const std::vector<float>& s11 = s11Frames->frameData( stepIdx, fIdx );
const std::vector<float>& s13 = s13Frames->frameData( fIdx ); const std::vector<float>& s22 = s22Frames->frameData( stepIdx, fIdx );
const std::vector<float>& s23 = s23Frames->frameData( fIdx ); const std::vector<float>& s33 = s33Frames->frameData( stepIdx, fIdx );
const std::vector<float>& s12 = s12Frames->frameData( stepIdx, fIdx );
const std::vector<float>& s13 = s13Frames->frameData( stepIdx, fIdx );
const std::vector<float>& s23 = s23Frames->frameData( stepIdx, fIdx );
std::vector<float>& s1 = s1Frames->frameData( fIdx ); std::vector<float>& s1 = s1Frames->frameData( stepIdx, fIdx );
std::vector<float>& s2 = s2Frames->frameData( fIdx ); std::vector<float>& s2 = s2Frames->frameData( stepIdx, fIdx );
std::vector<float>& s3 = s3Frames->frameData( fIdx ); std::vector<float>& s3 = s3Frames->frameData( stepIdx, fIdx );
std::vector<float>& s1inc = s1IncFrames->frameData( fIdx ); std::vector<float>& s1inc = s1IncFrames->frameData( stepIdx, fIdx );
std::vector<float>& s1azi = s1AziFrames->frameData( fIdx ); std::vector<float>& s1azi = s1AziFrames->frameData( stepIdx, fIdx );
std::vector<float>& s2inc = s2IncFrames->frameData( fIdx ); std::vector<float>& s2inc = s2IncFrames->frameData( stepIdx, fIdx );
std::vector<float>& s2azi = s2AziFrames->frameData( fIdx ); std::vector<float>& s2azi = s2AziFrames->frameData( stepIdx, fIdx );
std::vector<float>& s3inc = s3IncFrames->frameData( fIdx ); std::vector<float>& s3inc = s3IncFrames->frameData( stepIdx, fIdx );
std::vector<float>& s3azi = s3AziFrames->frameData( fIdx ); std::vector<float>& s3azi = s3AziFrames->frameData( stepIdx, fIdx );
size_t valCount = s11.size(); size_t valCount = s11.size();
s1.resize( valCount ); s1.resize( valCount );
s2.resize( valCount ); s2.resize( valCount );
s3.resize( valCount ); s3.resize( valCount );
s1inc.resize( valCount ); s1inc.resize( valCount );
s1azi.resize( valCount ); s1azi.resize( valCount );
s2inc.resize( valCount ); s2inc.resize( valCount );
s2azi.resize( valCount ); s2azi.resize( valCount );
s3inc.resize( valCount ); s3inc.resize( valCount );
s3azi.resize( valCount ); s3azi.resize( valCount );
#pragma omp parallel for schedule( dynamic ) #pragma omp parallel for schedule( dynamic )
for ( long vIdx = 0; vIdx < static_cast<long>( valCount ); ++vIdx ) for ( long vIdx = 0; vIdx < static_cast<long>( valCount ); ++vIdx )
{ {
caf::Ten3f T( s11[vIdx], s22[vIdx], s33[vIdx], s12[vIdx], s23[vIdx], s13[vIdx] ); caf::Ten3f T( s11[vIdx], s22[vIdx], s33[vIdx], s12[vIdx], s23[vIdx], s13[vIdx] );
cvf::Vec3f principalDirs[3]; cvf::Vec3f principalDirs[3];
cvf::Vec3f principals = T.calculatePrincipals( principalDirs ); cvf::Vec3f principals = T.calculatePrincipals( principalDirs );
s1[vIdx] = principals[0]; s1[vIdx] = principals[0];
s2[vIdx] = principals[1]; s2[vIdx] = principals[1];
s3[vIdx] = principals[2]; s3[vIdx] = principals[2];
if ( principals[0] != std::numeric_limits<float>::infinity() ) if ( principals[0] != std::numeric_limits<float>::infinity() )
{ {
RiaOffshoreSphericalCoords sphCoord1( principalDirs[0] ); RiaOffshoreSphericalCoords sphCoord1( principalDirs[0] );
s1inc[vIdx] = cvf::Math::toDegrees( sphCoord1.inc() ); s1inc[vIdx] = cvf::Math::toDegrees( sphCoord1.inc() );
s1azi[vIdx] = cvf::Math::toDegrees( sphCoord1.azi() ); s1azi[vIdx] = cvf::Math::toDegrees( sphCoord1.azi() );
} }
else else
{ {
s1inc[vIdx] = std::numeric_limits<float>::infinity(); s1inc[vIdx] = std::numeric_limits<float>::infinity();
s1azi[vIdx] = std::numeric_limits<float>::infinity(); s1azi[vIdx] = std::numeric_limits<float>::infinity();
} }
if ( principals[1] != std::numeric_limits<float>::infinity() ) if ( principals[1] != std::numeric_limits<float>::infinity() )
{ {
RiaOffshoreSphericalCoords sphCoord2( principalDirs[1] ); RiaOffshoreSphericalCoords sphCoord2( principalDirs[1] );
s2inc[vIdx] = cvf::Math::toDegrees( sphCoord2.inc() ); s2inc[vIdx] = cvf::Math::toDegrees( sphCoord2.inc() );
s2azi[vIdx] = cvf::Math::toDegrees( sphCoord2.azi() ); s2azi[vIdx] = cvf::Math::toDegrees( sphCoord2.azi() );
} }
else else
{ {
s2inc[vIdx] = std::numeric_limits<float>::infinity(); s2inc[vIdx] = std::numeric_limits<float>::infinity();
s2azi[vIdx] = std::numeric_limits<float>::infinity(); s2azi[vIdx] = std::numeric_limits<float>::infinity();
} }
if ( principals[2] != std::numeric_limits<float>::infinity() ) if ( principals[2] != std::numeric_limits<float>::infinity() )
{ {
RiaOffshoreSphericalCoords sphCoord3( principalDirs[2] ); RiaOffshoreSphericalCoords sphCoord3( principalDirs[2] );
s3inc[vIdx] = cvf::Math::toDegrees( sphCoord3.inc() ); s3inc[vIdx] = cvf::Math::toDegrees( sphCoord3.inc() );
s3azi[vIdx] = cvf::Math::toDegrees( sphCoord3.azi() ); s3azi[vIdx] = cvf::Math::toDegrees( sphCoord3.azi() );
} }
else else
{ {
s3inc[vIdx] = std::numeric_limits<float>::infinity(); s3inc[vIdx] = std::numeric_limits<float>::infinity();
s3azi[vIdx] = std::numeric_limits<float>::infinity(); s3azi[vIdx] = std::numeric_limits<float>::infinity();
}
} }
} }
stepCountProgress.incrementProgress();
frameCountProgress.incrementProgress();
} }
RigFemScalarResultFrames* requestedPrincipal = m_resultCollection->findOrLoadScalarResult( partIndex, resVarAddr ); RigFemScalarResultFrames* requestedPrincipal = m_resultCollection->findOrLoadScalarResult( partIndex, resVarAddr );

View File

@ -58,56 +58,59 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorQ::calculate( int partIndex,
{ {
CVF_ASSERT( resVarAddr.fieldName == "ST" && resVarAddr.componentName == "Q" ); CVF_ASSERT( resVarAddr.fieldName == "ST" && resVarAddr.componentName == "Q" );
caf::ProgressInfo frameCountProgress( m_resultCollection->frameCount() * 5, "" ); caf::ProgressInfo stepCountProgress( m_resultCollection->timeStepCount() * 5, "" );
frameCountProgress.setProgressDescription( stepCountProgress.setProgressDescription(
"Calculating " + QString::fromStdString( resVarAddr.fieldName + ": " + resVarAddr.componentName ) ); "Calculating " + QString::fromStdString( resVarAddr.fieldName + ": " + resVarAddr.componentName ) );
frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() );
RigFemScalarResultFrames* st11 = RigFemScalarResultFrames* st11 =
m_resultCollection->findOrLoadScalarResult( partIndex, RigFemResultAddress( resVarAddr.resultPosType, "ST", "S1" ) ); m_resultCollection->findOrLoadScalarResult( partIndex, RigFemResultAddress( resVarAddr.resultPosType, "ST", "S1" ) );
frameCountProgress.incrementProgress(); stepCountProgress.incrementProgress();
frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() );
RigFemScalarResultFrames* st22 = RigFemScalarResultFrames* st22 =
m_resultCollection->findOrLoadScalarResult( partIndex, RigFemResultAddress( resVarAddr.resultPosType, "ST", "S2" ) ); m_resultCollection->findOrLoadScalarResult( partIndex, RigFemResultAddress( resVarAddr.resultPosType, "ST", "S2" ) );
frameCountProgress.incrementProgress(); stepCountProgress.incrementProgress();
frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() );
RigFemScalarResultFrames* st33 = RigFemScalarResultFrames* st33 =
m_resultCollection->findOrLoadScalarResult( partIndex, RigFemResultAddress( resVarAddr.resultPosType, "ST", "S3" ) ); m_resultCollection->findOrLoadScalarResult( partIndex, RigFemResultAddress( resVarAddr.resultPosType, "ST", "S3" ) );
frameCountProgress.incrementProgress(); stepCountProgress.incrementProgress();
frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() );
RigFemScalarResultFrames* stm = RigFemScalarResultFrames* stm =
m_resultCollection->findOrLoadScalarResult( partIndex, RigFemResultAddress( resVarAddr.resultPosType, "ST", "SM" ) ); m_resultCollection->findOrLoadScalarResult( partIndex, RigFemResultAddress( resVarAddr.resultPosType, "ST", "SM" ) );
RigFemScalarResultFrames* dstDataFrames = m_resultCollection->createScalarResult( partIndex, resVarAddr ); RigFemScalarResultFrames* dstDataFrames = m_resultCollection->createScalarResult( partIndex, resVarAddr );
frameCountProgress.incrementProgress(); stepCountProgress.incrementProgress();
int frameCount = st11->frameCount(); const int timeSteps = st11->timeStepCount();
for ( int fIdx = 0; fIdx < frameCount; ++fIdx ) for ( int stepIdx = 0; stepIdx < timeSteps; stepIdx++ )
{ {
const std::vector<float>& st11Data = st11->frameData( fIdx ); const int frameCount = st11->frameCount( stepIdx );
const std::vector<float>& st22Data = st22->frameData( fIdx ); for ( int fIdx = 0; fIdx < frameCount; fIdx++ )
const std::vector<float>& st33Data = st33->frameData( fIdx ); {
const std::vector<float>& st11Data = st11->frameData( stepIdx, fIdx );
const std::vector<float>& st22Data = st22->frameData( stepIdx, fIdx );
const std::vector<float>& st33Data = st33->frameData( stepIdx, fIdx );
const std::vector<float>& stmData = stm->frameData( fIdx ); const std::vector<float>& stmData = stm->frameData( stepIdx, fIdx );
std::vector<float>& dstFrameData = dstDataFrames->frameData( fIdx ); std::vector<float>& dstFrameData = dstDataFrames->frameData( stepIdx, fIdx );
size_t valCount = st11Data.size(); size_t valCount = st11Data.size();
dstFrameData.resize( valCount ); dstFrameData.resize( valCount );
#pragma omp parallel for #pragma omp parallel for
for ( long vIdx = 0; vIdx < static_cast<long>( valCount ); ++vIdx ) for ( long vIdx = 0; vIdx < static_cast<long>( valCount ); ++vIdx )
{ {
float stmVal = stmData[vIdx]; float stmVal = stmData[vIdx];
float st11Corr = st11Data[vIdx] - stmVal; float st11Corr = st11Data[vIdx] - stmVal;
float st22Corr = st22Data[vIdx] - stmVal; float st22Corr = st22Data[vIdx] - stmVal;
float st33Corr = st33Data[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 ) );
}
} }
stepCountProgress.incrementProgress();
frameCountProgress.incrementProgress();
} }
return dstDataFrames; return dstDataFrames;

View File

@ -60,10 +60,10 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorSFI::calculate( int partInde
QString progressText = "Calculating " + QString::fromStdString( resAddr.fieldName + ": " + resAddr.componentName ); QString progressText = "Calculating " + QString::fromStdString( resAddr.fieldName + ": " + resAddr.componentName );
caf::ProgressInfo frameCountProgress( static_cast<size_t>( m_resultCollection->frameCount() ) * 3, progressText ); caf::ProgressInfo stepCountProgress( static_cast<size_t>( m_resultCollection->timeStepCount() ) * 3, progressText );
auto loadFrameLambda = [&]( const QString& component ) { 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() ) ); 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)( m_resultCollection->parameterCohesion() / tan( m_resultCollection->parameterFrictionAngleRad() ) );
float sinFricAng = sin( m_resultCollection->parameterFrictionAngleRad() ); float sinFricAng = sin( m_resultCollection->parameterFrictionAngleRad() );
int frameCount = se1Frames->frameCount(); const int timeSteps = se1Frames->timeStepCount();
for ( int fIdx = 0; fIdx < frameCount; ++fIdx ) 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<float>& se1Data = se1Frames->frameData( fIdx ); const int frameCount = se1Frames->frameCount( stepIdx );
const std::vector<float>& se3Data = se3Frames->frameData( fIdx ); for ( int fIdx = 0; fIdx < frameCount; fIdx++ )
{
const std::vector<float>& se1Data = se1Frames->frameData( stepIdx, fIdx );
const std::vector<float>& se3Data = se3Frames->frameData( stepIdx, fIdx );
std::vector<float>& dstFrameData = dstDataFrames->frameData( fIdx ); std::vector<float>& dstFrameData = dstDataFrames->frameData( stepIdx, fIdx );
size_t valCount = se1Data.size(); size_t valCount = se1Data.size();
dstFrameData.resize( valCount ); dstFrameData.resize( valCount );
#pragma omp parallel for #pragma omp parallel for
for ( long vIdx = 0; vIdx < static_cast<long>( valCount ); ++vIdx ) for ( long vIdx = 0; vIdx < static_cast<long>( valCount ); ++vIdx )
{ {
float se1 = se1Data[vIdx]; float se1 = se1Data[vIdx];
float se3 = se3Data[vIdx]; float se3 = se3Data[vIdx];
float se1Se3Diff = se1 - se3; float se1Se3Diff = se1 - se3;
if ( fabs( se1Se3Diff ) < 1e-7 ) if ( fabs( se1Se3Diff ) < 1e-7 )
{ {
dstFrameData[vIdx] = std::numeric_limits<float>::infinity(); dstFrameData[vIdx] = std::numeric_limits<float>::infinity();
} }
else else
{ {
dstFrameData[vIdx] = ( ( cohPrFricAngle + 0.5 * ( se1Data[vIdx] + se3Data[vIdx] ) ) * sinFricAng ) / dstFrameData[vIdx] = ( ( cohPrFricAngle + 0.5 * ( se1Data[vIdx] + se3Data[vIdx] ) ) * sinFricAng ) /
( 0.5 * ( se1Data[vIdx] - se3Data[vIdx] ) ); ( 0.5 * ( se1Data[vIdx] - se3Data[vIdx] ) );
}
} }
} }
} }
return dstDataFrames; return dstDataFrames;
} }

View File

@ -61,10 +61,10 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorSM::calculate( int partIndex
QString progressText = "Calculating " + QString progressText = "Calculating " +
QString::fromStdString( resVarAddr.fieldName + ": " + resVarAddr.componentName ); QString::fromStdString( resVarAddr.fieldName + ": " + resVarAddr.componentName );
caf::ProgressInfo frameCountProgress( static_cast<size_t>( m_resultCollection->frameCount() ) * 4, progressText ); caf::ProgressInfo stepCountProgress( static_cast<size_t>( m_resultCollection->timeStepCount() ) * 4, progressText );
auto loadFrameLambda = [&]( const QString& component ) { auto loadFrameLambda = [&]( const QString& component ) {
auto task = frameCountProgress.task( component ); auto task = stepCountProgress.task( component );
return m_resultCollection->findOrLoadScalarResult( partIndex, return m_resultCollection->findOrLoadScalarResult( partIndex,
resVarAddr.copyWithComponent( component.toStdString() ) ); resVarAddr.copyWithComponent( component.toStdString() ) );
}; };
@ -75,25 +75,28 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorSM::calculate( int partIndex
RigFemScalarResultFrames* dstDataFrames = m_resultCollection->createScalarResult( partIndex, resVarAddr ); RigFemScalarResultFrames* dstDataFrames = m_resultCollection->createScalarResult( partIndex, resVarAddr );
int frameCount = st11->frameCount(); const int timeSteps = st11->timeStepCount();
for ( int fIdx = 0; fIdx < frameCount; ++fIdx ) 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<float>& st11Data = st11->frameData( fIdx ); const int frameCount = st11->frameCount( stepIdx );
const std::vector<float>& st22Data = st22->frameData( fIdx ); for ( int fIdx = 0; fIdx < frameCount; fIdx++ )
const std::vector<float>& st33Data = st33->frameData( fIdx ); {
const std::vector<float>& st11Data = st11->frameData( stepIdx, fIdx );
const std::vector<float>& st22Data = st22->frameData( stepIdx, fIdx );
const std::vector<float>& st33Data = st33->frameData( stepIdx, fIdx );
std::vector<float>& dstFrameData = dstDataFrames->frameData( fIdx ); std::vector<float>& dstFrameData = dstDataFrames->frameData( stepIdx, fIdx );
size_t valCount = st11Data.size(); size_t valCount = st11Data.size();
dstFrameData.resize( valCount ); dstFrameData.resize( valCount );
#pragma omp parallel for #pragma omp parallel for
for ( long vIdx = 0; vIdx < static_cast<long>( valCount ); ++vIdx ) for ( long vIdx = 0; vIdx < static_cast<long>( valCount ); ++vIdx )
{ {
dstFrameData[vIdx] = ( st11Data[vIdx] + st22Data[vIdx] + st33Data[vIdx] ) / 3.0f; dstFrameData[vIdx] = ( st11Data[vIdx] + st22Data[vIdx] + st33Data[vIdx] ) / 3.0f;
}
} }
} }
return dstDataFrames; return dstDataFrames;
} }

View File

@ -59,13 +59,13 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorShearSE::calculate( int part
{ {
QString progressText = "Calculating " + QString::fromStdString( resAddr.fieldName + ": " + resAddr.componentName ); QString progressText = "Calculating " + QString::fromStdString( resAddr.fieldName + ": " + resAddr.componentName );
caf::ProgressInfo frameCountProgress( static_cast<size_t>( m_resultCollection->frameCount() ) * 2, progressText ); caf::ProgressInfo stepCountProgress( static_cast<size_t>( m_resultCollection->timeStepCount() ) * 2, progressText );
RigFemScalarResultFrames* dstDataFrames = m_resultCollection->createScalarResult( partIndex, resAddr ); RigFemScalarResultFrames* dstDataFrames = m_resultCollection->createScalarResult( partIndex, resAddr );
RigFemScalarResultFrames* srcDataFrames = nullptr; 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, srcDataFrames = m_resultCollection->findOrLoadScalarResult( partIndex,
RigFemResultAddress( resAddr.resultPosType, RigFemResultAddress( resAddr.resultPosType,
"S-Bar", "S-Bar",
@ -73,52 +73,54 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorShearSE::calculate( int part
} }
const RigFemPart* femPart = m_resultCollection->parts()->part( partIndex ); const RigFemPart* femPart = m_resultCollection->parts()->part( partIndex );
float inf = std::numeric_limits<float>::infinity(); constexpr float inf = std::numeric_limits<float>::infinity();
int frameCount = srcDataFrames->frameCount(); const int timeSteps = srcDataFrames->timeStepCount();
for ( int stepIdx = 0; stepIdx < timeSteps; stepIdx++ )
for ( int fIdx = 0; fIdx < frameCount; ++fIdx )
{ {
auto task = frameCountProgress.task( QString( "Frame %1" ).arg( fIdx ) ); auto task = stepCountProgress.task( QString( "Step %1" ).arg( stepIdx ) );
const std::vector<float>& srcSFrameData = srcDataFrames->frameData( fIdx ); const int frameCount = srcDataFrames->frameCount( stepIdx );
std::vector<float>& dstFrameData = dstDataFrames->frameData( fIdx ); for ( int fIdx = 0; fIdx < frameCount; fIdx++ )
size_t valCount = srcSFrameData.size(); {
dstFrameData.resize( valCount ); const std::vector<float>& srcSFrameData = srcDataFrames->frameData( stepIdx, fIdx );
std::vector<float>& 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 #pragma omp parallel for
for ( int elmIdx = 0; elmIdx < elementCount; ++elmIdx ) for ( int elmIdx = 0; elmIdx < elementCount; ++elmIdx )
{
RigElementType elmType = femPart->elementType( elmIdx );
int elmNodeCount = RigFemTypes::elementNodeCount( femPart->elementType( elmIdx ) );
if ( elmType == HEX8P )
{ {
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 ); for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx )
if ( elmNodResIdx < srcSFrameData.size() )
{ {
dstFrameData[elmNodResIdx] = -srcSFrameData[elmNodResIdx]; size_t elmNodResIdx = femPart->elementNodeResultIdx( elmIdx, elmNodIdx );
if ( elmNodResIdx < srcSFrameData.size() )
{
dstFrameData[elmNodResIdx] = -srcSFrameData[elmNodResIdx];
}
} }
} }
} else
else
{
for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx )
{ {
size_t elmNodResIdx = femPart->elementNodeResultIdx( elmIdx, elmNodIdx ); for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx )
if ( elmNodResIdx < dstFrameData.size() )
{ {
dstFrameData[elmNodResIdx] = inf; size_t elmNodResIdx = femPart->elementNodeResultIdx( elmIdx, elmNodIdx );
if ( elmNodResIdx < dstFrameData.size() )
{
dstFrameData[elmNodResIdx] = inf;
}
} }
} }
} }
} }
} }
return dstDataFrames; return dstDataFrames;
} }

View File

@ -57,10 +57,10 @@ bool RigFemPartResultCalculatorShearST::isMatching( const RigFemResultAddress& r
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RigFemScalarResultFrames* RigFemPartResultCalculatorShearST::calculate( int partIndex, const RigFemResultAddress& resVarAddr ) RigFemScalarResultFrames* RigFemPartResultCalculatorShearST::calculate( int partIndex, const RigFemResultAddress& resVarAddr )
{ {
caf::ProgressInfo frameCountProgress( m_resultCollection->frameCount() * 2, "" ); caf::ProgressInfo stepCountProgress( m_resultCollection->timeStepCount() * 2, "" );
frameCountProgress.setProgressDescription( stepCountProgress.setProgressDescription(
"Calculating " + QString::fromStdString( resVarAddr.fieldName + ": " + resVarAddr.componentName ) ); "Calculating " + QString::fromStdString( resVarAddr.fieldName + ": " + resVarAddr.componentName ) );
frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() );
RigFemScalarResultFrames* srcSDataFrames = RigFemScalarResultFrames* srcSDataFrames =
m_resultCollection->findOrLoadScalarResult( partIndex, m_resultCollection->findOrLoadScalarResult( partIndex,
@ -69,24 +69,27 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorShearST::calculate( int part
resVarAddr.componentName ) ); resVarAddr.componentName ) );
RigFemScalarResultFrames* dstDataFrames = m_resultCollection->createScalarResult( partIndex, resVarAddr ); RigFemScalarResultFrames* dstDataFrames = m_resultCollection->createScalarResult( partIndex, resVarAddr );
frameCountProgress.incrementProgress(); stepCountProgress.incrementProgress();
int frameCount = srcSDataFrames->frameCount(); const int timeSteps = srcSDataFrames->timeStepCount();
for ( int fIdx = 0; fIdx < frameCount; ++fIdx ) for ( int stepIdx = 0; stepIdx < timeSteps; stepIdx++ )
{ {
const std::vector<float>& srcSFrameData = srcSDataFrames->frameData( fIdx ); const int frameCount = srcSDataFrames->frameCount( stepIdx );
std::vector<float>& dstFrameData = dstDataFrames->frameData( fIdx ); for ( int fIdx = 0; fIdx < frameCount; fIdx++ )
{
const std::vector<float>& srcSFrameData = srcSDataFrames->frameData( stepIdx, fIdx );
std::vector<float>& dstFrameData = dstDataFrames->frameData( stepIdx, fIdx );
size_t valCount = srcSFrameData.size(); size_t valCount = srcSFrameData.size();
dstFrameData.resize( valCount ); dstFrameData.resize( valCount );
#pragma omp parallel for #pragma omp parallel for
for ( long vIdx = 0; vIdx < static_cast<long>( valCount ); ++vIdx ) for ( long vIdx = 0; vIdx < static_cast<long>( valCount ); ++vIdx )
{ {
dstFrameData[vIdx] = -srcSFrameData[vIdx]; dstFrameData[vIdx] = -srcSFrameData[vIdx];
}
} }
stepCountProgress.incrementProgress();
frameCountProgress.incrementProgress();
} }
return dstDataFrames; return dstDataFrames;

View File

@ -61,24 +61,24 @@ RigFemScalarResultFrames*
{ {
CVF_ASSERT( isMatching( resVarAddr ) ); CVF_ASSERT( isMatching( resVarAddr ) );
caf::ProgressInfo frameCountProgress( m_resultCollection->frameCount() * 3, "" ); caf::ProgressInfo stepCountProgress( m_resultCollection->timeStepCount() * 3, "" );
frameCountProgress.setProgressDescription( "Calculating Shear Slip Indicator." ); stepCountProgress.setProgressDescription( "Calculating Shear Slip Indicator." );
// Pore pressure // Pore pressure
frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() );
RigFemScalarResultFrames* porePressureDataFrames = RigFemScalarResultFrames* porePressureDataFrames =
m_resultCollection->findOrLoadScalarResult( partIndex, m_resultCollection->findOrLoadScalarResult( partIndex,
RigFemResultAddress( resVarAddr.resultPosType, "POR-Bar", "" ) ); RigFemResultAddress( resVarAddr.resultPosType, "POR-Bar", "" ) );
frameCountProgress.incrementProgress(); stepCountProgress.incrementProgress();
// Total vertical stress (ST.S33) // Total vertical stress (ST.S33)
frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() );
RigFemScalarResultFrames* stressDataFrames = RigFemScalarResultFrames* stressDataFrames =
m_resultCollection->findOrLoadScalarResult( partIndex, m_resultCollection->findOrLoadScalarResult( partIndex,
RigFemResultAddress( resVarAddr.resultPosType, "ST", "S33" ) ); RigFemResultAddress( resVarAddr.resultPosType, "ST", "S33" ) );
frameCountProgress.incrementProgress(); stepCountProgress.incrementProgress();
frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() );
RigFemScalarResultFrames* shearSlipIndicatorFrames = RigFemScalarResultFrames* shearSlipIndicatorFrames =
m_resultCollection->createScalarResult( partIndex, RigFemResultAddress( resVarAddr.resultPosType, "ST", "DPN" ) ); m_resultCollection->createScalarResult( partIndex, RigFemResultAddress( resVarAddr.resultPosType, "ST", "DPN" ) );
@ -88,76 +88,79 @@ RigFemScalarResultFrames*
float inf = std::numeric_limits<float>::infinity(); float inf = std::numeric_limits<float>::infinity();
frameCountProgress.setNextProgressIncrement( 1u ); stepCountProgress.setNextProgressIncrement( 1u );
int frameCount = stressDataFrames->frameCount(); const int timeSteps = stressDataFrames->timeStepCount();
for ( int fIdx = 0; fIdx < frameCount; ++fIdx ) for ( int stepIdx = 0; stepIdx < timeSteps; stepIdx++ )
{ {
const std::vector<float>& porFrameData = porePressureDataFrames->frameData( fIdx ); const int frameCount = stressDataFrames->frameCount( stepIdx );
if ( porFrameData.empty() ) continue; for ( int fIdx = 0; fIdx < frameCount; fIdx++ )
{
const std::vector<float>& porFrameData = porePressureDataFrames->frameData( stepIdx, fIdx );
if ( porFrameData.empty() ) continue;
const std::vector<float>& stressFrameData = stressDataFrames->frameData( fIdx ); const std::vector<float>& stressFrameData = stressDataFrames->frameData( stepIdx, fIdx );
if ( stressFrameData.empty() ) continue; if ( stressFrameData.empty() ) continue;
std::vector<float>& shearSlipIndicatorFrameData = shearSlipIndicatorFrames->frameData( fIdx ); std::vector<float>& shearSlipIndicatorFrameData = shearSlipIndicatorFrames->frameData( stepIdx, fIdx );
size_t valCount = stressFrameData.size(); size_t valCount = stressFrameData.size();
shearSlipIndicatorFrameData.resize( valCount ); shearSlipIndicatorFrameData.resize( valCount );
int elementCount = femPart->elementCount(); int elementCount = femPart->elementCount();
#pragma omp parallel for #pragma omp parallel for
for ( int elmIdx = 0; elmIdx < elementCount; ++elmIdx ) 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 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. for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx )
// 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() )
{ {
// Pore pressure (unit: Bar) // Use hydrostatic pressure from cell centroid.
float porePressureBar = porFrameData[elmNodResIdx]; // Use centroid to avoid intra-element differences
float totalVerticalStress = stressFrameData[elmNodResIdx]; cvf::Vec3d cellCentroid = femPartGrid->cellCentroid( elmIdx );
double cellCentroidTvdMSL = -cellCentroid.z();
float shearSlipIndicator = inf; double waterDensity = m_resultCollection->waterDensityShearSlipIndicator();
if ( porePressureBar != inf && totalVerticalStress - cellCenterHydroStaticPressure != 0.0 ) double cellCenterHydroStaticPressure =
RigGeoMechWellLogExtractor::hydroStaticPorePressureAtDepth( cellCentroidTvdMSL, waterDensity );
size_t elmNodResIdx = femPart->elementNodeResultIdx( elmIdx, elmNodIdx );
if ( elmNodResIdx < stressFrameData.size() )
{ {
shearSlipIndicator = ( porePressureBar - cellCenterHydroStaticPressure ) / // Pore pressure (unit: Bar)
( totalVerticalStress - cellCenterHydroStaticPressure ); 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
else
{
for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx )
{ {
size_t elmNodResIdx = femPart->elementNodeResultIdx( elmIdx, elmNodIdx ); for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx )
if ( elmNodResIdx < stressFrameData.size() )
{ {
shearSlipIndicatorFrameData[elmNodResIdx] = inf; size_t elmNodResIdx = femPart->elementNodeResultIdx( elmIdx, elmNodIdx );
if ( elmNodResIdx < stressFrameData.size() )
{
shearSlipIndicatorFrameData[elmNodResIdx] = inf;
}
} }
} }
} }
} }
stepCountProgress.incrementProgress();
frameCountProgress.incrementProgress();
} }
RigFemScalarResultFrames* requestedResultFrames = m_resultCollection->findOrLoadScalarResult( partIndex, resVarAddr ); RigFemScalarResultFrames* requestedResultFrames = m_resultCollection->findOrLoadScalarResult( partIndex, resVarAddr );

View File

@ -59,13 +59,13 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorStressAnisotropy::calculate(
{ {
CVF_ASSERT( isMatching( resVarAddr ) ); CVF_ASSERT( isMatching( resVarAddr ) );
caf::ProgressInfo frameCountProgress( m_resultCollection->frameCount() * 4, "" ); caf::ProgressInfo stepCountProgress( m_resultCollection->timeStepCount() * 4, "" );
frameCountProgress.setProgressDescription( stepCountProgress.setProgressDescription(
"Calculating " + QString::fromStdString( resVarAddr.fieldName + ": " + resVarAddr.componentName ) ); "Calculating " + QString::fromStdString( resVarAddr.fieldName + ": " + resVarAddr.componentName ) );
RigFemScalarResultFrames* s1Frames = nullptr; 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, s1Frames = m_resultCollection->findOrLoadScalarResult( partIndex,
RigFemResultAddress( resVarAddr.resultPosType, RigFemResultAddress( resVarAddr.resultPosType,
resVarAddr.fieldName, resVarAddr.fieldName,
@ -74,7 +74,7 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorStressAnisotropy::calculate(
RigFemScalarResultFrames* s2Frames = nullptr; 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, s2Frames = m_resultCollection->findOrLoadScalarResult( partIndex,
RigFemResultAddress( resVarAddr.resultPosType, RigFemResultAddress( resVarAddr.resultPosType,
resVarAddr.fieldName, resVarAddr.fieldName,
@ -83,7 +83,7 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorStressAnisotropy::calculate(
RigFemScalarResultFrames* s3Frames = nullptr; 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, s3Frames = m_resultCollection->findOrLoadScalarResult( partIndex,
RigFemResultAddress( resVarAddr.resultPosType, RigFemResultAddress( resVarAddr.resultPosType,
resVarAddr.fieldName, resVarAddr.fieldName,
@ -100,34 +100,37 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorStressAnisotropy::calculate(
m_resultCollection->createScalarResult( partIndex, m_resultCollection->createScalarResult( partIndex,
RigFemResultAddress( resVarAddr.resultPosType, resVarAddr.fieldName, "SA23" ) ); RigFemResultAddress( resVarAddr.resultPosType, resVarAddr.fieldName, "SA23" ) );
int frameCount = s1Frames->frameCount(); const int timeSteps = s1Frames->timeStepCount();
for ( int fIdx = 0; fIdx < frameCount; ++fIdx ) 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<float>& s1 = s1Frames->frameData( fIdx ); const int frameCount = s1Frames->frameCount( stepIdx );
const std::vector<float>& s2 = s2Frames->frameData( fIdx ); for ( int fIdx = 0; fIdx < frameCount; fIdx++ )
const std::vector<float>& s3 = s3Frames->frameData( fIdx ); {
const std::vector<float>& s1 = s1Frames->frameData( stepIdx, fIdx );
const std::vector<float>& s2 = s2Frames->frameData( stepIdx, fIdx );
const std::vector<float>& s3 = s3Frames->frameData( stepIdx, fIdx );
std::vector<float>& s12 = s12Frames->frameData( fIdx ); std::vector<float>& s12 = s12Frames->frameData( stepIdx, fIdx );
std::vector<float>& s13 = s13Frames->frameData( fIdx ); std::vector<float>& s13 = s13Frames->frameData( stepIdx, fIdx );
std::vector<float>& s23 = s23Frames->frameData( fIdx ); std::vector<float>& s23 = s23Frames->frameData( stepIdx, fIdx );
size_t valCount = s1.size(); size_t valCount = s1.size();
s12.resize( valCount ); s12.resize( valCount );
s13.resize( valCount ); s13.resize( valCount );
s23.resize( valCount ); s23.resize( valCount );
#pragma omp parallel for schedule( dynamic ) #pragma omp parallel for schedule( dynamic )
for ( long vIdx = 0; vIdx < static_cast<long>( valCount ); ++vIdx ) for ( long vIdx = 0; vIdx < static_cast<long>( valCount ); ++vIdx )
{ {
s12[vIdx] = 2.0 * ( s1[vIdx] - s2[vIdx] ) / ( s1[vIdx] + s2[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] ); s13[vIdx] = 2.0 * ( s1[vIdx] - s3[vIdx] ) / ( s1[vIdx] + s3[vIdx] );
s23[vIdx] = 2.0 * ( s2[vIdx] - s3[vIdx] ) / ( s2[vIdx] + s3[vIdx] ); s23[vIdx] = 2.0 * ( s2[vIdx] - s3[vIdx] ) / ( s2[vIdx] + s3[vIdx] );
}
} }
} }
RigFemScalarResultFrames* requestedStress = m_resultCollection->findOrLoadScalarResult( partIndex, resVarAddr ); RigFemScalarResultFrames* requestedStress = m_resultCollection->findOrLoadScalarResult( partIndex, resVarAddr );
return requestedStress; return requestedStress;
} }
@ -140,13 +143,13 @@ RigFemScalarResultFrames*
{ {
CVF_ASSERT( isMatching( resVarAddr ) ); CVF_ASSERT( isMatching( resVarAddr ) );
caf::ProgressInfo frameCountProgress( m_resultCollection->frameCount() * 4, "" ); caf::ProgressInfo stepCountProgress( m_resultCollection->timeStepCount() * 4, "" );
frameCountProgress.setProgressDescription( stepCountProgress.setProgressDescription(
"Calculating " + QString::fromStdString( resVarAddr.fieldName + ": " + resVarAddr.componentName ) ); "Calculating " + QString::fromStdString( resVarAddr.fieldName + ": " + resVarAddr.componentName ) );
RigFemScalarResultFrames* s1Frames = nullptr; 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, s1Frames = m_resultCollection->findOrLoadScalarResult( partIndex,
RigFemResultAddress( resVarAddr.resultPosType, RigFemResultAddress( resVarAddr.resultPosType,
resVarAddr.fieldName, resVarAddr.fieldName,
@ -155,7 +158,7 @@ RigFemScalarResultFrames*
RigFemScalarResultFrames* s2Frames = nullptr; 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, s2Frames = m_resultCollection->findOrLoadScalarResult( partIndex,
RigFemResultAddress( resVarAddr.resultPosType, RigFemResultAddress( resVarAddr.resultPosType,
resVarAddr.fieldName, resVarAddr.fieldName,
@ -164,7 +167,7 @@ RigFemScalarResultFrames*
RigFemScalarResultFrames* s3Frames = nullptr; 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, s3Frames = m_resultCollection->findOrLoadScalarResult( partIndex,
RigFemResultAddress( resVarAddr.resultPosType, RigFemResultAddress( resVarAddr.resultPosType,
resVarAddr.fieldName, resVarAddr.fieldName,
@ -190,59 +193,64 @@ RigFemScalarResultFrames*
"SA23", "SA23",
resVarAddr.timeLapseBaseStepIdx ) ); resVarAddr.timeLapseBaseStepIdx ) );
float inf = std::numeric_limits<float>::infinity(); constexpr float inf = std::numeric_limits<float>::infinity();
int frameCount = s1Frames->frameCount(); int baseTimeStep, baseFrame;
int baseTimeStep = resVarAddr.timeLapseBaseStepIdx; 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<float>& s1t = s1Frames->frameData( fIdx ); const int frameCount = s1Frames->frameCount( stepIdx );
const std::vector<float>& s2t = s2Frames->frameData( fIdx ); for ( int fIdx = 0; fIdx < frameCount; fIdx++ )
const std::vector<float>& s3t = s3Frames->frameData( fIdx );
const std::vector<float>& s1b = s1Frames->frameData( baseTimeStep );
const std::vector<float>& s2b = s2Frames->frameData( baseTimeStep );
const std::vector<float>& s3b = s3Frames->frameData( baseTimeStep );
std::vector<float>& s12 = s12Frames->frameData( fIdx );
std::vector<float>& s13 = s13Frames->frameData( fIdx );
std::vector<float>& 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<long>( valCount ); ++vIdx )
{ {
if ( fIdx != baseTimeStep ) const std::vector<float>& s1t = s1Frames->frameData( stepIdx, fIdx );
const std::vector<float>& s2t = s2Frames->frameData( stepIdx, fIdx );
const std::vector<float>& s3t = s3Frames->frameData( stepIdx, fIdx );
const std::vector<float>& s1b = s1Frames->frameData( baseTimeStep, baseFrame );
const std::vector<float>& s2b = s2Frames->frameData( baseTimeStep, baseFrame );
const std::vector<float>& s3b = s3Frames->frameData( baseTimeStep, baseFrame );
std::vector<float>& s12 = s12Frames->frameData( stepIdx, fIdx );
std::vector<float>& s13 = s13Frames->frameData( stepIdx, fIdx );
std::vector<float>& 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<long>( valCount ); ++vIdx )
{ {
double diffS1 = s1t[vIdx] - s1b[vIdx]; if ( fIdx != baseTimeStep )
double diffS2 = s2t[vIdx] - s2b[vIdx]; {
double diffS3 = s3t[vIdx] - s3b[vIdx]; double diffS1 = s1t[vIdx] - s1b[vIdx];
if ( std::abs( diffS1 + diffS2 ) > epsilon ) double diffS2 = s2t[vIdx] - s2b[vIdx];
s12[vIdx] = 2.0 * ( diffS1 - diffS2 ) / ( diffS1 + diffS2 ); double diffS3 = s3t[vIdx] - s3b[vIdx];
else if ( std::abs( diffS1 + diffS2 ) > epsilon )
s12[vIdx] = inf; s12[vIdx] = 2.0 * ( diffS1 - diffS2 ) / ( diffS1 + diffS2 );
else
s12[vIdx] = inf;
if ( std::abs( diffS1 + diffS3 ) > epsilon ) if ( std::abs( diffS1 + diffS3 ) > epsilon )
s13[vIdx] = 2.0 * ( diffS1 - diffS3 ) / ( diffS1 + diffS3 ); s13[vIdx] = 2.0 * ( diffS1 - diffS3 ) / ( diffS1 + diffS3 );
else else
s13[vIdx] = inf; s13[vIdx] = inf;
if ( std::abs( diffS2 + diffS3 ) > epsilon ) if ( std::abs( diffS2 + diffS3 ) > epsilon )
s23[vIdx] = 2.0 * ( diffS2 - diffS3 ) / ( diffS2 + diffS3 ); s23[vIdx] = 2.0 * ( diffS2 - diffS3 ) / ( diffS2 + diffS3 );
else else
s23[vIdx] = inf; s23[vIdx] = inf;
}
} }
} }
} }
RigFemScalarResultFrames* requestedStress = m_resultCollection->findOrLoadScalarResult( partIndex, resVarAddr ); RigFemScalarResultFrames* requestedStress = m_resultCollection->findOrLoadScalarResult( partIndex, resVarAddr );
return requestedStress; return requestedStress;
} }

View File

@ -74,10 +74,10 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorStressGradients::calculate(
{ {
CVF_ASSERT( resVarAddr.fieldName == "ST" || resVarAddr.fieldName == "SE" ); CVF_ASSERT( resVarAddr.fieldName == "ST" || resVarAddr.fieldName == "SE" );
caf::ProgressInfo frameCountProgress( m_resultCollection->frameCount() * 2, "" ); caf::ProgressInfo stepCountProgress( m_resultCollection->timeStepCount() * 2, "" );
frameCountProgress.setProgressDescription( stepCountProgress.setProgressDescription(
"Calculating gradient: " + QString::fromStdString( resVarAddr.fieldName + ": " + resVarAddr.componentName ) ); "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 origFieldName = QString::fromStdString( resVarAddr.fieldName );
QString origComponentName = QString::fromStdString( resVarAddr.componentName ); QString origComponentName = QString::fromStdString( resVarAddr.componentName );
@ -105,64 +105,67 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorStressGradients::calculate(
RigFemResultAddress( resVarAddr.resultPosType, RigFemResultAddress( resVarAddr.resultPosType,
resVarAddr.fieldName, resVarAddr.fieldName,
componentName.toStdString() + "-Z" ) ); componentName.toStdString() + "-Z" ) );
frameCountProgress.incrementProgress(); stepCountProgress.incrementProgress();
const RigFemPart* femPart = m_resultCollection->parts()->part( partIndex ); const RigFemPart* femPart = m_resultCollection->parts()->part( partIndex );
int elementCount = femPart->elementCount(); int elementCount = femPart->elementCount();
const std::vector<cvf::Vec3f>& nodeCoords = femPart->nodes().coordinates; const std::vector<cvf::Vec3f>& nodeCoords = femPart->nodes().coordinates;
int frameCount = inputResultFrames->frameCount(); const int timeSteps = inputResultFrames->timeStepCount();
for ( int fIdx = 0; fIdx < frameCount; ++fIdx ) for ( int stepIdx = 0; stepIdx < timeSteps; stepIdx++ )
{ {
const std::vector<float>& inputData = inputResultFrames->frameData( fIdx ); const int frameCount = inputResultFrames->frameCount( stepIdx );
for ( int fIdx = 0; fIdx < frameCount; fIdx++ )
{
const std::vector<float>& inputData = inputResultFrames->frameData( stepIdx, fIdx );
std::vector<float>& dstFrameDataX = dataFramesX->frameData( fIdx ); std::vector<float>& dstFrameDataX = dataFramesX->frameData( stepIdx, fIdx );
std::vector<float>& dstFrameDataY = dataFramesY->frameData( fIdx ); std::vector<float>& dstFrameDataY = dataFramesY->frameData( stepIdx, fIdx );
std::vector<float>& dstFrameDataZ = dataFramesZ->frameData( fIdx ); std::vector<float>& dstFrameDataZ = dataFramesZ->frameData( stepIdx, fIdx );
size_t valCount = inputData.size(); size_t valCount = inputData.size();
if ( valCount == 0 ) continue; if ( valCount == 0 ) continue;
dstFrameDataX.resize( valCount ); dstFrameDataX.resize( valCount );
dstFrameDataY.resize( valCount ); dstFrameDataY.resize( valCount );
dstFrameDataZ.resize( valCount ); dstFrameDataZ.resize( valCount );
#pragma omp parallel for schedule( dynamic ) #pragma omp parallel for schedule( dynamic )
for ( int elmIdx = 0; elmIdx < elementCount; ++elmIdx ) 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<cvf::Vec3d, 8> hexCorners;
for ( int i = 0; i < 8; i++ )
{ {
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 if ( !( elmType == HEX8P || elmType == HEX8 ) ) continue;
std::array<double, 8> cornerValues;
int elmNodeCount = RigFemTypes::elementNodeCount( elmType ); // Find the corner coordinates for element
for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx ) std::array<cvf::Vec3d, 8> hexCorners;
{ for ( int i = 0; i < 8; i++ )
size_t elmNodResIdx = femPart->elementNodeResultIdx( elmIdx, elmNodIdx ); {
cornerValues[elmNodIdx] = inputData[elmNodResIdx]; hexCorners[i] = cvf::Vec3d( nodeCoords[cornerIndices[i]] );
} }
std::array<cvf::Vec3d, 8> gradients = RigHexGradientTools::gradients( hexCorners, cornerValues ); // Find the corresponding corner values for the element
std::array<double, 8> cornerValues;
for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx ) int elmNodeCount = RigFemTypes::elementNodeCount( elmType );
{ for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx )
size_t elmNodResIdx = femPart->elementNodeResultIdx( elmIdx, elmNodIdx ); {
dstFrameDataX[elmNodResIdx] = gradients[elmNodIdx].x(); size_t elmNodResIdx = femPart->elementNodeResultIdx( elmIdx, elmNodIdx );
dstFrameDataY[elmNodResIdx] = gradients[elmNodIdx].y(); cornerValues[elmNodIdx] = inputData[elmNodResIdx];
dstFrameDataZ[elmNodResIdx] = gradients[elmNodIdx].z(); }
std::array<cvf::Vec3d, 8> 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();
}
} }
} }
stepCountProgress.incrementProgress();
frameCountProgress.incrementProgress();
} }
RigFemScalarResultFrames* requestedStress = m_resultCollection->findOrLoadScalarResult( partIndex, resVarAddr ); RigFemScalarResultFrames* requestedStress = m_resultCollection->findOrLoadScalarResult( partIndex, resVarAddr );

View File

@ -67,36 +67,36 @@ RigFemScalarResultFrames*
resVarAddr.componentName == "TP" || resVarAddr.componentName == "TPinc" || resVarAddr.componentName == "TP" || resVarAddr.componentName == "TPinc" ||
resVarAddr.componentName == "FAULTMOB" || resVarAddr.componentName == "PCRIT" ); resVarAddr.componentName == "FAULTMOB" || resVarAddr.componentName == "PCRIT" );
caf::ProgressInfo frameCountProgress( m_resultCollection->frameCount() * 7, "" ); caf::ProgressInfo stepCountProgress( m_resultCollection->timeStepCount() * 7, "" );
frameCountProgress.setProgressDescription( stepCountProgress.setProgressDescription(
"Calculating " + QString::fromStdString( resVarAddr.fieldName + ": " + resVarAddr.componentName ) ); "Calculating " + QString::fromStdString( resVarAddr.fieldName + ": " + resVarAddr.componentName ) );
frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() );
RigFemScalarResultFrames* s11Frames = RigFemScalarResultFrames* s11Frames =
m_resultCollection->findOrLoadScalarResult( partIndex, m_resultCollection->findOrLoadScalarResult( partIndex,
RigFemResultAddress( RIG_ELEMENT_NODAL, resVarAddr.fieldName, "S11" ) ); RigFemResultAddress( RIG_ELEMENT_NODAL, resVarAddr.fieldName, "S11" ) );
frameCountProgress.incrementProgress(); stepCountProgress.incrementProgress();
frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() );
RigFemScalarResultFrames* s22Frames = RigFemScalarResultFrames* s22Frames =
m_resultCollection->findOrLoadScalarResult( partIndex, m_resultCollection->findOrLoadScalarResult( partIndex,
RigFemResultAddress( RIG_ELEMENT_NODAL, resVarAddr.fieldName, "S22" ) ); RigFemResultAddress( RIG_ELEMENT_NODAL, resVarAddr.fieldName, "S22" ) );
frameCountProgress.incrementProgress(); stepCountProgress.incrementProgress();
frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() );
RigFemScalarResultFrames* s33Frames = RigFemScalarResultFrames* s33Frames =
m_resultCollection->findOrLoadScalarResult( partIndex, m_resultCollection->findOrLoadScalarResult( partIndex,
RigFemResultAddress( RIG_ELEMENT_NODAL, resVarAddr.fieldName, "S33" ) ); RigFemResultAddress( RIG_ELEMENT_NODAL, resVarAddr.fieldName, "S33" ) );
frameCountProgress.incrementProgress(); stepCountProgress.incrementProgress();
frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() );
RigFemScalarResultFrames* s12Frames = RigFemScalarResultFrames* s12Frames =
m_resultCollection->findOrLoadScalarResult( partIndex, m_resultCollection->findOrLoadScalarResult( partIndex,
RigFemResultAddress( RIG_ELEMENT_NODAL, resVarAddr.fieldName, "S12" ) ); RigFemResultAddress( RIG_ELEMENT_NODAL, resVarAddr.fieldName, "S12" ) );
frameCountProgress.incrementProgress(); stepCountProgress.incrementProgress();
frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() );
RigFemScalarResultFrames* s23Frames = RigFemScalarResultFrames* s23Frames =
m_resultCollection->findOrLoadScalarResult( partIndex, m_resultCollection->findOrLoadScalarResult( partIndex,
RigFemResultAddress( RIG_ELEMENT_NODAL, resVarAddr.fieldName, "S23" ) ); RigFemResultAddress( RIG_ELEMENT_NODAL, resVarAddr.fieldName, "S23" ) );
frameCountProgress.incrementProgress(); stepCountProgress.incrementProgress();
frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() );
RigFemScalarResultFrames* s13Frames = RigFemScalarResultFrames* s13Frames =
m_resultCollection->findOrLoadScalarResult( partIndex, m_resultCollection->findOrLoadScalarResult( partIndex,
RigFemResultAddress( RIG_ELEMENT_NODAL, resVarAddr.fieldName, "S13" ) ); RigFemResultAddress( RIG_ELEMENT_NODAL, resVarAddr.fieldName, "S13" ) );
@ -134,7 +134,7 @@ RigFemScalarResultFrames*
m_resultCollection->createScalarResult( partIndex, m_resultCollection->createScalarResult( partIndex,
RigFemResultAddress( resVarAddr.resultPosType, resVarAddr.fieldName, "PCRIT" ) ); RigFemResultAddress( resVarAddr.resultPosType, resVarAddr.fieldName, "PCRIT" ) );
frameCountProgress.incrementProgress(); stepCountProgress.incrementProgress();
const RigFemPart* femPart = m_resultCollection->parts()->part( partIndex ); const RigFemPart* femPart = m_resultCollection->parts()->part( partIndex );
const std::vector<cvf::Vec3f>& nodeCoordinates = femPart->nodes().coordinates; const std::vector<cvf::Vec3f>& nodeCoordinates = femPart->nodes().coordinates;
@ -142,124 +142,127 @@ RigFemScalarResultFrames*
float tanFricAng = tan( m_resultCollection->parameterFrictionAngleRad() ); float tanFricAng = tan( m_resultCollection->parameterFrictionAngleRad() );
float cohPrTanFricAngle = (float)( m_resultCollection->parameterCohesion() / tanFricAng ); float cohPrTanFricAngle = (float)( m_resultCollection->parameterCohesion() / tanFricAng );
int frameCount = s11Frames->frameCount(); const int timeSteps = s11Frames->timeStepCount();
for ( int fIdx = 0; fIdx < frameCount; ++fIdx ) for ( int stepIdx = 0; stepIdx < timeSteps; stepIdx++ )
{ {
const std::vector<float>& s11 = s11Frames->frameData( fIdx ); const int frameCount = s11Frames->frameCount( stepIdx );
if ( s11.empty() ) continue; for ( int fIdx = 0; fIdx < frameCount; fIdx++ )
{
const std::vector<float>& s11 = s11Frames->frameData( stepIdx, fIdx );
if ( s11.empty() ) continue;
const std::vector<float>& s22 = s22Frames->frameData( fIdx ); const std::vector<float>& s22 = s22Frames->frameData( stepIdx, fIdx );
const std::vector<float>& s33 = s33Frames->frameData( fIdx ); const std::vector<float>& s33 = s33Frames->frameData( stepIdx, fIdx );
const std::vector<float>& s12 = s12Frames->frameData( fIdx ); const std::vector<float>& s12 = s12Frames->frameData( stepIdx, fIdx );
const std::vector<float>& s23 = s23Frames->frameData( fIdx ); const std::vector<float>& s23 = s23Frames->frameData( stepIdx, fIdx );
const std::vector<float>& s13 = s13Frames->frameData( fIdx ); const std::vector<float>& s13 = s13Frames->frameData( stepIdx, fIdx );
std::vector<float>& SNDat = SNFrames->frameData( fIdx ); std::vector<float>& SNDat = SNFrames->frameData( stepIdx, fIdx );
std::vector<float>& STHDat = STHFrames->frameData( fIdx ); std::vector<float>& STHDat = STHFrames->frameData( stepIdx, fIdx );
std::vector<float>& STQVDat = STQVFrames->frameData( fIdx ); std::vector<float>& STQVDat = STQVFrames->frameData( stepIdx, fIdx );
std::vector<float>& TNHDat = TNHFrames->frameData( fIdx ); std::vector<float>& TNHDat = TNHFrames->frameData( stepIdx, fIdx );
std::vector<float>& TNQVDat = TNQVFrames->frameData( fIdx ); std::vector<float>& TNQVDat = TNQVFrames->frameData( stepIdx, fIdx );
std::vector<float>& THQVDat = THQVFrames->frameData( fIdx ); std::vector<float>& THQVDat = THQVFrames->frameData( stepIdx, fIdx );
std::vector<float>& TPDat = TPFrames->frameData( fIdx ); std::vector<float>& TPDat = TPFrames->frameData( stepIdx, fIdx );
std::vector<float>& TincDat = TPincFrames->frameData( fIdx ); std::vector<float>& TincDat = TPincFrames->frameData( stepIdx, fIdx );
std::vector<float>& FAULTMOBDat = FAULTMOBFrames->frameData( fIdx ); std::vector<float>& FAULTMOBDat = FAULTMOBFrames->frameData( stepIdx, fIdx );
std::vector<float>& PCRITDat = PCRITFrames->frameData( fIdx ); std::vector<float>& PCRITDat = PCRITFrames->frameData( stepIdx, fIdx );
// HACK ! Todo : make it robust against other elements than Hex8 // 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 size_t valCount = s11.size() * 3; // Number of Elm Node Face results 24 = 4 * num faces = 3* numElmNodes
SNDat.resize( valCount ); SNDat.resize( valCount );
STHDat.resize( valCount ); STHDat.resize( valCount );
STQVDat.resize( valCount ); STQVDat.resize( valCount );
TNHDat.resize( valCount ); TNHDat.resize( valCount );
TNQVDat.resize( valCount ); TNQVDat.resize( valCount );
THQVDat.resize( valCount ); THQVDat.resize( valCount );
TPDat.resize( valCount ); TPDat.resize( valCount );
TincDat.resize( valCount ); TincDat.resize( valCount );
FAULTMOBDat.resize( valCount ); FAULTMOBDat.resize( valCount );
PCRITDat.resize( valCount ); PCRITDat.resize( valCount );
int elementCount = femPart->elementCount(); int elementCount = femPart->elementCount();
#pragma omp parallel for #pragma omp parallel for
for ( int elmIdx = 0; elmIdx < elementCount; ++elmIdx ) 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 )
{ {
int faceNodeCount = 0; RigElementType elmType = femPart->elementType( elmIdx );
const int* localElmNodeIndicesForFace = int faceCount = RigFemTypes::elementFaceCount( elmType );
RigFemTypes::localElmNodeIndicesForFace( elmType, lfIdx, &faceNodeCount ); const int* elmNodeIndices = femPart->connectivities( elmIdx );
if ( faceNodeCount == 4 )
int elmNodFaceResIdxElmStart = elmIdx * 24; // HACK should get from part
for ( int lfIdx = 0; lfIdx < faceCount; ++lfIdx )
{ {
int elmNodFaceResIdxFaceStart = elmNodFaceResIdxElmStart + lfIdx * 4; // HACK int faceNodeCount = 0;
cvf::Vec3f quadVxs[4]; const int* localElmNodeIndicesForFace =
RigFemTypes::localElmNodeIndicesForFace( elmType, lfIdx, &faceNodeCount );
quadVxs[0] = ( nodeCoordinates[elmNodeIndices[localElmNodeIndicesForFace[0]]] ); if ( faceNodeCount == 4 )
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 )
{ {
size_t elmNodResIdx = qElmNodeResIdx[qIdx]; int elmNodFaceResIdxFaceStart = elmNodFaceResIdxElmStart + lfIdx * 4; // HACK
float t11 = s11[elmNodResIdx]; cvf::Vec3f quadVxs[4];
float t22 = s22[elmNodResIdx];
float t33 = s33[elmNodResIdx];
float t12 = s12[elmNodResIdx];
float t23 = s23[elmNodResIdx];
float t13 = s13[elmNodResIdx];
caf::Ten3f tensor( t11, t22, t33, t12, t23, t13 ); quadVxs[0] = ( nodeCoordinates[elmNodeIndices[localElmNodeIndicesForFace[0]]] );
caf::Ten3f xfTen = tensor.rotated( rotMx ); quadVxs[1] = ( nodeCoordinates[elmNodeIndices[localElmNodeIndicesForFace[1]]] );
int elmNodFaceResIdx = elmNodFaceResIdxFaceStart + qIdx; quadVxs[2] = ( nodeCoordinates[elmNodeIndices[localElmNodeIndicesForFace[2]]] );
quadVxs[3] = ( nodeCoordinates[elmNodeIndices[localElmNodeIndicesForFace[3]]] );
float szx = xfTen[caf::Ten3f::SZX]; cvf::Mat3f rotMx = cvf::GeometryTools::computePlaneHorizontalRotationMx( quadVxs[2] - quadVxs[0],
float syz = xfTen[caf::Ten3f::SYZ]; quadVxs[3] - quadVxs[1] );
float szz = xfTen[caf::Ten3f::SZZ];
STHDat[elmNodFaceResIdx] = xfTen[caf::Ten3f::SXX]; size_t qElmNodeResIdx[4];
STQVDat[elmNodFaceResIdx] = xfTen[caf::Ten3f::SYY]; qElmNodeResIdx[0] = femPart->elementNodeResultIdx( elmIdx, localElmNodeIndicesForFace[0] );
SNDat[elmNodFaceResIdx] = xfTen[caf::Ten3f::SZZ]; 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]; for ( int qIdx = 0; qIdx < 4; ++qIdx )
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 ) ); size_t elmNodResIdx = qElmNodeResIdx[qIdx];
} float t11 = s11[elmNodResIdx];
else float t22 = s22[elmNodResIdx];
{ float t33 = s33[elmNodResIdx];
TincDat[elmNodFaceResIdx] = std::numeric_limits<float>::infinity(); float t12 = s12[elmNodResIdx];
} float t23 = s23[elmNodResIdx];
float t13 = s13[elmNodResIdx];
FAULTMOBDat[elmNodFaceResIdx] = TP / ( tanFricAng * ( szz + cohPrTanFricAngle ) ); caf::Ten3f tensor( t11, t22, t33, t12, t23, t13 );
PCRITDat[elmNodFaceResIdx] = szz - TP / tanFricAng; 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<float>::infinity();
}
FAULTMOBDat[elmNodFaceResIdx] = TP / ( tanFricAng * ( szz + cohPrTanFricAngle ) );
PCRITDat[elmNodFaceResIdx] = szz - TP / tanFricAng;
}
} }
} }
} }
} }
stepCountProgress.incrementProgress();
frameCountProgress.incrementProgress();
} }
RigFemScalarResultFrames* requestedSurfStress = m_resultCollection->findOrLoadScalarResult( partIndex, resVarAddr ); RigFemScalarResultFrames* requestedSurfStress = m_resultCollection->findOrLoadScalarResult( partIndex, resVarAddr );

View File

@ -65,8 +65,8 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorSurfaceAngles::calculate( in
{ {
CVF_ASSERT( resVarAddr.componentName == "Pazi" || resVarAddr.componentName == "Pinc" ); CVF_ASSERT( resVarAddr.componentName == "Pazi" || resVarAddr.componentName == "Pinc" );
caf::ProgressInfo frameCountProgress( m_resultCollection->frameCount() * 1, "" ); caf::ProgressInfo stepCountProgress( m_resultCollection->timeStepCount() * 1, "" );
frameCountProgress.setProgressDescription( stepCountProgress.setProgressDescription(
"Calculating " + QString::fromStdString( resVarAddr.fieldName + ": " + resVarAddr.componentName ) ); "Calculating " + QString::fromStdString( resVarAddr.fieldName + ": " + resVarAddr.componentName ) );
RigFemScalarResultFrames* PaziFrames = RigFemScalarResultFrames* PaziFrames =
@ -78,65 +78,68 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorSurfaceAngles::calculate( in
const RigFemPart* femPart = m_resultCollection->parts()->part( partIndex ); const RigFemPart* femPart = m_resultCollection->parts()->part( partIndex );
const std::vector<cvf::Vec3f>& nodeCoordinates = femPart->nodes().coordinates; const std::vector<cvf::Vec3f>& nodeCoordinates = femPart->nodes().coordinates;
int frameCount = m_resultCollection->frameCount();
// HACK ! Todo : make it robust against other elements than Hex8 // 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* size_t valCount = femPart->elementCount() * 24; // Number of Elm Node Face results 24 = 4 * num faces = 3*
// numElmNodes // numElmNodes
for ( int fIdx = 0; fIdx < frameCount; ++fIdx ) const int timeSteps = PaziFrames->timeStepCount();
for ( int stepIdx = 0; stepIdx < timeSteps; stepIdx++ )
{ {
std::vector<float>& Pazi = PaziFrames->frameData( fIdx ); const int frameCount = PaziFrames->frameCount( stepIdx );
std::vector<float>& Pinc = PincFrames->frameData( fIdx ); for ( int fIdx = 0; fIdx < frameCount; fIdx++ )
Pazi.resize( valCount );
Pinc.resize( valCount );
int elementCount = femPart->elementCount();
#pragma omp parallel for
for ( int elmIdx = 0; elmIdx < elementCount; ++elmIdx )
{ {
RigElementType elmType = femPart->elementType( elmIdx ); std::vector<float>& Pazi = PaziFrames->frameData( stepIdx, fIdx );
int faceCount = RigFemTypes::elementFaceCount( elmType ); std::vector<float>& Pinc = PincFrames->frameData( stepIdx, fIdx );
const int* elmNodeIndices = femPart->connectivities( elmIdx );
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; RigElementType elmType = femPart->elementType( elmIdx );
const int* localElmNodeIndicesForFace = int faceCount = RigFemTypes::elementFaceCount( elmType );
RigFemTypes::localElmNodeIndicesForFace( elmType, lfIdx, &faceNodeCount ); const int* elmNodeIndices = femPart->connectivities( elmIdx );
if ( faceNodeCount == 4 )
int elmNodFaceResIdxElmStart = elmIdx * 24; // HACK should get from part
for ( int lfIdx = 0; lfIdx < faceCount; ++lfIdx )
{ {
int elmNodFaceResIdxFaceStart = elmNodFaceResIdxElmStart + lfIdx * 4; // HACK int faceNodeCount = 0;
cvf::Vec3f quadVxs[4]; const int* localElmNodeIndicesForFace =
RigFemTypes::localElmNodeIndicesForFace( elmType, lfIdx, &faceNodeCount );
quadVxs[0] = ( nodeCoordinates[elmNodeIndices[localElmNodeIndicesForFace[0]]] ); if ( faceNodeCount == 4 )
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; int elmNodFaceResIdxFaceStart = elmNodFaceResIdxElmStart + lfIdx * 4; // HACK
Pazi[elmNodFaceResIdx] = cvf::Math::toDegrees( sphCoord.azi() ); cvf::Vec3f quadVxs[4];
Pinc[elmNodFaceResIdx] = cvf::Math::toDegrees( sphCoord.inc() );
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() );
}
} }
} }
} }
} }
stepCountProgress.incrementProgress();
frameCountProgress.incrementProgress();
} }
RigFemScalarResultFrames* requestedPlaneAngle = m_resultCollection->findOrLoadScalarResult( partIndex, resVarAddr ); RigFemScalarResultFrames* requestedPlaneAngle = m_resultCollection->findOrLoadScalarResult( partIndex, resVarAddr );

View File

@ -83,10 +83,10 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorTimeLapse::calculate( int
RigFemScalarResultFrames* RigFemScalarResultFrames*
RigFemPartResultCalculatorTimeLapse::calculateTimeLapse( int partIndex, const RigFemResultAddress& resVarAddr ) RigFemPartResultCalculatorTimeLapse::calculateTimeLapse( int partIndex, const RigFemResultAddress& resVarAddr )
{ {
caf::ProgressInfo frameCountProgress( m_resultCollection->frameCount() * 2, "" ); caf::ProgressInfo stepCountProgress( m_resultCollection->timeStepCount() * 2, "" );
frameCountProgress.setProgressDescription( stepCountProgress.setProgressDescription(
"Calculating " + QString::fromStdString( resVarAddr.fieldName + ": " + resVarAddr.componentName ) ); "Calculating " + QString::fromStdString( resVarAddr.fieldName + ": " + resVarAddr.componentName ) );
frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() );
RigFemResultAddress resVarNative( resVarAddr.resultPosType, RigFemResultAddress resVarNative( resVarAddr.resultPosType,
resVarAddr.fieldName, resVarAddr.fieldName,
@ -109,30 +109,36 @@ RigFemScalarResultFrames*
srcDataFrames = m_resultCollection->findOrLoadScalarResult( partIndex, resVarNative ); srcDataFrames = m_resultCollection->findOrLoadScalarResult( partIndex, resVarNative );
} }
frameCountProgress.incrementProgress(); stepCountProgress.incrementProgress();
int frameCount = srcDataFrames->frameCount(); const int timeSteps = srcDataFrames->timeStepCount();
int baseFrameIdx = resVarAddr.timeLapseBaseStepIdx; auto [baseStepIdx, baseFrameIdx] =
if ( baseFrameIdx >= frameCount ) return dstDataFrames; m_resultCollection->stepListIndexToTimeStepAndDataFrameIndex( resVarAddr.timeLapseBaseStepIdx );
const std::vector<float>& baseFrameData = srcDataFrames->frameData( baseFrameIdx );
if ( baseStepIdx >= timeSteps ) return dstDataFrames;
const std::vector<float>& baseFrameData = srcDataFrames->frameData( baseStepIdx, baseFrameIdx );
if ( baseFrameData.empty() ) return dstDataFrames; if ( baseFrameData.empty() ) return dstDataFrames;
for ( int fIdx = 0; fIdx < frameCount; ++fIdx ) for ( int stepIdx = 0; stepIdx < timeSteps; stepIdx++ )
{ {
const std::vector<float>& srcFrameData = srcDataFrames->frameData( fIdx ); const int frameCount = srcDataFrames->frameCount( stepIdx );
if ( srcFrameData.empty() ) continue; // Create empty results for ( int fIdx = 0; fIdx < frameCount; fIdx++ )
{
const std::vector<float>& srcFrameData = srcDataFrames->frameData( stepIdx, fIdx );
if ( srcFrameData.empty() ) continue; // Create empty results
std::vector<float>& dstFrameData = dstDataFrames->frameData( fIdx ); std::vector<float>& dstFrameData = dstDataFrames->frameData( stepIdx, fIdx );
size_t valCount = srcFrameData.size(); size_t valCount = srcFrameData.size();
dstFrameData.resize( valCount ); dstFrameData.resize( valCount );
#pragma omp parallel for #pragma omp parallel for
for ( long vIdx = 0; vIdx < static_cast<long>( valCount ); ++vIdx ) for ( long vIdx = 0; vIdx < static_cast<long>( valCount ); ++vIdx )
{ {
dstFrameData[vIdx] = srcFrameData[vIdx] - baseFrameData[vIdx]; dstFrameData[vIdx] = srcFrameData[vIdx] - baseFrameData[vIdx];
}
} }
stepCountProgress.incrementProgress();
frameCountProgress.incrementProgress();
} }
return dstDataFrames; 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 // Gamma time lapse needs to be calculated as ST_dt / POR_dt and not Gamma - Gamma_baseFrame see github
// issue #937 // issue #937
caf::ProgressInfo frameCountProgress( m_resultCollection->frameCount() * 3, "" ); caf::ProgressInfo stepCountProgress( m_resultCollection->timeStepCount() * 3, "" );
frameCountProgress.setProgressDescription( stepCountProgress.setProgressDescription(
"Calculating " + QString::fromStdString( resVarAddr.fieldName + ": " + resVarAddr.componentName ) ); "Calculating " + QString::fromStdString( resVarAddr.fieldName + ": " + resVarAddr.componentName ) );
frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() );
RigFemResultAddress totStressCompAddr( resVarAddr.resultPosType, "ST", "", resVarAddr.timeLapseBaseStepIdx ); RigFemResultAddress totStressCompAddr( resVarAddr.resultPosType, "ST", "", resVarAddr.timeLapseBaseStepIdx );
{ {
@ -172,22 +178,22 @@ RigFemScalarResultFrames*
} }
RigFemScalarResultFrames* srcDataFrames = m_resultCollection->findOrLoadScalarResult( partIndex, totStressCompAddr ); RigFemScalarResultFrames* srcDataFrames = m_resultCollection->findOrLoadScalarResult( partIndex, totStressCompAddr );
frameCountProgress.incrementProgress(); stepCountProgress.incrementProgress();
frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() );
RigFemScalarResultFrames* srcPORDataFrames = RigFemScalarResultFrames* srcPORDataFrames =
m_resultCollection m_resultCollection
->findOrLoadScalarResult( partIndex, ->findOrLoadScalarResult( partIndex,
RigFemResultAddress( RIG_NODAL, "POR-Bar", "", resVarAddr.timeLapseBaseStepIdx ) ); RigFemResultAddress( RIG_NODAL, "POR-Bar", "", resVarAddr.timeLapseBaseStepIdx ) );
RigFemScalarResultFrames* dstDataFrames = m_resultCollection->createScalarResult( partIndex, resVarAddr ); RigFemScalarResultFrames* dstDataFrames = m_resultCollection->createScalarResult( partIndex, resVarAddr );
frameCountProgress.incrementProgress(); stepCountProgress.incrementProgress();
RigFemPartResultCalculatorGamma::calculateGammaFromFrames( partIndex, RigFemPartResultCalculatorGamma::calculateGammaFromFrames( partIndex,
m_resultCollection->parts(), m_resultCollection->parts(),
srcDataFrames, srcDataFrames,
srcPORDataFrames, srcPORDataFrames,
dstDataFrames, dstDataFrames,
&frameCountProgress ); &stepCountProgress );
if ( resVarAddr.normalizeByHydrostaticPressure() && RigFemPartResultsCollection::isNormalizableResult( resVarAddr ) ) if ( resVarAddr.normalizeByHydrostaticPressure() && RigFemPartResultsCollection::isNormalizableResult( resVarAddr ) )
{ {
RigFemPartResultCalculatorNormalized normalizedCalculator( *m_resultCollection ); RigFemPartResultCalculatorNormalized normalizedCalculator( *m_resultCollection );

View File

@ -112,6 +112,22 @@ RigFemPartResultsCollection::RigFemPartResultsCollection( RifGeoMechReaderInterf
femPartResult->initResultSteps( filteredStepNames ); 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_cohesion = 10.0;
m_frictionAngleRad = cvf::Math::toRadians( 30.0 ); m_frictionAngleRad = cvf::Math::toRadians( 30.0 );
m_normalizationAirGap = 0.0; m_normalizationAirGap = 0.0;
@ -388,9 +404,9 @@ void RigFemPartResultsCollection::setReferenceTimeStep( int referenceTimeStep )
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
int RigFemPartResultsCollection::referenceTimeStep() const std::pair<int, int> RigFemPartResultsCollection::referenceStepAndFrameIndex() const
{ {
return m_referenceTimeStep; return stepListIndexToTimeStepAndDataFrameIndex( m_referenceTimeStep );
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -405,7 +421,7 @@ void RigFemPartResultsCollection::setPermeabilityParameters( double fixe
m_permeabilityExponent = permeabilityExponent; m_permeabilityExponent = permeabilityExponent;
std::set<RigFemResultAddress> results = initialPermeabilityDependentResults(); std::set<RigFemResultAddress> results = initialPermeabilityDependentResults();
for ( auto result : results ) for ( auto& result : results )
{ {
deleteResult( result ); deleteResult( result );
} }
@ -459,12 +475,12 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::findOrLoadScalarResult( i
std::map<std::string, std::vector<float>> elementProperties = std::map<std::string, std::vector<float>> elementProperties =
m_elementPropertyReader->readAllElementPropertiesInFileContainingField( resVarAddr.fieldName ); m_elementPropertyReader->readAllElementPropertiesInFileContainingField( resVarAddr.fieldName );
for ( auto [addrString, values] : elementProperties ) for ( auto& [addrString, values] : elementProperties )
{ {
RigFemResultAddress addressForElement( RIG_ELEMENT, addrString, "" ); RigFemResultAddress addressForElement( RIG_ELEMENT, addrString, "" );
RigFemScalarResultFrames* currentFrames = m_femPartResults[partIndex]->createScalarResult( addressForElement ); RigFemScalarResultFrames* currentFrames = m_femPartResults[partIndex]->createScalarResult( addressForElement );
currentFrames->enableAsSingleFrameResult(); currentFrames->enableAsSingleStepResult();
currentFrames->frameData( 0 ).swap( values ); currentFrames->frameData( 0, 0 ).swap( values );
} }
frames = m_femPartResults[partIndex]->findScalarResult( resVarAddr ); frames = m_femPartResults[partIndex]->findScalarResult( resVarAddr );
@ -490,46 +506,50 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::findOrLoadScalarResult( i
resultsForEachComponent.push_back( m_femPartResults[partIndex]->createScalarResult( resultAddressOfComponent ) ); resultsForEachComponent.push_back( m_femPartResults[partIndex]->createScalarResult( resultAddressOfComponent ) );
} }
int frameCount = this->frameCount(); int timeSteps = this->timeStepCount();
caf::ProgressInfo progress( frameCount, "" ); caf::ProgressInfo progress( timeSteps, "" );
progress.setProgressDescription( progress.setProgressDescription(
QString( "Loading Native Result %1 %2" ).arg( resVarAddr.fieldName.c_str(), resVarAddr.componentName.c_str() ) ); 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<double> frameTimes = m_readerInterface->frameTimes( stepIndex ); std::vector<double> frameTimes = m_readerInterface->frameTimes( stepIndex );
int fIdx = (int)( frameTimes.size() - 1 ); for ( int frameIndex = 0; frameIndex < int( frameTimes.size() ); frameIndex++ )
std::vector<std::vector<float>*> componentDataVectors;
for ( auto& componentResult : resultsForEachComponent )
{ {
componentDataVectors.push_back( &( componentResult->frameData( stepIndex ) ) ); std::vector<std::vector<float>*> componentDataVectors;
} for ( auto& componentResult : resultsForEachComponent )
{
componentDataVectors.push_back( &( componentResult->frameData( stepIndex, frameIndex ) ) );
}
switch ( resVarAddr.resultPosType ) switch ( resVarAddr.resultPosType )
{ {
case RIG_NODAL: case RIG_NODAL:
m_readerInterface->readNodeField( resVarAddr.fieldName, partIndex, stepIndex, fIdx, &componentDataVectors ); m_readerInterface->readNodeField( resVarAddr.fieldName,
break; partIndex,
case RIG_ELEMENT_NODAL: stepIndex,
m_readerInterface->readElementNodeField( resVarAddr.fieldName, frameIndex,
partIndex, &componentDataVectors );
stepIndex, break;
fIdx, case RIG_ELEMENT_NODAL:
&componentDataVectors ); m_readerInterface->readElementNodeField( resVarAddr.fieldName,
break; partIndex,
case RIG_INTEGRATION_POINT: stepIndex,
m_readerInterface->readIntegrationPointField( resVarAddr.fieldName, frameIndex,
partIndex, &componentDataVectors );
stepIndex, break;
fIdx, case RIG_INTEGRATION_POINT:
&componentDataVectors ); m_readerInterface->readIntegrationPointField( resVarAddr.fieldName,
break; partIndex,
default: stepIndex,
break; frameIndex,
&componentDataVectors );
break;
default:
break;
}
} }
progress.incrementProgress(); progress.incrementProgress();
} }
@ -940,7 +960,7 @@ std::vector<RigFemResultAddress>
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
std::vector<std::string> RigFemPartResultsCollection::filteredStepNames() const std::vector<std::string> RigFemPartResultsCollection::filteredTimeStepNames() const
{ {
CVF_ASSERT( m_readerInterface.notNull() ); CVF_ASSERT( m_readerInterface.notNull() );
return m_readerInterface->filteredStepNames(); return m_readerInterface->filteredStepNames();
@ -949,9 +969,52 @@ std::vector<std::string> RigFemPartResultsCollection::filteredStepNames() const
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
int RigFemPartResultsCollection::frameCount() int RigFemPartResultsCollection::timeStepCount() const
{ {
return static_cast<int>( filteredStepNames().size() ); return static_cast<int>( filteredTimeStepNames().size() );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RigFemPartResultsCollection::frameCount( int timeStepIndex ) const
{
CVF_ASSERT( m_readerInterface.notNull() );
return m_readerInterface->frameCount( timeStepIndex );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const std::vector<std::pair<int, int>>& RigFemPartResultsCollection::stepList()
{
return m_stepList;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RigFemPartResultsCollection::totalSteps()
{
return int( stepList().size() );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<std::string> RigFemPartResultsCollection::stepNames() const
{
return m_stepNames;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const std::pair<int, int> RigFemPartResultsCollection::stepListIndexToTimeStepAndDataFrameIndex( int stepIndex ) const
{
if ( stepIndex < 0 ) return std::make_pair( stepIndex, -1 );
CVF_ASSERT( stepIndex < static_cast<int>( m_stepList.size() ) );
return m_stepList[stepIndex];
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -968,9 +1031,14 @@ bool RigFemPartResultsCollection::assertResultsLoaded( const RigFemResultAddress
if ( m_femPartResults[pIdx].notNull() ) if ( m_femPartResults[pIdx].notNull() )
{ {
RigFemScalarResultFrames* scalarResults = findOrLoadScalarResult( pIdx, resVarAddr ); 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<float>().swap( frames->frameData( frameIndex ) );
}
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -1059,13 +1114,15 @@ std::vector<RigFemResultAddress> RigFemPartResultsCollection::loadedResults() co
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
const std::vector<float>& const std::vector<float>& RigFemPartResultsCollection::resultValues( const RigFemResultAddress& resVarAddr,
RigFemPartResultsCollection::resultValues( const RigFemResultAddress& resVarAddr, int partIndex, int frameIndex ) int partIndex,
int stepIndex,
int frameIndex )
{ {
CVF_ASSERT( resVarAddr.isValid() ); CVF_ASSERT( resVarAddr.isValid() );
RigFemScalarResultFrames* scalarResults = findOrLoadScalarResult( partIndex, resVarAddr ); RigFemScalarResultFrames* scalarResults = findOrLoadScalarResult( partIndex, resVarAddr );
return scalarResults->frameData( frameIndex ); return scalarResults->frameData( stepIndex, frameIndex );
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -1073,13 +1130,14 @@ const std::vector<float>&
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RigFemPartResultsCollection::globalResultValues( const RigFemResultAddress& resVarAddr, void RigFemPartResultsCollection::globalResultValues( const RigFemResultAddress& resVarAddr,
int timeStepIndex, int timeStepIndex,
int frameIndex,
std::vector<float>& resultValues ) std::vector<float>& resultValues )
{ {
CVF_ASSERT( resVarAddr.isValid() ); CVF_ASSERT( resVarAddr.isValid() );
for ( int i = 0; i < partCount(); i++ ) for ( int i = 0; i < partCount(); i++ )
{ {
const std::vector<float>& partResults = this->resultValues( resVarAddr, i, (int)timeStepIndex ); const std::vector<float>& partResults = this->resultValues( resVarAddr, i, timeStepIndex, frameIndex );
if ( partResults.empty() ) if ( partResults.empty() )
{ {
size_t expectedSize = 0; size_t expectedSize = 0;
@ -1120,7 +1178,7 @@ void RigFemPartResultsCollection::globalResultValues( const RigFemResultAddress&
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
std::vector<caf::Ten3f> std::vector<caf::Ten3f>
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 ); CVF_ASSERT( resVarAddr.resultPosType == RIG_ELEMENT_NODAL || resVarAddr.resultPosType == RIG_INTEGRATION_POINT );
@ -1133,12 +1191,12 @@ std::vector<caf::Ten3f>
return outputTensors; return outputTensors;
} }
const std::vector<float>& v11 = resultValues( addresses[caf::Ten3f::SXX], partIndex, frameIndex ); const std::vector<float>& v11 = resultValues( addresses[caf::Ten3f::SXX], partIndex, stepIndex, frameIndex );
const std::vector<float>& v22 = resultValues( addresses[caf::Ten3f::SYY], partIndex, frameIndex ); const std::vector<float>& v22 = resultValues( addresses[caf::Ten3f::SYY], partIndex, stepIndex, frameIndex );
const std::vector<float>& v33 = resultValues( addresses[caf::Ten3f::SZZ], partIndex, frameIndex ); const std::vector<float>& v33 = resultValues( addresses[caf::Ten3f::SZZ], partIndex, stepIndex, frameIndex );
const std::vector<float>& v12 = resultValues( addresses[caf::Ten3f::SXY], partIndex, frameIndex ); const std::vector<float>& v12 = resultValues( addresses[caf::Ten3f::SXY], partIndex, stepIndex, frameIndex );
const std::vector<float>& v13 = resultValues( addresses[caf::Ten3f::SZX], partIndex, frameIndex ); const std::vector<float>& v13 = resultValues( addresses[caf::Ten3f::SZX], partIndex, stepIndex, frameIndex );
const std::vector<float>& v23 = resultValues( addresses[caf::Ten3f::SYZ], partIndex, frameIndex ); const std::vector<float>& v23 = resultValues( addresses[caf::Ten3f::SYZ], partIndex, stepIndex, frameIndex );
size_t valCount = v11.size(); size_t valCount = v11.size();
outputTensors.resize( valCount ); outputTensors.resize( valCount );
@ -1173,11 +1231,12 @@ RigStatisticsDataCache* RigFemPartResultsCollection::statistics( const RigFemRes
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RigFemPartResultsCollection::minMaxScalarValues( const RigFemResultAddress& resVarAddr, void RigFemPartResultsCollection::minMaxScalarValues( const RigFemResultAddress& resVarAddr,
int stepIndex,
int frameIndex, int frameIndex,
double* localMin, double* localMin,
double* localMax ) 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, void RigFemPartResultsCollection::posNegClosestToZero( const RigFemResultAddress& resVarAddr,
int frameIndex, int frameIndex,
int stepIndex,
double* localPosClosestToZero, double* localPosClosestToZero,
double* localNegClosestToZero ) 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, void RigFemPartResultsCollection::p10p90ScalarValues( const RigFemResultAddress& resVarAddr,
int stepIndex,
int frameIndex, int frameIndex,
double* p10, double* p10,
double* p90 ) 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 ); CVF_ASSERT( sum );
this->statistics( resVarAddr )->sumCellScalarValues( frameIndex, *sum ); this->statistics( resVarAddr )->sumCellScalarValues( stepIndex, *sum );
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -1280,11 +1347,15 @@ const std::vector<size_t>& RigFemPartResultsCollection::scalarValuesHistogram( c
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
const std::vector<size_t>& RigFemPartResultsCollection::scalarValuesHistogram( const RigFemResultAddress& resVarAddr, const std::vector<size_t>& RigFemPartResultsCollection::scalarValuesHistogram( const RigFemResultAddress& resVarAddr,
int stepIndex,
int frameIndex ) int frameIndex )
{ {
return this->statistics( resVarAddr )->cellScalarValuesHistogram( frameIndex ); return this->statistics( resVarAddr )->cellScalarValuesHistogram( stepIndex );
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RigFemResultAddress> std::vector<RigFemResultAddress>
RigFemPartResultsCollection::tensorPrincipalComponentAdresses( const RigFemResultAddress& resVarAddr ) RigFemPartResultsCollection::tensorPrincipalComponentAdresses( const RigFemResultAddress& resVarAddr )
{ {
@ -1458,6 +1529,7 @@ double RigFemPartResultsCollection::normalizationAirGap() const
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RigFemPartResultsCollection::minMaxScalarValuesOverAllTensorComponents( const RigFemResultAddress& resVarAddr, void RigFemPartResultsCollection::minMaxScalarValuesOverAllTensorComponents( const RigFemResultAddress& resVarAddr,
int stepIndex,
int frameIndex, int frameIndex,
double* localMin, double* localMin,
double* localMax ) double* localMax )
@ -1469,7 +1541,7 @@ void RigFemPartResultsCollection::minMaxScalarValuesOverAllTensorComponents( con
for ( const auto& address : tensorPrincipalComponentAdresses( resVarAddr ) ) for ( const auto& address : tensorPrincipalComponentAdresses( resVarAddr ) )
{ {
this->statistics( address )->minMaxCellScalarValues( frameIndex, min, max ); this->statistics( address )->minMaxCellScalarValues( stepIndex, min, max );
if ( min < currentMin ) if ( min < currentMin )
{ {
currentMin = min; currentMin = min;
@ -1517,6 +1589,7 @@ void RigFemPartResultsCollection::minMaxScalarValuesOverAllTensorComponents( con
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RigFemPartResultsCollection::posNegClosestToZeroOverAllTensorComponents( const RigFemResultAddress& resVarAddr, void RigFemPartResultsCollection::posNegClosestToZeroOverAllTensorComponents( const RigFemResultAddress& resVarAddr,
int stepIndex,
int frameIndex, int frameIndex,
double* localPosClosestToZero, double* localPosClosestToZero,
double* localNegClosestToZero ) double* localNegClosestToZero )
@ -1528,7 +1601,7 @@ void RigFemPartResultsCollection::posNegClosestToZeroOverAllTensorComponents( co
for ( const auto& address : tensorPrincipalComponentAdresses( resVarAddr ) ) for ( const auto& address : tensorPrincipalComponentAdresses( resVarAddr ) )
{ {
this->statistics( address )->posNegClosestToZero( frameIndex, pos, neg ); this->statistics( address )->posNegClosestToZero( stepIndex, pos, neg );
if ( pos < currentPosClosestToZero ) if ( pos < currentPosClosestToZero )
{ {
currentPosClosestToZero = pos; currentPosClosestToZero = pos;

View File

@ -115,27 +115,41 @@ public:
void setWaterDensityShearSlipIndicator( double waterDensity ); void setWaterDensityShearSlipIndicator( double waterDensity );
std::map<std::string, std::vector<std::string>> scalarFieldAndComponentNames( RigFemResultPosEnum resPos ); std::map<std::string, std::vector<std::string>> scalarFieldAndComponentNames( RigFemResultPosEnum resPos );
std::vector<std::string> filteredStepNames() const;
bool assertResultsLoaded( const RigFemResultAddress& resVarAddr ); bool assertResultsLoaded( const RigFemResultAddress& resVarAddr );
void deleteResult( const RigFemResultAddress& resVarAddr ); void deleteResult( const RigFemResultAddress& resVarAddr );
void deleteResultForAllTimeSteps( const std::vector<RigFemResultAddress>& addresses ); void deleteResultForAllTimeSteps( const std::vector<RigFemResultAddress>& addresses );
void deleteResultFrame( const RigFemResultAddress& resVarAddr, int partIndex, int frameIndex );
std::vector<RigFemResultAddress> loadedResults() const; std::vector<RigFemResultAddress> loadedResults() const;
const std::vector<float>& resultValues( const RigFemResultAddress& resVarAddr, int partIndex, int frameIndex ); const std::vector<float>&
void globalResultValues( const RigFemResultAddress& resVarAddr, int timeStepIndex, std::vector<float>& resultValues ); resultValues( const RigFemResultAddress& resVarAddr, int partIndex, int stepIndex, int frameIndex );
std::vector<caf::Ten3f> tensors( const RigFemResultAddress& resVarAddr, int partIndex, int frameIndex ); void globalResultValues( const RigFemResultAddress& resVarAddr,
int timeStepIndex,
int frameIndex,
std::vector<float>& resultValues );
std::vector<caf::Ten3f> tensors( const RigFemResultAddress& resVarAddr, int partIndex, int stepIndex, int frameIndex );
const RigFemPartCollection* parts() const; const RigFemPartCollection* parts() const;
int partCount() 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<std::pair<int, int>>& stepList();
std::vector<std::string> stepNames() const;
const std::pair<int, int> 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 minMaxScalarValues( const RigFemResultAddress& resVarAddr, double* globalMin, double* globalMax );
void posNegClosestToZero( const RigFemResultAddress& resVarAddr, void posNegClosestToZero( const RigFemResultAddress& resVarAddr,
int stepIndex,
int frameIndex, int frameIndex,
double* localPosClosestToZero, double* localPosClosestToZero,
double* localNegClosestToZero ); double* localNegClosestToZero );
@ -143,15 +157,16 @@ public:
double* globalPosClosestToZero, double* globalPosClosestToZero,
double* globalNegClosestToZero ); double* globalNegClosestToZero );
void meanScalarValue( const RigFemResultAddress& resVarAddr, double* meanValue ); 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, 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, 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<size_t>& scalarValuesHistogram( const RigFemResultAddress& resVarAddr ); const std::vector<size_t>& scalarValuesHistogram( const RigFemResultAddress& resVarAddr );
const std::vector<size_t>& scalarValuesHistogram( const RigFemResultAddress& resVarAddr, int frameIndex ); const std::vector<size_t>& scalarValuesHistogram( const RigFemResultAddress& resVarAddr, int stepIndex, int frameIndex );
void minMaxScalarValuesOverAllTensorComponents( const RigFemResultAddress& resVarAddr, void minMaxScalarValuesOverAllTensorComponents( const RigFemResultAddress& resVarAddr,
int stepIndex,
int frameIndex, int frameIndex,
double* localMin, double* localMin,
double* localMax ); double* localMax );
@ -159,6 +174,7 @@ public:
double* globalMin, double* globalMin,
double* globalMax ); double* globalMax );
void posNegClosestToZeroOverAllTensorComponents( const RigFemResultAddress& resVarAddr, void posNegClosestToZeroOverAllTensorComponents( const RigFemResultAddress& resVarAddr,
int stepIndex,
int frameIndex, int frameIndex,
double* localPosClosestToZero, double* localPosClosestToZero,
double* localNegClosestToZero ); double* localNegClosestToZero );
@ -177,7 +193,8 @@ public:
double normalizationAirGap() const; double normalizationAirGap() const;
void setReferenceTimeStep( int referenceTimeStep ); void setReferenceTimeStep( int referenceTimeStep );
int referenceTimeStep() const;
std::pair<int, int> referenceStepAndFrameIndex() const;
static std::set<RigFemResultAddress> referenceCaseDependentResults(); static std::set<RigFemResultAddress> referenceCaseDependentResults();
static bool isReferenceCaseDependentResult( const RigFemResultAddress& result ); static bool isReferenceCaseDependentResult( const RigFemResultAddress& result );
@ -197,6 +214,7 @@ public:
private: private:
RigFemScalarResultFrames* calculateDerivedResult( int partIndex, const RigFemResultAddress& resVarAddr ); RigFemScalarResultFrames* calculateDerivedResult( int partIndex, const RigFemResultAddress& resVarAddr );
std::vector<std::string> filteredTimeStepNames() const;
private: private:
cvf::Collection<RigFemPartResults> m_femPartResults; cvf::Collection<RigFemPartResults> m_femPartResults;
@ -239,4 +257,7 @@ private:
RigStatisticsDataCache* statistics( const RigFemResultAddress& resVarAddr ); RigStatisticsDataCache* statistics( const RigFemResultAddress& resVarAddr );
std::vector<RigFemResultAddress> getResAddrToComponentsToRead( const RigFemResultAddress& resVarAddr ); std::vector<RigFemResultAddress> getResAddrToComponentsToRead( const RigFemResultAddress& resVarAddr );
std::map<RigFemResultAddress, cvf::ref<RigStatisticsDataCache>> m_resultStatistics; std::map<RigFemResultAddress, cvf::ref<RigStatisticsDataCache>> m_resultStatistics;
std::vector<std::pair<int, int>> m_stepList;
std::vector<std::string> m_stepNames;
}; };

View File

@ -24,10 +24,10 @@
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RigFemScalarResultFrames::RigFemScalarResultFrames( int frameCount ) RigFemScalarResultFrames::RigFemScalarResultFrames( int timeStepCount )
{ {
m_dataForEachFrame.resize( frameCount ); m_dataForEachFrame.resize( timeStepCount );
m_isSingleFrameResult = false; 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<int>( m_dataForEachFrame.size() ); return static_cast<int>( m_dataForEachFrame.size() );
} }
@ -56,29 +56,57 @@ int RigFemScalarResultFrames::frameCount() const
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
std::vector<float>& RigFemScalarResultFrames::frameData( size_t frameIndex ) int RigFemScalarResultFrames::frameCount( int timeStepIndex ) const
{ {
if ( m_isSingleFrameResult ) if ( timeStepIndex >= timeStepCount() ) return 0;
{
return m_dataForEachFrame[0]; return static_cast<int>( m_dataForEachFrame[timeStepIndex].size() );
}
else
{
return m_dataForEachFrame[frameIndex];
}
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
const std::vector<float>& RigFemScalarResultFrames::frameData( size_t frameIndex ) const std::vector<float>& 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]; m_dataForEachFrame[timeStepIndex].resize( size_t( frameIndex + 1 ) );
}
else
{
return m_dataForEachFrame[frameIndex];
} }
return m_dataForEachFrame[timeStepIndex][frameIndex];
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const std::vector<float>& 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];
} }

View File

@ -28,16 +28,18 @@
class RigFemScalarResultFrames : public cvf::Object class RigFemScalarResultFrames : public cvf::Object
{ {
public: public:
explicit RigFemScalarResultFrames( int frameCount ); explicit RigFemScalarResultFrames( int timeStepCount );
~RigFemScalarResultFrames() override; ~RigFemScalarResultFrames() override;
void enableAsSingleFrameResult(); void enableAsSingleStepResult();
std::vector<float>& frameData( size_t frameIndex ); std::vector<float>& frameData( int timeStepIndex, int frameIndex );
const std::vector<float>& frameData( size_t frameIndex ) const; const std::vector<float>& frameData( int timeStepIndex, int frameIndex ) const;
int frameCount() const; int timeStepCount() const;
int frameCount( int timeStepIndex ) const;
private: private:
std::vector<std::vector<float>> m_dataForEachFrame; std::vector<std::vector<std::vector<float>>> m_dataForEachFrame;
bool m_isSingleFrameResult; std::vector<float> m_noData;
bool m_isSingleStepResult;
}; };

View File

@ -162,14 +162,14 @@ bool RigGeoMechCaseData::readFemParts( std::string* errorMessage, const std::vec
bool RigGeoMechCaseData::readDisplacements( std::string* errorMessage, bool RigGeoMechCaseData::readDisplacements( std::string* errorMessage,
int partId, int partId,
int timeStep, int timeStep,
int frameIndex,
std::vector<cvf::Vec3f>* displacements ) std::vector<cvf::Vec3f>* displacements )
{ {
CVF_ASSERT( errorMessage ); CVF_ASSERT( errorMessage );
#ifdef USE_ODB_API #ifdef USE_ODB_API
if ( m_readerInterface.notNull() && m_readerInterface->isOpen() ) if ( m_readerInterface.notNull() && m_readerInterface->isOpen() )
{ {
const auto& frames = m_readerInterface->frameTimes( timeStep ); m_readerInterface->readDisplacements( partId, timeStep, frameIndex, displacements );
m_readerInterface->readDisplacements( partId, timeStep, (int)frames.size() - 1, displacements );
return true; return true;
} }

View File

@ -41,7 +41,11 @@ public:
bool open( std::string* errorMessage ); bool open( std::string* errorMessage );
bool readTimeSteps( std::string* errorMessage, std::vector<std::string>* stepNames ); bool readTimeSteps( std::string* errorMessage, std::vector<std::string>* stepNames );
bool readFemParts( std::string* errorMessage, const std::vector<size_t>& timeStepFilter = std::vector<size_t>() ); bool readFemParts( std::string* errorMessage, const std::vector<size_t>& timeStepFilter = std::vector<size_t>() );
bool readDisplacements( std::string* errorMessage, int partId, int timeStep, std::vector<cvf::Vec3f>* displacements ); bool readDisplacements( std::string* errorMessage,
int partId,
int timeStep,
int frameIndex,
std::vector<cvf::Vec3f>* displacements );
RigFemPartCollection* femParts(); RigFemPartCollection* femParts();
const RigFemPartCollection* femParts() const; const RigFemPartCollection* femParts() const;

View File

@ -91,6 +91,7 @@ void RivFemElmVisibilityCalculator::computeRangeVisibility( cvf::UByteArray*
void RivFemElmVisibilityCalculator::computePropertyVisibility( cvf::UByteArray* cellVisibility, void RivFemElmVisibilityCalculator::computePropertyVisibility( cvf::UByteArray* cellVisibility,
const RigFemPart* part, const RigFemPart* part,
int timeStepIndex, int timeStepIndex,
int frameIndex,
const cvf::UByteArray* rangeFilterVisibility, const cvf::UByteArray* rangeFilterVisibility,
RimGeoMechPropertyFilterCollection* propFilterColl ) RimGeoMechPropertyFilterCollection* propFilterColl )
{ {
@ -124,7 +125,7 @@ void RivFemElmVisibilityCalculator::computePropertyVisibility( cvf::UByteArray*
resVarAddress.resultPosType = RIG_ELEMENT_NODAL; resVarAddress.resultPosType = RIG_ELEMENT_NODAL;
const std::vector<float>& resVals = const std::vector<float>& resVals =
caseData->femPartResults()->resultValues( resVarAddress, part->elementPartId(), timeStepIndex ); caseData->femPartResults()->resultValues( resVarAddress, part->elementPartId(), timeStepIndex, frameIndex );
if ( !propertyFilter->isActive() ) continue; if ( !propertyFilter->isActive() ) continue;
if ( !propertyFilter->resultDefinition->hasResult() ) continue; if ( !propertyFilter->resultDefinition->hasResult() ) continue;

View File

@ -43,6 +43,7 @@ public:
static void computePropertyVisibility( cvf::UByteArray* cellVisibility, static void computePropertyVisibility( cvf::UByteArray* cellVisibility,
const RigFemPart* grid, const RigFemPart* grid,
int timeStepIndex, int timeStepIndex,
int frameIndex,
const cvf::UByteArray* rangeFilterVisibility, const cvf::UByteArray* rangeFilterVisibility,
RimGeoMechPropertyFilterCollection* propFilterColl ); RimGeoMechPropertyFilterCollection* propFilterColl );

View File

@ -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 ); CVF_ASSERT( cellResultColors );
@ -297,7 +297,7 @@ void RivFemPartPartMgr::updateCellResultColor( size_t timeStepIndex, RimGeoMechC
} }
const std::vector<float>& resultValues = const std::vector<float>& resultValues =
caseData->femPartResults()->resultValues( resVarAddress, m_partIdx, (int)timeStepIndex ); caseData->femPartResults()->resultValues( resVarAddress, m_partIdx, timeStepIndex, frameIndex );
const std::vector<size_t>* vxToResultMapping = nullptr; const std::vector<size_t>* vxToResultMapping = nullptr;
int vxCount = 0; int vxCount = 0;

View File

@ -58,7 +58,7 @@ public:
void setDisplacements( bool useDisplacements, double scalingFactor, const std::vector<cvf::Vec3f>& displacements ); void setDisplacements( bool useDisplacements, double scalingFactor, const std::vector<cvf::Vec3f>& displacements );
void updateCellColor( cvf::Color4f color ); 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 ); void appendPartsToModel( cvf::ModelBasicList* model );

View File

@ -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 ) for ( size_t i = 0; i < m_femPartPartMgrs.size(); ++i )
{ {
m_femPartPartMgrs[i]->updateCellResultColor( timeStepIndex, cellResultColors ); m_femPartPartMgrs[i]->updateCellResultColor( timeStepIndex, frameIndex, cellResultColors );
} }
} }

View File

@ -57,7 +57,7 @@ public:
cvf::ref<cvf::UByteArray> cellVisibility( size_t partIndex ); cvf::ref<cvf::UByteArray> cellVisibility( size_t partIndex );
void updateCellColor( cvf::Color4f color ); 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<size_t>& partIndices ); void appendGridPartsToModel( cvf::ModelBasicList* model, const std::vector<size_t>& partIndices );
void appendGridPartsToModel( cvf::ModelBasicList* model ); void appendGridPartsToModel( cvf::ModelBasicList* model );

View File

@ -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_viewerStepIndex = aViewerTimeStep;
m_geometryType = aGeometryType; m_geometryType = aGeometryType;
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -98,9 +98,9 @@ void RivGeoMechPartMgrCache::Key::set( RivCellSetEnum aGeometryType, int aFrameI
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
bool RivGeoMechPartMgrCache::Key::operator<( const Key& other ) const 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 ); 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_geometryType( aGeometryType )
, m_frameIndex( aFrameIndex ) , m_viewerStepIndex( aViewerTimeStep )
{ {
} }

View File

@ -40,21 +40,21 @@ public:
public: public:
Key() Key()
: m_geometryType( -1 ) : 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; } unsigned short geometryType() const { return m_geometryType; }
bool operator<( const Key& other ) const; bool operator<( const Key& other ) const;
private: private:
int m_frameIndex; int m_viewerStepIndex;
unsigned short m_geometryType; unsigned short m_geometryType;
}; };

View File

@ -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<RivGeoMechPartMgrCache::Key> visiblePartMgrs = keysToVisiblePartMgrs( timeStepIndex ); std::vector<RivGeoMechPartMgrCache::Key> visiblePartMgrs = keysToVisiblePartMgrs( viewerStepIndex );
for ( size_t pmIdx = 0; pmIdx < visiblePartMgrs.size(); ++pmIdx ) for ( size_t pmIdx = 0; pmIdx < visiblePartMgrs.size(); ++pmIdx )
{ {
RivGeoMechPartMgr* partMgr = getUpdatedPartMgr( visiblePartMgrs[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<RivGeoMechPartMgrCache::Key> visiblePartMgrs = keysToVisiblePartMgrs( timeStepIndex ); std::vector<RivGeoMechPartMgrCache::Key> visiblePartMgrs = keysToVisiblePartMgrs( viewerStepIndex );
for ( size_t pmIdx = 0; pmIdx < visiblePartMgrs.size(); ++pmIdx ) for ( size_t pmIdx = 0; pmIdx < visiblePartMgrs.size(); ++pmIdx )
{ {
RivGeoMechPartMgr* partMgr = m_partMgrCache->partMgr( visiblePartMgrs[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<RivGeoMechPartMgrCache::Key> visiblePartMgrs = keysToVisiblePartMgrs( timeStepIndex ); std::vector<RivGeoMechPartMgrCache::Key> visiblePartMgrs = keysToVisiblePartMgrs( viewerStepIndex );
for ( size_t pmIdx = 0; pmIdx < visiblePartMgrs.size(); ++pmIdx ) for ( size_t pmIdx = 0; pmIdx < visiblePartMgrs.size(); ++pmIdx )
{ {
RivGeoMechPartMgr* partMgr = m_partMgrCache->partMgr( visiblePartMgrs[pmIdx] ); RivGeoMechPartMgr* partMgr = m_partMgrCache->partMgr( visiblePartMgrs[pmIdx] );
@ -114,15 +117,18 @@ void RivGeoMechVizLogic::scheduleGeometryRegen( RivCellSetEnum geometryType )
{ {
this->scheduleRegenOfDirectlyDependentGeometry( geometryType ); this->scheduleRegenOfDirectlyDependentGeometry( geometryType );
int frameCount = 0; bool resultsOk = ( m_geomechView->geoMechCase() && m_geomechView->geoMechCase()->geoMechData() &&
if ( 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 ); 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<RivGeoMechPartMgrCache::Key> visiblePartMgrs = keysToVisiblePartMgrs( timeStepIndex ); std::vector<RivGeoMechPartMgrCache::Key> visiblePartMgrs = keysToVisiblePartMgrs( viewerStepIndex );
for ( size_t pmIdx = 0; pmIdx < visiblePartMgrs.size(); ++pmIdx ) for ( size_t pmIdx = 0; pmIdx < visiblePartMgrs.size(); ++pmIdx )
{ {
m_partMgrCache->scheduleRegeneration( visiblePartMgrs[pmIdx] ); m_partMgrCache->scheduleRegeneration( visiblePartMgrs[pmIdx] );
@ -153,7 +159,7 @@ void RivGeoMechVizLogic::scheduleRegenOfDirectlyDependentGeometry( RivCellSetEnu
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
std::vector<RivGeoMechPartMgrCache::Key> RivGeoMechVizLogic::keysToVisiblePartMgrs( int timeStepIndex ) const std::vector<RivGeoMechPartMgrCache::Key> RivGeoMechVizLogic::keysToVisiblePartMgrs( int viewerStepIndex ) const
{ {
std::vector<RivGeoMechPartMgrCache::Key> visiblePartMgrs; std::vector<RivGeoMechPartMgrCache::Key> visiblePartMgrs;
if ( m_geomechView->viewController() && m_geomechView->viewController()->isVisibleCellsOveridden() ) if ( m_geomechView->viewController() && m_geomechView->viewController()->isVisibleCellsOveridden() )
@ -162,9 +168,9 @@ std::vector<RivGeoMechPartMgrCache::Key> RivGeoMechVizLogic::keysToVisiblePartMg
} }
else if ( m_geomechView->isGridVisualizationMode() ) 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() ) else if ( m_geomechView->cellFilterCollection()->hasActiveFilters() )
{ {
@ -207,10 +213,15 @@ RivGeoMechPartMgr* RivGeoMechVizLogic::getUpdatedPartMgr( RivGeoMechPartMgrCache
RivGeoMechPartMgr* partMgrToUpdate = m_partMgrCache->partMgr( pMgrKey ); RivGeoMechPartMgr* partMgrToUpdate = m_partMgrCache->partMgr( pMgrKey );
int partCount = 0; int partCount = 0;
RigGeoMechCaseData* caseData = nullptr; RigGeoMechCaseData* caseData = nullptr;
int timeStepIdx = -1;
int frameIdx = -1;
if ( m_geomechView->geoMechCase() ) if ( m_geomechView->geoMechCase() )
{ {
caseData = m_geomechView->geoMechCase()->geoMechData(); caseData = m_geomechView->geoMechCase()->geoMechData();
partCount = caseData->femParts()->partCount(); partCount = caseData->femParts()->partCount();
std::tie( timeStepIdx, frameIdx ) =
caseData->femPartResults()->stepListIndexToTimeStepAndDataFrameIndex( pMgrKey.viewerStepIndex() );
} }
if ( partMgrToUpdate->initializedFemPartCount() != partCount ) if ( partMgrToUpdate->initializedFemPartCount() != partCount )
@ -251,7 +262,8 @@ RivGeoMechPartMgr* RivGeoMechVizLogic::getUpdatedPartMgr( RivGeoMechPartMgrCache
RivFemElmVisibilityCalculator::computePropertyVisibility( elmVisibility.p(), RivFemElmVisibilityCalculator::computePropertyVisibility( elmVisibility.p(),
caseData->femParts()->part( femPartIdx ), caseData->femParts()->part( femPartIdx ),
pMgrKey.frameIndex(), timeStepIdx,
frameIdx,
rangeFiltVisibility.p(), rangeFiltVisibility.p(),
m_geomechView->geoMechPropertyFilterCollection() ); 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; if ( !m_geomechView->geoMechCase() ) return;
@ -298,7 +310,7 @@ void RivGeoMechVizLogic::calculateCurrentTotalCellVisibility( cvf::UByteArray* t
totalVisibility->resize( elmCount ); totalVisibility->resize( elmCount );
totalVisibility->setAll( false ); totalVisibility->setAll( false );
std::vector<RivGeoMechPartMgrCache::Key> visiblePartMgrs = keysToVisiblePartMgrs( timeStepIndex ); std::vector<RivGeoMechPartMgrCache::Key> visiblePartMgrs = keysToVisiblePartMgrs( viewerStepIndex );
for ( size_t pmIdx = 0; pmIdx < visiblePartMgrs.size(); ++pmIdx ) for ( size_t pmIdx = 0; pmIdx < visiblePartMgrs.size(); ++pmIdx )
{ {
RivGeoMechPartMgr* partMgr = getUpdatedPartMgr( visiblePartMgrs[pmIdx] ); RivGeoMechPartMgr* partMgr = getUpdatedPartMgr( visiblePartMgrs[pmIdx] );

View File

@ -43,13 +43,13 @@ public:
~RivGeoMechVizLogic() override; ~RivGeoMechVizLogic() override;
void appendNoAnimPartsToModel( cvf::ModelBasicList* model ); void appendNoAnimPartsToModel( cvf::ModelBasicList* model );
void appendPartsToModel( int timeStepIndex, cvf::ModelBasicList* model ); void appendPartsToModel( int viewerStepIndex, cvf::ModelBasicList* model );
void updateCellResultColor( int timeStepIndex, RimGeoMechCellColors* cellResultColors ); void updateCellResultColor( int viewerStepIndex, int timeStepIndex, int frameIndex, RimGeoMechCellColors* cellResultColors );
void updateStaticCellColors( int timeStepIndex ); void updateStaticCellColors( int viewerStepIndex );
void scheduleGeometryRegen( RivCellSetEnum geometryType ); void scheduleGeometryRegen( RivCellSetEnum geometryType );
void scheduleGeometryRegenOfVisiblePartMgrs( int timeStepIndex ); void scheduleGeometryRegenOfVisiblePartMgrs( int viewerStepIndex );
void calculateCurrentTotalCellVisibility( cvf::UByteArray* totalVisibility, int timeStepIndex ); void calculateCurrentTotalCellVisibility( cvf::UByteArray* totalVisibility, int viewerStepIndex );
std::vector<RivGeoMechPartMgrCache::Key> keysToVisiblePartMgrs( int timeStepIndex ) const; std::vector<RivGeoMechPartMgrCache::Key> keysToVisiblePartMgrs( int viewerStepIndex ) const;
const cvf::ref<RivGeoMechPartMgrCache> partMgrCache() const; const cvf::ref<RivGeoMechPartMgrCache> partMgrCache() const;
static cvf::Color3f staticCellColor(); static cvf::Color3f staticCellColor();

View File

@ -45,6 +45,7 @@ public:
virtual std::vector<std::string> allStepNames() const = 0; virtual std::vector<std::string> allStepNames() const = 0;
virtual std::vector<std::string> filteredStepNames() const = 0; virtual std::vector<std::string> filteredStepNames() const = 0;
virtual std::vector<double> frameTimes( int stepIndex ) const = 0; virtual std::vector<double> frameTimes( int stepIndex ) const = 0;
virtual int frameCount( int stepIndex ) const = 0;
virtual std::vector<std::string> elementSetNames( int partIndex ) = 0; virtual std::vector<std::string> elementSetNames( int partIndex ) = 0;
virtual std::vector<size_t> elementSet( int partIndex, int setIndex ) = 0; virtual std::vector<size_t> elementSet( int partIndex, int setIndex ) = 0;

View File

@ -480,6 +480,14 @@ std::vector<double> RifOdbReader::frameTimes( int stepIndex ) const
return frameValues; return frameValues;
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RifOdbReader::frameCount( int stepIndex ) const
{
return frameTimes( stepIndex ).size();
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@ -47,6 +47,7 @@ public:
std::vector<std::string> allStepNames() const override; std::vector<std::string> allStepNames() const override;
std::vector<std::string> filteredStepNames() const override; std::vector<std::string> filteredStepNames() const override;
std::vector<double> frameTimes( int stepIndex ) const override; std::vector<double> frameTimes( int stepIndex ) const override;
int frameCount( int stepIndex ) const override;
std::vector<std::string> elementSetNames( int partIndex ) override; std::vector<std::string> elementSetNames( int partIndex ) override;
std::vector<size_t> elementSet( int partIndex, int setIndex ) override; std::vector<size_t> elementSet( int partIndex, int setIndex ) override;

View File

@ -81,7 +81,7 @@ void RivBoxIntersectionPartMgr::applySingleColorEffect()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RivBoxIntersectionPartMgr::updateCellResultColor( size_t timeStepIndex ) void RivBoxIntersectionPartMgr::updateCellResultColor( int timeStepIndex )
{ {
RivIntersectionResultsColoringTools::calculateIntersectionResultColors( timeStepIndex, RivIntersectionResultsColoringTools::calculateIntersectionResultColors( timeStepIndex,
true, true,

View File

@ -56,7 +56,7 @@ public:
explicit RivBoxIntersectionPartMgr( RimBoxIntersection* intersectionBox ); explicit RivBoxIntersectionPartMgr( RimBoxIntersection* intersectionBox );
void applySingleColorEffect(); void applySingleColorEffect();
void updateCellResultColor( size_t timeStepIndex ); void updateCellResultColor( int timeStepIndex );
void appendNativeIntersectionFacesToModel( cvf::ModelBasicList* model, cvf::Transform* scaleTransform ); void appendNativeIntersectionFacesToModel( cvf::ModelBasicList* model, cvf::Transform* scaleTransform );
void appendMeshLinePartsToModel( cvf::ModelBasicList* model, cvf::Transform* scaleTransform ); void appendMeshLinePartsToModel( cvf::ModelBasicList* model, cvf::Transform* scaleTransform );

View File

@ -154,7 +154,7 @@ void RivExtrudedCurveIntersectionPartMgr::applySingleColorEffect()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RivExtrudedCurveIntersectionPartMgr::updateCellResultColor( size_t timeStepIndex, void RivExtrudedCurveIntersectionPartMgr::updateCellResultColor( int timeStepIndex,
const cvf::ScalarMapper* explicitScalarColorMapper, const cvf::ScalarMapper* explicitScalarColorMapper,
const RivTernaryScalarMapper* explicitTernaryColorMapper ) const RivTernaryScalarMapper* explicitTernaryColorMapper )
{ {

View File

@ -69,7 +69,7 @@ public:
explicit RivExtrudedCurveIntersectionPartMgr( RimExtrudedCurveIntersection* rimIntersection, bool isFlattened = false ); explicit RivExtrudedCurveIntersectionPartMgr( RimExtrudedCurveIntersection* rimIntersection, bool isFlattened = false );
void applySingleColorEffect(); void applySingleColorEffect();
void updateCellResultColor( size_t timeStepIndex, void updateCellResultColor( int timeStepIndex,
const cvf::ScalarMapper* explicitScalarColorMapper, const cvf::ScalarMapper* explicitScalarColorMapper,
const RivTernaryScalarMapper* explicitTernaryColorMapper ); const RivTernaryScalarMapper* explicitTernaryColorMapper );

View File

@ -51,7 +51,7 @@
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RivIntersectionResultsColoringTools::calculateIntersectionResultColors( void RivIntersectionResultsColoringTools::calculateIntersectionResultColors(
size_t timeStepIndex, int timeStepIndex,
bool useSeparateIntersectionResDefTimeStep, bool useSeparateIntersectionResDefTimeStep,
RimIntersection* rimIntersectionHandle, RimIntersection* rimIntersectionHandle,
const RivIntersectionGeometryGeneratorInterface* intersectionGeomGenIF, const RivIntersectionGeometryGeneratorInterface* intersectionGeomGenIF,
@ -227,7 +227,7 @@ void RivIntersectionResultsColoringTools::updateEclipseTernaryCellResultColors(
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RivIntersectionResultsColoringTools::updateGeoMechCellResultColors( void RivIntersectionResultsColoringTools::updateGeoMechCellResultColors(
const RimGeoMechResultDefinition* geomResultDef, const RimGeoMechResultDefinition* geomResultDef,
size_t timeStepIndex, int viewerTimeStepIndex,
const cvf::ScalarMapper* scalarColorMapper, const cvf::ScalarMapper* scalarColorMapper,
bool isLightingDisabled, bool isLightingDisabled,
const RivIntersectionGeometryGeneratorInterface* geomGenerator, const RivIntersectionGeometryGeneratorInterface* geomGenerator,
@ -243,6 +243,8 @@ void RivIntersectionResultsColoringTools::updateGeoMechCellResultColors(
if ( !caseData ) return; if ( !caseData ) return;
auto [stepIdx, frameIdx] = caseData->femPartResults()->stepListIndexToTimeStepAndDataFrameIndex( viewerTimeStepIndex );
const std::vector<size_t>& triangleToCellIdx = geomGenerator->triangleToCellIndex(); const std::vector<size_t>& triangleToCellIdx = geomGenerator->triangleToCellIndex();
const cvf::Vec3fArray* triangelVxes = geomGenerator->triangleVxes(); const cvf::Vec3fArray* triangelVxes = geomGenerator->triangleVxes();
const std::vector<RivIntersectionVertexWeights>& vertexWeights = const std::vector<RivIntersectionVertexWeights>& vertexWeights =
@ -253,7 +255,7 @@ void RivIntersectionResultsColoringTools::updateGeoMechCellResultColors(
if ( caseData->femPartResults()->partCount() == 1 ) if ( caseData->femPartResults()->partCount() == 1 )
{ {
const std::vector<float>& resultValues = const std::vector<float>& resultValues =
caseData->femPartResults()->resultValues( resVarAddress, 0, (int)timeStepIndex ); caseData->femPartResults()->resultValues( resVarAddress, 0, stepIdx, frameIdx );
RivIntersectionResultsColoringTools::calculateElementBasedGeoMechTextureCoords( intersectionFacesTextureCoords, RivIntersectionResultsColoringTools::calculateElementBasedGeoMechTextureCoords( intersectionFacesTextureCoords,
resultValues, resultValues,
@ -263,7 +265,7 @@ void RivIntersectionResultsColoringTools::updateGeoMechCellResultColors(
else else
{ {
std::vector<float> resultValues; std::vector<float> resultValues;
caseData->femPartResults()->globalResultValues( resVarAddress, (int)timeStepIndex, resultValues ); caseData->femPartResults()->globalResultValues( resVarAddress, stepIdx, frameIdx, resultValues );
RivIntersectionResultsColoringTools::calculateElementBasedGeoMechTextureCoords( intersectionFacesTextureCoords, RivIntersectionResultsColoringTools::calculateElementBasedGeoMechTextureCoords( intersectionFacesTextureCoords,
resultValues, resultValues,
@ -291,7 +293,9 @@ void RivIntersectionResultsColoringTools::updateGeoMechCellResultColors(
vertexWeights, vertexWeights,
caseData, caseData,
resVarAddress, resVarAddress,
(int)timeStepIndex, 0,
stepIdx,
frameIdx,
scalarColorMapper ); scalarColorMapper );
} }
} }
@ -311,7 +315,7 @@ void RivIntersectionResultsColoringTools::updateGeoMechCellResultColors(
if ( caseData->femPartResults()->partCount() == 1 ) if ( caseData->femPartResults()->partCount() == 1 )
{ {
const std::vector<float>& resultValues = const std::vector<float>& resultValues =
caseData->femPartResults()->resultValues( resVarAddress, 0, (int)timeStepIndex ); caseData->femPartResults()->resultValues( resVarAddress, 0, stepIdx, frameIdx );
RivIntersectionResultsColoringTools::calculateNodeOrElementNodeBasedGeoMechTextureCoords( intersectionFacesTextureCoords, RivIntersectionResultsColoringTools::calculateNodeOrElementNodeBasedGeoMechTextureCoords( intersectionFacesTextureCoords,
vertexWeights, vertexWeights,
resultValues, resultValues,
@ -322,7 +326,7 @@ void RivIntersectionResultsColoringTools::updateGeoMechCellResultColors(
else else
{ {
std::vector<float> resultValues; std::vector<float> resultValues;
caseData->femPartResults()->globalResultValues( resVarAddress, (int)timeStepIndex, resultValues ); caseData->femPartResults()->globalResultValues( resVarAddress, stepIdx, frameIdx, resultValues );
RivIntersectionResultsColoringTools::calculateNodeOrElementNodeBasedGeoMechTextureCoords( intersectionFacesTextureCoords, RivIntersectionResultsColoringTools::calculateNodeOrElementNodeBasedGeoMechTextureCoords( intersectionFacesTextureCoords,
vertexWeights, vertexWeights,
@ -427,10 +431,12 @@ void RivIntersectionResultsColoringTools::calculateGeoMechTensorXfTextureCoords(
const std::vector<RivIntersectionVertexWeights>& vertexWeights, const std::vector<RivIntersectionVertexWeights>& vertexWeights,
RigGeoMechCaseData* caseData, RigGeoMechCaseData* caseData,
const RigFemResultAddress& resVarAddress, const RigFemResultAddress& resVarAddress,
int partIdx,
int timeStepIdx, int timeStepIdx,
int frameIdx,
const cvf::ScalarMapper* mapper ) const cvf::ScalarMapper* mapper )
{ {
RiuGeoMechXfTensorResultAccessor accessor( caseData->femPartResults(), resVarAddress, timeStepIdx ); RiuGeoMechXfTensorResultAccessor accessor( caseData->femPartResults(), resVarAddress, partIdx, timeStepIdx, frameIdx );
textureCoords->resize( vertexWeights.size() ); textureCoords->resize( vertexWeights.size() );
cvf::Vec2f* rawPtr = textureCoords->ptr(); cvf::Vec2f* rawPtr = textureCoords->ptr();

View File

@ -42,7 +42,7 @@ class ScalarMapper;
class RivIntersectionResultsColoringTools class RivIntersectionResultsColoringTools
{ {
public: public:
static void calculateIntersectionResultColors( size_t timeStepIndex, static void calculateIntersectionResultColors( int timeStepIndex,
bool useSeparateIntersectionResDefTimeStep, bool useSeparateIntersectionResDefTimeStep,
RimIntersection* rimIntersectionHandle, RimIntersection* rimIntersectionHandle,
const RivIntersectionGeometryGeneratorInterface* intersectionGeomGenIF, const RivIntersectionGeometryGeneratorInterface* intersectionGeomGenIF,
@ -69,7 +69,7 @@ private:
cvf::Vec2fArray* m_intersectionBoxFacesTextureCoords ); cvf::Vec2fArray* m_intersectionBoxFacesTextureCoords );
static void updateGeoMechCellResultColors( const RimGeoMechResultDefinition* geomResultDef, static void updateGeoMechCellResultColors( const RimGeoMechResultDefinition* geomResultDef,
size_t timeStepIndex, int timeStepIndex,
const cvf::ScalarMapper* scalarColorMapper, const cvf::ScalarMapper* scalarColorMapper,
bool isLightingDisabled, bool isLightingDisabled,
const RivIntersectionGeometryGeneratorInterface* geomGenerator, const RivIntersectionGeometryGeneratorInterface* geomGenerator,
@ -99,7 +99,9 @@ private:
const std::vector<RivIntersectionVertexWeights>& vertexWeights, const std::vector<RivIntersectionVertexWeights>& vertexWeights,
RigGeoMechCaseData* caseData, RigGeoMechCaseData* caseData,
const RigFemResultAddress& resVarAddress, const RigFemResultAddress& resVarAddress,
int partIdx,
int timeStepIdx, int timeStepIdx,
int frameIdx,
const cvf::ScalarMapper* mapper ); const cvf::ScalarMapper* mapper );
static void calculatePlaneAngleTextureCoords( cvf::Vec2fArray* textureCoords, static void calculatePlaneAngleTextureCoords( cvf::Vec2fArray* textureCoords,

View File

@ -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 ); CVF_ASSERT( model );
@ -93,7 +96,8 @@ void RivTensorResultPartMgr::appendDynamicGeometryPartsToModel( cvf::ModelBasicL
for ( int partIdx = 0; partIdx < femParts->partCount(); partIdx++ ) for ( int partIdx = 0; partIdx < femParts->partCount(); partIdx++ )
{ {
std::vector<caf::Ten3f> vertexTensors = resultCollection->tensors( address, partIdx, (int)frameIndex ); std::vector<caf::Ten3f> vertexTensors =
resultCollection->tensors( address, partIdx, localTimeStepIndex, frameIndex );
if ( vertexTensors.empty() ) continue; if ( vertexTensors.empty() ) continue;
const RigFemPart* part = femParts->part( partIdx ); const RigFemPart* part = femParts->part( partIdx );
@ -108,7 +112,7 @@ void RivTensorResultPartMgr::appendDynamicGeometryPartsToModel( cvf::ModelBasicL
calculatePrincipalsAndDirections( elmTensors, &elmPrincipals, &elmPrincipalDirections ); calculatePrincipalsAndDirections( elmTensors, &elmPrincipals, &elmPrincipalDirections );
std::vector<RivGeoMechPartMgrCache::Key> partKeys = std::vector<RivGeoMechPartMgrCache::Key> partKeys =
m_rimReservoirView->vizLogic()->keysToVisiblePartMgrs( (int)frameIndex ); m_rimReservoirView->vizLogic()->keysToVisiblePartMgrs( viewerStepIndex );
RigFemPartNodes nodes = part->nodes(); RigFemPartNodes nodes = part->nodes();

View File

@ -50,7 +50,10 @@ public:
RivTensorResultPartMgr( RimGeoMechView* reservoirView ); RivTensorResultPartMgr( RimGeoMechView* reservoirView );
~RivTensorResultPartMgr() override; ~RivTensorResultPartMgr() override;
void appendDynamicGeometryPartsToModel( cvf::ModelBasicList* model, size_t frameIndex ) const; void appendDynamicGeometryPartsToModel( cvf::ModelBasicList* model,
int viewerStepIndex,
int localTimeStepIndex,
int frameIndex ) const;
private: private:
struct TensorVisualization struct TensorVisualization

View File

@ -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() ) if ( m_intersectionFaces.notNull() )
{ {

View File

@ -44,7 +44,7 @@ public:
explicit RivSurfacePartMgr( RimSurfaceInView* surface ); explicit RivSurfacePartMgr( RimSurfaceInView* surface );
void updateNativeSurfaceColors(); void updateNativeSurfaceColors();
void updateCellResultColor( size_t timeStepIndex ); void updateCellResultColor( int timeStepIndex );
void appendIntersectionGeometryPartsToModel( cvf::ModelBasicList* model, cvf::Transform* scaleTransform ); void appendIntersectionGeometryPartsToModel( cvf::ModelBasicList* model, cvf::Transform* scaleTransform );
void appendNativeGeometryPartsToModel( cvf::ModelBasicList* model, cvf::Transform* scaleTransform ); void appendNativeGeometryPartsToModel( cvf::ModelBasicList* model, cvf::Transform* scaleTransform );

View File

@ -792,15 +792,19 @@ void RimPolygonFilter::updateCellsForGeoMech( const std::vector<cvf::Vec3d>& poi
{ {
if ( gCase->geoMechData() && gCase->geoMechData()->femParts()->partCount() > 0 ) 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 ) if ( m_polyFilterMode == PolygonFilterModeType::DEPTH_Z )
{ {
updateCellsDepthGeoMech( points, grid ); updateCellsDepthGeoMech( points, grid );
} }
else if ( m_polyFilterMode == PolygonFilterModeType::INDEX_K ) else if ( m_polyFilterMode == PolygonFilterModeType::INDEX_K )
{ {
updateCellsKIndexGeoMech( points, grid ); updateCellsKIndexGeoMech( points, grid );
}
} }
} }
} }

View File

@ -483,7 +483,7 @@ QStringList RimGeoMechCase::timeStepStrings() const
const RigGeoMechCaseData* rigCaseData = geoMechData(); const RigGeoMechCaseData* rigCaseData = geoMechData();
if ( rigCaseData && rigCaseData->femPartResults() ) if ( rigCaseData && rigCaseData->femPartResults() )
{ {
std::vector<std::string> stepNames = rigCaseData->femPartResults()->filteredStepNames(); std::vector<std::string> stepNames = rigCaseData->femPartResults()->stepNames();
for ( size_t i = 0; i < stepNames.size(); i++ ) for ( size_t i = 0; i < stepNames.size(); i++ )
{ {
stringList += QString::fromStdString( stepNames[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(); const RigGeoMechCaseData* rigCaseData = geoMechData();
if ( rigCaseData && rigCaseData->femPartResults() ) if ( rigCaseData && rigCaseData->femPartResults() )
{ {
std::vector<std::string> stepNames = rigCaseData->femPartResults()->filteredStepNames(); std::vector<std::string> stepNames = rigCaseData->femPartResults()->stepNames();
if ( frameIdx < static_cast<int>( stepNames.size() ) ) if ( timeStepIdx < static_cast<int>( stepNames.size() ) )
{ {
return QString::fromStdString( stepNames[frameIdx] ); return QString::fromStdString( stepNames[timeStepIdx] );
} }
} }
@ -519,28 +519,31 @@ cvf::BoundingBox RimGeoMechCase::reservoirBoundingBox()
cvf::BoundingBox boundingBox; cvf::BoundingBox boundingBox;
RigGeoMechCaseData* rigCaseData = this->geoMechData(); RigGeoMechCaseData* rigCaseData = this->geoMechData();
if ( rigCaseData && rigCaseData->femPartResults() && rigCaseData->femParts()->part( 0 ) ) if ( rigCaseData && rigCaseData->femPartResults() && rigCaseData->femParts() )
{ {
RigFemPart* femPart = rigCaseData->femParts()->part( 0 ); for ( int p = 0; p < rigCaseData->femParts()->partCount(); p++ )
const RigFemPartGrid* femPartGrid = femPart->getOrCreateStructGrid();
RigFemResultAddress porBarAddr( RigFemResultPosEnum::RIG_ELEMENT_NODAL, "POR-Bar", "" );
const std::vector<float>& resultValues = rigCaseData->femPartResults()->resultValues( porBarAddr, 0, 0 );
for ( int i = 0; i < femPart->elementCount(); ++i )
{ {
size_t resValueIdx = femPart->elementNodeResultIdx( (int)i, 0 ); RigFemPart* femPart = rigCaseData->femParts()->part( p );
CVF_ASSERT( resValueIdx < resultValues.size() ); const RigFemPartGrid* femPartGrid = femPart->getOrCreateStructGrid();
double scalarValue = resultValues[resValueIdx];
bool validPorValue = scalarValue != std::numeric_limits<double>::infinity();
if ( validPorValue ) RigFemResultAddress porBarAddr( RigFemResultPosEnum::RIG_ELEMENT_NODAL, "POR-Bar", "" );
const std::vector<float>& resultValues = rigCaseData->femPartResults()->resultValues( porBarAddr, p, 0, 0 );
for ( int i = 0; i < femPart->elementCount(); ++i )
{ {
std::array<cvf::Vec3d, 8> hexCorners; size_t resValueIdx = femPart->elementNodeResultIdx( (int)i, 0 );
femPartGrid->cellCornerVertices( i, hexCorners.data() ); CVF_ASSERT( resValueIdx < resultValues.size() );
for ( size_t c = 0; c < 8; ++c ) double scalarValue = resultValues[resValueIdx];
bool validPorValue = scalarValue != std::numeric_limits<double>::infinity();
if ( validPorValue )
{ {
boundingBox.add( hexCorners[c] ); std::array<cvf::Vec3d, 8> hexCorners;
femPartGrid->cellCornerVertices( i, hexCorners.data() );
for ( size_t c = 0; c < 8; ++c )
{
boundingBox.add( hexCorners[c] );
}
} }
} }
} }

View File

@ -87,7 +87,7 @@ public:
std::vector<QDateTime> timeStepDates() const override; std::vector<QDateTime> timeStepDates() const override;
QStringList timeStepStrings() const override; QStringList timeStepStrings() const override;
QString timeStepName( int frameIdx ) const override; QString timeStepName( int timeStepIdx ) const override;
cvf::BoundingBox reservoirBoundingBox() override; cvf::BoundingBox reservoirBoundingBox() override;
cvf::BoundingBox activeCellsBoundingBox() const override; cvf::BoundingBox activeCellsBoundingBox() const override;

View File

@ -159,9 +159,12 @@ cvf::ref<cvf::UByteArray> RimGeoMechContourMapProjection::getCellVisibility() co
} }
if ( view()->propertyFilterCollection()->isActive() ) if ( view()->propertyFilterCollection()->isActive() )
{ {
auto [stepIdx, frameIdx] = view()->currentStepAndDataFrame();
RivFemElmVisibilityCalculator::computePropertyVisibility( cellGridIdxVisibility.p(), RivFemElmVisibilityCalculator::computePropertyVisibility( cellGridIdxVisibility.p(),
m_femPart.p(), m_femPart.p(),
view()->currentTimeStep(), stepIdx,
frameIdx,
cellGridIdxVisibility.p(), cellGridIdxVisibility.p(),
view()->geoMechPropertyFilterCollection() ); view()->geoMechPropertyFilterCollection() );
} }
@ -172,7 +175,7 @@ cvf::ref<cvf::UByteArray> 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, RigFemResultAddress porBarAddr( RigFemResultPosEnum::RIG_ELEMENT_NODAL,
"POR-Bar", "POR-Bar",
@ -180,7 +183,7 @@ cvf::BoundingBox RimGeoMechContourMapProjection::calculateExpandedPorBarBBox( in
RigGeoMechCaseData* caseData = geoMechCase()->geoMechData(); RigGeoMechCaseData* caseData = geoMechCase()->geoMechData();
RigFemPartResultsCollection* resultCollection = caseData->femPartResults(); RigFemPartResultsCollection* resultCollection = caseData->femPartResults();
const std::vector<float>& resultValues = resultCollection->resultValues( porBarAddr, 0, timeStep ); const std::vector<float>& resultValues = resultCollection->resultValues( porBarAddr, 0, timeStep, frameIndex );
cvf::BoundingBox boundingBox; cvf::BoundingBox boundingBox;
if ( resultValues.empty() ) if ( resultValues.empty() )
@ -230,7 +233,9 @@ void RimGeoMechContourMapProjection::updateGridInformation()
if ( m_limitToPorePressureRegions ) if ( m_limitToPorePressureRegions )
{ {
m_expandedBoundingBox = calculateExpandedPorBarBBox( view()->currentTimeStep() ); auto [stepIdx, frameIdx] = view()->currentStepAndDataFrame();
m_expandedBoundingBox = calculateExpandedPorBarBBox( stepIdx, frameIdx );
if ( !m_expandedBoundingBox.isValid() ) if ( !m_expandedBoundingBox.isValid() )
{ {
m_limitToPorePressureRegions = false; m_limitToPorePressureRegions = false;
@ -333,12 +338,13 @@ std::vector<double> RimGeoMechContourMapProjection::retrieveParameterWeights()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
std::vector<double> RimGeoMechContourMapProjection::generateResults( int timeStep ) std::vector<double> RimGeoMechContourMapProjection::generateResults( int viewerStepIndex )
{ {
RimGeoMechCellColors* cellColors = view()->cellResult(); RimGeoMechCellColors* cellColors = view()->cellResult();
RigFemResultAddress resultAddress = cellColors->resultAddress(); RigFemResultAddress resultAddress = cellColors->resultAddress();
std::vector<double> aggregatedResults = generateResultsFromAddress( resultAddress, m_mapCellVisibility, timeStep ); std::vector<double> aggregatedResults =
generateResultsFromAddress( resultAddress, m_mapCellVisibility, viewerStepIndex );
return aggregatedResults; return aggregatedResults;
} }
@ -348,13 +354,15 @@ std::vector<double> RimGeoMechContourMapProjection::generateResults( int timeSte
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
std::vector<double> RimGeoMechContourMapProjection::generateResultsFromAddress( RigFemResultAddress resultAddress, std::vector<double> RimGeoMechContourMapProjection::generateResultsFromAddress( RigFemResultAddress resultAddress,
const std::vector<bool>& mapCellVisibility, const std::vector<bool>& mapCellVisibility,
int timeStep ) int viewerStepIndex )
{ {
RigGeoMechCaseData* caseData = geoMechCase()->geoMechData(); RigGeoMechCaseData* caseData = geoMechCase()->geoMechData();
RigFemPartResultsCollection* resultCollection = caseData->femPartResults(); RigFemPartResultsCollection* resultCollection = caseData->femPartResults();
size_t nCells = numberOfCells(); size_t nCells = numberOfCells();
std::vector<double> aggregatedResults = std::vector<double>( nCells, std::numeric_limits<double>::infinity() ); std::vector<double> aggregatedResults = std::vector<double>( nCells, std::numeric_limits<double>::infinity() );
auto [stepIdx, frameIdx] = caseData->femPartResults()->stepListIndexToTimeStepAndDataFrameIndex( viewerStepIndex );
bool wasInvalid = false; bool wasInvalid = false;
if ( !resultAddress.isValid() ) if ( !resultAddress.isValid() )
{ {
@ -375,7 +383,7 @@ std::vector<double> RimGeoMechContourMapProjection::generateResultsFromAddress(
resultAddress.resultPosType = RIG_ELEMENT_NODAL; // formation indices are stored per element node result. resultAddress.resultPosType = RIG_ELEMENT_NODAL; // formation indices are stored per element node result.
} }
std::vector<float> resultValuesF = resultCollection->resultValues( resultAddress, 0, timeStep ); std::vector<float> resultValuesF = resultCollection->resultValues( resultAddress, 0, stepIdx, frameIdx );
if ( resultValuesF.empty() ) return aggregatedResults; if ( resultValuesF.empty() ) return aggregatedResults;
std::vector<double> resultValues = gridCellValues( resultAddress, resultValuesF ); std::vector<double> resultValues = gridCellValues( resultAddress, resultValuesF );
@ -672,3 +680,32 @@ void RimGeoMechContourMapProjection::defineEditorAttribute( const caf::PdmFieldH
} }
} }
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::pair<double, double> 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<double> 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 );
}

View File

@ -62,14 +62,14 @@ protected:
// GeoMech implementation specific data generation methods // GeoMech implementation specific data generation methods
cvf::ref<cvf::UByteArray> getCellVisibility() const override; cvf::ref<cvf::UByteArray> getCellVisibility() const override;
cvf::BoundingBox calculateExpandedPorBarBBox( int timeStep ) const; cvf::BoundingBox calculateExpandedPorBarBBox( int timeStep, int frameIndex ) const;
void updateGridInformation() override; void updateGridInformation() override;
std::vector<bool> getMapCellVisibility() override; std::vector<bool> getMapCellVisibility() override;
std::vector<double> retrieveParameterWeights() override; std::vector<double> retrieveParameterWeights() override;
std::vector<double> generateResults( int timeStep ) override; std::vector<double> generateResults( int viewerStepIndex ) override;
std::vector<double> generateResultsFromAddress( RigFemResultAddress resultAddress, std::vector<double> generateResultsFromAddress( RigFemResultAddress resultAddress,
const std::vector<bool>& mapCellVisibility, const std::vector<bool>& mapCellVisibility,
int timeStep ); int viewerStepIndex );
bool resultVariableChanged() const override; bool resultVariableChanged() const override;
void clearResultVariable() override; void clearResultVariable() override;
RimGridView* baseView() const override; RimGridView* baseView() const override;
@ -85,6 +85,8 @@ protected:
RimGeoMechCase* geoMechCase() const; RimGeoMechCase* geoMechCase() const;
RimGeoMechContourMapView* view() const; RimGeoMechContourMapView* view() const;
std::pair<double, double> minmaxValuesAllTimeSteps() override;
void updateAfterResultGeneration( int timeStep ) override; void updateAfterResultGeneration( int timeStep ) override;
protected: protected:

View File

@ -260,7 +260,7 @@ void RimGeoMechContourMapView::updateGeometry()
{ // Step 1: generate results. About 30% of the time. { // Step 1: generate results. About 30% of the time.
if ( m_contourMapProjection->isChecked() ) if ( m_contourMapProjection->isChecked() )
{ {
m_contourMapProjection->generateResultsIfNecessary( m_currentTimeStep() ); m_contourMapProjection->generateResultsIfNecessary( m_currentTimeStep );
} }
onUpdateLegends(); onUpdateLegends();

View File

@ -249,7 +249,7 @@ QList<caf::PdmOptionItemInfo>
std::vector<std::string> stepNames; std::vector<std::string> stepNames;
if ( m_geomCase->geoMechData() ) 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() ) ); options.push_back( caf::PdmOptionItemInfo( QString( "Disabled" ), RigFemResultAddress::noTimeLapseValue() ) );
@ -265,7 +265,7 @@ QList<caf::PdmOptionItemInfo>
std::vector<std::string> stepNames; std::vector<std::string> stepNames;
if ( m_geomCase->geoMechData() ) 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 ) for ( size_t stepIdx = 0; stepIdx < stepNames.size(); ++stepIdx )
@ -698,14 +698,14 @@ QString RimGeoMechResultDefinition::diffResultUiName() const
{ {
if ( referenceCaseDependentResultSelected() ) if ( referenceCaseDependentResultSelected() )
{ {
std::vector<std::string> stepNames = m_geomCase->geoMechData()->femPartResults()->filteredStepNames(); std::vector<std::string> timeStepNames = m_geomCase->geoMechData()->femPartResults()->stepNames();
QString timeStepString = QString::fromStdString( stepNames[m_referenceTimeStep()] ); QString timeStepString = QString::fromStdString( timeStepNames[m_referenceTimeStep()] );
diffResultString += QString( "<b>Reference Time Step</b>: %1" ).arg( timeStepString ); diffResultString += QString( "<b>Reference Time Step</b>: %1" ).arg( timeStepString );
} }
else if ( m_timeLapseBaseTimestep != RigFemResultAddress::noTimeLapseValue() ) else if ( m_timeLapseBaseTimestep != RigFemResultAddress::noTimeLapseValue() )
{ {
std::vector<std::string> stepNames = m_geomCase->geoMechData()->femPartResults()->filteredStepNames(); std::vector<std::string> timeStepNames = m_geomCase->geoMechData()->femPartResults()->stepNames();
QString timeStepString = QString::fromStdString( stepNames[m_timeLapseBaseTimestep()] ); QString timeStepString = QString::fromStdString( timeStepNames[m_timeLapseBaseTimestep()] );
diffResultString += QString( "<b>Base Time Step</b>: %1" ).arg( timeStepString ); diffResultString += QString( "<b>Base Time Step</b>: %1" ).arg( timeStepString );
} }
} }
@ -943,7 +943,7 @@ void RimGeoMechResultDefinition::setResultAddress( const RigFemResultAddress& re
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimGeoMechResultDefinition::updateLegendTextAndRanges( RimRegularLegendConfig* legendConfigToUpdate, void RimGeoMechResultDefinition::updateLegendTextAndRanges( RimRegularLegendConfig* legendConfigToUpdate,
const QString& legendHeading, const QString& legendHeading,
int timeStepIndex ) int viewerStepIndex )
{ {
if ( !this->ownerCaseData() || !( this->resultAddress().isValid() ) ) if ( !this->ownerCaseData() || !( this->resultAddress().isValid() ) )
{ {
@ -960,8 +960,14 @@ void RimGeoMechResultDefinition::updateLegendTextAndRanges( RimRegularLegendConf
RigFemResultAddress resVarAddress = this->resultAddress(); RigFemResultAddress resVarAddress = this->resultAddress();
gmCase->femPartResults()->minMaxScalarValues( resVarAddress, timeStepIndex, &localMin, &localMax ); auto [stepIdx, frameIdx] = gmCase->femPartResults()->stepListIndexToTimeStepAndDataFrameIndex( viewerStepIndex );
gmCase->femPartResults()->posNegClosestToZero( resVarAddress, timeStepIndex, &localPosClosestToZero, &localNegClosestToZero );
gmCase->femPartResults()->minMaxScalarValues( resVarAddress, stepIdx, frameIdx, &localMin, &localMax );
gmCase->femPartResults()->posNegClosestToZero( resVarAddress,
stepIdx,
frameIdx,
&localPosClosestToZero,
&localNegClosestToZero );
gmCase->femPartResults()->minMaxScalarValues( resVarAddress, &globalMin, &globalMax ); gmCase->femPartResults()->minMaxScalarValues( resVarAddress, &globalMin, &globalMax );
gmCase->femPartResults()->posNegClosestToZero( resVarAddress, &globalPosClosestToZero, &globalNegClosestToZero ); gmCase->femPartResults()->posNegClosestToZero( resVarAddress, &globalPosClosestToZero, &globalNegClosestToZero );

View File

@ -83,6 +83,8 @@ CAF_PDM_SOURCE_INIT( RimGeoMechView, "GeoMechView" );
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RimGeoMechView::RimGeoMechView( void ) RimGeoMechView::RimGeoMechView( void )
: m_currentInternalTimeStep( 0 )
, m_currentDataFrameIndex( -1 )
{ {
CAF_PDM_InitScriptableObject( "Geomechanical View", ":/3DViewGeoMech16x16.png", "", "The Geomechanical 3d View" ); CAF_PDM_InitScriptableObject( "Geomechanical View", ":/3DViewGeoMech16x16.png", "", "The Geomechanical 3d View" );
@ -277,10 +279,9 @@ void RimGeoMechView::onCreateDisplayModel()
if ( isTimeStepDependentDataVisibleInThisOrComparisonView() ) if ( isTimeStepDependentDataVisibleInThisOrComparisonView() )
{ {
// Create empty frames in the viewer // Create empty frames in the viewer, one per global timestep
const int totalSteps = geoMechCase()->geoMechData()->femPartResults()->totalSteps();
int frameCount = geoMechCase()->geoMechData()->femPartResults()->frameCount(); for ( int timeStepIndex = 0; timeStepIndex < totalSteps; timeStepIndex++ )
for ( int frameIndex = 0; frameIndex < frameCount; frameIndex++ )
{ {
cvf::ref<cvf::Scene> scene = new cvf::Scene; cvf::ref<cvf::Scene> scene = new cvf::Scene;
cvf::ref<cvf::ModelBasicList> emptyModel = new cvf::ModelBasicList; cvf::ref<cvf::ModelBasicList> emptyModel = new cvf::ModelBasicList;
@ -370,7 +371,11 @@ void RimGeoMechView::updateElementDisplacements()
{ {
std::string errmsg; std::string errmsg;
std::vector<cvf::Vec3f> displacements; std::vector<cvf::Vec3f> 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 ); part->setDisplacements( displacements );
} }
} }
@ -381,6 +386,15 @@ void RimGeoMechView::updateElementDisplacements()
m_vizLogic->scheduleGeometryRegenOfVisiblePartMgrs( m_currentTimeStep ); m_vizLogic->scheduleGeometryRegenOfVisiblePartMgrs( m_currentTimeStep );
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::pair<int, int> 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<cvf::ModelBasicList> frameParts = new cvf::ModelBasicList; cvf::ref<cvf::ModelBasicList> frameParts = new cvf::ModelBasicList;
frameParts->setName( name ); frameParts->setName( name );
m_tensorPartMgr->appendDynamicGeometryPartsToModel( frameParts.p(), m_currentTimeStep ); m_tensorPartMgr->appendDynamicGeometryPartsToModel( frameParts.p(),
m_currentTimeStep,
m_currentInternalTimeStep,
m_currentDataFrameIndex );
frameParts->updateBoundingBoxesRecursive(); frameParts->updateBoundingBoxesRecursive();
if ( frameParts->partCount() != 0 ) if ( frameParts->partCount() != 0 )
@ -445,7 +462,10 @@ void RimGeoMechView::onUpdateDisplayModelForCurrentTimeStep()
bool hasGeneralCellResult = this->cellResult()->hasResult(); bool hasGeneralCellResult = this->cellResult()->hasResult();
if ( hasGeneralCellResult ) if ( hasGeneralCellResult )
m_vizLogic->updateCellResultColor( m_currentTimeStep(), this->cellResult() ); m_vizLogic->updateCellResultColor( m_currentTimeStep(),
m_currentInternalTimeStep,
m_currentDataFrameIndex,
this->cellResult() );
else else
m_vizLogic->updateStaticCellColors( m_currentTimeStep() ); m_vizLogic->updateStaticCellColors( m_currentTimeStep() );
@ -466,8 +486,8 @@ void RimGeoMechView::onUpdateDisplayModelForCurrentTimeStep()
{ {
m_vizLogic->updateStaticCellColors( -1 ); m_vizLogic->updateStaticCellColors( -1 );
m_intersectionCollection->updateCellResultColor( false, m_currentTimeStep ); m_intersectionCollection->updateCellResultColor( false, m_currentInternalTimeStep );
if ( m_surfaceCollection ) m_surfaceCollection->updateCellResultColor( false, m_currentTimeStep ); if ( m_surfaceCollection ) m_surfaceCollection->updateCellResultColor( false, m_currentInternalTimeStep );
nativeOrOverrideViewer()->animationControl()->slotPause(); // To avoid animation timer spinning in the background 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; if ( !m_geomechCase || !m_geomechCase->geoMechData() ) return;
@ -606,9 +626,16 @@ void RimGeoMechView::updateTensorLegendTextAndRanges( RimRegularLegendConfig* le
RigFemResultAddress resVarAddress( resPos, resFieldName.toStdString(), "" ); 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, gmCase->femPartResults()->posNegClosestToZeroOverAllTensorComponents( resVarAddress,
timeStepIndex, timeStepIndex,
frameIndex,
&localPosClosestToZero, &localPosClosestToZero,
&localNegClosestToZero ); &localNegClosestToZero );
@ -793,15 +820,16 @@ RimGeoMechCase* RimGeoMechView::geoMechCase() const
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimGeoMechView::onClampCurrentTimestep() void RimGeoMechView::onClampCurrentTimestep()
{ {
int maxFrameCount = 0; int maxSteps = 0;
if ( m_geomechCase ) if ( m_geomechCase )
{ {
maxFrameCount = m_geomechCase->geoMechData()->femPartResults()->frameCount(); maxSteps = m_geomechCase->geoMechData()->femPartResults()->totalSteps();
} }
if ( m_currentTimeStep >= maxSteps ) m_currentTimeStep = maxSteps - 1;
if ( m_currentTimeStep >= maxFrameCount ) m_currentTimeStep = maxFrameCount - 1;
if ( m_currentTimeStep < 0 ) m_currentTimeStep = 0; 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() ) if ( m_geomechCase && m_geomechCase->geoMechData() && m_geomechCase->geoMechData()->femPartResults() )
{ {
return m_geomechCase->geoMechData()->femPartResults()->frameCount(); return m_geomechCase->geoMechData()->femPartResults()->totalSteps();
} }
return 0; 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(); return m_partsCollection();
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::pair<int, int> RimGeoMechView::currentStepAndDataFrame() const
{
return std::make_pair( m_currentInternalTimeStep, m_currentDataFrameIndex );
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@ -93,9 +93,9 @@ public:
bool isUsingFormationNames() const override; 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<RivGeoMechVizLogic> vizLogic() const; const cvf::ref<RivGeoMechVizLogic> vizLogic() const;
const RimTensorResults* tensorResults() const; const RimTensorResults* tensorResults() const;
@ -112,6 +112,8 @@ public:
bool showDisplacements() const; bool showDisplacements() const;
void setShowDisplacementsAndUpdate( bool show ); void setShowDisplacementsAndUpdate( bool show );
std::pair<int, int> currentStepAndDataFrame() const;
protected: protected:
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "" ) override; void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "" ) override;
@ -138,10 +140,12 @@ private:
void onUpdateLegends() override; void onUpdateLegends() override;
void updateTensorLegendTextAndRanges( RimRegularLegendConfig* legendConfig, int timeStepIndex ); void updateTensorLegendTextAndRanges( RimRegularLegendConfig* legendConfig, int viewerTimeStep );
void updateElementDisplacements(); void updateElementDisplacements();
std::pair<int, int> viewerStepToTimeStepAndFrameIndex( int viewerTimeStep );
caf::PdmChildField<RimTensorResults*> m_tensorResults; caf::PdmChildField<RimTensorResults*> m_tensorResults;
caf::PdmChildField<RimGeoMechPropertyFilterCollection*> m_propertyFilterCollection; caf::PdmChildField<RimGeoMechPropertyFilterCollection*> m_propertyFilterCollection;
caf::PdmPointer<RimGeoMechPropertyFilterCollection> m_overridePropertyFilterCollection; caf::PdmPointer<RimGeoMechPropertyFilterCollection> m_overridePropertyFilterCollection;
@ -154,4 +158,7 @@ private:
cvf::ref<cvf::Transform> m_scaleTransform; cvf::ref<cvf::Transform> m_scaleTransform;
cvf::ref<RivTensorResultPartMgr> m_tensorPartMgr; cvf::ref<RivTensorResultPartMgr> m_tensorPartMgr;
int m_currentInternalTimeStep;
int m_currentDataFrameIndex;
}; };

View File

@ -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; if ( !this->isActive() ) return;

View File

@ -73,7 +73,7 @@ public:
// Visualization interface // Visualization interface
void applySingleColorEffect(); 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 appendPartsToModel( Rim3dView& view, cvf::ModelBasicList* model, cvf::Transform* scaleTransform );
void rebuildGeometry(); void rebuildGeometry();

View File

@ -157,9 +157,10 @@ protected:
void clearResults(); void clearResults();
void clearTimeStepRange(); void clearTimeStepRange();
double maxValue( const std::vector<double>& aggregatedResults ) const; double maxValue( const std::vector<double>& aggregatedResults ) const;
double minValue( const std::vector<double>& aggregatedResults ) const; double minValue( const std::vector<double>& aggregatedResults ) const;
std::pair<double, double> minmaxValuesAllTimeSteps();
virtual std::pair<double, double> minmaxValuesAllTimeSteps();
virtual cvf::ref<cvf::UByteArray> getCellVisibility() const; virtual cvf::ref<cvf::UByteArray> getCellVisibility() const;
virtual std::vector<bool> getMapCellVisibility(); virtual std::vector<bool> getMapCellVisibility();

View File

@ -288,13 +288,22 @@ RigHistogramData RimHistogramCalculator::histogramData( RimGeoMechView*
} }
else if ( timeRange == StatisticsTimeRangeType::CURRENT_TIMESTEP ) else if ( timeRange == StatisticsTimeRangeType::CURRENT_TIMESTEP )
{ {
int timeStepIdx = geoMechView->currentTimeStep(); auto [timeStepIdx, frameIdx] = geoMechView->currentStepAndDataFrame();
caseData->femPartResults()->meanScalarValue( resAddress, timeStepIdx, &histData.mean ); caseData->femPartResults()->meanScalarValue( resAddress, timeStepIdx, frameIdx, &histData.mean );
caseData->femPartResults()->minMaxScalarValues( resAddress, timeStepIdx, &histData.min, &histData.max ); caseData->femPartResults()->minMaxScalarValues( resAddress,
caseData->femPartResults()->p10p90ScalarValues( resAddress, timeStepIdx, &histData.p10, &histData.p90 ); timeStepIdx,
caseData->femPartResults()->sumScalarValue( resAddress, timeStepIdx, &histData.sum ); 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 ) else if ( cellRange == StatisticsCellRangeType::VISIBLE_CELLS )

View File

@ -199,19 +199,19 @@ void RimTensorResults::mappingRange( double* min, double* max ) const
Rim3dView* view = nullptr; Rim3dView* view = nullptr;
firstAncestorOrThisOfType( view ); firstAncestorOrThisOfType( view );
int currentTimeStep = view->currentTimeStep();
RimGeoMechView* geoMechView = dynamic_cast<RimGeoMechView*>( view ); RimGeoMechView* geoMechView = dynamic_cast<RimGeoMechView*>( view );
RigFemPartResultsCollection* resultCollection = geoMechView->geoMechCase()->geoMechData()->femPartResults(); RigFemPartResultsCollection* resultCollection = geoMechView->geoMechCase()->geoMechData()->femPartResults();
if ( !resultCollection ) return; if ( !resultCollection ) return;
auto [stepIdx, frameIdx] = geoMechView->currentStepAndDataFrame();
if ( m_rangeMode == RimRegularLegendConfig::RangeModeType::AUTOMATIC_ALLTIMESTEPS ) if ( m_rangeMode == RimRegularLegendConfig::RangeModeType::AUTOMATIC_ALLTIMESTEPS )
{ {
resultCollection->minMaxScalarValuesOverAllTensorComponents( selectedTensorResult(), min, max ); resultCollection->minMaxScalarValuesOverAllTensorComponents( selectedTensorResult(), min, max );
} }
else if ( m_rangeMode == RimRegularLegendConfig::RangeModeType::AUTOMATIC_CURRENT_TIMESTEP ) else if ( m_rangeMode == RimRegularLegendConfig::RangeModeType::AUTOMATIC_CURRENT_TIMESTEP )
{ {
resultCollection->minMaxScalarValuesOverAllTensorComponents( selectedTensorResult(), currentTimeStep, min, max ); resultCollection->minMaxScalarValuesOverAllTensorComponents( selectedTensorResult(), stepIdx, frameIdx, min, max );
} }
} }
} }

View File

@ -135,6 +135,8 @@ RimWbsParameters::RimWbsParameters()
m_wellPath.uiCapability()->setUiHidden( true ); m_wellPath.uiCapability()->setUiHidden( true );
CAF_PDM_InitField( &m_timeStep, "TimeStep", -1, "TimeStep" ); CAF_PDM_InitField( &m_timeStep, "TimeStep", -1, "TimeStep" );
m_timeStep.uiCapability()->setUiHidden( true ); 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 }, m_parameterSourceFields = { { RigWbsParameter::PP_Reservoir(), &m_porePressureSource },
{ RigWbsParameter::PP_NonReservoir(), &m_porePressureNonReservoirSource }, { RigWbsParameter::PP_NonReservoir(), &m_porePressureNonReservoirSource },
@ -182,6 +184,7 @@ RimWbsParameters& RimWbsParameters::operator=( const RimWbsParameters& copyFrom
m_geoMechCase = copyFrom.m_geoMechCase(); m_geoMechCase = copyFrom.m_geoMechCase();
m_wellPath = copyFrom.m_wellPath(); m_wellPath = copyFrom.m_wellPath();
m_timeStep = copyFrom.m_timeStep(); m_timeStep = copyFrom.m_timeStep();
m_frameIndex = copyFrom.m_frameIndex();
for ( auto parameterSourcePair : m_parameterSourceFields ) for ( auto parameterSourcePair : m_parameterSourceFields )
{ {
@ -230,6 +233,14 @@ void RimWbsParameters::setTimeStep( int timeStep )
m_timeStep = 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(); femPartResults = m_geoMechCase->geoMechData()->femPartResults();
if ( femPartResults ) if ( femPartResults )
{ {
return !femPartResults->resultValues( resAddr, 0, m_timeStep ).empty(); return !femPartResults->resultValues( resAddr, 0, m_timeStep, m_frameIndex ).empty();
} }
} }
return false; return false;

View File

@ -47,6 +47,7 @@ public:
void setGeoMechCase( RimGeoMechCase* geoMechCase ); void setGeoMechCase( RimGeoMechCase* geoMechCase );
void setWellPath( RimWellPath* wellPath ); void setWellPath( RimWellPath* wellPath );
void setTimeStep( int timeStep ); void setTimeStep( int timeStep );
void setFrameIndex( int frameIndex );
void applyWbsParametersToExtractor( RigGeoMechWellLogExtractor* extractor ); void applyWbsParametersToExtractor( RigGeoMechWellLogExtractor* extractor );
@ -98,6 +99,7 @@ private:
caf::PdmPtrField<RimGeoMechCase*> m_geoMechCase; caf::PdmPtrField<RimGeoMechCase*> m_geoMechCase;
caf::PdmPtrField<RimWellPath*> m_wellPath; caf::PdmPtrField<RimWellPath*> m_wellPath;
caf::PdmField<int> m_timeStep; caf::PdmField<int> m_timeStep;
caf::PdmField<int> m_frameIndex;
std::map<RigWbsParameter, caf::PdmField<ParameterSourceEnum>*> m_parameterSourceFields; std::map<RigWbsParameter, caf::PdmField<ParameterSourceEnum>*> m_parameterSourceFields;
std::map<RigWbsParameter, caf::PdmField<double>*> m_userDefinedValueFields; std::map<RigWbsParameter, caf::PdmField<double>*> m_userDefinedValueFields;

View File

@ -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->setGeoMechCase( geoMechCase );
m_wbsParameters->setWellPath( wellPath ); m_wbsParameters->setWellPath( wellPath );
m_wbsParameters->setTimeStep( timeStep ); m_wbsParameters->setTimeStep( timeStep );
m_wbsParameters->setFrameIndex( frameIndex );
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -215,6 +219,7 @@ void RimWellBoreStabilityPlot::applyDataSource()
m_wbsParameters->setGeoMechCase( dynamic_cast<RimGeoMechCase*>( m_commonDataSource->caseToApply() ) ); m_wbsParameters->setGeoMechCase( dynamic_cast<RimGeoMechCase*>( m_commonDataSource->caseToApply() ) );
m_wbsParameters->setWellPath( m_commonDataSource->wellPathToApply() ); m_wbsParameters->setWellPath( m_commonDataSource->wellPathToApply() );
m_wbsParameters->setTimeStep( m_commonDataSource->timeStepToApply() ); m_wbsParameters->setTimeStep( m_commonDataSource->timeStepToApply() );
m_wbsParameters->setFrameIndex( -1 );
this->updateReferenceWellPathInCurves(); this->updateReferenceWellPathInCurves();
this->updateConnectedEditors(); this->updateConnectedEditors();

View File

@ -39,7 +39,8 @@ public:
void applyWbsParametersToExtractor( RigGeoMechWellLogExtractor* extractor ); void applyWbsParametersToExtractor( RigGeoMechWellLogExtractor* extractor );
double userDefinedValue( const RigWbsParameter& parameter ) const; double userDefinedValue( const RigWbsParameter& parameter ) const;
void copyWbsParameters( const RimWbsParameters* wbsParameters ); 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: protected:
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;

View File

@ -367,7 +367,7 @@ RimSurfaceInViewCollection*
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimSurfaceInViewCollection::updateCellResultColor( bool hasGeneralCellResult, size_t timeStepIndex ) void RimSurfaceInViewCollection::updateCellResultColor( bool hasGeneralCellResult, int timeStepIndex )
{ {
if ( !this->isChecked() ) return; if ( !this->isChecked() ) return;

View File

@ -58,7 +58,7 @@ public:
void clearGeometry(); void clearGeometry();
void appendPartsToModel( cvf::ModelBasicList* surfaceVizModel, cvf::Transform* scaleTransform ); void appendPartsToModel( cvf::ModelBasicList* surfaceVizModel, cvf::Transform* scaleTransform );
void updateCellResultColor( bool hasGeneralCellResult, size_t timeStepIndex ); void updateCellResultColor( bool hasGeneralCellResult, int timeStepIndex );
void applySingleColorEffect(); void applySingleColorEffect();
bool hasAnyActiveSeparateResults(); bool hasAnyActiveSeparateResults();

View File

@ -154,7 +154,7 @@ void Rim3dWellLogCurve::curveValuesAndMdsAtTimeStep( std::vector<double>* values
std::vector<double>* measuredDepthValues, std::vector<double>* measuredDepthValues,
int timeStep ) const int timeStep ) const
{ {
return this->curveValuesAndMds( values, measuredDepthValues ); curveValuesAndMds( values, measuredDepthValues );
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@ -170,7 +170,7 @@ void Rim3dWellLogExtractionCurve::curveValuesAndMds( std::vector<double>* values
{ {
CVF_ASSERT( m_timeStep() >= 0 ); 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::vector<doubl
RimWellLogExtractionCurve::findAndLoadWbsParametersFromLasFiles( wellPath, geomExtractor.p() ); RimWellLogExtractionCurve::findAndLoadWbsParametersFromLasFiles( wellPath, geomExtractor.p() );
m_geomResultDefinition->loadResult(); m_geomResultDefinition->loadResult();
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(); RigGeoMechCaseData* data = geomCase->geoMechData();
if ( data ) if ( data )
{ {
maxTimeStep = data->femPartResults()->frameCount(); maxTimeStep = data->femPartResults()->totalSteps();
} }
} }
@ -450,6 +454,7 @@ void Rim3dWellLogExtractionCurve::fieldChangedByUi( const caf::PdmFieldHandle* c
this->resetMinMaxValues(); this->resetMinMaxValues();
this->updateConnectedEditors(); this->updateConnectedEditors();
} }
Rim3dWellLogCurve::fieldChangedByUi( changedField, oldValue, newValue ); Rim3dWellLogCurve::fieldChangedByUi( changedField, oldValue, newValue );
} }

View File

@ -607,6 +607,9 @@ RimWellLogExtractionCurve::WellLogExtractionCurveData
cvf::ref<RigGeoMechWellLogExtractor> refWellExtractor = cvf::ref<RigGeoMechWellLogExtractor> refWellExtractor =
wellLogCollection->findOrCreateExtractor( m_refWellPath, geomCase ); wellLogCollection->findOrCreateExtractor( m_refWellPath, geomCase );
auto [timeStepIdx, frameIdx] =
geomCase->geoMechData()->femPartResults()->stepListIndexToTimeStepAndDataFrameIndex( m_timeStep );
if ( wellExtractor.notNull() ) if ( wellExtractor.notNull() )
{ {
curveData.measuredDepthValues = wellExtractor->cellIntersectionMDs(); curveData.measuredDepthValues = wellExtractor->cellIntersectionMDs();
@ -628,7 +631,7 @@ RimWellLogExtractionCurve::WellLogExtractionCurveData
m_geomResultDefinition->loadResult(); m_geomResultDefinition->loadResult();
curveData.xUnits = 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 // 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" ); RigFemResultAddress indexKResAdr( RigFemResultPosEnum::RIG_ELEMENT_NODAL, "INDEX", "INDEX_K" );
const size_t frameIdx = 0;
std::vector<double> refWellMeasuredDepthValues = refWellExtractor->cellIntersectionMDs(); std::vector<double> refWellMeasuredDepthValues = refWellExtractor->cellIntersectionMDs();
std::vector<double> refWellTvDepthValues = refWellExtractor->cellIntersectionTVDs(); std::vector<double> refWellTvDepthValues = refWellExtractor->cellIntersectionTVDs();
std::vector<double> refWellPropertyValues; std::vector<double> refWellPropertyValues;
@ -648,9 +650,9 @@ RimWellLogExtractionCurve::WellLogExtractionCurveData
std::vector<double> wellIndexKValues; std::vector<double> wellIndexKValues;
if ( indexKResAdr.isValid() ) if ( indexKResAdr.isValid() )
{ {
wellExtractor->curveData( indexKResAdr, frameIdx, &wellIndexKValues ); wellExtractor->curveData( indexKResAdr, timeStepIdx, frameIdx, &wellIndexKValues );
refWellExtractor->curveData( indexKResAdr, frameIdx, &refWellIndexKValues ); refWellExtractor->curveData( indexKResAdr, timeStepIdx, frameIdx, &refWellIndexKValues );
refWellExtractor->curveData( m_geomResultDefinition->resultAddress(), frameIdx, &refWellPropertyValues ); refWellExtractor->curveData( m_geomResultDefinition->resultAddress(), timeStepIdx, frameIdx, &refWellPropertyValues );
} }
if ( !wellIndexKValues.empty() && !refWellIndexKValues.empty() && !refWellPropertyValues.empty() ) if ( !wellIndexKValues.empty() && !refWellIndexKValues.empty() && !refWellPropertyValues.empty() )
@ -666,7 +668,8 @@ RimWellLogExtractionCurve::WellLogExtractionCurveData
} }
if ( performDataSmoothing ) if ( performDataSmoothing )
{ {
refWellExtractor->performCurveDataSmoothing( frameIdx, refWellExtractor->performCurveDataSmoothing( timeStepIdx,
frameIdx,
&curveData.measuredDepthValues, &curveData.measuredDepthValues,
&curveData.tvDepthValues, &curveData.tvDepthValues,
&curveData.values, &curveData.values,
@ -677,7 +680,8 @@ RimWellLogExtractionCurve::WellLogExtractionCurveData
if ( wellExtractor.notNull() && performDataSmoothing ) if ( wellExtractor.notNull() && performDataSmoothing )
{ {
wellExtractor->performCurveDataSmoothing( m_timeStep, wellExtractor->performCurveDataSmoothing( timeStepIdx,
frameIdx,
&curveData.measuredDepthValues, &curveData.measuredDepthValues,
&curveData.tvDepthValues, &curveData.tvDepthValues,
&curveData.values, &curveData.values,
@ -1148,7 +1152,7 @@ QString RimWellLogExtractionCurve::createCurveAutoName()
{ {
if ( geomCase->geoMechData() ) if ( geomCase->geoMechData() )
{ {
maxTimeStep = geomCase->geoMechData()->femPartResults()->frameCount(); maxTimeStep = geomCase->geoMechData()->femPartResults()->totalSteps();
} }
} }

View File

@ -2604,7 +2604,7 @@ CurveSamplingPointData RimWellLogTrack::curveSamplingPointData( RigGeoMechWellLo
curveData.tvd = extractor->cellIntersectionTVDs(); curveData.tvd = extractor->cellIntersectionTVDs();
curveData.rkbDiff = extractor->wellPathGeometry()->rkbDiff(); curveData.rkbDiff = extractor->wellPathGeometry()->rkbDiff();
extractor->curveData( resultAddress, 0, &curveData.data ); extractor->curveData( resultAddress, 0, 0, &curveData.data );
return curveData; return curveData;
} }
@ -3190,6 +3190,9 @@ void RimWellLogTrack::updateCurveDataRegionsOnPlot()
int timeStep = wellBoreStabilityPlot->commonDataSource()->timeStepToApply(); int timeStep = wellBoreStabilityPlot->commonDataSource()->timeStepToApply();
if ( geoMechCase && wellPath && timeStep >= 0 ) if ( geoMechCase && wellPath && timeStep >= 0 )
{ {
auto [stepIdx, frameIdx] =
geoMechCase->geoMechData()->femPartResults()->stepListIndexToTimeStepAndDataFrameIndex( timeStep );
RigGeoMechWellLogExtractor* geoMechWellLogExtractor = nullptr; RigGeoMechWellLogExtractor* geoMechWellLogExtractor = nullptr;
geoMechWellLogExtractor = geoMechWellLogExtractor =
RiaExtractionTools::findOrCreateWellLogExtractor( wellPath, dynamic_cast<RimGeoMechCase*>( geoMechCase ) ); RiaExtractionTools::findOrCreateWellLogExtractor( wellPath, dynamic_cast<RimGeoMechCase*>( geoMechCase ) );
@ -3207,9 +3210,9 @@ void RimWellLogTrack::updateCurveDataRegionsOnPlot()
wbsPlot->applyWbsParametersToExtractor( geoMechWellLogExtractor ); wbsPlot->applyWbsParametersToExtractor( geoMechWellLogExtractor );
} }
std::vector<double> ppSourceRegions = geoMechWellLogExtractor->porePressureSourceRegions( timeStep ); std::vector<double> ppSourceRegions = geoMechWellLogExtractor->porePressureSourceRegions( stepIdx, frameIdx );
std::vector<double> poissonSourceRegions = geoMechWellLogExtractor->poissonSourceRegions( timeStep ); std::vector<double> poissonSourceRegions = geoMechWellLogExtractor->poissonSourceRegions( stepIdx, frameIdx );
std::vector<double> ucsSourceRegions = geoMechWellLogExtractor->ucsSourceRegions( timeStep ); std::vector<double> ucsSourceRegions = geoMechWellLogExtractor->ucsSourceRegions( stepIdx, frameIdx );
{ {
caf::ColorTable colorTable( m_colorShadingLegend->colorArray() ); caf::ColorTable colorTable( m_colorShadingLegend->colorArray() );

View File

@ -81,11 +81,12 @@ double RimWellIADataAccess::resultValue( QString fieldName,
QString componentName, QString componentName,
RigFemResultPosEnum resultType, RigFemResultPosEnum resultType,
size_t resultIndex, size_t resultIndex,
int timeStep ) int timeStep,
int frameId )
{ {
RigFemResultAddress address( resultType, fieldName.toStdString(), componentName.toStdString() ); RigFemResultAddress address( resultType, fieldName.toStdString(), componentName.toStdString() );
const std::vector<float>& scalarResults = m_caseData->femPartResults()->resultValues( address, 0, timeStep ); const std::vector<float>& scalarResults = m_caseData->femPartResults()->resultValues( address, 0, timeStep, frameId );
if ( resultIndex < scalarResults.size() ) return scalarResults[resultIndex]; if ( resultIndex < scalarResults.size() ) return scalarResults[resultIndex];
@ -99,7 +100,8 @@ double RimWellIADataAccess::interpolatedResultValue( QString fieldNa
QString componentName, QString componentName,
RigFemResultPosEnum resultType, RigFemResultPosEnum resultType,
cvf::Vec3d position, cvf::Vec3d position,
int timeStep ) int timeStep,
int frameId )
{ {
RigFemResultAddress address( resultType, fieldName.toStdString(), componentName.toStdString() ); RigFemResultAddress address( resultType, fieldName.toStdString(), componentName.toStdString() );
@ -110,7 +112,7 @@ double RimWellIADataAccess::interpolatedResultValue( QString fieldNa
const int* elementConn = femPart->connectivities( elmIdx ); const int* elementConn = femPart->connectivities( elmIdx );
int elmNodeCount = RigFemTypes::elementNodeCount( elmType ); int elmNodeCount = RigFemTypes::elementNodeCount( elmType );
const std::vector<float>& scalarResults = m_caseData->femPartResults()->resultValues( address, 0, timeStep ); const std::vector<float>& scalarResults = m_caseData->femPartResults()->resultValues( address, 0, timeStep, frameId );
std::array<double, 8> nodeResults; std::array<double, 8> nodeResults;
std::array<cvf::Vec3d, 8> nodeCorners; std::array<cvf::Vec3d, 8> nodeCorners;

View File

@ -45,12 +45,14 @@ public:
QString componentName, QString componentName,
RigFemResultPosEnum resultType, RigFemResultPosEnum resultType,
size_t resultIndex, size_t resultIndex,
int timeStep ); int timeStep,
int frameId );
double interpolatedResultValue( QString fieldname, double interpolatedResultValue( QString fieldname,
QString componentName, QString componentName,
RigFemResultPosEnum resultType, RigFemResultPosEnum resultType,
cvf::Vec3d position, cvf::Vec3d position,
int timeStep ); int timeStep,
int frameId );
private: private:
RimGeoMechCase* m_case; RimGeoMechCase* m_case;

View File

@ -473,7 +473,7 @@ bool RimWellIASettings::updateResInsightParameters()
for ( size_t i = 0; i < nativeKeys.size(); i++ ) for ( size_t i = 0; i < nativeKeys.size(); i++ )
{ {
double stressValue = 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 ) ) if ( std::isfinite( stressValue ) )
{ {
initialStress->addParameter( paramKeys[i], stressValue * 100000.0 ); 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 ) ) if ( std::isfinite( ppValue ) )
{ {
initialStress->addParameter( "PP", ppValue * 100000.0 ); initialStress->addParameter( "PP", ppValue * 100000.0 );
@ -673,9 +673,13 @@ std::vector<cvf::Vec3d> RimWellIASettings::extractDisplacements( std::vector<cvf
for ( auto& pos : corners ) for ( auto& pos : corners )
{ {
double u1 = dataAccess.interpolatedResultValue( "U", "U1", RigFemResultPosEnum::RIG_NODAL, pos, timeStep ); int lastFrame = -1;
double u2 = dataAccess.interpolatedResultValue( "U", "U2", RigFemResultPosEnum::RIG_NODAL, pos, timeStep ); double u1 =
double u3 = dataAccess.interpolatedResultValue( "U", "U3", RigFemResultPosEnum::RIG_NODAL, pos, timeStep ); dataAccess.interpolatedResultValue( "U", "U1", RigFemResultPosEnum::RIG_NODAL, pos, timeStep, lastFrame );
double u2 =
dataAccess.interpolatedResultValue( "U", "U2", RigFemResultPosEnum::RIG_NODAL, pos, timeStep, lastFrame );
double u3 =
dataAccess.interpolatedResultValue( "U", "U3", RigFemResultPosEnum::RIG_NODAL, pos, timeStep, lastFrame );
displacements.push_back( cvf::Vec3d( u1, u2, u3 ) ); displacements.push_back( cvf::Vec3d( u1, u2, u3 ) );
} }

View File

@ -76,7 +76,8 @@ RigGeoMechWellLogExtractor::RigGeoMechWellLogExtractor( gsl::not_null<RigGeoMech
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RigGeoMechWellLogExtractor::performCurveDataSmoothing( int frameIndex, void RigGeoMechWellLogExtractor::performCurveDataSmoothing( int timeStepIndex,
int frameIndex,
std::vector<double>* mds, std::vector<double>* mds,
std::vector<double>* tvds, std::vector<double>* tvds,
std::vector<double>* values, std::vector<double>* values,
@ -89,11 +90,13 @@ void RigGeoMechWellLogExtractor::performCurveDataSmoothing( int
RigFemResultAddress shAddr( RIG_ELEMENT_NODAL, "ST", "S3" ); RigFemResultAddress shAddr( RIG_ELEMENT_NODAL, "ST", "S3" );
RigFemResultAddress porBarResAddr( RIG_ELEMENT_NODAL, "POR-Bar", "" ); RigFemResultAddress porBarResAddr( RIG_ELEMENT_NODAL, "POR-Bar", "" );
const std::vector<float>& unscaledShValues = resultCollection->resultValues( shAddr, 0, frameIndex ); const std::vector<float>& unscaledShValues = resultCollection->resultValues( shAddr, 0, timeStepIndex, frameIndex );
const std::vector<float>& porePressures = resultCollection->resultValues( porBarResAddr, 0, frameIndex ); const std::vector<float>& porePressures = resultCollection->resultValues( porBarResAddr, 0, timeStepIndex, frameIndex );
std::vector<float> interfaceShValues = interpolateInterfaceValues( shAddr, frameIndex, unscaledShValues ); std::vector<float> interfaceShValues =
std::vector<float> interfacePorePressures = interpolateInterfaceValues( porBarResAddr, frameIndex, porePressures ); interpolateInterfaceValues( shAddr, timeStepIndex, frameIndex, unscaledShValues );
std::vector<float> interfacePorePressures =
interpolateInterfaceValues( porBarResAddr, timeStepIndex, frameIndex, porePressures );
std::vector<double> interfaceShValuesDbl( interfaceShValues.size(), std::numeric_limits<double>::infinity() ); std::vector<double> interfaceShValuesDbl( interfaceShValues.size(), std::numeric_limits<double>::infinity() );
std::vector<double> interfacePorePressuresDbl( interfacePorePressures.size(), std::numeric_limits<double>::infinity() ); std::vector<double> interfacePorePressuresDbl( interfacePorePressures.size(), std::numeric_limits<double>::infinity() );
@ -116,7 +119,10 @@ void RigGeoMechWellLogExtractor::performCurveDataSmoothing( int
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// Get curve data for a given parameter. Returns the output units of the data. /// Get curve data for a given parameter. Returns the output units of the data.
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
QString RigGeoMechWellLogExtractor::curveData( const RigFemResultAddress& resAddr, int frameIndex, std::vector<double>* values ) QString RigGeoMechWellLogExtractor::curveData( const RigFemResultAddress& resAddr,
int timeStepIndex,
int frameIndex,
std::vector<double>* values )
{ {
CVF_TIGHT_ASSERT( values ); CVF_TIGHT_ASSERT( values );
@ -138,20 +144,20 @@ QString RigGeoMechWellLogExtractor::curveData( const RigFemResultAddress& resAdd
if ( resAddr.fieldName == RiaResultNames::wbsFGResult().toStdString() ) if ( resAddr.fieldName == RiaResultNames::wbsFGResult().toStdString() )
{ {
wellBoreWallCurveData( resAddr, frameIndex, values ); wellBoreWallCurveData( resAddr, timeStepIndex, frameIndex, values );
// Try to replace invalid values with Shale-values // Try to replace invalid values with Shale-values
wellBoreFGShale( frameIndex, values ); wellBoreFGShale( timeStepIndex, frameIndex, values );
values->front() = wbsCurveValuesAtMsl(); values->front() = wbsCurveValuesAtMsl();
} }
else if ( resAddr.fieldName == RiaResultNames::wbsSFGResult().toStdString() ) else if ( resAddr.fieldName == RiaResultNames::wbsSFGResult().toStdString() )
{ {
wellBoreWallCurveData( resAddr, frameIndex, values ); wellBoreWallCurveData( resAddr, timeStepIndex, frameIndex, values );
} }
else if ( resAddr.fieldName == RiaResultNames::wbsPPResult().toStdString() || else if ( resAddr.fieldName == RiaResultNames::wbsPPResult().toStdString() ||
resAddr.fieldName == RiaResultNames::wbsOBGResult().toStdString() || resAddr.fieldName == RiaResultNames::wbsOBGResult().toStdString() ||
resAddr.fieldName == RiaResultNames::wbsSHResult().toStdString() ) resAddr.fieldName == RiaResultNames::wbsSHResult().toStdString() )
{ {
wellPathScaledCurveData( resAddr, frameIndex, values ); wellPathScaledCurveData( resAddr, timeStepIndex, frameIndex, values );
values->front() = wbsCurveValuesAtMsl(); values->front() = wbsCurveValuesAtMsl();
} }
else if ( resAddr.fieldName == RiaResultNames::wbsAzimuthResult().toStdString() || else if ( resAddr.fieldName == RiaResultNames::wbsAzimuthResult().toStdString() ||
@ -161,7 +167,7 @@ QString RigGeoMechWellLogExtractor::curveData( const RigFemResultAddress& resAdd
} }
else if ( resAddr.fieldName == RiaResultNames::wbsSHMkResult().toStdString() ) else if ( resAddr.fieldName == RiaResultNames::wbsSHMkResult().toStdString() )
{ {
wellBoreSH_MatthewsKelly( frameIndex, values ); wellBoreSH_MatthewsKelly( timeStepIndex, frameIndex, values );
values->front() = wbsCurveValuesAtMsl(); values->front() = wbsCurveValuesAtMsl();
} }
else else
@ -172,7 +178,7 @@ QString RigGeoMechWellLogExtractor::curveData( const RigFemResultAddress& resAdd
{ {
if ( param == RigWbsParameter::FG_Shale() ) if ( param == RigWbsParameter::FG_Shale() )
{ {
wellBoreFGShale( frameIndex, values ); wellBoreFGShale( timeStepIndex, frameIndex, values );
} }
else else
{ {
@ -180,7 +186,7 @@ QString RigGeoMechWellLogExtractor::curveData( const RigFemResultAddress& resAdd
{ {
frameIndex = 0; frameIndex = 0;
} }
calculateWbsParameterForAllSegments( param, frameIndex, values, true ); calculateWbsParameterForAllSegments( param, timeStepIndex, frameIndex, values, true );
if ( param == RigWbsParameter::UCS() ) // UCS is reported as UCS/100 if ( param == RigWbsParameter::UCS() ) // UCS is reported as UCS/100
{ {
for ( double& value : *values ) for ( double& value : *values )
@ -209,11 +215,13 @@ QString RigGeoMechWellLogExtractor::curveData( const RigFemResultAddress& resAdd
CVF_ASSERT( resAddr.resultPosType != RIG_WELLPATH_DERIVED ); CVF_ASSERT( resAddr.resultPosType != RIG_WELLPATH_DERIVED );
const std::vector<float>& resultValues = m_caseData->femPartResults()->resultValues( convResAddr, 0, frameIndex ); const std::vector<float>& resultValues =
m_caseData->femPartResults()->resultValues( convResAddr, 0, timeStepIndex, frameIndex );
if ( !resultValues.empty() ) if ( !resultValues.empty() )
{ {
std::vector<float> interfaceValues = interpolateInterfaceValues( convResAddr, frameIndex, resultValues ); std::vector<float> interfaceValues =
interpolateInterfaceValues( convResAddr, timeStepIndex, frameIndex, resultValues );
values->resize( interfaceValues.size(), std::numeric_limits<double>::infinity() ); values->resize( interfaceValues.size(), std::numeric_limits<double>::infinity() );
@ -233,6 +241,7 @@ QString RigGeoMechWellLogExtractor::curveData( const RigFemResultAddress& resAdd
std::vector<RigGeoMechWellLogExtractor::WbsParameterSource> std::vector<RigGeoMechWellLogExtractor::WbsParameterSource>
RigGeoMechWellLogExtractor::calculateWbsParameterForAllSegments( const RigWbsParameter& parameter, RigGeoMechWellLogExtractor::calculateWbsParameterForAllSegments( const RigWbsParameter& parameter,
WbsParameterSource primarySource, WbsParameterSource primarySource,
int timeStepIndex,
int frameIndex, int frameIndex,
std::vector<double>* outputValues, std::vector<double>* outputValues,
bool allowNormalization ) bool allowNormalization )
@ -259,9 +268,10 @@ std::vector<RigGeoMechWellLogExtractor::WbsParameterSource>
{ {
RigFemResultAddress nativeAddr = parameter.femAddress( RigWbsParameter::GRID ); RigFemResultAddress nativeAddr = parameter.femAddress( RigWbsParameter::GRID );
const std::vector<float>& unscaledResultValues = resultCollection->resultValues( nativeAddr, 0, frameIndex ); const std::vector<float>& unscaledResultValues =
std::vector<float> interpolatedInterfaceValues = resultCollection->resultValues( nativeAddr, 0, timeStepIndex, frameIndex );
interpolateInterfaceValues( nativeAddr, frameIndex, unscaledResultValues ); std::vector<float> interpolatedInterfaceValues =
interpolateInterfaceValues( nativeAddr, timeStepIndex, frameIndex, unscaledResultValues );
gridValues.resize( m_intersections.size(), std::numeric_limits<double>::infinity() ); gridValues.resize( m_intersections.size(), std::numeric_limits<double>::infinity() );
#pragma omp parallel for #pragma omp parallel for
@ -290,7 +300,8 @@ std::vector<RigGeoMechWellLogExtractor::WbsParameterSource>
tvdRKBs.push_back( tvdValue + m_wellPathGeometry->rkbDiff() ); tvdRKBs.push_back( tvdValue + m_wellPathGeometry->rkbDiff() );
} }
RigFemResultAddress elementPropertyAddr = parameter.femAddress( RigWbsParameter::ELEMENT_PROPERTY_TABLE ); RigFemResultAddress elementPropertyAddr = parameter.femAddress( RigWbsParameter::ELEMENT_PROPERTY_TABLE );
elementPropertyValuesInput = &( resultCollection->resultValues( elementPropertyAddr, 0, frameIndex ) ); elementPropertyValuesInput =
&( resultCollection->resultValues( elementPropertyAddr, 0, timeStepIndex, frameIndex ) );
if ( elementPropertyValuesInput ) if ( elementPropertyValuesInput )
{ {
RiaWellLogUnitTools<float>::convertValues( tvdRKBs, RiaWellLogUnitTools<float>::convertValues( tvdRKBs,
@ -403,12 +414,14 @@ std::vector<RigGeoMechWellLogExtractor::WbsParameterSource>
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
std::vector<RigGeoMechWellLogExtractor::WbsParameterSource> std::vector<RigGeoMechWellLogExtractor::WbsParameterSource>
RigGeoMechWellLogExtractor::calculateWbsParameterForAllSegments( const RigWbsParameter& parameter, RigGeoMechWellLogExtractor::calculateWbsParameterForAllSegments( const RigWbsParameter& parameter,
int timeStepIndex,
int frameIndex, int frameIndex,
std::vector<double>* outputValues, std::vector<double>* outputValues,
bool allowNormalization ) bool allowNormalization )
{ {
return calculateWbsParameterForAllSegments( parameter, return calculateWbsParameterForAllSegments( parameter,
m_parameterSources.at( parameter ), m_parameterSources.at( parameter ),
timeStepIndex,
frameIndex, frameIndex,
outputValues, outputValues,
allowNormalization ); allowNormalization );
@ -419,6 +432,7 @@ std::vector<RigGeoMechWellLogExtractor::WbsParameterSource>
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
std::vector<RigGeoMechWellLogExtractor::WbsParameterSource> std::vector<RigGeoMechWellLogExtractor::WbsParameterSource>
RigGeoMechWellLogExtractor::calculateWbsParametersForAllSegments( const RigFemResultAddress& resAddr, RigGeoMechWellLogExtractor::calculateWbsParametersForAllSegments( const RigFemResultAddress& resAddr,
int timeStepIndex,
int frameIndex, int frameIndex,
std::vector<double>* values, std::vector<double>* values,
bool allowNormalization ) bool allowNormalization )
@ -431,7 +445,7 @@ std::vector<RigGeoMechWellLogExtractor::WbsParameterSource>
CVF_ASSERT( false && "wbsParameters() called on something that isn't a wbs parameter" ); 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::WbsParameterSource> std::vector<RigGeoMechWellLogExtractor::WbsParameterSource>
RigGeoMechWellLogExtractor::wellPathScaledCurveData( const RigFemResultAddress& resAddr, RigGeoMechWellLogExtractor::wellPathScaledCurveData( const RigFemResultAddress& resAddr,
int timeStepIndex,
int frameIndex, int frameIndex,
std::vector<double>* values, std::vector<double>* values,
bool forceGridSourceForPPReservoir /*=false*/ ) bool forceGridSourceForPPReservoir /*=false*/ )
@ -529,12 +544,15 @@ std::vector<RigGeoMechWellLogExtractor::WbsParameterSource>
} }
else else
{ {
ppSandSources = ppSandSources = calculateWbsParameterForAllSegments( RigWbsParameter::PP_Reservoir(),
calculateWbsParameterForAllSegments( RigWbsParameter::PP_Reservoir(), frameIndex, &ppSandValues, true ); timeStepIndex,
frameIndex,
&ppSandValues,
true );
} }
std::vector<WbsParameterSource> ppShaleSources = std::vector<WbsParameterSource> ppShaleSources =
calculateWbsParameterForAllSegments( RigWbsParameter::PP_NonReservoir(), 0, &ppShaleValues, true ); calculateWbsParameterForAllSegments( RigWbsParameter::PP_NonReservoir(), 0, 0, &ppShaleValues, true );
#pragma omp parallel for #pragma omp parallel for
for ( int64_t intersectionIdx = 0; intersectionIdx < (int64_t)m_intersections.size(); ++intersectionIdx ) for ( int64_t intersectionIdx = 0; intersectionIdx < (int64_t)m_intersections.size(); ++intersectionIdx )
@ -561,11 +579,11 @@ std::vector<RigGeoMechWellLogExtractor::WbsParameterSource>
} }
else if ( resAddr.fieldName == RiaResultNames::wbsOBGResult().toStdString() ) else if ( resAddr.fieldName == RiaResultNames::wbsOBGResult().toStdString() )
{ {
sources = calculateWbsParameterForAllSegments( RigWbsParameter::OBG(), frameIndex, values, true ); sources = calculateWbsParameterForAllSegments( RigWbsParameter::OBG(), timeStepIndex, frameIndex, values, true );
} }
else else
{ {
sources = calculateWbsParameterForAllSegments( RigWbsParameter::SH(), frameIndex, values, true ); sources = calculateWbsParameterForAllSegments( RigWbsParameter::SH(), timeStepIndex, frameIndex, values, true );
} }
return sources; return sources;
@ -575,6 +593,7 @@ std::vector<RigGeoMechWellLogExtractor::WbsParameterSource>
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RigGeoMechWellLogExtractor::wellBoreWallCurveData( const RigFemResultAddress& resAddr, void RigGeoMechWellLogExtractor::wellBoreWallCurveData( const RigFemResultAddress& resAddr,
int timeStepIndex,
int frameIndex, int frameIndex,
std::vector<double>* values ) std::vector<double>* values )
{ {
@ -589,7 +608,7 @@ void RigGeoMechWellLogExtractor::wellBoreWallCurveData( const RigFemResultAddres
RigFemPartResultsCollection* resultCollection = m_caseData->femPartResults(); RigFemPartResultsCollection* resultCollection = m_caseData->femPartResults();
// Load results // Load results
std::vector<caf::Ten3f> vertexStressesFloat = resultCollection->tensors( stressResAddr, 0, frameIndex ); std::vector<caf::Ten3f> vertexStressesFloat = resultCollection->tensors( stressResAddr, 0, timeStepIndex, frameIndex );
if ( !vertexStressesFloat.size() ) return; if ( !vertexStressesFloat.size() ) return;
std::vector<caf::Ten3d> vertexStresses; std::vector<caf::Ten3d> vertexStresses;
@ -600,7 +619,7 @@ void RigGeoMechWellLogExtractor::wellBoreWallCurveData( const RigFemResultAddres
} }
std::vector<caf::Ten3d> interpolatedInterfaceStressBar = std::vector<caf::Ten3d> interpolatedInterfaceStressBar =
interpolateInterfaceValues( stressResAddr, frameIndex, vertexStresses ); interpolateInterfaceValues( stressResAddr, timeStepIndex, frameIndex, vertexStresses );
values->resize( m_intersections.size(), std::numeric_limits<float>::infinity() ); values->resize( m_intersections.size(), std::numeric_limits<float>::infinity() );
@ -612,10 +631,10 @@ void RigGeoMechWellLogExtractor::wellBoreWallCurveData( const RigFemResultAddres
false ); false );
std::vector<double> poissonAllSegments( m_intersections.size(), std::numeric_limits<double>::infinity() ); std::vector<double> poissonAllSegments( m_intersections.size(), std::numeric_limits<double>::infinity() );
calculateWbsParameterForAllSegments( RigWbsParameter::poissonRatio(), frameIndex, &poissonAllSegments, false ); calculateWbsParameterForAllSegments( RigWbsParameter::poissonRatio(), timeStepIndex, frameIndex, &poissonAllSegments, false );
std::vector<double> ucsAllSegments( m_intersections.size(), std::numeric_limits<double>::infinity() ); std::vector<double> ucsAllSegments( m_intersections.size(), std::numeric_limits<double>::infinity() );
calculateWbsParameterForAllSegments( RigWbsParameter::UCS(), frameIndex, &ucsAllSegments, false ); calculateWbsParameterForAllSegments( RigWbsParameter::UCS(), timeStepIndex, frameIndex, &ucsAllSegments, false );
#pragma omp parallel for #pragma omp parallel for
for ( int64_t intersectionIdx = 0; intersectionIdx < (int64_t)m_intersections.size(); ++intersectionIdx ) 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<double>* values ) void RigGeoMechWellLogExtractor::wellBoreFGShale( int timeStepIndex, int frameIndex, std::vector<double>* values )
{ {
if ( values->empty() ) values->resize( m_intersections.size(), std::numeric_limits<double>::infinity() ); if ( values->empty() ) values->resize( m_intersections.size(), std::numeric_limits<double>::infinity() );
@ -686,10 +705,10 @@ void RigGeoMechWellLogExtractor::wellBoreFGShale( int frameIndex, std::vector<do
std::vector<double> K0_FG, OBG0; // parameters std::vector<double> K0_FG, OBG0; // parameters
RigFemResultAddress ppAddr( RIG_WELLPATH_DERIVED, RiaResultNames::wbsPPResult().toStdString(), "" ); 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::K0_FG(), timeStepIndex, frameIndex, &K0_FG, true );
calculateWbsParameterForAllSegments( RigWbsParameter::OBG0(), 0, &OBG0, true ); calculateWbsParameterForAllSegments( RigWbsParameter::OBG0(), 0, 0, &OBG0, true );
#pragma omp parallel for #pragma omp parallel for
for ( int64_t intersectionIdx = 0; intersectionIdx < (int64_t)m_intersections.size(); ++intersectionIdx ) for ( int64_t intersectionIdx = 0; intersectionIdx < (int64_t)m_intersections.size(); ++intersectionIdx )
@ -708,7 +727,7 @@ void RigGeoMechWellLogExtractor::wellBoreFGShale( int frameIndex, std::vector<do
else else
{ {
std::vector<double> SH; std::vector<double> SH;
calculateWbsParameterForAllSegments( RigWbsParameter::SH(), frameIndex, &SH, true ); calculateWbsParameterForAllSegments( RigWbsParameter::SH(), timeStepIndex, frameIndex, &SH, true );
CVF_ASSERT( SH.size() == m_intersections.size() ); CVF_ASSERT( SH.size() == m_intersections.size() );
double multiplier = m_userDefinedValues.at( RigWbsParameter::FG_Shale() ); double multiplier = m_userDefinedValues.at( RigWbsParameter::FG_Shale() );
CVF_ASSERT( multiplier != std::numeric_limits<double>::infinity() ); CVF_ASSERT( multiplier != std::numeric_limits<double>::infinity() );
@ -729,19 +748,19 @@ void RigGeoMechWellLogExtractor::wellBoreFGShale( int frameIndex, std::vector<do
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RigGeoMechWellLogExtractor::wellBoreSH_MatthewsKelly( int frameIndex, std::vector<double>* values ) void RigGeoMechWellLogExtractor::wellBoreSH_MatthewsKelly( int timeStepIndex, int frameIndex, std::vector<double>* values )
{ {
std::vector<double> PP, PP0; // results std::vector<double> PP, PP0; // results
std::vector<double> K0_SH, OBG0, DF; // parameters std::vector<double> K0_SH, OBG0, DF; // parameters
RigFemResultAddress ppAddr( RIG_WELLPATH_DERIVED, RiaResultNames::wbsPPResult().toStdString(), "" ); RigFemResultAddress ppAddr( RIG_WELLPATH_DERIVED, RiaResultNames::wbsPPResult().toStdString(), "" );
curveData( ppAddr, frameIndex, &PP ); curveData( ppAddr, timeStepIndex, frameIndex, &PP );
curveData( ppAddr, 0, &PP0 ); curveData( ppAddr, 0, 0, &PP0 );
calculateWbsParameterForAllSegments( RigWbsParameter::K0_SH(), frameIndex, &K0_SH, true ); calculateWbsParameterForAllSegments( RigWbsParameter::K0_SH(), timeStepIndex, frameIndex, &K0_SH, true );
calculateWbsParameterForAllSegments( RigWbsParameter::OBG0(), 0, &OBG0, true ); calculateWbsParameterForAllSegments( RigWbsParameter::OBG0(), 0, 0, &OBG0, true );
calculateWbsParameterForAllSegments( RigWbsParameter::DF(), frameIndex, &DF, true ); calculateWbsParameterForAllSegments( RigWbsParameter::DF(), timeStepIndex, frameIndex, &DF, true );
values->resize( m_intersections.size(), std::numeric_limits<double>::infinity() ); values->resize( m_intersections.size(), std::numeric_limits<double>::infinity() );
@ -815,12 +834,12 @@ QString RigGeoMechWellLogExtractor::parameterInputUnits( const RigWbsParameter&
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
std::vector<double> RigGeoMechWellLogExtractor::porePressureSourceRegions( int frameIndex ) std::vector<double> RigGeoMechWellLogExtractor::porePressureSourceRegions( int timeStepIndex, int frameIndex )
{ {
RigFemResultAddress ppResAddr( RIG_ELEMENT_NODAL, RiaResultNames::wbsPPResult().toStdString(), "" ); RigFemResultAddress ppResAddr( RIG_ELEMENT_NODAL, RiaResultNames::wbsPPResult().toStdString(), "" );
std::vector<double> values; std::vector<double> values;
std::vector<WbsParameterSource> sources = wellPathScaledCurveData( ppResAddr, frameIndex, &values ); std::vector<WbsParameterSource> sources = wellPathScaledCurveData( ppResAddr, timeStepIndex, frameIndex, &values );
std::vector<double> doubleSources( sources.size(), 0.0 ); std::vector<double> doubleSources( sources.size(), 0.0 );
#pragma omp parallel for #pragma omp parallel for
@ -833,11 +852,11 @@ std::vector<double> RigGeoMechWellLogExtractor::porePressureSourceRegions( int f
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
std::vector<double> RigGeoMechWellLogExtractor::poissonSourceRegions( int frameIndex ) std::vector<double> RigGeoMechWellLogExtractor::poissonSourceRegions( int timeStepIndex, int frameIndex )
{ {
std::vector<double> outputValues; std::vector<double> outputValues;
std::vector<WbsParameterSource> sources = std::vector<WbsParameterSource> sources =
calculateWbsParameterForAllSegments( RigWbsParameter::poissonRatio(), frameIndex, &outputValues, false ); calculateWbsParameterForAllSegments( RigWbsParameter::poissonRatio(), timeStepIndex, frameIndex, &outputValues, false );
std::vector<double> doubleSources( sources.size(), 0.0 ); std::vector<double> doubleSources( sources.size(), 0.0 );
#pragma omp parallel for #pragma omp parallel for
@ -851,11 +870,11 @@ std::vector<double> RigGeoMechWellLogExtractor::poissonSourceRegions( int frameI
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
std::vector<double> RigGeoMechWellLogExtractor::ucsSourceRegions( int frameIndex ) std::vector<double> RigGeoMechWellLogExtractor::ucsSourceRegions( int timeStepIndex, int frameIndex )
{ {
std::vector<double> outputValues; std::vector<double> outputValues;
std::vector<WbsParameterSource> sources = std::vector<WbsParameterSource> sources =
calculateWbsParameterForAllSegments( RigWbsParameter::UCS(), frameIndex, &outputValues, true ); calculateWbsParameterForAllSegments( RigWbsParameter::UCS(), timeStepIndex, frameIndex, &outputValues, true );
std::vector<double> doubleSources( sources.size(), 0.0 ); std::vector<double> doubleSources( sources.size(), 0.0 );
#pragma omp parallel for #pragma omp parallel for
@ -1251,6 +1270,7 @@ bool RigGeoMechWellLogExtractor::averageIntersectionValuesToSegmentValue( size_t
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
template <typename T> template <typename T>
std::vector<T> RigGeoMechWellLogExtractor::interpolateInterfaceValues( RigFemResultAddress nativeAddr, std::vector<T> RigGeoMechWellLogExtractor::interpolateInterfaceValues( RigFemResultAddress nativeAddr,
int timeStepIndex,
int frameIndex, int frameIndex,
const std::vector<T>& unscaledResultValues ) const std::vector<T>& unscaledResultValues )
{ {

View File

@ -61,13 +61,14 @@ public:
gsl::not_null<const RigWellPath*> wellpath, gsl::not_null<const RigWellPath*> wellpath,
const std::string& wellCaseErrorMsgName ); const std::string& wellCaseErrorMsgName );
void performCurveDataSmoothing( int frameIndex, void performCurveDataSmoothing( int timeStepIndex,
int frameIndex,
std::vector<double>* mds, std::vector<double>* mds,
std::vector<double>* tvds, std::vector<double>* tvds,
std::vector<double>* values, std::vector<double>* values,
const double smoothingTreshold ); const double smoothingTreshold );
QString curveData( const RigFemResultAddress& resAddr, int frameIndex, std::vector<double>* values ); QString curveData( const RigFemResultAddress& resAddr, int timeStepIndex, int frameIndex, std::vector<double>* values );
const RigGeoMechCaseData* caseData(); const RigGeoMechCaseData* caseData();
void setWbsLasValues( const RigWbsParameter& parameter, const std::vector<std::pair<double, double>>& values ); void setWbsLasValues( const RigWbsParameter& parameter, const std::vector<std::pair<double, double>>& values );
@ -76,9 +77,9 @@ public:
static QString parameterInputUnits( const RigWbsParameter& parameter ); static QString parameterInputUnits( const RigWbsParameter& parameter );
std::vector<double> porePressureSourceRegions( int frameIndex ); std::vector<double> porePressureSourceRegions( int timeStepIndex, int frameIndex );
std::vector<double> poissonSourceRegions( int frameIndex ); std::vector<double> poissonSourceRegions( int timeStepIndex, int frameIndex );
std::vector<double> ucsSourceRegions( int frameIndex ); std::vector<double> ucsSourceRegions( int timeStepIndex, int frameIndex );
static caf::Ten3d transformTensorToWellPathOrientation( const cvf::Vec3d& wellPathTangent, static caf::Ten3d transformTensorToWellPathOrientation( const cvf::Vec3d& wellPathTangent,
const caf::Ten3d& wellPathTensor ); const caf::Ten3d& wellPathTensor );
@ -98,27 +99,34 @@ private:
std::vector<WbsParameterSource> calculateWbsParameterForAllSegments( const RigWbsParameter& parameter, std::vector<WbsParameterSource> calculateWbsParameterForAllSegments( const RigWbsParameter& parameter,
WbsParameterSource primarySource, WbsParameterSource primarySource,
int timeStepIndex,
int frameIndex, int frameIndex,
std::vector<double>* outputValues, std::vector<double>* outputValues,
bool allowNormalization ); bool allowNormalization );
std::vector<WbsParameterSource> calculateWbsParameterForAllSegments( const RigWbsParameter& parameter, std::vector<WbsParameterSource> calculateWbsParameterForAllSegments( const RigWbsParameter& parameter,
int timeStepIndex,
int frameIndex, int frameIndex,
std::vector<double>* outputValues, std::vector<double>* outputValues,
bool allowNormalization ); bool allowNormalization );
std::vector<WbsParameterSource> calculateWbsParametersForAllSegments( const RigFemResultAddress& resAddr, std::vector<WbsParameterSource> calculateWbsParametersForAllSegments( const RigFemResultAddress& resAddr,
int timeStepIndex,
int frameIndex, int frameIndex,
std::vector<double>* values, std::vector<double>* values,
bool allowNormalization ); bool allowNormalization );
void wellPathAngles( const RigFemResultAddress& resAddr, std::vector<double>* values ); void wellPathAngles( const RigFemResultAddress& resAddr, std::vector<double>* values );
std::vector<WbsParameterSource> wellPathScaledCurveData( const RigFemResultAddress& resAddr, std::vector<WbsParameterSource> wellPathScaledCurveData( const RigFemResultAddress& resAddr,
int timeStepIndex,
int frameIndex, int frameIndex,
std::vector<double>* values, std::vector<double>* values,
bool forceGridSourceforPPReservoir = false ); bool forceGridSourceforPPReservoir = false );
void wellBoreWallCurveData( const RigFemResultAddress& resAddr, int frameIndex, std::vector<double>* values ); void wellBoreWallCurveData( const RigFemResultAddress& resAddr,
int timeStepIndex,
int frameIndex,
std::vector<double>* values );
void wellBoreFGShale( int frameIndex, std::vector<double>* values ); void wellBoreFGShale( int timeStepIndex, int frameIndex, std::vector<double>* values );
void wellBoreSH_MatthewsKelly( int frameIndex, std::vector<double>* values ); void wellBoreSH_MatthewsKelly( int timeStepIndex, int frameIndex, std::vector<double>* values );
template <typename T> template <typename T>
T interpolateGridResultValue( RigFemResultPosEnum resultPosType, T interpolateGridResultValue( RigFemResultPosEnum resultPosType,
@ -144,6 +152,7 @@ private:
template <typename T> template <typename T>
std::vector<T> interpolateInterfaceValues( RigFemResultAddress nativeAddr, std::vector<T> interpolateInterfaceValues( RigFemResultAddress nativeAddr,
int timeStepIndex,
int frameIndex, int frameIndex,
const std::vector<T>& unscaledResultValues ); const std::vector<T>& unscaledResultValues );

View File

@ -183,7 +183,8 @@ RiuEclipseSelectionItem::RiuEclipseSelectionItem( RimGridView*
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RiuGeoMechSelectionItem::RiuGeoMechSelectionItem( RimGridView* view, RiuGeoMechSelectionItem::RiuGeoMechSelectionItem( RimGridView* view,
RimGeoMechResultDefinition* resultDefinition, RimGeoMechResultDefinition* resultDefinition,
size_t timestepIdx, int timestepIdx,
int frameIdx,
size_t gridIndex, size_t gridIndex,
size_t cellIndex, size_t cellIndex,
cvf::Color3f color, cvf::Color3f color,
@ -192,6 +193,7 @@ RiuGeoMechSelectionItem::RiuGeoMechSelectionItem( RimGridView* vi
: m_view( view ) : m_view( view )
, m_resultDefinition( resultDefinition ) , m_resultDefinition( resultDefinition )
, m_timestepIdx( timestepIdx ) , m_timestepIdx( timestepIdx )
, m_frameIdx( frameIdx )
, m_gridIndex( gridIndex ) , m_gridIndex( gridIndex )
, m_cellIndex( cellIndex ) , m_cellIndex( cellIndex )
, m_color( color ) , m_color( color )
@ -206,7 +208,8 @@ RiuGeoMechSelectionItem::RiuGeoMechSelectionItem( RimGridView* vi
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RiuGeoMechSelectionItem::RiuGeoMechSelectionItem( RimGridView* view, RiuGeoMechSelectionItem::RiuGeoMechSelectionItem( RimGridView* view,
RimGeoMechResultDefinition* resultDefinition, RimGeoMechResultDefinition* resultDefinition,
size_t timestepIdx, int timestepIdx,
int frameIdx,
size_t gridIndex, size_t gridIndex,
size_t cellIndex, size_t cellIndex,
cvf::Color3f color, cvf::Color3f color,
@ -216,6 +219,7 @@ RiuGeoMechSelectionItem::RiuGeoMechSelectionItem( RimGridView*
: m_view( view ) : m_view( view )
, m_resultDefinition( resultDefinition ) , m_resultDefinition( resultDefinition )
, m_timestepIdx( timestepIdx ) , m_timestepIdx( timestepIdx )
, m_frameIdx( frameIdx )
, m_gridIndex( gridIndex ) , m_gridIndex( gridIndex )
, m_cellIndex( cellIndex ) , m_cellIndex( cellIndex )
, m_color( color ) , m_color( color )

View File

@ -174,7 +174,8 @@ class RiuGeoMechSelectionItem : public RiuSelectionItem
public: public:
explicit RiuGeoMechSelectionItem( RimGridView* view, explicit RiuGeoMechSelectionItem( RimGridView* view,
RimGeoMechResultDefinition* resultDefinition, RimGeoMechResultDefinition* resultDefinition,
size_t timestepIdx, int timestepIdx,
int frameIdx,
size_t gridIndex, size_t gridIndex,
size_t cellIndex, size_t cellIndex,
cvf::Color3f color, cvf::Color3f color,
@ -183,7 +184,8 @@ public:
explicit RiuGeoMechSelectionItem( RimGridView* view, explicit RiuGeoMechSelectionItem( RimGridView* view,
RimGeoMechResultDefinition* resultDefinition, RimGeoMechResultDefinition* resultDefinition,
size_t timestepIdx, int timestepIdx,
int frameIdx,
size_t gridIndex, size_t gridIndex,
size_t cellIndex, size_t cellIndex,
cvf::Color3f color, cvf::Color3f color,
@ -197,7 +199,8 @@ public:
public: public:
caf::PdmPointer<RimGridView> m_view; caf::PdmPointer<RimGridView> m_view;
caf::PdmPointer<RimGeoMechResultDefinition> m_resultDefinition; caf::PdmPointer<RimGeoMechResultDefinition> m_resultDefinition;
size_t m_timestepIdx; int m_timestepIdx;
int m_frameIdx;
size_t m_gridIndex; size_t m_gridIndex;
size_t m_cellIndex; size_t m_cellIndex;
cvf::Color3f m_color; cvf::Color3f m_color;

View File

@ -26,6 +26,7 @@
#include "RimEclipseCellColors.h" #include "RimEclipseCellColors.h"
#include "RimEclipseView.h" #include "RimEclipseView.h"
#include "RimExtrudedCurveIntersection.h" #include "RimExtrudedCurveIntersection.h"
#include "RimGeoMechCase.h"
#include "RimGeoMechCellColors.h" #include "RimGeoMechCellColors.h"
#include "RimGeoMechView.h" #include "RimGeoMechView.h"
#include "RimIntersectionResultDefinition.h" #include "RimIntersectionResultDefinition.h"
@ -42,6 +43,8 @@
#include "RivSourceInfo.h" #include "RivSourceInfo.h"
#include "RigEclipseCaseData.h" #include "RigEclipseCaseData.h"
#include "RigFemPartResultsCollection.h"
#include "RigGeoMechCaseData.h"
#include "RigMainGrid.h" #include "RigMainGrid.h"
#include "RigNNCData.h" #include "RigNNCData.h"
@ -133,7 +136,9 @@ bool RiuCellAndNncPickEventHandler::handle3dPickEvent( const Ric3dPickEvent& eve
RimGeoMechResultDefinition* geomResDef = nullptr; RimGeoMechResultDefinition* geomResDef = nullptr;
RimEclipseResultDefinition* eclResDef = nullptr; RimEclipseResultDefinition* eclResDef = nullptr;
size_t timestepIndex = cvf::UNDEFINED_SIZE_T; 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 // clang-format off
if ( const RivSourceInfo* rivSourceInfo = dynamic_cast<const RivSourceInfo*>( firstHitPart->sourceInfo() ) ) if ( const RivSourceInfo* rivSourceInfo = dynamic_cast<const RivSourceInfo*>( firstHitPart->sourceInfo() ) )
@ -199,14 +204,23 @@ bool RiuCellAndNncPickEventHandler::handle3dPickEvent( const Ric3dPickEvent& eve
{ {
if ( sepInterResDef->isEclipseResultDefinition() ) if ( sepInterResDef->isEclipseResultDefinition() )
{ {
eclResDef = sepInterResDef->eclipseResultDefinition(); eclResDef = sepInterResDef->eclipseResultDefinition();
timestepIndex = sepInterResDef->timeStep();
} }
else else
{ {
RimGeoMechView* geomView = dynamic_cast<RimGeoMechView*>( mainOrComparisonView );
if ( geomView )
{
if ( geomView->geoMechCase() && geomView->geoMechCase()->geoMechData() )
{
std::tie( timestepIndex, dataFrameIndex ) =
geomView->geoMechCase()->geoMechData()->femPartResults()->stepListIndexToTimeStepAndDataFrameIndex(
sepInterResDef->timeStep() );
}
}
geomResDef = sepInterResDef->geoMechResultDefinition(); geomResDef = sepInterResDef->geoMechResultDefinition();
} }
timestepIndex = sepInterResDef->timeStep();
} }
if ( gridLocalCellIndex == cvf::UNDEFINED_SIZE_T ) if ( gridLocalCellIndex == cvf::UNDEFINED_SIZE_T )
@ -286,7 +300,11 @@ bool RiuCellAndNncPickEventHandler::handle3dPickEvent( const Ric3dPickEvent& eve
if ( geomView ) if ( geomView )
{ {
if ( !geomResDef ) geomResDef = geomView->cellResult(); 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, selItem = new RiuGeoMechSelectionItem( associatedGridView,
geomResDef, geomResDef,
timestepIndex, timestepIndex,
dataFrameIndex,
gridIndex, gridIndex,
gridLocalCellIndex, gridLocalCellIndex,
curveColor, curveColor,
@ -380,6 +399,7 @@ bool RiuCellAndNncPickEventHandler::handle3dPickEvent( const Ric3dPickEvent& eve
selItem = new RiuGeoMechSelectionItem( associatedGridView, selItem = new RiuGeoMechSelectionItem( associatedGridView,
geomResDef, geomResDef,
timestepIndex, timestepIndex,
dataFrameIndex,
gridIndex, gridIndex,
gridLocalCellIndex, gridLocalCellIndex,
curveColor, curveColor,

View File

@ -46,7 +46,8 @@ RiuFemResultTextBuilder::RiuFemResultTextBuilder( RimGridView* di
RimGeoMechResultDefinition* geomResDef, RimGeoMechResultDefinition* geomResDef,
int gridIndex, int gridIndex,
int cellIndex, int cellIndex,
int timeStepIndex ) int timeStepIndex,
int frameIndex )
: m_isIntersectionTriangleSet( false ) : m_isIntersectionTriangleSet( false )
{ {
m_displayCoordView = displayCoordView; m_displayCoordView = displayCoordView;
@ -54,6 +55,7 @@ RiuFemResultTextBuilder::RiuFemResultTextBuilder( RimGridView* di
m_gridIndex = gridIndex; m_gridIndex = gridIndex;
m_cellIndex = cellIndex; m_cellIndex = cellIndex;
m_timeStepIndex = timeStepIndex; m_timeStepIndex = timeStepIndex;
m_frameIndex = frameIndex;
m_intersectionPointInDisplay = cvf::Vec3d::UNDEFINED; m_intersectionPointInDisplay = cvf::Vec3d::UNDEFINED;
m_face = cvf::StructGridInterface::NO_FACE; m_face = cvf::StructGridInterface::NO_FACE;
@ -198,7 +200,13 @@ QString RiuFemResultTextBuilder::gridResultDetails()
{ {
RigGeoMechCaseData* eclipseCaseData = m_geomResDef->geoMechCase()->geoMechData(); 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() ) if ( !text.isEmpty() )
{ {
@ -261,6 +269,7 @@ void RiuFemResultTextBuilder::appendTextFromResultColors( RigGeoMechCaseData*
int gridIndex, int gridIndex,
int cellIndex, int cellIndex,
int timeStepIndex, int timeStepIndex,
int frameIndex,
RimGeoMechResultDefinition* resultDefinition, RimGeoMechResultDefinition* resultDefinition,
QString* resultInfoText ) QString* resultInfoText )
{ {
@ -272,7 +281,7 @@ void RiuFemResultTextBuilder::appendTextFromResultColors( RigGeoMechCaseData*
if ( resultDefinition->hasResult() ) if ( resultDefinition->hasResult() )
{ {
const std::vector<float>& scalarResults = const std::vector<float>& scalarResults =
geomData->femPartResults()->resultValues( resultDefinition->resultAddress(), gridIndex, timeStepIndex ); geomData->femPartResults()->resultValues( resultDefinition->resultAddress(), gridIndex, timeStepIndex, frameIndex );
if ( scalarResults.size() ) if ( scalarResults.size() )
{ {
caf::AppEnum<RigFemResultPosEnum> resPosAppEnum = resultDefinition->resultPositionType(); caf::AppEnum<RigFemResultPosEnum> resPosAppEnum = resultDefinition->resultPositionType();
@ -399,8 +408,10 @@ QString RiuFemResultTextBuilder::closestNodeResultText( RimGeoMechResultDefiniti
RigGeoMechCaseData* geomData = m_geomResDef->geoMechCase()->geoMechData(); RigGeoMechCaseData* geomData = m_geomResDef->geoMechCase()->geoMechData();
const std::vector<float>& scalarResults = const std::vector<float>& scalarResults = geomData->femPartResults()->resultValues( resultColors->resultAddress(),
geomData->femPartResults()->resultValues( resultColors->resultAddress(), m_gridIndex, m_timeStepIndex ); m_gridIndex,
m_timeStepIndex,
m_frameIndex );
if ( scalarResults.size() && m_displayCoordView ) if ( scalarResults.size() && m_displayCoordView )
{ {
@ -441,7 +452,9 @@ QString RiuFemResultTextBuilder::closestNodeResultText( RimGeoMechResultDefiniti
{ {
RiuGeoMechXfTensorResultAccessor tensAccessor( geomData->femPartResults(), RiuGeoMechXfTensorResultAccessor tensAccessor( geomData->femPartResults(),
resultColors->resultAddress(), resultColors->resultAddress(),
m_timeStepIndex ); m_gridIndex,
m_timeStepIndex,
m_frameIndex );
float tensValue = tensAccessor.calculateElmNodeValue( m_intersectionTriangle, closestElmNodResIdx ); float tensValue = tensAccessor.calculateElmNodeValue( m_intersectionTriangle, closestElmNodResIdx );
text.append( QString( "Closest result: N[%1], in Element[%2] transformed onto intersection: %3 \n" ) text.append( QString( "Closest result: N[%1], in Element[%2] transformed onto intersection: %3 \n" )

View File

@ -48,7 +48,8 @@ public:
RimGeoMechResultDefinition* geomResDef, RimGeoMechResultDefinition* geomResDef,
int gridIndex, int gridIndex,
int cellIndex, int cellIndex,
int timeStepIndex ); int timeStepIndex,
int frameIndex );
void setFace( int face ); void setFace( int face );
void setIntersectionPointInDisplay( cvf::Vec3d intersectionPointInDisplay ); void setIntersectionPointInDisplay( cvf::Vec3d intersectionPointInDisplay );
void setIntersectionTriangle( const std::array<cvf::Vec3f, 3>& triangle ); void setIntersectionTriangle( const std::array<cvf::Vec3f, 3>& triangle );
@ -70,6 +71,7 @@ private:
int gridIndex, int gridIndex,
int cellIndex, int cellIndex,
int timeStepIndex, int timeStepIndex,
int frameIndex,
RimGeoMechResultDefinition* resultDefinition, RimGeoMechResultDefinition* resultDefinition,
QString* resultInfoText ); QString* resultInfoText );
@ -81,6 +83,7 @@ private:
int m_gridIndex; int m_gridIndex;
int m_cellIndex; int m_cellIndex;
int m_timeStepIndex; int m_timeStepIndex;
int m_frameIndex;
int m_face; int m_face;
bool m_isIntersectionTriangleSet; bool m_isIntersectionTriangleSet;

Some files were not shown because too many files have changed in this diff Show More