2013-02-14 08:27:35 -06:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS
|
|
|
|
//
|
|
|
|
// ResInsight is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
//
|
|
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include "RIStdInclude.h"
|
|
|
|
|
|
|
|
#include "RimStatisticalCalculation.h"
|
|
|
|
#include "RimReservoirView.h"
|
2013-02-15 01:44:45 -06:00
|
|
|
#include "cafPdmUiOrdering.h"
|
|
|
|
#include "RimIdenticalGridCaseGroup.h"
|
2013-02-21 01:48:26 -06:00
|
|
|
#include "RigEclipseCase.h"
|
|
|
|
#include "RigReservoirCellResults.h"
|
2013-03-02 08:32:38 -06:00
|
|
|
#include "RigStatistics.h"
|
|
|
|
#include "RigMainGrid.h"
|
2013-02-14 08:27:35 -06:00
|
|
|
|
|
|
|
|
2013-03-22 04:03:51 -05:00
|
|
|
CAF_PDM_SOURCE_INIT(RimStatisticsCase, "RimStatisticalCalculation");
|
2013-02-14 08:27:35 -06:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-03-22 04:03:51 -05:00
|
|
|
RimStatisticsCase::RimStatisticsCase()
|
2013-02-14 08:27:35 -06:00
|
|
|
: RimReservoir()
|
|
|
|
{
|
2013-03-07 09:47:42 -06:00
|
|
|
CAF_PDM_InitObject("Case Group Statistics", ":/Histogram16x16.png", "", "");
|
2013-03-02 08:32:38 -06:00
|
|
|
CAF_PDM_InitField(&m_resultName, "ResultName", QString("PRESSURE"), "ResultName", "", "", "");
|
|
|
|
|
2013-02-14 08:27:35 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-03-22 04:03:51 -05:00
|
|
|
RimStatisticsCase::~RimStatisticsCase()
|
2013-02-14 08:27:35 -06:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-03-02 08:32:38 -06:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-03-22 04:03:51 -05:00
|
|
|
void RimStatisticsCase::setMainGrid(RigMainGrid* mainGrid)
|
2013-03-02 08:32:38 -06:00
|
|
|
{
|
|
|
|
CVF_ASSERT(mainGrid);
|
2013-03-18 08:34:29 -05:00
|
|
|
CVF_ASSERT(this->reservoirData());
|
2013-03-02 08:32:38 -06:00
|
|
|
|
2013-03-18 08:34:29 -05:00
|
|
|
reservoirData()->setMainGrid(mainGrid);
|
2013-03-02 08:32:38 -06:00
|
|
|
}
|
|
|
|
|
2013-02-14 08:27:35 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-03-22 04:03:51 -05:00
|
|
|
bool RimStatisticsCase::openEclipseGridFile()
|
2013-02-14 08:27:35 -06:00
|
|
|
{
|
2013-03-18 08:34:29 -05:00
|
|
|
if (this->reservoirData()) return true;
|
2013-03-02 08:32:38 -06:00
|
|
|
|
2013-02-21 01:48:26 -06:00
|
|
|
cvf::ref<RigEclipseCase> eclipseCase = new RigEclipseCase;
|
|
|
|
|
2013-03-22 04:03:51 -05:00
|
|
|
CVF_ASSERT(parentStatisticsCaseCollection());
|
2013-03-21 09:31:47 -05:00
|
|
|
|
2013-03-22 04:03:51 -05:00
|
|
|
RimIdenticalGridCaseGroup* gridCaseGroup = parentStatisticsCaseCollection()->parentCaseGroup();
|
2013-03-21 09:31:47 -05:00
|
|
|
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));
|
2013-02-21 01:48:26 -06:00
|
|
|
|
2013-03-18 08:34:29 -05:00
|
|
|
this->setReservoirData( eclipseCase.p() );
|
2013-02-21 01:48:26 -06:00
|
|
|
|
2013-02-14 08:27:35 -06:00
|
|
|
return true;
|
|
|
|
}
|
2013-02-15 01:44:45 -06:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-03-22 04:03:51 -05:00
|
|
|
void RimStatisticsCase::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) const
|
2013-02-15 01:44:45 -06:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-03-22 04:03:51 -05:00
|
|
|
RimStatisticsCaseCollection* RimStatisticsCase::parentStatisticsCaseCollection()
|
2013-02-15 01:44:45 -06:00
|
|
|
{
|
2013-03-22 04:03:51 -05:00
|
|
|
std::vector<RimStatisticsCaseCollection*> parentObjects;
|
2013-03-13 07:51:26 -05:00
|
|
|
this->parentObjectsOfType(parentObjects);
|
2013-02-15 01:44:45 -06:00
|
|
|
|
2013-03-13 07:51:26 -05:00
|
|
|
if (parentObjects.size() > 0)
|
2013-02-15 01:44:45 -06:00
|
|
|
{
|
2013-03-13 07:51:26 -05:00
|
|
|
return parentObjects[0];
|
2013-02-15 01:44:45 -06:00
|
|
|
}
|
|
|
|
|
2013-03-13 07:51:26 -05:00
|
|
|
return NULL;
|
2013-02-15 01:44:45 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-03-22 04:03:51 -05:00
|
|
|
void RimStatisticsCase::computeStatistics()
|
2013-02-15 01:44:45 -06:00
|
|
|
{
|
2013-03-18 08:34:29 -05:00
|
|
|
if (this->reservoirData() == NULL)
|
2013-02-15 01:44:45 -06:00
|
|
|
{
|
2013-03-02 08:32:38 -06:00
|
|
|
openEclipseGridFile();
|
2013-02-15 01:44:45 -06:00
|
|
|
}
|
|
|
|
|
2013-03-21 04:31:58 -05:00
|
|
|
RimIdenticalGridCaseGroup* gridCaseGroup = caseGroup();
|
|
|
|
CVF_ASSERT(gridCaseGroup);
|
|
|
|
gridCaseGroup->computeUnionOfActiveCells();
|
|
|
|
|
2013-03-18 08:34:29 -05:00
|
|
|
std::vector<RimReservoir*> sourceCases;
|
2013-02-15 01:44:45 -06:00
|
|
|
|
2013-03-02 08:32:38 -06:00
|
|
|
getSourceCases(sourceCases);
|
|
|
|
|
|
|
|
if (sourceCases.size() == 0)
|
2013-02-15 01:44:45 -06:00
|
|
|
{
|
2013-03-02 08:32:38 -06:00
|
|
|
return;
|
2013-02-15 01:44:45 -06:00
|
|
|
}
|
2013-03-02 08:32:38 -06:00
|
|
|
|
2013-03-08 03:49:33 -06:00
|
|
|
// 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
|
2013-03-18 08:34:29 -05:00
|
|
|
size_t timeStepCount = sourceCases.at(0)->results(RifReaderInterface::MATRIX_RESULTS)->cellResults()->maxTimeStepCount();
|
2013-03-08 03:49:33 -06:00
|
|
|
|
2013-03-22 04:03:51 -05:00
|
|
|
RimStatisticsConfig statisticsConfig;
|
2013-03-02 08:32:38 -06:00
|
|
|
|
|
|
|
std::vector<size_t> timeStepIndices;
|
2013-03-05 06:10:26 -06:00
|
|
|
for (size_t i = 0; i < timeStepCount; i++)
|
|
|
|
{
|
|
|
|
timeStepIndices.push_back(i);
|
|
|
|
}
|
2013-03-02 08:32:38 -06:00
|
|
|
|
|
|
|
RigEclipseCase* resultCase = reservoirData();
|
|
|
|
|
2013-03-13 01:58:49 -05:00
|
|
|
QList<QPair<RimDefines::ResultCatType, QString> > resultSpecification;
|
|
|
|
|
2013-03-21 09:31:47 -05:00
|
|
|
//resultSpecification.append(qMakePair(RimDefines::DYNAMIC_NATIVE, QString("PRESSURE")));
|
2013-03-13 07:51:26 -05:00
|
|
|
|
2013-03-21 09:31:47 -05:00
|
|
|
|
2013-03-13 01:58:49 -05:00
|
|
|
{
|
2013-03-21 09:31:47 -05:00
|
|
|
QStringList resultNames = sourceCases.at(0)->results(RifReaderInterface::MATRIX_RESULTS)->cellResults()->resultNames(RimDefines::DYNAMIC_NATIVE);
|
2013-03-13 01:58:49 -05:00
|
|
|
foreach(QString resultName, resultNames)
|
|
|
|
{
|
|
|
|
resultSpecification.append(qMakePair(RimDefines::DYNAMIC_NATIVE, resultName));
|
|
|
|
}
|
|
|
|
}
|
2013-03-08 03:49:33 -06:00
|
|
|
|
2013-03-13 01:58:49 -05:00
|
|
|
{
|
2013-03-21 09:31:47 -05:00
|
|
|
QStringList resultNames = sourceCases.at(0)->results(RifReaderInterface::MATRIX_RESULTS)->cellResults()->resultNames(RimDefines::STATIC_NATIVE);
|
2013-03-13 01:58:49 -05:00
|
|
|
foreach(QString resultName, resultNames)
|
|
|
|
{
|
|
|
|
resultSpecification.append(qMakePair(RimDefines::STATIC_NATIVE, resultName));
|
|
|
|
}
|
|
|
|
}
|
2013-03-21 09:31:47 -05:00
|
|
|
|
2013-03-13 01:58:49 -05:00
|
|
|
|
2013-03-22 04:03:51 -05:00
|
|
|
RimStatisticsCaseEvaluator stat(sourceCases, timeStepIndices, statisticsConfig, resultCase);
|
|
|
|
stat.evaluateForResults(resultSpecification);
|
2013-03-07 07:57:28 -06:00
|
|
|
|
|
|
|
for (size_t i = 0; i < reservoirViews().size(); i++)
|
|
|
|
{
|
|
|
|
RimReservoirView* reservoirView = reservoirViews()[i];
|
|
|
|
CVF_ASSERT(reservoirView);
|
|
|
|
|
|
|
|
reservoirView->scheduleGeometryRegen(RivReservoirViewPartMgr::ACTIVE);
|
|
|
|
reservoirView->createDisplayModelAndRedraw();
|
|
|
|
}
|
2013-03-08 03:49:33 -06:00
|
|
|
|
2013-02-15 01:44:45 -06:00
|
|
|
}
|
|
|
|
|
2013-03-02 08:32:38 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-03-22 04:03:51 -05:00
|
|
|
void RimStatisticsCase::getSourceCases(std::vector<RimReservoir*>& sourceCases)
|
2013-03-02 08:32:38 -06:00
|
|
|
{
|
|
|
|
RimIdenticalGridCaseGroup* gridCaseGroup = caseGroup();
|
|
|
|
if (gridCaseGroup)
|
|
|
|
{
|
|
|
|
size_t caseCount = gridCaseGroup->caseCollection->reservoirs.size();
|
|
|
|
for (size_t i = 0; i < caseCount; i++)
|
|
|
|
{
|
|
|
|
CVF_ASSERT(gridCaseGroup->caseCollection);
|
|
|
|
CVF_ASSERT(gridCaseGroup->caseCollection->reservoirs[i]);
|
|
|
|
CVF_ASSERT(gridCaseGroup->caseCollection->reservoirs[i]->reservoirData());
|
|
|
|
|
2013-03-18 08:34:29 -05:00
|
|
|
RimReservoir* sourceCase = gridCaseGroup->caseCollection->reservoirs[i];
|
2013-03-02 08:32:38 -06:00
|
|
|
sourceCases.push_back(sourceCase);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-03-22 04:03:51 -05:00
|
|
|
RimIdenticalGridCaseGroup* RimStatisticsCase::caseGroup()
|
2013-03-02 08:32:38 -06:00
|
|
|
{
|
2013-03-22 04:03:51 -05:00
|
|
|
RimStatisticsCaseCollection* parentCollection = parentStatisticsCaseCollection();
|
2013-03-13 07:51:26 -05:00
|
|
|
if (parentCollection)
|
2013-03-02 08:32:38 -06:00
|
|
|
{
|
2013-03-13 07:51:26 -05:00
|
|
|
return parentCollection->parentCaseGroup();
|
2013-03-02 08:32:38 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|