Merge pull request #8168 from OPM/intersection_displacement

GeoMech: Support showing displacements on intersections, too
This commit is contained in:
jonjenssen
2021-10-20 01:41:14 +02:00
committed by GitHub
parent 3fa59a9fc3
commit 059f30236b
8 changed files with 61 additions and 21 deletions

View File

@@ -21,11 +21,14 @@
#include "RigFemPart.h" #include "RigFemPart.h"
#include "RigFemPartCollection.h" #include "RigFemPartCollection.h"
#include "RimGeoMechPartCollection.h"
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RivFemIntersectionGrid::RivFemIntersectionGrid( const RigFemPartCollection* femParts ) RivFemIntersectionGrid::RivFemIntersectionGrid( const RigFemPartCollection* femParts, const RimGeoMechPartCollection* parts )
: m_femParts( femParts ) : m_femParts( femParts )
, m_parts( parts )
{ {
} }
@@ -83,14 +86,29 @@ void RivFemIntersectionGrid::cellCornerVertices( size_t globalCellIndex, cvf::Ve
{ {
auto [part, elementIdx] = m_femParts->partAndElementIndex( globalCellIndex ); auto [part, elementIdx] = m_femParts->partAndElementIndex( globalCellIndex );
const bool useDisplacements = m_parts->isDisplacementsUsed();
const std::vector<cvf::Vec3f>& nodeCoords = part->nodes().coordinates; const std::vector<cvf::Vec3f>& nodeCoords = part->nodes().coordinates;
const int* cornerIndices = part->connectivities( elementIdx ); const int* cornerIndices = part->connectivities( elementIdx );
if ( useDisplacements )
{
const double scaleFactor = m_parts->currentDisplacementScaleFactor();
const std::vector<cvf::Vec3f>& displacements = m_parts->displacements( part->elementPartId() );
for ( int i = 0; i < 8; i++ )
{
const int idx = cornerIndices[i];
cellCorners[i] = cvf::Vec3d( nodeCoords[idx] + displacements[idx] * scaleFactor );
}
}
else
{
for ( int i = 0; i < 8; i++ ) for ( int i = 0; i < 8; i++ )
{ {
cellCorners[i] = cvf::Vec3d( nodeCoords[cornerIndices[i]] ); cellCorners[i] = cvf::Vec3d( nodeCoords[cornerIndices[i]] );
} }
} }
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///

View File

@@ -31,11 +31,12 @@
class RigFemPart; class RigFemPart;
class RigFemPartCollection; class RigFemPartCollection;
class RigFault; class RigFault;
class RimGeoMechPartCollection;
class RivFemIntersectionGrid : public RivIntersectionHexGridInterface class RivFemIntersectionGrid : public RivIntersectionHexGridInterface
{ {
public: public:
explicit RivFemIntersectionGrid( const RigFemPartCollection* femParts ); explicit RivFemIntersectionGrid( const RigFemPartCollection* femParts, const RimGeoMechPartCollection* parts );
cvf::Vec3d displayOffset() const override; cvf::Vec3d displayOffset() const override;
cvf::BoundingBox boundingBox() const override; cvf::BoundingBox boundingBox() const override;
@@ -49,4 +50,5 @@ public:
private: private:
cvf::cref<RigFemPartCollection> m_femParts; cvf::cref<RigFemPartCollection> m_femParts;
const RimGeoMechPartCollection* m_parts;
}; };

View File

@@ -91,7 +91,7 @@ void RimGeoMechPart::setDisplacements( const std::vector<cvf::Vec3f>& displaceme
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
const std::vector<cvf::Vec3f> RimGeoMechPart::displacements() const const std::vector<cvf::Vec3f>& RimGeoMechPart::displacements() const
{ {
return m_displacements; return m_displacements;
} }

View File

@@ -39,7 +39,7 @@ public:
int partId() const; int partId() const;
void setDisplacements( const std::vector<cvf::Vec3f>& displacements ); void setDisplacements( const std::vector<cvf::Vec3f>& displacements );
const std::vector<cvf::Vec3f> displacements() const; const std::vector<cvf::Vec3f>& displacements() const;
protected: protected:
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;

View File

@@ -39,6 +39,7 @@ RimGeoMechPartCollection::RimGeoMechPartCollection()
, m_currentDisplacementTimeStep( -1 ) , m_currentDisplacementTimeStep( -1 )
, m_displacementsUsed( false ) , m_displacementsUsed( false )
, m_currentScaleFactor( 1.0 ) , m_currentScaleFactor( 1.0 )
, m_noDisplacements()
{ {
CAF_PDM_InitScriptableObject( "Parts", ":/GeoMechCase24x24.png", "", "" ); CAF_PDM_InitScriptableObject( "Parts", ":/GeoMechCase24x24.png", "", "" );
@@ -145,12 +146,20 @@ int RimGeoMechPartCollection::currentDisplacementTimeStep() const
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
const std::vector<cvf::Vec3f> RimGeoMechPartCollection::displacements( int partId ) const double RimGeoMechPartCollection::currentDisplacementScaleFactor() const
{
return m_currentScaleFactor;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const std::vector<cvf::Vec3f>& RimGeoMechPartCollection::displacements( int partId ) const
{ {
RimGeoMechPart* thepart = part( partId ); RimGeoMechPart* thepart = part( partId );
if ( thepart ) return thepart->displacements(); if ( thepart ) return thepart->displacements();
return std::vector<cvf::Vec3f>(); return m_noDisplacements;
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@@ -44,11 +44,12 @@ public:
bool isPartEnabled( int partId ) const; bool isPartEnabled( int partId ) const;
const std::vector<cvf::Vec3f> displacements( int partId ) const; const std::vector<cvf::Vec3f>& displacements( int partId ) const;
void setCurrentDisplacementSettings( int currentTimeStep, bool showDisplacement, double scaleFactor ); void setCurrentDisplacementSettings( int currentTimeStep, bool showDisplacement, double scaleFactor );
bool isDisplacementsUsed() const; bool isDisplacementsUsed() const;
int currentDisplacementTimeStep() const; int currentDisplacementTimeStep() const;
double currentDisplacementScaleFactor() const;
std::vector<RimGeoMechPart*> parts() const; std::vector<RimGeoMechPart*> parts() const;
@@ -61,4 +62,6 @@ private:
int m_currentDisplacementTimeStep; int m_currentDisplacementTimeStep;
double m_currentScaleFactor; double m_currentScaleFactor;
bool m_displacementsUsed; bool m_displacementsUsed;
std::vector<cvf::Vec3f> m_noDisplacements;
}; };

View File

@@ -434,14 +434,21 @@ void RimGeoMechView::onUpdateDisplayModelForCurrentTimeStep()
} }
} }
if ( this->cellResult()->hasResult() ) bool hasGeneralCellResult = this->cellResult()->hasResult();
if ( hasGeneralCellResult )
m_vizLogic->updateCellResultColor( m_currentTimeStep(), this->cellResult() ); m_vizLogic->updateCellResultColor( m_currentTimeStep(), this->cellResult() );
else else
m_vizLogic->updateStaticCellColors( m_currentTimeStep() ); m_vizLogic->updateStaticCellColors( m_currentTimeStep() );
bool hasGeneralCellResult = this->cellResult()->hasResult(); // Intersections
{
m_intersectionVizModel->removeAllParts();
m_intersectionCollection->rebuildGeometry();
m_intersectionCollection->appendPartsToModel( *this, m_intersectionVizModel.p(), scaleTransform() );
m_intersectionCollection->updateCellResultColor( hasGeneralCellResult, m_currentTimeStep ); m_intersectionCollection->updateCellResultColor( hasGeneralCellResult, m_currentTimeStep );
}
if ( m_surfaceCollection ) if ( m_surfaceCollection )
{ {
m_surfaceCollection->updateCellResultColor( hasGeneralCellResult, m_currentTimeStep ); m_surfaceCollection->updateCellResultColor( hasGeneralCellResult, m_currentTimeStep );

View File

@@ -185,6 +185,9 @@ void RimIntersection::updateDefaultSeparateDataSource()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
cvf::ref<RivIntersectionHexGridInterface> RimIntersection::createHexGridInterface() cvf::ref<RivIntersectionHexGridInterface> RimIntersection::createHexGridInterface()
{ {
RimGeoMechView* geoView;
this->firstAncestorOrThisOfType( geoView );
RimIntersectionResultDefinition* resDef = activeSeparateResultDefinition(); RimIntersectionResultDefinition* resDef = activeSeparateResultDefinition();
if ( resDef && resDef->activeCase() ) if ( resDef && resDef->activeCase() )
{ {
@@ -203,9 +206,9 @@ cvf::ref<RivIntersectionHexGridInterface> RimIntersection::createHexGridInterfac
auto* geomCase = dynamic_cast<RimGeoMechCase*>( resDef->activeCase() ); auto* geomCase = dynamic_cast<RimGeoMechCase*>( resDef->activeCase() );
if ( geomCase && geomCase->geoMechData() && geomCase->geoMechData()->femParts() ) if ( geomCase && geomCase->geoMechData() && geomCase->geoMechData()->femParts() && geoView )
{ {
return new RivFemIntersectionGrid( geomCase->geoMechData()->femParts() ); return new RivFemIntersectionGrid( geomCase->geoMechData()->femParts(), geoView->partsCollection() );
} }
} }
@@ -218,11 +221,9 @@ cvf::ref<RivIntersectionHexGridInterface> RimIntersection::createHexGridInterfac
return new RivEclipseIntersectionGrid( grid, eclipseView->currentActiveCellInfo(), this->isInactiveCellsVisible() ); return new RivEclipseIntersectionGrid( grid, eclipseView->currentActiveCellInfo(), this->isInactiveCellsVisible() );
} }
RimGeoMechView* geoView;
this->firstAncestorOrThisOfType( geoView );
if ( geoView && geoView->femParts() ) if ( geoView && geoView->femParts() )
{ {
return new RivFemIntersectionGrid( geoView->femParts() ); return new RivFemIntersectionGrid( geoView->femParts(), geoView->partsCollection() );
} }
return nullptr; return nullptr;