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 "RifReaderStatisticalCalculation.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
|
|
|
|
|
|
|
|
|
|
|
CAF_PDM_SOURCE_INIT(RimStatisticalCalculation, "RimStatisticalCalculation");
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimStatisticalCalculation::RimStatisticalCalculation()
|
|
|
|
: 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-21 01:48:26 -06:00
|
|
|
m_readerInterface = new RifReaderStatisticalCalculation;
|
2013-03-02 08:32:38 -06:00
|
|
|
|
|
|
|
openEclipseGridFile();
|
2013-02-14 08:27:35 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimStatisticalCalculation::~RimStatisticalCalculation()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-03-02 08:32:38 -06:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimStatisticalCalculation::setMainGrid(RigMainGrid* mainGrid)
|
|
|
|
{
|
|
|
|
CVF_ASSERT(mainGrid);
|
|
|
|
CVF_ASSERT(m_rigEclipseCase.notNull());
|
|
|
|
|
|
|
|
m_rigEclipseCase->setMainGrid(mainGrid);
|
|
|
|
}
|
|
|
|
|
2013-02-14 08:27:35 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
bool RimStatisticalCalculation::openEclipseGridFile()
|
|
|
|
{
|
2013-03-02 08:32:38 -06:00
|
|
|
if (m_rigEclipseCase.notNull()) return true;
|
|
|
|
|
2013-02-21 01:48:26 -06:00
|
|
|
cvf::ref<RigEclipseCase> eclipseCase = new RigEclipseCase;
|
|
|
|
|
|
|
|
if (!m_readerInterface->open("dummy", eclipseCase.p()))
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_rigEclipseCase = eclipseCase;
|
|
|
|
|
|
|
|
m_rigEclipseCase->results(RifReaderInterface::MATRIX_RESULTS)->setReaderInterface(m_readerInterface.p());
|
|
|
|
m_rigEclipseCase->results(RifReaderInterface::FRACTURE_RESULTS)->setReaderInterface(m_readerInterface.p());
|
|
|
|
|
2013-02-14 08:27:35 -06:00
|
|
|
return true;
|
|
|
|
}
|
2013-02-15 01:44:45 -06:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimStatisticalCalculation::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) const
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-02-21 05:00:49 -06:00
|
|
|
RimStatisticalCollection* RimStatisticalCalculation::parent()
|
2013-02-15 01:44:45 -06:00
|
|
|
{
|
|
|
|
std::vector<caf::PdmObject*> parentObjects;
|
|
|
|
this->parentObjects(parentObjects);
|
|
|
|
|
2013-02-21 05:00:49 -06:00
|
|
|
RimStatisticalCollection* parentObject = NULL;
|
2013-02-15 01:44:45 -06:00
|
|
|
for (size_t i = 0; i < parentObjects.size(); i++)
|
|
|
|
{
|
|
|
|
if (parentObject) continue;
|
|
|
|
|
|
|
|
caf::PdmObject* obj = parentObjects[i];
|
2013-02-21 05:00:49 -06:00
|
|
|
parentObject = dynamic_cast<RimStatisticalCollection*>(obj);
|
2013-02-15 01:44:45 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
CVF_ASSERT(parentObject);
|
|
|
|
|
|
|
|
return parentObject;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimStatisticalCalculation::computeStatistics()
|
|
|
|
{
|
2013-03-02 08:32:38 -06:00
|
|
|
if (m_rigEclipseCase.isNull())
|
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-02 08:32:38 -06:00
|
|
|
cvf::Collection<RigEclipseCase> 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
|
|
|
|
size_t timeStepCount = sourceCases.at(0)->results(RifReaderInterface::MATRIX_RESULTS)->maxTimeStepCount();
|
|
|
|
|
2013-03-02 08:32:38 -06:00
|
|
|
RigStatisticsConfig statisticsConfig;
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
RigStatistics stat(sourceCases, timeStepIndices, statisticsConfig, resultCase);
|
2013-03-08 03:49:33 -06:00
|
|
|
QStringList resultNames = sourceCases.at(0)->results(RifReaderInterface::MATRIX_RESULTS)->resultNames(RimDefines::DYNAMIC_NATIVE);
|
|
|
|
|
|
|
|
stat.evaluateStatistics(RimDefines::DYNAMIC_NATIVE, resultNames);
|
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
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimStatisticalCalculation::getSourceCases(cvf::Collection<RigEclipseCase>& sourceCases)
|
|
|
|
{
|
|
|
|
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());
|
|
|
|
|
|
|
|
RigEclipseCase* sourceCase = gridCaseGroup->caseCollection->reservoirs[i]->reservoirData();
|
|
|
|
sourceCases.push_back(sourceCase);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimIdenticalGridCaseGroup* RimStatisticalCalculation::caseGroup()
|
|
|
|
{
|
|
|
|
RimStatisticalCollection* statColl = parent();
|
|
|
|
if (statColl)
|
|
|
|
{
|
|
|
|
std::vector<caf::PdmObject*> parentObjects;
|
|
|
|
statColl->parentObjects(parentObjects);
|
|
|
|
|
|
|
|
RimIdenticalGridCaseGroup* gridCaseGroup = NULL;
|
|
|
|
for (size_t i = 0; i < parentObjects.size(); i++)
|
|
|
|
{
|
|
|
|
if (gridCaseGroup) continue;
|
|
|
|
|
|
|
|
caf::PdmObject* obj = parentObjects[i];
|
|
|
|
gridCaseGroup = dynamic_cast<RimIdenticalGridCaseGroup*>(obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
return gridCaseGroup;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|