From a88191be33d05c174da926f22dbd503a213ec0b6 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Wed, 8 Jul 2020 15:45:50 +0200 Subject: [PATCH] #6169 Element property table: invalidate Geo Mech results on changes in table. --- .../GeoMechDataModel/RigFemPartResults.cpp | 8 +++++++ .../GeoMechDataModel/RigFemPartResults.h | 1 + .../RigFemPartResultsCollection.cpp | 11 ++++++++++ .../RigFemPartResultsCollection.h | 1 + .../ProjectDataModel/RimGeoMechCase.cpp | 21 ++++++++++++++++--- 5 files changed, 39 insertions(+), 3 deletions(-) diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResults.cpp b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResults.cpp index bad6468c26..bcb21778b0 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResults.cpp +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResults.cpp @@ -101,3 +101,11 @@ std::vector RigFemPartResults::loadedResults() const } return currentResults; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigFemPartResults::deleteAllScalarResults() +{ + resultSets.clear(); +} diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResults.h b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResults.h index bf727cd4ba..acfb148749 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResults.h +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResults.h @@ -42,6 +42,7 @@ public: RigFemScalarResultFrames* createScalarResult( const RigFemResultAddress& resVarAddr ); RigFemScalarResultFrames* findScalarResult( const RigFemResultAddress& resVarAddr ); void deleteScalarResult( const RigFemResultAddress& resVarAddr ); + void deleteAllScalarResults(); std::vector loadedResults() const; private: diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp index ef3b6bbc3c..c75a68cdce 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp @@ -599,6 +599,17 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::createScalarResult( int return m_femPartResults[partIndex]->createScalarResult( resVarAddr ); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigFemPartResultsCollection::deleteAllScalarResults() +{ + for ( cvf::ref results : m_femPartResults ) + { + results->deleteAllScalarResults(); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.h b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.h index 9538dd28b2..0d877fefbb 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.h +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.h @@ -147,6 +147,7 @@ public: RigFemScalarResultFrames* findOrLoadScalarResult( int partIndex, const RigFemResultAddress& resVarAddr ); RigFemScalarResultFrames* createScalarResult( int partIndex, const RigFemResultAddress& resVarAddr ); + void deleteAllScalarResults(); bool isValidBiotData( const std::vector& biotData, size_t elementCount ) const; static std::vector getStressComponentNames( bool includeShear = true ); diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp index 1db67c7946..4d73afa76c 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp @@ -609,6 +609,7 @@ void RimGeoMechCase::addElementPropertyFiles( const std::vector& if ( m_geoMechCaseData.notNull() ) { geoMechData()->femPartResults()->addElementPropertyFiles( newFileNames ); + geoMechData()->femPartResults()->deleteAllScalarResults(); } } @@ -747,9 +748,9 @@ void RimGeoMechCase::fieldChangedByUi( const caf::PdmFieldHandle* changedField, updateFormationNamesData(); } + RigGeoMechCaseData* rigCaseData = geoMechData(); if ( changedField == &m_cohesion || changedField == &m_frictionAngleDeg ) { - RigGeoMechCaseData* rigCaseData = geoMechData(); if ( rigCaseData && rigCaseData->femPartResults() ) { rigCaseData->femPartResults()->setCalculationParameters( m_cohesion(), @@ -761,7 +762,6 @@ void RimGeoMechCase::fieldChangedByUi( const caf::PdmFieldHandle* changedField, else if ( changedField == &m_biotFixedCoefficient || changedField == &m_biotCoefficientType || changedField == &m_biotResultAddress ) { - RigGeoMechCaseData* rigCaseData = geoMechData(); if ( rigCaseData && rigCaseData->femPartResults() ) { if ( m_biotCoefficientType() == RimGeoMechCase::BiotCoefficientType::BIOT_NONE ) @@ -810,7 +810,6 @@ void RimGeoMechCase::fieldChangedByUi( const caf::PdmFieldHandle* changedField, else if ( changedField == &m_initialPermeabilityFixed || changedField == &m_initialPermeabilityType || changedField == &m_initialPermeabilityResultAddress || changedField == &m_permeabilityExponent ) { - RigGeoMechCaseData* rigCaseData = geoMechData(); if ( rigCaseData && rigCaseData->femPartResults() ) { if ( m_initialPermeabilityType() == RimGeoMechCase::InitialPermeabilityType::INITIAL_PERMEABILITY_FIXED ) @@ -861,19 +860,34 @@ void RimGeoMechCase::fieldChangedByUi( const caf::PdmFieldHandle* changedField, { m_reloadElementPropertyFileCommand = false; reloadSelectedElementPropertyFiles(); + if ( rigCaseData && rigCaseData->femPartResults() ) + { + rigCaseData->femPartResults()->deleteAllScalarResults(); + } updateConnectedEditors(); + updateConnectedViews(); } else if ( changedField == &m_closeElementPropertyFileCommand ) { m_closeElementPropertyFileCommand = false; closeSelectedElementPropertyFiles(); + if ( rigCaseData && rigCaseData->femPartResults() ) + { + rigCaseData->femPartResults()->deleteAllScalarResults(); + } updateConnectedEditors(); + updateConnectedViews(); } else if ( changedField == &m_importElementPropertyFileCommand ) { m_importElementPropertyFileCommand = false; importElementPropertyFile(); + if ( rigCaseData && rigCaseData->femPartResults() ) + { + rigCaseData->femPartResults()->deleteAllScalarResults(); + } updateConnectedEditors(); + updateConnectedViews(); } } @@ -1002,6 +1016,7 @@ void RimGeoMechCase::closeSelectedElementPropertyFiles() if ( m_geoMechCaseData.notNull() ) { addressesToDelete = geoMechData()->femPartResults()->removeElementPropertyFiles( filesToClose ); + geoMechData()->femPartResults()->deleteAllScalarResults(); } for ( RimGeoMechView* view : geoMechViews() )