2013-02-14 07:30:01 -06:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
2014-09-23 08:04:57 -05:00
|
|
|
// Copyright (C) 2011- Statoil ASA
|
|
|
|
// Copyright (C) 2013- Ceetron Solutions AS
|
|
|
|
// Copyright (C) 2011-2012 Ceetron AS
|
2013-02-14 07:30:01 -06:00
|
|
|
//
|
|
|
|
// 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 "RimIdenticalGridCaseGroup.h"
|
2013-05-06 03:55:00 -05:00
|
|
|
|
2014-07-24 03:11:43 -05:00
|
|
|
#include "RigActiveCellInfo.h"
|
|
|
|
#include "RigCaseCellResultsData.h"
|
|
|
|
#include "RigCaseData.h"
|
|
|
|
#include "RigGridManager.h"
|
2015-05-15 02:16:33 -05:00
|
|
|
#include "RimEclipseCase.h"
|
2014-07-24 03:11:43 -05:00
|
|
|
#include "RimCaseCollection.h"
|
2015-06-25 06:45:32 -05:00
|
|
|
#include "RimCellEdgeColors.h"
|
2014-07-24 07:03:17 -05:00
|
|
|
#include "RimReservoirCellResultsStorage.h"
|
2015-05-21 03:34:38 -05:00
|
|
|
#include "RimEclipseView.h"
|
2015-06-25 06:23:36 -05:00
|
|
|
#include "RimEclipseResultCase.h"
|
2015-06-25 06:32:00 -05:00
|
|
|
#include "RimEclipseCellColors.h"
|
2015-06-25 06:23:36 -05:00
|
|
|
#include "RimEclipseStatisticsCase.h"
|
2014-10-23 04:41:28 -05:00
|
|
|
#include "RigCaseCellResultsData.h"
|
2013-05-06 03:55:00 -05:00
|
|
|
|
2013-03-14 03:28:49 -05:00
|
|
|
#include "cafProgressInfo.h"
|
2015-05-20 02:40:00 -05:00
|
|
|
#include "RiuMainWindow.h"
|
|
|
|
#include <QMessageBox>
|
|
|
|
#include <QDir>
|
2013-02-14 07:30:01 -06:00
|
|
|
|
|
|
|
CAF_PDM_SOURCE_INIT(RimIdenticalGridCaseGroup, "RimIdenticalGridCaseGroup");
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimIdenticalGridCaseGroup::RimIdenticalGridCaseGroup()
|
|
|
|
{
|
2013-03-07 09:47:42 -06:00
|
|
|
CAF_PDM_InitObject("Grid Case Group", ":/GridCaseGroup16x16.png", "", "");
|
2013-02-14 07:30:01 -06:00
|
|
|
|
2013-03-07 05:32:19 -06:00
|
|
|
CAF_PDM_InitField(&name, "UserDescription", QString("Grid Case Group"), "Name", "", "", "");
|
2013-02-21 03:38:28 -06:00
|
|
|
|
2013-05-10 08:35:33 -05:00
|
|
|
CAF_PDM_InitField(&groupId, "GroupId", -1, "Case Group ID", "", "" ,"");
|
2015-08-05 06:27:36 -05:00
|
|
|
groupId.uiCapability()->setUiReadOnly(true);
|
2013-05-10 08:35:33 -05:00
|
|
|
|
2015-08-12 03:26:49 -05:00
|
|
|
CAF_PDM_InitFieldNoDefault(&statisticsCaseCollection, "StatisticsCaseCollection", "statisticsCaseCollection ChildArrayField", "", "", "");
|
|
|
|
statisticsCaseCollection.uiCapability()->setUiHidden(true);
|
|
|
|
CAF_PDM_InitFieldNoDefault(&caseCollection, "CaseCollection", "Source Cases ChildArrayField", "", "", "");
|
|
|
|
caseCollection.uiCapability()->setUiHidden(true);
|
2013-03-07 05:32:19 -06:00
|
|
|
|
2013-02-21 08:37:51 -06:00
|
|
|
caseCollection = new RimCaseCollection;
|
2015-08-20 08:24:49 -05:00
|
|
|
caseCollection->uiCapability()->setUiName("Source Cases");
|
|
|
|
caseCollection->uiCapability()->setUiIcon(QIcon(":/Cases16x16.png"));
|
2015-08-12 03:26:49 -05:00
|
|
|
|
2013-03-22 05:47:46 -05:00
|
|
|
statisticsCaseCollection = new RimCaseCollection;
|
2015-08-20 08:24:49 -05:00
|
|
|
statisticsCaseCollection->uiCapability()->setUiName("Derived Statistics");
|
|
|
|
statisticsCaseCollection->uiCapability()->setUiIcon(QIcon(":/Histograms16x16.png"));
|
2015-08-12 03:26:49 -05:00
|
|
|
|
2013-02-15 01:44:45 -06:00
|
|
|
|
2013-03-14 02:47:42 -05:00
|
|
|
m_mainGrid = NULL;
|
2013-03-21 04:31:58 -05:00
|
|
|
|
2013-03-21 09:31:47 -05:00
|
|
|
m_unionOfMatrixActiveCells = new RigActiveCellInfo;
|
|
|
|
m_unionOfFractureActiveCells = new RigActiveCellInfo;
|
2013-02-14 07:30:01 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimIdenticalGridCaseGroup::~RimIdenticalGridCaseGroup()
|
|
|
|
{
|
2013-03-07 02:21:29 -06:00
|
|
|
m_mainGrid = NULL;
|
2013-02-14 07:30:01 -06:00
|
|
|
|
2013-03-07 02:21:29 -06:00
|
|
|
delete caseCollection;
|
|
|
|
caseCollection = NULL;
|
|
|
|
|
2013-03-22 04:03:51 -05:00
|
|
|
delete statisticsCaseCollection;
|
|
|
|
statisticsCaseCollection = NULL;
|
2013-02-14 07:30:01 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2015-05-15 01:40:27 -05:00
|
|
|
void RimIdenticalGridCaseGroup::addCase(RimEclipseCase* reservoir)
|
2013-02-14 07:30:01 -06:00
|
|
|
{
|
|
|
|
CVF_ASSERT(reservoir);
|
|
|
|
|
|
|
|
if (!reservoir) return;
|
|
|
|
|
2013-03-13 08:58:36 -05:00
|
|
|
if (!m_mainGrid)
|
2013-02-14 07:30:01 -06:00
|
|
|
{
|
2013-04-07 10:27:45 -05:00
|
|
|
m_mainGrid = reservoir->reservoirData()->mainGrid();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
reservoir->reservoirData()->setMainGrid(m_mainGrid);
|
2013-02-14 07:30:01 -06:00
|
|
|
}
|
|
|
|
|
2013-02-21 08:37:51 -06:00
|
|
|
caseCollection()->reservoirs().push_back(reservoir);
|
2013-03-07 03:06:31 -06:00
|
|
|
|
2013-03-21 04:31:58 -05:00
|
|
|
clearActiveCellUnions();
|
|
|
|
clearStatisticsResults();
|
|
|
|
updateMainGridAndActiveCellsForStatisticsCases();
|
2013-02-14 07:30:01 -06:00
|
|
|
}
|
|
|
|
|
2013-03-20 05:35:27 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2015-05-15 01:40:27 -05:00
|
|
|
void RimIdenticalGridCaseGroup::removeCase(RimEclipseCase* reservoir)
|
2013-03-20 05:35:27 -05:00
|
|
|
{
|
2013-04-11 05:06:38 -05:00
|
|
|
if (caseCollection()->reservoirs().count(reservoir) == 0)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-03-20 05:35:27 -05:00
|
|
|
caseCollection()->reservoirs().removeChildObject(reservoir);
|
|
|
|
|
|
|
|
if (caseCollection()->reservoirs().size() == 0)
|
|
|
|
{
|
|
|
|
m_mainGrid = NULL;
|
|
|
|
}
|
2013-03-21 04:31:58 -05:00
|
|
|
|
|
|
|
clearActiveCellUnions();
|
|
|
|
clearStatisticsResults();
|
|
|
|
updateMainGridAndActiveCellsForStatisticsCases();
|
2013-03-20 05:35:27 -05:00
|
|
|
}
|
|
|
|
|
2013-02-14 07:30:01 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RigMainGrid* RimIdenticalGridCaseGroup::mainGrid()
|
|
|
|
{
|
2013-03-13 08:58:36 -05:00
|
|
|
if (m_mainGrid) return m_mainGrid;
|
2013-02-14 07:30:01 -06:00
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2013-02-21 03:38:28 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
caf::PdmFieldHandle* RimIdenticalGridCaseGroup::userDescriptionField()
|
|
|
|
{
|
|
|
|
return &name;
|
|
|
|
}
|
|
|
|
|
2013-03-14 03:28:49 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-03-22 10:24:42 -05:00
|
|
|
/// Make sure changes in this functions is validated to RiaApplication::addEclipseCases()
|
2013-03-14 03:28:49 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-03-21 09:31:47 -05:00
|
|
|
void RimIdenticalGridCaseGroup::loadMainCaseAndActiveCellInfo()
|
2013-03-14 03:28:49 -05:00
|
|
|
{
|
|
|
|
if (caseCollection()->reservoirs().size() == 0)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-03-21 09:31:47 -05:00
|
|
|
// Read the main case completely including grid.
|
|
|
|
// The mainGrid from the first case is reused directly in for the other cases.
|
2013-03-14 03:28:49 -05:00
|
|
|
// When reading active cell info, only the total cell count is tested for consistency
|
|
|
|
|
2015-05-15 01:40:27 -05:00
|
|
|
RimEclipseCase* mainCase = caseCollection()->reservoirs[0];
|
2015-05-20 02:40:00 -05:00
|
|
|
if (!mainCase->openReserviorCase())
|
2013-04-10 08:33:34 -05:00
|
|
|
{
|
2015-05-20 02:40:00 -05:00
|
|
|
QMessageBox::warning(RiuMainWindow::instance(),
|
|
|
|
"Error when opening project file",
|
|
|
|
"Could not open the Eclipse Grid file: \n"+ mainCase->gridFileName() + "\n"+
|
|
|
|
"Current working directory is: \n" +
|
|
|
|
QDir::currentPath());
|
2013-04-10 08:33:34 -05:00
|
|
|
return;
|
|
|
|
}
|
2013-03-14 03:28:49 -05:00
|
|
|
|
2015-05-20 02:40:00 -05:00
|
|
|
RigCaseData* rigCaseData = mainCase->reservoirData();
|
|
|
|
CVF_ASSERT(rigCaseData);
|
2014-10-28 04:15:20 -05:00
|
|
|
|
2016-07-15 07:46:23 -05:00
|
|
|
RifReaderInterface::PorosityModelResultType poroModel = RifReaderInterface::MATRIX_RESULTS;
|
|
|
|
mainCase->results(poroModel)->cellResults()->createPlaceholderResultEntries();
|
|
|
|
|
|
|
|
|
2014-10-27 01:19:04 -05:00
|
|
|
// Action A : Read active cell info
|
|
|
|
// Read active cell info from all source cases. The file access is optimized for this purpose, and result meta data
|
|
|
|
// is copied from main case to all other cases (see "Action B")
|
2013-03-21 09:31:47 -05:00
|
|
|
|
|
|
|
caf::ProgressInfo info(caseCollection()->reservoirs.size(), "Case group - Reading Active Cell data");
|
|
|
|
for (size_t i = 1; i < caseCollection()->reservoirs.size(); i++)
|
2013-03-14 03:28:49 -05:00
|
|
|
{
|
2015-06-25 04:56:18 -05:00
|
|
|
RimEclipseResultCase* rimReservoir = dynamic_cast<RimEclipseResultCase*>(caseCollection()->reservoirs[i]);
|
2013-03-21 09:31:47 -05:00
|
|
|
if(!rimReservoir) continue; // Input reservoir
|
2013-03-14 03:28:49 -05:00
|
|
|
|
2014-10-28 04:17:02 -05:00
|
|
|
if (!rimReservoir->openAndReadActiveCellData(rigCaseData))
|
2013-03-14 03:28:49 -05:00
|
|
|
{
|
2013-04-10 08:33:34 -05:00
|
|
|
// Error message
|
|
|
|
continue;
|
2013-03-14 03:28:49 -05:00
|
|
|
}
|
|
|
|
|
2013-03-21 09:31:47 -05:00
|
|
|
info.incrementProgress();
|
2013-03-14 03:28:49 -05:00
|
|
|
}
|
|
|
|
|
2014-10-28 04:17:02 -05:00
|
|
|
m_mainGrid = rigCaseData->mainGrid();
|
2013-03-21 09:31:47 -05:00
|
|
|
|
|
|
|
// Check if we need to calculate the union of the active cells
|
2013-03-14 03:28:49 -05:00
|
|
|
|
2013-03-21 04:31:58 -05:00
|
|
|
bool foundResultsInCache = false;
|
2013-03-22 05:47:46 -05:00
|
|
|
for (size_t i = 0; i < statisticsCaseCollection()->reservoirs.size(); i++)
|
2013-03-14 03:28:49 -05:00
|
|
|
{
|
2015-05-15 01:40:27 -05:00
|
|
|
RimEclipseCase* rimReservoir = statisticsCaseCollection()->reservoirs[i];
|
2013-03-21 04:31:58 -05:00
|
|
|
|
|
|
|
// Check if any results are stored in cache
|
2013-03-21 09:31:47 -05:00
|
|
|
if (rimReservoir->results(RifReaderInterface::MATRIX_RESULTS)->storedResultsCount() > 0 ||
|
|
|
|
rimReservoir->results(RifReaderInterface::FRACTURE_RESULTS)->storedResultsCount() > 0)
|
2013-03-21 04:31:58 -05:00
|
|
|
{
|
|
|
|
foundResultsInCache = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2013-03-14 03:28:49 -05:00
|
|
|
|
2013-03-21 04:31:58 -05:00
|
|
|
if (foundResultsInCache)
|
|
|
|
{
|
|
|
|
computeUnionOfActiveCells();
|
2013-03-14 03:28:49 -05:00
|
|
|
}
|
|
|
|
|
2014-10-27 01:19:04 -05:00
|
|
|
// Action B : Copy result meta data from main case to all other cases in grid case group
|
|
|
|
|
|
|
|
// This code was originally part of RimStatisticsCaseEvaluator, but moved here to be a general solution
|
|
|
|
// for all cases
|
2014-10-23 04:41:28 -05:00
|
|
|
|
|
|
|
{
|
|
|
|
RifReaderInterface::PorosityModelResultType poroModel = RifReaderInterface::MATRIX_RESULTS;
|
|
|
|
|
2014-10-28 04:17:02 -05:00
|
|
|
std::vector<QDateTime> timeStepDates = rigCaseData->results(poroModel)->timeStepDates(0);
|
|
|
|
const std::vector<RigCaseCellResultsData::ResultInfo> resultInfos = rigCaseData->results(poroModel)->infoForEachResultIndex();
|
2014-10-23 04:41:28 -05:00
|
|
|
|
|
|
|
for (size_t i = 1; i < caseCollection()->reservoirs.size(); i++)
|
|
|
|
{
|
2015-06-25 04:56:18 -05:00
|
|
|
RimEclipseResultCase* rimReservoir = dynamic_cast<RimEclipseResultCase*>(caseCollection()->reservoirs[i]);
|
2014-10-23 04:41:28 -05:00
|
|
|
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;
|
2016-07-15 07:46:23 -05:00
|
|
|
bool mustBeCalculated = resultInfos[resIdx].m_mustBeCalculated;
|
2014-10-23 04:41:28 -05:00
|
|
|
|
|
|
|
size_t scalarResultIndex = cellResultsStorage->cellResults()->findScalarResultIndex(resultType, resultName);
|
|
|
|
if (scalarResultIndex == cvf::UNDEFINED_SIZE_T)
|
|
|
|
{
|
|
|
|
size_t scalarResultIndex = cellResultsStorage->cellResults()->addEmptyScalarResult(resultType, resultName, needsToBeStored);
|
2016-07-15 07:46:23 -05:00
|
|
|
|
|
|
|
if (mustBeCalculated) cellResultsStorage->cellResults()->setMustBeCalculated(scalarResultIndex);
|
|
|
|
|
2014-10-23 04:41:28 -05:00
|
|
|
cellResultsStorage->cellResults()->setTimeStepDates(scalarResultIndex, timeStepDates);
|
|
|
|
|
|
|
|
std::vector< std::vector<double> >& dataValues = cellResultsStorage->cellResults()->cellScalarResults(scalarResultIndex);
|
|
|
|
dataValues.resize(timeStepDates.size());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
cellResultsStorage->cellResults()->createPlaceholderResultEntries();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-21 09:31:47 -05:00
|
|
|
// "Load" the statistical cases
|
2013-03-21 04:31:58 -05:00
|
|
|
|
2013-03-22 05:47:46 -05:00
|
|
|
for (size_t i = 0; i < statisticsCaseCollection()->reservoirs.size(); i++)
|
2013-03-21 09:31:47 -05:00
|
|
|
{
|
2015-05-15 01:40:27 -05:00
|
|
|
RimEclipseCase* rimReservoir = statisticsCaseCollection()->reservoirs[i];
|
2013-03-21 09:31:47 -05:00
|
|
|
|
|
|
|
rimReservoir->openEclipseGridFile();
|
|
|
|
|
|
|
|
if (i == 0)
|
|
|
|
{
|
|
|
|
rimReservoir->reservoirData()->computeActiveCellBoundingBoxes();
|
|
|
|
}
|
|
|
|
}
|
2013-03-21 04:31:58 -05:00
|
|
|
}
|
|
|
|
|
2013-03-21 09:31:47 -05:00
|
|
|
|
2013-03-21 04:31:58 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimIdenticalGridCaseGroup::computeUnionOfActiveCells()
|
|
|
|
{
|
2014-08-08 03:27:29 -05:00
|
|
|
if (m_unionOfMatrixActiveCells->reservoirActiveCellCount() > 0)
|
2013-03-21 04:31:58 -05:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (caseCollection->reservoirs.size() == 0 || !m_mainGrid)
|
|
|
|
{
|
2013-03-21 09:31:47 -05:00
|
|
|
this->clearActiveCellUnions();
|
2013-03-21 04:31:58 -05:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-11-24 07:21:02 -06:00
|
|
|
m_unionOfMatrixActiveCells->setReservoirCellCount(m_mainGrid->globalCellArray().size());
|
|
|
|
m_unionOfFractureActiveCells->setReservoirCellCount(m_mainGrid->globalCellArray().size());
|
2013-03-21 04:31:58 -05:00
|
|
|
m_unionOfMatrixActiveCells->setGridCount(m_mainGrid->gridCount());
|
|
|
|
m_unionOfFractureActiveCells->setGridCount(m_mainGrid->gridCount());
|
|
|
|
|
|
|
|
size_t globalActiveMatrixIndex = 0;
|
|
|
|
size_t globalActiveFractureIndex = 0;
|
|
|
|
|
|
|
|
for (size_t gridIdx = 0; gridIdx < m_mainGrid->gridCount(); gridIdx++)
|
|
|
|
{
|
|
|
|
RigGridBase* grid = m_mainGrid->gridByIndex(gridIdx);
|
|
|
|
|
|
|
|
std::vector<char> activeM(grid->cellCount(), 0);
|
|
|
|
std::vector<char> activeF(grid->cellCount(), 0);
|
|
|
|
|
2014-08-08 03:07:32 -05:00
|
|
|
for (size_t gridLocalCellIndex = 0; gridLocalCellIndex < grid->cellCount(); gridLocalCellIndex++)
|
2013-03-21 04:31:58 -05:00
|
|
|
{
|
|
|
|
for (size_t caseIdx = 0; caseIdx < caseCollection->reservoirs.size(); caseIdx++)
|
|
|
|
{
|
2014-08-08 03:16:54 -05:00
|
|
|
size_t reservoirCellIndex = grid->reservoirCellIndex(gridLocalCellIndex);
|
2013-03-21 04:31:58 -05:00
|
|
|
|
2014-08-08 03:07:32 -05:00
|
|
|
if (activeM[gridLocalCellIndex] == 0)
|
2013-03-21 04:31:58 -05:00
|
|
|
{
|
2014-08-08 03:02:26 -05:00
|
|
|
if (caseCollection->reservoirs[caseIdx]->reservoirData()->activeCellInfo(RifReaderInterface::MATRIX_RESULTS)->isActive(reservoirCellIndex))
|
2013-03-21 04:31:58 -05:00
|
|
|
{
|
2014-08-08 03:07:32 -05:00
|
|
|
activeM[gridLocalCellIndex] = 1;
|
2013-03-21 04:31:58 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-08 03:07:32 -05:00
|
|
|
if (activeF[gridLocalCellIndex] == 0)
|
2013-03-21 04:31:58 -05:00
|
|
|
{
|
2014-08-08 03:02:26 -05:00
|
|
|
if (caseCollection->reservoirs[caseIdx]->reservoirData()->activeCellInfo(RifReaderInterface::FRACTURE_RESULTS)->isActive(reservoirCellIndex))
|
2013-03-21 04:31:58 -05:00
|
|
|
{
|
2014-08-08 03:07:32 -05:00
|
|
|
activeF[gridLocalCellIndex] = 1;
|
2013-03-21 04:31:58 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t activeMatrixIndex = 0;
|
|
|
|
size_t activeFractureIndex = 0;
|
|
|
|
|
2014-08-08 03:07:32 -05:00
|
|
|
for (size_t gridLocalCellIndex = 0; gridLocalCellIndex < grid->cellCount(); gridLocalCellIndex++)
|
2013-03-21 04:31:58 -05:00
|
|
|
{
|
2014-08-08 03:16:54 -05:00
|
|
|
size_t reservoirCellIndex = grid->reservoirCellIndex(gridLocalCellIndex);
|
2013-03-21 04:31:58 -05:00
|
|
|
|
2014-08-08 03:07:32 -05:00
|
|
|
if (activeM[gridLocalCellIndex] != 0)
|
2013-03-21 04:31:58 -05:00
|
|
|
{
|
2014-08-08 03:02:26 -05:00
|
|
|
m_unionOfMatrixActiveCells->setCellResultIndex(reservoirCellIndex, globalActiveMatrixIndex++);
|
2013-03-21 04:31:58 -05:00
|
|
|
activeMatrixIndex++;
|
|
|
|
}
|
|
|
|
|
2014-08-08 03:07:32 -05:00
|
|
|
if (activeF[gridLocalCellIndex] != 0)
|
2013-03-21 04:31:58 -05:00
|
|
|
{
|
2014-08-08 03:02:26 -05:00
|
|
|
m_unionOfFractureActiveCells->setCellResultIndex(reservoirCellIndex, globalActiveFractureIndex++);
|
2013-03-21 04:31:58 -05:00
|
|
|
activeFractureIndex++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
m_unionOfMatrixActiveCells->setGridActiveCellCounts(gridIdx, activeMatrixIndex);
|
|
|
|
m_unionOfFractureActiveCells->setGridActiveCellCounts(gridIdx, activeFractureIndex);
|
|
|
|
}
|
|
|
|
|
|
|
|
m_unionOfMatrixActiveCells->computeDerivedData();
|
|
|
|
m_unionOfFractureActiveCells->computeDerivedData();
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2015-06-25 04:57:41 -05:00
|
|
|
RimEclipseStatisticsCase* RimIdenticalGridCaseGroup::createAndAppendStatisticsCase()
|
2013-03-21 04:31:58 -05:00
|
|
|
{
|
2015-06-25 04:57:41 -05:00
|
|
|
RimEclipseStatisticsCase* newStatisticsCase = new RimEclipseStatisticsCase;
|
2013-03-21 04:31:58 -05:00
|
|
|
|
2013-04-11 05:06:38 -05:00
|
|
|
newStatisticsCase->caseUserDescription = QString("Statistics ") + QString::number(statisticsCaseCollection()->reservoirs.size()+1);
|
2013-03-22 05:47:46 -05:00
|
|
|
statisticsCaseCollection()->reservoirs.push_back(newStatisticsCase);
|
2016-11-23 03:23:59 -06:00
|
|
|
|
|
|
|
newStatisticsCase->populateResultSelectionAfterLoadingGrid();
|
2013-03-22 05:47:46 -05:00
|
|
|
newStatisticsCase->openEclipseGridFile();
|
2013-03-21 09:31:47 -05:00
|
|
|
|
2013-03-22 05:47:46 -05:00
|
|
|
return newStatisticsCase;
|
2013-03-21 04:31:58 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimIdenticalGridCaseGroup::updateMainGridAndActiveCellsForStatisticsCases()
|
|
|
|
{
|
2013-03-22 05:47:46 -05:00
|
|
|
for (size_t i = 0; i < statisticsCaseCollection->reservoirs().size(); i++)
|
2013-03-21 04:31:58 -05:00
|
|
|
{
|
2015-05-15 01:40:27 -05:00
|
|
|
RimEclipseCase* rimStaticsCase = statisticsCaseCollection->reservoirs[i];
|
2013-03-21 04:31:58 -05:00
|
|
|
|
2015-08-20 03:24:03 -05:00
|
|
|
if (rimStaticsCase->reservoirData())
|
2013-03-21 04:31:58 -05:00
|
|
|
{
|
2015-08-20 03:24:03 -05:00
|
|
|
rimStaticsCase->reservoirData()->setMainGrid(this->mainGrid());
|
|
|
|
|
|
|
|
if (i == 0)
|
|
|
|
{
|
|
|
|
rimStaticsCase->reservoirData()->computeActiveCellBoundingBoxes();
|
|
|
|
}
|
2013-03-21 04:31:58 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimIdenticalGridCaseGroup::clearStatisticsResults()
|
|
|
|
{
|
2013-03-22 05:47:46 -05:00
|
|
|
for (size_t i = 0; i < statisticsCaseCollection->reservoirs().size(); i++)
|
2013-03-21 04:31:58 -05:00
|
|
|
{
|
2015-05-15 01:40:27 -05:00
|
|
|
RimEclipseCase* rimStaticsCase = statisticsCaseCollection->reservoirs[i];
|
2013-03-22 05:47:46 -05:00
|
|
|
if (!rimStaticsCase) continue;
|
|
|
|
|
2015-08-20 03:24:03 -05:00
|
|
|
if (rimStaticsCase->results(RifReaderInterface::MATRIX_RESULTS)->cellResults())
|
|
|
|
{
|
|
|
|
rimStaticsCase->results(RifReaderInterface::MATRIX_RESULTS)->cellResults()->clearAllResults();
|
|
|
|
}
|
|
|
|
if (rimStaticsCase->results(RifReaderInterface::FRACTURE_RESULTS)->cellResults())
|
|
|
|
{
|
|
|
|
rimStaticsCase->results(RifReaderInterface::FRACTURE_RESULTS)->cellResults()->clearAllResults();
|
|
|
|
}
|
2013-03-22 03:16:50 -05:00
|
|
|
|
|
|
|
for (size_t j = 0; j < rimStaticsCase->reservoirViews.size(); j++)
|
|
|
|
{
|
2015-05-21 03:05:33 -05:00
|
|
|
RimEclipseView* rimReservoirView = rimStaticsCase->reservoirViews[j];
|
2013-04-30 06:41:53 -05:00
|
|
|
rimReservoirView->cellResult()->setResultVariable(RimDefines::undefinedResultName());
|
2016-08-06 01:44:49 -05:00
|
|
|
rimReservoirView->cellEdgeResult()->setResultVariable(RimDefines::undefinedResultName());
|
2013-03-22 03:16:50 -05:00
|
|
|
rimReservoirView->loadDataAndUpdate();
|
|
|
|
}
|
2013-03-21 04:31:58 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimIdenticalGridCaseGroup::clearActiveCellUnions()
|
|
|
|
{
|
2013-03-21 09:31:47 -05:00
|
|
|
m_unionOfMatrixActiveCells->clear();
|
|
|
|
m_unionOfFractureActiveCells->clear();
|
2013-03-14 03:28:49 -05:00
|
|
|
}
|
|
|
|
|
2013-03-21 07:56:50 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2015-05-15 01:40:27 -05:00
|
|
|
bool RimIdenticalGridCaseGroup::contains(RimEclipseCase* reservoir) const
|
2013-03-21 07:56:50 -05:00
|
|
|
{
|
|
|
|
CVF_ASSERT(reservoir);
|
|
|
|
|
|
|
|
for (size_t i = 0; i < caseCollection()->reservoirs().size(); i++)
|
|
|
|
{
|
2015-05-15 01:40:27 -05:00
|
|
|
RimEclipseCase* rimReservoir = caseCollection()->reservoirs()[i];
|
2013-04-11 05:06:38 -05:00
|
|
|
if (reservoir->gridFileName() == rimReservoir->gridFileName())
|
2013-03-21 07:56:50 -05:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-04-05 07:46:35 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-03-21 09:31:47 -05:00
|
|
|
RigActiveCellInfo* RimIdenticalGridCaseGroup::unionOfActiveCells(RifReaderInterface::PorosityModelResultType porosityType)
|
|
|
|
{
|
|
|
|
if (porosityType == RifReaderInterface::MATRIX_RESULTS)
|
|
|
|
{
|
|
|
|
return m_unionOfMatrixActiveCells.p();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return m_unionOfFractureActiveCells.p();
|
|
|
|
}
|
|
|
|
}
|
2013-03-22 05:47:46 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
bool RimIdenticalGridCaseGroup::isStatisticsCaseCollection(RimCaseCollection* rimCaseCollection)
|
|
|
|
{
|
2015-07-31 11:58:23 -05:00
|
|
|
caf::PdmFieldHandle* parentField = rimCaseCollection->parentField();
|
|
|
|
if (parentField)
|
2013-03-22 05:47:46 -05:00
|
|
|
{
|
2015-07-31 11:58:23 -05:00
|
|
|
if (parentField->keyword() == "StatisticsCaseCollection")
|
2013-03-22 05:47:46 -05:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2013-04-02 09:59:55 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2015-05-15 01:40:27 -05:00
|
|
|
RimEclipseCase* RimIdenticalGridCaseGroup::mainCase()
|
2013-04-02 09:59:55 -05:00
|
|
|
{
|
|
|
|
if(caseCollection()->reservoirs().size())
|
|
|
|
{
|
|
|
|
return caseCollection()->reservoirs()[0];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
2013-04-07 10:27:45 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2015-05-15 01:40:27 -05:00
|
|
|
bool RimIdenticalGridCaseGroup::canCaseBeAdded(RimEclipseCase* reservoir) const
|
2013-04-07 10:27:45 -05:00
|
|
|
{
|
|
|
|
CVF_ASSERT(reservoir && reservoir->reservoirData() && reservoir->reservoirData()->mainGrid());
|
|
|
|
|
|
|
|
if (!m_mainGrid)
|
|
|
|
{
|
|
|
|
// Empty case group, reservoir can be added
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
RigMainGrid* incomingMainGrid = reservoir->reservoirData()->mainGrid();
|
|
|
|
|
|
|
|
if (RigGridManager::isEqual(m_mainGrid, incomingMainGrid))
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|