mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Grid Calculator: Fix view updates when calculation is changed or removed.
This commit is contained in:
parent
fdefb214d8
commit
b761bb42af
@ -56,6 +56,7 @@
|
||||
#include "RimGeoMechCellColors.h"
|
||||
#include "RimGeoMechModels.h"
|
||||
#include "RimGeoMechView.h"
|
||||
#include "RimGridCalculationCollection.h"
|
||||
#include "RimIdenticalGridCaseGroup.h"
|
||||
#include "RimMainPlotCollection.h"
|
||||
#include "RimObservedDataCollection.h"
|
||||
@ -647,6 +648,11 @@ bool RiaApplication::loadProject( const QString& projectFileName,
|
||||
}
|
||||
}
|
||||
|
||||
for ( auto gridCalculation : m_project->gridCalculationCollection()->calculations() )
|
||||
{
|
||||
gridCalculation->calculate();
|
||||
}
|
||||
|
||||
if ( m_project->viewLinkerCollection() && m_project->viewLinkerCollection()->viewLinker() )
|
||||
{
|
||||
m_project->viewLinkerCollection()->viewLinker()->updateOverrides();
|
||||
|
@ -18,7 +18,11 @@
|
||||
|
||||
#include "RimGridCalculation.h"
|
||||
|
||||
#include "RiaDefines.h"
|
||||
#include "RimEclipseCase.h"
|
||||
#include "RimEclipseCellColors.h"
|
||||
#include "RimEclipseView.h"
|
||||
#include "RimReloadCaseTools.h"
|
||||
|
||||
#include "RiaLogging.h"
|
||||
#include "RiaPorosityModel.h"
|
||||
@ -122,6 +126,9 @@ bool RimGridCalculation::calculate()
|
||||
{
|
||||
eclipseCase->results( porosityModel )->createResultEntry( resAddr, true );
|
||||
}
|
||||
|
||||
eclipseCase->results( porosityModel )->clearScalarResult( resAddr );
|
||||
|
||||
std::vector<std::vector<double>>* scalarResultFrames =
|
||||
eclipseCase->results( porosityModel )->modifiableCellScalarResultTimesteps( resAddr );
|
||||
size_t timeStepCount = eclipseCase->results( porosityModel )->maxTimeStepCount();
|
||||
@ -143,36 +150,61 @@ bool RimGridCalculation::calculate()
|
||||
return evaluatedOk;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimEclipseCase* RimGridCalculation::findEclipseCaseFromVariables()
|
||||
{
|
||||
RimEclipseCase* eclipseCase = nullptr;
|
||||
for ( size_t i = 0; i < m_variables.size(); i++ )
|
||||
{
|
||||
RimGridCalculationVariable* v = dynamic_cast<RimGridCalculationVariable*>( m_variables[i] );
|
||||
if ( v->eclipseCase() ) eclipseCase = v->eclipseCase();
|
||||
}
|
||||
|
||||
return eclipseCase;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGridCalculation::updateDependentObjects()
|
||||
{
|
||||
// RimGridCalculationCollection* calcColl = nullptr;
|
||||
// this->firstAncestorOrThisOfTypeAsserted( calcColl );
|
||||
// calcColl->rebuildCaseMetaData();
|
||||
|
||||
// RimGridMultiPlotCollection* summaryPlotCollection = RiaGridTools::summaryMultiPlotCollection();
|
||||
// for ( auto multiPlot : summaryPlotCollection->multiPlots() )
|
||||
// {
|
||||
// for ( RimGridPlot* sumPlot : multiPlot->summaryPlots() )
|
||||
// {
|
||||
// bool plotContainsCalculatedCurves = false;
|
||||
|
||||
// for ( RimGridCurve* sumCurve : sumPlot->summaryCurves() )
|
||||
// {
|
||||
// if ( sumCurve->summaryAddressY().category() == RifEclipseGridAddress::SUMMARY_CALCULATED )
|
||||
// {
|
||||
// sumCurve->updateConnectedEditors();
|
||||
|
||||
// plotContainsCalculatedCurves = true;
|
||||
// }
|
||||
// }
|
||||
|
||||
// if ( plotContainsCalculatedCurves )
|
||||
// {
|
||||
// sumPlot->loadDataAndUpdate();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
RimEclipseCase* eclipseCase = findEclipseCaseFromVariables();
|
||||
if ( eclipseCase )
|
||||
{
|
||||
RimReloadCaseTools::updateAll3dViews( eclipseCase );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGridCalculation::removeDependentObjects()
|
||||
{
|
||||
QString leftHandSideVariableName = RimGridCalculation::findLeftHandSide( m_expression );
|
||||
|
||||
auto porosityModel = RiaDefines::PorosityModelType::MATRIX_MODEL;
|
||||
|
||||
RigEclipseResultAddress resAddr( RiaDefines::ResultCatType::GENERATED, leftHandSideVariableName );
|
||||
|
||||
RimEclipseCase* eclipseCase = findEclipseCaseFromVariables();
|
||||
if ( eclipseCase )
|
||||
{
|
||||
// Select default result if
|
||||
for ( auto v : eclipseCase->reservoirViews() )
|
||||
{
|
||||
if ( v->cellResult()->resultType() == resAddr.resultCatType() &&
|
||||
v->cellResult()->resultVariable() == resAddr.resultName() )
|
||||
{
|
||||
v->cellResult()->setResultType( RiaDefines::ResultCatType::DYNAMIC_NATIVE );
|
||||
v->cellResult()->setResultVariable( "SOIL" );
|
||||
}
|
||||
}
|
||||
|
||||
eclipseCase->results( porosityModel )->clearScalarResult( resAddr );
|
||||
eclipseCase->results( porosityModel )->eraseGeneratedResult( resAddr );
|
||||
|
||||
RimReloadCaseTools::updateAll3dViews( eclipseCase );
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,8 @@
|
||||
#include "RimGridCalculationVariable.h"
|
||||
#include "RimUserDefinedCalculation.h"
|
||||
|
||||
class RimEclipseCase;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
///
|
||||
@ -34,7 +36,10 @@ public:
|
||||
|
||||
bool calculate() override;
|
||||
void updateDependentObjects() override;
|
||||
void removeDependentObjects() override;
|
||||
|
||||
protected:
|
||||
RimGridCalculationVariable* createVariable() const override;
|
||||
|
||||
RimEclipseCase* findEclipseCaseFromVariables();
|
||||
};
|
||||
|
@ -33,9 +33,10 @@ public:
|
||||
// Reload grid data, but not summary
|
||||
static void reloadAllEclipseGridData( RimEclipseCase* eclipseCase );
|
||||
|
||||
static void updateAll3dViews( RimEclipseCase* eclipseCase );
|
||||
|
||||
private:
|
||||
static void reloadAllEclipseData( RimEclipseCase* eclipseCase, bool reloadSummaryData );
|
||||
static void clearAllGridData( RigEclipseCaseData* eclipseCaseData );
|
||||
static void updateAll3dViews( RimEclipseCase* eclipseCase );
|
||||
static void updateAllPlots();
|
||||
};
|
||||
|
@ -190,3 +190,10 @@ void RimSummaryCalculation::updateDependentObjects()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryCalculation::removeDependentObjects()
|
||||
{
|
||||
}
|
||||
|
@ -46,6 +46,7 @@ public:
|
||||
|
||||
bool calculate() override;
|
||||
void updateDependentObjects() override;
|
||||
void removeDependentObjects() override;
|
||||
|
||||
protected:
|
||||
RimSummaryCalculationVariable* createVariable() const override;
|
||||
|
@ -64,6 +64,7 @@ public:
|
||||
bool parseExpression();
|
||||
virtual bool calculate() = 0;
|
||||
virtual void updateDependentObjects() = 0;
|
||||
virtual void removeDependentObjects() = 0;
|
||||
|
||||
caf::PdmFieldHandle* userDescriptionField() override;
|
||||
|
||||
|
@ -102,6 +102,7 @@ RimUserDefinedCalculation*
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimUserDefinedCalculationCollection::deleteCalculation( RimUserDefinedCalculation* calculation )
|
||||
{
|
||||
calculation->removeDependentObjects();
|
||||
m_calculations.removeChildObject( calculation );
|
||||
|
||||
rebuildCaseMetaData();
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "RigCaseCellResultsData.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
#include "RiaDefines.h"
|
||||
#include "RiaEclipseUnitTools.h"
|
||||
#include "RiaLogging.h"
|
||||
|
||||
@ -42,6 +43,7 @@
|
||||
|
||||
#include "RifReaderEclipseOutput.h"
|
||||
|
||||
#include "cafAssert.h"
|
||||
#include "cafProgressInfo.h"
|
||||
#include "cvfGeometryTools.h"
|
||||
|
||||
@ -907,6 +909,23 @@ void RigCaseCellResultsData::eraseAllSourSimData()
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RigCaseCellResultsData::eraseGeneratedResult( const RigEclipseResultAddress& resultAddress )
|
||||
{
|
||||
CAF_ASSERT( resultAddress.resultCatType() == RiaDefines::ResultCatType::GENERATED );
|
||||
|
||||
for ( auto& it : m_resultInfos )
|
||||
{
|
||||
if ( it.resultType() == RiaDefines::ResultCatType::GENERATED && it.resultName() == resultAddress.resultName() )
|
||||
{
|
||||
it.setResultType( RiaDefines::ResultCatType::REMOVED );
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -120,6 +120,7 @@ public:
|
||||
void clearAllResults();
|
||||
void freeAllocatedResultsData();
|
||||
void eraseAllSourSimData();
|
||||
void eraseGeneratedResult( const RigEclipseResultAddress& resultAddress );
|
||||
|
||||
QStringList resultNames( RiaDefines::ResultCatType type ) const;
|
||||
std::vector<RigEclipseResultAddress> existingResults() const;
|
||||
|
Loading…
Reference in New Issue
Block a user