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:
committed by
Magne Sjaastad
parent
05bf744197
commit
dc5d53ad20
@@ -183,7 +183,8 @@ RiuEclipseSelectionItem::RiuEclipseSelectionItem( RimGridView*
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiuGeoMechSelectionItem::RiuGeoMechSelectionItem( RimGridView* view,
|
||||
RimGeoMechResultDefinition* resultDefinition,
|
||||
size_t timestepIdx,
|
||||
int timestepIdx,
|
||||
int frameIdx,
|
||||
size_t gridIndex,
|
||||
size_t cellIndex,
|
||||
cvf::Color3f color,
|
||||
@@ -192,6 +193,7 @@ RiuGeoMechSelectionItem::RiuGeoMechSelectionItem( RimGridView* vi
|
||||
: m_view( view )
|
||||
, m_resultDefinition( resultDefinition )
|
||||
, m_timestepIdx( timestepIdx )
|
||||
, m_frameIdx( frameIdx )
|
||||
, m_gridIndex( gridIndex )
|
||||
, m_cellIndex( cellIndex )
|
||||
, m_color( color )
|
||||
@@ -206,7 +208,8 @@ RiuGeoMechSelectionItem::RiuGeoMechSelectionItem( RimGridView* vi
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiuGeoMechSelectionItem::RiuGeoMechSelectionItem( RimGridView* view,
|
||||
RimGeoMechResultDefinition* resultDefinition,
|
||||
size_t timestepIdx,
|
||||
int timestepIdx,
|
||||
int frameIdx,
|
||||
size_t gridIndex,
|
||||
size_t cellIndex,
|
||||
cvf::Color3f color,
|
||||
@@ -216,6 +219,7 @@ RiuGeoMechSelectionItem::RiuGeoMechSelectionItem( RimGridView*
|
||||
: m_view( view )
|
||||
, m_resultDefinition( resultDefinition )
|
||||
, m_timestepIdx( timestepIdx )
|
||||
, m_frameIdx( frameIdx )
|
||||
, m_gridIndex( gridIndex )
|
||||
, m_cellIndex( cellIndex )
|
||||
, m_color( color )
|
||||
|
||||
@@ -174,7 +174,8 @@ class RiuGeoMechSelectionItem : public RiuSelectionItem
|
||||
public:
|
||||
explicit RiuGeoMechSelectionItem( RimGridView* view,
|
||||
RimGeoMechResultDefinition* resultDefinition,
|
||||
size_t timestepIdx,
|
||||
int timestepIdx,
|
||||
int frameIdx,
|
||||
size_t gridIndex,
|
||||
size_t cellIndex,
|
||||
cvf::Color3f color,
|
||||
@@ -183,7 +184,8 @@ public:
|
||||
|
||||
explicit RiuGeoMechSelectionItem( RimGridView* view,
|
||||
RimGeoMechResultDefinition* resultDefinition,
|
||||
size_t timestepIdx,
|
||||
int timestepIdx,
|
||||
int frameIdx,
|
||||
size_t gridIndex,
|
||||
size_t cellIndex,
|
||||
cvf::Color3f color,
|
||||
@@ -197,7 +199,8 @@ public:
|
||||
public:
|
||||
caf::PdmPointer<RimGridView> m_view;
|
||||
caf::PdmPointer<RimGeoMechResultDefinition> m_resultDefinition;
|
||||
size_t m_timestepIdx;
|
||||
int m_timestepIdx;
|
||||
int m_frameIdx;
|
||||
size_t m_gridIndex;
|
||||
size_t m_cellIndex;
|
||||
cvf::Color3f m_color;
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include "RimEclipseCellColors.h"
|
||||
#include "RimEclipseView.h"
|
||||
#include "RimExtrudedCurveIntersection.h"
|
||||
#include "RimGeoMechCase.h"
|
||||
#include "RimGeoMechCellColors.h"
|
||||
#include "RimGeoMechView.h"
|
||||
#include "RimIntersectionResultDefinition.h"
|
||||
@@ -42,6 +43,8 @@
|
||||
#include "RivSourceInfo.h"
|
||||
|
||||
#include "RigEclipseCaseData.h"
|
||||
#include "RigFemPartResultsCollection.h"
|
||||
#include "RigGeoMechCaseData.h"
|
||||
#include "RigMainGrid.h"
|
||||
#include "RigNNCData.h"
|
||||
|
||||
@@ -133,7 +136,9 @@ bool RiuCellAndNncPickEventHandler::handle3dPickEvent( const Ric3dPickEvent& eve
|
||||
RimGeoMechResultDefinition* geomResDef = nullptr;
|
||||
RimEclipseResultDefinition* eclResDef = nullptr;
|
||||
size_t timestepIndex = cvf::UNDEFINED_SIZE_T;
|
||||
RimIntersectionResultDefinition* sepInterResDef = nullptr;
|
||||
int dataFrameIndex = -2; // needs to be less than -1, as -1 means last step
|
||||
|
||||
RimIntersectionResultDefinition* sepInterResDef = nullptr;
|
||||
|
||||
// clang-format off
|
||||
if ( const RivSourceInfo* rivSourceInfo = dynamic_cast<const RivSourceInfo*>( firstHitPart->sourceInfo() ) )
|
||||
@@ -199,14 +204,23 @@ bool RiuCellAndNncPickEventHandler::handle3dPickEvent( const Ric3dPickEvent& eve
|
||||
{
|
||||
if ( sepInterResDef->isEclipseResultDefinition() )
|
||||
{
|
||||
eclResDef = sepInterResDef->eclipseResultDefinition();
|
||||
eclResDef = sepInterResDef->eclipseResultDefinition();
|
||||
timestepIndex = sepInterResDef->timeStep();
|
||||
}
|
||||
else
|
||||
{
|
||||
RimGeoMechView* geomView = dynamic_cast<RimGeoMechView*>( mainOrComparisonView );
|
||||
if ( geomView )
|
||||
{
|
||||
if ( geomView->geoMechCase() && geomView->geoMechCase()->geoMechData() )
|
||||
{
|
||||
std::tie( timestepIndex, dataFrameIndex ) =
|
||||
geomView->geoMechCase()->geoMechData()->femPartResults()->stepListIndexToTimeStepAndDataFrameIndex(
|
||||
sepInterResDef->timeStep() );
|
||||
}
|
||||
}
|
||||
geomResDef = sepInterResDef->geoMechResultDefinition();
|
||||
}
|
||||
|
||||
timestepIndex = sepInterResDef->timeStep();
|
||||
}
|
||||
|
||||
if ( gridLocalCellIndex == cvf::UNDEFINED_SIZE_T )
|
||||
@@ -286,7 +300,11 @@ bool RiuCellAndNncPickEventHandler::handle3dPickEvent( const Ric3dPickEvent& eve
|
||||
if ( geomView )
|
||||
{
|
||||
if ( !geomResDef ) geomResDef = geomView->cellResult();
|
||||
if ( timestepIndex == cvf::UNDEFINED_SIZE_T ) timestepIndex = geomView->currentTimeStep();
|
||||
|
||||
auto [stepIdx, frameIdx] = geomView->currentStepAndDataFrame();
|
||||
|
||||
if ( timestepIndex == cvf::UNDEFINED_SIZE_T ) timestepIndex = stepIdx;
|
||||
if ( dataFrameIndex < -1 ) dataFrameIndex = frameIdx;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -370,6 +388,7 @@ bool RiuCellAndNncPickEventHandler::handle3dPickEvent( const Ric3dPickEvent& eve
|
||||
selItem = new RiuGeoMechSelectionItem( associatedGridView,
|
||||
geomResDef,
|
||||
timestepIndex,
|
||||
dataFrameIndex,
|
||||
gridIndex,
|
||||
gridLocalCellIndex,
|
||||
curveColor,
|
||||
@@ -380,6 +399,7 @@ bool RiuCellAndNncPickEventHandler::handle3dPickEvent( const Ric3dPickEvent& eve
|
||||
selItem = new RiuGeoMechSelectionItem( associatedGridView,
|
||||
geomResDef,
|
||||
timestepIndex,
|
||||
dataFrameIndex,
|
||||
gridIndex,
|
||||
gridLocalCellIndex,
|
||||
curveColor,
|
||||
|
||||
@@ -46,7 +46,8 @@ RiuFemResultTextBuilder::RiuFemResultTextBuilder( RimGridView* di
|
||||
RimGeoMechResultDefinition* geomResDef,
|
||||
int gridIndex,
|
||||
int cellIndex,
|
||||
int timeStepIndex )
|
||||
int timeStepIndex,
|
||||
int frameIndex )
|
||||
: m_isIntersectionTriangleSet( false )
|
||||
{
|
||||
m_displayCoordView = displayCoordView;
|
||||
@@ -54,6 +55,7 @@ RiuFemResultTextBuilder::RiuFemResultTextBuilder( RimGridView* di
|
||||
m_gridIndex = gridIndex;
|
||||
m_cellIndex = cellIndex;
|
||||
m_timeStepIndex = timeStepIndex;
|
||||
m_frameIndex = frameIndex;
|
||||
|
||||
m_intersectionPointInDisplay = cvf::Vec3d::UNDEFINED;
|
||||
m_face = cvf::StructGridInterface::NO_FACE;
|
||||
@@ -198,7 +200,13 @@ QString RiuFemResultTextBuilder::gridResultDetails()
|
||||
{
|
||||
RigGeoMechCaseData* eclipseCaseData = m_geomResDef->geoMechCase()->geoMechData();
|
||||
|
||||
this->appendTextFromResultColors( eclipseCaseData, m_gridIndex, m_cellIndex, m_timeStepIndex, m_geomResDef, &text );
|
||||
this->appendTextFromResultColors( eclipseCaseData,
|
||||
m_gridIndex,
|
||||
m_cellIndex,
|
||||
m_timeStepIndex,
|
||||
m_frameIndex,
|
||||
m_geomResDef,
|
||||
&text );
|
||||
|
||||
if ( !text.isEmpty() )
|
||||
{
|
||||
@@ -261,6 +269,7 @@ void RiuFemResultTextBuilder::appendTextFromResultColors( RigGeoMechCaseData*
|
||||
int gridIndex,
|
||||
int cellIndex,
|
||||
int timeStepIndex,
|
||||
int frameIndex,
|
||||
RimGeoMechResultDefinition* resultDefinition,
|
||||
QString* resultInfoText )
|
||||
{
|
||||
@@ -272,7 +281,7 @@ void RiuFemResultTextBuilder::appendTextFromResultColors( RigGeoMechCaseData*
|
||||
if ( resultDefinition->hasResult() )
|
||||
{
|
||||
const std::vector<float>& scalarResults =
|
||||
geomData->femPartResults()->resultValues( resultDefinition->resultAddress(), gridIndex, timeStepIndex );
|
||||
geomData->femPartResults()->resultValues( resultDefinition->resultAddress(), gridIndex, timeStepIndex, frameIndex );
|
||||
if ( scalarResults.size() )
|
||||
{
|
||||
caf::AppEnum<RigFemResultPosEnum> resPosAppEnum = resultDefinition->resultPositionType();
|
||||
@@ -399,8 +408,10 @@ QString RiuFemResultTextBuilder::closestNodeResultText( RimGeoMechResultDefiniti
|
||||
|
||||
RigGeoMechCaseData* geomData = m_geomResDef->geoMechCase()->geoMechData();
|
||||
|
||||
const std::vector<float>& scalarResults =
|
||||
geomData->femPartResults()->resultValues( resultColors->resultAddress(), m_gridIndex, m_timeStepIndex );
|
||||
const std::vector<float>& scalarResults = geomData->femPartResults()->resultValues( resultColors->resultAddress(),
|
||||
m_gridIndex,
|
||||
m_timeStepIndex,
|
||||
m_frameIndex );
|
||||
|
||||
if ( scalarResults.size() && m_displayCoordView )
|
||||
{
|
||||
@@ -441,7 +452,9 @@ QString RiuFemResultTextBuilder::closestNodeResultText( RimGeoMechResultDefiniti
|
||||
{
|
||||
RiuGeoMechXfTensorResultAccessor tensAccessor( geomData->femPartResults(),
|
||||
resultColors->resultAddress(),
|
||||
m_timeStepIndex );
|
||||
m_gridIndex,
|
||||
m_timeStepIndex,
|
||||
m_frameIndex );
|
||||
float tensValue = tensAccessor.calculateElmNodeValue( m_intersectionTriangle, closestElmNodResIdx );
|
||||
|
||||
text.append( QString( "Closest result: N[%1], in Element[%2] transformed onto intersection: %3 \n" )
|
||||
|
||||
@@ -48,7 +48,8 @@ public:
|
||||
RimGeoMechResultDefinition* geomResDef,
|
||||
int gridIndex,
|
||||
int cellIndex,
|
||||
int timeStepIndex );
|
||||
int timeStepIndex,
|
||||
int frameIndex );
|
||||
void setFace( int face );
|
||||
void setIntersectionPointInDisplay( cvf::Vec3d intersectionPointInDisplay );
|
||||
void setIntersectionTriangle( const std::array<cvf::Vec3f, 3>& triangle );
|
||||
@@ -70,6 +71,7 @@ private:
|
||||
int gridIndex,
|
||||
int cellIndex,
|
||||
int timeStepIndex,
|
||||
int frameIndex,
|
||||
RimGeoMechResultDefinition* resultDefinition,
|
||||
QString* resultInfoText );
|
||||
|
||||
@@ -81,6 +83,7 @@ private:
|
||||
int m_gridIndex;
|
||||
int m_cellIndex;
|
||||
int m_timeStepIndex;
|
||||
int m_frameIndex;
|
||||
|
||||
int m_face;
|
||||
bool m_isIntersectionTriangleSet;
|
||||
|
||||
@@ -156,28 +156,44 @@ void RiuFemTimeHistoryResultAccessor::computeTimeHistoryData()
|
||||
{
|
||||
int closestElmNodeResIndex = closestCalc.closestElementNodeResIdx();
|
||||
|
||||
for ( int frameIdx = 0; frameIdx < femPartResultsColl->frameCount(); frameIdx++ )
|
||||
const int timeSteps = femPartResultsColl->timeStepCount();
|
||||
for ( int stepIdx = 0; stepIdx < timeSteps; stepIdx++ )
|
||||
{
|
||||
RiuGeoMechXfTensorResultAccessor stressXfAccessor( femPartResultsColl, *m_femResultAddress, frameIdx );
|
||||
float scalarValue = stressXfAccessor.calculateElmNodeValue( m_intersectionTriangle, closestElmNodeResIndex );
|
||||
m_timeHistoryValues.push_back( scalarValue );
|
||||
const int frameCount = femPartResultsColl->frameCount( stepIdx );
|
||||
for ( int frameIdx = 0; frameIdx < frameCount; frameIdx++ )
|
||||
{
|
||||
RiuGeoMechXfTensorResultAccessor stressXfAccessor( femPartResultsColl,
|
||||
*m_femResultAddress,
|
||||
m_gridIndex,
|
||||
stepIdx,
|
||||
frameIdx );
|
||||
float scalarValue =
|
||||
stressXfAccessor.calculateElmNodeValue( m_intersectionTriangle, closestElmNodeResIndex );
|
||||
m_timeHistoryValues.push_back( scalarValue );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( scalarResultIndex < 0 ) return;
|
||||
|
||||
for ( int frameIdx = 0; frameIdx < femPartResultsColl->frameCount(); frameIdx++ )
|
||||
const int timeSteps = femPartResultsColl->timeStepCount();
|
||||
for ( int stepIdx = 0; stepIdx < timeSteps; stepIdx++ )
|
||||
{
|
||||
const std::vector<float>& scalarResults =
|
||||
m_geoMechCaseData->femPartResults()->resultValues( *m_femResultAddress,
|
||||
static_cast<int>( m_gridIndex ),
|
||||
frameIdx );
|
||||
if ( scalarResults.size() )
|
||||
const int frameCount = femPartResultsColl->frameCount( stepIdx );
|
||||
for ( int frameIdx = 0; frameIdx < frameCount; frameIdx++ )
|
||||
{
|
||||
float scalarValue = scalarResults[scalarResultIndex];
|
||||
const std::vector<float>& scalarResults =
|
||||
m_geoMechCaseData->femPartResults()->resultValues( *m_femResultAddress,
|
||||
static_cast<int>( m_gridIndex ),
|
||||
stepIdx,
|
||||
frameIdx );
|
||||
if ( scalarResults.size() )
|
||||
{
|
||||
float scalarValue = scalarResults[scalarResultIndex];
|
||||
|
||||
m_timeHistoryValues.push_back( scalarValue );
|
||||
m_timeHistoryValues.push_back( scalarValue );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,23 +93,25 @@ float RiuGeoMechXfTensorResultAccessor::PCRIT( const caf::Ten3f& t ) const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiuGeoMechXfTensorResultAccessor::RiuGeoMechXfTensorResultAccessor( RigFemPartResultsCollection* femResCollection,
|
||||
const RigFemResultAddress& resVarAddress,
|
||||
int timeStepIdx )
|
||||
int partIdx,
|
||||
int timeStepIdx,
|
||||
int frameIdx )
|
||||
{
|
||||
RigFemResultAddress tensComp = resVarAddress;
|
||||
tensComp.resultPosType = RIG_ELEMENT_NODAL;
|
||||
|
||||
tensComp.componentName = "S11";
|
||||
tens11 = &femResCollection->resultValues( tensComp, 0, timeStepIdx );
|
||||
tens11 = &femResCollection->resultValues( tensComp, partIdx, timeStepIdx, frameIdx );
|
||||
tensComp.componentName = "S22";
|
||||
tens22 = &femResCollection->resultValues( tensComp, 0, timeStepIdx );
|
||||
tens22 = &femResCollection->resultValues( tensComp, partIdx, timeStepIdx, frameIdx );
|
||||
tensComp.componentName = "S33";
|
||||
tens33 = &femResCollection->resultValues( tensComp, 0, timeStepIdx );
|
||||
tens33 = &femResCollection->resultValues( tensComp, partIdx, timeStepIdx, frameIdx );
|
||||
tensComp.componentName = "S12";
|
||||
tens12 = &femResCollection->resultValues( tensComp, 0, timeStepIdx );
|
||||
tens12 = &femResCollection->resultValues( tensComp, partIdx, timeStepIdx, frameIdx );
|
||||
tensComp.componentName = "S23";
|
||||
tens23 = &femResCollection->resultValues( tensComp, 0, timeStepIdx );
|
||||
tens23 = &femResCollection->resultValues( tensComp, partIdx, timeStepIdx, frameIdx );
|
||||
tensComp.componentName = "S13";
|
||||
tens13 = &femResCollection->resultValues( tensComp, 0, timeStepIdx );
|
||||
tens13 = &femResCollection->resultValues( tensComp, partIdx, timeStepIdx, frameIdx );
|
||||
|
||||
if ( resVarAddress.componentName == "SN" )
|
||||
{
|
||||
|
||||
@@ -32,7 +32,9 @@ class RiuGeoMechXfTensorResultAccessor
|
||||
public:
|
||||
RiuGeoMechXfTensorResultAccessor( RigFemPartResultsCollection* femResCollection,
|
||||
const RigFemResultAddress& resVarAddress,
|
||||
int timeStepIdx );
|
||||
int partIdx,
|
||||
int timeStepIdx,
|
||||
int frameIdx );
|
||||
|
||||
void calculateInterpolatedValue( const cvf::Vec3f triangle[3],
|
||||
const RivIntersectionVertexWeights vertexWeights[3],
|
||||
|
||||
@@ -116,6 +116,7 @@ void RiuMohrsCirclePlot::appendSelection( const RiuSelectionItem* selectionItem
|
||||
|
||||
addOrUpdateCurves( geoMechSelectionItem->m_resultDefinition,
|
||||
geoMechSelectionItem->m_timestepIdx,
|
||||
geoMechSelectionItem->m_frameIdx,
|
||||
gridIndex,
|
||||
cellIndex,
|
||||
cvf::Color3ub( color ) );
|
||||
@@ -164,13 +165,15 @@ void RiuMohrsCirclePlot::updateOnTimeStepChanged( Rim3dView* changedView )
|
||||
std::vector<MohrsCirclesInfo> mohrsCiclesInfosCopy = m_mohrsCiclesInfos;
|
||||
deletePlotItems();
|
||||
|
||||
RimGeoMechView* geomechView = dynamic_cast<RimGeoMechView*>( changedView );
|
||||
|
||||
if ( geomechView == nullptr ) return;
|
||||
|
||||
auto [stepIdx, frameIdx] = geomechView->currentStepAndDataFrame();
|
||||
|
||||
for ( const MohrsCirclesInfo& mohrInfo : mohrsCiclesInfosCopy )
|
||||
{
|
||||
addOrUpdateCurves( mohrInfo.geomResDef,
|
||||
changedView->currentTimeStep(),
|
||||
mohrInfo.gridIndex,
|
||||
mohrInfo.elmIndex,
|
||||
mohrInfo.color );
|
||||
addOrUpdateCurves( mohrInfo.geomResDef, stepIdx, frameIdx, mohrInfo.gridIndex, mohrInfo.elmIndex, mohrInfo.color );
|
||||
}
|
||||
|
||||
updatePlot();
|
||||
@@ -356,7 +359,8 @@ void RiuMohrsCirclePlot::deleteEnvelopes()
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RiuMohrsCirclePlot::addOrUpdateCurves( const RimGeoMechResultDefinition* geomResDef,
|
||||
size_t timeStepIndex,
|
||||
int timeStepIndex,
|
||||
int frameIndex,
|
||||
size_t gridIndex,
|
||||
size_t elmIndex,
|
||||
const cvf::Color3ub& color )
|
||||
@@ -371,7 +375,7 @@ bool RiuMohrsCirclePlot::addOrUpdateCurves( const RimGeoMechResultDefinition* ge
|
||||
|
||||
// TODO: All tensors are calculated every time this function is called. FIX
|
||||
|
||||
std::vector<caf::Ten3f> vertexTensors = resultCollection->tensors( address, 0, (int)timeStepIndex );
|
||||
std::vector<caf::Ten3f> vertexTensors = resultCollection->tensors( address, 0, timeStepIndex, frameIndex );
|
||||
if ( vertexTensors.empty() )
|
||||
{
|
||||
return false;
|
||||
|
||||
@@ -100,7 +100,8 @@ private:
|
||||
void deleteEnvelopes();
|
||||
|
||||
bool addOrUpdateCurves( const RimGeoMechResultDefinition* geomResDef,
|
||||
size_t timeStepIndex,
|
||||
int timeStepIndex,
|
||||
int frameIndex,
|
||||
size_t gridIndex,
|
||||
size_t elmIndex,
|
||||
const cvf::Color3ub& color );
|
||||
|
||||
@@ -391,7 +391,8 @@ void RiuSelectionChangedHandler::updateResultInfo( const RiuSelectionItem* itemA
|
||||
geomSelectionItem->m_resultDefinition,
|
||||
(int)geomSelectionItem->m_gridIndex,
|
||||
(int)geomSelectionItem->m_cellIndex,
|
||||
(int)geomSelectionItem->m_timestepIdx );
|
||||
(int)geomSelectionItem->m_timestepIdx,
|
||||
geomSelectionItem->m_frameIdx );
|
||||
|
||||
textBuilder.setIntersectionPointInDisplay( geomSelectionItem->m_localIntersectionPointInDisplay );
|
||||
textBuilder.setFace( geomSelectionItem->m_elementFace );
|
||||
|
||||
Reference in New Issue
Block a user