From 337ad4d356cf773cb22cced2e58992759a01c258 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Mon, 11 Sep 2017 11:03:05 +0200 Subject: [PATCH] #1693 Remove and move stuff away from RimReservoirCellResultsStorage To make its sole responsibility to store/restore generated results to/from cache file --- .../ProjectDataModel/RimEclipseCase.cpp | 6 +-- .../ProjectDataModel/RimEclipseInputCase.cpp | 8 ++-- .../ProjectDataModel/RimEclipseResultCase.cpp | 14 ++---- .../RimReservoirCellResultsStorage.cpp | 47 +------------------ .../RimReservoirCellResultsStorage.h | 12 ----- .../ProjectDataModel/RimTimeStepFilter.cpp | 7 +-- .../ProjectDataModel/RimTimeStepFilter.h | 2 +- .../RigCaseCellResultsData.cpp | 38 +++++++++++++-- .../RigCaseCellResultsData.h | 4 +- 9 files changed, 50 insertions(+), 88 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp b/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp index 4100aaa8e0..244785f95f 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp @@ -258,7 +258,7 @@ RimEclipseView* RimEclipseCase::createCopyAndAddView(const RimEclipseView* sourc //-------------------------------------------------------------------------------------------------- void RimEclipseCase::recalculateCompletionTypeAndRedrawAllViews() { - m_matrixModelResults->clearScalarResult(RiaDefines::DYNAMIC_NATIVE, RiaDefines::completionTypeResultName()); + m_matrixModelResults->cellResults()->clearScalarResult(RiaDefines::DYNAMIC_NATIVE, RiaDefines::completionTypeResultName()); for (RimView* view : views()) { @@ -417,15 +417,11 @@ void RimEclipseCase::setReservoirData(RigEclipseCaseData* eclipseCase) { m_fractureModelResults()->setCellResults(eclipseCaseData()->results(RiaDefines::FRACTURE_MODEL)); m_matrixModelResults()->setCellResults(eclipseCaseData()->results(RiaDefines::MATRIX_MODEL)); - m_fractureModelResults()->setMainGrid(this->eclipseCaseData()->mainGrid()); - m_matrixModelResults()->setMainGrid(this->eclipseCaseData()->mainGrid()); } else { m_fractureModelResults()->setCellResults(NULL); m_matrixModelResults()->setCellResults(NULL); - m_fractureModelResults()->setMainGrid(NULL); - m_matrixModelResults()->setMainGrid(NULL); } } diff --git a/ApplicationCode/ProjectDataModel/RimEclipseInputCase.cpp b/ApplicationCode/ProjectDataModel/RimEclipseInputCase.cpp index e64b99a703..6f7f666549 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseInputCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseInputCase.cpp @@ -88,8 +88,8 @@ void RimEclipseInputCase::openDataFileSet(const QStringList& fileNames) if (fileNames.contains(RiaDefines::mockModelBasicInputCase())) { cvf::ref readerInterface = this->createMockModel(fileNames[0]); - results(RiaDefines::MATRIX_MODEL)->setReaderInterface(readerInterface.p()); - results(RiaDefines::FRACTURE_MODEL)->setReaderInterface(readerInterface.p()); + results(RiaDefines::MATRIX_MODEL)->cellResults()->setReaderInterface(readerInterface.p()); + results(RiaDefines::FRACTURE_MODEL)->cellResults()->setReaderInterface(readerInterface.p()); eclipseCaseData()->activeCellInfo(RiaDefines::MATRIX_MODEL)->computeDerivedData(); eclipseCaseData()->activeCellInfo(RiaDefines::FRACTURE_MODEL)->computeDerivedData(); @@ -204,8 +204,8 @@ bool RimEclipseInputCase::openEclipseGridFile() CVF_ASSERT(this->eclipseCaseData()); CVF_ASSERT(readerInterface.notNull()); - results(RiaDefines::MATRIX_MODEL)->setReaderInterface(readerInterface.p()); - results(RiaDefines::FRACTURE_MODEL)->setReaderInterface(readerInterface.p()); + results(RiaDefines::MATRIX_MODEL)->cellResults()->setReaderInterface(readerInterface.p()); + results(RiaDefines::FRACTURE_MODEL)->cellResults()->setReaderInterface(readerInterface.p()); this->eclipseCaseData()->mainGrid()->setFlipAxis(flipXAxis, flipYAxis); diff --git a/ApplicationCode/ProjectDataModel/RimEclipseResultCase.cpp b/ApplicationCode/ProjectDataModel/RimEclipseResultCase.cpp index d2f73123da..5d1eecf1ff 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseResultCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseResultCase.cpp @@ -179,8 +179,8 @@ bool RimEclipseResultCase::importGridAndResultMetaData(bool showTimeStepFilter) readerInterface = readerEclipseOutput; } - results(RiaDefines::MATRIX_MODEL)->setReaderInterface(readerInterface.p()); - results(RiaDefines::FRACTURE_MODEL)->setReaderInterface(readerInterface.p()); + results(RiaDefines::MATRIX_MODEL)->cellResults()->setReaderInterface(readerInterface.p()); + results(RiaDefines::FRACTURE_MODEL)->cellResults()->setReaderInterface(readerInterface.p()); progInfo.incrementProgress(); @@ -262,8 +262,8 @@ bool RimEclipseResultCase::openAndReadActiveCellData(RigEclipseCaseData* mainEcl readerInterface = readerEclipseOutput; } - results(RiaDefines::MATRIX_MODEL)->setReaderInterface(readerInterface.p()); - results(RiaDefines::FRACTURE_MODEL)->setReaderInterface(readerInterface.p()); + results(RiaDefines::MATRIX_MODEL)->cellResults()->setReaderInterface(readerInterface.p()); + results(RiaDefines::FRACTURE_MODEL)->cellResults()->setReaderInterface(readerInterface.p()); CVF_ASSERT(this->eclipseCaseData()); CVF_ASSERT(readerInterface.notNull()); @@ -282,11 +282,7 @@ void RimEclipseResultCase::loadAndUpdateSourSimData() { if (!results(RiaDefines::MATRIX_MODEL)) return; - RifReaderEclipseOutput* rifReaderOutput = dynamic_cast(results(RiaDefines::MATRIX_MODEL)->readerInterface()); - if (rifReaderOutput) - { - rifReaderOutput->setHdf5FileName(m_sourSimFileName); - } + results(RiaDefines::MATRIX_MODEL)->cellResults()->setHdf5Filename(m_sourSimFileName); if (!hasSourSimFile()) { diff --git a/ApplicationCode/ProjectDataModel/RimReservoirCellResultsStorage.cpp b/ApplicationCode/ProjectDataModel/RimReservoirCellResultsStorage.cpp index 045afd28bb..38710f0bfe 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoirCellResultsStorage.cpp +++ b/ApplicationCode/ProjectDataModel/RimReservoirCellResultsStorage.cpp @@ -49,8 +49,7 @@ CAF_PDM_SOURCE_INIT(RimReservoirCellResultsStorage, "ReservoirCellResultStorage" /// //-------------------------------------------------------------------------------------------------- RimReservoirCellResultsStorage::RimReservoirCellResultsStorage() - : m_cellResults(NULL), - m_ownerMainGrid(NULL) + : m_cellResults(NULL) { CAF_PDM_InitObject("Cacher", "", "", ""); @@ -212,33 +211,6 @@ QString RimReservoirCellResultsStorage::getCacheDirectoryPath() return cacheDirPath; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimReservoirCellResultsStorage::setReaderInterface(RifReaderInterface* readerInterface) -{ - m_readerInterface = readerInterface; - m_cellResults->setReaderInterface(readerInterface); -} - - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RifReaderInterface* RimReservoirCellResultsStorage::readerInterface() -{ - return m_readerInterface.p(); -} - - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -const RifReaderInterface* RimReservoirCellResultsStorage::readerInterface() const -{ - return m_readerInterface.p(); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -249,15 +221,6 @@ size_t RimReservoirCellResultsStorage::findOrLoadScalarResult(const QString& res return m_cellResults->findOrLoadScalarResult(resultName); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimReservoirCellResultsStorage::clearScalarResult(RiaDefines::ResultCatType type, const QString & resultName) -{ - size_t scalarResultIndex = m_cellResults->findScalarResultIndex(type, resultName); - m_cellResults->cellScalarResults(scalarResultIndex).clear(); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -364,14 +327,6 @@ void RimReservoirCellResultsStorage::setCellResults(RigCaseCellResultsData* cell } } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimReservoirCellResultsStorage::setMainGrid(RigMainGrid* mainGrid) -{ - m_ownerMainGrid = mainGrid; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimReservoirCellResultsStorage.h b/ApplicationCode/ProjectDataModel/RimReservoirCellResultsStorage.h index 6c57768d64..a7b537e184 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoirCellResultsStorage.h +++ b/ApplicationCode/ProjectDataModel/RimReservoirCellResultsStorage.h @@ -51,20 +51,10 @@ public: size_t storedResultsCount(); - void setMainGrid(RigMainGrid* mainGrid); - - void setReaderInterface(RifReaderInterface* readerInterface); - RifReaderInterface* readerInterface(); - const RifReaderInterface* readerInterface() const; - - void computeDepthRelatedResults(); - size_t findOrLoadScalarResultForTimeStep(RiaDefines::ResultCatType type, const QString& resultName, size_t timeStepIndex); size_t findOrLoadScalarResult(RiaDefines::ResultCatType type, const QString& resultName); size_t findOrLoadScalarResult(const QString& resultName); ///< Simplified search. Assumes unique names across types. - void clearScalarResult(RiaDefines::ResultCatType type, const QString& resultName); - protected: // Overridden methods from PdmObject virtual void setupBeforeSave(); @@ -77,9 +67,7 @@ private: caf::PdmChildArrayField m_resultCacheMetaData; - cvf::ref m_readerInterface; RigCaseCellResultsData* m_cellResults; - RigMainGrid* m_ownerMainGrid; }; class RimReservoirCellResultsStorageEntryInfo : public caf::PdmObject diff --git a/ApplicationCode/ProjectDataModel/RimTimeStepFilter.cpp b/ApplicationCode/ProjectDataModel/RimTimeStepFilter.cpp index c52134403d..fe161f3231 100644 --- a/ApplicationCode/ProjectDataModel/RimTimeStepFilter.cpp +++ b/ApplicationCode/ProjectDataModel/RimTimeStepFilter.cpp @@ -28,6 +28,7 @@ #include "cafPdmUiTextEditor.h" #include +#include "RigCaseCellResultsData.h" namespace caf { @@ -231,11 +232,7 @@ std::vector RimTimeStepFilter::allTimeSteps() const RimEclipseResultCase* rimEclipseResultCase = parentEclipseResultCase(); if (rimEclipseResultCase && rimEclipseResultCase->results(RiaDefines::MATRIX_MODEL)) { - const RifReaderEclipseOutput* rifReaderOutput = dynamic_cast(rimEclipseResultCase->results(RiaDefines::MATRIX_MODEL)->readerInterface()); - if (rifReaderOutput) - { - return rifReaderOutput->allTimeSteps(); - } + return rimEclipseResultCase->results(RiaDefines::MATRIX_MODEL)->cellResults()->allTimeStepDatesFromEclipseReader(); } return m_timeStepsFromFile; diff --git a/ApplicationCode/ProjectDataModel/RimTimeStepFilter.h b/ApplicationCode/ProjectDataModel/RimTimeStepFilter.h index e457366aff..bfe35a2360 100644 --- a/ApplicationCode/ProjectDataModel/RimTimeStepFilter.h +++ b/ApplicationCode/ProjectDataModel/RimTimeStepFilter.h @@ -84,5 +84,5 @@ private: caf::PdmField m_applyReloadOfCase; - std::vector m_timeStepsFromFile; + std::vector m_timeStepsFromFile; /// Temporarily set to provide correct options before the case data structures are operative }; diff --git a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp index 002365ff8b..7b0c6f0942 100644 --- a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp +++ b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp @@ -440,6 +440,22 @@ bool RigCaseCellResultsData::hasFlowDiagUsableFluxes() const return hasFlowFluxes; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RigCaseCellResultsData::allTimeStepDatesFromEclipseReader() const +{ + const RifReaderEclipseOutput* rifReaderOutput = dynamic_cast(m_readerInterface.p()); + if (rifReaderOutput) + { + return rifReaderOutput->allTimeSteps(); + } + else + { + return std::vector(); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -597,14 +613,14 @@ QString RigCaseCellResultsData::makeResultNameUnique(const QString& resultNamePr //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigCaseCellResultsData::removeResult(const QString& resultName) +void RigCaseCellResultsData::clearScalarResult(RiaDefines::ResultCatType type, const QString & resultName) { - size_t resultIdx = findScalarResultIndex(resultName); - if (resultIdx == cvf::UNDEFINED_SIZE_T) return; + size_t scalarResultIndex = this->findScalarResultIndex(type, resultName); + if (scalarResultIndex == cvf::UNDEFINED_SIZE_T) return; - m_cellScalarResults[resultIdx].clear(); + m_cellScalarResults[scalarResultIndex].clear(); - m_resultInfos[resultIdx].m_resultType = RiaDefines::REMOVED; + //m_resultInfos[scalarResultIndex].m_resultType = RiaDefines::REMOVED; } //-------------------------------------------------------------------------------------------------- @@ -2124,6 +2140,18 @@ void RigCaseCellResultsData::setReaderInterface(RifReaderInterface* readerInterf } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigCaseCellResultsData::setHdf5Filename(const QString& hdf5SourSimFilename) +{ + RifReaderEclipseOutput* rifReaderOutput = dynamic_cast(m_readerInterface.p()); + if (rifReaderOutput) + { + rifReaderOutput->setHdf5FileName(hdf5SourSimFilename); + } +} + //-------------------------------------------------------------------------------------------------- /// If we have any results on any time step, assume we have loaded results //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.h b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.h index 9fcdbbfb8e..ac0bc2e701 100644 --- a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.h +++ b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.h @@ -47,6 +47,7 @@ public: explicit RigCaseCellResultsData(RigEclipseCaseData* ownerCaseData); void setReaderInterface(RifReaderInterface* readerInterface); + void setHdf5Filename(const QString& hdf5SourSimFilename ); void setMainGrid(RigMainGrid* ownerGrid); void setActiveCellInfo(RigActiveCellInfo* activeCellInfo) { m_activeCellInfo = activeCellInfo;} @@ -77,6 +78,7 @@ public: bool isUsingGlobalActiveIndex(size_t scalarResultIndex) const; bool hasFlowDiagUsableFluxes() const; + std::vector allTimeStepDatesFromEclipseReader() const; std::vector timeStepDates() const; QDateTime timeStepDate(size_t scalarResultIndex, size_t timeStepIndex) const; std::vector timeStepDates(size_t scalarResultIndex) const; @@ -103,7 +105,7 @@ public: void createPlaceholderResultEntries(); void computeDepthRelatedResults(); - void removeResult(const QString& resultName); + void clearScalarResult(RiaDefines::ResultCatType type, const QString & resultName); void clearAllResults(); void freeAllocatedResultsData();