mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
GeoMech: show deformations in grid view (#8123)
Enable support in geomech view to show grid deformations
This commit is contained in:
@@ -61,9 +61,9 @@ RivFemPartGeometryGenerator::~RivFemPartGeometryGenerator()
|
||||
/// Generate surface drawable geo from the specified region
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
ref<DrawableGeo> RivFemPartGeometryGenerator::generateSurface()
|
||||
ref<DrawableGeo> RivFemPartGeometryGenerator::generateSurface( const std::vector<cvf::Vec3f>& nodeCoordinates )
|
||||
{
|
||||
computeArrays();
|
||||
computeArrays( nodeCoordinates );
|
||||
|
||||
CVF_ASSERT( m_quadVertices.notNull() );
|
||||
|
||||
@@ -126,7 +126,7 @@ ref<DrawableGeo> RivFemPartGeometryGenerator::createOutlineMeshDrawable( double
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivFemPartGeometryGenerator::computeArrays()
|
||||
void RivFemPartGeometryGenerator::computeArrays( const std::vector<cvf::Vec3f>& nodeCoordinates )
|
||||
{
|
||||
std::vector<Vec3f> vertices;
|
||||
std::vector<int>& trianglesToElements = m_triangleMapper->triangleToElmIndexMap();
|
||||
@@ -148,8 +148,6 @@ void RivFemPartGeometryGenerator::computeArrays()
|
||||
trianglesToElements.reserve( estimatedQuadVxCount / 2 );
|
||||
trianglesToElementFaces.reserve( estimatedQuadVxCount / 2 );
|
||||
|
||||
const std::vector<cvf::Vec3f>& nodeCoordinates = m_part->nodes().coordinates;
|
||||
|
||||
#pragma omp parallel for schedule( dynamic )
|
||||
for ( int elmIdx = 0; elmIdx < static_cast<int>( m_part->elementCount() ); elmIdx++ )
|
||||
{
|
||||
|
||||
@@ -21,10 +21,13 @@
|
||||
|
||||
#include "cvfArray.h"
|
||||
#include "cvfObject.h"
|
||||
#include "cvfVector3.h"
|
||||
|
||||
#include "RigFemPart.h"
|
||||
#include "cvfStructGrid.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace cvf
|
||||
{
|
||||
class DrawableGeo;
|
||||
@@ -77,7 +80,7 @@ public:
|
||||
|
||||
// Generated geometry
|
||||
|
||||
cvf::ref<cvf::DrawableGeo> generateSurface();
|
||||
cvf::ref<cvf::DrawableGeo> generateSurface( const std::vector<cvf::Vec3f>& nodeCoordinates );
|
||||
cvf::ref<cvf::DrawableGeo> createMeshDrawable();
|
||||
cvf::ref<cvf::DrawableGeo> createOutlineMeshDrawable( double creaseAngle );
|
||||
|
||||
@@ -96,7 +99,7 @@ public:
|
||||
const cvf::Vec3d& displayModelOffset );
|
||||
|
||||
private:
|
||||
void computeArrays();
|
||||
void computeArrays( const std::vector<cvf::Vec3f>& nodeCoordinates );
|
||||
|
||||
private:
|
||||
// Input
|
||||
@@ -106,11 +109,10 @@ private:
|
||||
|
||||
// Created arrays
|
||||
cvf::ref<cvf::Vec3fArray> m_quadVertices;
|
||||
// cvf::ref<cvf::Vec3fArray> m_triangleVertices; // If needed, we will do it like this, I think
|
||||
std::vector<size_t> m_quadVerticesToNodeIdx;
|
||||
std::vector<size_t> m_quadVerticesToGlobalElmNodeIdx;
|
||||
std::vector<size_t> m_quadVerticesToGlobalElmFaceNodeIdx;
|
||||
std::vector<size_t> m_quadVerticesToGlobalElmIdx;
|
||||
std::vector<size_t> m_quadVerticesToNodeIdx;
|
||||
std::vector<size_t> m_quadVerticesToGlobalElmNodeIdx;
|
||||
std::vector<size_t> m_quadVerticesToGlobalElmFaceNodeIdx;
|
||||
std::vector<size_t> m_quadVerticesToGlobalElmIdx;
|
||||
|
||||
// Mappings
|
||||
cvf::ref<RivFemPartTriangleToElmMapper> m_triangleMapper;
|
||||
|
||||
@@ -19,12 +19,15 @@
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
#include "RivFemPartPartMgr.h"
|
||||
|
||||
#include "RivGeoMechPartMgr.h"
|
||||
|
||||
#include "RiaPreferences.h"
|
||||
|
||||
#include "RifGeoMechReaderInterface.h"
|
||||
|
||||
#include "RigFemPart.h"
|
||||
#include "RigFemPartResultsCollection.h"
|
||||
#include "RigFemScalarResultFrames.h"
|
||||
#include "RigGeoMechCaseData.h"
|
||||
@@ -103,6 +106,33 @@ void RivFemPartPartMgr::setCellVisibility( cvf::UByteArray* cellVisibilities )
|
||||
generatePartGeometry( m_surfaceGenerator );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivFemPartPartMgr::setDisplacements( bool useDisplacements,
|
||||
double scalingFactor,
|
||||
const std::vector<cvf::Vec3f>& displacements )
|
||||
{
|
||||
size_t nodeCount = m_part->nodes().coordinates.size();
|
||||
m_displacedNodeCoordinates.resize( nodeCount );
|
||||
const auto coords = m_part->nodes().coordinates;
|
||||
|
||||
if ( useDisplacements )
|
||||
{
|
||||
for ( size_t i = 0; i < nodeCount; i++ )
|
||||
{
|
||||
m_displacedNodeCoordinates[i] = coords[i] + displacements[i] * scalingFactor;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for ( size_t i = 0; i < nodeCount; i++ )
|
||||
{
|
||||
m_displacedNodeCoordinates[i] = coords[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -113,7 +143,7 @@ void RivFemPartPartMgr::generatePartGeometry( RivFemPartGeometryGenerator& geoBu
|
||||
{
|
||||
m_surfaceFaces = nullptr; // To possibly free memory before adding the new stuff
|
||||
|
||||
cvf::ref<cvf::DrawableGeo> geo = geoBuilder.generateSurface();
|
||||
cvf::ref<cvf::DrawableGeo> geo = geoBuilder.generateSurface( m_displacedNodeCoordinates );
|
||||
if ( geo.notNull() )
|
||||
{
|
||||
geo->computeNormals();
|
||||
|
||||
@@ -20,9 +20,12 @@
|
||||
#pragma once
|
||||
|
||||
#include "cvfObject.h"
|
||||
#include "cvfVector3.h"
|
||||
|
||||
#include "RivFemPartGeometryGenerator.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace cvf
|
||||
{
|
||||
class StructGridInterface;
|
||||
@@ -46,12 +49,14 @@ class RigFemPart;
|
||||
class RivFemPartPartMgr : public cvf::Object
|
||||
{
|
||||
public:
|
||||
explicit RivFemPartPartMgr( const RigFemPart* femPart, cvf::Vec3d displayOffset );
|
||||
explicit RivFemPartPartMgr( const RigFemPart* part, cvf::Vec3d displayOffset );
|
||||
~RivFemPartPartMgr() override;
|
||||
void setTransform( cvf::Transform* scaleTransform );
|
||||
void setCellVisibility( cvf::UByteArray* cellVisibilities );
|
||||
cvf::ref<cvf::UByteArray> cellVisibility() { return m_cellVisibility; }
|
||||
|
||||
void setDisplacements( bool useDisplacements, double scalingFactor, const std::vector<cvf::Vec3f>& displacements );
|
||||
|
||||
void updateCellColor( cvf::Color4f color );
|
||||
void updateCellResultColor( size_t timeStepIndex, RimGeoMechCellColors* cellResultColors );
|
||||
|
||||
@@ -66,6 +71,8 @@ private:
|
||||
int m_partIdx;
|
||||
cvf::cref<RigFemPart> m_part;
|
||||
|
||||
std::vector<cvf::Vec3f> m_displacedNodeCoordinates;
|
||||
|
||||
cvf::ref<cvf::Transform> m_scaleTransform;
|
||||
float m_opacityLevel;
|
||||
cvf::Color3f m_defaultColor;
|
||||
|
||||
@@ -18,13 +18,16 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RivGeoMechPartMgr.h"
|
||||
#include "cvfModelBasicList.h"
|
||||
#include "cvfPart.h"
|
||||
#include <cstdlib>
|
||||
|
||||
#include "RigFemPartCollection.h"
|
||||
#include "RigGeoMechCaseData.h"
|
||||
|
||||
#include "RimGeoMechPartCollection.h"
|
||||
|
||||
#include "cvfModelBasicList.h"
|
||||
#include "cvfPart.h"
|
||||
#include <cstdlib>
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -59,6 +62,17 @@ void RivGeoMechPartMgr::clearAndSetReservoir( const RigGeoMechCaseData* geoMechC
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivGeoMechPartMgr::updateDisplacements( const RimGeoMechPartCollection* parts, bool showDisplacements, double scaleFactor )
|
||||
{
|
||||
for ( size_t i = 0; i < m_femPartPartMgrs.size(); i++ )
|
||||
{
|
||||
m_femPartPartMgrs[i]->setDisplacements( showDisplacements, scaleFactor, parts->displacements( (int)i ) );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -33,6 +33,7 @@ class Transform;
|
||||
class RimGeoMechCellColors;
|
||||
class RigGeoMechCaseData;
|
||||
class RimGeoMechView;
|
||||
class RimGeoMechPartCollection;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
@@ -51,6 +52,7 @@ public:
|
||||
void clearAndSetReservoir( const RigGeoMechCaseData* geoMechCase );
|
||||
void setTransform( cvf::Transform* scaleTransform );
|
||||
void setCellVisibility( size_t partIndex, cvf::UByteArray* cellVisibilities );
|
||||
void updateDisplacements( const RimGeoMechPartCollection* parts, bool showDisplacements, double scaleFactor );
|
||||
|
||||
cvf::ref<cvf::UByteArray> cellVisibility( size_t partIndex );
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "RimCellFilterCollection.h"
|
||||
#include "RimGeoMechCase.h"
|
||||
#include "RimGeoMechCellColors.h"
|
||||
#include "RimGeoMechPartCollection.h"
|
||||
#include "RimGeoMechPropertyFilterCollection.h"
|
||||
#include "RimGeoMechView.h"
|
||||
#include "RimViewController.h"
|
||||
@@ -126,6 +127,21 @@ void RivGeoMechVizLogic::scheduleGeometryRegen( RivCellSetEnum geometryType )
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivGeoMechVizLogic::scheduleGeometryRegenOfVisiblePartMgrs( int timeStepIndex )
|
||||
{
|
||||
std::vector<RivGeoMechPartMgrCache::Key> visiblePartMgrs = keysToVisiblePartMgrs( timeStepIndex );
|
||||
for ( size_t pmIdx = 0; pmIdx < visiblePartMgrs.size(); ++pmIdx )
|
||||
{
|
||||
m_partMgrCache->scheduleRegeneration( visiblePartMgrs[pmIdx] );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivGeoMechVizLogic::scheduleRegenOfDirectlyDependentGeometry( RivCellSetEnum geometryType )
|
||||
{
|
||||
if ( geometryType == RANGE_FILTERED )
|
||||
@@ -202,6 +218,10 @@ RivGeoMechPartMgr* RivGeoMechVizLogic::getUpdatedPartMgr( RivGeoMechPartMgrCache
|
||||
partMgrToUpdate->clearAndSetReservoir( caseData );
|
||||
}
|
||||
|
||||
partMgrToUpdate->updateDisplacements( m_geomechView->partsCollection(),
|
||||
m_geomechView->showDisplacements(),
|
||||
m_geomechView->displacementScaleFactor() );
|
||||
|
||||
partMgrToUpdate->setTransform( m_geomechView->scaleTransform() );
|
||||
|
||||
for ( int femPartIdx = 0; femPartIdx < partCount; ++femPartIdx )
|
||||
@@ -266,12 +286,11 @@ void RivGeoMechVizLogic::calculateCurrentTotalCellVisibility( cvf::UByteArray* t
|
||||
{
|
||||
if ( !m_geomechView->geoMechCase() ) return;
|
||||
|
||||
size_t gridCount = m_geomechView->femParts()->partCount();
|
||||
|
||||
if ( gridCount == 0 ) return;
|
||||
int partCount = m_geomechView->femParts()->partCount();
|
||||
if ( partCount == 0 ) return;
|
||||
|
||||
int elmCount = 0;
|
||||
for ( int i = 0; i < m_geomechView->femParts()->partCount(); i++ )
|
||||
for ( int i = 0; i < partCount; i++ )
|
||||
{
|
||||
RigFemPart* part = m_geomechView->femParts()->part( i );
|
||||
elmCount += part->elementCount();
|
||||
@@ -287,7 +306,7 @@ void RivGeoMechVizLogic::calculateCurrentTotalCellVisibility( cvf::UByteArray* t
|
||||
if ( partMgr )
|
||||
{
|
||||
int elmOffset = 0;
|
||||
for ( int i = 0; i < m_geomechView->femParts()->partCount(); i++ )
|
||||
for ( int i = 0; i < partCount; i++ )
|
||||
{
|
||||
RigFemPart* part = m_geomechView->femParts()->part( i );
|
||||
|
||||
|
||||
@@ -47,6 +47,7 @@ public:
|
||||
void updateCellResultColor( int timeStepIndex, RimGeoMechCellColors* cellResultColors );
|
||||
void updateStaticCellColors( int timeStepIndex );
|
||||
void scheduleGeometryRegen( RivCellSetEnum geometryType );
|
||||
void scheduleGeometryRegenOfVisiblePartMgrs( int timeStepIndex );
|
||||
void calculateCurrentTotalCellVisibility( cvf::UByteArray* totalVisibility, int timeStepIndex );
|
||||
std::vector<RivGeoMechPartMgrCache::Key> keysToVisiblePartMgrs( int timeStepIndex ) const;
|
||||
const cvf::ref<RivGeoMechPartMgrCache> partMgrCache() const;
|
||||
|
||||
Reference in New Issue
Block a user