From 326cd7975406920f2674bdbdbe8bc6317b27f6a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Thu, 21 Mar 2013 15:31:47 +0100 Subject: [PATCH] Result Storage: Finally things have come together, and seems to behave. Refactored the loadProject system to make loading of statistical cases work as they should. Got the update of references regarding grid and unionActive cells work Introduced a bool to keep track of what cell results to store. Introduced a clear method in ActiveCellInfo. Renamed a bit p4#: 21036 --- ApplicationCode/Application/RIApplication.cpp | 99 +++++++----- .../RifEclipseInputFileTools.cpp | 6 +- .../FileInterface/RifReaderEclipseOutput.cpp | 8 +- .../FileInterface/RifReaderMockModel.cpp | 6 +- .../RifReaderStatisticalCalculation.cpp | 8 +- .../ProjectDataModel/RigStatistics.cpp | 4 +- .../RimIdenticalGridCaseGroup.cpp | 88 +++++----- .../RimIdenticalGridCaseGroup.h | 6 +- .../ProjectDataModel/RimReservoir.cpp | 2 +- .../RimReservoirCellResultsCacher.cpp | 150 ++++++++++++++++-- .../RimReservoirCellResultsCacher.h | 18 ++- .../ProjectDataModel/RimResultReservoir.cpp | 2 +- .../RimStatisticalCalculation.cpp | 31 ++-- .../ReservoirDataModel/RigActiveCellInfo.cpp | 13 ++ .../ReservoirDataModel/RigActiveCellInfo.h | 2 + .../ReservoirDataModel/RigEclipseCase.cpp | 6 +- .../ReservoirDataModel/RigEclipseCase.h | 8 +- .../RigReservoirCellResults.cpp | 13 +- .../RigReservoirCellResults.h | 17 +- .../SocketInterface/RiaSocketServer.cpp | 2 +- 20 files changed, 334 insertions(+), 155 deletions(-) diff --git a/ApplicationCode/Application/RIApplication.cpp b/ApplicationCode/Application/RIApplication.cpp index fbc60f5473..127df8be08 100644 --- a/ApplicationCode/Application/RIApplication.cpp +++ b/ApplicationCode/Application/RIApplication.cpp @@ -223,14 +223,21 @@ const char* RIApplication::getVersionStringApp(bool includeCrtInfo) //-------------------------------------------------------------------------------------------------- bool RIApplication::loadProject(const QString& projectFileName) { + // First Close the current project + if (!closeProject(true)) return false; + // Open the project file and read the serialized data. + // Will initialize itself. + if (!QFile::exists(projectFileName)) return false; m_project->fileName = projectFileName; m_project->readFile(); m_project->fileName = projectFileName; // Make sure we overwrite the old filename read from the project file + // On error, delete everything, and bail out. + if (m_project->projectFileVersionString().isEmpty()) { closeProject(false); @@ -244,62 +251,78 @@ bool RIApplication::loadProject(const QString& projectFileName) // Delete all object possibly generated by readFile() delete m_project; m_project = new RimProject; + + onProjectOpenedOrClosed(); + + return true; } - else + + /////// + // Load the external data, and initialize stuff that needs specific ordering + + m_preferences->lastUsedProjectFileName = projectFileName; + writePreferences(); + + for (size_t cgIdx = 0; cgIdx < m_project->caseGroups.size(); ++cgIdx) { - m_preferences->lastUsedProjectFileName = projectFileName; - writePreferences(); + // Load the Main case of each IdenticalGridCaseGroup - std::vector casesToLoad; + RimIdenticalGridCaseGroup* igcg = m_project->caseGroups[cgIdx]; + igcg->loadMainCaseAndActiveCellInfo(); + } - // Add all "native" cases in the project - for (size_t cIdx = 0; cIdx < m_project->reservoirs().size(); ++cIdx) + // Now load the ReservoirViews for the cases + + std::vector casesToLoad; + + // Add all "native" cases in the project + for (size_t cIdx = 0; cIdx < m_project->reservoirs().size(); ++cIdx) + { + casesToLoad.push_back(m_project->reservoirs()[cIdx]); + } + + // Add all statistics cases as well + for (size_t cgIdx = 0; cgIdx < m_project->caseGroups().size(); ++cgIdx) + { + if (m_project->caseGroups[cgIdx]->statisticalReservoirCollection()) { - casesToLoad.push_back(m_project->reservoirs()[cIdx]); - } - - // Add all statistics cases as well - for (size_t cgIdx = 0; cgIdx < m_project->caseGroups().size(); ++cgIdx) - { - if (m_project->caseGroups[cgIdx]->statisticalReservoirCollection()) + caf::PdmPointersField & statCases = m_project->caseGroups[cgIdx]->statisticalReservoirCollection()->reservoirs(); + for (size_t scIdx = 0; scIdx < statCases.size(); ++scIdx) { - caf::PdmPointersField & statCases = m_project->caseGroups[cgIdx]->statisticalReservoirCollection()->reservoirs(); - for (size_t scIdx = 0; scIdx < statCases.size(); ++scIdx) - { - casesToLoad.push_back(statCases[scIdx]); - } + casesToLoad.push_back(statCases[scIdx]); } } + } - caf::ProgressInfo caseProgress(casesToLoad.size() , "Reading Cases"); + caf::ProgressInfo caseProgress(casesToLoad.size() , "Reading Cases"); - for (size_t cIdx = 0; cIdx < casesToLoad.size(); ++cIdx) + for (size_t cIdx = 0; cIdx < casesToLoad.size(); ++cIdx) + { + RimReservoir* ri = casesToLoad[cIdx]; + CVF_ASSERT(ri); + + caseProgress.setProgressDescription(ri->caseName()); + + caf::ProgressInfo viewProgress(ri->reservoirViews().size() , "Creating Views"); + + size_t j; + for (j = 0; j < ri->reservoirViews().size(); j++) { - RimReservoir* ri = casesToLoad[cIdx]; - CVF_ASSERT(ri); + RimReservoirView* riv = ri->reservoirViews[j]; + CVF_ASSERT(riv); - caseProgress.setProgressDescription(ri->caseName()); + viewProgress.setProgressDescription(riv->name()); - caf::ProgressInfo viewProgress(ri->reservoirViews().size() , "Creating Views"); + riv->loadDataAndUpdate(); - size_t j; - for (j = 0; j < ri->reservoirViews().size(); j++) - { - RimReservoirView* riv = ri->reservoirViews()[j]; - CVF_ASSERT(riv); - - viewProgress.setProgressDescription(riv->name()); - - riv->loadDataAndUpdate(); - viewProgress.incrementProgress(); - } - - caseProgress.incrementProgress(); + viewProgress.incrementProgress(); } + + caseProgress.incrementProgress(); } onProjectOpenedOrClosed(); - + return true; } diff --git a/ApplicationCode/FileInterface/RifEclipseInputFileTools.cpp b/ApplicationCode/FileInterface/RifEclipseInputFileTools.cpp index 13182d8852..bcb4c98d57 100644 --- a/ApplicationCode/FileInterface/RifEclipseInputFileTools.cpp +++ b/ApplicationCode/FileInterface/RifEclipseInputFileTools.cpp @@ -214,7 +214,7 @@ std::map RifEclipseInputFileTools::readProperties(const QStri { QString newResultName = reservoir->results(RifReaderInterface::MATRIX_RESULTS)->makeResultNameUnique(fileKeywords[i].keyword); - size_t resultIndex = reservoir->results(RifReaderInterface::MATRIX_RESULTS)->addEmptyScalarResult(RimDefines::INPUT_PROPERTY, newResultName); // Should really merge with inputProperty object information because we need to use PropertyName, and not keyword + size_t resultIndex = reservoir->results(RifReaderInterface::MATRIX_RESULTS)->addEmptyScalarResult(RimDefines::INPUT_PROPERTY, newResultName, false); // Should really merge with inputProperty object information because we need to use PropertyName, and not keyword std::vector< std::vector >& newPropertyData = reservoir->results(RifReaderInterface::MATRIX_RESULTS)->cellScalarResults(resultIndex); newPropertyData.push_back(std::vector()); @@ -297,7 +297,7 @@ bool RifEclipseInputFileTools::readProperty(const QString& fileName, RigEclipseC size_t resultIndex = eclipseCase->results(RifReaderInterface::MATRIX_RESULTS)->findScalarResultIndex(newResultName); if (resultIndex == cvf::UNDEFINED_SIZE_T) { - resultIndex = eclipseCase->results(RifReaderInterface::MATRIX_RESULTS)->addEmptyScalarResult(RimDefines::INPUT_PROPERTY, newResultName); + resultIndex = eclipseCase->results(RifReaderInterface::MATRIX_RESULTS)->addEmptyScalarResult(RimDefines::INPUT_PROPERTY, newResultName, false); } std::vector< std::vector >& newPropertyData = eclipseCase->results(RifReaderInterface::MATRIX_RESULTS)->cellScalarResults(resultIndex); @@ -535,7 +535,7 @@ bool RifEclipseInputFileTools::readPropertyAtFilePosition(const QString& fileNam size_t resultIndex = eclipseCase->results(RifReaderInterface::MATRIX_RESULTS)->findScalarResultIndex(newResultName); if (resultIndex == cvf::UNDEFINED_SIZE_T) { - resultIndex = eclipseCase->results(RifReaderInterface::MATRIX_RESULTS)->addEmptyScalarResult(RimDefines::INPUT_PROPERTY, newResultName); + resultIndex = eclipseCase->results(RifReaderInterface::MATRIX_RESULTS)->addEmptyScalarResult(RimDefines::INPUT_PROPERTY, newResultName, false); } std::vector< std::vector >& newPropertyData = eclipseCase->results(RifReaderInterface::MATRIX_RESULTS)->cellScalarResults(resultIndex); diff --git a/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp b/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp index 584f731876..3d8e746183 100644 --- a/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp +++ b/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp @@ -564,7 +564,7 @@ bool RifReaderEclipseOutput::buildMetaData() for (int i = 0; i < matrixResultNames.size(); ++i) { - size_t resIndex = matrixModelResults->addEmptyScalarResult(RimDefines::DYNAMIC_NATIVE, matrixResultNames[i]); + size_t resIndex = matrixModelResults->addEmptyScalarResult(RimDefines::DYNAMIC_NATIVE, matrixResultNames[i], false); matrixModelResults->setTimeStepDates(resIndex, m_timeSteps); } } @@ -577,7 +577,7 @@ bool RifReaderEclipseOutput::buildMetaData() for (int i = 0; i < fractureResultNames.size(); ++i) { - size_t resIndex = fractureModelResults->addEmptyScalarResult(RimDefines::DYNAMIC_NATIVE, fractureResultNames[i]); + size_t resIndex = fractureModelResults->addEmptyScalarResult(RimDefines::DYNAMIC_NATIVE, fractureResultNames[i], false); fractureModelResults->setTimeStepDates(resIndex, m_timeSteps); } } @@ -610,7 +610,7 @@ bool RifReaderEclipseOutput::buildMetaData() for (int i = 0; i < matrixResultNames.size(); ++i) { - size_t resIndex = matrixModelResults->addEmptyScalarResult(RimDefines::STATIC_NATIVE, matrixResultNames[i]); + size_t resIndex = matrixModelResults->addEmptyScalarResult(RimDefines::STATIC_NATIVE, matrixResultNames[i], false); matrixModelResults->setTimeStepDates(resIndex, staticDate); } } @@ -629,7 +629,7 @@ bool RifReaderEclipseOutput::buildMetaData() for (int i = 0; i < fractureResultNames.size(); ++i) { - size_t resIndex = fractureModelResults->addEmptyScalarResult(RimDefines::STATIC_NATIVE, fractureResultNames[i]); + size_t resIndex = fractureModelResults->addEmptyScalarResult(RimDefines::STATIC_NATIVE, fractureResultNames[i], false); fractureModelResults->setTimeStepDates(resIndex, staticDate); } } diff --git a/ApplicationCode/FileInterface/RifReaderMockModel.cpp b/ApplicationCode/FileInterface/RifReaderMockModel.cpp index fc8257bcf7..49de1cb07b 100644 --- a/ApplicationCode/FileInterface/RifReaderMockModel.cpp +++ b/ApplicationCode/FileInterface/RifReaderMockModel.cpp @@ -43,7 +43,7 @@ bool RifReaderMockModel::open(const QString& fileName, RigEclipseCase* eclipseCa for (size_t i = 0; i < m_reservoirBuilder.resultCount(); i++) { - size_t resIdx = cellResults->addEmptyScalarResult(RimDefines::DYNAMIC_NATIVE, QString("Dynamic_Result_%1").arg(i)); + size_t resIdx = cellResults->addEmptyScalarResult(RimDefines::DYNAMIC_NATIVE, QString("Dynamic_Result_%1").arg(i), false); cellResults->setTimeStepDates(resIdx, dates); } @@ -59,7 +59,7 @@ bool RifReaderMockModel::open(const QString& fileName, RigEclipseCase* eclipseCa int resIndex = 0; if (i > 1) resIndex = i; - size_t resIdx = cellResults->addEmptyScalarResult(RimDefines::STATIC_NATIVE, QString("Static_Result_%1%2").arg(resIndex).arg(varEnd)); + size_t resIdx = cellResults->addEmptyScalarResult(RimDefines::STATIC_NATIVE, QString("Static_Result_%1%2").arg(resIndex).arg(varEnd), false); cellResults->setTimeStepDates(resIdx, staticDates); } @@ -68,7 +68,7 @@ bool RifReaderMockModel::open(const QString& fileName, RigEclipseCase* eclipseCa { \ size_t resIdx; \ QString resultName(Name); \ - resIdx = cellResults->addEmptyScalarResult(RimDefines::INPUT_PROPERTY, resultName); \ + resIdx = cellResults->addEmptyScalarResult(RimDefines::INPUT_PROPERTY, resultName, false); \ cellResults->setTimeStepDates(resIdx, staticDates); \ cellResults->cellScalarResults(resIdx).resize(1); \ std::vector& values = cellResults->cellScalarResults(resIdx)[0]; \ diff --git a/ApplicationCode/FileInterface/RifReaderStatisticalCalculation.cpp b/ApplicationCode/FileInterface/RifReaderStatisticalCalculation.cpp index ca9d4cdc08..07bf2ab9db 100644 --- a/ApplicationCode/FileInterface/RifReaderStatisticalCalculation.cpp +++ b/ApplicationCode/FileInterface/RifReaderStatisticalCalculation.cpp @@ -60,13 +60,13 @@ void RifReaderStatisticalCalculation::buildMetaData(RigEclipseCase* eclipseCase) // Dynamic results for (int i = 0; i < m_matrixDynamicResultNames.size(); ++i) { - size_t resIndex = matrixModelResults->addEmptyScalarResult(RimDefines::DYNAMIC_NATIVE, m_matrixDynamicResultNames[i]); + size_t resIndex = matrixModelResults->addEmptyScalarResult(RimDefines::DYNAMIC_NATIVE, m_matrixDynamicResultNames[i], true); matrixModelResults->setTimeStepDates(resIndex, m_timeSteps); } for (int i = 0; i < m_fractureDynamicResultNames.size(); ++i) { - size_t resIndex = fractureModelResults->addEmptyScalarResult(RimDefines::DYNAMIC_NATIVE, m_fractureDynamicResultNames[i]); + size_t resIndex = fractureModelResults->addEmptyScalarResult(RimDefines::DYNAMIC_NATIVE, m_fractureDynamicResultNames[i], true); fractureModelResults->setTimeStepDates(resIndex, m_timeSteps); } @@ -79,13 +79,13 @@ void RifReaderStatisticalCalculation::buildMetaData(RigEclipseCase* eclipseCase) // Static results for (int i = 0; i < m_fractureStaticResultNames.size(); ++i) { - size_t resIndex = fractureModelResults->addEmptyScalarResult(RimDefines::STATIC_NATIVE, m_fractureStaticResultNames[i]); + size_t resIndex = fractureModelResults->addEmptyScalarResult(RimDefines::STATIC_NATIVE, m_fractureStaticResultNames[i], true); fractureModelResults->setTimeStepDates(resIndex, staticDate); } for (int i = 0; i < m_matrixStaticResultNames.size(); ++i) { - size_t resIndex = matrixModelResults->addEmptyScalarResult(RimDefines::STATIC_NATIVE, m_matrixStaticResultNames[i]); + size_t resIndex = matrixModelResults->addEmptyScalarResult(RimDefines::STATIC_NATIVE, m_matrixStaticResultNames[i], true); matrixModelResults->setTimeStepDates(resIndex, staticDate); } } diff --git a/ApplicationCode/ProjectDataModel/RigStatistics.cpp b/ApplicationCode/ProjectDataModel/RigStatistics.cpp index b3e9a6e549..3b6a173402 100644 --- a/ApplicationCode/ProjectDataModel/RigStatistics.cpp +++ b/ApplicationCode/ProjectDataModel/RigStatistics.cpp @@ -37,7 +37,7 @@ void RigStatistics::addNamedResult(RigReservoirCellResults* destinationCellResul std::vector sourceTimeStepDates = m_sourceCases[0]->results(RifReaderInterface::MATRIX_RESULTS)->cellResults()->timeStepDates(0); - size_t destinationScalarResultIndex = destinationCellResults->addEmptyScalarResult(resultType, resultName); + size_t destinationScalarResultIndex = destinationCellResults->addEmptyScalarResult(resultType, resultName, true); CVF_ASSERT(destinationScalarResultIndex != cvf::UNDEFINED_SIZE_T); destinationCellResults->setTimeStepDates(destinationScalarResultIndex, sourceTimeStepDates); @@ -76,7 +76,7 @@ void RigStatistics::buildSourceMetaData(RimDefines::ResultCatType resultType, co size_t scalarResultIndex = matrixResults->findOrLoadScalarResult(resultType, resultName); if (scalarResultIndex == cvf::UNDEFINED_SIZE_T) { - size_t scalarResultIndex = matrixResults->cellResults()->addEmptyScalarResult(resultType, resultName); + size_t scalarResultIndex = matrixResults->cellResults()->addEmptyScalarResult(resultType, resultName, false); matrixResults->cellResults()->setTimeStepDates(scalarResultIndex, timeStepDates); std::vector< std::vector >& dataValues = matrixResults->cellResults()->cellScalarResults(scalarResultIndex); diff --git a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp index 0a10f4586e..74f61921ca 100644 --- a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp +++ b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp @@ -51,7 +51,8 @@ RimIdenticalGridCaseGroup::RimIdenticalGridCaseGroup() m_mainGrid = NULL; - clearActiveCellUnions(); + m_unionOfMatrixActiveCells = new RigActiveCellInfo; + m_unionOfFractureActiveCells = new RigActiveCellInfo; } //-------------------------------------------------------------------------------------------------- @@ -136,51 +137,50 @@ caf::PdmFieldHandle* RimIdenticalGridCaseGroup::userDescriptionField() //-------------------------------------------------------------------------------------------------- /// Make sure changes in this functions is validated to RIApplication::addEclipseCases() //-------------------------------------------------------------------------------------------------- -void RimIdenticalGridCaseGroup::initAfterRead() +void RimIdenticalGridCaseGroup::loadMainCaseAndActiveCellInfo() { if (caseCollection()->reservoirs().size() == 0) { return; } - // First file is read completely including grid. - // The main grid from the first case is reused directly in for the other cases. + // Read the main case completely including grid. + // The mainGrid from the first case is reused directly in for the other cases. // When reading active cell info, only the total cell count is tested for consistency - RigEclipseCase* mainEclipseCase = NULL; - RimResultReservoir* rimReservoir = dynamic_cast(caseCollection()->reservoirs()[0]); - CVF_ASSERT(rimReservoir); - - rimReservoir->openEclipseGridFile(); - - mainEclipseCase = rimReservoir->reservoirData(); + RimReservoir* mainCase = caseCollection()->reservoirs[0]; + mainCase->openEclipseGridFile(); + RigEclipseCase* mainEclipseCase = mainCase->reservoirData(); CVF_ASSERT(mainEclipseCase); - // Read active cell info from all source cases - caf::ProgressInfo info(caseCollection()->reservoirs().size(), "Case group - Reading Active Cell data"); - for (size_t i = 1; i < caseCollection()->reservoirs().size(); i++) + + caf::ProgressInfo info(caseCollection()->reservoirs.size(), "Case group - Reading Active Cell data"); + for (size_t i = 1; i < caseCollection()->reservoirs.size(); i++) { - RimResultReservoir* rimReservoir = dynamic_cast(caseCollection()->reservoirs()[i]); - CVF_ASSERT(rimReservoir); + RimResultReservoir* rimReservoir = dynamic_cast(caseCollection()->reservoirs[i]); + if(!rimReservoir) continue; // Input reservoir if (!rimReservoir->openAndReadActiveCellData(mainEclipseCase)) { CVF_ASSERT(false); } - info.setProgress(i); + info.incrementProgress(); } + m_mainGrid = mainEclipseCase->mainGrid(); + + // Check if we need to calculate the union of the active cells bool foundResultsInCache = false; - for (size_t i = 0; i < statisticalReservoirCollection()->reservoirs().size(); i++) + for (size_t i = 0; i < statisticalReservoirCollection()->reservoirs.size(); i++) { - RimStatisticalCalculation* rimReservoir = statisticalReservoirCollection()->reservoirs()[i]; + RimStatisticalCalculation* rimReservoir = statisticalReservoirCollection()->reservoirs[i]; // Check if any results are stored in cache - if (rimReservoir->results(RifReaderInterface::MATRIX_RESULTS)->m_resultCacheMetaData.size() > 0 || - rimReservoir->results(RifReaderInterface::FRACTURE_RESULTS)->m_resultCacheMetaData.size() > 0) + if (rimReservoir->results(RifReaderInterface::MATRIX_RESULTS)->storedResultsCount() > 0 || + rimReservoir->results(RifReaderInterface::FRACTURE_RESULTS)->storedResultsCount() > 0) { foundResultsInCache = true; break; @@ -192,11 +192,22 @@ void RimIdenticalGridCaseGroup::initAfterRead() computeUnionOfActiveCells(); } - m_mainGrid = mainEclipseCase->mainGrid(); + // "Load" the statistical cases - updateMainGridAndActiveCellsForStatisticsCases(); + for (size_t i = 0; i < statisticalReservoirCollection()->reservoirs.size(); i++) + { + RimStatisticalCalculation* rimReservoir = statisticalReservoirCollection()->reservoirs[i]; + + rimReservoir->openEclipseGridFile(); + + if (i == 0) + { + rimReservoir->reservoirData()->computeActiveCellBoundingBoxes(); + } + } } + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -209,13 +220,11 @@ void RimIdenticalGridCaseGroup::computeUnionOfActiveCells() if (caseCollection->reservoirs.size() == 0 || !m_mainGrid) { - m_unionOfMatrixActiveCells = new RigActiveCellInfo; - m_unionOfFractureActiveCells = new RigActiveCellInfo; + this->clearActiveCellUnions(); return; } - m_unionOfMatrixActiveCells->setGlobalCellCount(m_mainGrid->cells().size()); m_unionOfFractureActiveCells->setGlobalCellCount(m_mainGrid->cells().size()); m_unionOfMatrixActiveCells->setGridCount(m_mainGrid->gridCount()); @@ -291,12 +300,10 @@ RimStatisticalCalculation* RimIdenticalGridCaseGroup::createAndAppendStatistical RimStatisticalCalculation* newObject = new RimStatisticalCalculation; newObject->caseName = QString("Statistics ") + QString::number(statisticalReservoirCollection()->reservoirs.size()+1); - newObject->setMainGrid(this->mainGrid()); - newObject->reservoirData()->setActiveCellInfo(RifReaderInterface::MATRIX_RESULTS, m_unionOfMatrixActiveCells.p()); - newObject->reservoirData()->setActiveCellInfo(RifReaderInterface::FRACTURE_RESULTS, m_unionOfFractureActiveCells.p()); - statisticalReservoirCollection()->reservoirs.push_back(newObject); + newObject->openEclipseGridFile(); + return newObject; } @@ -309,13 +316,11 @@ void RimIdenticalGridCaseGroup::updateMainGridAndActiveCellsForStatisticsCases() { RimStatisticalCalculation* rimStaticsCase = statisticalReservoirCollection->reservoirs[i]; - rimStaticsCase->setMainGrid(this->mainGrid()); - rimStaticsCase->reservoirData()->setActiveCellInfo(RifReaderInterface::MATRIX_RESULTS, m_unionOfMatrixActiveCells.p()); - rimStaticsCase->reservoirData()->setActiveCellInfo(RifReaderInterface::FRACTURE_RESULTS, m_unionOfFractureActiveCells.p()); + rimStaticsCase->reservoirData()->setMainGrid(this->mainGrid()); if (i == 0) { - rimStaticsCase->reservoirData()->computeCachedData(); + rimStaticsCase->reservoirData()->computeActiveCellBoundingBoxes(); } } } @@ -338,8 +343,8 @@ void RimIdenticalGridCaseGroup::clearStatisticsResults() //-------------------------------------------------------------------------------------------------- void RimIdenticalGridCaseGroup::clearActiveCellUnions() { - m_unionOfMatrixActiveCells = new RigActiveCellInfo; - m_unionOfFractureActiveCells = new RigActiveCellInfo; + m_unionOfMatrixActiveCells->clear(); + m_unionOfFractureActiveCells->clear(); } //-------------------------------------------------------------------------------------------------- @@ -361,3 +366,14 @@ bool RimIdenticalGridCaseGroup::contains(RimReservoir* reservoir) const return false; } +RigActiveCellInfo* RimIdenticalGridCaseGroup::unionOfActiveCells(RifReaderInterface::PorosityModelResultType porosityType) +{ + if (porosityType == RifReaderInterface::MATRIX_RESULTS) + { + return m_unionOfMatrixActiveCells.p(); + } + else + { + return m_unionOfFractureActiveCells.p(); + } +} diff --git a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.h b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.h index 6b05d6ec29..06c0c2d077 100644 --- a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.h +++ b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.h @@ -54,21 +54,21 @@ public: caf::PdmField caseCollection; caf::PdmField statisticalReservoirCollection; + void loadMainCaseAndActiveCellInfo(); + RigMainGrid* mainGrid(); + RigActiveCellInfo* unionOfActiveCells(RifReaderInterface::PorosityModelResultType porosityType); void computeUnionOfActiveCells(); protected: virtual caf::PdmFieldHandle* userDescriptionField(); - virtual void initAfterRead(); - private: void updateMainGridAndActiveCellsForStatisticsCases(); void clearStatisticsResults(); void clearActiveCellUnions(); - private: RigMainGrid* m_mainGrid; diff --git a/ApplicationCode/ProjectDataModel/RimReservoir.cpp b/ApplicationCode/ProjectDataModel/RimReservoir.cpp index dab4e7566d..abd80217ef 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoir.cpp +++ b/ApplicationCode/ProjectDataModel/RimReservoir.cpp @@ -261,7 +261,7 @@ void RimReservoir::computeCachedData() RigEclipseCase* rigEclipseCase = reservoirData(); if (rigEclipseCase) { - rigEclipseCase->computeCachedData(); + rigEclipseCase->computeActiveCellBoundingBoxes(); rigEclipseCase->mainGrid()->computeCachedData(); diff --git a/ApplicationCode/ProjectDataModel/RimReservoirCellResultsCacher.cpp b/ApplicationCode/ProjectDataModel/RimReservoirCellResultsCacher.cpp index 650da7597c..6cf8ec3a05 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoirCellResultsCacher.cpp +++ b/ApplicationCode/ProjectDataModel/RimReservoirCellResultsCacher.cpp @@ -22,6 +22,7 @@ #include "RIApplication.h" #include "RigMainGrid.h" #include "RigCell.h" +#include "cafProgressInfo.h" CAF_PDM_SOURCE_INIT(RimReservoirCellResultsStorage, "ReservoirCellResultStorage"); @@ -58,16 +59,36 @@ RimReservoirCellResultsStorage::~RimReservoirCellResultsStorage() //-------------------------------------------------------------------------------------------------- void RimReservoirCellResultsStorage::setupBeforeSave() { + m_resultCacheMetaData.deleteAllChildObjects(); + QString newValidCacheFileName = getValidCacheFileName(); + + // Delete the storage file + + QFileInfo storageFileInfo(newValidCacheFileName); + if (storageFileInfo.exists()) + { + QDir storageDir = storageFileInfo.dir(); + storageDir.remove(storageFileInfo.fileName()); + } + if (!m_cellResults) return; const std::vector& resInfo = m_cellResults->infoForEachResultIndex(); - m_resultCacheMetaData.deleteAllChildObjects(); - if(resInfo.size()) + bool hasResultsToStore = false; + for (size_t rIdx = 0; rIdx < resInfo.size(); ++rIdx) + { + if (resInfo[rIdx].m_needsToBeStored) + { + hasResultsToStore = true; + break; + } + } + + if(resInfo.size() && hasResultsToStore) { QDir::root().mkpath(getCacheDirectoryPath()); - QString newValidCacheFileName = getValidCacheFileName(); QFile cacheFile(newValidCacheFileName); if (!cacheFile.open(QIODevice::WriteOnly)) @@ -79,16 +100,22 @@ void RimReservoirCellResultsStorage::setupBeforeSave() m_resultCacheFileName = newValidCacheFileName; QDataStream stream(&cacheFile); - stream.setVersion(QDataStream::Qt_4_0); + stream.setVersion(QDataStream::Qt_4_6); stream << (quint32)0xCEECAC4E; // magic number stream << (quint32)1; // Version number. Increment if needing to extend the format in ways that can not be handled generically by the reader + caf::ProgressInfo progInfo(resInfo.size(), "Saving generated and imported properties"); + for (size_t rIdx = 0; rIdx < resInfo.size(); ++rIdx) { + // If there is no data, we do not store anything for the current result variable + // (Even not the metadata, of cause) size_t timestepCount = m_cellResults->cellScalarResults(resInfo[rIdx].m_gridScalarResultIndex).size(); - if (timestepCount) + if (timestepCount && resInfo[rIdx].m_needsToBeStored) { + progInfo.setProgressDescription(resInfo[rIdx].m_resultName); + // Create and setup the cache information for this result RimReservoirCellResultsStorageEntryInfo* cacheEntry = new RimReservoirCellResultsStorageEntryInfo; m_resultCacheMetaData.push_back(cacheEntry); @@ -125,10 +152,13 @@ void RimReservoirCellResultsStorage::setupBeforeSave() } } } + + progInfo.incrementProgress(); } } } + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -256,7 +286,15 @@ size_t RimReservoirCellResultsStorage::findOrLoadScalarResult(RimDefines::Result if (resultGridIndex == cvf::UNDEFINED_SIZE_T) return cvf::UNDEFINED_SIZE_T; - if (m_cellResults->cellScalarResults(resultGridIndex).size()) return resultGridIndex; + // If we have any results on any timestep, assume we have loaded results already + + for (size_t tsIdx = 0; tsIdx < m_cellResults->timeStepCount(resultGridIndex); ++tsIdx) + { + if (m_cellResults->cellScalarResults(resultGridIndex, tsIdx).size()) + { + return resultGridIndex; + } + } if (type == RimDefines::GENERATED) { @@ -369,7 +407,7 @@ void RimReservoirCellResultsStorage::loadOrComputeSOILForTimeStep(size_t timeSte size_t soilResultGridIndex = findOrLoadScalarResult(RimDefines::DYNAMIC_NATIVE, "SOIL"); if (soilResultGridIndex == cvf::UNDEFINED_SIZE_T) { - soilResultGridIndex = m_cellResults->addEmptyScalarResult(RimDefines::DYNAMIC_NATIVE, "SOIL"); + soilResultGridIndex = m_cellResults->addEmptyScalarResult(RimDefines::DYNAMIC_NATIVE, "SOIL", false); CVF_ASSERT(soilResultGridIndex != cvf::UNDEFINED_SIZE_T); m_cellResults->cellScalarResults(soilResultGridIndex).resize(soilTimeStepCount); @@ -424,37 +462,37 @@ void RimReservoirCellResultsStorage::computeDepthRelatedResults() if (depthResultGridIndex == cvf::UNDEFINED_SIZE_T) { - depthResultGridIndex = m_cellResults->addStaticScalarResult(RimDefines::STATIC_NATIVE, "DEPTH", resultValueCount); + depthResultGridIndex = m_cellResults->addStaticScalarResult(RimDefines::STATIC_NATIVE, "DEPTH", false, resultValueCount); computeDepth = true; } if (dxResultGridIndex == cvf::UNDEFINED_SIZE_T) { - dxResultGridIndex = m_cellResults->addStaticScalarResult(RimDefines::STATIC_NATIVE, "DX", resultValueCount); + dxResultGridIndex = m_cellResults->addStaticScalarResult(RimDefines::STATIC_NATIVE, "DX", false, resultValueCount); computeDx = true; } if (dyResultGridIndex == cvf::UNDEFINED_SIZE_T) { - dyResultGridIndex = m_cellResults->addStaticScalarResult(RimDefines::STATIC_NATIVE, "DY", resultValueCount); + dyResultGridIndex = m_cellResults->addStaticScalarResult(RimDefines::STATIC_NATIVE, "DY", false, resultValueCount); computeDy = true; } if (dzResultGridIndex == cvf::UNDEFINED_SIZE_T) { - dzResultGridIndex = m_cellResults->addStaticScalarResult(RimDefines::STATIC_NATIVE, "DZ", resultValueCount); + dzResultGridIndex = m_cellResults->addStaticScalarResult(RimDefines::STATIC_NATIVE, "DZ", false, resultValueCount); computeDz = true; } if (topsResultGridIndex == cvf::UNDEFINED_SIZE_T) { - topsResultGridIndex = m_cellResults->addStaticScalarResult(RimDefines::STATIC_NATIVE, "TOPS", resultValueCount); + topsResultGridIndex = m_cellResults->addStaticScalarResult(RimDefines::STATIC_NATIVE, "TOPS", false, resultValueCount); computeTops = true; } if (bottomResultGridIndex == cvf::UNDEFINED_SIZE_T) { - bottomResultGridIndex = m_cellResults->addStaticScalarResult(RimDefines::STATIC_NATIVE, "BOTTOM", resultValueCount); + bottomResultGridIndex = m_cellResults->addStaticScalarResult(RimDefines::STATIC_NATIVE, "BOTTOM", false, resultValueCount); computeBottom = true; } @@ -539,6 +577,84 @@ size_t RimReservoirCellResultsStorage::findOrLoadScalarResult(const QString& res void RimReservoirCellResultsStorage::setCellResults(RigReservoirCellResults* cellResults) { m_cellResults = cellResults; + + if (m_cellResults == NULL) + return; + + // Now that we have got the results container, we can finally + // Read data from the internal storage and populate it + + if (m_resultCacheFileName().isEmpty()) + return; + + // Get the name of the cache name relative to the current project file position + QString newValidCacheFileName = getValidCacheFileName(); + + QFile storageFile(newValidCacheFileName); + + // Warn if we thought we were to find some data on the storage file + + if (!storageFile.exists() && m_resultCacheMetaData.size()) + { + qWarning() << "Reading stored results: Missing the storage file : " + newValidCacheFileName; + return; + } + + if (!storageFile.open(QIODevice::ReadOnly)) + { + qWarning() << "Reading stored results: Can't open the file : " + newValidCacheFileName; + return; + } + + QDataStream stream(&storageFile); + stream.setVersion(QDataStream::Qt_4_6); + quint32 magicNumber = 0; + quint32 versionNumber = 0; + stream >> magicNumber; + + if (magicNumber != 0xCEECAC4E) + { + qWarning() << "Reading stored results: The storage file has wrong type "; + return; + } + + stream >> versionNumber; + if (versionNumber > 1 ) + { + qWarning() << "Reading stored results: The storage file has been written by a newer version of ResInsight"; + return; + } + + caf::ProgressInfo progress(m_resultCacheMetaData.size(), "Reading internally stored results"); + // Fill the object with data from the storage + + for (size_t rIdx = 0; rIdx < m_resultCacheMetaData.size(); ++rIdx) + { + RimReservoirCellResultsStorageEntryInfo* resInfo = m_resultCacheMetaData[rIdx]; + size_t resultIndex = m_cellResults->addEmptyScalarResult(resInfo->m_resultType(), resInfo->m_resultName(), true); + + m_cellResults->setTimeStepDates(resultIndex, resInfo->m_timeStepDates()); + + progress.setProgressDescription(resInfo->m_resultName); + + for (size_t tsIdx = 0; tsIdx < resInfo->m_timeStepDates().size(); ++tsIdx) + { + std::vector* data = NULL; + + data = &(m_cellResults->cellScalarResults(rIdx, tsIdx)); + + quint64 cellCount = 0; + stream >> cellCount; + data->resize(cellCount, HUGE_VAL); + + for (size_t cIdx = 0; cIdx < cellCount; ++cIdx) + { + stream >> (*data)[cIdx]; + } + } + + progress.incrementProgress(); + } } //-------------------------------------------------------------------------------------------------- @@ -549,6 +665,14 @@ void RimReservoirCellResultsStorage::setMainGrid(RigMainGrid* mainGrid) m_ownerMainGrid = mainGrid; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t RimReservoirCellResultsStorage::storedResultsCount() +{ + return m_resultCacheMetaData.size(); +} + CAF_PDM_SOURCE_INIT(RimReservoirCellResultsStorageEntryInfo, "ResultStorageEntryInfo"); diff --git a/ApplicationCode/ProjectDataModel/RimReservoirCellResultsCacher.h b/ApplicationCode/ProjectDataModel/RimReservoirCellResultsCacher.h index 19141d7c6a..2351e6c54d 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoirCellResultsCacher.h +++ b/ApplicationCode/ProjectDataModel/RimReservoirCellResultsCacher.h @@ -36,35 +36,39 @@ public: RimReservoirCellResultsStorage(); virtual ~RimReservoirCellResultsStorage(); - // Fields - caf::PdmField m_resultCacheFileName; - caf::PdmPointersField - m_resultCacheMetaData; - + void setCellResults(RigReservoirCellResults* cellResults); RigReservoirCellResults* cellResults() { return m_cellResults; } const RigReservoirCellResults* cellResults() const { return m_cellResults; } - void setCellResults(RigReservoirCellResults* cellResults); + size_t storedResultsCount(); + void setMainGrid(RigMainGrid* mainGrid); void setReaderInterface(RifReaderInterface* readerInterface); RifReaderInterface* readerInterface(); void loadOrComputeSOIL(); - void loadOrComputeSOILForTimeStep(size_t timeStepIndex); void computeDepthRelatedResults(); size_t findOrLoadScalarResultForTimeStep(RimDefines::ResultCatType type, const QString& resultName, size_t timeStepIndex); size_t findOrLoadScalarResult(RimDefines::ResultCatType type, const QString& resultName); size_t findOrLoadScalarResult(const QString& resultName); ///< Simplified search. Assumes unique names across types. +protected: // Overridden methods from PdmObject virtual void setupBeforeSave(); private: + void loadOrComputeSOILForTimeStep(size_t timeStepIndex); + QString getValidCacheFileName(); QString getCacheDirectoryPath(); + // Fields + caf::PdmField m_resultCacheFileName; + caf::PdmPointersField + m_resultCacheMetaData; + cvf::ref m_readerInterface; RigReservoirCellResults* m_cellResults; RigMainGrid* m_ownerMainGrid; diff --git a/ApplicationCode/ProjectDataModel/RimResultReservoir.cpp b/ApplicationCode/ProjectDataModel/RimResultReservoir.cpp index b85640de6e..f2e9620587 100644 --- a/ApplicationCode/ProjectDataModel/RimResultReservoir.cpp +++ b/ApplicationCode/ProjectDataModel/RimResultReservoir.cpp @@ -145,7 +145,7 @@ bool RimResultReservoir::openAndReadActiveCellData(RigEclipseCase* mainEclipseCa CVF_ASSERT(this->reservoirData()); CVF_ASSERT(readerInterface.notNull()); - reservoirData()->computeCachedData(); + reservoirData()->computeActiveCellBoundingBoxes(); return true; } diff --git a/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.cpp b/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.cpp index 0212edbbdd..3a6827e17b 100644 --- a/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.cpp +++ b/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.cpp @@ -40,9 +40,6 @@ RimStatisticalCalculation::RimStatisticalCalculation() CAF_PDM_InitObject("Case Group Statistics", ":/Histogram16x16.png", "", ""); CAF_PDM_InitField(&m_resultName, "ResultName", QString("PRESSURE"), "ResultName", "", "", ""); - m_readerInterface = new RifReaderStatisticalCalculation; - - openEclipseGridFile(); } //-------------------------------------------------------------------------------------------------- @@ -74,16 +71,20 @@ bool RimStatisticalCalculation::openEclipseGridFile() cvf::ref eclipseCase = new RigEclipseCase; - if (!m_readerInterface->open("dummy", eclipseCase.p())) - { - return false; - } + CVF_ASSERT(parentStatisticalCollection()); + + RimIdenticalGridCaseGroup* gridCaseGroup = parentStatisticalCollection()->parentCaseGroup(); + CVF_ASSERT(gridCaseGroup); + + RigMainGrid* mainGrid = gridCaseGroup->mainGrid(); + + eclipseCase->setMainGrid(mainGrid); + + eclipseCase->setActiveCellInfo(RifReaderInterface::MATRIX_RESULTS, gridCaseGroup->unionOfActiveCells(RifReaderInterface::MATRIX_RESULTS)); + eclipseCase->setActiveCellInfo(RifReaderInterface::FRACTURE_RESULTS, gridCaseGroup->unionOfActiveCells(RifReaderInterface::FRACTURE_RESULTS)); this->setReservoirData( eclipseCase.p() ); - results(RifReaderInterface::MATRIX_RESULTS)->setReaderInterface(m_readerInterface.p()); - results(RifReaderInterface::FRACTURE_RESULTS)->setReaderInterface(m_readerInterface.p()); - return true; } @@ -150,11 +151,11 @@ void RimStatisticalCalculation::computeStatistics() QList > resultSpecification; - resultSpecification.append(qMakePair(RimDefines::DYNAMIC_NATIVE, QString("PRESSURE"))); + //resultSpecification.append(qMakePair(RimDefines::DYNAMIC_NATIVE, QString("PRESSURE"))); - /* + { - QStringList resultNames = sourceCases.at(0)->results(RifReaderInterface::MATRIX_RESULTS)->resultNames(RimDefines::DYNAMIC_NATIVE); + QStringList resultNames = sourceCases.at(0)->results(RifReaderInterface::MATRIX_RESULTS)->cellResults()->resultNames(RimDefines::DYNAMIC_NATIVE); foreach(QString resultName, resultNames) { resultSpecification.append(qMakePair(RimDefines::DYNAMIC_NATIVE, resultName)); @@ -162,13 +163,13 @@ void RimStatisticalCalculation::computeStatistics() } { - QStringList resultNames = sourceCases.at(0)->results(RifReaderInterface::MATRIX_RESULTS)->resultNames(RimDefines::STATIC_NATIVE); + QStringList resultNames = sourceCases.at(0)->results(RifReaderInterface::MATRIX_RESULTS)->cellResults()->resultNames(RimDefines::STATIC_NATIVE); foreach(QString resultName, resultNames) { resultSpecification.append(qMakePair(RimDefines::STATIC_NATIVE, resultName)); } } - */ + RigStatistics stat(sourceCases, timeStepIndices, statisticsConfig, resultCase); stat.evaluateStatistics(resultSpecification); diff --git a/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.cpp b/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.cpp index 7591d27798..545dc046fb 100644 --- a/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.cpp +++ b/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.cpp @@ -158,6 +158,19 @@ void RigActiveCellInfo::setMatrixActiveCellsGeometryBoundingBox(cvf::BoundingBox m_matrixActiveCellsBoundingBox = bb; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigActiveCellInfo::clear() +{ + m_perGridActiveCellInfo.clear(); + m_activeInMatrixModel.clear(); + m_globalMatrixModelActiveCellCount = 0; + m_activeCellPositionMin = cvf::Vec3st(0,0,0); + m_activeCellPositionMax = cvf::Vec3st(0,0,0); + m_matrixActiveCellsBoundingBox.reset(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.h b/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.h index 50ae9e1a34..abd01a5e76 100644 --- a/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.h +++ b/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.h @@ -51,6 +51,8 @@ public: cvf::BoundingBox matrixActiveCellsGeometryBoundingBox() const; void setMatrixActiveCellsGeometryBoundingBox(cvf::BoundingBox bb); + void clear(); + private: class GridActiveCellCounts { diff --git a/ApplicationCode/ReservoirDataModel/RigEclipseCase.cpp b/ApplicationCode/ReservoirDataModel/RigEclipseCase.cpp index dbfbdbdde8..6cdb533792 100644 --- a/ApplicationCode/ReservoirDataModel/RigEclipseCase.cpp +++ b/ApplicationCode/ReservoirDataModel/RigEclipseCase.cpp @@ -277,7 +277,7 @@ public: //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigEclipseCase::computeActiveCellData() +void RigEclipseCase::computeActiveCellIJKBBox() { CellRangeBB matrixModelActiveBB; CellRangeBB fractureModelActiveBB; @@ -306,9 +306,9 @@ void RigEclipseCase::computeActiveCellData() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigEclipseCase::computeCachedData() +void RigEclipseCase::computeActiveCellBoundingBoxes() { - computeActiveCellData(); + computeActiveCellIJKBBox(); computeActiveCellsGeometryBoundingBox(); } diff --git a/ApplicationCode/ReservoirDataModel/RigEclipseCase.h b/ApplicationCode/ReservoirDataModel/RigEclipseCase.h index 04d23400ec..c4ed2a5b46 100644 --- a/ApplicationCode/ReservoirDataModel/RigEclipseCase.h +++ b/ApplicationCode/ReservoirDataModel/RigEclipseCase.h @@ -59,20 +59,18 @@ public: size_t timeStepIndex, size_t scalarSetIndex); - void setWellResults(const cvf::Collection& data); + void setWellResults(const cvf::Collection& data); const cvf::Collection& wellResults() { return m_wellResults; } - cvf::UByteArray* wellCellsInGrid(size_t gridIndex); RigCell& cellFromWellResultCell(const RigWellResultCell& wellResultCell); bool findSharedSourceFace(cvf::StructGridInterface::FaceType& sharedSourceFace, const RigWellResultCell& sourceWellCellResult, const RigWellResultCell& otherWellCellResult) const; - void computeCachedData(); - //void closeReaderInterface(); + void computeActiveCellBoundingBoxes(); private: - void computeActiveCellData(); + void computeActiveCellIJKBBox(); void computeWellCellsPrGrid(); void computeActiveCellsGeometryBoundingBox(); diff --git a/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.cpp b/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.cpp index 7f5089a86d..4ee9d29606 100644 --- a/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.cpp +++ b/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.cpp @@ -337,7 +337,7 @@ size_t RigReservoirCellResults::findScalarResultIndex(const QString& resultName) /// Adds an empty scalar set, and returns the scalarResultIndex to it. /// if resultName already exists, it returns the scalarResultIndex to the existing result. //-------------------------------------------------------------------------------------------------- -size_t RigReservoirCellResults::addEmptyScalarResult(RimDefines::ResultCatType type, const QString& resultName) +size_t RigReservoirCellResults::addEmptyScalarResult(RimDefines::ResultCatType type, const QString& resultName, bool needsToBeStored) { size_t scalarResultIndex = cvf::UNDEFINED_SIZE_T; @@ -346,7 +346,7 @@ size_t RigReservoirCellResults::addEmptyScalarResult(RimDefines::ResultCatType t { scalarResultIndex = this->resultCount(); m_cellScalarResults.push_back(std::vector >()); - ResultInfo resInfo(type, resultName, scalarResultIndex); + ResultInfo resInfo(type, needsToBeStored, resultName, scalarResultIndex); m_resultInfos.push_back(resInfo); } @@ -435,9 +435,8 @@ void RigReservoirCellResults::setTimeStepDates(size_t scalarResultIndex, const s m_resultInfos[scalarResultIndex].m_timeStepDates = dates; - // We need this. But not yet ... - //std::vector< std::vector >& dataValues = this->cellScalarResults(scalarResultIndex); - //dataValues.resize(dates.size()); + std::vector< std::vector >& dataValues = this->cellScalarResults(scalarResultIndex); + dataValues.resize(dates.size()); } //-------------------------------------------------------------------------------------------------- @@ -517,9 +516,9 @@ void RigReservoirCellResults::clearAllResults() //-------------------------------------------------------------------------------------------------- /// Add a result with given type and name, and allocate one result vector for the static result values //-------------------------------------------------------------------------------------------------- -size_t RigReservoirCellResults::addStaticScalarResult(RimDefines::ResultCatType type, const QString& resultName, size_t resultValueCount) +size_t RigReservoirCellResults::addStaticScalarResult(RimDefines::ResultCatType type, const QString& resultName, bool needsToBeStored, size_t resultValueCount) { - size_t resultIdx = addEmptyScalarResult(type, resultName); + size_t resultIdx = addEmptyScalarResult(type, resultName, needsToBeStored); m_cellScalarResults[resultIdx].push_back(std::vector()); m_cellScalarResults[resultIdx][0].resize(resultValueCount, HUGE_VAL); diff --git a/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.h b/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.h index 7e624b29bf..6fa3caca61 100644 --- a/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.h +++ b/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.h @@ -35,10 +35,7 @@ class RigReservoirCellResults : public cvf::Object public: RigReservoirCellResults(RigMainGrid* ownerGrid); - //void setReaderInterface(RifReaderInterface* readerInterface); - //RifReaderInterface* readerInterface(); - - void setMainGrid(RigMainGrid* ownerGrid); + void setMainGrid(RigMainGrid* ownerGrid); // Max and min values of the results void recalculateMinMax(size_t scalarResultIndex); @@ -64,14 +61,14 @@ public: size_t findScalarResultIndex(RimDefines::ResultCatType type, const QString& resultName) const; size_t findScalarResultIndex(const QString& resultName) const; - size_t addEmptyScalarResult(RimDefines::ResultCatType type, const QString& resultName); + size_t addEmptyScalarResult(RimDefines::ResultCatType type, const QString& resultName, bool needsToBeStored); QString makeResultNameUnique(const QString& resultNameProposal) const; void removeResult(const QString& resultName); void clearAllResults(); - // Access the results data + const std::vector< std::vector > & cellScalarResults(size_t scalarResultIndex) const; std::vector< std::vector > & cellScalarResults(size_t scalarResultIndex); std::vector& cellScalarResults(size_t scalarResultIndex, size_t timeStepIndex); @@ -83,14 +80,15 @@ public: class ResultInfo { public: - ResultInfo(RimDefines::ResultCatType resultType, QString resultName, size_t gridScalarResultIndex) - : m_resultType(resultType), m_resultName(resultName), m_gridScalarResultIndex(gridScalarResultIndex) { } + ResultInfo(RimDefines::ResultCatType resultType, bool needsToBeStored, QString resultName, size_t gridScalarResultIndex) + : m_resultType(resultType), m_needsToBeStored(needsToBeStored), m_resultName(resultName), m_gridScalarResultIndex(gridScalarResultIndex) { } public: RimDefines::ResultCatType m_resultType; + bool m_needsToBeStored; QString m_resultName; size_t m_gridScalarResultIndex; - std::vector m_timeStepDates; + std::vector m_timeStepDates; }; const std::vector& infoForEachResultIndex() { return m_resultInfos;} @@ -98,6 +96,7 @@ public: public: size_t addStaticScalarResult(RimDefines::ResultCatType type, const QString& resultName, + bool needsToBeStored, size_t resultValueCount); private: diff --git a/ApplicationCode/SocketInterface/RiaSocketServer.cpp b/ApplicationCode/SocketInterface/RiaSocketServer.cpp index 04c123c1e1..e48ab7b3f5 100644 --- a/ApplicationCode/SocketInterface/RiaSocketServer.cpp +++ b/ApplicationCode/SocketInterface/RiaSocketServer.cpp @@ -286,7 +286,7 @@ void RiaSocketServer::readCommandFromOctave() if (scalarResultIndex == cvf::UNDEFINED_SIZE_T && isSetProperty) { - scalarResultIndex = reservoir->results(RifReaderInterface::MATRIX_RESULTS)->cellResults()->addEmptyScalarResult(RimDefines::GENERATED, propertyName); + scalarResultIndex = reservoir->results(RifReaderInterface::MATRIX_RESULTS)->cellResults()->addEmptyScalarResult(RimDefines::GENERATED, propertyName, true); } if (scalarResultIndex != cvf::UNDEFINED_SIZE_T)