mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Geomech frames support (#9678)
Support for showing frames in geomech data.
This commit is contained in:
@@ -112,6 +112,22 @@ RigFemPartResultsCollection::RigFemPartResultsCollection( RifGeoMechReaderInterf
|
||||
femPartResult->initResultSteps( filteredStepNames );
|
||||
}
|
||||
|
||||
// initialize step cache
|
||||
{
|
||||
int stepIdx = 0;
|
||||
for ( auto& stepName : filteredStepNames )
|
||||
{
|
||||
int frameIdx = 0;
|
||||
for ( auto& frame : m_readerInterface->frameTimes( stepIdx ) )
|
||||
{
|
||||
m_stepNames.emplace_back( stepName + " (" + std::to_string( frame ) + ")" );
|
||||
m_stepList.emplace_back( stepIdx, frameIdx );
|
||||
frameIdx++;
|
||||
}
|
||||
stepIdx++;
|
||||
}
|
||||
}
|
||||
|
||||
m_cohesion = 10.0;
|
||||
m_frictionAngleRad = cvf::Math::toRadians( 30.0 );
|
||||
m_normalizationAirGap = 0.0;
|
||||
@@ -388,9 +404,9 @@ void RigFemPartResultsCollection::setReferenceTimeStep( int referenceTimeStep )
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
int RigFemPartResultsCollection::referenceTimeStep() const
|
||||
std::pair<int, int> RigFemPartResultsCollection::referenceStepAndFrameIndex() const
|
||||
{
|
||||
return m_referenceTimeStep;
|
||||
return stepListIndexToTimeStepAndDataFrameIndex( m_referenceTimeStep );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -405,7 +421,7 @@ void RigFemPartResultsCollection::setPermeabilityParameters( double fixe
|
||||
m_permeabilityExponent = permeabilityExponent;
|
||||
|
||||
std::set<RigFemResultAddress> results = initialPermeabilityDependentResults();
|
||||
for ( auto result : results )
|
||||
for ( auto& result : results )
|
||||
{
|
||||
deleteResult( result );
|
||||
}
|
||||
@@ -459,12 +475,12 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::findOrLoadScalarResult( i
|
||||
std::map<std::string, std::vector<float>> elementProperties =
|
||||
m_elementPropertyReader->readAllElementPropertiesInFileContainingField( resVarAddr.fieldName );
|
||||
|
||||
for ( auto [addrString, values] : elementProperties )
|
||||
for ( auto& [addrString, values] : elementProperties )
|
||||
{
|
||||
RigFemResultAddress addressForElement( RIG_ELEMENT, addrString, "" );
|
||||
RigFemScalarResultFrames* currentFrames = m_femPartResults[partIndex]->createScalarResult( addressForElement );
|
||||
currentFrames->enableAsSingleFrameResult();
|
||||
currentFrames->frameData( 0 ).swap( values );
|
||||
currentFrames->enableAsSingleStepResult();
|
||||
currentFrames->frameData( 0, 0 ).swap( values );
|
||||
}
|
||||
|
||||
frames = m_femPartResults[partIndex]->findScalarResult( resVarAddr );
|
||||
@@ -490,46 +506,50 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::findOrLoadScalarResult( i
|
||||
resultsForEachComponent.push_back( m_femPartResults[partIndex]->createScalarResult( resultAddressOfComponent ) );
|
||||
}
|
||||
|
||||
int frameCount = this->frameCount();
|
||||
caf::ProgressInfo progress( frameCount, "" );
|
||||
int timeSteps = this->timeStepCount();
|
||||
caf::ProgressInfo progress( timeSteps, "" );
|
||||
progress.setProgressDescription(
|
||||
QString( "Loading Native Result %1 %2" ).arg( resVarAddr.fieldName.c_str(), resVarAddr.componentName.c_str() ) );
|
||||
|
||||
for ( int stepIndex = 0; stepIndex < frameCount; ++stepIndex )
|
||||
for ( int stepIndex = 0; stepIndex < timeSteps; ++stepIndex )
|
||||
{
|
||||
std::vector<double> frameTimes = m_readerInterface->frameTimes( stepIndex );
|
||||
|
||||
int fIdx = (int)( frameTimes.size() - 1 );
|
||||
|
||||
std::vector<std::vector<float>*> componentDataVectors;
|
||||
for ( auto& componentResult : resultsForEachComponent )
|
||||
for ( int frameIndex = 0; frameIndex < int( frameTimes.size() ); frameIndex++ )
|
||||
{
|
||||
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 )
|
||||
{
|
||||
case RIG_NODAL:
|
||||
m_readerInterface->readNodeField( resVarAddr.fieldName, partIndex, stepIndex, fIdx, &componentDataVectors );
|
||||
break;
|
||||
case RIG_ELEMENT_NODAL:
|
||||
m_readerInterface->readElementNodeField( resVarAddr.fieldName,
|
||||
partIndex,
|
||||
stepIndex,
|
||||
fIdx,
|
||||
&componentDataVectors );
|
||||
break;
|
||||
case RIG_INTEGRATION_POINT:
|
||||
m_readerInterface->readIntegrationPointField( resVarAddr.fieldName,
|
||||
partIndex,
|
||||
stepIndex,
|
||||
fIdx,
|
||||
&componentDataVectors );
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
switch ( resVarAddr.resultPosType )
|
||||
{
|
||||
case RIG_NODAL:
|
||||
m_readerInterface->readNodeField( resVarAddr.fieldName,
|
||||
partIndex,
|
||||
stepIndex,
|
||||
frameIndex,
|
||||
&componentDataVectors );
|
||||
break;
|
||||
case RIG_ELEMENT_NODAL:
|
||||
m_readerInterface->readElementNodeField( resVarAddr.fieldName,
|
||||
partIndex,
|
||||
stepIndex,
|
||||
frameIndex,
|
||||
&componentDataVectors );
|
||||
break;
|
||||
case RIG_INTEGRATION_POINT:
|
||||
m_readerInterface->readIntegrationPointField( resVarAddr.fieldName,
|
||||
partIndex,
|
||||
stepIndex,
|
||||
frameIndex,
|
||||
&componentDataVectors );
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
progress.incrementProgress();
|
||||
}
|
||||
|
||||
@@ -940,7 +960,7 @@ std::vector<RigFemResultAddress>
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<std::string> RigFemPartResultsCollection::filteredStepNames() const
|
||||
std::vector<std::string> RigFemPartResultsCollection::filteredTimeStepNames() const
|
||||
{
|
||||
CVF_ASSERT( m_readerInterface.notNull() );
|
||||
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() )
|
||||
{
|
||||
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>&
|
||||
RigFemPartResultsCollection::resultValues( const RigFemResultAddress& resVarAddr, int partIndex, int frameIndex )
|
||||
const std::vector<float>& RigFemPartResultsCollection::resultValues( const RigFemResultAddress& resVarAddr,
|
||||
int partIndex,
|
||||
int stepIndex,
|
||||
int frameIndex )
|
||||
{
|
||||
CVF_ASSERT( resVarAddr.isValid() );
|
||||
|
||||
RigFemScalarResultFrames* scalarResults = findOrLoadScalarResult( partIndex, resVarAddr );
|
||||
return scalarResults->frameData( frameIndex );
|
||||
return scalarResults->frameData( stepIndex, frameIndex );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -1073,13 +1130,14 @@ const std::vector<float>&
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RigFemPartResultsCollection::globalResultValues( const RigFemResultAddress& resVarAddr,
|
||||
int timeStepIndex,
|
||||
int frameIndex,
|
||||
std::vector<float>& resultValues )
|
||||
{
|
||||
CVF_ASSERT( resVarAddr.isValid() );
|
||||
|
||||
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() )
|
||||
{
|
||||
size_t expectedSize = 0;
|
||||
@@ -1120,7 +1178,7 @@ void RigFemPartResultsCollection::globalResultValues( const RigFemResultAddress&
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
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 );
|
||||
|
||||
@@ -1133,12 +1191,12 @@ std::vector<caf::Ten3f>
|
||||
return outputTensors;
|
||||
}
|
||||
|
||||
const std::vector<float>& v11 = resultValues( addresses[caf::Ten3f::SXX], partIndex, frameIndex );
|
||||
const std::vector<float>& v22 = resultValues( addresses[caf::Ten3f::SYY], partIndex, frameIndex );
|
||||
const std::vector<float>& v33 = resultValues( addresses[caf::Ten3f::SZZ], partIndex, frameIndex );
|
||||
const std::vector<float>& v12 = resultValues( addresses[caf::Ten3f::SXY], partIndex, frameIndex );
|
||||
const std::vector<float>& v13 = resultValues( addresses[caf::Ten3f::SZX], partIndex, frameIndex );
|
||||
const std::vector<float>& v23 = resultValues( addresses[caf::Ten3f::SYZ], 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, stepIndex, 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, stepIndex, 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, stepIndex, frameIndex );
|
||||
|
||||
size_t valCount = v11.size();
|
||||
outputTensors.resize( valCount );
|
||||
@@ -1173,11 +1231,12 @@ RigStatisticsDataCache* RigFemPartResultsCollection::statistics( const RigFemRes
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RigFemPartResultsCollection::minMaxScalarValues( const RigFemResultAddress& resVarAddr,
|
||||
int stepIndex,
|
||||
int frameIndex,
|
||||
double* localMin,
|
||||
double* localMax )
|
||||
{
|
||||
this->statistics( resVarAddr )->minMaxCellScalarValues( frameIndex, *localMin, *localMax );
|
||||
this->statistics( resVarAddr )->minMaxCellScalarValues( stepIndex, *localMin, *localMax );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -1195,10 +1254,11 @@ void RigFemPartResultsCollection::minMaxScalarValues( const RigFemResultAddress&
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RigFemPartResultsCollection::posNegClosestToZero( const RigFemResultAddress& resVarAddr,
|
||||
int frameIndex,
|
||||
int stepIndex,
|
||||
double* localPosClosestToZero,
|
||||
double* localNegClosestToZero )
|
||||
{
|
||||
this->statistics( resVarAddr )->posNegClosestToZero( frameIndex, *localPosClosestToZero, *localNegClosestToZero );
|
||||
this->statistics( resVarAddr )->posNegClosestToZero( stepIndex, *localPosClosestToZero, *localNegClosestToZero );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -1224,9 +1284,12 @@ void RigFemPartResultsCollection::meanScalarValue( const RigFemResultAddress& re
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RigFemPartResultsCollection::meanScalarValue( const RigFemResultAddress& resVarAddr, int frameIndex, double* meanValue )
|
||||
void RigFemPartResultsCollection::meanScalarValue( const RigFemResultAddress& resVarAddr,
|
||||
int stepIndex,
|
||||
int frameIndex,
|
||||
double* meanValue )
|
||||
{
|
||||
this->statistics( resVarAddr )->meanCellScalarValues( frameIndex, *meanValue );
|
||||
this->statistics( resVarAddr )->meanCellScalarValues( stepIndex, *meanValue );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -1241,11 +1304,12 @@ void RigFemPartResultsCollection::p10p90ScalarValues( const RigFemResultAddress&
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RigFemPartResultsCollection::p10p90ScalarValues( const RigFemResultAddress& resVarAddr,
|
||||
int stepIndex,
|
||||
int frameIndex,
|
||||
double* p10,
|
||||
double* p90 )
|
||||
{
|
||||
this->statistics( resVarAddr )->p10p90CellScalarValues( frameIndex, *p10, *p90 );
|
||||
this->statistics( resVarAddr )->p10p90CellScalarValues( stepIndex, *p10, *p90 );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -1261,11 +1325,14 @@ void RigFemPartResultsCollection::sumScalarValue( const RigFemResultAddress& res
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RigFemPartResultsCollection::sumScalarValue( const RigFemResultAddress& resVarAddr, int frameIndex, double* sum )
|
||||
void RigFemPartResultsCollection::sumScalarValue( const RigFemResultAddress& resVarAddr,
|
||||
int stepIndex,
|
||||
int frameIndex,
|
||||
double* sum )
|
||||
{
|
||||
CVF_ASSERT( sum );
|
||||
|
||||
this->statistics( resVarAddr )->sumCellScalarValues( frameIndex, *sum );
|
||||
this->statistics( resVarAddr )->sumCellScalarValues( stepIndex, *sum );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -1280,11 +1347,15 @@ const std::vector<size_t>& RigFemPartResultsCollection::scalarValuesHistogram( c
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const std::vector<size_t>& RigFemPartResultsCollection::scalarValuesHistogram( const RigFemResultAddress& resVarAddr,
|
||||
int stepIndex,
|
||||
int frameIndex )
|
||||
{
|
||||
return this->statistics( resVarAddr )->cellScalarValuesHistogram( frameIndex );
|
||||
return this->statistics( resVarAddr )->cellScalarValuesHistogram( stepIndex );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RigFemResultAddress>
|
||||
RigFemPartResultsCollection::tensorPrincipalComponentAdresses( const RigFemResultAddress& resVarAddr )
|
||||
{
|
||||
@@ -1458,6 +1529,7 @@ double RigFemPartResultsCollection::normalizationAirGap() const
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RigFemPartResultsCollection::minMaxScalarValuesOverAllTensorComponents( const RigFemResultAddress& resVarAddr,
|
||||
int stepIndex,
|
||||
int frameIndex,
|
||||
double* localMin,
|
||||
double* localMax )
|
||||
@@ -1469,7 +1541,7 @@ void RigFemPartResultsCollection::minMaxScalarValuesOverAllTensorComponents( con
|
||||
|
||||
for ( const auto& address : tensorPrincipalComponentAdresses( resVarAddr ) )
|
||||
{
|
||||
this->statistics( address )->minMaxCellScalarValues( frameIndex, min, max );
|
||||
this->statistics( address )->minMaxCellScalarValues( stepIndex, min, max );
|
||||
if ( min < currentMin )
|
||||
{
|
||||
currentMin = min;
|
||||
@@ -1517,6 +1589,7 @@ void RigFemPartResultsCollection::minMaxScalarValuesOverAllTensorComponents( con
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RigFemPartResultsCollection::posNegClosestToZeroOverAllTensorComponents( const RigFemResultAddress& resVarAddr,
|
||||
int stepIndex,
|
||||
int frameIndex,
|
||||
double* localPosClosestToZero,
|
||||
double* localNegClosestToZero )
|
||||
@@ -1528,7 +1601,7 @@ void RigFemPartResultsCollection::posNegClosestToZeroOverAllTensorComponents( co
|
||||
|
||||
for ( const auto& address : tensorPrincipalComponentAdresses( resVarAddr ) )
|
||||
{
|
||||
this->statistics( address )->posNegClosestToZero( frameIndex, pos, neg );
|
||||
this->statistics( address )->posNegClosestToZero( stepIndex, pos, neg );
|
||||
if ( pos < currentPosClosestToZero )
|
||||
{
|
||||
currentPosClosestToZero = pos;
|
||||
|
||||
Reference in New Issue
Block a user