2012-05-18 02:45:23 -05: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"
|
|
|
|
|
2012-06-26 09:10:41 -05:00
|
|
|
#include "RifReaderEclipseOutput.h"
|
2012-08-31 12:12:47 -05:00
|
|
|
#include "RifReaderMockModel.h"
|
|
|
|
|
2012-05-18 02:45:23 -05:00
|
|
|
#include "RimReservoir.h"
|
2012-08-31 12:12:47 -05:00
|
|
|
#include "RimReservoirView.h"
|
|
|
|
|
2013-02-13 06:33:35 -06:00
|
|
|
#include "RigEclipseCase.h"
|
2012-05-18 02:45:23 -05:00
|
|
|
#include "RigMainGrid.h"
|
|
|
|
#include "RigReservoirCellResults.h"
|
|
|
|
|
|
|
|
#include "cvfAssert.h"
|
|
|
|
|
2012-08-31 12:12:47 -05:00
|
|
|
#include "cafPdmUiPushButtonEditor.h"
|
|
|
|
|
2012-05-18 02:45:23 -05:00
|
|
|
#include <QString>
|
2013-02-14 06:16:56 -06:00
|
|
|
#include "RimProject.h"
|
2012-05-18 02:45:23 -05:00
|
|
|
|
2013-03-18 05:40:39 -05:00
|
|
|
CAF_PDM_SOURCE_INIT(RimReservoir, "RimReservoir");
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------------------------
|
2012-05-18 02:45:23 -05:00
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimReservoir::RimReservoir()
|
|
|
|
{
|
2013-02-14 03:19:27 -06:00
|
|
|
m_rigEclipseCase = NULL;
|
2012-05-18 02:45:23 -05:00
|
|
|
|
|
|
|
CAF_PDM_InitField(&caseName, "CaseName", QString(), "Case name", "", "" ,"");
|
2012-08-31 12:12:47 -05:00
|
|
|
// CAF_PDM_InitField(&releaseResultMemory, "ReleaseResultMemory", true, "Release result memory", "", "" ,"");
|
|
|
|
// releaseResultMemory.setIOReadable(false);
|
|
|
|
// releaseResultMemory.setIOWritable(false);
|
|
|
|
// releaseResultMemory.setUiEditorTypeName(caf::PdmUiPushButtonEditor::uiEditorTypeName());
|
2012-05-18 02:45:23 -05:00
|
|
|
|
|
|
|
CAF_PDM_InitFieldNoDefault(&reservoirViews, "ReservoirViews", "", "", "", "");
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-02-13 06:24:39 -06:00
|
|
|
RigEclipseCase* RimReservoir::reservoirData()
|
2012-05-18 02:45:23 -05:00
|
|
|
{
|
2013-02-14 03:19:27 -06:00
|
|
|
return m_rigEclipseCase.p();
|
2012-05-18 02:45:23 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-02-13 06:24:39 -06:00
|
|
|
const RigEclipseCase* RimReservoir::reservoirData() const
|
2012-05-18 02:45:23 -05:00
|
|
|
{
|
2013-02-14 03:19:27 -06:00
|
|
|
return m_rigEclipseCase.p();
|
2012-05-18 02:45:23 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimReservoir::initAfterRead()
|
|
|
|
{
|
|
|
|
size_t j;
|
|
|
|
for (j = 0; j < reservoirViews().size(); j++)
|
|
|
|
{
|
|
|
|
RimReservoirView* riv = reservoirViews()[j];
|
|
|
|
CVF_ASSERT(riv);
|
|
|
|
|
|
|
|
riv->setEclipseCase(this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimReservoir::~RimReservoir()
|
|
|
|
{
|
2012-06-26 09:10:41 -05:00
|
|
|
reservoirViews.deleteAllChildObjects();
|
2013-03-08 01:35:27 -06:00
|
|
|
|
2013-03-14 03:28:49 -05:00
|
|
|
if (m_rigEclipseCase.notNull())
|
|
|
|
{
|
|
|
|
// At this point, we assume that memory should be released
|
|
|
|
CVF_ASSERT(m_rigEclipseCase->refCount() == 1);
|
|
|
|
}
|
2012-05-18 02:45:23 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimReservoirView* RimReservoir::createAndAddReservoirView()
|
|
|
|
{
|
2013-03-13 05:42:26 -05:00
|
|
|
// If parent is collection, and number of views is zero, make sure rig is set to NULL to initiate normal case loading
|
|
|
|
if (parentCaseCollection() != NULL && reservoirViews().size() == 0)
|
|
|
|
{
|
2013-03-14 03:28:49 -05:00
|
|
|
if (m_rigEclipseCase.notNull())
|
|
|
|
{
|
|
|
|
CVF_ASSERT(m_rigEclipseCase->refCount() == 1);
|
|
|
|
}
|
|
|
|
|
2013-03-13 05:42:26 -05:00
|
|
|
m_rigEclipseCase = NULL;
|
|
|
|
}
|
|
|
|
|
2012-05-18 02:45:23 -05:00
|
|
|
RimReservoirView* riv = new RimReservoirView();
|
|
|
|
riv->setEclipseCase(this);
|
|
|
|
|
|
|
|
size_t i = reservoirViews().size();
|
|
|
|
riv->name = QString("View %1").arg(i + 1);
|
|
|
|
|
|
|
|
reservoirViews().push_back(riv);
|
|
|
|
|
|
|
|
return riv;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
/// TODO: Move this functionality to PdmPointersField
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimReservoir::removeReservoirView(RimReservoirView* reservoirView)
|
|
|
|
{
|
|
|
|
std::vector<size_t> indices;
|
|
|
|
|
|
|
|
size_t i;
|
|
|
|
for (i = 0; i < reservoirViews().size(); i++)
|
|
|
|
{
|
|
|
|
if (reservoirViews()[i] == reservoirView)
|
|
|
|
{
|
|
|
|
indices.push_back(i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// NB! Make sure the ordering goes from large to low index
|
|
|
|
while (!indices.empty())
|
|
|
|
{
|
|
|
|
reservoirViews().erase(indices.back());
|
|
|
|
indices.pop_back();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-26 09:10:41 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimReservoir::removeResult(const QString& resultName)
|
|
|
|
{
|
|
|
|
size_t i;
|
|
|
|
for (i = 0; i < reservoirViews().size(); i++)
|
|
|
|
{
|
|
|
|
RimReservoirView* reservoirView = reservoirViews()[i];
|
|
|
|
CVF_ASSERT(reservoirView);
|
|
|
|
|
|
|
|
RimResultSlot* result = reservoirView->cellResult;
|
|
|
|
CVF_ASSERT(result);
|
|
|
|
|
|
|
|
bool rebuildDisplayModel = false;
|
|
|
|
|
|
|
|
// Set cell result variable to none if displaying
|
|
|
|
if (result->resultVariable() == resultName)
|
|
|
|
{
|
2012-08-31 12:12:47 -05:00
|
|
|
result->resultVariable.v() = RimDefines::undefinedResultName();
|
2012-06-26 09:10:41 -05:00
|
|
|
result->loadResult();
|
|
|
|
|
|
|
|
rebuildDisplayModel = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::list< caf::PdmPointer< RimCellPropertyFilter > >::iterator it;
|
|
|
|
RimCellPropertyFilterCollection* propFilterCollection = reservoirView->propertyFilterCollection();
|
|
|
|
for (it = propFilterCollection->propertyFilters.v().begin(); it != propFilterCollection->propertyFilters.v().end(); ++it)
|
|
|
|
{
|
|
|
|
RimCellPropertyFilter* propertyFilter = *it;
|
|
|
|
if (propertyFilter->resultDefinition->resultVariable.v() == resultName)
|
|
|
|
{
|
2012-08-31 12:12:47 -05:00
|
|
|
propertyFilter->resultDefinition->resultVariable.v() = RimDefines::undefinedResultName();
|
2012-06-26 09:10:41 -05:00
|
|
|
propertyFilter->resultDefinition->loadResult();
|
|
|
|
propertyFilter->setDefaultValues();
|
|
|
|
|
|
|
|
rebuildDisplayModel = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rebuildDisplayModel)
|
|
|
|
{
|
|
|
|
reservoirViews()[i]->createDisplayModelAndRedraw();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// TODO
|
|
|
|
// CellEdgeResults are not considered, as they do not support display of input properties yet
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-31 12:12:47 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimReservoir::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
|
|
|
|
{
|
|
|
|
if (changedField == &releaseResultMemory)
|
|
|
|
{
|
2013-02-14 03:19:27 -06:00
|
|
|
if (m_rigEclipseCase.notNull())
|
2012-08-31 12:12:47 -05:00
|
|
|
{
|
|
|
|
for (size_t i = 0; i < reservoirViews().size(); i++)
|
|
|
|
{
|
|
|
|
RimReservoirView* reservoirView = reservoirViews()[i];
|
|
|
|
CVF_ASSERT(reservoirView);
|
|
|
|
|
|
|
|
RimResultSlot* result = reservoirView->cellResult;
|
|
|
|
CVF_ASSERT(result);
|
|
|
|
|
|
|
|
result->resultVariable.v() = RimDefines::undefinedResultName();
|
|
|
|
result->loadResult();
|
|
|
|
|
|
|
|
RimCellEdgeResultSlot* cellEdgeResult = reservoirView->cellEdgeResult;
|
|
|
|
CVF_ASSERT(cellEdgeResult);
|
|
|
|
|
|
|
|
cellEdgeResult->resultVariable.v() = RimDefines::undefinedResultName();
|
|
|
|
cellEdgeResult->loadResult();
|
|
|
|
|
|
|
|
reservoirView->createDisplayModelAndRedraw();
|
|
|
|
}
|
|
|
|
|
2013-02-14 03:19:27 -06:00
|
|
|
RigReservoirCellResults* matrixModelResults = m_rigEclipseCase->results(RifReaderInterface::MATRIX_RESULTS);
|
2013-02-01 07:39:32 -06:00
|
|
|
if (matrixModelResults)
|
2012-08-31 12:12:47 -05:00
|
|
|
{
|
2013-02-01 07:39:32 -06:00
|
|
|
matrixModelResults->clearAllResults();
|
|
|
|
}
|
|
|
|
|
2013-02-14 03:19:27 -06:00
|
|
|
RigReservoirCellResults* fractureModelResults = m_rigEclipseCase->results(RifReaderInterface::FRACTURE_RESULTS);
|
2013-02-01 07:39:32 -06:00
|
|
|
if (fractureModelResults)
|
|
|
|
{
|
|
|
|
fractureModelResults->clearAllResults();
|
2012-08-31 12:12:47 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
releaseResultMemory = oldValue.toBool();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-14 06:16:56 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-02-22 03:12:06 -06:00
|
|
|
void RimReservoir::computeCachedData()
|
2013-02-14 06:16:56 -06:00
|
|
|
{
|
2013-02-22 03:12:06 -06:00
|
|
|
RigEclipseCase* rigEclipseCase = reservoirData();
|
|
|
|
if (rigEclipseCase)
|
2013-02-14 06:16:56 -06:00
|
|
|
{
|
2013-02-22 03:12:06 -06:00
|
|
|
rigEclipseCase->computeCachedData();
|
2013-02-14 06:16:56 -06:00
|
|
|
|
2013-02-22 03:12:06 -06:00
|
|
|
rigEclipseCase->mainGrid()->computeCachedData();
|
2013-02-14 06:16:56 -06:00
|
|
|
|
2013-02-22 03:12:06 -06:00
|
|
|
std::vector<RigGridBase*> grids;
|
|
|
|
rigEclipseCase->allGrids(&grids);
|
|
|
|
|
|
|
|
size_t i;
|
|
|
|
for (i = 0; i < grids.size(); i++)
|
|
|
|
{
|
|
|
|
grids[i]->computeFaults();
|
|
|
|
}
|
2013-02-14 06:16:56 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-13 05:42:26 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimCaseCollection* RimReservoir::parentCaseCollection()
|
|
|
|
{
|
|
|
|
std::vector<RimCaseCollection*> parentObjects;
|
|
|
|
this->parentObjectsOfType(parentObjects);
|
|
|
|
|
|
|
|
if (parentObjects.size() > 0)
|
|
|
|
{
|
|
|
|
return parentObjects[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|