2012-06-26 09:10:41 -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.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2013-03-22 10:12:00 -05:00
|
|
|
#include "RiaStdInclude.h"
|
2013-03-22 10:40:41 -05:00
|
|
|
#include "RimResultCase.h"
|
2013-03-22 10:58:44 -05:00
|
|
|
#include "RigCaseData.h"
|
2012-06-26 09:10:41 -05:00
|
|
|
#include "RifReaderEclipseOutput.h"
|
2013-03-22 10:58:44 -05:00
|
|
|
#include "RigCaseCellResultsData.h"
|
2012-06-26 09:10:41 -05:00
|
|
|
#include "RimReservoirView.h"
|
|
|
|
#include "RifReaderMockModel.h"
|
|
|
|
#include "RifReaderEclipseInput.h"
|
|
|
|
#include "cafProgressInfo.h"
|
2013-02-11 01:16:51 -06:00
|
|
|
#include "RimProject.h"
|
2013-04-07 10:20:58 -05:00
|
|
|
#include "RifEclipseOutputFileTools.h"
|
2013-04-08 01:36:34 -05:00
|
|
|
#include "RiaApplication.h"
|
2013-05-06 03:55:00 -05:00
|
|
|
#include "RimIdenticalGridCaseGroup.h"
|
|
|
|
#include "RimScriptCollection.h"
|
|
|
|
#include "RimCaseCollection.h"
|
|
|
|
#include "RimReservoirCellResultsCacher.h"
|
2013-05-16 07:02:59 -05:00
|
|
|
#include "RimWellPathCollection.h"
|
2013-05-06 03:55:00 -05:00
|
|
|
|
|
|
|
#include "cafPdmFieldCvfMat4d.h"
|
|
|
|
#include "cafPdmFieldCvfColor.h"
|
|
|
|
#include "RimResultSlot.h"
|
|
|
|
#include "RimCellEdgeResultSlot.h"
|
|
|
|
#include "RimCellRangeFilterCollection.h"
|
|
|
|
#include "RimCellPropertyFilterCollection.h"
|
|
|
|
#include "RimWellCollection.h"
|
|
|
|
#include "Rim3dOverlayInfoConfig.h"
|
2013-06-06 08:02:35 -05:00
|
|
|
#include "RimOilField.h"
|
|
|
|
#include "RimAnalysisModels.h"
|
2012-06-26 09:10:41 -05:00
|
|
|
|
2013-03-22 09:43:42 -05:00
|
|
|
CAF_PDM_SOURCE_INIT(RimResultCase, "EclipseCase");
|
2012-06-26 09:10:41 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-03-22 09:43:42 -05:00
|
|
|
RimResultCase::RimResultCase()
|
|
|
|
: RimCase()
|
2012-06-26 09:10:41 -05:00
|
|
|
{
|
2013-05-31 18:29:05 -05:00
|
|
|
CAF_PDM_InitObject("Eclipse Case", ":/Case48x48.png", "", "");
|
2013-03-07 09:47:42 -06:00
|
|
|
|
2012-06-26 09:10:41 -05:00
|
|
|
CAF_PDM_InitField(&caseFileName, "CaseFileName", QString(), "Case file name", "", "" ,"");
|
2013-04-11 05:06:38 -05:00
|
|
|
caseFileName.setUiReadOnly(true);
|
|
|
|
|
|
|
|
// Obsolete, unused field
|
2012-06-26 09:10:41 -05:00
|
|
|
CAF_PDM_InitField(&caseDirectory, "CaseFolder", QString(), "Directory", "", "" ,"");
|
2013-04-11 05:06:38 -05:00
|
|
|
caseDirectory.setIOWritable(false);
|
|
|
|
caseDirectory.setUiHidden(true);
|
|
|
|
|
2013-04-26 06:19:34 -05:00
|
|
|
flipXAxis.setIOWritable(true);
|
|
|
|
flipXAxis.setUiHidden(true);
|
|
|
|
flipYAxis.setIOWritable(true);
|
|
|
|
flipYAxis.setUiHidden(true);
|
|
|
|
|
2013-04-12 05:03:04 -05:00
|
|
|
m_activeCellInfoIsReadFromFile = false;
|
|
|
|
m_gridAndWellDataIsReadFromFile = false;
|
2012-06-26 09:10:41 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-03-22 09:43:42 -05:00
|
|
|
bool RimResultCase::openEclipseGridFile()
|
2012-06-26 09:10:41 -05:00
|
|
|
{
|
2013-02-06 06:44:27 -06:00
|
|
|
caf::ProgressInfo progInfo(50, "Reading Eclipse Grid File");
|
2012-06-26 09:10:41 -05:00
|
|
|
|
|
|
|
progInfo.setProgressDescription("Open Grid File");
|
2013-02-06 06:44:27 -06:00
|
|
|
progInfo.setNextProgressIncrement(48);
|
2013-04-12 05:03:04 -05:00
|
|
|
|
|
|
|
// Early exit if data is already read
|
|
|
|
if (m_gridAndWellDataIsReadFromFile) return true;
|
2012-06-26 09:10:41 -05:00
|
|
|
|
|
|
|
cvf::ref<RifReaderInterface> readerInterface;
|
|
|
|
|
2013-04-11 05:06:38 -05:00
|
|
|
if (caseFileName().contains("Result Mock Debug Model"))
|
2012-06-26 09:10:41 -05:00
|
|
|
{
|
2013-04-11 05:06:38 -05:00
|
|
|
readerInterface = this->createMockModel(this->caseFileName());
|
2012-06-26 09:10:41 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-04-08 01:36:34 -05:00
|
|
|
if (!QFile::exists(caseFileName()))
|
2012-06-26 09:10:41 -05:00
|
|
|
{
|
2013-02-11 01:16:51 -06:00
|
|
|
return false;
|
2012-06-26 09:10:41 -05:00
|
|
|
}
|
|
|
|
|
2013-03-22 09:43:42 -05:00
|
|
|
cvf::ref<RigCaseData> eclipseCase = new RigCaseData;
|
2012-06-26 09:10:41 -05:00
|
|
|
readerInterface = new RifReaderEclipseOutput;
|
2013-04-08 01:36:34 -05:00
|
|
|
if (!readerInterface->open(caseFileName(), eclipseCase.p()))
|
2012-06-26 09:10:41 -05:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-03-18 08:34:29 -05:00
|
|
|
this->setReservoirData( eclipseCase.p() );
|
2012-06-26 09:10:41 -05:00
|
|
|
}
|
|
|
|
|
2013-03-18 08:34:29 -05:00
|
|
|
results(RifReaderInterface::MATRIX_RESULTS)->setReaderInterface(readerInterface.p());
|
|
|
|
results(RifReaderInterface::FRACTURE_RESULTS)->setReaderInterface(readerInterface.p());
|
|
|
|
|
2013-02-06 06:44:27 -06:00
|
|
|
progInfo.incrementProgress();
|
2012-06-26 09:10:41 -05:00
|
|
|
|
2013-03-18 08:34:29 -05:00
|
|
|
CVF_ASSERT(this->reservoirData());
|
2012-06-26 09:10:41 -05:00
|
|
|
CVF_ASSERT(readerInterface.notNull());
|
|
|
|
|
2013-02-14 06:16:56 -06:00
|
|
|
progInfo.setProgressDescription("Computing Case Cache");
|
2013-02-22 03:12:06 -06:00
|
|
|
computeCachedData();
|
2012-06-26 09:10:41 -05:00
|
|
|
|
2013-04-12 05:03:04 -05:00
|
|
|
m_gridAndWellDataIsReadFromFile = true;
|
|
|
|
m_activeCellInfoIsReadFromFile = true;
|
|
|
|
|
2012-06-26 09:10:41 -05:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-02-27 08:27:33 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-03-22 09:43:42 -05:00
|
|
|
bool RimResultCase::openAndReadActiveCellData(RigCaseData* mainEclipseCase)
|
2013-02-27 08:27:33 -06:00
|
|
|
{
|
2013-04-12 05:03:04 -05:00
|
|
|
// Early exit if data is already read
|
|
|
|
if (m_activeCellInfoIsReadFromFile) return true;
|
2013-02-27 08:27:33 -06:00
|
|
|
|
2013-04-12 05:03:04 -05:00
|
|
|
cvf::ref<RifReaderInterface> readerInterface;
|
2013-04-11 05:06:38 -05:00
|
|
|
if (caseFileName().contains("Result Mock Debug Model"))
|
2013-02-27 08:27:33 -06:00
|
|
|
{
|
2013-04-11 05:06:38 -05:00
|
|
|
readerInterface = this->createMockModel(this->caseFileName());
|
2013-02-27 08:27:33 -06:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-04-08 01:36:34 -05:00
|
|
|
if (!QFile::exists(caseFileName()))
|
2013-02-27 08:27:33 -06:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-03-22 09:43:42 -05:00
|
|
|
cvf::ref<RigCaseData> eclipseCase = new RigCaseData;
|
2013-03-05 06:10:26 -06:00
|
|
|
|
|
|
|
CVF_ASSERT(mainEclipseCase && mainEclipseCase->mainGrid());
|
|
|
|
eclipseCase->setMainGrid(mainEclipseCase->mainGrid());
|
2013-02-27 08:27:33 -06:00
|
|
|
|
2013-03-19 02:21:55 -05:00
|
|
|
size_t scalarIndexWithMaxTimeStepCount = cvf::UNDEFINED_SIZE_T;
|
|
|
|
mainEclipseCase->results(RifReaderInterface::MATRIX_RESULTS)->maxTimeStepCount(&scalarIndexWithMaxTimeStepCount);
|
|
|
|
if (scalarIndexWithMaxTimeStepCount == cvf::UNDEFINED_SIZE_T)
|
2013-02-27 08:27:33 -06:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-03-19 02:21:55 -05:00
|
|
|
std::vector<QDateTime> timeStepDates = mainEclipseCase->results(RifReaderInterface::MATRIX_RESULTS)->timeStepDates(scalarIndexWithMaxTimeStepCount);
|
|
|
|
|
|
|
|
cvf::ref<RifReaderEclipseOutput> readerEclipseOutput = new RifReaderEclipseOutput;
|
2013-04-08 01:36:34 -05:00
|
|
|
if (!readerEclipseOutput->openAndReadActiveCellData(caseFileName(), timeStepDates, eclipseCase.p()))
|
2013-03-19 02:21:55 -05:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
readerEclipseOutput->close();
|
2013-02-27 08:27:33 -06:00
|
|
|
|
2013-03-18 08:34:29 -05:00
|
|
|
this->setReservoirData( eclipseCase.p() );
|
2013-03-19 02:21:55 -05:00
|
|
|
|
|
|
|
readerInterface = readerEclipseOutput;
|
2013-02-27 08:27:33 -06:00
|
|
|
}
|
|
|
|
|
2013-03-18 08:34:29 -05:00
|
|
|
results(RifReaderInterface::MATRIX_RESULTS)->setReaderInterface(readerInterface.p());
|
|
|
|
results(RifReaderInterface::FRACTURE_RESULTS)->setReaderInterface(readerInterface.p());
|
|
|
|
|
|
|
|
CVF_ASSERT(this->reservoirData());
|
2013-02-27 08:27:33 -06:00
|
|
|
CVF_ASSERT(readerInterface.notNull());
|
|
|
|
|
2013-03-21 09:31:47 -05:00
|
|
|
reservoirData()->computeActiveCellBoundingBoxes();
|
2013-02-27 08:27:33 -06:00
|
|
|
|
2013-04-12 05:03:04 -05:00
|
|
|
m_activeCellInfoIsReadFromFile = true;
|
|
|
|
|
2013-02-27 08:27:33 -06:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-06-26 09:10:41 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-03-22 09:43:42 -05:00
|
|
|
cvf::ref<RifReaderInterface> RimResultCase::createMockModel(QString modelName)
|
2012-06-26 09:10:41 -05:00
|
|
|
{
|
|
|
|
cvf::ref<RifReaderMockModel> mockFileInterface = new RifReaderMockModel;
|
2013-03-22 09:43:42 -05:00
|
|
|
cvf::ref<RigCaseData> reservoir = new RigCaseData;
|
2012-06-26 09:10:41 -05:00
|
|
|
|
|
|
|
if (modelName == "Result Mock Debug Model Simple")
|
|
|
|
{
|
|
|
|
// Create the mock file interface and and RigSerervoir and set them up.
|
|
|
|
mockFileInterface->setWorldCoordinates(cvf::Vec3d(10, 10, 10), cvf::Vec3d(20, 20, 20));
|
|
|
|
mockFileInterface->setGridPointDimensions(cvf::Vec3st(4, 5, 6));
|
|
|
|
mockFileInterface->addLocalGridRefinement(cvf::Vec3st(0, 2, 2), cvf::Vec3st(0, 2, 2), cvf::Vec3st(3, 3, 3));
|
|
|
|
|
|
|
|
mockFileInterface->open("", reservoir.p());
|
|
|
|
{
|
|
|
|
size_t idx = reservoir->mainGrid()->cellIndexFromIJK(1, 3, 4);
|
2013-02-25 07:07:59 -06:00
|
|
|
|
|
|
|
//TODO: Rewrite active cell info in mock models
|
|
|
|
//reservoir->mainGrid()->cell(idx).setActiveIndexInMatrixModel(cvf::UNDEFINED_SIZE_T);
|
2012-06-26 09:10:41 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
size_t idx = reservoir->mainGrid()->cellIndexFromIJK(2, 2, 3);
|
2013-02-25 07:07:59 -06:00
|
|
|
|
|
|
|
//TODO: Rewrite active cell info in mock models
|
|
|
|
//reservoir->mainGrid()->cell(idx).setActiveIndexInMatrixModel(cvf::UNDEFINED_SIZE_T);
|
2012-06-26 09:10:41 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (modelName == "Result Mock Debug Model With Results")
|
|
|
|
{
|
|
|
|
mockFileInterface->setWorldCoordinates(cvf::Vec3d(10, 10, 10), cvf::Vec3d(-20, -20, -20));
|
|
|
|
mockFileInterface->setGridPointDimensions(cvf::Vec3st(5, 10, 20));
|
|
|
|
mockFileInterface->addLocalGridRefinement(cvf::Vec3st(0, 3, 3), cvf::Vec3st(1, 4, 9), cvf::Vec3st(2, 2, 2));
|
|
|
|
mockFileInterface->setResultInfo(3, 10);
|
|
|
|
|
|
|
|
mockFileInterface->open("", reservoir.p());
|
|
|
|
|
|
|
|
// Make a fault
|
|
|
|
cvf::Vec3d& tmp = reservoir->mainGrid()->nodes()[1];
|
|
|
|
tmp += cvf::Vec3d(1, 0, 0);
|
|
|
|
}
|
|
|
|
else if (modelName =="Result Mock Debug Model Large With Results")
|
|
|
|
{
|
|
|
|
double startX = 0;
|
|
|
|
double startY = 0;
|
|
|
|
double startZ = 0;
|
|
|
|
|
|
|
|
double widthX = 6000;
|
|
|
|
double widthY = 12000;
|
|
|
|
double widthZ = 500;
|
|
|
|
|
|
|
|
double offsetX = 0;
|
|
|
|
double offsetY = 0;
|
|
|
|
double offsetZ = 0;
|
|
|
|
|
|
|
|
// Test code to simulate UTM coordinates
|
|
|
|
offsetX = 400000;
|
|
|
|
offsetY = 6000000;
|
|
|
|
offsetZ = 0;
|
|
|
|
|
|
|
|
|
|
|
|
mockFileInterface->setWorldCoordinates(cvf::Vec3d(startX + offsetX, startY + offsetY, startZ + offsetZ), cvf::Vec3d(startX + widthX + offsetX, startY + widthY + offsetY, startZ + widthZ + offsetZ));
|
|
|
|
mockFileInterface->setGridPointDimensions(cvf::Vec3st(50, 100, 200));
|
|
|
|
mockFileInterface->addLocalGridRefinement(cvf::Vec3st(0, 30, 30), cvf::Vec3st(1, 40, 90), cvf::Vec3st(2, 2, 2));
|
|
|
|
mockFileInterface->setResultInfo(3, 10);
|
|
|
|
|
|
|
|
mockFileInterface->open("", reservoir.p());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-03-18 08:34:29 -05:00
|
|
|
this->setReservoirData( reservoir.p() );
|
2012-06-26 09:10:41 -05:00
|
|
|
|
|
|
|
return mockFileInterface.p();
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-03-22 09:43:42 -05:00
|
|
|
RimResultCase::~RimResultCase()
|
2012-06-26 09:10:41 -05:00
|
|
|
{
|
|
|
|
reservoirViews.deleteAllChildObjects();
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-03-22 09:43:42 -05:00
|
|
|
QString RimResultCase::locationOnDisc() const
|
2012-06-26 09:10:41 -05:00
|
|
|
{
|
2013-04-11 05:06:38 -05:00
|
|
|
QFileInfo fi(caseFileName());
|
|
|
|
return fi.absolutePath();
|
2012-06-26 09:10:41 -05:00
|
|
|
}
|
|
|
|
|
2013-02-11 01:16:51 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-04-08 01:36:34 -05:00
|
|
|
void RimResultCase::readGridDimensions(std::vector< std::vector<int> >& gridDimensions)
|
2013-02-11 01:16:51 -06:00
|
|
|
{
|
2013-04-11 05:06:38 -05:00
|
|
|
RifEclipseOutputFileTools::readGridDimensions(caseFileName(), gridDimensions);
|
2013-04-08 01:36:34 -05:00
|
|
|
}
|
2013-02-11 01:16:51 -06:00
|
|
|
|
2013-04-08 01:36:34 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-04-12 01:31:59 -05:00
|
|
|
void RimResultCase::updateFilePathsFromProjectPath(const QString& newProjectPath, const QString& oldProjectPath)
|
2013-04-08 01:36:34 -05:00
|
|
|
{
|
2013-04-12 01:31:59 -05:00
|
|
|
bool foundFile = false;
|
|
|
|
std::vector<QString> searchedPaths;
|
2013-02-11 01:16:51 -06:00
|
|
|
|
2013-04-12 01:31:59 -05:00
|
|
|
// Update filename and folder paths when opening project from a different file location
|
|
|
|
caseFileName = relocateFile(caseFileName(), newProjectPath, oldProjectPath, &foundFile, &searchedPaths);
|
2013-02-11 01:16:51 -06:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-04-08 07:29:43 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-04-11 05:06:38 -05:00
|
|
|
void RimResultCase::setCaseInfo(const QString& userDescription, const QString& caseFileName)
|
2013-04-08 07:29:43 -05:00
|
|
|
{
|
2013-05-08 03:41:56 -05:00
|
|
|
this->caseUserDescription = userDescription;
|
|
|
|
this->caseFileName = caseFileName;
|
|
|
|
|
|
|
|
RimProject* proj = RiaApplication::instance()->project();
|
|
|
|
proj->assignCaseIdToCase(this);
|
2013-04-11 05:06:38 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimResultCase::initAfterRead()
|
|
|
|
{
|
|
|
|
RimCase::initAfterRead();
|
|
|
|
|
|
|
|
// Convert from old (9.0.2) way of storing the case file
|
|
|
|
if (caseFileName().isEmpty())
|
|
|
|
{
|
|
|
|
if (!this->caseName().isEmpty() && !caseDirectory().isEmpty())
|
|
|
|
{
|
|
|
|
caseFileName = QDir::fromNativeSeparators(caseDirectory()) + "/" + caseName() + ".EGRID";
|
|
|
|
}
|
|
|
|
}
|
2013-04-08 07:29:43 -05:00
|
|
|
}
|
|
|
|
|