Calculate statistics for all available properties in main case by default

p4#: 20832
This commit is contained in:
Jacob Støren 2013-03-08 10:49:33 +01:00
parent 9605a1eec9
commit 0a5102894b
3 changed files with 46 additions and 29 deletions

View File

@ -136,11 +136,13 @@ void RimStatisticalCalculation::computeStatistics()
return; return;
} }
// The first source has been read completely from disk, and contains grid and meta data
// Use this information for all cases in the case group
size_t timeStepCount = sourceCases.at(0)->results(RifReaderInterface::MATRIX_RESULTS)->maxTimeStepCount();
RigStatisticsConfig statisticsConfig; RigStatisticsConfig statisticsConfig;
std::vector<size_t> timeStepIndices; std::vector<size_t> timeStepIndices;
size_t timeStepCount = sourceCases.at(0)->results(RifReaderInterface::MATRIX_RESULTS)->maxTimeStepCount();
for (size_t i = 0; i < timeStepCount; i++) for (size_t i = 0; i < timeStepCount; i++)
{ {
timeStepIndices.push_back(i); timeStepIndices.push_back(i);
@ -149,7 +151,9 @@ void RimStatisticalCalculation::computeStatistics()
RigEclipseCase* resultCase = reservoirData(); RigEclipseCase* resultCase = reservoirData();
RigStatistics stat(sourceCases, timeStepIndices, statisticsConfig, resultCase); RigStatistics stat(sourceCases, timeStepIndices, statisticsConfig, resultCase);
stat.evaluateStatistics(RimDefines::DYNAMIC_NATIVE, m_resultName); QStringList resultNames = sourceCases.at(0)->results(RifReaderInterface::MATRIX_RESULTS)->resultNames(RimDefines::DYNAMIC_NATIVE);
stat.evaluateStatistics(RimDefines::DYNAMIC_NATIVE, resultNames);
for (size_t i = 0; i < reservoirViews().size(); i++) for (size_t i = 0; i < reservoirViews().size(); i++)
{ {
@ -159,6 +163,7 @@ void RimStatisticalCalculation::computeStatistics()
reservoirView->scheduleGeometryRegen(RivReservoirViewPartMgr::ACTIVE); reservoirView->scheduleGeometryRegen(RivReservoirViewPartMgr::ACTIVE);
reservoirView->createDisplayModelAndRedraw(); reservoirView->createDisplayModelAndRedraw();
} }
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@ -71,28 +71,28 @@ void RigStatistics::computeActiveCellUnion()
std::vector<char> activeF(grid->cellCount(), 0); std::vector<char> activeF(grid->cellCount(), 0);
for (size_t localGridCellIdx = 0; localGridCellIdx < grid->cellCount(); localGridCellIdx++) for (size_t localGridCellIdx = 0; localGridCellIdx < grid->cellCount(); localGridCellIdx++)
{
for (size_t caseIdx = 0; caseIdx < m_sourceCases.size(); caseIdx++)
{ {
for (size_t caseIdx = 0; caseIdx < m_sourceCases.size(); caseIdx++)
{
size_t globalCellIdx = grid->globalGridCellIndex(localGridCellIdx); size_t globalCellIdx = grid->globalGridCellIndex(localGridCellIdx);
if (activeM[localGridCellIdx] == 0) if (activeM[localGridCellIdx] == 0)
{ {
if (m_sourceCases[caseIdx]->activeCellInfo()->isActiveInMatrixModel(globalCellIdx)) if (m_sourceCases[caseIdx]->activeCellInfo()->isActiveInMatrixModel(globalCellIdx))
{ {
activeM[localGridCellIdx] = 1; activeM[localGridCellIdx] = 1;
}
} }
}
if (activeF[localGridCellIdx] == 0) if (activeF[localGridCellIdx] == 0)
{ {
if (m_sourceCases[caseIdx]->activeCellInfo()->isActiveInFractureModel(globalCellIdx)) if (m_sourceCases[caseIdx]->activeCellInfo()->isActiveInFractureModel(globalCellIdx))
{ {
activeF[localGridCellIdx] = 1; activeF[localGridCellIdx] = 1;
}
} }
} }
} }
}
size_t activeMatrixIndex = 0; size_t activeMatrixIndex = 0;
size_t activeFractureIndex = 0; size_t activeFractureIndex = 0;
@ -102,17 +102,17 @@ void RigStatistics::computeActiveCellUnion()
size_t globalCellIdx = grid->globalGridCellIndex(localGridCellIdx); size_t globalCellIdx = grid->globalGridCellIndex(localGridCellIdx);
if (activeM[localGridCellIdx] != 0) if (activeM[localGridCellIdx] != 0)
{ {
m_destinationCase->activeCellInfo()->setActiveIndexInMatrixModel(globalCellIdx, globalActiveMatrixIndex++); m_destinationCase->activeCellInfo()->setActiveIndexInMatrixModel(globalCellIdx, globalActiveMatrixIndex++);
activeMatrixIndex++; activeMatrixIndex++;
} }
if (activeF[localGridCellIdx] != 0) if (activeF[localGridCellIdx] != 0)
{ {
m_destinationCase->activeCellInfo()->setActiveIndexInFractureModel(globalCellIdx, globalActiveFractureIndex++); m_destinationCase->activeCellInfo()->setActiveIndexInFractureModel(globalCellIdx, globalActiveFractureIndex++);
activeFractureIndex++; activeFractureIndex++;
}
} }
}
m_destinationCase->activeCellInfo()->setGridActiveCellCounts(gridIdx, activeMatrixIndex, activeFractureIndex); m_destinationCase->activeCellInfo()->setGridActiveCellCounts(gridIdx, activeMatrixIndex, activeFractureIndex);
} }
@ -121,25 +121,33 @@ void RigStatistics::computeActiveCellUnion()
m_destinationCase->computeCachedData(); m_destinationCase->computeCachedData();
} }
QString createResultNameMin(const QString& resultName) { return resultName + "_MIN"; }
QString createResultNameMax(const QString& resultName) { return resultName + "_MAX"; }
QString createResultNameMean(const QString& resultName) { return resultName + "_MEAN"; }
QString createResultNameDev(const QString& resultName) { return resultName + "_DEV"; }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RigStatistics::evaluateStatistics(RimDefines::ResultCatType resultType, const QString& resultName) void RigStatistics::evaluateStatistics(RimDefines::ResultCatType resultType, const QStringList& resultNames)
{ {
CVF_ASSERT(m_destinationCase.notNull()); CVF_ASSERT(m_destinationCase.notNull());
computeActiveCellUnion(); computeActiveCellUnion();
buildSourceMetaData(resultType, resultName); size_t activeMatrixCellCount = m_destinationCase->activeCellInfo()->globalMatrixModelActiveCellCount();
QString minResultName = resultName + "_MIN";
QString maxResultName = resultName + "_MAX";
QString meanResultName = resultName + "_MEAN";
QString devResultName = resultName + "_DEV";
RigReservoirCellResults* matrixResults = m_destinationCase->results(RifReaderInterface::MATRIX_RESULTS); RigReservoirCellResults* matrixResults = m_destinationCase->results(RifReaderInterface::MATRIX_RESULTS);
size_t activeMatrixCellCount = m_destinationCase->activeCellInfo()->globalMatrixModelActiveCellCount(); foreach(QString resultName, resultNames)
{
buildSourceMetaData(resultType, resultName);
QString minResultName = createResultNameMin(resultName);
QString maxResultName = createResultNameMax(resultName);
QString meanResultName = createResultNameMean(resultName);
QString devResultName = createResultNameDev(resultName);
if (activeMatrixCellCount > 0) if (activeMatrixCellCount > 0)
{ {
addNamedResult(matrixResults, resultType, minResultName, activeMatrixCellCount); addNamedResult(matrixResults, resultType, minResultName, activeMatrixCellCount);
@ -147,6 +155,7 @@ void RigStatistics::evaluateStatistics(RimDefines::ResultCatType resultType, con
addNamedResult(matrixResults, resultType, meanResultName, activeMatrixCellCount); addNamedResult(matrixResults, resultType, meanResultName, activeMatrixCellCount);
addNamedResult(matrixResults, resultType, devResultName, activeMatrixCellCount); addNamedResult(matrixResults, resultType, devResultName, activeMatrixCellCount);
} }
}
if (activeMatrixCellCount > 0) if (activeMatrixCellCount > 0)
{ {
@ -161,6 +170,8 @@ void RigStatistics::evaluateStatistics(RimDefines::ResultCatType resultType, con
{ {
RigGridBase* grid = m_destinationCase->grid(gridIdx); RigGridBase* grid = m_destinationCase->grid(gridIdx);
foreach(QString resultName, resultNames)
{
// Build data access objects for source scalar results // Build data access objects for source scalar results
cvf::Collection<cvf::StructGridScalarDataAccess> dataAccesObjectList; cvf::Collection<cvf::StructGridScalarDataAccess> dataAccesObjectList;
for (size_t caseIdx = 0; caseIdx < m_sourceCases.size(); caseIdx++) for (size_t caseIdx = 0; caseIdx < m_sourceCases.size(); caseIdx++)
@ -183,7 +194,7 @@ void RigStatistics::evaluateStatistics(RimDefines::ResultCatType resultType, con
cvf::ref<cvf::StructGridScalarDataAccess> dataAccessObjectDev = NULL; cvf::ref<cvf::StructGridScalarDataAccess> dataAccessObjectDev = NULL;
{ {
size_t scalarResultIndex = matrixResults->findScalarResultIndex(RimDefines::DYNAMIC_NATIVE, minResultName); size_t scalarResultIndex = matrixResults->findScalarResultIndex(RimDefines::DYNAMIC_NATIVE, createResultNameMin(resultName));
if (scalarResultIndex != cvf::UNDEFINED_SIZE_T) if (scalarResultIndex != cvf::UNDEFINED_SIZE_T)
{ {
dataAccessObjectMin = m_destinationCase->dataAccessObject(grid, RifReaderInterface::MATRIX_RESULTS, timeStepIdx, scalarResultIndex); dataAccessObjectMin = m_destinationCase->dataAccessObject(grid, RifReaderInterface::MATRIX_RESULTS, timeStepIdx, scalarResultIndex);
@ -191,7 +202,7 @@ void RigStatistics::evaluateStatistics(RimDefines::ResultCatType resultType, con
} }
{ {
size_t scalarResultIndex = matrixResults->findScalarResultIndex(RimDefines::DYNAMIC_NATIVE, maxResultName); size_t scalarResultIndex = matrixResults->findScalarResultIndex(RimDefines::DYNAMIC_NATIVE, createResultNameMax(resultName));
if (scalarResultIndex != cvf::UNDEFINED_SIZE_T) if (scalarResultIndex != cvf::UNDEFINED_SIZE_T)
{ {
dataAccessObjectMax = m_destinationCase->dataAccessObject(grid, RifReaderInterface::MATRIX_RESULTS, timeStepIdx, scalarResultIndex); dataAccessObjectMax = m_destinationCase->dataAccessObject(grid, RifReaderInterface::MATRIX_RESULTS, timeStepIdx, scalarResultIndex);
@ -199,7 +210,7 @@ void RigStatistics::evaluateStatistics(RimDefines::ResultCatType resultType, con
} }
{ {
size_t scalarResultIndex = matrixResults->findScalarResultIndex(RimDefines::DYNAMIC_NATIVE, meanResultName); size_t scalarResultIndex = matrixResults->findScalarResultIndex(RimDefines::DYNAMIC_NATIVE, createResultNameMean(resultName));
if (scalarResultIndex != cvf::UNDEFINED_SIZE_T) if (scalarResultIndex != cvf::UNDEFINED_SIZE_T)
{ {
dataAccessObjectMean = m_destinationCase->dataAccessObject(grid, RifReaderInterface::MATRIX_RESULTS, timeStepIdx, scalarResultIndex); dataAccessObjectMean = m_destinationCase->dataAccessObject(grid, RifReaderInterface::MATRIX_RESULTS, timeStepIdx, scalarResultIndex);
@ -207,7 +218,7 @@ void RigStatistics::evaluateStatistics(RimDefines::ResultCatType resultType, con
} }
{ {
size_t scalarResultIndex = matrixResults->findScalarResultIndex(RimDefines::DYNAMIC_NATIVE, devResultName); size_t scalarResultIndex = matrixResults->findScalarResultIndex(RimDefines::DYNAMIC_NATIVE, createResultNameDev(resultName));
if (scalarResultIndex != cvf::UNDEFINED_SIZE_T) if (scalarResultIndex != cvf::UNDEFINED_SIZE_T)
{ {
dataAccessObjectDev = m_destinationCase->dataAccessObject(grid, RifReaderInterface::MATRIX_RESULTS, timeStepIdx, scalarResultIndex); dataAccessObjectDev = m_destinationCase->dataAccessObject(grid, RifReaderInterface::MATRIX_RESULTS, timeStepIdx, scalarResultIndex);
@ -252,6 +263,7 @@ void RigStatistics::evaluateStatistics(RimDefines::ResultCatType resultType, con
} }
} }
} }
}
for (size_t caseIdx = 0; caseIdx < m_sourceCases.size(); caseIdx++) for (size_t caseIdx = 0; caseIdx < m_sourceCases.size(); caseIdx++)
{ {

View File

@ -128,7 +128,7 @@ public:
RigEclipseCase* destinationCase); RigEclipseCase* destinationCase);
void evaluateStatistics(RimDefines::ResultCatType resultType, const QString& resultName); void evaluateStatistics(RimDefines::ResultCatType resultType, const QStringList& resultNames);
void debugOutput(RimDefines::ResultCatType resultType, const QString& resultName, size_t timeStepIdx); void debugOutput(RimDefines::ResultCatType resultType, const QString& resultName, size_t timeStepIdx);