Fix for executing a script on result cases with no view

This commit is contained in:
Magne Sjaastad 2014-10-23 11:41:28 +02:00
parent 2509fa974f
commit 3b7919a913
3 changed files with 59 additions and 24 deletions

View File

@ -32,6 +32,7 @@
#include "RimResultCase.h"
#include "RimResultSlot.h"
#include "RimStatisticsCase.h"
#include "RigCaseCellResultsData.h"
#include "cafProgressInfo.h"
@ -203,6 +204,42 @@ void RimIdenticalGridCaseGroup::loadMainCaseAndActiveCellInfo()
computeUnionOfActiveCells();
}
// Propagate result meta data to all cases
{
RifReaderInterface::PorosityModelResultType poroModel = RifReaderInterface::MATRIX_RESULTS;
std::vector<QDateTime> timeStepDates = mainEclipseCase->results(poroModel)->timeStepDates(0);
const std::vector<RigCaseCellResultsData::ResultInfo> resultInfos = mainEclipseCase->results(poroModel)->infoForEachResultIndex();
for (size_t i = 1; i < caseCollection()->reservoirs.size(); i++)
{
RimResultCase* rimReservoir = dynamic_cast<RimResultCase*>(caseCollection()->reservoirs[i]);
if (!rimReservoir) continue; // Input reservoir
RimReservoirCellResultsStorage* cellResultsStorage = rimReservoir->results(poroModel);
for (size_t resIdx = 0; resIdx < resultInfos.size(); resIdx++)
{
RimDefines::ResultCatType resultType = resultInfos[resIdx].m_resultType;
QString resultName = resultInfos[resIdx].m_resultName;
bool needsToBeStored = resultInfos[resIdx].m_needsToBeStored;
size_t scalarResultIndex = cellResultsStorage->cellResults()->findScalarResultIndex(resultType, resultName);
if (scalarResultIndex == cvf::UNDEFINED_SIZE_T)
{
size_t scalarResultIndex = cellResultsStorage->cellResults()->addEmptyScalarResult(resultType, resultName, needsToBeStored);
cellResultsStorage->cellResults()->setTimeStepDates(scalarResultIndex, timeStepDates);
std::vector< std::vector<double> >& dataValues = cellResultsStorage->cellResults()->cellScalarResults(scalarResultIndex);
dataValues.resize(timeStepDates.size());
}
}
cellResultsStorage->cellResults()->createPlaceholderResultEntries();
}
}
// "Load" the statistical cases
for (size_t i = 0; i < statisticsCaseCollection()->reservoirs.size(); i++)

View File

@ -109,28 +109,28 @@ void RimStatisticsCaseEvaluator::evaluateForResults(const QList<ResSpec>& result
size_t activeCellCount = m_destinationCase->activeCellInfo(poroModel)->reservoirActiveCellCount();
RigCaseCellResultsData* destCellResultsData = m_destinationCase->results(poroModel);
// Special handling if SOIL is asked for
// Build SGAS/SWAT meta data, SOIL is automatically generated as part of RigCaseCellResultsData::findOrLoadScalarResultForTimeStep
if (resultName.toUpper() == "SOIL")
{
size_t swatIndex = m_sourceCases.at(0)->results(poroModel)->cellResults()->findScalarResultIndex(resultType, "SWAT");
if (swatIndex != cvf::UNDEFINED_SIZE_T)
{
buildSourceMetaData(poroModel, resultType, "SWAT");
}
size_t sgasIndex = m_sourceCases.at(0)->results(poroModel)->cellResults()->findScalarResultIndex(resultType, "SGAS");
if (sgasIndex != cvf::UNDEFINED_SIZE_T)
{
buildSourceMetaData(poroModel, resultType, "SGAS");
}
}
else
{
// Meta info is loaded from disk for first case only
// Build metadata for all other source cases
buildSourceMetaData(poroModel, resultType, resultName);
}
// // Special handling if SOIL is asked for
// // Build SGAS/SWAT meta data, SOIL is automatically generated as part of RigCaseCellResultsData::findOrLoadScalarResultForTimeStep
// if (resultName.toUpper() == "SOIL")
// {
// size_t swatIndex = m_sourceCases.at(0)->results(poroModel)->cellResults()->findScalarResultIndex(resultType, "SWAT");
// if (swatIndex != cvf::UNDEFINED_SIZE_T)
// {
// buildSourceMetaData(poroModel, resultType, "SWAT");
// }
//
// size_t sgasIndex = m_sourceCases.at(0)->results(poroModel)->cellResults()->findScalarResultIndex(resultType, "SGAS");
// if (sgasIndex != cvf::UNDEFINED_SIZE_T)
// {
// buildSourceMetaData(poroModel, resultType, "SGAS");
// }
// }
// else
// {
// // Meta info is loaded from disk for first case only
// // Build metadata for all other source cases
// buildSourceMetaData(poroModel, resultType, resultName);
// }
// Create new result data structures to contain the statistical values
std::vector<QString> statisticalResultNames;

View File

@ -404,8 +404,6 @@ RimReservoirView* RimUiTreeModelPdm::addReservoirView(const QModelIndex& itemInd
if (collectionItem)
{
RimCase* rimReservoir = dynamic_cast<RimCase*>(collectionItem->dataObject().p());
rimReservoir->openEclipseGridFile();
RimReservoirView* insertedView = rimReservoir->createAndAddReservoirView();
// Must be run before buildViewItems, as wells are created in this function