Merge pull request #20 from OPM/internal

Update dev branch to latest
This commit is contained in:
JacobStoren 2013-04-02 06:14:26 -07:00
commit 3c08fd8abf
215 changed files with 11243 additions and 3197 deletions

View File

@ -16,7 +16,7 @@
//
/////////////////////////////////////////////////////////////////////////////////
#include "RIStdInclude.h"
#include "RiaStdInclude.h"
#include "cafLog.h"
#include "cafEffectCache.h"
@ -26,20 +26,20 @@
#include "cvfStructGridGeometryGenerator.h"
#include "RIVersionInfo.h"
#include "RIBaseDefs.h"
#include "RiaVersionInfo.h"
#include "RiaBaseDefs.h"
#include "RIApplication.h"
#include "RIMainWindow.h"
#include "RIViewer.h"
#include "RIProcessMonitor.h"
#include "RIPreferences.h"
#include "RiaApplication.h"
#include "RiuMainWindow.h"
#include "RiuViewer.h"
#include "RiuProcessMonitor.h"
#include "RiaPreferences.h"
#include "RimResultReservoir.h"
#include "RimInputReservoir.h"
#include "RimResultCase.h"
#include "RimInputCase.h"
#include "RimReservoirView.h"
#include "RigReservoir.h"
#include "RigCaseData.h"
#include "RigCell.h"
#include "RigReservoirBuilderMock.h"
@ -55,15 +55,16 @@
#include "RimUiTreeModelPdm.h"
#include "RiaImageCompareReporter.h"
#include "RiaImageFileCompare.h"
#include "cafProgressInfo.h"
namespace caf
{
template<>
void AppEnum< RIApplication::RINavigationPolicy >::setUp()
void AppEnum< RiaApplication::RINavigationPolicy >::setUp()
{
addItem(RIApplication::NAVIGATION_POLICY_CEETRON, "NAVIGATION_POLICY_CEETRON", "Ceetron");
addItem(RIApplication::NAVIGATION_POLICY_CAD, "NAVIGATION_POLICY_CAD", "CAD");
setDefault(RIApplication::NAVIGATION_POLICY_CAD);
addItem(RiaApplication::NAVIGATION_POLICY_CEETRON, "NAVIGATION_POLICY_CEETRON", "Ceetron");
addItem(RiaApplication::NAVIGATION_POLICY_CAD, "NAVIGATION_POLICY_CAD", "CAD");
setDefault(RiaApplication::NAVIGATION_POLICY_CAD);
}
}
@ -82,7 +83,7 @@ namespace RegTestNames
//==================================================================================================
///
/// \class RIApplication
/// \class RiaApplication
///
/// Application class
///
@ -92,7 +93,7 @@ namespace RegTestNames
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RIApplication::RIApplication(int& argc, char** argv)
RiaApplication::RiaApplication(int& argc, char** argv)
: QApplication(argc, argv)
{
// USed to get registry settings in the right place
@ -105,7 +106,7 @@ RIApplication::RIApplication(int& argc, char** argv)
//cvf::Trace::enable(false);
m_preferences = new RIPreferences;
m_preferences = new RiaPreferences;
readPreferences();
applyPreferences();
@ -132,14 +133,14 @@ RIApplication::RIApplication(int& argc, char** argv)
#ifdef WIN32
//m_startupDefaultDirectory += "/My Documents/";
#endif
setDefaultFileDialogDirectory("MULTICASEIMPORT", "/");
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RIApplication::~RIApplication()
RiaApplication::~RiaApplication()
{
delete m_preferences;
}
@ -148,18 +149,18 @@ RIApplication::~RIApplication()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RIApplication* RIApplication::instance()
RiaApplication* RiaApplication::instance()
{
return static_cast<RIApplication*>qApp;
return static_cast<RiaApplication*>qApp;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RIApplication::setWindowCaptionFromAppState()
void RiaApplication::setWindowCaptionFromAppState()
{
RIMainWindow* mainWnd = RIMainWindow::instance();
RiuMainWindow* mainWnd = RiuMainWindow::instance();
if (!mainWnd) return;
// The stuff being done here should really be handled by Qt automatically as a result of
@ -185,7 +186,7 @@ void RIApplication::setWindowCaptionFromAppState()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RIApplication::processNonGuiEvents()
void RiaApplication::processNonGuiEvents()
{
processEvents(QEventLoop::ExcludeUserInputEvents);
}
@ -194,7 +195,7 @@ void RIApplication::processNonGuiEvents()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const char* RIApplication::getVersionStringApp(bool includeCrtInfo)
const char* RiaApplication::getVersionStringApp(bool includeCrtInfo)
{
// Use static buf so we can return ptr
static char szBuf[1024];
@ -220,16 +221,23 @@ const char* RIApplication::getVersionStringApp(bool includeCrtInfo)
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RIApplication::loadProject(const QString& projectFileName)
bool RiaApplication::loadProject(const QString& projectFileName)
{
// First Close the current project
if (!closeProject(true)) return false;
// Open the project file and read the serialized data.
// Will initialize itself.
if (!QFile::exists(projectFileName)) return false;
m_project->fileName = projectFileName;
m_project->readFile();
m_project->fileName = projectFileName; // Make sure we overwrite the old filename read from the project file
// On error, delete everything, and bail out.
if (m_project->projectFileVersionString().isEmpty())
{
closeProject(false);
@ -237,37 +245,84 @@ bool RIApplication::loadProject(const QString& projectFileName)
QString tmp = QString("Unknown project file version detected in file \n%1\n\nCould not open project.").arg(projectFileName);
QMessageBox::warning(NULL, "Error when opening project file", tmp);
RIMainWindow* mainWnd = RIMainWindow::instance();
RiuMainWindow* mainWnd = RiuMainWindow::instance();
mainWnd->setPdmRoot(NULL);
// Delete all object possibly generated by readFile()
delete m_project;
m_project = new RimProject;
onProjectOpenedOrClosed();
return true;
}
else
///////
// Load the external data, and initialize stuff that needs specific ordering
m_preferences->lastUsedProjectFileName = projectFileName;
writePreferences();
for (size_t cgIdx = 0; cgIdx < m_project->caseGroups.size(); ++cgIdx)
{
m_preferences->lastUsedProjectFileName = projectFileName;
writePreferences();
// Load the Main case of each IdenticalGridCaseGroup
size_t i;
for (i = 0; i < m_project->reservoirs().size(); ++i)
RimIdenticalGridCaseGroup* igcg = m_project->caseGroups[cgIdx];
igcg->loadMainCaseAndActiveCellInfo();
}
// Now load the ReservoirViews for the cases
std::vector<RimCase*> casesToLoad;
// Add all "native" cases in the project
for (size_t cIdx = 0; cIdx < m_project->reservoirs().size(); ++cIdx)
{
casesToLoad.push_back(m_project->reservoirs()[cIdx]);
}
// Add all statistics cases as well
for (size_t cgIdx = 0; cgIdx < m_project->caseGroups().size(); ++cgIdx)
{
if (m_project->caseGroups[cgIdx]->statisticsCaseCollection())
{
RimReservoir* ri = m_project->reservoirs()[i];
CVF_ASSERT(ri);
size_t j;
for (j = 0; j < ri->reservoirViews().size(); j++)
caf::PdmPointersField<RimCase*> & statCases = m_project->caseGroups[cgIdx]->statisticsCaseCollection()->reservoirs();
for (size_t scIdx = 0; scIdx < statCases.size(); ++scIdx)
{
RimReservoirView* riv = ri->reservoirViews()[j];
CVF_ASSERT(riv);
riv->loadDataAndUpdate();
casesToLoad.push_back(statCases[scIdx]);
}
}
}
caf::ProgressInfo caseProgress(casesToLoad.size() , "Reading Cases");
for (size_t cIdx = 0; cIdx < casesToLoad.size(); ++cIdx)
{
RimCase* ri = casesToLoad[cIdx];
CVF_ASSERT(ri);
caseProgress.setProgressDescription(ri->caseName());
caf::ProgressInfo viewProgress(ri->reservoirViews().size() , "Creating Views");
size_t j;
for (j = 0; j < ri->reservoirViews().size(); j++)
{
RimReservoirView* riv = ri->reservoirViews[j];
CVF_ASSERT(riv);
viewProgress.setProgressDescription(riv->name());
riv->loadDataAndUpdate();
viewProgress.incrementProgress();
}
caseProgress.incrementProgress();
}
onProjectOpenedOrClosed();
return true;
}
@ -275,7 +330,7 @@ bool RIApplication::loadProject(const QString& projectFileName)
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RIApplication::loadLastUsedProject()
bool RiaApplication::loadLastUsedProject()
{
return loadProject(m_preferences->lastUsedProjectFileName);
}
@ -284,7 +339,7 @@ bool RIApplication::loadLastUsedProject()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RIApplication::saveProject()
bool RiaApplication::saveProject()
{
CVF_ASSERT(m_project.notNull());
@ -302,11 +357,11 @@ bool RIApplication::saveProject()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RIApplication::saveProjectPromptForFileName()
bool RiaApplication::saveProjectPromptForFileName()
{
//if (m_project.isNull()) return true;
RIApplication* app = RIApplication::instance();
RiaApplication* app = RiaApplication::instance();
QString startPath;
if (!m_project->fileName().isEmpty())
@ -341,7 +396,7 @@ bool RIApplication::saveProjectPromptForFileName()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RIApplication::saveProjectAs(const QString& fileName)
bool RiaApplication::saveProjectAs(const QString& fileName)
{
m_project->fileName = fileName;
m_project->writeFile();
@ -356,9 +411,9 @@ bool RIApplication::saveProjectAs(const QString& fileName)
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RIApplication::closeProject(bool askToSaveIfDirty)
bool RiaApplication::closeProject(bool askToSaveIfDirty)
{
RIMainWindow* mainWnd = RIMainWindow::instance();
RiuMainWindow* mainWnd = RiuMainWindow::instance();
terminateProcess();
@ -396,9 +451,9 @@ bool RIApplication::closeProject(bool askToSaveIfDirty)
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RIApplication::onProjectOpenedOrClosed()
void RiaApplication::onProjectOpenedOrClosed()
{
RIMainWindow* mainWnd = RIMainWindow::instance();
RiuMainWindow* mainWnd = RiuMainWindow::instance();
if (!mainWnd) return;
mainWnd->initializeGuiNewProjectLoaded();
@ -411,7 +466,7 @@ void RIApplication::onProjectOpenedOrClosed()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RIApplication::currentProjectFileName() const
QString RiaApplication::currentProjectFileName() const
{
return m_project->fileName();
}
@ -420,7 +475,7 @@ QString RIApplication::currentProjectFileName() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RIApplication::openEclipseCaseFromFile(const QString& fileName)
bool RiaApplication::openEclipseCaseFromFile(const QString& fileName)
{
if (!QFile::exists(fileName)) return false;
@ -434,12 +489,12 @@ bool RIApplication::openEclipseCaseFromFile(const QString& fileName)
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RIApplication::openEclipseCase(const QString& caseName, const QString& caseFileName)
bool RiaApplication::openEclipseCase(const QString& caseName, const QString& caseFileName)
{
QFileInfo gridFileName(caseFileName);
QString casePath = gridFileName.absolutePath();
RimResultReservoir* rimResultReservoir = new RimResultReservoir();
RimResultCase* rimResultReservoir = new RimResultCase();
rimResultReservoir->caseName = caseName;
rimResultReservoir->caseFileName = caseFileName;
rimResultReservoir->caseDirectory = casePath;
@ -472,9 +527,9 @@ bool RIApplication::openEclipseCase(const QString& caseName, const QString& case
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RIApplication::openInputEclipseCase(const QString& caseName, const QStringList& caseFileNames)
bool RiaApplication::openInputEclipseCase(const QString& caseName, const QStringList& caseFileNames)
{
RimInputReservoir* rimInputReservoir = new RimInputReservoir();
RimInputCase* rimInputReservoir = new RimInputCase();
rimInputReservoir->caseName = caseName;
rimInputReservoir->openDataFileSet(caseFileNames);
@ -502,7 +557,7 @@ bool RIApplication::openInputEclipseCase(const QString& caseName, const QStringL
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RIApplication::createMockModel()
void RiaApplication::createMockModel()
{
openEclipseCase("Result Mock Debug Model Simple", "Result Mock Debug Model Simple");
}
@ -510,7 +565,7 @@ void RIApplication::createMockModel()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RIApplication::createResultsMockModel()
void RiaApplication::createResultsMockModel()
{
openEclipseCase("Result Mock Debug Model With Results", "Result Mock Debug Model With Results");
}
@ -519,7 +574,7 @@ void RIApplication::createResultsMockModel()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RIApplication::createLargeResultsMockModel()
void RiaApplication::createLargeResultsMockModel()
{
openEclipseCase("Result Mock Debug Model Large With Results", "Result Mock Debug Model Large With Results");
}
@ -527,7 +582,7 @@ void RIApplication::createLargeResultsMockModel()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RIApplication::createInputMockModel()
void RiaApplication::createInputMockModel()
{
openInputEclipseCase("Input Mock Debug Model Simple", QStringList("Input Mock Debug Model Simple"));
}
@ -535,7 +590,7 @@ void RIApplication::createInputMockModel()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const RimReservoirView* RIApplication::activeReservoirView() const
const RimReservoirView* RiaApplication::activeReservoirView() const
{
return m_activeReservoirView;
}
@ -543,7 +598,7 @@ const RimReservoirView* RIApplication::activeReservoirView() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimReservoirView* RIApplication::activeReservoirView()
RimReservoirView* RiaApplication::activeReservoirView()
{
return m_activeReservoirView;
}
@ -551,7 +606,7 @@ RimReservoirView* RIApplication::activeReservoirView()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RIApplication::setActiveReservoirView(RimReservoirView* rv)
void RiaApplication::setActiveReservoirView(RimReservoirView* rv)
{
m_activeReservoirView = rv;
}
@ -559,7 +614,7 @@ void RIApplication::setActiveReservoirView(RimReservoirView* rv)
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RIApplication::setUseShaders(bool enable)
void RiaApplication::setUseShaders(bool enable)
{
m_preferences->useShaders = enable;
writePreferences();
@ -568,7 +623,7 @@ void RIApplication::setUseShaders(bool enable)
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RIApplication::useShaders() const
bool RiaApplication::useShaders() const
{
if (!m_preferences->useShaders) return false;
@ -582,7 +637,7 @@ bool RIApplication::useShaders() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RIApplication::RINavigationPolicy RIApplication::navigationPolicy() const
RiaApplication::RINavigationPolicy RiaApplication::navigationPolicy() const
{
return m_preferences->navigationPolicy();
}
@ -591,7 +646,7 @@ RIApplication::RINavigationPolicy RIApplication::navigationPolicy() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RIApplication::setShowPerformanceInfo(bool enable)
void RiaApplication::setShowPerformanceInfo(bool enable)
{
m_preferences->showHud = enable;
writePreferences();
@ -601,7 +656,7 @@ void RIApplication::setShowPerformanceInfo(bool enable)
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RIApplication::showPerformanceInfo() const
bool RiaApplication::showPerformanceInfo() const
{
return m_preferences->showHud;
}
@ -610,7 +665,7 @@ bool RIApplication::showPerformanceInfo() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RIApplication::parseArguments()
bool RiaApplication::parseArguments()
{
QStringList arguments = QCoreApplication::arguments();
@ -765,7 +820,7 @@ bool RIApplication::parseArguments()
if (isRunRegressionTest)
{
RIMainWindow* mainWnd = RIMainWindow::instance();
RiuMainWindow* mainWnd = RiuMainWindow::instance();
if (mainWnd)
{
mainWnd->hideAllDockWindows();
@ -830,7 +885,7 @@ bool RIApplication::parseArguments()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RIApplication::scriptDirectory() const
QString RiaApplication::scriptDirectory() const
{
return m_preferences->scriptDirectory();
}
@ -838,7 +893,7 @@ QString RIApplication::scriptDirectory() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RIApplication::scriptEditorPath() const
QString RiaApplication::scriptEditorPath() const
{
return m_preferences->scriptEditorExecutable();
}
@ -846,7 +901,7 @@ QString RIApplication::scriptEditorPath() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RIApplication::octavePath() const
QString RiaApplication::octavePath() const
{
return m_preferences->octaveExecutable();
}
@ -854,9 +909,9 @@ QString RIApplication::octavePath() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RIApplication::slotWorkerProcessFinished(int exitCode, QProcess::ExitStatus exitStatus)
void RiaApplication::slotWorkerProcessFinished(int exitCode, QProcess::ExitStatus exitStatus)
{
RIMainWindow::instance()->processMonitor()->stopMonitorWorkProcess();
RiuMainWindow::instance()->processMonitor()->stopMonitorWorkProcess();
// Execute delete later so that other slots that are hooked up
// get a chance to run before we delete the object
@ -888,14 +943,14 @@ void RIApplication::slotWorkerProcessFinished(int exitCode, QProcess::ExitStatus
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RIApplication::launchProcess(const QString& program, const QStringList& arguments)
bool RiaApplication::launchProcess(const QString& program, const QStringList& arguments)
{
if (m_workerProcess == NULL)
{
m_workerProcess = new caf::UiProcess(this);
connect(m_workerProcess, SIGNAL(finished(int, QProcess::ExitStatus)), SLOT(slotWorkerProcessFinished(int, QProcess::ExitStatus)));
RIMainWindow::instance()->processMonitor()->startMonitorWorkProcess(m_workerProcess);
RiuMainWindow::instance()->processMonitor()->startMonitorWorkProcess(m_workerProcess);
m_workerProcess->start(program, arguments);
if (!m_workerProcess->waitForStarted(1000))
@ -903,9 +958,9 @@ bool RIApplication::launchProcess(const QString& program, const QStringList& arg
m_workerProcess->close();
m_workerProcess = NULL;
RIMainWindow::instance()->processMonitor()->stopMonitorWorkProcess();
RiuMainWindow::instance()->processMonitor()->stopMonitorWorkProcess();
QMessageBox::warning(RIMainWindow::instance(), "Script execution", "Failed to start script executable located at\n" + program);
QMessageBox::warning(RiuMainWindow::instance(), "Script execution", "Failed to start script executable located at\n" + program);
return false;
}
@ -922,7 +977,7 @@ bool RIApplication::launchProcess(const QString& program, const QStringList& arg
//--------------------------------------------------------------------------------------------------
/// Read fields of a Pdm object using QSettings
//--------------------------------------------------------------------------------------------------
void RIApplication::readPreferences()
void RiaApplication::readPreferences()
{
QSettings settings;
std::vector<caf::PdmFieldHandle*> fields;
@ -944,7 +999,7 @@ void RIApplication::readPreferences()
//--------------------------------------------------------------------------------------------------
/// Write fields of a Pdm object using QSettings
//--------------------------------------------------------------------------------------------------
void RIApplication::writePreferences()
void RiaApplication::writePreferences()
{
QSettings settings;
@ -963,7 +1018,7 @@ void RIApplication::writePreferences()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RIPreferences* RIApplication::preferences()
RiaPreferences* RiaApplication::preferences()
{
return m_preferences;
}
@ -971,7 +1026,7 @@ RIPreferences* RIApplication::preferences()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RIApplication::applyPreferences()
void RiaApplication::applyPreferences()
{
if (m_activeReservoirView && m_activeReservoirView->viewer())
{
@ -999,7 +1054,7 @@ void RIApplication::applyPreferences()
if (this->project())
{
this->project()->setUserScriptPath(m_preferences->scriptDirectory());
RimUiTreeModelPdm* treeModel = RIMainWindow::instance()->uiPdmModel();
RimUiTreeModelPdm* treeModel = RiuMainWindow::instance()->uiPdmModel();
if (treeModel) treeModel->rebuildUiSubTree(this->project()->scriptCollection());
}
@ -1008,7 +1063,7 @@ void RIApplication::applyPreferences()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RIApplication::terminateProcess()
void RiaApplication::terminateProcess()
{
if (m_workerProcess)
{
@ -1021,7 +1076,7 @@ void RIApplication::terminateProcess()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RIApplication::defaultFileDialogDirectory(const QString& dialogName)
QString RiaApplication::defaultFileDialogDirectory(const QString& dialogName)
{
QString defaultDirectory = m_startupDefaultDirectory;
std::map<QString, QString>::iterator it;
@ -1038,7 +1093,7 @@ QString RIApplication::defaultFileDialogDirectory(const QString& dialogName)
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RIApplication::setDefaultFileDialogDirectory(const QString& dialogName, const QString& defaultDirectory)
void RiaApplication::setDefaultFileDialogDirectory(const QString& dialogName, const QString& defaultDirectory)
{
m_fileDialogDefaultDirectories[dialogName] = defaultDirectory;
}
@ -1046,7 +1101,7 @@ void RIApplication::setDefaultFileDialogDirectory(const QString& dialogName, con
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RIApplication::saveSnapshotPromtpForFilename()
void RiaApplication::saveSnapshotPromtpForFilename()
{
QString startPath;
if (!m_project->fileName().isEmpty())
@ -1076,7 +1131,7 @@ void RIApplication::saveSnapshotPromtpForFilename()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RIApplication::saveSnapshotAs(const QString& fileName)
void RiaApplication::saveSnapshotAs(const QString& fileName)
{
if (m_activeReservoirView && m_activeReservoirView->viewer())
{
@ -1095,7 +1150,7 @@ void RIApplication::saveSnapshotAs(const QString& fileName)
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RIApplication::copySnapshotToClipboard()
void RiaApplication::copySnapshotToClipboard()
{
if (m_activeReservoirView && m_activeReservoirView->viewer())
{
@ -1112,9 +1167,9 @@ void RIApplication::copySnapshotToClipboard()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RIApplication::saveSnapshotForAllViews(const QString& snapshotFolderName)
void RiaApplication::saveSnapshotForAllViews(const QString& snapshotFolderName)
{
RIMainWindow* mainWnd = RIMainWindow::instance();
RiuMainWindow* mainWnd = RiuMainWindow::instance();
if (!mainWnd) return;
if (m_project.isNull()) return;
@ -1134,7 +1189,7 @@ void RIApplication::saveSnapshotForAllViews(const QString& snapshotFolderName)
for (size_t i = 0; i < m_project->reservoirs().size(); ++i)
{
RimReservoir* ri = m_project->reservoirs()[i];
RimCase* ri = m_project->reservoirs()[i];
if (!ri) continue;
for (size_t j = 0; j < ri->reservoirViews().size(); j++)
@ -1145,7 +1200,7 @@ void RIApplication::saveSnapshotForAllViews(const QString& snapshotFolderName)
{
setActiveReservoirView(riv);
RIViewer* viewer = riv->viewer();
RiuViewer* viewer = riv->viewer();
mainWnd->setActiveViewer(viewer);
// Process all events to avoid a black image when grabbing frame buffer
@ -1174,7 +1229,7 @@ void removeDirectoryWithContent(QDir dirToDelete )
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RIApplication::runRegressionTest(const QString& testRootPath)
void RiaApplication::runRegressionTest(const QString& testRootPath)
{
QString generatedFolderName = RegTestNames::generatedFolderName;
QString diffFolderName = RegTestNames::diffFolderName;
@ -1253,6 +1308,8 @@ void RIApplication::runRegressionTest(const QString& testRootPath)
qDebug() << "Error comparing :" << imgComparator.errorMessage() << "\n" << imgComparator.errorDetails();
}
}
closeProject(false);
}
}
}
@ -1260,7 +1317,7 @@ void RIApplication::runRegressionTest(const QString& testRootPath)
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RIApplication::updateRegressionTest(const QString& testRootPath)
void RiaApplication::updateRegressionTest(const QString& testRootPath)
{
// Find all sub folders
@ -1291,3 +1348,72 @@ void RIApplication::updateRegressionTest(const QString& testRootPath)
}
}
}
//--------------------------------------------------------------------------------------------------
/// Make sure changes in this functions is validated to RimIdenticalGridCaseGroup::initAfterRead()
//--------------------------------------------------------------------------------------------------
bool RiaApplication::addEclipseCases(const QStringList& fileNames)
{
if (fileNames.size() == 0) return true;
// First file is read completely including grid.
// The main grid from the first case is reused directly in for the other cases.
// When reading active cell info, only the total cell count is tested for consistency
RigCaseData* mainEclipseCase = NULL;
{
QString firstFileName = fileNames[0];
QFileInfo gridFileName(firstFileName);
QString caseName = gridFileName.completeBaseName();
QString casePath = gridFileName.absolutePath();
RimResultCase* rimResultReservoir = new RimResultCase();
rimResultReservoir->caseName = caseName;
rimResultReservoir->caseFileName = firstFileName;
rimResultReservoir->caseDirectory = casePath;
m_project->reservoirs.push_back(rimResultReservoir);
if (!rimResultReservoir->openEclipseGridFile())
{
return false;
}
m_project->moveEclipseCaseIntoCaseGroup(rimResultReservoir);
mainEclipseCase = rimResultReservoir->reservoirData();
}
caf::ProgressInfo info(fileNames.size(), "Reading Active Cell data");
for (int i = 1; i < fileNames.size(); i++)
{
QString fileName = fileNames[i];
QFileInfo gridFileName(fileName);
QString caseName = gridFileName.completeBaseName();
QString casePath = gridFileName.absolutePath();
RimResultCase* rimResultReservoir = new RimResultCase();
rimResultReservoir->caseName = caseName;
rimResultReservoir->caseFileName = fileName;
rimResultReservoir->caseDirectory = casePath;
m_project->reservoirs.push_back(rimResultReservoir);
if (!rimResultReservoir->openAndReadActiveCellData(mainEclipseCase))
{
return false;
}
m_project->moveEclipseCaseIntoCaseGroup(rimResultReservoir);
info.setProgress(i);
}
onProjectOpenedOrClosed();
return true;
}

View File

@ -30,11 +30,11 @@
#include "RimProject.h"
class RIProcess;
class RigReservoir;
class RimReservoir;
class RigCaseData;
class RimCase;
class Drawable;
class RiaSocketServer;
class RIPreferences;
class RiaPreferences;
namespace caf
{
@ -46,7 +46,7 @@ namespace caf
//
//
//==================================================================================================
class RIApplication : public QApplication
class RiaApplication : public QApplication
{
Q_OBJECT
@ -58,9 +58,9 @@ public:
};
public:
RIApplication(int& argc, char** argv);
~RIApplication();
static RIApplication* instance();
RiaApplication(int& argc, char** argv);
~RiaApplication();
static RiaApplication* instance();
bool parseArguments();
@ -80,6 +80,7 @@ public:
bool openEclipseCaseFromFile(const QString& fileName);
bool openEclipseCase(const QString& caseName, const QString& caseFileName);
bool addEclipseCases(const QStringList& fileNames);
bool openInputEclipseCase(const QString& caseName, const QStringList& caseFileNames);
bool loadLastUsedProject();
@ -115,7 +116,7 @@ public:
bool launchProcess(const QString& program, const QStringList& arguments);
void terminateProcess();
RIPreferences* preferences();
RiaPreferences* preferences();
void readPreferences();
void writePreferences();
void applyPreferences();
@ -138,7 +139,7 @@ private:
caf::UiProcess* m_workerProcess;
RIPreferences* m_preferences;
RiaPreferences* m_preferences;
std::map<QString, QString> m_fileDialogDefaultDirectories;
QString m_startupDefaultDirectory;

View File

@ -16,17 +16,17 @@
//
/////////////////////////////////////////////////////////////////////////////////
#include "RIStdInclude.h"
#include "RIPreferences.h"
#include "RiaStdInclude.h"
#include "RiaPreferences.h"
#include "cafPdmUiFilePathEditor.h"
CAF_PDM_SOURCE_INIT(RIPreferences, "RIPreferences");
CAF_PDM_SOURCE_INIT(RiaPreferences, "RiaPreferences");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RIPreferences::RIPreferences(void)
RiaPreferences::RiaPreferences(void)
{
CAF_PDM_InitField(&navigationPolicy, "navigationPolicy", caf::AppEnum<RIApplication::RINavigationPolicy>(RIApplication::NAVIGATION_POLICY_CAD), "Navigation mode", "", "", "");
CAF_PDM_InitField(&navigationPolicy, "navigationPolicy", caf::AppEnum<RiaApplication::RINavigationPolicy>(RiaApplication::NAVIGATION_POLICY_CAD), "Navigation mode", "", "", "");
CAF_PDM_InitFieldNoDefault(&scriptDirectory, "scriptDirectory", "Shared Script Folder", "", "", "");
scriptDirectory.setUiEditorTypeName(caf::PdmUiFilePathEditor::uiEditorTypeName());
@ -53,7 +53,7 @@ RIPreferences::RIPreferences(void)
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RIPreferences::~RIPreferences(void)
RiaPreferences::~RiaPreferences(void)
{
}
@ -61,7 +61,7 @@ RIPreferences::~RIPreferences(void)
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RIPreferences::defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute * attribute)
void RiaPreferences::defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute * attribute)
{
if (field == &scriptDirectory)
{
@ -76,7 +76,7 @@ void RIPreferences::defineEditorAttribute(const caf::PdmFieldHandle* field, QStr
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RIPreferences::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) const
void RiaPreferences::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) const
{
uiOrdering.add(&navigationPolicy);

View File

@ -19,18 +19,18 @@
#pragma once
#include "cafPdmObject.h"
#include "RIApplication.h"
#include "RiaApplication.h"
class RIPreferences : public caf::PdmObject
class RiaPreferences : public caf::PdmObject
{
CAF_PDM_HEADER_INIT;
public:
RIPreferences(void);
virtual ~RIPreferences(void);
RiaPreferences(void);
virtual ~RiaPreferences(void);
public: // Pdm Fields
caf::PdmField<caf::AppEnum< RIApplication::RINavigationPolicy > > navigationPolicy;
caf::PdmField<caf::AppEnum< RiaApplication::RINavigationPolicy > > navigationPolicy;
caf::PdmField<QString> scriptDirectory;
caf::PdmField<QString> scriptEditorExecutable;

View File

@ -4,8 +4,8 @@ project (ApplicationCode)
# NB: The generated file is written to Cmake binary folder to avoid source tree pollution
# This folder is added to include_directories
CONFIGURE_FILE( ${CMAKE_SOURCE_DIR}/ApplicationCode/Adm/RIVersionInfo.h.cmake
${CMAKE_BINARY_DIR}/Generated/RIVersionInfo.h
CONFIGURE_FILE( ${CMAKE_SOURCE_DIR}/ApplicationCode/Adm/RiaVersionInfo.h.cmake
${CMAKE_BINARY_DIR}/Generated/RiaVersionInfo.h
)
@ -20,20 +20,21 @@ include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/ProjectDataModel
${CMAKE_CURRENT_SOURCE_DIR}/ReservoirDataModel
${CMAKE_BINARY_DIR}/Generated
${CMAKE_CURRENT_BINARY_DIR}
)
# Use all cpp and h files in the subdirectories
# Use all h files in the subdirectories to make them available in the project
file( GLOB_RECURSE HEADER_FILES *.h )
list( APPEND CPP_SOURCES
RIMain.cpp
RIStdInclude.cpp
RiaMain.cpp
RiaStdInclude.cpp
)
list( APPEND CPP_SOURCES
Application/RIApplication.cpp
Application/RIPreferences.cpp
Application/RiaApplication.cpp
Application/RiaPreferences.cpp
Application/RiaImageFileCompare.cpp
Application/RiaImageCompareReporter.cpp
)
@ -49,22 +50,12 @@ list( APPEND CPP_SOURCES
ModelVisualization/RivWellHeadPartMgr.cpp
)
list( APPEND CPP_SOURCES
FileInterface/RifEclipseInputFileTools.cpp
FileInterface/RifEclipseOutputFileTools.cpp
FileInterface/RifEclipseRestartFilesetAccess.cpp
FileInterface/RifEclipseRestartDataAccess.cpp
FileInterface/RifEclipseUnifiedRestartFileAccess.cpp
FileInterface/RifReaderEclipseInput.cpp
FileInterface/RifReaderEclipseOutput.cpp
FileInterface/RifReaderMockModel.cpp
)
list( APPEND CPP_SOURCES
SocketInterface/RiaSocketServer.cpp
)
list( APPEND CPP_SOURCES
ProjectDataModel/RimCaseCollection.cpp
ProjectDataModel/RimCellFilter.cpp
ProjectDataModel/RimCellPropertyFilter.cpp
ProjectDataModel/RimCellPropertyFilterCollection.cpp
@ -73,11 +64,12 @@ list( APPEND CPP_SOURCES
ProjectDataModel/RimDefines.cpp
ProjectDataModel/RimLegendConfig.cpp
ProjectDataModel/RimProject.cpp
ProjectDataModel/RimReservoir.cpp
ProjectDataModel/RimCase.cpp
ProjectDataModel/RimIdenticalGridCaseGroup.cpp
ProjectDataModel/RimInputProperty.cpp
ProjectDataModel/RimInputPropertyCollection.cpp
ProjectDataModel/RimInputReservoir.cpp
ProjectDataModel/RimResultReservoir.cpp
ProjectDataModel/RimInputCase.cpp
ProjectDataModel/RimResultCase.cpp
ProjectDataModel/RimReservoirView.cpp
ProjectDataModel/RimResultDefinition.cpp
ProjectDataModel/RimResultSlot.cpp
@ -85,55 +77,62 @@ list( APPEND CPP_SOURCES
ProjectDataModel/RimWell.cpp
ProjectDataModel/RimWellCollection.cpp
ProjectDataModel/RimScriptCollection.cpp
ProjectDataModel/RimStatisticsCase.cpp
ProjectDataModel/RimStatisticsCaseCollection.cpp
ProjectDataModel/RimCalcScript.cpp
ProjectDataModel/RimExportInputPropertySettings.cpp
ProjectDataModel/RimBinaryExportSettings.cpp
ProjectDataModel/Rim3dOverlayInfoConfig.cpp
ProjectDataModel/RimUiTreeModelPdm.cpp
ProjectDataModel/RimUiTreeView.cpp
ProjectDataModel/RimReservoirCellResultsCacher.cpp
ProjectDataModel/RimStatisticsCaseEvaluator.cpp
)
# Populate the filenames into variable lists
include ("ReservoirDataModel/CMakeLists_files.cmake")
include ("FileInterface/CMakeLists_files.cmake")
list( APPEND CPP_SOURCES
${CODE_SOURCE_FILES}
)
list( APPEND CPP_SOURCES
ReservoirDataModel/RigCell.cpp
ReservoirDataModel/RigGridBase.cpp
ReservoirDataModel/RigReservoirCellResults.cpp
ReservoirDataModel/RigLocalGrid.cpp
ReservoirDataModel/RigMainGrid.cpp
ReservoirDataModel/RigReservoir.cpp
ReservoirDataModel/RigReservoirBuilderMock.cpp
ReservoirDataModel/RigWellResults.cpp
ReservoirDataModel/RigGridScalarDataAccess.cpp
)
list( APPEND CPP_SOURCES
UserInterface/RICursors.cpp
UserInterface/RIMainWindow.cpp
UserInterface/RIPreferencesDialog.cpp
UserInterface/RIResultInfoPanel.cpp
UserInterface/RIViewer.cpp
UserInterface/RiuCursors.cpp
UserInterface/RiuMainWindow.cpp
UserInterface/RiuPreferencesDialog.cpp
UserInterface/RiuResultInfoPanel.cpp
UserInterface/RiuViewer.cpp
UserInterface/RiuSimpleHistogramWidget.cpp
UserInterface/RIProcessMonitor.cpp
UserInterface/RiuMultiCaseImportDialog.cpp
UserInterface/RiuProcessMonitor.cpp
)
# Define files for MOC-ing
set ( QT_MOC_HEADERS
Application/RIApplication.h
Application/RiaApplication.h
ProjectDataModel/RimUiTreeModelPdm.h
ProjectDataModel/RimUiTreeView.h
UserInterface/RIMainWindow.h
UserInterface/RIPreferencesDialog.h
UserInterface/RIResultInfoPanel.h
UserInterface/RIViewer.h
UserInterface/RIProcessMonitor.h
UserInterface/RiuMainWindow.h
UserInterface/RiuPreferencesDialog.h
UserInterface/RiuResultInfoPanel.h
UserInterface/RiuViewer.h
UserInterface/RiuProcessMonitor.h
SocketInterface/RiaSocketServer.h
UserInterface/RiuMultiCaseImportDialog.h
)
qt4_wrap_cpp( MOC_FILES_CPP ${QT_MOC_HEADERS} )
# Define files for the uic compiler
set ( QT_UI_FILES
UserInterface/RiuMultiCaseImportDialog.ui
)
qt4_wrap_ui( FORM_FILES_CPP ${QT_UI_FILES} )
# NOTE! Resources in subfolders must append to QRC_FILES using the following statement
# set( QRC_FILES
# ${QRC_FILES}
@ -155,19 +154,20 @@ qt4_add_resources( QRC_FILES_CPP ${QRC_FILES} )
#############################################################################
set( RAW_SOURCES ${CPP_SOURCES} )
list( REMOVE_ITEM RAW_SOURCES RIStdInclude.cpp)
list( REMOVE_ITEM RAW_SOURCES ReservoirDataModel/RigReaderInterfaceECL.cpp)
list( REMOVE_ITEM RAW_SOURCES ReservoirDataModel/RigGridScalarDataAccess.cpp)
list( REMOVE_ITEM RAW_SOURCES ModelVisualization/RivCellEdgeEffectGenerator.cpp)
list( REMOVE_ITEM RAW_SOURCES ModelVisualization/RivPipeGeometryGenerator.cpp)
list( REMOVE_ITEM RAW_SOURCES ModelVisualization/RivWellPipesPartMgr.cpp)
list( REMOVE_ITEM RAW_SOURCES ModelVisualization/RivWellHeadPartMgr.cpp)
list( REMOVE_ITEM RAW_SOURCES Application/RiaImageFileCompare.cpp)
list( REMOVE_ITEM RAW_SOURCES Application/RiaImageCompareReporter.cpp)
list( REMOVE_ITEM RAW_SOURCES
RiaStdInclude.cpp
${CODE_SOURCE_FILES}
list( REMOVE_ITEM RAW_SOURCES
ModelVisualization/RivCellEdgeEffectGenerator.cpp
ModelVisualization/RivPipeGeometryGenerator.cpp
ModelVisualization/RivWellPipesPartMgr.cpp
ModelVisualization/RivWellHeadPartMgr.cpp
Application/RiaImageFileCompare.cpp
Application/RiaImageCompareReporter.cpp
FileInterface/RifEclipseInputFileTools.cpp
FileInterface/RifEclipseOutputFileTools.cpp
FileInterface/RifEclipseRestartFilesetAccess.cpp
@ -175,8 +175,9 @@ list( REMOVE_ITEM RAW_SOURCES
FileInterface/RifEclipseUnifiedRestartFileAccess.cpp
FileInterface/RifReaderEclipseInput.cpp
FileInterface/RifReaderEclipseOutput.cpp
UserInterface/RiuSimpleHistogramWidget.cpp
UserInterface/RiuSimpleHistogramWidget.cpp
UserInterface/RiuMultiCaseImportDialog.cpp
)
include( CustomPCH.cmake )
@ -189,7 +190,7 @@ set( ALL_INCLUDES
${QT_INCLUDES}
)
set( PCH_NAME RIStdInclude )
set( PCH_NAME RiaStdInclude )
set( GCC_PCH_TARGET gccPCH )
set( PCH_COMPILER_DEFINE EMPTY )
IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
@ -205,6 +206,7 @@ precompiled_header( RAW_SOURCES ALL_INCLUDES ${GCC_PCH_TARGET} ${PCH_NAME} ${PCH
add_executable(ResInsight
${CPP_SOURCES}
${MOC_FILES_CPP}
${FORM_FILES_CPP}
${QRC_FILES_CPP}
${HEADER_FILES}
)

View File

@ -0,0 +1,31 @@
# Use this workaround until we're on 2.8.3 on all platforms and can use CMAKE_CURRENT_LIST_DIR directly
if (${CMAKE_VERSION} VERSION_GREATER "2.8.2")
set(CEE_CURRENT_LIST_DIR ${CMAKE_CURRENT_LIST_DIR}/)
endif()
list(APPEND CODE_HEADER_FILES
${CEE_CURRENT_LIST_DIR}RifEclipseInputFileTools.h
${CEE_CURRENT_LIST_DIR}RifEclipseOutputFileTools.h
${CEE_CURRENT_LIST_DIR}RifEclipseRestartDataAccess.h
${CEE_CURRENT_LIST_DIR}RifEclipseRestartFilesetAccess.h
${CEE_CURRENT_LIST_DIR}RifEclipseUnifiedRestartFileAccess.h
${CEE_CURRENT_LIST_DIR}RifReaderEclipseInput.h
${CEE_CURRENT_LIST_DIR}RifReaderEclipseOutput.h
${CEE_CURRENT_LIST_DIR}RifReaderInterface.h
${CEE_CURRENT_LIST_DIR}RifReaderMockModel.h
)
list(APPEND CODE_SOURCE_FILES
${CEE_CURRENT_LIST_DIR}RifEclipseInputFileTools.cpp
${CEE_CURRENT_LIST_DIR}RifEclipseOutputFileTools.cpp
${CEE_CURRENT_LIST_DIR}RifEclipseRestartDataAccess.cpp
${CEE_CURRENT_LIST_DIR}RifEclipseRestartFilesetAccess.cpp
${CEE_CURRENT_LIST_DIR}RifEclipseUnifiedRestartFileAccess.cpp
${CEE_CURRENT_LIST_DIR}RifReaderEclipseInput.cpp
${CEE_CURRENT_LIST_DIR}RifReaderEclipseOutput.cpp
${CEE_CURRENT_LIST_DIR}RifReaderMockModel.cpp
)

View File

@ -18,39 +18,39 @@ include_directories(
${ResInsight_SOURCE_DIR}/cafProjectDataModel
${ResInsight_SOURCE_DIR}/CommonCode
#Remove when RigStatistics is out
${ResInsight_SOURCE_DIR}/ApplicationCode/ModelVisualization
)
set( FILEINTERFACE_CPP_SOURCES
../RifEclipseInputFileTools.cpp
../RifEclipseOutputFileTools.cpp
../RifEclipseRestartFilesetAccess.cpp
../RifEclipseRestartDataAccess.cpp
../RifEclipseUnifiedRestartFileAccess.cpp
../RifReaderEclipseOutput.cpp
../RifReaderEclipseInput.cpp
../RifReaderMockModel.cpp
)
set( RESERVOIRDATAMODEL_CPP_SOURCES
${ResInsight_SOURCE_DIR}/ApplicationCode/ReservoirDataModel/RigCell.cpp
${ResInsight_SOURCE_DIR}/ApplicationCode/ReservoirDataModel/RigGridBase.cpp
${ResInsight_SOURCE_DIR}/ApplicationCode/ReservoirDataModel/RigLocalGrid.cpp
${ResInsight_SOURCE_DIR}/ApplicationCode/ReservoirDataModel/RigMainGrid.cpp
${ResInsight_SOURCE_DIR}/ApplicationCode/ReservoirDataModel/RigReservoir.cpp
${ResInsight_SOURCE_DIR}/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.cpp
${ResInsight_SOURCE_DIR}/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.cpp
${ResInsight_SOURCE_DIR}/ApplicationCode/ReservoirDataModel/RigWellResults.cpp
${ResInsight_SOURCE_DIR}/ApplicationCode/ReservoirDataModel/RigGridScalarDataAccess.cpp
# Populate variables from read from CMakeLists_files.cmake
set (CODE_SOURCE_FILES )
include ("${ResInsight_SOURCE_DIR}/ApplicationCode/FileInterface/CMakeLists_files.cmake")
set( CPP_SOURCES
${CPP_SOURCES}
${CODE_SOURCE_FILES}
)
source_group( "FileInterface" FILES ${CODE_SOURCE_FILES} )
# Populate variables from read from CMakeLists_files.cmake
set (CODE_SOURCE_FILES )
include ("${ResInsight_SOURCE_DIR}/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake")
set( CPP_SOURCES
${CPP_SOURCES}
${CODE_SOURCE_FILES}
)
source_group( "ReservoirDataModel" FILES ${CODE_SOURCE_FILES} )
set( CPP_SOURCES
${CPP_SOURCES}
${ResInsight_SOURCE_DIR}/cafUserInterface/cafProgressInfo.cpp
)
set( CPP_SOURCES
${FILEINTERFACE_CPP_SOURCES}
${RESERVOIRDATAMODEL_CPP_SOURCES}
)
source_group( "FileInterface" FILES ${FILEINTERFACE_CPP_SOURCES} )
source_group( "ReservoirDataModel" FILES ${RESERVOIRDATAMODEL_CPP_SOURCES} )
source_group( "Headers" FILES ${CODE_HEADER_FILES} )
set( UNIT_TEST_CPP_SOURCES
main.cpp
@ -58,7 +58,6 @@ set( UNIT_TEST_CPP_SOURCES
Ert-Test.cpp
)
set( LINK_LIBRARIES
CommonCode
@ -75,20 +74,22 @@ set( LINK_LIBRARIES
${QT_LIBRARIES}
)
add_executable( ${ProjectName}
${CODE_HEADER_FILES}
${CPP_SOURCES}
${UNIT_TEST_CPP_SOURCES}
${ResInsight_SOURCE_DIR}/ThirdParty/gtest/gtest-all.cc
${ResInsight_SOURCE_DIR}/ApplicationCode/FileInterface/CMakeLists_files.cmake
${ResInsight_SOURCE_DIR}/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake
)
set( EXTERNAL_LINK_LIBRARIES ${ERT_LIBRARY_LIST} )
target_link_libraries( ${ProjectName} ${LINK_LIBRARIES} ${EXTERNAL_LINK_LIBRARIES})
# Copy Dlls
if (MSVC)
@ -101,21 +102,4 @@ if (MSVC)
${CMAKE_CURRENT_BINARY_DIR}/$<CONFIGURATION>)
endforeach( qtlib )
# DLLs ERT depends on
# add_custom_command(TARGET ${ProjectName} POST_BUILD
# COMMAND ${CMAKE_COMMAND} -E copy_directory
# "${PROJECT_SOURCE_DIR}/../../../ThirdParty/Ert-windows/bin/"
# ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIGURATION>)
# ERT DLLs
# set (ERT_MODULES ecl geometry util well)
# foreach (ert_module ${ERT_MODULES})
# add_custom_command(TARGET ${ProjectName} POST_BUILD
# COMMAND ${CMAKE_COMMAND} -E copy_if_different
# "${CMAKE_CURRENT_SOURCE_DIR}/../../../ThirdParty/Ert-windows/${ert_module}/lib/lib${ert_module}.dll"
# ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIGURATION>)
# endforeach()
endif(MSVC)

View File

@ -37,7 +37,7 @@
#include "gtest/gtest.h"
#include "RigReservoir.h"
#include "RigCaseData.h"
#include "RifReaderEclipseInput.h"
#if 0

View File

@ -18,15 +18,15 @@
//
/////////////////////////////////////////////////////////////////////////////////
#include "RIStdInclude.h"
#include "RiaStdInclude.h"
#include "gtest/gtest.h"
#include "RigReservoir.h"
#include "RigCaseData.h"
#include "RifReaderEclipseOutput.h"
#include "ecl_file.h"
#include "RifEclipseOutputFileTools.h"
#include "RigReservoirCellResults.h"
#include "RigCaseCellResultsData.h"
@ -68,7 +68,7 @@ TEST(RigReservoirTest, FileOutputToolsTest)
void buildResultInfoString(RigReservoir* reservoir, RifReaderInterface::PorosityModelResultType porosityModel, RimDefines::ResultCatType resultType)
{
RigReservoirCellResults* matrixResults = reservoir->mainGrid()->results(porosityModel);
RigCaseCellResultsData* matrixResults = reservoir->results(porosityModel);
{
QStringList resultNames = matrixResults->resultNames(resultType);
@ -247,7 +247,7 @@ TEST(RigReservoirTest, BasicTest)
TEST(RigReservoirTest, WellTest)
{
cvf::ref<RifReaderEclipseOutput> readerInterfaceEcl = new RifReaderEclipseOutput;
cvf::ref<RigReservoir> reservoir = new RigReservoir;
cvf::ref<RigCaseData> reservoir = new RigCaseData;
// Location of test dataset received from Håkon Høgstøl in July 2011 with 10k active cells
#ifdef WIN32

View File

@ -16,7 +16,7 @@
//
/////////////////////////////////////////////////////////////////////////////////
#include "RIStdInclude.h"
#include "RiaStdInclude.h"
#include "cvfBase.h"

View File

@ -18,9 +18,9 @@
#include "RifEclipseInputFileTools.h"
#include "RifReaderEclipseOutput.h"
#include "RigReservoirCellResults.h"
#include "RigCaseCellResultsData.h"
#include "RigReservoir.h"
#include "RigCaseData.h"
#include "cafProgressInfo.h"
#include <vector>
@ -61,9 +61,9 @@ RifEclipseInputFileTools::~RifEclipseInputFileTools()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RifEclipseInputFileTools::openGridFile(const QString& fileName, RigReservoir* reservoir)
bool RifEclipseInputFileTools::openGridFile(const QString& fileName, RigCaseData* eclipseCase)
{
CVF_ASSERT(reservoir);
CVF_ASSERT(eclipseCase);
qint64 coordPos = -1;
qint64 zcornPos = -1;
@ -154,7 +154,7 @@ bool RifEclipseInputFileTools::openGridFile(const QString& fileName, RigReservoi
progress.setProgress(6);
RifReaderEclipseOutput::transferGeometry(inputGrid, reservoir);
RifReaderEclipseOutput::transferGeometry(inputGrid, eclipseCase);
progress.setProgress(7);
progress.setProgressDescription("Cleaning up ...");
@ -176,7 +176,7 @@ bool RifEclipseInputFileTools::openGridFile(const QString& fileName, RigReservoi
//--------------------------------------------------------------------------------------------------
/// Read known properties from the input file
//--------------------------------------------------------------------------------------------------
std::map<QString, QString> RifEclipseInputFileTools::readProperties(const QString &fileName, RigReservoir *reservoir)
std::map<QString, QString> RifEclipseInputFileTools::readProperties(const QString &fileName, RigCaseData *reservoir)
{
CVF_ASSERT(reservoir);
@ -212,11 +212,11 @@ std::map<QString, QString> RifEclipseInputFileTools::readProperties(const QStri
ecl_kw_type* eclKeyWordData = ecl_kw_fscanf_alloc_current_grdecl__(gridFilePointer, false , ECL_FLOAT_TYPE);
if (eclKeyWordData)
{
QString newResultName = reservoir->mainGrid()->results(RifReaderInterface::MATRIX_RESULTS)->makeResultNameUnique(fileKeywords[i].keyword);
QString newResultName = reservoir->results(RifReaderInterface::MATRIX_RESULTS)->makeResultNameUnique(fileKeywords[i].keyword);
size_t resultIndex = reservoir->mainGrid()->results(RifReaderInterface::MATRIX_RESULTS)->addEmptyScalarResult(RimDefines::INPUT_PROPERTY, newResultName); // Should really merge with inputProperty object information because we need to use PropertyName, and not keyword
size_t resultIndex = reservoir->results(RifReaderInterface::MATRIX_RESULTS)->addEmptyScalarResult(RimDefines::INPUT_PROPERTY, newResultName, false); // Should really merge with inputProperty object information because we need to use PropertyName, and not keyword
std::vector< std::vector<double> >& newPropertyData = reservoir->mainGrid()->results(RifReaderInterface::MATRIX_RESULTS)->cellScalarResults(resultIndex);
std::vector< std::vector<double> >& newPropertyData = reservoir->results(RifReaderInterface::MATRIX_RESULTS)->cellScalarResults(resultIndex);
newPropertyData.push_back(std::vector<double>());
newPropertyData[0].resize(ecl_kw_get_size(eclKeyWordData), HUGE_VAL);
ecl_kw_get_data_as_double(eclKeyWordData, newPropertyData[0].data());
@ -282,9 +282,9 @@ std::vector< RifKeywordAndFilePos > RifEclipseInputFileTools::findKeywordsOnFile
/// Reads the property data requested into the \a reservoir, overwriting any previous
/// propeties with the same name.
//--------------------------------------------------------------------------------------------------
bool RifEclipseInputFileTools::readProperty(const QString& fileName, RigReservoir* reservoir, const QString& eclipseKeyWord, const QString& resultName)
bool RifEclipseInputFileTools::readProperty(const QString& fileName, RigCaseData* eclipseCase, const QString& eclipseKeyWord, const QString& resultName)
{
CVF_ASSERT(reservoir);
CVF_ASSERT(eclipseCase);
FILE* filePointer = util_fopen(fileName.toLatin1().data(), "r");
if (!filePointer) return false;
@ -294,13 +294,13 @@ bool RifEclipseInputFileTools::readProperty(const QString& fileName, RigReservoi
if (eclKeyWordData)
{
QString newResultName = resultName;
size_t resultIndex = reservoir->mainGrid()->results(RifReaderInterface::MATRIX_RESULTS)->findScalarResultIndex(newResultName);
size_t resultIndex = eclipseCase->results(RifReaderInterface::MATRIX_RESULTS)->findScalarResultIndex(newResultName);
if (resultIndex == cvf::UNDEFINED_SIZE_T)
{
resultIndex = reservoir->mainGrid()->results(RifReaderInterface::MATRIX_RESULTS)->addEmptyScalarResult(RimDefines::INPUT_PROPERTY, newResultName);
resultIndex = eclipseCase->results(RifReaderInterface::MATRIX_RESULTS)->addEmptyScalarResult(RimDefines::INPUT_PROPERTY, newResultName, false);
}
std::vector< std::vector<double> >& newPropertyData = reservoir->mainGrid()->results(RifReaderInterface::MATRIX_RESULTS)->cellScalarResults(resultIndex);
std::vector< std::vector<double> >& newPropertyData = eclipseCase->results(RifReaderInterface::MATRIX_RESULTS)->cellScalarResults(resultIndex);
newPropertyData.resize(1);
newPropertyData[0].resize(ecl_kw_get_size(eclKeyWordData), HUGE_VAL);
ecl_kw_get_data_as_double(eclKeyWordData, newPropertyData[0].data());
@ -370,11 +370,11 @@ const std::vector<QString>& RifEclipseInputFileTools::knownPropertyKeywords()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RifEclipseInputFileTools::writePropertyToTextFile(const QString& fileName, RigReservoir* reservoir, size_t timeStep, const QString& resultName, const QString& eclipseKeyWord)
bool RifEclipseInputFileTools::writePropertyToTextFile(const QString& fileName, RigCaseData* eclipseCase, size_t timeStep, const QString& resultName, const QString& eclipseKeyWord)
{
CVF_ASSERT(reservoir);
CVF_ASSERT(eclipseCase);
size_t resultIndex = reservoir->mainGrid()->results(RifReaderInterface::MATRIX_RESULTS)->findScalarResultIndex(resultName);
size_t resultIndex = eclipseCase->results(RifReaderInterface::MATRIX_RESULTS)->findScalarResultIndex(resultName);
if (resultIndex == cvf::UNDEFINED_SIZE_T)
{
return false;
@ -386,7 +386,7 @@ bool RifEclipseInputFileTools::writePropertyToTextFile(const QString& fileName,
return false;
}
std::vector< std::vector<double> >& resultData = reservoir->mainGrid()->results(RifReaderInterface::MATRIX_RESULTS)->cellScalarResults(resultIndex);
std::vector< std::vector<double> >& resultData = eclipseCase->results(RifReaderInterface::MATRIX_RESULTS)->cellScalarResults(resultIndex);
if (resultData.size() == 0)
{
return false;
@ -402,11 +402,11 @@ bool RifEclipseInputFileTools::writePropertyToTextFile(const QString& fileName,
/// Create and write a result vector with values for all cells.
/// undefinedValue is used for cells with no result
//--------------------------------------------------------------------------------------------------
bool RifEclipseInputFileTools::writeBinaryResultToTextFile(const QString& fileName, RigReservoir* reservoir, RifReaderInterface::PorosityModelResultType porosityModel, size_t timeStep, const QString& resultName, const QString& eclipseKeyWord, const double undefinedValue)
bool RifEclipseInputFileTools::writeBinaryResultToTextFile(const QString& fileName, RigCaseData* eclipseCase, RifReaderInterface::PorosityModelResultType porosityModel, size_t timeStep, const QString& resultName, const QString& eclipseKeyWord, const double undefinedValue)
{
CVF_ASSERT(reservoir);
CVF_ASSERT(eclipseCase);
size_t resultIndex = reservoir->mainGrid()->results(porosityModel)->findScalarResultIndex(resultName);
size_t resultIndex = eclipseCase->results(porosityModel)->findScalarResultIndex(resultName);
if (resultIndex == cvf::UNDEFINED_SIZE_T)
{
return false;
@ -418,7 +418,7 @@ bool RifEclipseInputFileTools::writeBinaryResultToTextFile(const QString& fileNa
return false;
}
cvf::ref<RigGridScalarDataAccess> dataAccessObject = reservoir->mainGrid()->dataAccessObject(porosityModel, timeStep, resultIndex);
cvf::ref<cvf::StructGridScalarDataAccess> dataAccessObject = eclipseCase->dataAccessObject(eclipseCase->mainGrid(), porosityModel, timeStep, resultIndex);
if (dataAccessObject.isNull())
{
return false;
@ -426,13 +426,13 @@ bool RifEclipseInputFileTools::writeBinaryResultToTextFile(const QString& fileNa
std::vector<double> resultData;
size_t i, j, k;
for (k = 0; k < reservoir->mainGrid()->cellCountK(); k++)
for (k = 0; k < eclipseCase->mainGrid()->cellCountK(); k++)
{
for (j = 0; j < reservoir->mainGrid()->cellCountJ(); j++)
for (j = 0; j < eclipseCase->mainGrid()->cellCountJ(); j++)
{
for (i = 0; i < reservoir->mainGrid()->cellCountI(); i++)
for (i = 0; i < eclipseCase->mainGrid()->cellCountI(); i++)
{
double resultValue = dataAccessObject->cellScalar(i, j, k);
double resultValue = dataAccessObject->cellScalar(eclipseCase->mainGrid()->cellIndexFromIJK(i, j, k));
if (resultValue == HUGE_VAL)
{
resultValue = undefinedValue;
@ -519,9 +519,9 @@ void RifEclipseInputFileTools::findGridKeywordPositions(const QString& filename,
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RifEclipseInputFileTools::readPropertyAtFilePosition(const QString& fileName, RigReservoir* reservoir, const QString& eclipseKeyWord, qint64 filePos, const QString& resultName)
bool RifEclipseInputFileTools::readPropertyAtFilePosition(const QString& fileName, RigCaseData* eclipseCase, const QString& eclipseKeyWord, qint64 filePos, const QString& resultName)
{
CVF_ASSERT(reservoir);
CVF_ASSERT(eclipseCase);
FILE* filePointer = util_fopen(fileName.toLatin1().data(), "r");
if (!filePointer) return false;
@ -532,13 +532,13 @@ bool RifEclipseInputFileTools::readPropertyAtFilePosition(const QString& fileNam
if (eclKeyWordData)
{
QString newResultName = resultName;
size_t resultIndex = reservoir->mainGrid()->results(RifReaderInterface::MATRIX_RESULTS)->findScalarResultIndex(newResultName);
size_t resultIndex = eclipseCase->results(RifReaderInterface::MATRIX_RESULTS)->findScalarResultIndex(newResultName);
if (resultIndex == cvf::UNDEFINED_SIZE_T)
{
resultIndex = reservoir->mainGrid()->results(RifReaderInterface::MATRIX_RESULTS)->addEmptyScalarResult(RimDefines::INPUT_PROPERTY, newResultName);
resultIndex = eclipseCase->results(RifReaderInterface::MATRIX_RESULTS)->addEmptyScalarResult(RimDefines::INPUT_PROPERTY, newResultName, false);
}
std::vector< std::vector<double> >& newPropertyData = reservoir->mainGrid()->results(RifReaderInterface::MATRIX_RESULTS)->cellScalarResults(resultIndex);
std::vector< std::vector<double> >& newPropertyData = eclipseCase->results(RifReaderInterface::MATRIX_RESULTS)->cellScalarResults(resultIndex);
newPropertyData.resize(1);
newPropertyData[0].resize(ecl_kw_get_size(eclKeyWordData), HUGE_VAL);
ecl_kw_get_data_as_double(eclKeyWordData, newPropertyData[0].data());

View File

@ -27,7 +27,7 @@
#include "RifReaderInterface.h"
class RigReservoir;
class RigCaseData;
class QFile;
@ -52,19 +52,19 @@ public:
RifEclipseInputFileTools();
virtual ~RifEclipseInputFileTools();
static bool openGridFile(const QString& fileName, RigReservoir* reservoir);
static bool openGridFile(const QString& fileName, RigCaseData* eclipseCase);
// Returns map of assigned resultName and Eclipse Keyword.
static std::map<QString, QString> readProperties(const QString& fileName, RigReservoir* reservoir);
static bool readProperty (const QString& fileName, RigReservoir* reservoir, const QString& eclipseKeyWord, const QString& resultName );
static bool readPropertyAtFilePosition (const QString& fileName, RigReservoir* reservoir, const QString& eclipseKeyWord, qint64 filePos, const QString& resultName );
static std::map<QString, QString> readProperties(const QString& fileName, RigCaseData* eclipseCase);
static bool readProperty (const QString& fileName, RigCaseData* eclipseCase, const QString& eclipseKeyWord, const QString& resultName );
static bool readPropertyAtFilePosition (const QString& fileName, RigCaseData* eclipseCase, const QString& eclipseKeyWord, qint64 filePos, const QString& resultName );
static std::vector< RifKeywordAndFilePos > findKeywordsOnFile(const QString &fileName);
static const std::vector<QString>& knownPropertyKeywords();
static bool writePropertyToTextFile(const QString& fileName, RigReservoir* reservoir, size_t timeStep, const QString& resultName, const QString& eclipseKeyWord);
static bool writeBinaryResultToTextFile(const QString& fileName, RigReservoir* reservoir, RifReaderInterface::PorosityModelResultType porosityModel, size_t timeStep, const QString& resultName, const QString& eclipseKeyWord, const double undefinedValue);
static bool writePropertyToTextFile(const QString& fileName, RigCaseData* eclipseCase, size_t timeStep, const QString& resultName, const QString& eclipseKeyWord);
static bool writeBinaryResultToTextFile(const QString& fileName, RigCaseData* eclipseCase, RifReaderInterface::PorosityModelResultType porosityModel, size_t timeStep, const QString& resultName, const QString& eclipseKeyWord, const double undefinedValue);
private:
static void writeDataToTextFile(QFile* file, const QString& eclipseKeyWord, const std::vector<double>& resultData);

View File

@ -46,7 +46,7 @@ RifEclipseOutputFileTools::~RifEclipseOutputFileTools()
//--------------------------------------------------------------------------------------------------
/// Get list of time step texts (dates)
//--------------------------------------------------------------------------------------------------
void RifEclipseOutputFileTools::timeSteps(ecl_file_type* ecl_file, QList<QDateTime>* timeSteps, bool* detectedFractionOfDay )
void RifEclipseOutputFileTools::timeSteps(ecl_file_type* ecl_file, std::vector<QDateTime>* timeSteps, bool* detectedFractionOfDay )
{
CVF_ASSERT(timeSteps);
CVF_ASSERT(ecl_file);
@ -84,7 +84,7 @@ void RifEclipseOutputFileTools::timeSteps(ecl_file_type* ecl_file, QList<QDateTi
}
}
QList<QDateTime> timeStepsFound;
std::vector<QDateTime> timeStepsFound;
if (hasFractionOfDay)
{
@ -102,15 +102,15 @@ void RifEclipseOutputFileTools::timeSteps(ecl_file_type* ecl_file, QList<QDateTi
double floorDayValue = cvf::Math::floor(dayValue);
double dayFraction = dayValue - floorDayValue;
int seconds = (dayFraction * 24.0 * 60.0 * 60.0);
int seconds = static_cast<int>(dayFraction * 24.0 * 60.0 * 60.0);
QTime time(0, 0);
time = time.addSecs(seconds);
QDate reportDate = simulationStart;
reportDate = reportDate.addDays(floorDayValue);
reportDate = reportDate.addDays(static_cast<int>(floorDayValue));
QDateTime reportDateTime(reportDate, time);
if (timeStepsFound.indexOf(reportDateTime) < 0)
if (std::find(timeStepsFound.begin(), timeStepsFound.end(), reportDateTime) == timeStepsFound.end())
{
timeStepsFound.push_back(reportDateTime);
}
@ -132,7 +132,7 @@ void RifEclipseOutputFileTools::timeSteps(ecl_file_type* ecl_file, QList<QDateTi
CVF_ASSERT(reportDate.isValid());
QDateTime reportDateTime(reportDate);
if (timeStepsFound.indexOf(reportDateTime) < 0)
if (std::find(timeStepsFound.begin(), timeStepsFound.end(), reportDateTime) == timeStepsFound.end())
{
timeStepsFound.push_back(reportDateTime);
}
@ -172,6 +172,28 @@ bool RifEclipseOutputFileTools::keywordData(ecl_file_type* ecl_file, const QStri
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RifEclipseOutputFileTools::keywordData(ecl_file_type* ecl_file, const QString& keyword, size_t fileKeywordOccurrence, std::vector<int>* values)
{
ecl_kw_type* kwData = ecl_file_iget_named_kw(ecl_file, keyword.toAscii().data(), static_cast<int>(fileKeywordOccurrence));
if (kwData)
{
size_t numValues = ecl_kw_get_size(kwData);
std::vector<int> integerData;
integerData.resize(numValues);
ecl_kw_get_memcpy_int_data(kwData, integerData.data());
values->insert(values->end(), integerData.begin(), integerData.end());
return true;
}
return false;
}
//--------------------------------------------------------------------------------------------------
/// Get first occurrence of file of given type in given list of filenames, as filename or NULL if not found

View File

@ -45,9 +45,10 @@ public:
static void findKeywordsAndDataItemCounts(ecl_file_type* ecl_file, QStringList* keywords, std::vector<size_t>* keywordDataItemCounts);
static bool keywordData(ecl_file_type* ecl_file, const QString& keyword, size_t fileKeywordOccurrence, std::vector<double>* values);
static bool keywordData(ecl_file_type* ecl_file, const QString& keyword, size_t fileKeywordOccurrence, std::vector<int>* values);
// static void timeStepsText(ecl_file_type* ecl_file, QStringList* timeSteps);
static void timeSteps(ecl_file_type* ecl_file, QList<QDateTime>* timeSteps, bool* detectedFractionOfDay = NULL);
static void timeSteps(ecl_file_type* ecl_file, std::vector<QDateTime>* timeSteps, bool* detectedFractionOfDay = NULL);
static bool fileSet(const QString& fileName, QStringList* fileSet);

View File

@ -42,11 +42,13 @@ public:
RifEclipseRestartDataAccess();
virtual ~RifEclipseRestartDataAccess();
virtual bool open(const QStringList& fileSet) = 0;
virtual bool open() = 0;
virtual void setFileSet(const QStringList& fileSet) = 0;
virtual void close() = 0;
virtual void setTimeSteps(const std::vector<QDateTime>& timeSteps) {};
virtual size_t timeStepCount() = 0;
virtual QList<QDateTime> timeSteps() = 0;
virtual std::vector<QDateTime> timeSteps() = 0;
virtual void resultNames(QStringList* resultNames, std::vector<size_t>* resultDataItemCounts) = 0;
virtual bool results(const QString& resultName, size_t timeStep, size_t gridCount, std::vector<double>* values) = 0;

View File

@ -40,30 +40,44 @@ RifEclipseRestartFilesetAccess::~RifEclipseRestartFilesetAccess()
//--------------------------------------------------------------------------------------------------
/// Open files
//--------------------------------------------------------------------------------------------------
bool RifEclipseRestartFilesetAccess::open(const QStringList& fileSet)
bool RifEclipseRestartFilesetAccess::open()
{
close();
int numFiles = fileSet.size();
caf::ProgressInfo progInfo(numFiles,"");
int i;
for (i = 0; i < numFiles; i++)
if (m_fileNames.size() > 0)
{
progInfo.setProgressDescription(fileSet[i]);
caf::ProgressInfo progInfo(m_fileNames.size(), "");
ecl_file_type* ecl_file = ecl_file_open(fileSet[i].toAscii().data());
if (!ecl_file) return false;
int i;
for (i = 0; i < m_fileNames.size(); i++)
{
progInfo.setProgressDescription(m_fileNames[i]);
m_ecl_files.push_back(ecl_file);
openTimeStep(i);
progInfo.incrementProgress();
progInfo.incrementProgress();
}
}
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RifEclipseRestartFilesetAccess::setFileSet(const QStringList& fileSet)
{
close();
m_ecl_files.clear();
m_fileNames = fileSet;
for (int i = 0; i < m_fileNames.size(); i++)
{
m_ecl_files.push_back(NULL);
}
CVF_ASSERT(m_fileNames.size() == static_cast<int>(m_ecl_files.size()));
}
//--------------------------------------------------------------------------------------------------
/// Close files
//--------------------------------------------------------------------------------------------------
@ -71,10 +85,22 @@ void RifEclipseRestartFilesetAccess::close()
{
for (size_t i = 0; i < m_ecl_files.size(); i++)
{
ecl_file_close(m_ecl_files[i]);
}
m_ecl_files.clear();
if (m_ecl_files[i])
{
ecl_file_close(m_ecl_files[i]);
}
m_ecl_files[i] = NULL;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RifEclipseRestartFilesetAccess::setTimeSteps(const std::vector<QDateTime>& timeSteps)
{
CVF_ASSERT(m_fileNames.size() == timeSteps.size());
m_timeSteps = timeSteps;
}
//--------------------------------------------------------------------------------------------------
@ -82,35 +108,39 @@ void RifEclipseRestartFilesetAccess::close()
//--------------------------------------------------------------------------------------------------
size_t RifEclipseRestartFilesetAccess::timeStepCount()
{
return m_ecl_files.size();
return m_timeSteps.size();
}
//--------------------------------------------------------------------------------------------------
/// Get the time steps
//--------------------------------------------------------------------------------------------------
QList<QDateTime> RifEclipseRestartFilesetAccess::timeSteps()
std::vector<QDateTime> RifEclipseRestartFilesetAccess::timeSteps()
{
QList<QDateTime> timeSteps;
size_t numSteps = timeStepCount();
size_t i;
for (i = 0; i < numSteps; i++)
if (m_timeSteps.size() == 0)
{
QList<QDateTime> stepTime;
size_t numSteps = m_fileNames.size();
size_t i;
for (i = 0; i < numSteps; i++)
{
std::vector<QDateTime> stepTime;
RifEclipseOutputFileTools::timeSteps(m_ecl_files[i], &stepTime);
openTimeStep(i);
RifEclipseOutputFileTools::timeSteps(m_ecl_files[i], &stepTime);
if (stepTime.size() == 1)
{
timeSteps.push_back(stepTime[0]);
}
else
{
timeSteps.push_back(QDateTime());
if (stepTime.size() == 1)
{
m_timeSteps.push_back(stepTime[0]);
}
else
{
m_timeSteps.push_back(QDateTime());
}
}
}
return timeSteps;
return m_timeSteps;
}
//--------------------------------------------------------------------------------------------------
@ -120,6 +150,8 @@ void RifEclipseRestartFilesetAccess::resultNames(QStringList* resultNames, std::
{
CVF_ASSERT(timeStepCount() > 0);
openTimeStep(0);
std::vector<size_t> valueCountForOneFile;
RifEclipseOutputFileTools::findKeywordsAndDataItemCounts(m_ecl_files[0], resultNames, &valueCountForOneFile);
@ -134,28 +166,35 @@ void RifEclipseRestartFilesetAccess::resultNames(QStringList* resultNames, std::
//--------------------------------------------------------------------------------------------------
bool RifEclipseRestartFilesetAccess::results(const QString& resultName, size_t timeStep, size_t gridCount, std::vector<double>* values)
{
size_t numOccurrences = ecl_file_get_num_named_kw(m_ecl_files[timeStep], resultName.toAscii().data());
if (timeStep >= timeStepCount())
{
return false;
}
openTimeStep(timeStep);
size_t fileGridCount = ecl_file_get_num_named_kw(m_ecl_files[timeStep], resultName.toAscii().data());
// No results for this result variable for current time step found
if (numOccurrences == 0) return true;
if (fileGridCount == 0) return true;
// Result handling depends on presents of result values for all grids
if (gridCount != numOccurrences)
if (gridCount != fileGridCount)
{
return false;
}
size_t i;
for (i = 0; i < numOccurrences; i++)
for (i = 0; i < fileGridCount; i++)
{
std::vector<double> partValues;
std::vector<double> gridValues;
if (!RifEclipseOutputFileTools::keywordData(m_ecl_files[timeStep], resultName, i, &partValues))
if (!RifEclipseOutputFileTools::keywordData(m_ecl_files[timeStep], resultName, i, &gridValues))
{
return false;
}
values->insert(values->end(), partValues.begin(), partValues.end());
values->insert(values->end(), gridValues.begin(), gridValues.end());
}
return true;
@ -171,6 +210,8 @@ void RifEclipseRestartFilesetAccess::readWellData(well_info_type* well_info)
for (size_t i = 0; i < m_ecl_files.size(); i++)
{
openTimeStep(i);
const char* fileName = ecl_file_get_src_file(m_ecl_files[i]);
int reportNumber = ecl_util_filename_report_nr(fileName);
if(reportNumber != -1)
@ -179,3 +220,20 @@ void RifEclipseRestartFilesetAccess::readWellData(well_info_type* well_info)
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RifEclipseRestartFilesetAccess::openTimeStep(size_t timeStep)
{
CVF_ASSERT(timeStep < m_ecl_files.size());
if (m_ecl_files[timeStep] == NULL)
{
int index = static_cast<int>(timeStep);
ecl_file_type* ecl_file = ecl_file_open(m_fileNames[index].toAscii().data());
m_ecl_files[timeStep] = ecl_file;
}
}

View File

@ -35,11 +35,13 @@ public:
RifEclipseRestartFilesetAccess();
virtual ~RifEclipseRestartFilesetAccess();
bool open(const QStringList& fileSet);
bool open();
void setFileSet(const QStringList& fileSet);
void close();
void setTimeSteps(const std::vector<QDateTime>& timeSteps);
size_t timeStepCount();
QList<QDateTime> timeSteps();
std::vector<QDateTime> timeSteps();
void resultNames(QStringList* resultNames, std::vector<size_t>* resultDataItemCounts);
bool results(const QString& resultName, size_t timeStep, size_t gridCount, std::vector<double>* values);
@ -47,5 +49,11 @@ public:
virtual void readWellData(well_info_type* well_info);
private:
std::vector< ecl_file_type* > m_ecl_files;
void openTimeStep(size_t timeStep);
private:
QStringList m_fileNames;
std::vector<QDateTime> m_timeSteps;
std::vector< ecl_file_type* > m_ecl_files;
};

View File

@ -38,22 +38,23 @@ RifEclipseUnifiedRestartFileAccess::RifEclipseUnifiedRestartFileAccess()
//--------------------------------------------------------------------------------------------------
RifEclipseUnifiedRestartFileAccess::~RifEclipseUnifiedRestartFileAccess()
{
if (m_ecl_file)
{
ecl_file_close(m_ecl_file);
}
m_ecl_file = NULL;
close();
}
//--------------------------------------------------------------------------------------------------
/// Open file
//--------------------------------------------------------------------------------------------------
bool RifEclipseUnifiedRestartFileAccess::open(const QStringList& fileSet)
bool RifEclipseUnifiedRestartFileAccess::open()
{
QString fileName = fileSet[0];
return true;
}
m_ecl_file = ecl_file_open(fileName.toAscii().data());
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RifEclipseUnifiedRestartFileAccess::openFile()
{
m_ecl_file = ecl_file_open(m_filename.toAscii().data());
if (!m_ecl_file) return false;
return true;
@ -64,6 +65,12 @@ bool RifEclipseUnifiedRestartFileAccess::open(const QStringList& fileSet)
//--------------------------------------------------------------------------------------------------
void RifEclipseUnifiedRestartFileAccess::close()
{
if (m_ecl_file)
{
ecl_file_close(m_ecl_file);
}
m_ecl_file = NULL;
}
//--------------------------------------------------------------------------------------------------
@ -71,18 +78,25 @@ void RifEclipseUnifiedRestartFileAccess::close()
//--------------------------------------------------------------------------------------------------
size_t RifEclipseUnifiedRestartFileAccess::timeStepCount()
{
if (!openFile())
{
return 0;
}
return timeSteps().size();
}
//--------------------------------------------------------------------------------------------------
/// Get the time steps
//--------------------------------------------------------------------------------------------------
QList<QDateTime> RifEclipseUnifiedRestartFileAccess::timeSteps()
std::vector<QDateTime> RifEclipseUnifiedRestartFileAccess::timeSteps()
{
CVF_ASSERT(m_ecl_file != NULL);
std::vector<QDateTime> timeSteps;
QList<QDateTime> timeSteps;
RifEclipseOutputFileTools::timeSteps(m_ecl_file, &timeSteps);
if (openFile())
{
RifEclipseOutputFileTools::timeSteps(m_ecl_file, &timeSteps);
}
return timeSteps;
}
@ -92,7 +106,10 @@ QList<QDateTime> RifEclipseUnifiedRestartFileAccess::timeSteps()
//--------------------------------------------------------------------------------------------------
void RifEclipseUnifiedRestartFileAccess::resultNames(QStringList* resultNames, std::vector<size_t>* resultDataItemCounts)
{
RifEclipseOutputFileTools::findKeywordsAndDataItemCounts(m_ecl_file, resultNames, resultDataItemCounts);
if (openFile())
{
RifEclipseOutputFileTools::findKeywordsAndDataItemCounts(m_ecl_file, resultNames, resultDataItemCounts);
}
}
//--------------------------------------------------------------------------------------------------
@ -100,6 +117,11 @@ void RifEclipseUnifiedRestartFileAccess::resultNames(QStringList* resultNames, s
//--------------------------------------------------------------------------------------------------
bool RifEclipseUnifiedRestartFileAccess::results(const QString& resultName, size_t timeStep, size_t gridCount, std::vector<double>* values)
{
if (!openFile())
{
return false;
}
size_t numOccurrences = ecl_file_get_num_named_kw(m_ecl_file, resultName.toAscii().data());
size_t startIndex = timeStep * gridCount;
@ -124,8 +146,19 @@ bool RifEclipseUnifiedRestartFileAccess::results(const QString& resultName, size
void RifEclipseUnifiedRestartFileAccess::readWellData(well_info_type* well_info)
{
if (!well_info) return;
CVF_ASSERT(m_ecl_file);
well_info_add_UNRST_wells(well_info, m_ecl_file);
if (openFile())
{
well_info_add_UNRST_wells(well_info, m_ecl_file);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RifEclipseUnifiedRestartFileAccess::setFileSet(const QStringList& fileSet)
{
m_filename = fileSet[0];
}

View File

@ -37,11 +37,12 @@ public:
RifEclipseUnifiedRestartFileAccess();
virtual ~RifEclipseUnifiedRestartFileAccess();
bool open(const QStringList& fileSet);
void setFileSet(const QStringList& fileSet);
bool open();
void close();
size_t timeStepCount();
QList<QDateTime> timeSteps();
std::vector<QDateTime> timeSteps();
void resultNames(QStringList* resultNames, std::vector<size_t>* resultDataItemCounts);
bool results(const QString& resultName, size_t timeStep, size_t gridCount, std::vector<double>* values);
@ -49,5 +50,9 @@ public:
virtual void readWellData(well_info_type * well_info);
private:
bool openFile();
private:
QString m_filename;
ecl_file_type* m_ecl_file;
};

View File

@ -19,8 +19,8 @@
#include "cvfBase.h"
#include "RigMainGrid.h"
#include "RigReservoir.h"
#include "RigReservoirCellResults.h"
#include "RigCaseData.h"
#include "RigCaseCellResultsData.h"
#include "RifReaderEclipseInput.h"
#include "RifReaderEclipseOutput.h"
@ -57,9 +57,9 @@ RifReaderEclipseInput::~RifReaderEclipseInput()
//--------------------------------------------------------------------------------------------------
/// Open file and read geometry into given reservoir object
//--------------------------------------------------------------------------------------------------
bool RifReaderEclipseInput::open(const QString& fileName, RigReservoir* reservoir)
bool RifReaderEclipseInput::open(const QString& fileName, RigCaseData* eclipseCase)
{
CVF_ASSERT(reservoir);
CVF_ASSERT(eclipseCase);
// Make sure everything's closed
close();
@ -84,9 +84,9 @@ bool RifReaderEclipseInput::open(const QString& fileName, RigReservoir* reservoi
// create InputProperty object
bool isOk = false;
if (reservoir->mainGrid()->gridPointDimensions() == cvf::Vec3st(0,0,0))
if (eclipseCase->mainGrid()->gridPointDimensions() == cvf::Vec3st(0,0,0))
{
isOk = RifEclipseInputFileTools::openGridFile(fileName, reservoir);
isOk = RifEclipseInputFileTools::openGridFile(fileName, eclipseCase);
}
return isOk;

View File

@ -32,7 +32,7 @@ public:
virtual ~RifReaderEclipseInput();
// Virtual interface implementation
virtual bool open(const QString& fileName, RigReservoir* reservoir);
virtual bool open(const QString& fileName, RigCaseData* eclipseCase);

View File

@ -19,8 +19,8 @@
#include "cvfBase.h"
#include "RigMainGrid.h"
#include "RigReservoir.h"
#include "RigReservoirCellResults.h"
#include "RigCaseData.h"
#include "RigCaseCellResultsData.h"
#include "RifReaderEclipseOutput.h"
#include "RifEclipseOutputFileTools.h"
@ -32,6 +32,8 @@
#include "ecl_grid.h"
#include "well_state.h"
#include "ecl_kw_magic.h"
#include "cafProgressInfo.h"
//--------------------------------------------------------------------------------------------------
@ -84,8 +86,10 @@ static const size_t cellMappingECLRi[8] = { 0, 1, 3, 2, 4, 5, 7, 6 };
// Static functions
//**************************************************************************************************
bool transferGridCellData(RigMainGrid* mainGrid, RigGridBase* localGrid, const ecl_grid_type* localEclGrid, size_t matrixActiveStartIndex, size_t fractureActiveStartIndex)
bool transferGridCellData(RigMainGrid* mainGrid, RigActiveCellInfo* activeCellInfo, RigActiveCellInfo* fractureActiveCellInfo, RigGridBase* localGrid, const ecl_grid_type* localEclGrid, size_t matrixActiveStartIndex, size_t fractureActiveStartIndex)
{
CVF_ASSERT(activeCellInfo && fractureActiveCellInfo);
int cellCount = ecl_grid_get_global_size(localEclGrid);
size_t cellStartIndex = mainGrid->cells().size();
size_t nodeStartIndex = mainGrid->nodes().size();
@ -103,39 +107,31 @@ bool transferGridCellData(RigMainGrid* mainGrid, RigGridBase* localGrid, const e
// Loop over cells and fill them with data
#pragma omp parallel for
for (int gIdx = 0; gIdx < cellCount; ++gIdx)
for (int localCellIdx = 0; localCellIdx < cellCount; ++localCellIdx)
{
RigCell& cell = mainGrid->cells()[cellStartIndex + gIdx];
RigCell& cell = mainGrid->cells()[cellStartIndex + localCellIdx];
bool invalid = ecl_grid_cell_invalid1(localEclGrid, gIdx);
bool invalid = ecl_grid_cell_invalid1(localEclGrid, localCellIdx);
cell.setInvalid(invalid);
cell.setCellIndex(gIdx);
cell.setCellIndex(localCellIdx);
// Active cell index
int matrixActiveIndex = ecl_grid_get_active_index1(localEclGrid, gIdx);
int matrixActiveIndex = ecl_grid_get_active_index1(localEclGrid, localCellIdx);
if (matrixActiveIndex != -1)
{
cell.setActiveIndexInMatrixModel(matrixActiveStartIndex + matrixActiveIndex);
}
else
{
cell.setActiveIndexInMatrixModel(cvf::UNDEFINED_SIZE_T);
activeCellInfo->setCellResultIndex(cellStartIndex + localCellIdx, matrixActiveStartIndex + matrixActiveIndex);
}
int fractureActiveIndex = ecl_grid_get_active_fracture_index1(localEclGrid, gIdx);
int fractureActiveIndex = ecl_grid_get_active_fracture_index1(localEclGrid, localCellIdx);
if (fractureActiveIndex != -1)
{
cell.setActiveIndexInFractureModel(fractureActiveStartIndex + fractureActiveIndex);
}
else
{
cell.setActiveIndexInFractureModel(cvf::UNDEFINED_SIZE_T);
fractureActiveCellInfo->setCellResultIndex(cellStartIndex + localCellIdx, fractureActiveStartIndex + fractureActiveIndex);
}
// Parent cell index
int parentCellIndex = ecl_grid_get_parent_cell1(localEclGrid, gIdx);
int parentCellIndex = ecl_grid_get_parent_cell1(localEclGrid, localCellIdx);
if (parentCellIndex == -1)
{
cell.setParentCellIndex(cvf::UNDEFINED_SIZE_T);
@ -146,21 +142,21 @@ bool transferGridCellData(RigMainGrid* mainGrid, RigGridBase* localGrid, const e
}
// Coarse cell info
ecl_coarse_cell_type * coarseCellData = ecl_grid_get_cell_coarse_group1( localEclGrid , gIdx);
ecl_coarse_cell_type * coarseCellData = ecl_grid_get_cell_coarse_group1( localEclGrid , localCellIdx);
cell.setInCoarseCell(coarseCellData != NULL);
// Corner coordinates
int cIdx;
for (cIdx = 0; cIdx < 8; ++cIdx)
{
double * point = mainGrid->nodes()[nodeStartIndex + gIdx * 8 + cellMappingECLRi[cIdx]].ptr();
ecl_grid_get_corner_xyz1(localEclGrid, gIdx, cIdx, &(point[0]), &(point[1]), &(point[2]));
double * point = mainGrid->nodes()[nodeStartIndex + localCellIdx * 8 + cellMappingECLRi[cIdx]].ptr();
ecl_grid_get_corner_xyz1(localEclGrid, localCellIdx, cIdx, &(point[0]), &(point[1]), &(point[2]));
point[2] = -point[2];
cell.cornerIndices()[cIdx] = nodeStartIndex + gIdx*8 + cIdx;
cell.cornerIndices()[cIdx] = nodeStartIndex + localCellIdx*8 + cIdx;
}
// Sub grid in cell
const ecl_grid_type* subGrid = ecl_grid_get_cell_lgr1(localEclGrid, gIdx);
const ecl_grid_type* subGrid = ecl_grid_get_cell_lgr1(localEclGrid, localCellIdx);
if (subGrid != NULL)
{
int subGridFileIndex = ecl_grid_get_grid_nr(subGrid);
@ -169,7 +165,9 @@ bool transferGridCellData(RigMainGrid* mainGrid, RigGridBase* localGrid, const e
}
// Mark inactive long pyramid looking cells as invalid
if (!invalid && (cell.isInCoarseCell() || (!cell.isActiveInMatrixModel() && !cell.isActiveInFractureModel()) ) )
// Forslag
//if (!invalid && (cell.isInCoarseCell() || (!cell.isActiveInMatrixModel() && !cell.isActiveInFractureModel()) ) )
if (!invalid)
{
cell.setInvalid(cell.isLongPyramidCell());
}
@ -193,7 +191,15 @@ bool transferGridCellData(RigMainGrid* mainGrid, RigGridBase* localGrid, const e
//--------------------------------------------------------------------------------------------------
RifReaderEclipseOutput::RifReaderEclipseOutput()
{
ground();
m_fileName.clear();
m_fileSet.clear();
m_timeSteps.clear();
m_eclipseCase = NULL;
m_ecl_init_file = NULL;
m_dynamicResultsAccess = NULL;
}
//--------------------------------------------------------------------------------------------------
@ -201,37 +207,33 @@ RifReaderEclipseOutput::RifReaderEclipseOutput()
//--------------------------------------------------------------------------------------------------
RifReaderEclipseOutput::~RifReaderEclipseOutput()
{
close();
}
//--------------------------------------------------------------------------------------------------
/// Ground members
//--------------------------------------------------------------------------------------------------
void RifReaderEclipseOutput::ground()
{
m_fileName.clear();
m_fileSet.clear();
m_timeSteps.clear();
m_mainGrid = NULL;
}
//--------------------------------------------------------------------------------------------------
/// Close interface (for now, no files are kept open after calling methods, so just clear members)
//--------------------------------------------------------------------------------------------------
void RifReaderEclipseOutput::close()
{
m_ecl_file = NULL;
m_dynamicResultsAccess = NULL;
if (m_ecl_init_file)
{
ecl_file_close(m_ecl_init_file);
}
m_ecl_init_file = NULL;
ground();
if (m_dynamicResultsAccess.notNull())
{
m_dynamicResultsAccess->close();
}
}
//--------------------------------------------------------------------------------------------------
/// Read geometry from file given by name into given reservoir object
//--------------------------------------------------------------------------------------------------
bool RifReaderEclipseOutput::transferGeometry(const ecl_grid_type* mainEclGrid, RigReservoir* reservoir)
bool RifReaderEclipseOutput::transferGeometry(const ecl_grid_type* mainEclGrid, RigCaseData* eclipseCase)
{
CVF_ASSERT(reservoir);
CVF_ASSERT(eclipseCase);
if (!mainEclGrid)
{
@ -239,7 +241,12 @@ bool RifReaderEclipseOutput::transferGeometry(const ecl_grid_type* mainEclGrid,
return false;
}
RigMainGrid* mainGrid = reservoir->mainGrid();
RigActiveCellInfo* activeCellInfo = eclipseCase->activeCellInfo(RifReaderInterface::MATRIX_RESULTS);
RigActiveCellInfo* fractureActiveCellInfo = eclipseCase->activeCellInfo(RifReaderInterface::FRACTURE_RESULTS);
CVF_ASSERT(activeCellInfo && fractureActiveCellInfo);
RigMainGrid* mainGrid = eclipseCase->mainGrid();
{
cvf::Vec3st gridPointDim(0,0,0);
gridPointDim.x() = ecl_grid_get_nx(mainEclGrid) + 1;
@ -273,6 +280,9 @@ bool RifReaderEclipseOutput::transferGeometry(const ecl_grid_type* mainEclGrid,
totalCellCount += ecl_grid_get_global_size(localEclGrid);
}
activeCellInfo->setGlobalCellCount(totalCellCount);
fractureActiveCellInfo->setGlobalCellCount(totalCellCount);
// Reserve room for the cells and nodes and fill them with data
@ -283,15 +293,20 @@ bool RifReaderEclipseOutput::transferGeometry(const ecl_grid_type* mainEclGrid,
progInfo.setProgressDescription("Main Grid");
progInfo.setNextProgressIncrement(3);
transferGridCellData(mainGrid, mainGrid, mainEclGrid, 0, 0);
transferGridCellData(mainGrid, activeCellInfo, fractureActiveCellInfo, mainGrid, mainEclGrid, 0, 0);
progInfo.setProgress(3);
size_t globalMatrixActiveSize = ecl_grid_get_nactive(mainEclGrid);
size_t globalFractureActiveSize = ecl_grid_get_nactive_fracture(mainEclGrid);
mainGrid->setMatrixModelActiveCellCount(globalMatrixActiveSize);
mainGrid->setFractureModelActiveCellCount(globalFractureActiveSize);
activeCellInfo->setGridCount(1 + numLGRs);
fractureActiveCellInfo->setGridCount(1 + numLGRs);
activeCellInfo->setGridActiveCellCounts(0, globalMatrixActiveSize);
fractureActiveCellInfo->setGridActiveCellCounts(0, globalFractureActiveSize);
for (lgrIdx = 0; lgrIdx < numLGRs; ++lgrIdx)
{
@ -300,22 +315,21 @@ bool RifReaderEclipseOutput::transferGeometry(const ecl_grid_type* mainEclGrid,
ecl_grid_type* localEclGrid = ecl_grid_iget_lgr(mainEclGrid, lgrIdx);
RigLocalGrid* localGrid = static_cast<RigLocalGrid*>(mainGrid->gridByIndex(lgrIdx+1));
transferGridCellData(mainGrid, localGrid, localEclGrid, globalMatrixActiveSize, globalFractureActiveSize);
transferGridCellData(mainGrid, activeCellInfo, fractureActiveCellInfo, localGrid, localEclGrid, globalMatrixActiveSize, globalFractureActiveSize);
int activeCellCount = ecl_grid_get_nactive(localEclGrid);
localGrid->setMatrixModelActiveCellCount(activeCellCount);
globalMatrixActiveSize += activeCellCount;
int matrixActiveCellCount = ecl_grid_get_nactive(localEclGrid);
globalMatrixActiveSize += matrixActiveCellCount;
activeCellCount = ecl_grid_get_nactive_fracture(localEclGrid);
localGrid->setFractureModelActiveCellCount(activeCellCount);
globalFractureActiveSize += activeCellCount;
int fractureActiveCellCount = ecl_grid_get_nactive_fracture(localEclGrid);
globalFractureActiveSize += fractureActiveCellCount;
activeCellInfo->setGridActiveCellCounts(lgrIdx + 1, matrixActiveCellCount);
fractureActiveCellInfo->setGridActiveCellCounts(lgrIdx + 1, fractureActiveCellCount);
progInfo.setProgress(3 + lgrIdx);
}
mainGrid->setGlobalMatrixModelActiveCellCount(globalMatrixActiveSize);
mainGrid->setGlobalFractureModelActiveCellCount(globalFractureActiveSize);
activeCellInfo->computeDerivedData();
fractureActiveCellInfo->computeDerivedData();
return true;
}
@ -323,9 +337,9 @@ bool RifReaderEclipseOutput::transferGeometry(const ecl_grid_type* mainEclGrid,
//--------------------------------------------------------------------------------------------------
/// Open file and read geometry into given reservoir object
//--------------------------------------------------------------------------------------------------
bool RifReaderEclipseOutput::open(const QString& fileName, RigReservoir* reservoir)
bool RifReaderEclipseOutput::open(const QString& fileName, RigCaseData* eclipseCase)
{
CVF_ASSERT(reservoir);
CVF_ASSERT(eclipseCase);
caf::ProgressInfo progInfo(100, "");
progInfo.setProgressDescription("Reading Grid");
@ -351,7 +365,7 @@ bool RifReaderEclipseOutput::open(const QString& fileName, RigReservoir* reservo
progInfo.setNextProgressIncrement(10);
progInfo.setProgressDescription("Transferring grid geometry");
if (!transferGeometry(mainEclGrid, reservoir)) return false;
if (!transferGeometry(mainEclGrid, eclipseCase)) return false;
progInfo.incrementProgress();
progInfo.setProgressDescription("Releasing reader memory");
@ -361,30 +375,157 @@ bool RifReaderEclipseOutput::open(const QString& fileName, RigReservoir* reservo
progInfo.setProgressDescription("Reading Result index");
progInfo.setNextProgressIncrement(60);
m_mainGrid = reservoir->mainGrid();
reservoir->mainGrid()->results(RifReaderInterface::MATRIX_RESULTS)->setReaderInterface(this);
reservoir->mainGrid()->results(RifReaderInterface::FRACTURE_RESULTS)->setReaderInterface(this);
m_eclipseCase = eclipseCase;
// Build results meta data
if (!buildMetaData(reservoir)) return false;
if (!buildMetaData()) return false;
progInfo.incrementProgress();
progInfo.setNextProgressIncrement(8);
progInfo.setProgressDescription("Reading Well information");
readWellCells(reservoir);
readWellCells();
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RifReaderEclipseOutput::openAndReadActiveCellData(const QString& fileName, const std::vector<QDateTime>& mainCaseTimeSteps, RigCaseData* eclipseCase)
{
CVF_ASSERT(eclipseCase);
// It is required to have a main grid before reading active cell data
if (!eclipseCase->mainGrid())
{
return false;
}
close();
// Get set of files
QStringList fileSet;
if (!RifEclipseOutputFileTools::fileSet(fileName, &fileSet)) return false;
// Keep the set of files of interest
m_fileSet = fileSet;
m_eclipseCase = eclipseCase;
if (!readActiveCellInfo())
{
return false;
}
// Reading of metadata and well cells is not performed here
//if (!buildMetaData()) return false;
// readWellCells();
m_dynamicResultsAccess = createDynamicResultsAccess(m_fileSet);
m_dynamicResultsAccess->setTimeSteps(mainCaseTimeSteps);
return true;
}
//--------------------------------------------------------------------------------------------------
///
/// See also RigStatistics::computeActiveCellUnion()
//--------------------------------------------------------------------------------------------------
bool RifReaderEclipseOutput::readActiveCellInfo()
{
CVF_ASSERT(m_eclipseCase);
CVF_ASSERT(m_eclipseCase->mainGrid());
QString egridFileName = RifEclipseOutputFileTools::fileNameByType(m_fileSet, ECL_EGRID_FILE);
if (egridFileName.size() > 0)
{
ecl_file_type* ecl_file = ecl_file_open(egridFileName.toAscii().data());
if (!ecl_file) return false;
int actnumKeywordCount = ecl_file_get_num_named_kw(ecl_file, ACTNUM_KW);
if (actnumKeywordCount > 0)
{
std::vector<std::vector<int> > actnumValuesPerGrid;
actnumValuesPerGrid.resize(actnumKeywordCount);
size_t globalCellCount = 0;
for (size_t gridIdx = 0; gridIdx < static_cast<size_t>(actnumKeywordCount); gridIdx++)
{
RifEclipseOutputFileTools::keywordData(ecl_file, ACTNUM_KW, gridIdx, &actnumValuesPerGrid[gridIdx]);
globalCellCount += actnumValuesPerGrid[gridIdx].size();
}
// Check if number of cells is matching
if (m_eclipseCase->mainGrid()->cells().size() != globalCellCount)
{
return false;
}
RigActiveCellInfo* activeCellInfo = m_eclipseCase->activeCellInfo(RifReaderInterface::MATRIX_RESULTS);
RigActiveCellInfo* fractureActiveCellInfo = m_eclipseCase->activeCellInfo(RifReaderInterface::FRACTURE_RESULTS);
activeCellInfo->setGlobalCellCount(globalCellCount);
fractureActiveCellInfo->setGlobalCellCount(globalCellCount);
activeCellInfo->setGridCount(actnumKeywordCount);
fractureActiveCellInfo->setGridCount(actnumKeywordCount);
size_t cellIdx = 0;
size_t globalActiveMatrixIndex = 0;
size_t globalActiveFractureIndex = 0;
for (size_t gridIdx = 0; gridIdx < static_cast<size_t>(actnumKeywordCount); gridIdx++)
{
size_t activeMatrixIndex = 0;
size_t activeFractureIndex = 0;
std::vector<int>& actnumValues = actnumValuesPerGrid[gridIdx];
for (size_t i = 0; i < actnumValues.size(); i++)
{
if (actnumValues[i] == 1 || actnumValues[i] == 3)
{
activeCellInfo->setCellResultIndex(cellIdx, globalActiveMatrixIndex++);
activeMatrixIndex++;
}
if (actnumValues[i] == 2 || actnumValues[i] == 3)
{
fractureActiveCellInfo->setCellResultIndex(cellIdx, globalActiveFractureIndex++);
activeFractureIndex++;
}
cellIdx++;
}
activeCellInfo->setGridActiveCellCounts(gridIdx, activeMatrixIndex);
fractureActiveCellInfo->setGridActiveCellCounts(gridIdx, activeFractureIndex);
}
activeCellInfo->computeDerivedData();
fractureActiveCellInfo->computeDerivedData();
}
ecl_file_close(ecl_file);
return true;
}
return false;
}
//--------------------------------------------------------------------------------------------------
/// Build meta data - get states and results info
//--------------------------------------------------------------------------------------------------
bool RifReaderEclipseOutput::buildMetaData(RigReservoir* reservoir)
bool RifReaderEclipseOutput::buildMetaData()
{
CVF_ASSERT(reservoir);
CVF_ASSERT(m_eclipseCase);
CVF_ASSERT(m_fileSet.size() > 0);
caf::ProgressInfo progInfo(m_fileSet.size() + 3,"");
@ -392,16 +533,19 @@ bool RifReaderEclipseOutput::buildMetaData(RigReservoir* reservoir)
progInfo.setNextProgressIncrement(m_fileSet.size());
// Create access object for dynamic results
m_dynamicResultsAccess = dynamicResultsAccess(m_fileSet);
m_dynamicResultsAccess = createDynamicResultsAccess(m_fileSet);
if (m_dynamicResultsAccess.isNull())
{
return false;
}
m_dynamicResultsAccess->open();
progInfo.incrementProgress();
RigReservoirCellResults* matrixModelResults = reservoir->mainGrid()->results(RifReaderInterface::MATRIX_RESULTS);
RigReservoirCellResults* fractureModelResults = reservoir->mainGrid()->results(RifReaderInterface::FRACTURE_RESULTS);
RigCaseCellResultsData* matrixModelResults = m_eclipseCase->results(RifReaderInterface::MATRIX_RESULTS);
RigCaseCellResultsData* fractureModelResults = m_eclipseCase->results(RifReaderInterface::FRACTURE_RESULTS);
if (m_dynamicResultsAccess.notNull())
{
@ -413,21 +557,27 @@ bool RifReaderEclipseOutput::buildMetaData(RigReservoir* reservoir)
m_dynamicResultsAccess->resultNames(&resultNames, &resultNamesDataItemCounts);
{
QStringList matrixResultNames = validKeywordsForPorosityModel(resultNames, resultNamesDataItemCounts, RifReaderInterface::MATRIX_RESULTS, m_dynamicResultsAccess->timeStepCount());
QStringList matrixResultNames = validKeywordsForPorosityModel(resultNames, resultNamesDataItemCounts,
m_eclipseCase->activeCellInfo(RifReaderInterface::MATRIX_RESULTS),
m_eclipseCase->activeCellInfo(RifReaderInterface::FRACTURE_RESULTS),
RifReaderInterface::MATRIX_RESULTS, m_dynamicResultsAccess->timeStepCount());
for (int i = 0; i < matrixResultNames.size(); ++i)
{
size_t resIndex = matrixModelResults->addEmptyScalarResult(RimDefines::DYNAMIC_NATIVE, matrixResultNames[i]);
size_t resIndex = matrixModelResults->addEmptyScalarResult(RimDefines::DYNAMIC_NATIVE, matrixResultNames[i], false);
matrixModelResults->setTimeStepDates(resIndex, m_timeSteps);
}
}
{
QStringList fractureResultNames = validKeywordsForPorosityModel(resultNames, resultNamesDataItemCounts, RifReaderInterface::FRACTURE_RESULTS, m_dynamicResultsAccess->timeStepCount());
QStringList fractureResultNames = validKeywordsForPorosityModel(resultNames, resultNamesDataItemCounts,
m_eclipseCase->activeCellInfo(RifReaderInterface::MATRIX_RESULTS),
m_eclipseCase->activeCellInfo(RifReaderInterface::FRACTURE_RESULTS),
RifReaderInterface::FRACTURE_RESULTS, m_dynamicResultsAccess->timeStepCount());
for (int i = 0; i < fractureResultNames.size(); ++i)
{
size_t resIndex = fractureModelResults->addEmptyScalarResult(RimDefines::DYNAMIC_NATIVE, fractureResultNames[i]);
size_t resIndex = fractureModelResults->addEmptyScalarResult(RimDefines::DYNAMIC_NATIVE, fractureResultNames[i], false);
fractureModelResults->setTimeStepDates(resIndex, m_timeSteps);
}
}
@ -436,22 +586,23 @@ bool RifReaderEclipseOutput::buildMetaData(RigReservoir* reservoir)
progInfo.incrementProgress();
QString initFileName = RifEclipseOutputFileTools::fileNameByType(m_fileSet, ECL_INIT_FILE);
if (initFileName.size() > 0)
openInitFile();
progInfo.incrementProgress();
if (m_ecl_init_file)
{
ecl_file_type* ecl_file = ecl_file_open(initFileName.toAscii().data());
if (!ecl_file) return false;
progInfo.incrementProgress();
QStringList resultNames;
std::vector<size_t> resultNamesDataItemCounts;
RifEclipseOutputFileTools::findKeywordsAndDataItemCounts(ecl_file, &resultNames, &resultNamesDataItemCounts);
RifEclipseOutputFileTools::findKeywordsAndDataItemCounts(m_ecl_init_file, &resultNames, &resultNamesDataItemCounts);
{
QStringList matrixResultNames = validKeywordsForPorosityModel(resultNames, resultNamesDataItemCounts, RifReaderInterface::MATRIX_RESULTS, 1);
QStringList matrixResultNames = validKeywordsForPorosityModel(resultNames, resultNamesDataItemCounts,
m_eclipseCase->activeCellInfo(RifReaderInterface::MATRIX_RESULTS),
m_eclipseCase->activeCellInfo(RifReaderInterface::FRACTURE_RESULTS),
RifReaderInterface::MATRIX_RESULTS, 1);
QList<QDateTime> staticDate;
std::vector<QDateTime> staticDate;
if (m_timeSteps.size() > 0)
{
staticDate.push_back(m_timeSteps.front());
@ -459,15 +610,18 @@ bool RifReaderEclipseOutput::buildMetaData(RigReservoir* reservoir)
for (int i = 0; i < matrixResultNames.size(); ++i)
{
size_t resIndex = matrixModelResults->addEmptyScalarResult(RimDefines::STATIC_NATIVE, matrixResultNames[i]);
size_t resIndex = matrixModelResults->addEmptyScalarResult(RimDefines::STATIC_NATIVE, matrixResultNames[i], false);
matrixModelResults->setTimeStepDates(resIndex, staticDate);
}
}
{
QStringList fractureResultNames = validKeywordsForPorosityModel(resultNames, resultNamesDataItemCounts, RifReaderInterface::FRACTURE_RESULTS, 1);
QStringList fractureResultNames = validKeywordsForPorosityModel(resultNames, resultNamesDataItemCounts,
m_eclipseCase->activeCellInfo(RifReaderInterface::MATRIX_RESULTS),
m_eclipseCase->activeCellInfo(RifReaderInterface::FRACTURE_RESULTS),
RifReaderInterface::FRACTURE_RESULTS, 1);
QList<QDateTime> staticDate;
std::vector<QDateTime> staticDate;
if (m_timeSteps.size() > 0)
{
staticDate.push_back(m_timeSteps.front());
@ -475,12 +629,10 @@ bool RifReaderEclipseOutput::buildMetaData(RigReservoir* reservoir)
for (int i = 0; i < fractureResultNames.size(); ++i)
{
size_t resIndex = fractureModelResults->addEmptyScalarResult(RimDefines::STATIC_NATIVE, fractureResultNames[i]);
size_t resIndex = fractureModelResults->addEmptyScalarResult(RimDefines::STATIC_NATIVE, fractureResultNames[i], false);
fractureModelResults->setTimeStepDates(resIndex, staticDate);
}
}
m_ecl_file = ecl_file;
}
return true;
@ -489,7 +641,7 @@ bool RifReaderEclipseOutput::buildMetaData(RigReservoir* reservoir)
//--------------------------------------------------------------------------------------------------
/// Create results access object (.UNRST or .X0001 ... .XNNNN)
//--------------------------------------------------------------------------------------------------
RifEclipseRestartDataAccess* RifReaderEclipseOutput::dynamicResultsAccess(const QStringList& fileSet)
RifEclipseRestartDataAccess* RifReaderEclipseOutput::createDynamicResultsAccess(const QStringList& fileSet)
{
RifEclipseRestartDataAccess* resultsAccess = NULL;
@ -498,11 +650,7 @@ RifEclipseRestartDataAccess* RifReaderEclipseOutput::dynamicResultsAccess(const
if (unrstFileName.size() > 0)
{
resultsAccess = new RifEclipseUnifiedRestartFileAccess();
if (!resultsAccess->open(QStringList(unrstFileName)))
{
delete resultsAccess;
return NULL;
}
resultsAccess->setFileSet(QStringList(unrstFileName));
}
else
{
@ -511,17 +659,10 @@ RifEclipseRestartDataAccess* RifReaderEclipseOutput::dynamicResultsAccess(const
if (restartFiles.size() > 0)
{
resultsAccess = new RifEclipseRestartFilesetAccess();
if (!resultsAccess->open(restartFiles))
{
delete resultsAccess;
return NULL;
}
resultsAccess->setFileSet(restartFiles);
}
}
// !! could add support for formatted result files
// !! consider priorities in case multiple types exist (.UNRST, .XNNNN, ...)
return resultsAccess;
}
@ -531,16 +672,22 @@ RifEclipseRestartDataAccess* RifReaderEclipseOutput::dynamicResultsAccess(const
bool RifReaderEclipseOutput::staticResult(const QString& result, PorosityModelResultType matrixOrFracture, std::vector<double>* values)
{
CVF_ASSERT(values);
CVF_ASSERT(m_ecl_file);
if (!openInitFile())
{
return false;
}
CVF_ASSERT(m_ecl_init_file);
std::vector<double> fileValues;
size_t numOccurrences = ecl_file_get_num_named_kw(m_ecl_file, result.toAscii().data());
size_t numOccurrences = ecl_file_get_num_named_kw(m_ecl_init_file, result.toAscii().data());
size_t i;
for (i = 0; i < numOccurrences; i++)
{
std::vector<double> partValues;
RifEclipseOutputFileTools::keywordData(m_ecl_file, result, i, &partValues);
RifEclipseOutputFileTools::keywordData(m_ecl_init_file, result, i, &partValues);
fileValues.insert(fileValues.end(), partValues.begin(), partValues.end());
}
@ -554,10 +701,19 @@ bool RifReaderEclipseOutput::staticResult(const QString& result, PorosityModelRe
//--------------------------------------------------------------------------------------------------
bool RifReaderEclipseOutput::dynamicResult(const QString& result, PorosityModelResultType matrixOrFracture, size_t stepIndex, std::vector<double>* values)
{
CVF_ASSERT(m_dynamicResultsAccess.notNull());
if (m_dynamicResultsAccess.isNull())
{
m_dynamicResultsAccess = createDynamicResultsAccess(m_fileSet);
}
if (m_dynamicResultsAccess.isNull())
{
CVF_ASSERT(false);
return false;
}
std::vector<double> fileValues;
if (!m_dynamicResultsAccess->results(result, stepIndex, m_mainGrid->gridCount(), &fileValues))
if (!m_dynamicResultsAccess->results(result, stepIndex, m_eclipseCase->mainGrid()->gridCount(), &fileValues))
{
return false;
}
@ -570,9 +726,9 @@ bool RifReaderEclipseOutput::dynamicResult(const QString& result, PorosityModelR
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RifReaderEclipseOutput::readWellCells(RigReservoir* reservoir)
void RifReaderEclipseOutput::readWellCells()
{
CVF_ASSERT(reservoir);
CVF_ASSERT(m_eclipseCase);
if (m_dynamicResultsAccess.isNull()) return;
@ -581,11 +737,11 @@ void RifReaderEclipseOutput::readWellCells(RigReservoir* reservoir)
m_dynamicResultsAccess->readWellData(ert_well_info);
RigMainGrid* mainGrid = reservoir->mainGrid();
RigMainGrid* mainGrid = m_eclipseCase->mainGrid();
std::vector<RigGridBase*> grids;
reservoir->allGrids(&grids);
m_eclipseCase->allGrids(&grids);
cvf::Collection<RigWellResults> wells;
cvf::Collection<RigSingleWellResultsData> wells;
caf::ProgressInfo progress(well_info_get_num_wells(ert_well_info), "");
int wellIdx;
@ -594,7 +750,7 @@ void RifReaderEclipseOutput::readWellCells(RigReservoir* reservoir)
const char* wellName = well_info_iget_well_name(ert_well_info, wellIdx);
CVF_ASSERT(wellName);
cvf::ref<RigWellResults> wellResults = new RigWellResults;
cvf::ref<RigSingleWellResultsData> wellResults = new RigSingleWellResultsData;
wellResults->m_wellName = wellName;
well_ts_type* ert_well_time_series = well_info_get_ts(ert_well_info , wellName);
@ -671,7 +827,7 @@ void RifReaderEclipseOutput::readWellCells(RigReservoir* reservoir)
// If a well is defined in fracture region, the K-value is from (cellCountK - 1) -> cellCountK*2 - 1
// Adjust K so index is always in valid grid region
if (cellK >= grids[gridNr]->cellCountK())
if (cellK >= static_cast<int>(grids[gridNr]->cellCountK()))
{
cellK -= static_cast<int>(grids[gridNr]->cellCountK());
}
@ -716,7 +872,7 @@ void RifReaderEclipseOutput::readWellCells(RigReservoir* reservoir)
// If a well is defined in fracture region, the K-value is from (cellCountK - 1) -> cellCountK*2 - 1
// Adjust K so index is always in valid grid region
if (cellK >= grids[gridNr]->cellCountK())
if (cellK >= static_cast<int>(grids[gridNr]->cellCountK()))
{
cellK -= static_cast<int>(grids[gridNr]->cellCountK());
}
@ -743,41 +899,27 @@ void RifReaderEclipseOutput::readWellCells(RigReservoir* reservoir)
well_info_free(ert_well_info);
reservoir->setWellResults(wells);
m_eclipseCase->setWellResults(wells);
}
//--------------------------------------------------------------------------------------------------
// For case DUALPORO, the well K index is reported outside the grid. If this happens,
// for the given IJ position, search from K=0 and upwards for first active cell.
//--------------------------------------------------------------------------------------------------
int RifReaderEclipseOutput::findSmallestActiveCellIndexK(const RigGridBase* grid, int cellI, int cellJ)
{
if (!grid) return -1;
for (int candidateCellK = 0; candidateCellK < grid->cellCountK(); candidateCellK++ )
{
if (grid->isCellActive(cellI, cellJ, candidateCellK))
{
return candidateCellK;
}
}
return -1;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QStringList RifReaderEclipseOutput::validKeywordsForPorosityModel(const QStringList& keywords, const std::vector<size_t>& keywordDataItemCounts, PorosityModelResultType matrixOrFracture, size_t timeStepCount) const
QStringList RifReaderEclipseOutput::validKeywordsForPorosityModel(const QStringList& keywords, const std::vector<size_t>& keywordDataItemCounts,
const RigActiveCellInfo* activeCellInfo, const RigActiveCellInfo* fractureActiveCellInfo,
PorosityModelResultType matrixOrFracture, size_t timeStepCount) const
{
if (keywords.size() != keywordDataItemCounts.size())
CVF_ASSERT(activeCellInfo);
if (keywords.size() != static_cast<int>(keywordDataItemCounts.size()))
{
return QStringList();
}
if (matrixOrFracture == RifReaderInterface::FRACTURE_RESULTS)
{
if (m_mainGrid->globalFractureModelActiveCellCount() == 0)
if (fractureActiveCellInfo->globalActiveCellCount() == 0)
{
return QStringList();
}
@ -790,17 +932,27 @@ QStringList RifReaderEclipseOutput::validKeywordsForPorosityModel(const QStringL
QString keyword = keywords[i];
size_t keywordDataCount = keywordDataItemCounts[i];
size_t timeStepsMatrix = keywordDataItemCounts[i] / m_mainGrid->globalMatrixModelActiveCellCount();
size_t timeStepsMatrixRest = keywordDataItemCounts[i] % m_mainGrid->globalMatrixModelActiveCellCount();
size_t timeStepsMatrixAndFracture = keywordDataItemCounts[i] / (m_mainGrid->globalMatrixModelActiveCellCount() + m_mainGrid->globalFractureModelActiveCellCount());
size_t timeStepsMatrixAndFractureRest = keywordDataItemCounts[i] % (m_mainGrid->globalMatrixModelActiveCellCount() + m_mainGrid->globalFractureModelActiveCellCount());
if (matrixOrFracture == RifReaderInterface::MATRIX_RESULTS)
if (activeCellInfo->globalActiveCellCount() > 0)
{
if (timeStepsMatrixRest == 0 || timeStepsMatrixAndFractureRest == 0)
size_t timeStepsMatrix = keywordDataItemCounts[i] / activeCellInfo->globalActiveCellCount();
size_t timeStepsMatrixRest = keywordDataItemCounts[i] % activeCellInfo->globalActiveCellCount();
size_t timeStepsMatrixAndFracture = keywordDataItemCounts[i] / (activeCellInfo->globalActiveCellCount() + fractureActiveCellInfo->globalActiveCellCount());
size_t timeStepsMatrixAndFractureRest = keywordDataItemCounts[i] % (activeCellInfo->globalActiveCellCount() + fractureActiveCellInfo->globalActiveCellCount());
if (matrixOrFracture == RifReaderInterface::MATRIX_RESULTS)
{
if (timeStepCount == timeStepsMatrix || timeStepCount == timeStepsMatrixAndFracture)
if (timeStepsMatrixRest == 0 || timeStepsMatrixAndFractureRest == 0)
{
if (timeStepCount == timeStepsMatrix || timeStepCount == timeStepsMatrixAndFracture)
{
keywordsWithCorrectNumberOfDataItems.push_back(keywords[i]);
}
}
}
else
{
if (timeStepsMatrixAndFractureRest == 0 && timeStepCount == timeStepsMatrixAndFracture)
{
keywordsWithCorrectNumberOfDataItems.push_back(keywords[i]);
}
@ -808,57 +960,87 @@ QStringList RifReaderEclipseOutput::validKeywordsForPorosityModel(const QStringL
}
else
{
if (timeStepsMatrixAndFractureRest == 0 && timeStepCount == timeStepsMatrixAndFracture)
{
keywordsWithCorrectNumberOfDataItems.push_back(keywords[i]);
}
keywordsWithCorrectNumberOfDataItems.push_back(keywords[i]);
}
}
return keywordsWithCorrectNumberOfDataItems;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RifReaderEclipseOutput::extractResultValuesBasedOnPorosityModel(PorosityModelResultType matrixOrFracture, std::vector<double>* destinationResultValues, const std::vector<double>& sourceResultValues)
{
if (matrixOrFracture == RifReaderInterface::MATRIX_RESULTS)
RigActiveCellInfo* fracActCellInfo = m_eclipseCase->activeCellInfo(RifReaderInterface::FRACTURE_RESULTS);
if (matrixOrFracture == RifReaderInterface::MATRIX_RESULTS && fracActCellInfo->globalActiveCellCount() == 0)
{
if (m_mainGrid->globalFractureModelActiveCellCount() == 0)
{
destinationResultValues->insert(destinationResultValues->end(), sourceResultValues.begin(), sourceResultValues.end());
}
else
{
size_t dataItemCount = 0;
size_t sourceStartPosition = 0;
for (size_t i = 0; i < m_mainGrid->gridCount(); i++)
{
size_t matrixActiveCellCount = m_mainGrid->gridByIndex(i)->matrixModelActiveCellCount();
size_t fractureActiveCellCount = m_mainGrid->gridByIndex(i)->matrixModelActiveCellCount();
destinationResultValues->insert(destinationResultValues->end(), sourceResultValues.begin() + sourceStartPosition, sourceResultValues.begin() + sourceStartPosition + matrixActiveCellCount);
sourceStartPosition += (matrixActiveCellCount + fractureActiveCellCount);
}
}
destinationResultValues->insert(destinationResultValues->end(), sourceResultValues.begin(), sourceResultValues.end());
}
else
{
RigActiveCellInfo* actCellInfo = m_eclipseCase->activeCellInfo(RifReaderInterface::MATRIX_RESULTS);
size_t dataItemCount = 0;
size_t sourceStartPosition = 0;
for (size_t i = 0; i < m_mainGrid->gridCount(); i++)
for (size_t i = 0; i < m_eclipseCase->mainGrid()->gridCount(); i++)
{
size_t matrixActiveCellCount = m_mainGrid->gridByIndex(i)->matrixModelActiveCellCount();
size_t fractureActiveCellCount = m_mainGrid->gridByIndex(i)->matrixModelActiveCellCount();
size_t matrixActiveCellCount = 0;
size_t fractureActiveCellCount = 0;
actCellInfo->gridActiveCellCounts(i, matrixActiveCellCount);
fracActCellInfo->gridActiveCellCounts(i, fractureActiveCellCount);
destinationResultValues->insert(destinationResultValues->end(), sourceResultValues.begin() + sourceStartPosition + matrixActiveCellCount, sourceResultValues.begin() + sourceStartPosition + matrixActiveCellCount + fractureActiveCellCount);
if (matrixOrFracture == RifReaderInterface::MATRIX_RESULTS)
{
destinationResultValues->insert(destinationResultValues->end(),
sourceResultValues.begin() + sourceStartPosition,
sourceResultValues.begin() + sourceStartPosition + matrixActiveCellCount);
}
else
{
destinationResultValues->insert(destinationResultValues->end(),
sourceResultValues.begin() + sourceStartPosition + matrixActiveCellCount,
sourceResultValues.begin() + sourceStartPosition + matrixActiveCellCount + fractureActiveCellCount);
}
sourceStartPosition += (matrixActiveCellCount + fractureActiveCellCount);
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RifReaderEclipseOutput::openInitFile()
{
if (m_ecl_init_file)
{
return true;
}
QString initFileName = RifEclipseOutputFileTools::fileNameByType(m_fileSet, ECL_INIT_FILE);
if (initFileName.size() > 0)
{
m_ecl_init_file = ecl_file_open(initFileName.toAscii().data());
if (m_ecl_init_file)
{
return true;
}
}
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<QDateTime> RifReaderEclipseOutput::timeSteps()
{
return m_timeSteps;
}

View File

@ -26,6 +26,7 @@ class RifEclipseOutputFileTools;
class RifEclipseRestartDataAccess;
class RigGridBase;
class RigMainGrid;
class RigActiveCellInfo;
typedef struct ecl_grid_struct ecl_grid_type;
typedef struct ecl_file_struct ecl_file_type;
@ -42,36 +43,38 @@ public:
RifReaderEclipseOutput();
virtual ~RifReaderEclipseOutput();
bool open(const QString& fileName, RigReservoir* reservoir);
bool open(const QString& fileName, RigCaseData* eclipseCase);
virtual bool openAndReadActiveCellData(const QString& fileName, const std::vector<QDateTime>& mainCaseTimeSteps, RigCaseData* eclipseCase);
void close();
bool staticResult(const QString& result, PorosityModelResultType matrixOrFracture, std::vector<double>* values);
bool dynamicResult(const QString& result, PorosityModelResultType matrixOrFracture, size_t stepIndex, std::vector<double>* values);
static bool transferGeometry(const ecl_grid_type* mainEclGrid, RigReservoir* reservoir);
static bool transferGeometry(const ecl_grid_type* mainEclGrid, RigCaseData* eclipseCase);
private:
void ground();
bool buildMetaData(RigReservoir* reservoir);
void readWellCells(RigReservoir* reservoir);
bool readActiveCellInfo();
bool buildMetaData();
void readWellCells();
bool openInitFile();
bool openDynamicAccess();
void extractResultValuesBasedOnPorosityModel(PorosityModelResultType matrixOrFracture, std::vector<double>* values, const std::vector<double>& fileValues);
int findSmallestActiveCellIndexK( const RigGridBase* grid, int cellI, int cellJ);
static RifEclipseRestartDataAccess* createDynamicResultsAccess(const QStringList& fileSet);
static RifEclipseRestartDataAccess* staticResultsAccess(const QStringList& fileSet);
static RifEclipseRestartDataAccess* dynamicResultsAccess(const QStringList& fileSet);
QStringList validKeywordsForPorosityModel(const QStringList& keywords, const std::vector<size_t>& keywordDataItemCounts, PorosityModelResultType matrixOrFracture, size_t timeStepCount) const;
QStringList validKeywordsForPorosityModel(const QStringList& keywords, const std::vector<size_t>& keywordDataItemCounts, const RigActiveCellInfo* activeCellInfo, const RigActiveCellInfo* fractureActiveCellInfo, PorosityModelResultType matrixOrFracture, size_t timeStepCount) const;
virtual std::vector<QDateTime> timeSteps();
private:
QString m_fileName; // Name of file used to start accessing Eclipse output files
QStringList m_fileSet; // Set of files in filename's path with same base name as filename
cvf::cref<RigMainGrid> m_mainGrid;
RigCaseData* m_eclipseCase;
QList<QDateTime> m_timeSteps;
std::vector<QDateTime> m_timeSteps;
ecl_file_type* m_ecl_file; // File access to static results
ecl_file_type* m_ecl_init_file; // File access to static results
cvf::ref<RifEclipseRestartDataAccess> m_dynamicResultsAccess; // File access to dynamic results
};

View File

@ -24,9 +24,10 @@
#include <QString>
#include <QStringList>
#include <QDateTime>
class RigReservoir;
class RigCaseData;
//==================================================================================================
//
@ -46,10 +47,11 @@ public:
RifReaderInterface() {}
virtual ~RifReaderInterface() {}
virtual bool open(const QString& fileName, RigReservoir* reservoir) = 0;
virtual bool open(const QString& fileName, RigCaseData* eclipseCase) = 0;
virtual void close() = 0;
virtual bool staticResult(const QString& result, PorosityModelResultType matrixOrFracture, std::vector<double>* values) = 0;
virtual bool dynamicResult(const QString& result, PorosityModelResultType matrixOrFracture, size_t stepIndex, std::vector<double>* values) = 0;
};
virtual std::vector<QDateTime> timeSteps() { std::vector<QDateTime> timeSteps; return timeSteps; }
};

View File

@ -16,25 +16,25 @@
//
/////////////////////////////////////////////////////////////////////////////////
#include "RIStdInclude.h"
#include "RiaStdInclude.h"
#include "RifReaderMockModel.h"
#include "RigReservoirCellResults.h"
#include "RigCaseCellResultsData.h"
#include "RifReaderInterface.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RifReaderMockModel::open(const QString& fileName, RigReservoir* reservoir)
bool RifReaderMockModel::open(const QString& fileName, RigCaseData* eclipseCase)
{
m_reservoirBuilder.populateReservoir(reservoir);
m_reservoirBuilder.populateReservoir(eclipseCase);
m_reservoir = reservoir;
m_reservoir = eclipseCase;
RigReservoirCellResults* cellResults = reservoir->mainGrid()->results(RifReaderInterface::MATRIX_RESULTS);
RigCaseCellResultsData* cellResults = eclipseCase->results(RifReaderInterface::MATRIX_RESULTS);
QList<QDateTime> dates;
std::vector<QDateTime> dates;
for (int i = 0; i < static_cast<int>(m_reservoirBuilder.timeStepCount()); i++)
{
@ -43,13 +43,13 @@ bool RifReaderMockModel::open(const QString& fileName, RigReservoir* reservoir)
for (size_t i = 0; i < m_reservoirBuilder.resultCount(); i++)
{
size_t resIdx = cellResults->addEmptyScalarResult(RimDefines::DYNAMIC_NATIVE, QString("Dynamic_Result_%1").arg(i));
size_t resIdx = cellResults->addEmptyScalarResult(RimDefines::DYNAMIC_NATIVE, QString("Dynamic_Result_%1").arg(i), false);
cellResults->setTimeStepDates(resIdx, dates);
}
if (m_reservoirBuilder.timeStepCount() == 0) return true;
QList<QDateTime> staticDates;
std::vector<QDateTime> staticDates;
staticDates.push_back(dates[0]);
for (int i = 0; i < static_cast<int>(m_reservoirBuilder.resultCount()); i++)
{
@ -59,7 +59,7 @@ bool RifReaderMockModel::open(const QString& fileName, RigReservoir* reservoir)
int resIndex = 0;
if (i > 1) resIndex = i;
size_t resIdx = cellResults->addEmptyScalarResult(RimDefines::STATIC_NATIVE, QString("Static_Result_%1%2").arg(resIndex).arg(varEnd));
size_t resIdx = cellResults->addEmptyScalarResult(RimDefines::STATIC_NATIVE, QString("Static_Result_%1%2").arg(resIndex).arg(varEnd), false);
cellResults->setTimeStepDates(resIdx, staticDates);
}
@ -68,7 +68,7 @@ bool RifReaderMockModel::open(const QString& fileName, RigReservoir* reservoir)
{ \
size_t resIdx; \
QString resultName(Name); \
resIdx = cellResults->addEmptyScalarResult(RimDefines::INPUT_PROPERTY, resultName); \
resIdx = cellResults->addEmptyScalarResult(RimDefines::INPUT_PROPERTY, resultName, false); \
cellResults->setTimeStepDates(resIdx, staticDates); \
cellResults->cellScalarResults(resIdx).resize(1); \
std::vector<double>& values = cellResults->cellScalarResults(resIdx)[0]; \
@ -96,7 +96,7 @@ void RifReaderMockModel::close()
//--------------------------------------------------------------------------------------------------
bool RifReaderMockModel::inputProperty(const QString& propertyName, std::vector<double>* values)
{
return m_reservoirBuilder.inputProperty(m_reservoir.p(), propertyName, values);
return m_reservoirBuilder.inputProperty(m_reservoir, propertyName, values);
}
//--------------------------------------------------------------------------------------------------
@ -104,7 +104,7 @@ bool RifReaderMockModel::inputProperty(const QString& propertyName, std::vector<
//--------------------------------------------------------------------------------------------------
bool RifReaderMockModel::staticResult(const QString& result, RifReaderInterface::PorosityModelResultType matrixOrFracture, std::vector<double>* values)
{
m_reservoirBuilder.staticResult(m_reservoir.p(), result, values);
m_reservoirBuilder.staticResult(m_reservoir, result, values);
return true;
}
@ -114,7 +114,7 @@ bool RifReaderMockModel::staticResult(const QString& result, RifReaderInterface:
//--------------------------------------------------------------------------------------------------
bool RifReaderMockModel::dynamicResult(const QString& result, RifReaderInterface::PorosityModelResultType matrixOrFracture, size_t stepIndex, std::vector<double>* values)
{
m_reservoirBuilder.dynamicResult(m_reservoir.p(), result, stepIndex, values);
m_reservoirBuilder.dynamicResult(m_reservoir, result, stepIndex, values);
return true;
}
@ -170,8 +170,8 @@ void RifReaderMockModel::addLocalGridRefinement(const cvf::Vec3st& minCellPositi
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RifReaderMockModel::populateReservoir(RigReservoir* reservoir)
void RifReaderMockModel::populateReservoir(RigCaseData* eclipseCase)
{
m_reservoirBuilder.populateReservoir(reservoir);
m_reservoirBuilder.populateReservoir(eclipseCase);
}

View File

@ -33,17 +33,17 @@ public:
void addLocalGridRefinement(const cvf::Vec3st& minCellPosition, const cvf::Vec3st& maxCellPosition, const cvf::Vec3st& singleCellRefinementFactors);
virtual bool open( const QString& fileName, RigReservoir* reservoir );
virtual bool open( const QString& fileName, RigCaseData* eclipseCase );
virtual void close();
virtual bool staticResult( const QString& result, RifReaderInterface::PorosityModelResultType matrixOrFracture, std::vector<double>* values );
virtual bool dynamicResult( const QString& result, RifReaderInterface::PorosityModelResultType matrixOrFracture, size_t stepIndex, std::vector<double>* values );
private:
void populateReservoir(RigReservoir* reservoir);
void populateReservoir(RigCaseData* eclipseCase);
bool inputProperty( const QString& propertyName, std::vector<double>* values );
RigReservoirBuilderMock m_reservoirBuilder;
cvf::ref<RigReservoir> m_reservoir;
RigCaseData* m_reservoir;
};

View File

@ -16,7 +16,7 @@
//
/////////////////////////////////////////////////////////////////////////////////
#include "RIStdInclude.h"
#include "RiaStdInclude.h"
#include "RivCellEdgeEffectGenerator.h"
@ -33,20 +33,27 @@
#include "cvfShaderProgram.h"
#include "cvfRenderStateCullFace.h"
#include <vector>
#include <QFile>
#include <QTextStream>
#include "RimReservoirView.h"
#include "RigGridBase.h"
#include "RigMainGrid.h"
#include "RigReservoirCellResults.h"
#include "cvfTextureImage.h"
#include "cvfTexture.h"
#include "cvfSampler.h"
#include "cvfScalarMapper.h"
#include "cafEffectGenerator.h"
#include <vector>
#include <QFile>
#include <QTextStream>
#include "RimReservoirView.h"
#include "RimResultSlot.h"
#include "RigGridBase.h"
#include "RigMainGrid.h"
#include "RigCaseCellResultsData.h"
#include "RigCaseData.h"
#include "RigActiveCellInfo.h"
//--------------------------------------------------------------------------------------------------
///
@ -87,12 +94,12 @@ void RivCellEdgeGeometryGenerator::addCellEdgeResultsToDrawableGeo(
cvf::ScalarMapper* edgeResultScalarMapper = cellEdgeResultSlot->legendConfig()->scalarMapper();
const RigGridBase* grid = dynamic_cast<const RigGridBase*>(generator->activeGrid());
CVF_ASSERT(grid != NULL);
bool cellScalarResultUseGlobalActiveIndex = true;
bool edgeScalarResultUseGlobalActiveIndex[6];
RigCaseData* eclipseCase = cellResultSlot->reservoirView()->eclipseCase()->reservoirData();
CVF_ASSERT(eclipseCase != NULL);
cvf::ref<cvf::StructGridScalarDataAccess> cellCenterDataAccessObject = NULL;
if (cellResultSlot->hasResult())
{
if (!cellResultSlot->hasDynamicResult())
@ -101,23 +108,30 @@ void RivCellEdgeGeometryGenerator::addCellEdgeResultsToDrawableGeo(
timeStepIndex = 0;
}
RifReaderInterface::PorosityModelResultType porosityModel = RigReservoirCellResults::convertFromProjectModelPorosityModel(cellResultSlot->porosityModel());
cellScalarResultUseGlobalActiveIndex = grid->mainGrid()->results(porosityModel)->isUsingGlobalActiveIndex(cellResultSlot->gridScalarIndex());
RifReaderInterface::PorosityModelResultType porosityModel = RigCaseCellResultsData::convertFromProjectModelPorosityModel(cellResultSlot->porosityModel());
cellCenterDataAccessObject = eclipseCase->dataAccessObject(grid, porosityModel, timeStepIndex, cellResultSlot->gridScalarIndex());
}
CVF_ASSERT(cellEdgeResultSlot->hasResult());
size_t resultIndices[6];
cellEdgeResultSlot->gridScalarIndices(resultIndices);
if (cellEdgeResultSlot->hasResult())
cvf::Collection<cvf::StructGridScalarDataAccess> cellEdgeDataAccessObjects;
size_t cubeFaceIdx;
for (cubeFaceIdx = 0; cubeFaceIdx < 6; cubeFaceIdx++)
{
size_t cubeFaceIdx;
for (cubeFaceIdx = 0; cubeFaceIdx < 6; cubeFaceIdx++)
cvf::ref<cvf::StructGridScalarDataAccess> daObj;
if (resultIndices[cubeFaceIdx] != cvf::UNDEFINED_SIZE_T)
{
if (resultIndices[cubeFaceIdx] != cvf::UNDEFINED_SIZE_T)
{
edgeScalarResultUseGlobalActiveIndex[cubeFaceIdx] = grid->mainGrid()->results(RifReaderInterface::MATRIX_RESULTS)->isUsingGlobalActiveIndex(resultIndices[cubeFaceIdx]);
}
// Assuming static values to be mapped onto cell edge, always using time step zero
// TODO: Now hardcoded matrix results, should it be possible to use fracture results?
daObj = eclipseCase->dataAccessObject(grid, RifReaderInterface::MATRIX_RESULTS, 0, resultIndices[cubeFaceIdx]);
}
cellEdgeDataAccessObjects.push_back(daObj.p());
}
double ignoredScalarValue = cellEdgeResultSlot->ignoredScalarValue();
@ -138,15 +152,14 @@ void RivCellEdgeGeometryGenerator::addCellEdgeResultsToDrawableGeo(
float cellColorTextureCoord = 0.5f; // If no results exists, the texture will have a special color
size_t cellIndex = quadToCell[quadIdx];
size_t resultValueIndex = cellIndex;
if (cellScalarResultUseGlobalActiveIndex)
{
resultValueIndex = grid->cell(cellIndex).activeIndexInMatrixModel();
}
double scalarValue = HUGE_VAL;
if (cellCenterDataAccessObject.notNull())
{
scalarValue = cellCenterDataAccessObject->cellScalar(cellIndex);
}
{
RifReaderInterface::PorosityModelResultType porosityModel = RigReservoirCellResults::convertFromProjectModelPorosityModel(cellResultSlot->porosityModel());
double scalarValue = grid->mainGrid()->results(porosityModel)->cellScalarResult(timeStepIndex, cellResultSlot->gridScalarIndex(), resultValueIndex);
if (scalarValue != HUGE_VAL)
{
cellColorTextureCoord = cellResultScalarMapper->mapToTextureCoord(scalarValue)[0];
@ -168,14 +181,12 @@ void RivCellEdgeGeometryGenerator::addCellEdgeResultsToDrawableGeo(
{
edgeColor = -1.0f; // Undefined texture coord. Shader handles this.
resultValueIndex = cellIndex;
if (edgeScalarResultUseGlobalActiveIndex[cubeFaceIdx])
double scalarValue = HUGE_VAL;
if (cellEdgeDataAccessObjects[cubeFaceIdx].notNull())
{
resultValueIndex = grid->cell(cellIndex).activeIndexInMatrixModel();
scalarValue = cellEdgeDataAccessObjects[cubeFaceIdx]->cellScalar(cellIndex);
}
// Assuming static values to be mapped onto cell edge, always using time step zero
double scalarValue = grid->mainGrid()->results(RifReaderInterface::MATRIX_RESULTS)->cellScalarResult(0, resultIndices[cubeFaceIdx], resultValueIndex);
if (scalarValue != HUGE_VAL && scalarValue != ignoredScalarValue)
{
edgeColor = edgeResultScalarMapper->mapToTextureCoord(scalarValue)[0];

View File

@ -16,7 +16,7 @@
//
/////////////////////////////////////////////////////////////////////////////////
#include "RIStdInclude.h"
#include "RiaStdInclude.h"
#include "RivGridPartMgr.h"
#include "cvfPart.h"
#include "cafEffectGenerator.h"
@ -28,7 +28,8 @@
#include "RimResultSlot.h"
#include "RimCellEdgeResultSlot.h"
#include "RigGridScalarDataAccess.h"
#include "RigReservoirCellResults.h"
#include "RigCaseCellResultsData.h"
#include "RigCaseData.h"
//--------------------------------------------------------------------------------------------------
@ -220,8 +221,11 @@ void RivGridPartMgr::updateCellResultColor(size_t timeStepIndex, RimResultSlot*
size_t resTimeStepIdx = timeStepIndex;
if (cellResultSlot->hasStaticResult()) resTimeStepIdx = 0;
RifReaderInterface::PorosityModelResultType porosityModel = RigReservoirCellResults::convertFromProjectModelPorosityModel(cellResultSlot->porosityModel());
cvf::ref<RigGridScalarDataAccess> dataAccessObject = m_grid->dataAccessObject(porosityModel, resTimeStepIdx, scalarSetIndex);
RifReaderInterface::PorosityModelResultType porosityModel = RigCaseCellResultsData::convertFromProjectModelPorosityModel(cellResultSlot->porosityModel());
RigCaseData* eclipseCase = cellResultSlot->reservoirView()->eclipseCase()->reservoirData();
cvf::ref<cvf::StructGridScalarDataAccess> dataAccessObject = eclipseCase->dataAccessObject(m_grid.p(), porosityModel, resTimeStepIdx, scalarSetIndex);
if (dataAccessObject.isNull()) return;
// Outer surface

View File

@ -83,6 +83,7 @@ void RivPipeGeometryGenerator::setBendScalingFactor(double scaleFactor)
//--------------------------------------------------------------------------------------------------
void RivPipeGeometryGenerator::setRadius(double radius)
{
CVF_ASSERT(0 <= radius && radius < 1e100);
m_radius = radius;
clearComputedData();
@ -93,6 +94,7 @@ void RivPipeGeometryGenerator::setRadius(double radius)
//--------------------------------------------------------------------------------------------------
void RivPipeGeometryGenerator::setCrossSectionVertexCount(size_t nodeCount)
{
CVF_ASSERT( 2 < nodeCount && nodeCount < 1000000);
m_crossSectionNodeCount = nodeCount;
clearComputedData();

View File

@ -16,23 +16,23 @@
//
/////////////////////////////////////////////////////////////////////////////////
#include "RIStdInclude.h"
#include "RiaStdInclude.h"
#include "RivReservoirPartMgr.h"
#include "RivGridPartMgr.h"
#include "cvfStructGrid.h"
#include "cvfModelBasicList.h"
#include "RigReservoir.h"
#include "RigCaseData.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivReservoirPartMgr::clearAndSetReservoir(const RigReservoir* reservoir)
void RivReservoirPartMgr::clearAndSetReservoir(const RigCaseData* eclipseCase)
{
m_allGrids.clear();
if (reservoir)
if (eclipseCase)
{
std::vector<const RigGridBase*> grids;
reservoir->allGrids(&grids);
eclipseCase->allGrids(&grids);
for (size_t i = 0; i < grids.size() ; ++i)
{
m_allGrids.push_back(new RivGridPartMgr(grids[i], i) );

View File

@ -30,7 +30,7 @@ namespace cvf
class RimResultSlot;
class RimCellEdgeResultSlot;
class RivGridPartMgr;
class RigReservoir;
class RigCaseData;
//==================================================================================================
@ -43,7 +43,7 @@ class RigReservoir;
class RivReservoirPartMgr: public cvf::Object
{
public:
void clearAndSetReservoir(const RigReservoir* reservoir);
void clearAndSetReservoir(const RigCaseData* eclipseCase);
void setTransform(cvf::Transform* scaleTransform);
void setCellVisibility(size_t gridIndex, cvf::UByteArray* cellVisibilities );

View File

@ -16,7 +16,7 @@
//
/////////////////////////////////////////////////////////////////////////////////
#include "RIStdInclude.h"
#include "RiaStdInclude.h"
#include "RivReservoirPipesPartMgr.h"
#include "RimReservoirView.h"

View File

@ -16,13 +16,13 @@
//
/////////////////////////////////////////////////////////////////////////////////
#include "RIStdInclude.h"
#include "RiaStdInclude.h"
#include "RivReservoirViewPartMgr.h"
#include "RivGridPartMgr.h"
#include "RimReservoirView.h"
#include "RigReservoir.h"
#include "RigCaseData.h"
#include "RigGridBase.h"
#include "RigReservoirCellResults.h"
#include "RigCaseCellResultsData.h"
#include "RigGridScalarDataAccess.h"
//--------------------------------------------------------------------------------------------------
@ -125,10 +125,10 @@ void RivReservoirViewPartMgr::scheduleGeometryRegen(ReservoirGeometryCacheType g
//--------------------------------------------------------------------------------------------------
void RivReservoirViewPartMgr::clearGeometryCache(ReservoirGeometryCacheType geomType)
{
RigReservoir* reservoir = NULL;
RigCaseData* eclipseCase = NULL;
if (m_reservoirView != NULL && m_reservoirView->eclipseCase())
{
reservoir = m_reservoirView->eclipseCase()->reservoirData();
eclipseCase = m_reservoirView->eclipseCase()->reservoirData();
}
if (geomType == PROPERTY_FILTERED)
@ -138,7 +138,7 @@ void RivReservoirViewPartMgr::clearGeometryCache(ReservoirGeometryCacheType geom
m_propFilteredGeometryFramesNeedsRegen[i] = true;
if (m_propFilteredGeometryFrames[i].notNull())
{
m_propFilteredGeometryFrames[i]->clearAndSetReservoir(reservoir);
m_propFilteredGeometryFrames[i]->clearAndSetReservoir(eclipseCase);
m_propFilteredGeometryFrames[i]->setTransform(m_scaleTransform.p());
}
}
@ -150,7 +150,7 @@ void RivReservoirViewPartMgr::clearGeometryCache(ReservoirGeometryCacheType geom
m_propFilteredWellGeometryFramesNeedsRegen[i] = true;
if (m_propFilteredWellGeometryFrames[i].notNull())
{
m_propFilteredWellGeometryFrames[i]->clearAndSetReservoir(reservoir);
m_propFilteredWellGeometryFrames[i]->clearAndSetReservoir(eclipseCase);
m_propFilteredWellGeometryFrames[i]->setTransform(m_scaleTransform.p());
}
}
@ -158,7 +158,7 @@ void RivReservoirViewPartMgr::clearGeometryCache(ReservoirGeometryCacheType geom
else
{
m_geometriesNeedsRegen[geomType] = true;
m_geometries[geomType].clearAndSetReservoir(reservoir);
m_geometries[geomType].clearAndSetReservoir(eclipseCase);
m_geometries[geomType].setTransform(m_scaleTransform.p());
}
}
@ -224,7 +224,7 @@ void RivReservoirViewPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicL
//--------------------------------------------------------------------------------------------------
void RivReservoirViewPartMgr::createGeometry(ReservoirGeometryCacheType geometryType)
{
RigReservoir* res = m_reservoirView->eclipseCase()->reservoirData();
RigCaseData* res = m_reservoirView->eclipseCase()->reservoirData();
m_geometries[geometryType].clearAndSetReservoir(res);
m_geometries[geometryType].setTransform(m_scaleTransform.p());
std::vector<RigGridBase*> grids;
@ -246,13 +246,16 @@ void RivReservoirViewPartMgr::createGeometry(ReservoirGeometryCacheType geometry
//--------------------------------------------------------------------------------------------------
void RivReservoirViewPartMgr::computeVisibility(cvf::UByteArray* cellVisibility, ReservoirGeometryCacheType geometryType, RigGridBase* grid, size_t gridIdx)
{
RigCaseData* eclipseCase = m_reservoirView->eclipseCase()->reservoirData();
RigActiveCellInfo* activeCellInfo = m_reservoirView->currentActiveCellInfo();
switch (geometryType)
{
case ACTIVE:
computeNativeVisibility(cellVisibility, grid, false, false, true, m_reservoirView->showMainGrid() );
computeNativeVisibility(cellVisibility, grid, activeCellInfo, eclipseCase->wellCellsInGrid(gridIdx), false, false, true, m_reservoirView->showMainGrid() );
break;
case ALL_WELL_CELLS:
computeAllWellCellsVisibility(cellVisibility, grid);
copyByteArray(cellVisibility, eclipseCase->wellCellsInGrid(gridIdx));
break;
case VISIBLE_WELL_CELLS:
{
@ -287,7 +290,7 @@ void RivReservoirViewPartMgr::computeVisibility(cvf::UByteArray* cellVisibility,
}
break;
case INACTIVE:
computeNativeVisibility(cellVisibility, grid, m_reservoirView->showInvalidCells(), true, false, m_reservoirView->showMainGrid());
computeNativeVisibility(cellVisibility, grid, activeCellInfo, eclipseCase->wellCellsInGrid(gridIdx), m_reservoirView->showInvalidCells(), true, false, m_reservoirView->showMainGrid());
break;
case RANGE_FILTERED:
{
@ -367,7 +370,7 @@ void RivReservoirViewPartMgr::computeVisibility(cvf::UByteArray* cellVisibility,
//--------------------------------------------------------------------------------------------------
void RivReservoirViewPartMgr::createPropertyFilteredGeometry(size_t frameIndex)
{
RigReservoir* res = m_reservoirView->eclipseCase()->reservoirData();
RigCaseData* res = m_reservoirView->eclipseCase()->reservoirData();
if ( frameIndex >= m_propFilteredGeometryFrames.size())
{
@ -382,28 +385,29 @@ void RivReservoirViewPartMgr::createPropertyFilteredGeometry(size_t frameIndex)
bool hasActiveRangeFilters = m_reservoirView->rangeFilterCollection()->hasActiveFilters() || m_reservoirView->wellCollection()->hasVisibleWellCells();
for (size_t i = 0; i < grids.size(); ++i)
for (size_t gIdx = 0; gIdx < grids.size(); ++gIdx)
{
cvf::ref<cvf::UByteArray> cellVisibility = m_propFilteredGeometryFrames[frameIndex]->cellVisibility(i);
cvf::ref<cvf::UByteArray> cellVisibility = m_propFilteredGeometryFrames[frameIndex]->cellVisibility(gIdx);
cvf::ref<cvf::UByteArray> rangeVisibility;
cvf::ref<cvf::UByteArray> fenceVisibility;
cvf::cref<cvf::UByteArray> cellIsWellCellStatuses = res->wellCellsInGrid(gIdx);
if (m_geometriesNeedsRegen[RANGE_FILTERED]) createGeometry(RANGE_FILTERED);
if (m_geometriesNeedsRegen[VISIBLE_WELL_FENCE_CELLS_OUTSIDE_RANGE_FILTER]) createGeometry(VISIBLE_WELL_FENCE_CELLS_OUTSIDE_RANGE_FILTER);
rangeVisibility = m_geometries[RANGE_FILTERED].cellVisibility(i);
fenceVisibility = m_geometries[VISIBLE_WELL_FENCE_CELLS_OUTSIDE_RANGE_FILTER].cellVisibility(i);
rangeVisibility = m_geometries[RANGE_FILTERED].cellVisibility(gIdx);
fenceVisibility = m_geometries[VISIBLE_WELL_FENCE_CELLS_OUTSIDE_RANGE_FILTER].cellVisibility(gIdx);
cellVisibility->resize(rangeVisibility->size());
#pragma omp parallel for
for (int cellIdx = 0; cellIdx < static_cast<int>(cellVisibility->size()); ++cellIdx)
{
(*cellVisibility)[cellIdx] = (!hasActiveRangeFilters && !grids[i]->cell(cellIdx).isWellCell()) || (*rangeVisibility)[cellIdx] || (*fenceVisibility)[cellIdx];
(*cellVisibility)[cellIdx] = (!hasActiveRangeFilters && !(*cellIsWellCellStatuses)[cellIdx]) || (*rangeVisibility)[cellIdx] || (*fenceVisibility)[cellIdx];
}
computePropertyVisibility(cellVisibility.p(), grids[i], frameIndex, cellVisibility.p(), m_reservoirView->propertyFilterCollection());
computePropertyVisibility(cellVisibility.p(), grids[gIdx], frameIndex, cellVisibility.p(), m_reservoirView->propertyFilterCollection());
m_propFilteredGeometryFrames[frameIndex]->setCellVisibility(i, cellVisibility.p());
m_propFilteredGeometryFrames[frameIndex]->setCellVisibility(gIdx, cellVisibility.p());
}
m_propFilteredGeometryFramesNeedsRegen[frameIndex] = false;
@ -414,7 +418,7 @@ void RivReservoirViewPartMgr::createPropertyFilteredGeometry(size_t frameIndex)
//--------------------------------------------------------------------------------------------------
void RivReservoirViewPartMgr::createPropertyFilteredWellGeometry(size_t frameIndex)
{
RigReservoir* res = m_reservoirView->eclipseCase()->reservoirData();
RigCaseData* res = m_reservoirView->eclipseCase()->reservoirData();
if ( frameIndex >= m_propFilteredWellGeometryFrames.size())
{
@ -432,26 +436,28 @@ void RivReservoirViewPartMgr::createPropertyFilteredWellGeometry(size_t frameInd
bool hasActiveRangeFilters = m_reservoirView->rangeFilterCollection()->hasActiveFilters() || m_reservoirView->wellCollection()->hasVisibleWellCells();
for (size_t i = 0; i < grids.size(); ++i)
for (size_t gIdx = 0; gIdx < grids.size(); ++gIdx)
{
cvf::ref<cvf::UByteArray> cellVisibility = m_propFilteredWellGeometryFrames[frameIndex]->cellVisibility(i);
cvf::ref<cvf::UByteArray> cellVisibility = m_propFilteredWellGeometryFrames[frameIndex]->cellVisibility(gIdx);
cvf::ref<cvf::UByteArray> rangeVisibility;
cvf::ref<cvf::UByteArray> wellCellsOutsideVisibility;
cvf::cref<cvf::UByteArray> cellIsWellCellStatuses = res->wellCellsInGrid(gIdx);
if (m_geometriesNeedsRegen[RANGE_FILTERED_WELL_CELLS]) createGeometry(RANGE_FILTERED_WELL_CELLS);
rangeVisibility = m_geometries[RANGE_FILTERED_WELL_CELLS].cellVisibility(i);
rangeVisibility = m_geometries[RANGE_FILTERED_WELL_CELLS].cellVisibility(gIdx);
if (m_geometriesNeedsRegen[VISIBLE_WELL_CELLS_OUTSIDE_RANGE_FILTER]) createGeometry(VISIBLE_WELL_CELLS_OUTSIDE_RANGE_FILTER);
wellCellsOutsideVisibility = m_geometries[VISIBLE_WELL_CELLS_OUTSIDE_RANGE_FILTER].cellVisibility(i);
wellCellsOutsideVisibility = m_geometries[VISIBLE_WELL_CELLS_OUTSIDE_RANGE_FILTER].cellVisibility(gIdx);
cellVisibility->resize(rangeVisibility->size());
#pragma omp parallel for
for (int cellIdx = 0; cellIdx < static_cast<int>(cellVisibility->size()); ++cellIdx)
{
(*cellVisibility)[cellIdx] = (!hasActiveRangeFilters && grids[i]->cell(cellIdx).isWellCell()) || (*rangeVisibility)[cellIdx] || (*wellCellsOutsideVisibility)[cellIdx];
(*cellVisibility)[cellIdx] = (!hasActiveRangeFilters && (*cellIsWellCellStatuses)[cellIdx]) || (*rangeVisibility)[cellIdx] || (*wellCellsOutsideVisibility)[cellIdx];
}
computePropertyVisibility(cellVisibility.p(), grids[i], frameIndex, cellVisibility.p(), m_reservoirView->propertyFilterCollection());
m_propFilteredWellGeometryFrames[frameIndex]->setCellVisibility(i, cellVisibility.p());
computePropertyVisibility(cellVisibility.p(), grids[gIdx], frameIndex, cellVisibility.p(), m_reservoirView->propertyFilterCollection());
m_propFilteredWellGeometryFrames[frameIndex]->setCellVisibility(gIdx, cellVisibility.p());
}
m_propFilteredWellGeometryFramesNeedsRegen[frameIndex] = false;
@ -460,7 +466,7 @@ void RivReservoirViewPartMgr::createPropertyFilteredWellGeometry(size_t frameInd
//--------------------------------------------------------------------------------------------------
/// Evaluate visibility based on cell state
//--------------------------------------------------------------------------------------------------
void RivReservoirViewPartMgr::computeNativeVisibility(cvf::UByteArray* cellVisibility, const RigGridBase* grid,
void RivReservoirViewPartMgr::computeNativeVisibility(cvf::UByteArray* cellVisibility, const RigGridBase* grid, const RigActiveCellInfo* activeCellInfo, const cvf::UByteArray* cellIsInWellStatuses,
bool invalidCellsIsVisible,
bool inactiveCellsIsVisible,
bool activeCellsIsVisible,
@ -468,18 +474,23 @@ void RivReservoirViewPartMgr::computeNativeVisibility(cvf::UByteArray* cellVisib
{
CVF_ASSERT(cellVisibility != NULL);
CVF_ASSERT(grid != NULL);
CVF_ASSERT(activeCellInfo != NULL);
CVF_ASSERT(cellIsInWellStatuses != NULL);
CVF_ASSERT(cellIsInWellStatuses->size() >= grid->cellCount());
cellVisibility->resize(grid->cellCount());
#pragma omp parallel for
for (int cellIndex = 0; cellIndex < static_cast<int>(grid->cellCount()); cellIndex++)
{
const RigCell& cell = grid->cell(cellIndex);
size_t globalCellIndex = cell.mainGridCellIndex();
if ( !invalidCellsIsVisible && cell.isInvalid()
|| !inactiveCellsIsVisible && !cell.isActiveInMatrixModel()
|| !activeCellsIsVisible && cell.isActiveInMatrixModel()
|| !inactiveCellsIsVisible && !activeCellInfo->isActive(globalCellIndex)
|| !activeCellsIsVisible && activeCellInfo->isActive(globalCellIndex)
|| mainGridIsVisible && (cell.subGrid() != NULL)
|| cell.isWellCell()
|| (*cellIsInWellStatuses)[cellIndex]
)
{
(*cellVisibility)[cellIndex] = false;
@ -493,27 +504,23 @@ void RivReservoirViewPartMgr::computeNativeVisibility(cvf::UByteArray* cellVisib
//--------------------------------------------------------------------------------------------------
/// Evaluate Well cell visibility based on cell state
/// Copy the data from source into destination. This is not trivial to do using cvf::Array ...
/// using parallelized operator [] and not memcopy. Do not know what is faster.
//--------------------------------------------------------------------------------------------------
void RivReservoirViewPartMgr::computeAllWellCellsVisibility(cvf::UByteArray* cellVisibility, const RigGridBase* grid )
void RivReservoirViewPartMgr::copyByteArray(cvf::UByteArray* destination, const cvf::UByteArray* source )
{
CVF_ASSERT(cellVisibility != NULL);
CVF_ASSERT(grid != NULL);
cellVisibility->resize(grid->cellCount());
CVF_ASSERT(destination != NULL);
CVF_ASSERT(source != NULL);
if (destination->size() != source->size())
{
destination->resize(source->size());
}
#pragma omp parallel for
for (int cellIndex = 0; cellIndex < static_cast<int>(grid->cellCount()); cellIndex++)
for (int cellIndex = 0; cellIndex < static_cast<int>(source->size()); cellIndex++)
{
const RigCell& cell = grid->cell(cellIndex);
if ( cell.isWellCell() )
{
(*cellVisibility)[cellIndex] = true;
}
else
{
(*cellVisibility)[cellIndex] = false;
}
(*destination)[cellIndex] = (*source)[cellIndex];
}
}
@ -599,8 +606,10 @@ void RivReservoirViewPartMgr::computePropertyVisibility(cvf::UByteArray* cellVis
const RimCellFilter::FilterModeType filterType = (*pfIt)->filterMode();
RifReaderInterface::PorosityModelResultType porosityModel = RigReservoirCellResults::convertFromProjectModelPorosityModel((*pfIt)->resultDefinition()->porosityModel());
cvf::ref<RigGridScalarDataAccess> dataAccessObject = grid->dataAccessObject(porosityModel, timeStepIndex, scalarResultIndex);
RifReaderInterface::PorosityModelResultType porosityModel = RigCaseCellResultsData::convertFromProjectModelPorosityModel((*pfIt)->resultDefinition()->porosityModel());
RigCaseData* eclipseCase = propFilterColl->reservoirView()->eclipseCase()->reservoirData();
cvf::ref<cvf::StructGridScalarDataAccess> dataAccessObject = eclipseCase->dataAccessObject(grid, porosityModel, timeStepIndex, scalarResultIndex);
CVF_ASSERT(dataAccessObject.notNull());
#pragma omp parallel for schedule(dynamic)

View File

@ -28,6 +28,7 @@ class RimReservoirView;
class RigGridBase;
class RimCellRangeFilterCollection;
class RimCellPropertyFilterCollection;
class RigActiveCellInfo;
class RivReservoirViewPartMgr: public cvf::Object
{
@ -77,10 +78,10 @@ private:
void clearGeometryCache(ReservoirGeometryCacheType geomType);
static void computeNativeVisibility (cvf::UByteArray* cellVisibility, const RigGridBase* grid, bool invalidCellsIsVisible, bool inactiveCellsIsVisible, bool activeCellsIsVisible, bool mainGridIsVisible);
static void computeRangeVisibility (cvf::UByteArray* cellVisibility, const RigGridBase* grid, const cvf::UByteArray* nativeVisibility, const RimCellRangeFilterCollection* rangeFilterColl);
static void computePropertyVisibility(cvf::UByteArray* cellVisibility, const RigGridBase* grid, size_t timeStepIndex, const cvf::UByteArray* rangeFilterVisibility, RimCellPropertyFilterCollection* propFilterColl);
static void computeAllWellCellsVisibility(cvf::UByteArray* cellVisibility, const RigGridBase* grid );
static void computeNativeVisibility (cvf::UByteArray* cellVisibilities, const RigGridBase* grid, const RigActiveCellInfo* activeCellInfo, const cvf::UByteArray* cellIsInWellStatuses, bool invalidCellsIsVisible, bool inactiveCellsIsVisible, bool activeCellsIsVisible, bool mainGridIsVisible);
static void computeRangeVisibility (cvf::UByteArray* cellVisibilities, const RigGridBase* grid, const cvf::UByteArray* nativeVisibility, const RimCellRangeFilterCollection* rangeFilterColl);
static void computePropertyVisibility(cvf::UByteArray* cellVisibilities, const RigGridBase* grid, size_t timeStepIndex, const cvf::UByteArray* rangeFilterVisibility, RimCellPropertyFilterCollection* propFilterColl);
static void copyByteArray(cvf::UByteArray* cellVisibilities, const cvf::UByteArray* cellIsWellStatuses );
private:

View File

@ -36,7 +36,7 @@
#include "RimReservoirView.h"
#include "RigReservoir.h"
#include "RigCaseData.h"
#include "RigCell.h"
#include "RivPipeGeometryGenerator.h"
@ -72,11 +72,11 @@ void RivWellHeadPartMgr::buildWellHeadParts(size_t frameIndex)
if (m_rimReservoirView.isNull()) return;
RigReservoir* rigReservoir = m_rimReservoirView->eclipseCase()->reservoirData();
RigCaseData* rigReservoir = m_rimReservoirView->eclipseCase()->reservoirData();
RimWell* well = m_rimWell;
RigWellResults* wellResults = well->wellResults();
RigSingleWellResultsData* wellResults = well->wellResults();
if (wellResults->m_staticWellCells.m_wellResultBranches.size() == 0)
{
@ -90,7 +90,7 @@ void RivWellHeadPartMgr::buildWellHeadParts(size_t frameIndex)
const RigCell& whCell = rigReservoir->cellFromWellResultCell(wellResultFrame.m_wellHead);
double characteristicCellSize = rigReservoir->mainGrid()->characteristicCellSize();
double characteristicCellSize = rigReservoir->mainGrid()->characteristicIJCellSize();
// Match this position with pipe start position in RivWellPipesPartMgr::calculateWellPipeCenterline()
cvf::Vec3d whStartPos = whCell.faceCenter(cvf::StructGridInterface::NEG_K);

View File

@ -19,8 +19,8 @@
#include "cvfLibCore.h"
#include "RimReservoir.h"
#include "RigReservoir.h"
#include "RimCase.h"
#include "RigCaseData.h"
#include "RivWellPipesPartMgr.h"
#include "RigCell.h"
#include "RivPipeGeometryGenerator.h"
@ -86,7 +86,7 @@ void RivWellPipesPartMgr::buildWellPipeParts()
calculateWellPipeCenterline(pipeBranchesCLCoords, pipeBranchesCellIds);
double characteristicCellSize = m_rimReservoirView->eclipseCase()->reservoirData()->mainGrid()->characteristicCellSize();
double characteristicCellSize = m_rimReservoirView->eclipseCase()->reservoirData()->mainGrid()->characteristicIJCellSize();
double pipeRadius = m_rimReservoirView->wellCollection()->pipeRadiusScaleFactor() *m_rimWell->pipeRadiusScaleFactor() * characteristicCellSize;
for (size_t brIdx = 0; brIdx < pipeBranchesCellIds.size(); ++brIdx)
@ -158,8 +158,8 @@ void RivWellPipesPartMgr::calculateWellPipeCenterline( std::vector< std::vector
bool isAutoDetectBranches = m_rimReservoirView->wellCollection()->isAutoDetectingBranches();
RigReservoir* rigReservoir = m_rimReservoirView->eclipseCase()->reservoirData();
RigWellResults* wellResults = m_rimWell->wellResults();
RigCaseData* rigReservoir = m_rimReservoirView->eclipseCase()->reservoirData();
RigSingleWellResultsData* wellResults = m_rimWell->wellResults();
const RigWellResultFrame& staticWellFrame = m_rimWell->wellResults()->m_staticWellCells;
@ -357,7 +357,7 @@ void RivWellPipesPartMgr::updatePipeResultColor(size_t frameIndex)
{
if (m_rimWell == NULL) return;
RigWellResults* wRes = m_rimWell->wellResults();
RigSingleWellResultsData* wRes = m_rimWell->wellResults();
if (wRes == NULL) return;
if (frameIndex < wRes->firstResultTimeStep()) return; // Or reset colors or something

View File

@ -20,7 +20,7 @@
#include "cafPdmPointer.h"
#include <list>
#include "RigWellResults.h"
#include "RigSingleWellResultsData.h"
namespace cvf
{

View File

@ -16,15 +16,15 @@
//
/////////////////////////////////////////////////////////////////////////////////
#include "RIStdInclude.h"
#include "RiaStdInclude.h"
#include "Rim3dOverlayInfoConfig.h"
#include "RimReservoirView.h"
#include "RIViewer.h"
#include "RimReservoir.h"
#include "RigReservoir.h"
#include "RiuViewer.h"
#include "RimCase.h"
#include "RigCaseData.h"
#include "RigMainGrid.h"
#include "RigReservoirCellResults.h"
#include "RigCaseCellResultsData.h"
CAF_PDM_SOURCE_INIT(Rim3dOverlayInfoConfig, "View3dOverlayInfoConfig");
@ -70,7 +70,8 @@ void Rim3dOverlayInfoConfig::setPosition(cvf::Vec2ui position)
//--------------------------------------------------------------------------------------------------
void Rim3dOverlayInfoConfig::update3DInfo()
{
if (!m_reservoirView && m_reservoirView->viewer()) return;
if (!m_reservoirView) return;
if (!m_reservoirView->viewer()) return;
m_reservoirView->viewer()->showInfoText(showInfoText());
m_reservoirView->viewer()->showHistogram(false);
@ -80,16 +81,22 @@ void Rim3dOverlayInfoConfig::update3DInfo()
{
QString caseName;
QString totCellCount;
QString activeCellCount;
QString activeCellCountText;
QString fractureActiveCellCount;
QString iSize, jSize, kSize;
QString propName;
QString cellEdgeName;
if (m_reservoirView->eclipseCase() && m_reservoirView->eclipseCase()->reservoirData())
if (m_reservoirView->eclipseCase() && m_reservoirView->eclipseCase()->reservoirData() && m_reservoirView->eclipseCase()->reservoirData()->mainGrid())
{
caseName = m_reservoirView->eclipseCase()->caseName();
totCellCount = QString::number(m_reservoirView->eclipseCase()->reservoirData()->mainGrid()->cells().size());
activeCellCount = QString::number(m_reservoirView->eclipseCase()->reservoirData()->mainGrid()->globalMatrixModelActiveCellCount());
size_t mxActCellCount = m_reservoirView->eclipseCase()->reservoirData()->activeCellInfo(RifReaderInterface::MATRIX_RESULTS)->globalActiveCellCount();
size_t frActCellCount = m_reservoirView->eclipseCase()->reservoirData()->activeCellInfo(RifReaderInterface::FRACTURE_RESULTS)->globalActiveCellCount();
if (frActCellCount > 0) activeCellCountText += "Matrix : ";
activeCellCountText += QString::number(mxActCellCount);
if (frActCellCount > 0) activeCellCountText += " Fracture : " + QString::number(frActCellCount);
iSize = QString::number(m_reservoirView->eclipseCase()->reservoirData()->mainGrid()->cellCountI());
jSize = QString::number(m_reservoirView->eclipseCase()->reservoirData()->mainGrid()->cellCountJ());
kSize = QString::number(m_reservoirView->eclipseCase()->reservoirData()->mainGrid()->cellCountK());
@ -100,7 +107,7 @@ void Rim3dOverlayInfoConfig::update3DInfo()
QString infoText = QString(
"<p><b><center>-- %1 --</center></b><p> "
"<b>Cell count. Total:</b> %2 <b>Active:</b> %3 <br>"
"<b>Main Grid I,J,K:</b> %4, %5, %6 <br>").arg(caseName, totCellCount, activeCellCount, iSize, jSize, kSize);
"<b>Main Grid I,J,K:</b> %4, %5, %6 <br>").arg(caseName, totCellCount, activeCellCountText, iSize, jSize, kSize);
if (m_reservoirView->animationMode() && m_reservoirView->cellResult()->hasResult())
{
@ -110,9 +117,9 @@ void Rim3dOverlayInfoConfig::update3DInfo()
double p10, p90;
double mean;
size_t scalarIndex = m_reservoirView->cellResult()->gridScalarIndex();
m_reservoirView->gridCellResults()->minMaxCellScalarValues(scalarIndex, min, max);
m_reservoirView->gridCellResults()->p10p90CellScalarValues(scalarIndex, p10, p90);
m_reservoirView->gridCellResults()->meanCellScalarValues(scalarIndex, mean);
m_reservoirView->currentGridCellResults()->cellResults()->minMaxCellScalarValues(scalarIndex, min, max);
m_reservoirView->currentGridCellResults()->cellResults()->p10p90CellScalarValues(scalarIndex, p10, p90);
m_reservoirView->currentGridCellResults()->cellResults()->meanCellScalarValues(scalarIndex, mean);
//infoText += QString("<blockquote><b>Min:</b> %1 <b>P10:</b> %2 <b>Mean:</b> %3 <b>P90:</b> %4 <b>Max:</b> %5 </blockquote>").arg(min).arg(p10).arg(mean).arg(p90).arg(max);
//infoText += QString("<blockquote><pre>Min: %1 P10: %2 Mean: %3 \n P90: %4 Max: %5 </pre></blockquote>").arg(min).arg(p10).arg(mean).arg(p90).arg(max);
@ -134,7 +141,7 @@ void Rim3dOverlayInfoConfig::update3DInfo()
|| m_reservoirView->wellCollection()->hasVisibleWellPipes())
{
int currentTimeStep = m_reservoirView->currentTimeStep();
QDateTime date = m_reservoirView->gridCellResults()->timeStepDate(0, currentTimeStep);
QDateTime date = m_reservoirView->currentGridCellResults()->cellResults()->timeStepDate(0, currentTimeStep);
infoText += QString("<b>Time Step:</b> %1 <b>Time:</b> %2").arg(currentTimeStep).arg(date.toString("dd.MMM yyyy"));
}
@ -150,12 +157,12 @@ void Rim3dOverlayInfoConfig::update3DInfo()
double mean;
size_t scalarIndex = m_reservoirView->cellResult()->gridScalarIndex();
m_reservoirView->gridCellResults()->minMaxCellScalarValues(scalarIndex, min, max);
m_reservoirView->gridCellResults()->p10p90CellScalarValues(scalarIndex, p10, p90);
m_reservoirView->gridCellResults()->meanCellScalarValues(scalarIndex, mean);
m_reservoirView->currentGridCellResults()->cellResults()->minMaxCellScalarValues(scalarIndex, min, max);
m_reservoirView->currentGridCellResults()->cellResults()->p10p90CellScalarValues(scalarIndex, p10, p90);
m_reservoirView->currentGridCellResults()->cellResults()->meanCellScalarValues(scalarIndex, mean);
m_reservoirView->viewer()->showHistogram(true);
m_reservoirView->viewer()->setHistogram(min, max, m_reservoirView->gridCellResults()->cellScalarValuesHistogram(scalarIndex));
m_reservoirView->viewer()->setHistogram(min, max, m_reservoirView->currentGridCellResults()->cellResults()->cellScalarValuesHistogram(scalarIndex));
m_reservoirView->viewer()->setHistogramPercentiles(p10, p90, mean);
}
}

View File

@ -16,7 +16,7 @@
//
/////////////////////////////////////////////////////////////////////////////////
#include "RIStdInclude.h"
#include "RiaStdInclude.h"
#include "RimBinaryExportSettings.h"
#include "cafPdmUiFilePathEditor.h"

View File

@ -16,7 +16,7 @@
//
/////////////////////////////////////////////////////////////////////////////////
#include "RIStdInclude.h"
#include "RiaStdInclude.h"
#include "cafPdmField.h"
@ -35,6 +35,7 @@ RimCalcScript::RimCalcScript()
CAF_PDM_InitField(&absolutePath, "AbsolutePath", QString(), "Location", "", "" ,"");
CAF_PDM_InitField(&content, "Content", QString(), "Directory", "", "" ,"");
content.setUiHidden(true);
content.setIOWritable(false);
absolutePath.setUiEditorTypeName(caf::PdmUiFilePathEditor::uiEditorTypeName());
}

View File

@ -16,60 +16,84 @@
//
/////////////////////////////////////////////////////////////////////////////////
#include "RIStdInclude.h"
#include "RiaStdInclude.h"
#include "RifReaderEclipseOutput.h"
#include "RifReaderMockModel.h"
#include "RimReservoir.h"
#include "RimCase.h"
#include "RimReservoirView.h"
#include "RigReservoir.h"
#include "RigCaseData.h"
#include "RigMainGrid.h"
#include "RigReservoirCellResults.h"
#include "RigCaseCellResultsData.h"
#include "cvfAssert.h"
#include "cafPdmUiPushButtonEditor.h"
#include <QString>
#include "RimProject.h"
#include "RimReservoirCellResultsCacher.h"
//--------------------------------------------------------------------------------------------------
CAF_PDM_SOURCE_INIT(RimCase, "RimReservoir");
//------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimReservoir::RimReservoir()
RimCase::RimCase()
{
m_rigReservoir = NULL;
CAF_PDM_InitField(&caseName, "CaseName", QString(), "Case name", "", "" ,"");
// CAF_PDM_InitField(&releaseResultMemory, "ReleaseResultMemory", true, "Release result memory", "", "" ,"");
// releaseResultMemory.setIOReadable(false);
// releaseResultMemory.setIOWritable(false);
// releaseResultMemory.setUiEditorTypeName(caf::PdmUiPushButtonEditor::uiEditorTypeName());
CAF_PDM_InitFieldNoDefault(&reservoirViews, "ReservoirViews", "", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_matrixModelResults, "MatrixModelResults", "", "", "", "");
m_matrixModelResults.setUiHidden(true);
CAF_PDM_InitFieldNoDefault(&m_fractureModelResults, "FractureModelResults", "", "", "", "");
m_fractureModelResults.setUiHidden(true);
m_matrixModelResults = new RimReservoirCellResultsStorage;
m_fractureModelResults = new RimReservoirCellResultsStorage;
this->setReservoirData( NULL );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigReservoir* RimReservoir::reservoirData()
RimCase::~RimCase()
{
return m_rigReservoir.p();
reservoirViews.deleteAllChildObjects();
delete m_matrixModelResults();
delete m_fractureModelResults();
if (this->reservoirData())
{
// At this point, we assume that memory should be released
CVF_ASSERT(this->reservoirData()->refCount() == 1);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigCaseData* RimCase::reservoirData()
{
return m_rigEclipseCase.p();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const RigReservoir* RimReservoir::reservoirData() const
const RigCaseData* RimCase::reservoirData() const
{
return m_rigReservoir.p();
return m_rigEclipseCase.p();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimReservoir::initAfterRead()
void RimCase::initAfterRead()
{
size_t j;
for (j = 0; j < reservoirViews().size(); j++)
@ -84,16 +108,19 @@ void RimReservoir::initAfterRead()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimReservoir::~RimReservoir()
RimReservoirView* RimCase::createAndAddReservoirView()
{
reservoirViews.deleteAllChildObjects();
}
// 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)
{
if (this->reservoirData())
{
CVF_ASSERT(this->reservoirData()->refCount() == 1);
}
this->setReservoirData( NULL );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimReservoirView* RimReservoir::createAndAddReservoirView()
{
RimReservoirView* riv = new RimReservoirView();
riv->setEclipseCase(this);
@ -108,7 +135,7 @@ RimReservoirView* RimReservoir::createAndAddReservoirView()
//--------------------------------------------------------------------------------------------------
/// TODO: Move this functionality to PdmPointersField
//--------------------------------------------------------------------------------------------------
void RimReservoir::removeReservoirView(RimReservoirView* reservoirView)
void RimCase::removeReservoirView(RimReservoirView* reservoirView)
{
std::vector<size_t> indices;
@ -132,7 +159,7 @@ void RimReservoir::removeReservoirView(RimReservoirView* reservoirView)
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimReservoir::removeResult(const QString& resultName)
void RimCase::removeResult(const QString& resultName)
{
size_t i;
for (i = 0; i < reservoirViews().size(); i++)
@ -183,11 +210,11 @@ void RimReservoir::removeResult(const QString& resultName)
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimReservoir::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
void RimCase::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
{
if (changedField == &releaseResultMemory)
{
if (m_rigReservoir.notNull())
if (this->reservoirData())
{
for (size_t i = 0; i < reservoirViews().size(); i++)
{
@ -209,13 +236,13 @@ void RimReservoir::fieldChangedByUi(const caf::PdmFieldHandle* changedField, con
reservoirView->createDisplayModelAndRedraw();
}
RigReservoirCellResults* matrixModelResults = m_rigReservoir->mainGrid()->results(RifReaderInterface::MATRIX_RESULTS);
RigCaseCellResultsData* matrixModelResults = reservoirData()->results(RifReaderInterface::MATRIX_RESULTS);
if (matrixModelResults)
{
matrixModelResults->clearAllResults();
}
RigReservoirCellResults* fractureModelResults = m_rigReservoir->mainGrid()->results(RifReaderInterface::FRACTURE_RESULTS);
RigCaseCellResultsData* fractureModelResults = reservoirData()->results(RifReaderInterface::FRACTURE_RESULTS);
if (fractureModelResults)
{
fractureModelResults->clearAllResults();
@ -226,3 +253,78 @@ void RimReservoir::fieldChangedByUi(const caf::PdmFieldHandle* changedField, con
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimCase::computeCachedData()
{
RigCaseData* rigEclipseCase = reservoirData();
if (rigEclipseCase)
{
rigEclipseCase->computeActiveCellBoundingBoxes();
rigEclipseCase->mainGrid()->computeCachedData();
std::vector<RigGridBase*> grids;
rigEclipseCase->allGrids(&grids);
size_t i;
for (i = 0; i < grids.size(); i++)
{
grids[i]->computeFaults();
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimCaseCollection* RimCase::parentCaseCollection()
{
std::vector<RimCaseCollection*> parentObjects;
this->parentObjectsOfType(parentObjects);
if (parentObjects.size() > 0)
{
return parentObjects[0];
}
return NULL;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimCase::setReservoirData(RigCaseData* eclipseCase)
{
m_rigEclipseCase = eclipseCase;
if (this->reservoirData())
{
m_fractureModelResults()->setCellResults(reservoirData()->results(RifReaderInterface::FRACTURE_RESULTS));
m_matrixModelResults()->setCellResults(reservoirData()->results(RifReaderInterface::MATRIX_RESULTS));
m_fractureModelResults()->setMainGrid(this->reservoirData()->mainGrid());
m_matrixModelResults()->setMainGrid(this->reservoirData()->mainGrid());
}
else
{
m_fractureModelResults()->setCellResults(NULL);
m_matrixModelResults()->setCellResults(NULL);
m_fractureModelResults()->setMainGrid(NULL);
m_matrixModelResults()->setMainGrid(NULL);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimReservoirCellResultsStorage* RimCase::results(RifReaderInterface::PorosityModelResultType porosityModel)
{
if (porosityModel == RifReaderInterface::MATRIX_RESULTS)
{
return m_matrixModelResults();
}
return m_fractureModelResults();
}

View File

@ -0,0 +1,89 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cvfBase.h"
#include "cvfObject.h"
#include "cafPdmField.h"
#include "cafPdmObject.h"
#include "RimReservoirCellResultsCacher.h"
#include "RifReaderInterface.h"
class QString;
class RigCaseData;
class RigGridBase;
class RimReservoirView;
class RimCaseCollection;
//class RimReservoirCellResultsCacher;
//==================================================================================================
//
// Interface for reservoirs.
//
//==================================================================================================
class RimCase : public caf::PdmObject
{
CAF_PDM_HEADER_INIT;
public:
RimCase();
virtual ~RimCase();
// Fields:
caf::PdmField<QString> caseName;
caf::PdmField<bool> releaseResultMemory;
caf::PdmPointersField<RimReservoirView*> reservoirViews;
virtual bool openEclipseGridFile() { return false;}; // Should be pure virtual but PDM does not allow that.
RigCaseData* reservoirData();
const RigCaseData* reservoirData() const;
RimReservoirCellResultsStorage* results(RifReaderInterface::PorosityModelResultType porosityModel);
RimReservoirView* createAndAddReservoirView();
void removeReservoirView(RimReservoirView* reservoirView);
void removeResult(const QString& resultName);
virtual QString locationOnDisc() const { return QString(); }
RimCaseCollection* parentCaseCollection();
// Overridden methods from PdmObject
public:
virtual caf::PdmFieldHandle* userDescriptionField() { return &caseName; }
protected:
virtual void initAfterRead();
virtual void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue );
// Internal methods
protected:
void computeCachedData();
void setReservoirData(RigCaseData* eclipseCase);
private:
cvf::ref<RigCaseData> m_rigEclipseCase;
private:
caf::PdmField<RimReservoirCellResultsStorage*> m_matrixModelResults;
caf::PdmField<RimReservoirCellResultsStorage*> m_fractureModelResults;
};

View File

@ -0,0 +1,61 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RiaStdInclude.h"
#include "RimCaseCollection.h"
#include "RimReservoirView.h"
#include "RimIdenticalGridCaseGroup.h"
CAF_PDM_SOURCE_INIT(RimCaseCollection, "RimCaseCollection");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimCaseCollection::RimCaseCollection()
{
CAF_PDM_InitObject("Derived Statistics", "", "", "");
CAF_PDM_InitFieldNoDefault(&reservoirs, "Reservoirs", "", "", "", "");
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimCaseCollection::~RimCaseCollection()
{
reservoirs.deleteAllChildObjects();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimIdenticalGridCaseGroup* RimCaseCollection::parentCaseGroup()
{
std::vector<RimIdenticalGridCaseGroup*> parentObjects;
this->parentObjectsOfType(parentObjects);
if (parentObjects.size() > 0)
{
return parentObjects[0];
}
return NULL;
}

View File

@ -0,0 +1,48 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cvfBase.h"
#include "cvfObject.h"
#include "cafPdmField.h"
#include "cafPdmObject.h"
#include "RimStatisticsCase.h"
//==================================================================================================
//
//
//
//==================================================================================================
class RimCaseCollection : public caf::PdmObject
{
CAF_PDM_HEADER_INIT;
public:
RimCaseCollection();
virtual ~RimCaseCollection();
caf::PdmPointersField<RimCase*> reservoirs;
RimIdenticalGridCaseGroup* parentCaseGroup();
private:
};

View File

@ -16,15 +16,15 @@
//
/////////////////////////////////////////////////////////////////////////////////
#include "RIStdInclude.h"
#include "RiaStdInclude.h"
#include "RimCellEdgeResultSlot.h"
#include "RimLegendConfig.h"
#include "RimReservoirView.h"
#include "RimReservoir.h"
#include "RimCase.h"
#include "RimReservoirView.h"
#include "RigReservoirCellResults.h"
#include "RigReservoir.h"
#include "RigCaseCellResultsData.h"
#include "RigCaseData.h"
#include "cafPdmUiListEditor.h"
@ -71,7 +71,7 @@ void RimCellEdgeResultSlot::setReservoirView(RimReservoirView* ownerReservoirVie
//--------------------------------------------------------------------------------------------------
void RimCellEdgeResultSlot::loadResult()
{
CVF_ASSERT(m_reservoirView && m_reservoirView->gridCellResults());
CVF_ASSERT(m_reservoirView && m_reservoirView->currentGridCellResults());
resetResultIndices();
QStringList vars = findResultVariableNames();
@ -80,7 +80,7 @@ void RimCellEdgeResultSlot::loadResult()
int i;
for (i = 0; i < vars.size(); ++i)
{
size_t resultindex = m_reservoirView->gridCellResults()->findOrLoadScalarResult(RimDefines::STATIC_NATIVE, vars[i]);
size_t resultindex = m_reservoirView->currentGridCellResults()->findOrLoadScalarResult(RimDefines::STATIC_NATIVE, vars[i]);
int cubeFaceIdx;
for (cubeFaceIdx = 0; cubeFaceIdx < 6; ++cubeFaceIdx)
{
@ -130,10 +130,10 @@ QList<caf::PdmOptionItemInfo> RimCellEdgeResultSlot::calculateValueOptions(const
{
if (fieldNeedingOptions == &resultVariable)
{
if (m_reservoirView && m_reservoirView->gridCellResults())
if (m_reservoirView && m_reservoirView->currentGridCellResults())
{
QStringList varList;
varList = m_reservoirView->gridCellResults()->resultNames(RimDefines::STATIC_NATIVE);
varList = m_reservoirView->currentGridCellResults()->cellResults()->resultNames(RimDefines::STATIC_NATIVE);
//TODO: Must also handle input properties
//varList += m_reservoirView->gridCellResults()->resultNames(RimDefines::INPUT_PROPERTY);
@ -205,10 +205,10 @@ QStringList RimCellEdgeResultSlot::findResultVariableNames()
{
QStringList varNames;
if (m_reservoirView && m_reservoirView->gridCellResults() && !resultVariable().isEmpty())
if (m_reservoirView && m_reservoirView->currentGridCellResults() && !resultVariable().isEmpty())
{
QStringList varList;
varList = m_reservoirView->gridCellResults()->resultNames(RimDefines::STATIC_NATIVE);
varList = m_reservoirView->currentGridCellResults()->cellResults()->resultNames(RimDefines::STATIC_NATIVE);
//TODO: Must handle Input properties
int i;
@ -313,7 +313,7 @@ void RimCellEdgeResultSlot::minMaxCellEdgeValues(double& min, double& max)
{
double cMin, cMax;
m_reservoirView->gridCellResults()->minMaxCellScalarValues(resultIndices[idx], cMin, cMax);
m_reservoirView->currentGridCellResults()->cellResults()->minMaxCellScalarValues(resultIndices[idx], cMin, cMax);
globalMin = CVF_MIN(globalMin, cMin);
globalMax = CVF_MAX(globalMax, cMax);

View File

@ -23,7 +23,7 @@
#include "cafAppEnum.h"
#include "RimDefines.h"
class RigReservoirCellResults;
class RigCaseCellResultsData;
namespace caf
{

View File

@ -16,7 +16,7 @@
//
/////////////////////////////////////////////////////////////////////////////////
#include "RIStdInclude.h"
#include "RiaStdInclude.h"
#include "cafAppEnum.h"

View File

@ -16,13 +16,13 @@
//
/////////////////////////////////////////////////////////////////////////////////
#include "RIStdInclude.h"
#include "RiaStdInclude.h"
#include "RimReservoirView.h"
#include "RimCellPropertyFilter.h"
#include "RimCellPropertyFilterCollection.h"
#include "RigGridBase.h"
#include "RigReservoirCellResults.h"
#include "RigCaseCellResultsData.h"
#include "cafPdmUiDoubleSliderEditor.h"
@ -143,10 +143,10 @@ void RimCellPropertyFilter::setDefaultValues()
size_t scalarIndex = resultDefinition->gridScalarIndex();
if (scalarIndex != cvf::UNDEFINED_SIZE_T)
{
RigReservoirCellResults* results = m_parentContainer->reservoirView()->gridCellResults();
RimReservoirCellResultsStorage* results = m_parentContainer->reservoirView()->currentGridCellResults();
if (results)
{
results->minMaxCellScalarValues(scalarIndex, min, max);
results->cellResults()->minMaxCellScalarValues(scalarIndex, min, max);
}
}

View File

@ -32,7 +32,7 @@ class RimCellPropertyFilterCollection;
class RimResultDefinition;
class RigGridBase;
class RigReservoirCellResults;
class RigCaseCellResultsData;
namespace cvf
{

View File

@ -16,13 +16,13 @@
//
/////////////////////////////////////////////////////////////////////////////////
#include "RIStdInclude.h"
#include "RiaStdInclude.h"
#include "RimCellPropertyFilterCollection.h"
#include "RimReservoirView.h"
#include "RigGridBase.h"
#include "RigReservoirCellResults.h"
#include "RigCaseCellResultsData.h"
CAF_PDM_SOURCE_INIT(RimCellPropertyFilterCollection, "CellPropertyFilters");

View File

@ -16,12 +16,12 @@
//
/////////////////////////////////////////////////////////////////////////////////
#include "RIStdInclude.h"
#include "RiaStdInclude.h"
#include "RimCellRangeFilter.h"
#include "RimCellRangeFilterCollection.h"
#include "RimReservoirView.h"
#include "RigReservoir.h"
#include "RigCaseData.h"
#include "cafPdmUiSliderEditor.h"
@ -115,11 +115,11 @@ void RimCellRangeFilter::setDefaultValues()
{
CVF_ASSERT(m_parentContainer);
RigMainGrid* mainGrid = m_parentContainer->mainGrid();
if (mainGrid)
RigActiveCellInfo* actCellInfo = m_parentContainer->activeCellInfo();
if (actCellInfo)
{
cvf::Vec3st min, max;
mainGrid->matrixModelActiveCellsBoundingBox(min, max);
actCellInfo->IJKBoundingBox(min, max);
// Adjust to Eclipse indexing
min.x() = min.x() + 1;
@ -159,10 +159,13 @@ void RimCellRangeFilter::defineEditorAttribute(const caf::PdmFieldHandle* field,
}
RigMainGrid* mainGrid = m_parentContainer->mainGrid();
if (mainGrid)
CVF_ASSERT(mainGrid);
RigActiveCellInfo* actCellInfo = m_parentContainer->activeCellInfo();
if (actCellInfo)
{
cvf::Vec3st min, max;
mainGrid->matrixModelActiveCellsBoundingBox(min, max);
actCellInfo->IJKBoundingBox(min, max);
// Adjust to Eclipse indexing
min.x() = min.x() + 1;

View File

@ -16,12 +16,12 @@
//
/////////////////////////////////////////////////////////////////////////////////
#include "RIStdInclude.h"
#include "RiaStdInclude.h"
#include "RimCellRangeFilterCollection.h"
#include "RimReservoirView.h"
#include "RigReservoir.h"
#include "RigCaseData.h"
@ -97,8 +97,6 @@ void RimCellRangeFilterCollection::compoundCellRangeFilter(cvf::CellRangeFilter*
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -126,9 +124,21 @@ RigMainGrid* RimCellRangeFilterCollection::mainGrid() const
m_reservoirView->eclipseCase()->reservoirData()->mainGrid())
{
RigMainGrid* mainGrid = m_reservoirView->eclipseCase()->reservoirData()->mainGrid();
return m_reservoirView->eclipseCase()->reservoirData()->mainGrid();
}
return mainGrid;
return NULL;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigActiveCellInfo* RimCellRangeFilterCollection::activeCellInfo() const
{
if (m_reservoirView )
{
return m_reservoirView->currentActiveCellInfo();
}
return NULL;
@ -209,3 +219,4 @@ bool RimCellRangeFilterCollection::hasActiveFilters() const
return false;
}

View File

@ -20,6 +20,8 @@
#include "RimCellRangeFilter.h"
class RigActiveCellInfo;
//==================================================================================================
///
///
@ -42,9 +44,10 @@ public:
void compoundCellRangeFilter(cvf::CellRangeFilter* cellRangeFilter) const;
bool hasActiveFilters() const;
void setReservoirView(RimReservoirView* reservoirView);
RimReservoirView* reservoirView();
RigMainGrid* mainGrid() const;
void setReservoirView(RimReservoirView* reservoirView);
RimReservoirView* reservoirView();
RigMainGrid* mainGrid() const;
RigActiveCellInfo* activeCellInfo() const;
// Overridden methods
virtual void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue );

View File

@ -16,7 +16,7 @@
//
/////////////////////////////////////////////////////////////////////////////////
#include "RIStdInclude.h"
#include "RiaStdInclude.h"
#include "RimDefines.h"
#include "cafAppEnum.h"

View File

@ -16,7 +16,7 @@
//
/////////////////////////////////////////////////////////////////////////////////
#include "RIStdInclude.h"
#include "RiaStdInclude.h"
#include "RimExportInputPropertySettings.h"
#include "cafPdmUiFilePathEditor.h"

View File

@ -0,0 +1,407 @@
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RiaStdInclude.h"
#include "RimIdenticalGridCaseGroup.h"
#include "RimCase.h"
#include "RimReservoirView.h"
#include "RigCaseData.h"
#include "RigCaseCellResultsData.h"
#include "RimStatisticsCase.h"
#include "RimStatisticsCaseCollection.h"
#include "RimResultCase.h"
#include "cafProgressInfo.h"
#include "RigActiveCellInfo.h"
CAF_PDM_SOURCE_INIT(RimIdenticalGridCaseGroup, "RimIdenticalGridCaseGroup");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimIdenticalGridCaseGroup::RimIdenticalGridCaseGroup()
{
CAF_PDM_InitObject("Grid Case Group", ":/GridCaseGroup16x16.png", "", "");
CAF_PDM_InitField(&name, "UserDescription", QString("Grid Case Group"), "Name", "", "", "");
CAF_PDM_InitFieldNoDefault(&statisticsCaseCollection, "StatisticsCaseCollection", "Derived Statistics", ":/Histograms16x16.png", "", "");
CAF_PDM_InitFieldNoDefault(&caseCollection, "CaseCollection", "Cases", ":/Cases16x16.png", "", "");
caseCollection = new RimCaseCollection;
statisticsCaseCollection = new RimCaseCollection;
m_mainGrid = NULL;
m_unionOfMatrixActiveCells = new RigActiveCellInfo;
m_unionOfFractureActiveCells = new RigActiveCellInfo;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimIdenticalGridCaseGroup::~RimIdenticalGridCaseGroup()
{
m_mainGrid = NULL;
delete caseCollection;
caseCollection = NULL;
delete statisticsCaseCollection;
statisticsCaseCollection = NULL;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimIdenticalGridCaseGroup::addCase(RimCase* reservoir)
{
CVF_ASSERT(reservoir);
if (!reservoir) return;
RigMainGrid* incomingMainGrid = reservoir->reservoirData()->mainGrid();
if (!m_mainGrid)
{
m_mainGrid = incomingMainGrid;
}
CVF_ASSERT(m_mainGrid == incomingMainGrid);
caseCollection()->reservoirs().push_back(reservoir);
if (statisticsCaseCollection->reservoirs().size() == 0)
{
createAndAppendStatisticsCase();
}
clearActiveCellUnions();
clearStatisticsResults();
updateMainGridAndActiveCellsForStatisticsCases();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimIdenticalGridCaseGroup::removeCase(RimCase* reservoir)
{
caseCollection()->reservoirs().removeChildObject(reservoir);
if (caseCollection()->reservoirs().size() == 0)
{
m_mainGrid = NULL;
}
clearActiveCellUnions();
clearStatisticsResults();
updateMainGridAndActiveCellsForStatisticsCases();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigMainGrid* RimIdenticalGridCaseGroup::mainGrid()
{
if (m_mainGrid) return m_mainGrid;
return NULL;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::PdmFieldHandle* RimIdenticalGridCaseGroup::userDescriptionField()
{
return &name;
}
//--------------------------------------------------------------------------------------------------
/// Make sure changes in this functions is validated to RiaApplication::addEclipseCases()
//--------------------------------------------------------------------------------------------------
void RimIdenticalGridCaseGroup::loadMainCaseAndActiveCellInfo()
{
if (caseCollection()->reservoirs().size() == 0)
{
return;
}
// Read the main case completely including grid.
// The mainGrid from the first case is reused directly in for the other cases.
// When reading active cell info, only the total cell count is tested for consistency
RimCase* mainCase = caseCollection()->reservoirs[0];
mainCase->openEclipseGridFile();
RigCaseData* mainEclipseCase = mainCase->reservoirData();
CVF_ASSERT(mainEclipseCase);
// Read active cell info from all source cases
caf::ProgressInfo info(caseCollection()->reservoirs.size(), "Case group - Reading Active Cell data");
for (size_t i = 1; i < caseCollection()->reservoirs.size(); i++)
{
RimResultCase* rimReservoir = dynamic_cast<RimResultCase*>(caseCollection()->reservoirs[i]);
if(!rimReservoir) continue; // Input reservoir
if (!rimReservoir->openAndReadActiveCellData(mainEclipseCase))
{
CVF_ASSERT(false);
}
info.incrementProgress();
}
m_mainGrid = mainEclipseCase->mainGrid();
// Check if we need to calculate the union of the active cells
bool foundResultsInCache = false;
for (size_t i = 0; i < statisticsCaseCollection()->reservoirs.size(); i++)
{
RimCase* rimReservoir = statisticsCaseCollection()->reservoirs[i];
// Check if any results are stored in cache
if (rimReservoir->results(RifReaderInterface::MATRIX_RESULTS)->storedResultsCount() > 0 ||
rimReservoir->results(RifReaderInterface::FRACTURE_RESULTS)->storedResultsCount() > 0)
{
foundResultsInCache = true;
break;
}
}
if (foundResultsInCache)
{
computeUnionOfActiveCells();
}
// "Load" the statistical cases
for (size_t i = 0; i < statisticsCaseCollection()->reservoirs.size(); i++)
{
RimCase* rimReservoir = statisticsCaseCollection()->reservoirs[i];
rimReservoir->openEclipseGridFile();
if (i == 0)
{
rimReservoir->reservoirData()->computeActiveCellBoundingBoxes();
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimIdenticalGridCaseGroup::computeUnionOfActiveCells()
{
if (m_unionOfMatrixActiveCells->globalActiveCellCount() > 0)
{
return;
}
if (caseCollection->reservoirs.size() == 0 || !m_mainGrid)
{
this->clearActiveCellUnions();
return;
}
m_unionOfMatrixActiveCells->setGlobalCellCount(m_mainGrid->cells().size());
m_unionOfFractureActiveCells->setGlobalCellCount(m_mainGrid->cells().size());
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);
for (size_t localGridCellIdx = 0; localGridCellIdx < grid->cellCount(); localGridCellIdx++)
{
for (size_t caseIdx = 0; caseIdx < caseCollection->reservoirs.size(); caseIdx++)
{
size_t globalCellIdx = grid->globalGridCellIndex(localGridCellIdx);
if (activeM[localGridCellIdx] == 0)
{
if (caseCollection->reservoirs[caseIdx]->reservoirData()->activeCellInfo(RifReaderInterface::MATRIX_RESULTS)->isActive(globalCellIdx))
{
activeM[localGridCellIdx] = 1;
}
}
if (activeF[localGridCellIdx] == 0)
{
if (caseCollection->reservoirs[caseIdx]->reservoirData()->activeCellInfo(RifReaderInterface::FRACTURE_RESULTS)->isActive(globalCellIdx))
{
activeF[localGridCellIdx] = 1;
}
}
}
}
size_t activeMatrixIndex = 0;
size_t activeFractureIndex = 0;
for (size_t localGridCellIdx = 0; localGridCellIdx < grid->cellCount(); localGridCellIdx++)
{
size_t globalCellIdx = grid->globalGridCellIndex(localGridCellIdx);
if (activeM[localGridCellIdx] != 0)
{
m_unionOfMatrixActiveCells->setCellResultIndex(globalCellIdx, globalActiveMatrixIndex++);
activeMatrixIndex++;
}
if (activeF[localGridCellIdx] != 0)
{
m_unionOfFractureActiveCells->setCellResultIndex(globalCellIdx, globalActiveFractureIndex++);
activeFractureIndex++;
}
}
m_unionOfMatrixActiveCells->setGridActiveCellCounts(gridIdx, activeMatrixIndex);
m_unionOfFractureActiveCells->setGridActiveCellCounts(gridIdx, activeFractureIndex);
}
m_unionOfMatrixActiveCells->computeDerivedData();
m_unionOfFractureActiveCells->computeDerivedData();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimStatisticsCase* RimIdenticalGridCaseGroup::createAndAppendStatisticsCase()
{
RimStatisticsCase* newStatisticsCase = new RimStatisticsCase;
newStatisticsCase->caseName = QString("Statistics ") + QString::number(statisticsCaseCollection()->reservoirs.size()+1);
statisticsCaseCollection()->reservoirs.push_back(newStatisticsCase);
newStatisticsCase->openEclipseGridFile();
return newStatisticsCase;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimIdenticalGridCaseGroup::updateMainGridAndActiveCellsForStatisticsCases()
{
for (size_t i = 0; i < statisticsCaseCollection->reservoirs().size(); i++)
{
RimCase* rimStaticsCase = statisticsCaseCollection->reservoirs[i];
rimStaticsCase->reservoirData()->setMainGrid(this->mainGrid());
if (i == 0)
{
rimStaticsCase->reservoirData()->computeActiveCellBoundingBoxes();
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimIdenticalGridCaseGroup::clearStatisticsResults()
{
for (size_t i = 0; i < statisticsCaseCollection->reservoirs().size(); i++)
{
RimCase* rimStaticsCase = statisticsCaseCollection->reservoirs[i];
if (!rimStaticsCase) continue;
rimStaticsCase->results(RifReaderInterface::MATRIX_RESULTS)->cellResults()->clearAllResults();
rimStaticsCase->results(RifReaderInterface::FRACTURE_RESULTS)->cellResults()->clearAllResults();
for (size_t j = 0; j < rimStaticsCase->reservoirViews.size(); j++)
{
RimReservoirView* rimReservoirView = rimStaticsCase->reservoirViews[j];
rimReservoirView->cellResult()->resultVariable = RimDefines::undefinedResultName();
rimReservoirView->cellEdgeResult()->resultVariable = RimDefines::undefinedResultName();
rimReservoirView->loadDataAndUpdate();
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimIdenticalGridCaseGroup::clearActiveCellUnions()
{
m_unionOfMatrixActiveCells->clear();
m_unionOfFractureActiveCells->clear();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimIdenticalGridCaseGroup::contains(RimCase* reservoir) const
{
CVF_ASSERT(reservoir);
for (size_t i = 0; i < caseCollection()->reservoirs().size(); i++)
{
RimCase* rimReservoir = caseCollection()->reservoirs()[i];
if (reservoir->caseName == reservoir->caseName)
{
return true;
}
}
return false;
}
RigActiveCellInfo* RimIdenticalGridCaseGroup::unionOfActiveCells(RifReaderInterface::PorosityModelResultType porosityType)
{
if (porosityType == RifReaderInterface::MATRIX_RESULTS)
{
return m_unionOfMatrixActiveCells.p();
}
else
{
return m_unionOfFractureActiveCells.p();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimIdenticalGridCaseGroup::isStatisticsCaseCollection(RimCaseCollection* rimCaseCollection)
{
std::vector<caf::PdmFieldHandle*> fields;
rimCaseCollection->parentFields(fields);
if (fields.size() == 1)
{
if (fields[0]->keyword() == "StatisticsCaseCollection")
{
return true;
}
}
return false;
}

View File

@ -0,0 +1,79 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cvfBase.h"
#include "cvfObject.h"
#include "cafPdmField.h"
#include "cafPdmObject.h"
#include "RimStatisticsCaseCollection.h"
#include "RimCaseCollection.h"
class RimCase;
class RigMainGrid;
class RigActiveCellInfo;
//==================================================================================================
//
//
//
//==================================================================================================
class RimIdenticalGridCaseGroup : public caf::PdmObject
{
CAF_PDM_HEADER_INIT;
public:
RimIdenticalGridCaseGroup();
virtual ~RimIdenticalGridCaseGroup();
caf::PdmField<QString> name;
void addCase(RimCase* reservoir);
void removeCase(RimCase* reservoir);
bool contains(RimCase* reservoir) const;
RimStatisticsCase* createAndAppendStatisticsCase();
caf::PdmField<RimCaseCollection*> caseCollection;
caf::PdmField<RimCaseCollection*> statisticsCaseCollection;
void loadMainCaseAndActiveCellInfo();
RigMainGrid* mainGrid();
RigActiveCellInfo* unionOfActiveCells(RifReaderInterface::PorosityModelResultType porosityType);
void computeUnionOfActiveCells();
static bool isStatisticsCaseCollection(RimCaseCollection* rimCaseCollection);
protected:
virtual caf::PdmFieldHandle* userDescriptionField();
private:
void updateMainGridAndActiveCellsForStatisticsCases();
void clearStatisticsResults();
void clearActiveCellUnions();
private:
RigMainGrid* m_mainGrid;
cvf::ref<RigActiveCellInfo> m_unionOfMatrixActiveCells;
cvf::ref<RigActiveCellInfo> m_unionOfFractureActiveCells;
};

View File

@ -16,16 +16,16 @@
//
/////////////////////////////////////////////////////////////////////////////////
#include "RIStdInclude.h"
#include "RiaStdInclude.h"
#include "RimInputReservoir.h"
#include "RimInputCase.h"
#include "RimInputProperty.h"
#include "RimReservoirView.h"
#include "RifReaderEclipseInput.h"
#include "RigReservoir.h"
#include "RigReservoirCellResults.h"
#include "RigCaseData.h"
#include "RigCaseCellResultsData.h"
#include "cvfAssert.h"
@ -34,18 +34,18 @@
#include "RifEclipseInputFileTools.h"
#include "cafProgressInfo.h"
#include "RIApplication.h"
#include "RIPreferences.h"
#include "RiaApplication.h"
#include "RiaPreferences.h"
CAF_PDM_SOURCE_INIT(RimInputReservoir, "RimInputReservoir");
CAF_PDM_SOURCE_INIT(RimInputCase, "RimInputReservoir");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimInputReservoir::RimInputReservoir()
: RimReservoir()
RimInputCase::RimInputCase()
: RimCase()
{
CAF_PDM_InitObject("RimInputReservoir", ":/EclipseInput48x48.png", "", "");
CAF_PDM_InitObject("RimInputCase", ":/EclipseInput48x48.png", "", "");
CAF_PDM_InitField(&m_gridFileName, "GridFileName", QString(), "Case grid filename", "", "" ,"");
CAF_PDM_InitFieldNoDefault(&m_additionalFileNames, "AdditionalFileNames", "Additional files", "", "" ,"");
@ -58,7 +58,7 @@ RimInputReservoir::RimInputReservoir()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimInputReservoir::~RimInputReservoir()
RimInputCase::~RimInputCase()
{
delete m_inputPropertyCollection;
}
@ -67,42 +67,23 @@ RimInputReservoir::~RimInputReservoir()
/// Open the supplied file set. If no grid data has been read, it will first find the possible
/// grid data among the files then read all supported properties from the files matching the grid
//--------------------------------------------------------------------------------------------------
void RimInputReservoir::openDataFileSet(const QStringList& filenames)
void RimInputCase::openDataFileSet(const QStringList& filenames)
{
if (caseName().contains("Input Mock Debug Model"))
{
cvf::ref<RifReaderInterface> readerInterface = this->createMockModel(this->caseName());
m_rigReservoir->mainGrid()->results(RifReaderInterface::MATRIX_RESULTS)->setReaderInterface(readerInterface.p());
m_rigReservoir->mainGrid()->results(RifReaderInterface::FRACTURE_RESULTS)->setReaderInterface(readerInterface.p());
results(RifReaderInterface::MATRIX_RESULTS)->setReaderInterface(readerInterface.p());
results(RifReaderInterface::FRACTURE_RESULTS)->setReaderInterface(readerInterface.p());
size_t matrixActiveCellCount = 0;
size_t fractureActiveCellCount = 0;
for (size_t cellIdx = 0; cellIdx < m_rigReservoir->mainGrid()->cells().size(); cellIdx++)
{
const RigCell& cell = m_rigReservoir->mainGrid()->cells()[cellIdx];
if (cell.isActiveInMatrixModel())
{
matrixActiveCellCount++;
}
if (cell.isActiveInFractureModel())
{
fractureActiveCellCount++;
}
}
m_rigReservoir->mainGrid()->setGlobalMatrixModelActiveCellCount(matrixActiveCellCount);
m_rigReservoir->mainGrid()->setGlobalFractureModelActiveCellCount(fractureActiveCellCount);
reservoirData()->activeCellInfo(RifReaderInterface::MATRIX_RESULTS)->computeDerivedData();
reservoirData()->activeCellInfo(RifReaderInterface::FRACTURE_RESULTS)->computeDerivedData();
return;
}
if (m_rigReservoir.isNull())
if (this->reservoirData() == NULL)
{
RigReservoir* reservoir = new RigReservoir;
m_rigReservoir = reservoir;
this->setReservoirData(new RigCaseData);
}
// First find and read the grid data
@ -114,8 +95,7 @@ void RimInputReservoir::openDataFileSet(const QStringList& filenames)
{
m_gridFileName = filenames[i];
m_rigReservoir->computeFaults();
m_rigReservoir->mainGrid()->computeCachedData();
computeCachedData();
break;
}
@ -174,10 +154,10 @@ void RimInputReservoir::openDataFileSet(const QStringList& filenames)
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimInputReservoir::openEclipseGridFile()
bool RimInputCase::openEclipseGridFile()
{
// Early exit if reservoir data is created
if (m_rigReservoir.isNull())
if (this->reservoirData() == NULL)
{
cvf::ref<RifReaderInterface> readerInterface;
@ -187,33 +167,32 @@ bool RimInputReservoir::openEclipseGridFile()
}
else
{
RigReservoir* reservoir = new RigReservoir;
cvf::ref<RigCaseData> eclipseCase = new RigCaseData;
readerInterface = new RifReaderEclipseInput;
if (!readerInterface->open(m_gridFileName, reservoir))
if (!readerInterface->open(m_gridFileName, eclipseCase.p()))
{
delete reservoir;
return false;
}
m_rigReservoir = reservoir;
loadAndSyncronizeInputProperties();
this->setReservoirData( eclipseCase.p() );
}
CVF_ASSERT(m_rigReservoir.notNull());
CVF_ASSERT(this->reservoirData());
CVF_ASSERT(readerInterface.notNull());
m_rigReservoir->mainGrid()->results(RifReaderInterface::MATRIX_RESULTS)->setReaderInterface(readerInterface.p());
m_rigReservoir->mainGrid()->results(RifReaderInterface::FRACTURE_RESULTS)->setReaderInterface(readerInterface.p());
m_rigReservoir->computeFaults();
m_rigReservoir->mainGrid()->computeCachedData();
results(RifReaderInterface::MATRIX_RESULTS)->setReaderInterface(readerInterface.p());
results(RifReaderInterface::FRACTURE_RESULTS)->setReaderInterface(readerInterface.p());
computeCachedData();
loadAndSyncronizeInputProperties();
}
RIApplication* app = RIApplication::instance();
RiaApplication* app = RiaApplication::instance();
if (app->preferences()->autocomputeDepthRelatedProperties)
{
RigReservoirCellResults* matrixResults = m_rigReservoir->mainGrid()->results(RifReaderInterface::MATRIX_RESULTS);
RigReservoirCellResults* fractureResults = m_rigReservoir->mainGrid()->results(RifReaderInterface::FRACTURE_RESULTS);
RimReservoirCellResultsStorage* matrixResults = results(RifReaderInterface::MATRIX_RESULTS);
RimReservoirCellResultsStorage* fractureResults = results(RifReaderInterface::FRACTURE_RESULTS);
matrixResults->computeDepthRelatedResults();
fractureResults->computeDepthRelatedResults();
@ -227,11 +206,11 @@ bool RimInputReservoir::openEclipseGridFile()
/// Loads input property data from the gridFile and additional files
/// Creates new InputProperties if necessary, and flags the unused ones as obsolete
//--------------------------------------------------------------------------------------------------
void RimInputReservoir::loadAndSyncronizeInputProperties()
void RimInputCase::loadAndSyncronizeInputProperties()
{
// Make sure we actually have reservoir data
CVF_ASSERT(m_rigReservoir.notNull());
CVF_ASSERT(this->reservoirData());
CVF_ASSERT(this->reservoirData()->mainGrid()->gridPointDimensions() != cvf::Vec3st(0,0,0));
// Then read the properties from all the files referenced by the InputReservoir
@ -305,7 +284,7 @@ void RimInputReservoir::loadAndSyncronizeInputProperties()
{
if (fileKeywordSet.count(knownKeywords[fkIt]))
{
QString resultName = this->reservoirData()->mainGrid()->results(RifReaderInterface::MATRIX_RESULTS)->makeResultNameUnique(knownKeywords[fkIt]);
QString resultName = this->reservoirData()->results(RifReaderInterface::MATRIX_RESULTS)->makeResultNameUnique(knownKeywords[fkIt]);
if (RifEclipseInputFileTools::readProperty(filenames[i], this->reservoirData(), knownKeywords[fkIt], resultName))
{
RimInputProperty* inputProperty = new RimInputProperty;
@ -334,7 +313,7 @@ void RimInputReservoir::loadAndSyncronizeInputProperties()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimInputReservoir::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
void RimInputCase::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
{
}
@ -342,7 +321,7 @@ void RimInputReservoir::fieldChangedByUi(const caf::PdmFieldHandle* changedField
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimInputReservoir::addFiles(const QStringList& newFileNames)
void RimInputCase::addFiles(const QStringList& newFileNames)
{
}
@ -351,7 +330,7 @@ void RimInputReservoir::addFiles(const QStringList& newFileNames)
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimInputReservoir::removeFiles(const QStringList& obsoleteFileNames)
void RimInputCase::removeFiles(const QStringList& obsoleteFileNames)
{
}
@ -359,7 +338,7 @@ void RimInputReservoir::removeFiles(const QStringList& obsoleteFileNames)
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimInputReservoir::removeProperty(RimInputProperty* inputProperty)
void RimInputCase::removeProperty(RimInputProperty* inputProperty)
{
bool isPropertyFileReferencedByOthers = false;
@ -380,7 +359,7 @@ void RimInputReservoir::removeProperty(RimInputProperty* inputProperty)
}
// Remove the results pointed to by this input property
RigReservoirCellResults* results = m_rigReservoir->mainGrid()->results(RifReaderInterface::MATRIX_RESULTS);
RigCaseCellResultsData* results = reservoirData()->results(RifReaderInterface::MATRIX_RESULTS);
results->removeResult(inputProperty->resultName);
this->removeResult(inputProperty->resultName);
@ -389,9 +368,9 @@ void RimInputReservoir::removeProperty(RimInputProperty* inputProperty)
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::ref<RifReaderInterface> RimInputReservoir::createMockModel(QString modelName)
cvf::ref<RifReaderInterface> RimInputCase::createMockModel(QString modelName)
{
cvf::ref<RigReservoir> reservoir = new RigReservoir;
cvf::ref<RigCaseData> reservoir = new RigCaseData;
cvf::ref<RifReaderMockModel> mockFileInterface = new RifReaderMockModel;
if (modelName == "Input Mock Debug Model Simple")
@ -405,12 +384,16 @@ cvf::ref<RifReaderInterface> RimInputReservoir::createMockModel(QString modelNam
mockFileInterface->open("", reservoir.p());
{
size_t idx = reservoir->mainGrid()->cellIndexFromIJK(1, 3, 4);
reservoir->mainGrid()->cell(idx).setActiveIndexInMatrixModel(cvf::UNDEFINED_SIZE_T);
//TODO: Rewrite active cell info in mock models
//reservoir->mainGrid()->cell(idx).setActiveIndexInMatrixModel(cvf::UNDEFINED_SIZE_T);
}
{
size_t idx = reservoir->mainGrid()->cellIndexFromIJK(2, 2, 3);
reservoir->mainGrid()->cell(idx).setActiveIndexInMatrixModel(cvf::UNDEFINED_SIZE_T);
//TODO: Rewrite active cell info in mock models
//reservoir->mainGrid()->cell(idx).setActiveIndexInMatrixModel(cvf::UNDEFINED_SIZE_T);
}
// Add a property
@ -421,7 +404,7 @@ cvf::ref<RifReaderInterface> RimInputReservoir::createMockModel(QString modelNam
m_inputPropertyCollection->inputProperties.push_back(inputProperty);
}
m_rigReservoir = reservoir;
this->setReservoirData( reservoir.p() );
return mockFileInterface.p();
}
@ -429,7 +412,7 @@ cvf::ref<RifReaderInterface> RimInputReservoir::createMockModel(QString modelNam
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimInputReservoir::locationOnDisc() const
QString RimInputCase::locationOnDisc() const
{
if (m_gridFileName().isEmpty()) return QString();

View File

@ -23,7 +23,7 @@
#include "cafPdmField.h"
#include "cafPdmObject.h"
#include "RimReservoir.h"
#include "RimCase.h"
#include "RimInputPropertyCollection.h"
@ -36,13 +36,13 @@ class RifReaderInterface;
//
//
//==================================================================================================
class RimInputReservoir : public RimReservoir
class RimInputCase : public RimCase
{
CAF_PDM_HEADER_INIT;
public:
RimInputReservoir();
virtual ~RimInputReservoir();
RimInputCase();
virtual ~RimInputCase();
// Fields
caf::PdmField<std::vector<QString> > m_additionalFileNames;
@ -56,7 +56,7 @@ public:
void removeProperty(RimInputProperty* inputProperty);
// RimReservoir overrides
// RimCase overrides
virtual bool openEclipseGridFile(); // Find grid file among file set. Read, Find read and validate property date. Syncronize child property sets.
// PdmObject overrides

View File

@ -16,7 +16,7 @@
//
/////////////////////////////////////////////////////////////////////////////////
#include "RIStdInclude.h"
#include "RiaStdInclude.h"
#include "RimInputProperty.h"

View File

@ -16,7 +16,7 @@
//
/////////////////////////////////////////////////////////////////////////////////
#include "RIStdInclude.h"
#include "RiaStdInclude.h"
#include "RimInputPropertyCollection.h"

View File

@ -16,7 +16,7 @@
//
/////////////////////////////////////////////////////////////////////////////////
#include "RIStdInclude.h"
#include "RiaStdInclude.h"
#include "RimLegendConfig.h"
#include "RimReservoirView.h"
@ -405,13 +405,13 @@ void RimLegendConfig::recreateLegend()
//--------------------------------------------------------------------------------------------------
double RimLegendConfig::adjust(double domainValue, double precision)
{
double decadeValue = cvf::Math::abs(domainValue);
double threshold = 1e-6;
if (decadeValue < threshold)
double absDomainValue = cvf::Math::abs(domainValue);
if (absDomainValue == 0.0)
{
return 0.0;
}
double logDecValue = log10(decadeValue);
double logDecValue = log10(absDomainValue);
logDecValue = cvf::Math::ceil(logDecValue);
double factor = pow(10.0, precision - logDecValue);

View File

@ -92,7 +92,7 @@ private:
caf::PdmPointer<RimReservoirView> m_reservoirView;
cvf::ref<cvf::ScalarMapperDiscreteLinear> m_linDiscreteScalarMapper;
cvf::ref<cvf::ScalarMapperDiscreteLinear> m_logDiscreteScalarMapper;
cvf::ref<cvf::ScalarMapperDiscreteLog> m_logDiscreteScalarMapper;
cvf::ref<cvf::ScalarMapperContinuousLog> m_logSmoothScalarMapper;
cvf::ref<cvf::ScalarMapperContinuousLinear> m_linSmoothScalarMapper;
cvf::ref<cvf::ScalarMapper> m_currentScalarMapper;

View File

@ -16,12 +16,16 @@
//
/////////////////////////////////////////////////////////////////////////////////
#include "RIStdInclude.h"
#include "RiaStdInclude.h"
#include "RimProject.h"
#include "RIApplication.h"
#include "RIVersionInfo.h"
#include "RimScriptCollection.h"
#include "RiaApplication.h"
#include "RiaVersionInfo.h"
#include "RigGridManager.h"
#include "RigCaseData.h"
#include "RimResultCase.h"
CAF_PDM_SOURCE_INIT(RimProject, "ResInsightProject");
//--------------------------------------------------------------------------------------------------
@ -33,11 +37,15 @@ RimProject::RimProject(void)
m_projectFileVersionString.setUiHidden(true);
CAF_PDM_InitFieldNoDefault(&reservoirs, "Reservoirs", "", "", "", "");
CAF_PDM_InitFieldNoDefault(&caseGroups, "CaseGroups", "", "", "", "");
CAF_PDM_InitFieldNoDefault(&scriptCollection, "ScriptCollection", "Scripts", ":/Default.png", "", "");
scriptCollection = new RimScriptCollection();
scriptCollection->directory.setUiHidden(true);
m_gridCollection = new RigGridManager;
initAfterRead();
}
@ -46,6 +54,8 @@ RimProject::RimProject(void)
//--------------------------------------------------------------------------------------------------
RimProject::~RimProject(void)
{
close();
if (scriptCollection()) delete scriptCollection();
reservoirs.deleteAllChildObjects();
@ -56,7 +66,10 @@ RimProject::~RimProject(void)
//--------------------------------------------------------------------------------------------------
void RimProject::close()
{
m_gridCollection->clear();
reservoirs.deleteAllChildObjects();
caseGroups.deleteAllChildObjects();
fileName = "";
}
@ -69,7 +82,7 @@ void RimProject::initAfterRead()
//
// TODO : Must store content of scripts in project file and notify user if stored content is different from disk on execute and edit
//
RIApplication* app = RIApplication::instance();
RiaApplication* app = RiaApplication::instance();
QString scriptDirectory = app->scriptDirectory();
this->setUserScriptPath(scriptDirectory);
@ -113,3 +126,108 @@ QString RimProject::projectFileVersionString() const
{
return m_projectFileVersionString;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimProject::moveEclipseCaseIntoCaseGroup(RimCase* rimReservoir)
{
CVF_ASSERT(rimReservoir);
RigCaseData* rigEclipseCase = rimReservoir->reservoirData();
RigMainGrid* equalGrid = registerCaseInGridCollection(rigEclipseCase);
CVF_ASSERT(equalGrid);
// Insert in identical grid group
bool foundGroup = false;
for (size_t i = 0; i < caseGroups.size(); i++)
{
RimIdenticalGridCaseGroup* cg = caseGroups()[i];
if (cg->mainGrid() == equalGrid)
{
cg->addCase(rimReservoir);
foundGroup = true;
}
}
if (!foundGroup)
{
RimIdenticalGridCaseGroup* group = new RimIdenticalGridCaseGroup;
group->addCase(rimReservoir);
caseGroups().push_back(group);
}
// Remove reservoir from main container
reservoirs().removeChildObject(rimReservoir);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimProject::removeCaseFromAllGroups(RimCase* reservoir)
{
m_gridCollection->removeCase(reservoir->reservoirData());
for (size_t i = 0; i < caseGroups.size(); i++)
{
RimIdenticalGridCaseGroup* cg = caseGroups()[i];
cg->removeCase(reservoir);
}
reservoirs().removeChildObject(reservoir);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigMainGrid* RimProject::registerCaseInGridCollection(RigCaseData* rigEclipseCase)
{
CVF_ASSERT(rigEclipseCase);
RigMainGrid* equalGrid = m_gridCollection->findEqualGrid(rigEclipseCase->mainGrid());
if (equalGrid)
{
// Replace the grid with an already registered grid
rigEclipseCase->setMainGrid(equalGrid);
}
else
{
// This is the first insertion of this grid, compute cached data
rigEclipseCase->mainGrid()->computeCachedData();
std::vector<RigGridBase*> grids;
rigEclipseCase->allGrids(&grids);
size_t i;
for (i = 0; i < grids.size(); i++)
{
grids[i]->computeFaults();
}
equalGrid = rigEclipseCase->mainGrid();
}
m_gridCollection->addCase(rigEclipseCase);
return equalGrid;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimProject::insertCaseInCaseGroup(RimIdenticalGridCaseGroup* caseGroup, RimCase* rimReservoir)
{
CVF_ASSERT(rimReservoir);
RigCaseData* rigEclipseCase = rimReservoir->reservoirData();
registerCaseInGridCollection(rigEclipseCase);
caseGroup->addCase(rimReservoir);
}

View File

@ -20,8 +20,10 @@
#include "cafPdmDocument.h"
#include "RimScriptCollection.h"
#include "RimIdenticalGridCaseGroup.h"
class RimReservoir;
class RimCase;
class RigGridManager;
//==================================================================================================
///
@ -32,8 +34,9 @@ class RimProject : public caf::PdmDocument
CAF_PDM_HEADER_INIT;
public:
caf::PdmPointersField<RimReservoir*> reservoirs;
caf::PdmField<RimScriptCollection*> scriptCollection;
caf::PdmPointersField<RimCase*> reservoirs;
caf::PdmPointersField<RimIdenticalGridCaseGroup*> caseGroups;
caf::PdmField<RimScriptCollection*> scriptCollection;
void setUserScriptPath(const QString& path);
//void updateProjectScriptPath();
@ -45,11 +48,21 @@ public:
void close();
void insertCaseInCaseGroup(RimIdenticalGridCaseGroup* caseGroup, RimCase* rimReservoir);
void moveEclipseCaseIntoCaseGroup(RimCase* rimReservoir);
void removeCaseFromAllGroups(RimCase* rimReservoir);
private:
RigMainGrid* registerCaseInGridCollection(RigCaseData* rigEclipseCase);
protected:
// Overridden methods
virtual void initAfterRead();
virtual void setupBeforeSave();
private:
caf::PdmField<QString> m_projectFileVersionString;
caf::PdmField<QString> m_projectFileVersionString;
cvf::ref<RigGridManager> m_gridCollection;
};

View File

@ -1,76 +0,0 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cvfBase.h"
#include "cvfObject.h"
#include "cafPdmField.h"
#include "cafPdmObject.h"
class QString;
class RigReservoir;
class RigGridBase;
class RimReservoirView;
//==================================================================================================
//
// Interface for reservoirs.
// As this is a pure virtual class, the factory macros are not relevant (nor possible) to use
// CAF_PDM_HEADER_INIT and CAF_PDM_SOURCE_INIT
//
//==================================================================================================
class RimReservoir : public caf::PdmObject
{
public:
RimReservoir();
virtual ~RimReservoir();
virtual bool openEclipseGridFile() = 0;
RigReservoir* reservoirData();
const RigReservoir* reservoirData() const;
RimReservoirView* createAndAddReservoirView();
void removeReservoirView(RimReservoirView* reservoirView);
void removeResult(const QString& resultName);
// Fields:
caf::PdmField<QString> caseName;
caf::PdmField<bool> releaseResultMemory;
caf::PdmPointersField<RimReservoirView*> reservoirViews;
virtual caf::PdmFieldHandle* userDescriptionField() { return &caseName; }
virtual QString locationOnDisc() const { return QString(); }
protected:
// Overridden methods
virtual void initAfterRead();
virtual void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue );
protected:
cvf::ref<RigReservoir> m_rigReservoir;
};

View File

@ -0,0 +1,699 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RiaStdInclude.h"
#include "RimReservoirCellResultsCacher.h"
#include "RigCaseCellResultsData.h"
#include "RiaApplication.h"
#include "RigMainGrid.h"
#include "RigCell.h"
#include "cafProgressInfo.h"
CAF_PDM_SOURCE_INIT(RimReservoirCellResultsStorage, "ReservoirCellResultStorage");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimReservoirCellResultsStorage::RimReservoirCellResultsStorage()
: m_cellResults(NULL),
m_ownerMainGrid(NULL)
{
CAF_PDM_InitObject("Cacher", "", "", "");
CAF_PDM_InitField(&m_resultCacheFileName, "ResultCacheFileName", QString(), "UiDummyname", "", "" ,"");
m_resultCacheFileName.setUiHidden(true);
CAF_PDM_InitFieldNoDefault(&m_resultCacheMetaData, "ResultCacheEntries", "UiDummyname", "", "", "");
m_resultCacheMetaData.setUiHidden(true);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimReservoirCellResultsStorage::~RimReservoirCellResultsStorage()
{
m_resultCacheMetaData.deleteAllChildObjects();
}
//--------------------------------------------------------------------------------------------------
/// This override populates the metainfo regarding the cell results data in the RigCaseCellResultsData
/// object. This metainfo will then be written to the project file when saving, and thus read on project file open.
/// This method then writes the actual double arrays to the data file in a simple format:
/// MagicNumber<uint32>, Version<uint32>, ResultVariables< Array < TimeStep< CellDataArraySize<uint64>, CellData< Array<double > > > >
///
//--------------------------------------------------------------------------------------------------
void RimReservoirCellResultsStorage::setupBeforeSave()
{
m_resultCacheMetaData.deleteAllChildObjects();
QString newValidCacheFileName = getValidCacheFileName();
// Delete the storage file
QFileInfo storageFileInfo(newValidCacheFileName);
if (storageFileInfo.exists())
{
QDir storageDir = storageFileInfo.dir();
storageDir.remove(storageFileInfo.fileName());
}
if (!m_cellResults) return;
const std::vector<RigCaseCellResultsData::ResultInfo>& resInfo = m_cellResults->infoForEachResultIndex();
bool hasResultsToStore = false;
for (size_t rIdx = 0; rIdx < resInfo.size(); ++rIdx)
{
if (resInfo[rIdx].m_needsToBeStored)
{
hasResultsToStore = true;
break;
}
}
if(resInfo.size() && hasResultsToStore)
{
QDir::root().mkpath(getCacheDirectoryPath());
QFile cacheFile(newValidCacheFileName);
if (!cacheFile.open(QIODevice::WriteOnly))
{
qWarning() << "Saving project: Can't open the cache file : " + newValidCacheFileName;
return;
}
m_resultCacheFileName = newValidCacheFileName;
QDataStream stream(&cacheFile);
stream.setVersion(QDataStream::Qt_4_6);
stream << (quint32)0xCEECAC4E; // magic number
stream << (quint32)1; // Version number. Increment if needing to extend the format in ways that can not be handled generically by the reader
caf::ProgressInfo progInfo(resInfo.size(), "Saving generated and imported properties");
for (size_t rIdx = 0; rIdx < resInfo.size(); ++rIdx)
{
// If there is no data, we do not store anything for the current result variable
// (Even not the metadata, of cause)
size_t timestepCount = m_cellResults->cellScalarResults(resInfo[rIdx].m_gridScalarResultIndex).size();
if (timestepCount && resInfo[rIdx].m_needsToBeStored)
{
progInfo.setProgressDescription(resInfo[rIdx].m_resultName);
// Create and setup the cache information for this result
RimReservoirCellResultsStorageEntryInfo* cacheEntry = new RimReservoirCellResultsStorageEntryInfo;
m_resultCacheMetaData.push_back(cacheEntry);
cacheEntry->m_resultType = resInfo[rIdx].m_resultType;
cacheEntry->m_resultName = resInfo[rIdx].m_resultName;
cacheEntry->m_timeStepDates = resInfo[rIdx].m_timeStepDates;
// Take note of the file position for fast lookup later
cacheEntry->m_filePosition = cacheFile.pos();
// Write all the scalar values for each time step to the stream,
// starting with the number of values
for (size_t tsIdx = 0; tsIdx < resInfo[rIdx].m_timeStepDates.size() ; ++tsIdx)
{
const std::vector<double>* data = NULL;
if (tsIdx < timestepCount)
{
data = &(m_cellResults->cellScalarResults(resInfo[rIdx].m_gridScalarResultIndex, tsIdx));
}
if (data && data->size())
{
stream << (quint64)(data->size());
for (size_t cIdx = 0; cIdx < data->size(); ++cIdx)
{
stream << (*data)[cIdx];
}
}
else
{
stream << (quint64)0;
}
}
}
progInfo.incrementProgress();
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimReservoirCellResultsStorage::getValidCacheFileName()
{
QString cacheFileName;
if (m_resultCacheFileName().isEmpty())
{
QString newCacheDirPath = getCacheDirectoryPath();
QUuid guid = QUuid::createUuid();
cacheFileName = newCacheDirPath + "/" + guid.toString();
}
else
{
// Make the path correct related to the possibly new project filename
QString newCacheDirPath = getCacheDirectoryPath();
QFileInfo oldCacheFile(m_resultCacheFileName());
cacheFileName = newCacheDirPath + "/" + oldCacheFile.fileName();
}
return cacheFileName;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimReservoirCellResultsStorage::getCacheDirectoryPath()
{
QString cacheDirPath;
QString projectFileName = RiaApplication::instance()->project()->fileName();
QFileInfo fileInfo(projectFileName);
cacheDirPath = fileInfo.canonicalPath();
cacheDirPath += "/" + fileInfo.completeBaseName() + "_cache";
return cacheDirPath;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimReservoirCellResultsStorage::setReaderInterface(RifReaderInterface* readerInterface)
{
m_readerInterface = readerInterface;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RifReaderInterface* RimReservoirCellResultsStorage::readerInterface()
{
return m_readerInterface.p();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
size_t RimReservoirCellResultsStorage::findOrLoadScalarResultForTimeStep(RimDefines::ResultCatType type, const QString& resultName, size_t timeStepIndex)
{
// Special handling for SOIL
if (type == RimDefines::DYNAMIC_NATIVE && resultName.toUpper() == "SOIL")
{
loadOrComputeSOILForTimeStep(timeStepIndex);
}
size_t scalarResultIndex = cvf::UNDEFINED_SIZE_T;
scalarResultIndex = m_cellResults->findScalarResultIndex(type, resultName);
if (scalarResultIndex == cvf::UNDEFINED_SIZE_T) return cvf::UNDEFINED_SIZE_T;
if (type == RimDefines::GENERATED)
{
return cvf::UNDEFINED_SIZE_T;
}
if (m_readerInterface.notNull())
{
size_t timeStepCount = m_cellResults->infoForEachResultIndex()[scalarResultIndex].m_timeStepDates.size();
bool resultLoadingSucess = true;
if (type == RimDefines::DYNAMIC_NATIVE && timeStepCount > 0)
{
m_cellResults->cellScalarResults(scalarResultIndex).resize(timeStepCount);
std::vector<double>& values = m_cellResults->cellScalarResults(scalarResultIndex)[timeStepIndex];
if (values.size() == 0)
{
if (!m_readerInterface->dynamicResult(resultName, RifReaderInterface::MATRIX_RESULTS, timeStepIndex, &values))
{
resultLoadingSucess = false;
}
}
}
else if (type == RimDefines::STATIC_NATIVE)
{
m_cellResults->cellScalarResults(scalarResultIndex).resize(1);
std::vector<double>& values = m_cellResults->cellScalarResults(scalarResultIndex)[0];
if (!m_readerInterface->staticResult(resultName, RifReaderInterface::MATRIX_RESULTS, &values))
{
resultLoadingSucess = false;
}
}
if (!resultLoadingSucess)
{
// Error logging
CVF_ASSERT(false);
}
}
return scalarResultIndex;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
size_t RimReservoirCellResultsStorage::findOrLoadScalarResult(RimDefines::ResultCatType type, const QString& resultName)
{
size_t resultGridIndex = cvf::UNDEFINED_SIZE_T;
resultGridIndex = m_cellResults->findScalarResultIndex(type, resultName);
if (resultGridIndex == cvf::UNDEFINED_SIZE_T) return cvf::UNDEFINED_SIZE_T;
// If we have any results on any timestep, assume we have loaded results already
for (size_t tsIdx = 0; tsIdx < m_cellResults->timeStepCount(resultGridIndex); ++tsIdx)
{
if (m_cellResults->cellScalarResults(resultGridIndex, tsIdx).size())
{
return resultGridIndex;
}
}
if (type == RimDefines::GENERATED)
{
return cvf::UNDEFINED_SIZE_T;
}
if (m_readerInterface.notNull())
{
// Add one more result to result container
size_t timeStepCount = m_cellResults->infoForEachResultIndex()[resultGridIndex].m_timeStepDates.size();
bool resultLoadingSucess = true;
if (type == RimDefines::DYNAMIC_NATIVE && timeStepCount > 0)
{
m_cellResults->cellScalarResults(resultGridIndex).resize(timeStepCount);
size_t i;
for (i = 0; i < timeStepCount; i++)
{
std::vector<double>& values = m_cellResults->cellScalarResults(resultGridIndex)[i];
if (!m_readerInterface->dynamicResult(resultName, RifReaderInterface::MATRIX_RESULTS, i, &values))
{
resultLoadingSucess = false;
}
}
}
else if (type == RimDefines::STATIC_NATIVE)
{
m_cellResults->cellScalarResults(resultGridIndex).resize(1);
std::vector<double>& values = m_cellResults->cellScalarResults(resultGridIndex)[0];
if (!m_readerInterface->staticResult(resultName, RifReaderInterface::MATRIX_RESULTS, &values))
{
resultLoadingSucess = false;
}
}
if (!resultLoadingSucess)
{
// Remove last scalar result because loading of result failed
m_cellResults->cellScalarResults(resultGridIndex).clear();
}
}
return resultGridIndex;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimReservoirCellResultsStorage::loadOrComputeSOIL()
{
for (size_t timeStepIdx = 0; timeStepIdx < m_cellResults->maxTimeStepCount(); timeStepIdx++)
{
loadOrComputeSOILForTimeStep(timeStepIdx);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimReservoirCellResultsStorage::loadOrComputeSOILForTimeStep(size_t timeStepIndex)
{
size_t scalarIndexSWAT = findOrLoadScalarResultForTimeStep(RimDefines::DYNAMIC_NATIVE, "SWAT", timeStepIndex);
size_t scalarIndexSGAS = findOrLoadScalarResultForTimeStep(RimDefines::DYNAMIC_NATIVE, "SGAS", timeStepIndex);
// Early exit if none of SWAT or SGAS is present
if (scalarIndexSWAT == cvf::UNDEFINED_SIZE_T && scalarIndexSGAS == cvf::UNDEFINED_SIZE_T)
{
return;
}
size_t soilResultValueCount = 0;
size_t soilTimeStepCount = 0;
std::vector<double>* swatForTimeStep = NULL;
std::vector<double>* sgasForTimeStep = NULL;
if (scalarIndexSWAT != cvf::UNDEFINED_SIZE_T)
{
swatForTimeStep = &(m_cellResults->cellScalarResults(scalarIndexSWAT, timeStepIndex));
if (swatForTimeStep->size() == 0)
{
swatForTimeStep = NULL;
}
else
{
soilResultValueCount = swatForTimeStep->size();
soilTimeStepCount = m_cellResults->infoForEachResultIndex()[scalarIndexSWAT].m_timeStepDates.size();
}
}
if (scalarIndexSGAS != cvf::UNDEFINED_SIZE_T)
{
sgasForTimeStep = &(m_cellResults->cellScalarResults(scalarIndexSGAS, timeStepIndex));
if (sgasForTimeStep->size() == 0)
{
sgasForTimeStep = NULL;
}
else
{
soilResultValueCount = qMax(soilResultValueCount, sgasForTimeStep->size());
size_t sgasTimeStepCount = m_cellResults->infoForEachResultIndex()[scalarIndexSGAS].m_timeStepDates.size();
soilTimeStepCount = qMax(soilTimeStepCount, sgasTimeStepCount);
}
}
size_t soilResultGridIndex = findOrLoadScalarResult(RimDefines::DYNAMIC_NATIVE, "SOIL");
if (soilResultGridIndex == cvf::UNDEFINED_SIZE_T)
{
soilResultGridIndex = m_cellResults->addEmptyScalarResult(RimDefines::DYNAMIC_NATIVE, "SOIL", false);
CVF_ASSERT(soilResultGridIndex != cvf::UNDEFINED_SIZE_T);
m_cellResults->cellScalarResults(soilResultGridIndex).resize(soilTimeStepCount);
for (size_t timeStepIdx = 0; timeStepIdx < soilTimeStepCount; timeStepIdx++)
{
m_cellResults->cellScalarResults(soilResultGridIndex, timeStepIdx).resize(soilResultValueCount);
}
}
std::vector<double>& soilForTimeStep = m_cellResults->cellScalarResults(soilResultGridIndex, timeStepIndex);
#pragma omp parallel for
for (int idx = 0; idx < static_cast<int>(soilResultValueCount); idx++)
{
double soilValue = 1.0;
if (sgasForTimeStep)
{
soilValue -= sgasForTimeStep->at(idx);
}
if (swatForTimeStep)
{
soilValue -= swatForTimeStep->at(idx);
}
soilForTimeStep[idx] = soilValue;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimReservoirCellResultsStorage::computeDepthRelatedResults()
{
size_t depthResultGridIndex = findOrLoadScalarResult(RimDefines::STATIC_NATIVE, "DEPTH");
size_t dxResultGridIndex = findOrLoadScalarResult(RimDefines::STATIC_NATIVE, "DX");
size_t dyResultGridIndex = findOrLoadScalarResult(RimDefines::STATIC_NATIVE, "DY");
size_t dzResultGridIndex = findOrLoadScalarResult(RimDefines::STATIC_NATIVE, "DZ");
size_t topsResultGridIndex = findOrLoadScalarResult(RimDefines::STATIC_NATIVE, "TOPS");
size_t bottomResultGridIndex = findOrLoadScalarResult(RimDefines::STATIC_NATIVE, "BOTTOM");
bool computeDepth = false;
bool computeDx = false;
bool computeDy = false;
bool computeDz = false;
bool computeTops = false;
bool computeBottom = false;
size_t resultValueCount = m_ownerMainGrid->cells().size();
if (depthResultGridIndex == cvf::UNDEFINED_SIZE_T)
{
depthResultGridIndex = m_cellResults->addStaticScalarResult(RimDefines::STATIC_NATIVE, "DEPTH", false, resultValueCount);
computeDepth = true;
}
if (dxResultGridIndex == cvf::UNDEFINED_SIZE_T)
{
dxResultGridIndex = m_cellResults->addStaticScalarResult(RimDefines::STATIC_NATIVE, "DX", false, resultValueCount);
computeDx = true;
}
if (dyResultGridIndex == cvf::UNDEFINED_SIZE_T)
{
dyResultGridIndex = m_cellResults->addStaticScalarResult(RimDefines::STATIC_NATIVE, "DY", false, resultValueCount);
computeDy = true;
}
if (dzResultGridIndex == cvf::UNDEFINED_SIZE_T)
{
dzResultGridIndex = m_cellResults->addStaticScalarResult(RimDefines::STATIC_NATIVE, "DZ", false, resultValueCount);
computeDz = true;
}
if (topsResultGridIndex == cvf::UNDEFINED_SIZE_T)
{
topsResultGridIndex = m_cellResults->addStaticScalarResult(RimDefines::STATIC_NATIVE, "TOPS", false, resultValueCount);
computeTops = true;
}
if (bottomResultGridIndex == cvf::UNDEFINED_SIZE_T)
{
bottomResultGridIndex = m_cellResults->addStaticScalarResult(RimDefines::STATIC_NATIVE, "BOTTOM", false, resultValueCount);
computeBottom = true;
}
std::vector< std::vector<double> >& depth = m_cellResults->cellScalarResults(depthResultGridIndex);
std::vector< std::vector<double> >& dx = m_cellResults->cellScalarResults(dxResultGridIndex);
std::vector< std::vector<double> >& dy = m_cellResults->cellScalarResults(dyResultGridIndex);
std::vector< std::vector<double> >& dz = m_cellResults->cellScalarResults(dzResultGridIndex);
std::vector< std::vector<double> >& tops = m_cellResults->cellScalarResults(topsResultGridIndex);
std::vector< std::vector<double> >& bottom = m_cellResults->cellScalarResults(bottomResultGridIndex);
size_t cellIdx = 0;
for (cellIdx = 0; cellIdx < m_ownerMainGrid->cells().size(); cellIdx++)
{
const RigCell& cell = m_ownerMainGrid->cells()[cellIdx];
if (computeDepth)
{
depth[0][cellIdx] = cvf::Math::abs(cell.center().z());
}
if (computeDx)
{
cvf::Vec3d cellWidth = cell.faceCenter(cvf::StructGridInterface::NEG_I) - cell.faceCenter(cvf::StructGridInterface::POS_I);
dx[0][cellIdx] = cvf::Math::abs(cellWidth.x());
}
if (computeDy)
{
cvf::Vec3d cellWidth = cell.faceCenter(cvf::StructGridInterface::NEG_J) - cell.faceCenter(cvf::StructGridInterface::POS_J);
dy[0][cellIdx] = cvf::Math::abs(cellWidth.y());
}
if (computeDz)
{
cvf::Vec3d cellWidth = cell.faceCenter(cvf::StructGridInterface::NEG_K) - cell.faceCenter(cvf::StructGridInterface::POS_K);
dz[0][cellIdx] = cvf::Math::abs(cellWidth.z());
}
if (computeTops)
{
tops[0][cellIdx] = cvf::Math::abs(cell.faceCenter(cvf::StructGridInterface::NEG_K).z());
}
if (computeBottom)
{
bottom[0][cellIdx] = cvf::Math::abs(cell.faceCenter(cvf::StructGridInterface::POS_K).z());
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
size_t RimReservoirCellResultsStorage::findOrLoadScalarResult(const QString& resultName)
{
size_t scalarResultIndex = cvf::UNDEFINED_SIZE_T;
scalarResultIndex = this->findOrLoadScalarResult(RimDefines::STATIC_NATIVE, resultName);
if (scalarResultIndex == cvf::UNDEFINED_SIZE_T)
{
scalarResultIndex = this->findOrLoadScalarResult(RimDefines::DYNAMIC_NATIVE, resultName);
}
if (scalarResultIndex == cvf::UNDEFINED_SIZE_T)
{
scalarResultIndex = m_cellResults->findScalarResultIndex(RimDefines::GENERATED, resultName);
}
if (scalarResultIndex == cvf::UNDEFINED_SIZE_T)
{
scalarResultIndex = m_cellResults->findScalarResultIndex(RimDefines::INPUT_PROPERTY, resultName);
}
return scalarResultIndex;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimReservoirCellResultsStorage::setCellResults(RigCaseCellResultsData* cellResults)
{
m_cellResults = cellResults;
if (m_cellResults == NULL)
return;
// Now that we have got the results container, we can finally
// Read data from the internal storage and populate it
if (m_resultCacheFileName().isEmpty())
return;
// Get the name of the cache name relative to the current project file position
QString newValidCacheFileName = getValidCacheFileName();
QFile storageFile(newValidCacheFileName);
// Warn if we thought we were to find some data on the storage file
if (!storageFile.exists() && m_resultCacheMetaData.size())
{
qWarning() << "Reading stored results: Missing the storage file : " + newValidCacheFileName;
return;
}
if (!storageFile.open(QIODevice::ReadOnly))
{
qWarning() << "Reading stored results: Can't open the file : " + newValidCacheFileName;
return;
}
QDataStream stream(&storageFile);
stream.setVersion(QDataStream::Qt_4_6);
quint32 magicNumber = 0;
quint32 versionNumber = 0;
stream >> magicNumber;
if (magicNumber != 0xCEECAC4E)
{
qWarning() << "Reading stored results: The storage file has wrong type ";
return;
}
stream >> versionNumber;
if (versionNumber > 1 )
{
qWarning() << "Reading stored results: The storage file has been written by a newer version of ResInsight";
return;
}
caf::ProgressInfo progress(m_resultCacheMetaData.size(), "Reading internally stored results");
// Fill the object with data from the storage
for (size_t rIdx = 0; rIdx < m_resultCacheMetaData.size(); ++rIdx)
{
RimReservoirCellResultsStorageEntryInfo* resInfo = m_resultCacheMetaData[rIdx];
size_t resultIndex = m_cellResults->addEmptyScalarResult(resInfo->m_resultType(), resInfo->m_resultName(), true);
m_cellResults->setTimeStepDates(resultIndex, resInfo->m_timeStepDates());
progress.setProgressDescription(resInfo->m_resultName);
for (size_t tsIdx = 0; tsIdx < resInfo->m_timeStepDates().size(); ++tsIdx)
{
std::vector<double>* data = NULL;
data = &(m_cellResults->cellScalarResults(rIdx, tsIdx));
quint64 cellCount = 0;
stream >> cellCount;
data->resize(cellCount, HUGE_VAL);
for (size_t cIdx = 0; cIdx < cellCount; ++cIdx)
{
stream >> (*data)[cIdx];
}
}
progress.incrementProgress();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimReservoirCellResultsStorage::setMainGrid(RigMainGrid* mainGrid)
{
m_ownerMainGrid = mainGrid;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
size_t RimReservoirCellResultsStorage::storedResultsCount()
{
return m_resultCacheMetaData.size();
}
CAF_PDM_SOURCE_INIT(RimReservoirCellResultsStorageEntryInfo, "ResultStorageEntryInfo");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimReservoirCellResultsStorageEntryInfo::RimReservoirCellResultsStorageEntryInfo()
{
CAF_PDM_InitObject("Cache Entry", "", "", "");
CAF_PDM_InitField(&m_resultType, "ResultType", caf::AppEnum<RimDefines::ResultCatType>(RimDefines::REMOVED), "ResultType", "", "" ,"");
CAF_PDM_InitField(&m_resultName, "ResultName", QString(), "ResultName", "", "" ,"");
CAF_PDM_InitFieldNoDefault(&m_timeStepDates, "TimeSteps", "TimeSteps", "", "" ,"");
CAF_PDM_InitField(&m_filePosition, "FilePositionDataStart", qint64(-1), "FilePositionDataStart", "", "" ,"");
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimReservoirCellResultsStorageEntryInfo::~RimReservoirCellResultsStorageEntryInfo()
{
}

View File

@ -0,0 +1,89 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include <QDateTime>
#include "cafPdmField.h"
#include "cafPdmObject.h"
#include "cafAppEnum.h"
#include "RimDefines.h"
class RimReservoirCellResultsStorageEntryInfo;
class RigCaseCellResultsData;
class RifReaderInterface;
class RigMainGrid;
class RimReservoirCellResultsStorage : public caf::PdmObject
{
CAF_PDM_HEADER_INIT;
public:
RimReservoirCellResultsStorage();
virtual ~RimReservoirCellResultsStorage();
void setCellResults(RigCaseCellResultsData* cellResults);
RigCaseCellResultsData* cellResults() { return m_cellResults; }
const RigCaseCellResultsData* cellResults() const { return m_cellResults; }
size_t storedResultsCount();
void setMainGrid(RigMainGrid* mainGrid);
void setReaderInterface(RifReaderInterface* readerInterface);
RifReaderInterface* readerInterface();
void loadOrComputeSOIL();
void computeDepthRelatedResults();
size_t findOrLoadScalarResultForTimeStep(RimDefines::ResultCatType type, const QString& resultName, size_t timeStepIndex);
size_t findOrLoadScalarResult(RimDefines::ResultCatType type, const QString& resultName);
size_t findOrLoadScalarResult(const QString& resultName); ///< Simplified search. Assumes unique names across types.
protected:
// Overridden methods from PdmObject
virtual void setupBeforeSave();
private:
void loadOrComputeSOILForTimeStep(size_t timeStepIndex);
QString getValidCacheFileName();
QString getCacheDirectoryPath();
// Fields
caf::PdmField<QString> m_resultCacheFileName;
caf::PdmPointersField<RimReservoirCellResultsStorageEntryInfo*>
m_resultCacheMetaData;
cvf::ref<RifReaderInterface> m_readerInterface;
RigCaseCellResultsData* m_cellResults;
RigMainGrid* m_ownerMainGrid;
};
class RimReservoirCellResultsStorageEntryInfo : public caf::PdmObject
{
CAF_PDM_HEADER_INIT;
public:
RimReservoirCellResultsStorageEntryInfo();
virtual ~RimReservoirCellResultsStorageEntryInfo();
caf::PdmField<caf::AppEnum< RimDefines::ResultCatType> > m_resultType;
caf::PdmField<QString> m_resultName;
caf::PdmField< std::vector <QDateTime> > m_timeStepDates;
caf::PdmField<qint64> m_filePosition;
};

View File

@ -16,15 +16,15 @@
//
/////////////////////////////////////////////////////////////////////////////////
#include "RIStdInclude.h"
#include "RIViewer.h"
#include "RiaStdInclude.h"
#include "RiuViewer.h"
#include "RimReservoirView.h"
#include "RIMainWindow.h"
#include "RiuMainWindow.h"
#include "RigGridBase.h"
#include "RigReservoir.h"
#include "RIApplication.h"
#include "RIPreferences.h"
#include "RigCaseData.h"
#include "RiaApplication.h"
#include "RiaPreferences.h"
#include "cafEffectGenerator.h"
#include "cafFrameAnimationControl.h"
@ -32,7 +32,7 @@
#include "RimCellRangeFilterCollection.h"
#include "cvfStructGridGeometryGenerator.h"
#include "RigReservoirCellResults.h"
#include "RigCaseCellResultsData.h"
#include "RivCellEdgeEffectGenerator.h"
#include "RimCellEdgeResultSlot.h"
#include "cvfqtUtils.h"
@ -41,7 +41,7 @@
#include "cafCadNavigation.h"
#include "cafCeetronNavigation.h"
#include "RimReservoir.h"
#include "RimCase.h"
#include "Rim3dOverlayInfoConfig.h"
#include "RigGridScalarDataAccess.h"
@ -82,8 +82,8 @@ CAF_PDM_SOURCE_INIT(RimReservoirView, "ReservoirView");
//--------------------------------------------------------------------------------------------------
RimReservoirView::RimReservoirView()
{
RIApplication* app = RIApplication::instance();
RIPreferences* preferences = app->preferences();
RiaApplication* app = RiaApplication::instance();
RiaPreferences* preferences = app->preferences();
CVF_ASSERT(preferences);
CAF_PDM_InitObject("Reservoir View", ":/ReservoirView.png", "", "");
@ -137,6 +137,9 @@ RimReservoirView::RimReservoirView()
CAF_PDM_InitField(&showInactiveCells, "ShowInactiveCells", false, "Show Inactive Cells", "", "", "");
CAF_PDM_InitField(&showInvalidCells, "ShowInvalidCells", false, "Show Invalid Cells", "", "", "");
CAF_PDM_InitField(&backgroundColor, "ViewBackgroundColor", cvf::Color3f(0.69f, 0.77f, 0.87f), "Viewer Background", "", "", "");
CAF_PDM_InitField(&cameraPosition, "CameraPosition", cvf::Mat4d::IDENTITY, "", "", "", "");
@ -169,7 +172,7 @@ RimReservoirView::~RimReservoirView()
if (m_viewer)
{
RIMainWindow::instance()->removeViewer(m_viewer);
RiuMainWindow::instance()->removeViewer(m_viewer);
}
m_geometry->clearGeometryCache();
@ -189,19 +192,19 @@ void RimReservoirView::updateViewerWidget()
if (!m_viewer)
{
QGLFormat glFormat;
glFormat.setDirectRendering(RIApplication::instance()->useShaders());
glFormat.setDirectRendering(RiaApplication::instance()->useShaders());
m_viewer = new RIViewer(glFormat, NULL);
m_viewer = new RiuViewer(glFormat, NULL);
m_viewer->setOwnerReservoirView(this);
RIMainWindow::instance()->addViewer(m_viewer);
RiuMainWindow::instance()->addViewer(m_viewer);
m_viewer->setMinNearPlaneDistance(10);
this->cellResult()->legendConfig->recreateLegend();
this->cellEdgeResult()->legendConfig->recreateLegend();
m_viewer->setColorLegend1(this->cellResult()->legendConfig->legend());
m_viewer->setColorLegend2(this->cellEdgeResult()->legendConfig->legend());
if (RIApplication::instance()->navigationPolicy() == RIApplication::NAVIGATION_POLICY_CEETRON)
if (RiaApplication::instance()->navigationPolicy() == RiaApplication::NAVIGATION_POLICY_CEETRON)
{
m_viewer->setNavigationPolicy(new caf::CeetronNavigation);
}
@ -210,16 +213,18 @@ void RimReservoirView::updateViewerWidget()
m_viewer->setNavigationPolicy(new caf::CadNavigation);
}
m_viewer->enablePerfInfoHud(RIApplication::instance()->showPerformanceInfo());
m_viewer->enablePerfInfoHud(RiaApplication::instance()->showPerformanceInfo());
//m_viewer->layoutWidget()->showMaximized();
isViewerCreated = true;
}
RIMainWindow::instance()->setActiveViewer(m_viewer);
RiuMainWindow::instance()->setActiveViewer(m_viewer);
if (isViewerCreated) m_viewer->mainCamera()->setViewMatrix(cameraPosition);
m_viewer->mainCamera()->viewport()->setClearColor(cvf::Color4f(backgroundColor()));
m_viewer->update();
}
else
@ -267,11 +272,11 @@ void RimReservoirView::updateViewerWidgetWindowTitle()
void RimReservoirView::clampCurrentTimestep()
{
// Clamp the current timestep to actual possibilities
if (this->gridCellResults())
if (this->currentGridCellResults()->cellResults())
{
if (m_currentTimeStep() > this->gridCellResults()->maxTimeStepCount())
if (m_currentTimeStep() >= static_cast<int>(this->currentGridCellResults()->cellResults()->maxTimeStepCount()))
{
m_currentTimeStep = static_cast<int>(this->gridCellResults()->maxTimeStepCount()) -1;
m_currentTimeStep = static_cast<int>(this->currentGridCellResults()->cellResults()->maxTimeStepCount()) -1;
}
}
@ -298,7 +303,7 @@ void RimReservoirView::createDisplayModelAndRedraw()
}
}
RIMainWindow::instance()->refreshAnimationActions();
RiuMainWindow::instance()->refreshAnimationActions();
}
//--------------------------------------------------------------------------------------------------
@ -358,6 +363,13 @@ void RimReservoirView::fieldChangedByUi(const caf::PdmFieldHandle* changedField,
createDisplayModelAndRedraw();
}
}
else if (changedField == &backgroundColor )
{
if (viewer() != NULL)
{
updateViewerWidget();
}
}
else if (changedField == &m_currentTimeStep)
{
if (m_viewer)
@ -448,10 +460,10 @@ void RimReservoirView::createDisplayModel()
|| this->propertyFilterCollection()->hasActiveDynamicFilters()
|| this->wellCollection->hasVisibleWellPipes())
{
CVF_ASSERT(gridCellResults());
CVF_ASSERT(currentGridCellResults());
size_t i;
for (i = 0; i < gridCellResults()->maxTimeStepCount(); i++)
for (i = 0; i < currentGridCellResults()->cellResults()->maxTimeStepCount(); i++)
{
timeStepIndices.push_back(i);
}
@ -690,16 +702,16 @@ void RimReservoirView::loadDataAndUpdate()
{
if (!m_reservoir->openEclipseGridFile())
{
QMessageBox::warning(RIMainWindow::instance(), "Error when opening project file", "Could not open the Eclipse Grid file (EGRID/GRID): \n"+ m_reservoir->caseName());
QMessageBox::warning(RiuMainWindow::instance(), "Error when opening project file", "Could not open the Eclipse Grid file (EGRID/GRID): \n"+ m_reservoir->caseName());
m_reservoir = NULL;
return;
}
else
{
RIApplication* app = RIApplication::instance();
RiaApplication* app = RiaApplication::instance();
if (app->preferences()->autocomputeSOIL)
{
RigReservoirCellResults* results = gridCellResults();
RimReservoirCellResultsStorage* results = currentGridCellResults();
CVF_ASSERT(results);
results->loadOrComputeSOIL();
}
@ -709,7 +721,7 @@ void RimReservoirView::loadDataAndUpdate()
CVF_ASSERT(this->cellResult() != NULL);
this->cellResult()->loadResult();
if (m_reservoir->reservoirData()->mainGrid()->globalFractureModelActiveCellCount() == 0)
if (m_reservoir->reservoirData()->activeCellInfo(RifReaderInterface::FRACTURE_RESULTS)->globalActiveCellCount() == 0)
{
this->cellResult->porosityModel.setUiHidden(true);
}
@ -820,7 +832,7 @@ void RimReservoirView::updateStaticCellColors(unsigned short geometryType)
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RIViewer* RimReservoirView::viewer()
RiuViewer* RimReservoirView::viewer()
{
return m_viewer;
}
@ -835,20 +847,20 @@ bool RimReservoirView::pickInfo(size_t gridIndex, size_t cellIndex, const cvf::V
if (m_reservoir)
{
const RigReservoir* reservoir = m_reservoir->reservoirData();
if (reservoir)
const RigCaseData* eclipseCase = m_reservoir->reservoirData();
if (eclipseCase)
{
size_t i = 0;
size_t j = 0;
size_t k = 0;
if (reservoir->grid(gridIndex)->ijkFromCellIndex(cellIndex, &i, &j, &k))
if (eclipseCase->grid(gridIndex)->ijkFromCellIndex(cellIndex, &i, &j, &k))
{
// Adjust to 1-based Eclipse indexing
i++;
j++;
k++;
cvf::Vec3d domainCoord = point + reservoir->grid(gridIndex)->displayModelOffset();
cvf::Vec3d domainCoord = point + eclipseCase->grid(gridIndex)->displayModelOffset();
pickInfoText->sprintf("Hit grid %u, cell [%u, %u, %u], intersection point: [E: %.2f, N: %.2f, Depth: %.2f]", static_cast<unsigned int>(gridIndex), static_cast<unsigned int>(i), static_cast<unsigned int>(j), static_cast<unsigned int>(k), domainCoord.x(), domainCoord.y(), -domainCoord.z());
return true;
@ -862,18 +874,19 @@ bool RimReservoirView::pickInfo(size_t gridIndex, size_t cellIndex, const cvf::V
//--------------------------------------------------------------------------------------------------
/// Get the current scalar value for the display face at the given index
//--------------------------------------------------------------------------------------------------
void RimReservoirView::appendCellResultInfo(size_t gridIndex, size_t cellIndex, QString* resultInfoText) const
void RimReservoirView::appendCellResultInfo(size_t gridIndex, size_t cellIndex, QString* resultInfoText)
{
CVF_ASSERT(resultInfoText);
if (m_reservoir && m_reservoir->reservoirData())
{
const RigReservoir* reservoir = m_reservoir->reservoirData();
const RigGridBase* grid = reservoir->grid(gridIndex);
RigCaseData* eclipseCase = m_reservoir->reservoirData();
RigGridBase* grid = eclipseCase->grid(gridIndex);
if (this->cellResult()->hasResult())
{
RifReaderInterface::PorosityModelResultType porosityModel = RigReservoirCellResults::convertFromProjectModelPorosityModel(cellResult()->porosityModel());
cvf::ref<RigGridScalarDataAccess> dataAccessObject = grid->dataAccessObject(porosityModel, m_currentTimeStep, this->cellResult()->gridScalarIndex());
RifReaderInterface::PorosityModelResultType porosityModel = RigCaseCellResultsData::convertFromProjectModelPorosityModel(cellResult()->porosityModel());
cvf::ref<cvf::StructGridScalarDataAccess> dataAccessObject = eclipseCase->dataAccessObject(grid, porosityModel, m_currentTimeStep, this->cellResult()->gridScalarIndex());
if (dataAccessObject.notNull())
{
double scalarValue = dataAccessObject->cellScalar(cellIndex);
@ -893,8 +906,8 @@ void RimReservoirView::appendCellResultInfo(size_t gridIndex, size_t cellIndex,
if (resultIndices[idx] == cvf::UNDEFINED_SIZE_T) continue;
// Cell edge results are static, results are loaded for first time step only
RifReaderInterface::PorosityModelResultType porosityModel = RigReservoirCellResults::convertFromProjectModelPorosityModel(cellResult()->porosityModel());
cvf::ref<RigGridScalarDataAccess> dataAccessObject = grid->dataAccessObject(porosityModel, 0, resultIndices[idx]);
RifReaderInterface::PorosityModelResultType porosityModel = RigCaseCellResultsData::convertFromProjectModelPorosityModel(cellResult()->porosityModel());
cvf::ref<cvf::StructGridScalarDataAccess> dataAccessObject = eclipseCase->dataAccessObject(grid, porosityModel, 0, resultIndices[idx]);
if (dataAccessObject.notNull())
{
double scalarValue = dataAccessObject->cellScalar(cellIndex);
@ -957,16 +970,30 @@ void RimReservoirView::setupBeforeSave()
//--------------------------------------------------------------------------------------------------
/// Convenience for quick access to results
//--------------------------------------------------------------------------------------------------
RigReservoirCellResults* RimReservoirView::gridCellResults()
RimReservoirCellResultsStorage* RimReservoirView::currentGridCellResults()
{
if (m_reservoir)
{
RifReaderInterface::PorosityModelResultType porosityModel = RigCaseCellResultsData::convertFromProjectModelPorosityModel(cellResult->porosityModel());
return m_reservoir->results(porosityModel);
}
return NULL;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigActiveCellInfo* RimReservoirView::currentActiveCellInfo()
{
if (m_reservoir &&
m_reservoir->reservoirData() &&
m_reservoir->reservoirData()->mainGrid()
m_reservoir->reservoirData()
)
{
RifReaderInterface::PorosityModelResultType porosityModel = RigReservoirCellResults::convertFromProjectModelPorosityModel(cellResult->porosityModel());
RifReaderInterface::PorosityModelResultType porosityModel = RigCaseCellResultsData::convertFromProjectModelPorosityModel(cellResult->porosityModel());
return m_reservoir->reservoirData()->mainGrid()->results(porosityModel);
return m_reservoir->reservoirData()->activeCellInfo(porosityModel);
}
return NULL;
@ -1032,11 +1059,11 @@ void RimReservoirView::updateLegends()
return;
}
RigReservoir* reservoir = m_reservoir->reservoirData();
CVF_ASSERT(reservoir);
RigCaseData* eclipseCase = m_reservoir->reservoirData();
CVF_ASSERT(eclipseCase);
RifReaderInterface::PorosityModelResultType porosityModel = RigReservoirCellResults::convertFromProjectModelPorosityModel(cellResult()->porosityModel());
RigReservoirCellResults* results = reservoir->mainGrid()->results(porosityModel);
RifReaderInterface::PorosityModelResultType porosityModel = RigCaseCellResultsData::convertFromProjectModelPorosityModel(cellResult()->porosityModel());
RigCaseCellResultsData* results = eclipseCase->results(porosityModel);
CVF_ASSERT(results);
if (this->cellResult()->hasResult())
@ -1085,7 +1112,7 @@ void RimReservoirView::updateLegends()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimReservoirView::setEclipseCase(RimReservoir* reservoir)
void RimReservoirView::setEclipseCase(RimCase* reservoir)
{
m_reservoir = reservoir;
}
@ -1093,7 +1120,7 @@ void RimReservoirView::setEclipseCase(RimReservoir* reservoir)
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimReservoir* RimReservoirView::eclipseCase()
RimCase* RimReservoirView::eclipseCase()
{
return m_reservoir;
}
@ -1115,7 +1142,7 @@ void RimReservoirView::syncronizeWellsWithResults()
{
if (!(m_reservoir && m_reservoir->reservoirData()) ) return;
cvf::Collection<RigWellResults> wellResults = m_reservoir->reservoirData()->wellResults();
cvf::Collection<RigSingleWellResultsData> wellResults = m_reservoir->reservoirData()->wellResults();
// Find corresponding well from well result, or create a new
size_t wIdx;
@ -1137,7 +1164,7 @@ void RimReservoirView::syncronizeWellsWithResults()
for (wIdx = 0; wIdx < this->wellCollection()->wells().size(); ++wIdx)
{
RimWell* well = this->wellCollection()->wells()[wIdx];
RigWellResults* wellRes = well->wellResults();
RigSingleWellResultsData* wellRes = well->wellResults();
if (wellRes == NULL)
{
delete well;
@ -1171,13 +1198,17 @@ void RimReservoirView::calculateVisibleWellCellsIncFence(cvf::UByteArray* visibl
// If all wells are forced off, return
if (this->wellCollection()->wellCellVisibility() == RimWellCollection::FORCE_ALL_OFF) return;
RigActiveCellInfo* activeCellInfo = this->currentActiveCellInfo();
CVF_ASSERT(activeCellInfo);
// Loop over the wells and find their contribution
for (size_t wIdx = 0; wIdx < this->wellCollection()->wells().size(); ++wIdx)
{
RimWell* well = this->wellCollection()->wells()[wIdx];
if (this->wellCollection()->wellCellVisibility() == RimWellCollection::FORCE_ALL_ON || well->showWellCells())
{
RigWellResults* wres = well->wellResults();
RigSingleWellResultsData* wres = well->wellResults();
if (!wres) continue;
const std::vector< RigWellResultFrame >& wellResFrames = wres->m_wellCellsTimeSteps;
@ -1235,7 +1266,9 @@ void RimReservoirView::calculateVisibleWellCellsIncFence(cvf::UByteArray* visibl
for ( fIdx = 0; fIdx < cellCountFenceDirection; ++fIdx)
{
size_t fenceCellIndex = grid->cellIndexFromIJK(*pI,*pJ,*pK);
if (grid->cell(fenceCellIndex).isActiveInMatrixModel())
size_t globalGridCellIndex = grid->globalGridCellIndex(fenceCellIndex);
if (activeCellInfo && activeCellInfo->isActive(globalGridCellIndex))
{
(*visibleCells)[fenceCellIndex] = true;
}

View File

@ -23,7 +23,7 @@
#include <QPointer>
#include <QString>
#include "RimReservoir.h"
#include "RimCase.h"
#include "RimResultSlot.h"
#include "RimCellEdgeResultSlot.h"
#include "RimCellRangeFilter.h"
@ -39,7 +39,7 @@
#include "RivReservoirViewPartMgr.h"
#include "RivReservoirPipesPartMgr.h"
class RIViewer;
class RiuViewer;
class RigGridBase;
class RigGridCellFaceVisibilityFilter;
class RivReservoirViewPartMgr;
@ -51,7 +51,6 @@ namespace cvf
class ModelBasicList;
}
enum ViewState
{
GEOMETRY_ONLY,
@ -85,97 +84,103 @@ public:
NO_SURFACE
};
// Public fields:
// Fields containing child objects :
caf::PdmField<RimResultSlot*> cellResult;
caf::PdmField<RimCellEdgeResultSlot*> cellEdgeResult;
caf::PdmField<Rim3dOverlayInfoConfig*> overlayInfoConfig;
caf::PdmField<RimResultSlot*> cellResult;
caf::PdmField<RimCellEdgeResultSlot*> cellEdgeResult;
caf::PdmField<double> scaleZ;
caf::PdmField<bool> showWindow;
caf::PdmField<QString> name;
caf::PdmField<RimCellRangeFilterCollection*> rangeFilterCollection;
caf::PdmField<RimCellPropertyFilterCollection*> propertyFilterCollection;
// Visibility
caf::PdmField<bool> showInvalidCells;
caf::PdmField<bool> showInactiveCells;
caf::PdmField<bool> showMainGrid;
caf::PdmField<RimWellCollection*> wellCollection;
caf::PdmField<RimWellCollection*> wellCollection;
caf::PdmField<Rim3dOverlayInfoConfig*> overlayInfoConfig;
caf::PdmField<RimCellRangeFilterCollection*> rangeFilterCollection;
caf::PdmField<RimCellPropertyFilterCollection*> propertyFilterCollection;
// Visualization setup fields
caf::PdmField< caf::AppEnum< MeshModeType > > meshMode;
caf::PdmField< caf::AppEnum< SurfaceModeType > > surfaceMode;
caf::PdmField<QString> name;
caf::PdmField<double> scaleZ;
caf::PdmField<bool> showWindow;
caf::PdmField<bool> showInvalidCells;
caf::PdmField<bool> showInactiveCells;
caf::PdmField<bool> showMainGrid;
caf::PdmField< caf::AppEnum< MeshModeType > > meshMode;
caf::PdmField< caf::AppEnum< SurfaceModeType > > surfaceMode;
caf::PdmField< cvf::Color3f > backgroundColor;
caf::PdmField<cvf::Mat4d> cameraPosition;
caf::PdmField<int> maximumFrameRate;
caf::PdmField<bool> animationMode;
// Access internal objects
RimReservoirCellResultsStorage* currentGridCellResults();
RigActiveCellInfo* currentActiveCellInfo();
void setEclipseCase(RimCase* reservoir);
RimCase* eclipseCase();
// Animation
caf::PdmField<int> maximumFrameRate;
caf::PdmField<bool> animationMode;
int currentTimeStep() { return m_currentTimeStep;}
void setCurrentTimeStep(int frameIdx);
void updateCurrentTimeStepAndRedraw();
void endAnimation();
int currentTimeStep() { return m_currentTimeStep;}
void setCurrentTimeStep(int frameIdx);
void updateCurrentTimeStepAndRedraw();
void endAnimation();
// 3D Viewer
// Cam pos should be a field, but is not yet supported bu caf::Pdm
caf::PdmField<cvf::Mat4d> cameraPosition;
void setDefaultView();
RIViewer* viewer();
void updateViewerWidget();
void updateViewerWidgetWindowTitle();
RiuViewer* viewer();
void updateViewerWidget();
void updateViewerWidgetWindowTitle();
void setDefaultView();
// Picking info
bool pickInfo(size_t gridIndex, size_t cellIndex, const cvf::Vec3d& point, QString* pickInfoText) const;
void appendCellResultInfo(size_t gridIndex, size_t cellIndex, QString* resultInfoText) const;
RigReservoirCellResults* gridCellResults();
void setEclipseCase(RimReservoir* reservoir);
RimReservoir* eclipseCase();
void calculateVisibleWellCellsIncFence(cvf::UByteArray* visibleCells, RigGridBase * grid);
bool pickInfo(size_t gridIndex, size_t cellIndex, const cvf::Vec3d& point, QString* pickInfoText) const;
void appendCellResultInfo(size_t gridIndex, size_t cellIndex, QString* resultInfoText) ;
// Does this belong here, really ?
void calculateVisibleWellCellsIncFence(cvf::UByteArray* visibleCells, RigGridBase * grid);
// Display model generation
public:
void loadDataAndUpdate();
void createDisplayModelAndRedraw();
void scheduleGeometryRegen(unsigned short geometryType);
void schedulePipeGeometryRegen();
void loadDataAndUpdate();
void createDisplayModelAndRedraw();
void scheduleGeometryRegen(unsigned short geometryType);
void schedulePipeGeometryRegen();
// Display model generation
private:
void createDisplayModel();
void updateDisplayModelVisibility();
void updateCurrentTimeStep();
void indicesToVisibleGrids(std::vector<size_t>* gridIndices);
void updateScaleTransform();
void updateStaticCellColors();
void updateStaticCellColors(unsigned short geometryType);
void updateLegends();
cvf::ref<RivReservoirViewPartMgr> m_geometry;
cvf::ref<RivReservoirPipesPartMgr> m_pipesPartManager;
// Overridden PDM methods:
public:
virtual caf::PdmFieldHandle* userDescriptionField() { return &name;}
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue);
virtual caf::PdmFieldHandle* userDescriptionField() { return &name;}
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue);
protected:
virtual void initAfterRead();
virtual void setupBeforeSave();
virtual void initAfterRead();
virtual void setupBeforeSave();
// Really private
private:
void syncronizeWellsWithResults();
void clampCurrentTimestep();
private:
void syncronizeWellsWithResults();
void clampCurrentTimestep();
private:
caf::PdmField<int> m_currentTimeStep;
QPointer<RIViewer> m_viewer;
caf::PdmPointer<RimReservoir> m_reservoir;
caf::PdmField<int> m_currentTimeStep;
QPointer<RiuViewer> m_viewer;
caf::PdmPointer<RimCase> m_reservoir;
// Display model generation
private:
void createDisplayModel();
void updateDisplayModelVisibility();
void updateCurrentTimeStep();
void indicesToVisibleGrids(std::vector<size_t>* gridIndices);
void updateScaleTransform();
void updateStaticCellColors();
void updateStaticCellColors(unsigned short geometryType);
void updateLegends();
cvf::ref<RivReservoirViewPartMgr> m_geometry;
cvf::ref<RivReservoirPipesPartMgr> m_pipesPartManager;
};

View File

@ -16,11 +16,11 @@
//
/////////////////////////////////////////////////////////////////////////////////
#include "RIStdInclude.h"
#include "RimResultReservoir.h"
#include "RigReservoir.h"
#include "RiaStdInclude.h"
#include "RimResultCase.h"
#include "RigCaseData.h"
#include "RifReaderEclipseOutput.h"
#include "RigReservoirCellResults.h"
#include "RigCaseCellResultsData.h"
#include "RimReservoirView.h"
#include "RifReaderMockModel.h"
#include "RifReaderEclipseInput.h"
@ -28,13 +28,15 @@
#include "RimProject.h"
CAF_PDM_SOURCE_INIT(RimResultReservoir, "EclipseCase");
CAF_PDM_SOURCE_INIT(RimResultCase, "EclipseCase");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimResultReservoir::RimResultReservoir()
: RimReservoir()
RimResultCase::RimResultCase()
: RimCase()
{
CAF_PDM_InitObject("Eclipse Case", ":/AppLogo48x48.png", "", "");
CAF_PDM_InitField(&caseFileName, "CaseFileName", QString(), "Case file name", "", "" ,"");
CAF_PDM_InitField(&caseDirectory, "CaseFolder", QString(), "Directory", "", "" ,"");
}
@ -43,14 +45,14 @@ RimResultReservoir::RimResultReservoir()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimResultReservoir::openEclipseGridFile()
bool RimResultCase::openEclipseGridFile()
{
caf::ProgressInfo progInfo(50, "Reading Eclipse Grid File");
progInfo.setProgressDescription("Open Grid File");
progInfo.setNextProgressIncrement(48);
// Early exit if reservoir data is created
if (m_rigReservoir.notNull()) return true;
if (this->reservoirData()) return true;
cvf::ref<RifReaderInterface> readerInterface;
@ -58,28 +60,6 @@ bool RimResultReservoir::openEclipseGridFile()
{
readerInterface = this->createMockModel(this->caseName());
size_t matrixActiveCellCount = 0;
size_t fractureActiveCellCount = 0;
for (size_t cellIdx = 0; cellIdx < m_rigReservoir->mainGrid()->cells().size(); cellIdx++)
{
const RigCell& cell = m_rigReservoir->mainGrid()->cells()[cellIdx];
if (cell.isActiveInMatrixModel())
{
matrixActiveCellCount++;
}
if (cell.isActiveInFractureModel())
{
fractureActiveCellCount++;
}
}
m_rigReservoir->mainGrid()->setGlobalMatrixModelActiveCellCount(matrixActiveCellCount);
m_rigReservoir->mainGrid()->setGlobalFractureModelActiveCellCount(fractureActiveCellCount);
m_rigReservoir->mainGrid()->results(RifReaderInterface::MATRIX_RESULTS)->setReaderInterface(readerInterface.p());
m_rigReservoir->mainGrid()->results(RifReaderInterface::FRACTURE_RESULTS)->setReaderInterface(readerInterface.p());
}
else
{
@ -89,40 +69,96 @@ bool RimResultReservoir::openEclipseGridFile()
return false;
}
RigReservoir* reservoir = new RigReservoir;
cvf::ref<RigCaseData> eclipseCase = new RigCaseData;
readerInterface = new RifReaderEclipseOutput;
if (!readerInterface->open(fname, reservoir))
if (!readerInterface->open(fname, eclipseCase.p()))
{
delete reservoir;
return false;
}
m_rigReservoir = reservoir;
this->setReservoirData( eclipseCase.p() );
}
results(RifReaderInterface::MATRIX_RESULTS)->setReaderInterface(readerInterface.p());
results(RifReaderInterface::FRACTURE_RESULTS)->setReaderInterface(readerInterface.p());
progInfo.incrementProgress();
CVF_ASSERT(m_rigReservoir.notNull());
CVF_ASSERT(this->reservoirData());
CVF_ASSERT(readerInterface.notNull());
progInfo.setProgressDescription("Computing Faults");
m_rigReservoir->computeFaults();
progInfo.incrementProgress();
progInfo.setProgressDescription("Computing Cache");
m_rigReservoir->mainGrid()->computeCachedData();
progInfo.setProgressDescription("Computing Case Cache");
computeCachedData();
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimResultCase::openAndReadActiveCellData(RigCaseData* mainEclipseCase)
{
cvf::ref<RifReaderInterface> readerInterface;
if (caseName().contains("Result Mock Debug Model"))
{
readerInterface = this->createMockModel(this->caseName());
}
else
{
QString fname = createAbsoluteFilenameFromCase(caseName);
if (fname.isEmpty())
{
return false;
}
cvf::ref<RigCaseData> eclipseCase = new RigCaseData;
CVF_ASSERT(mainEclipseCase && mainEclipseCase->mainGrid());
eclipseCase->setMainGrid(mainEclipseCase->mainGrid());
size_t scalarIndexWithMaxTimeStepCount = cvf::UNDEFINED_SIZE_T;
mainEclipseCase->results(RifReaderInterface::MATRIX_RESULTS)->maxTimeStepCount(&scalarIndexWithMaxTimeStepCount);
if (scalarIndexWithMaxTimeStepCount == cvf::UNDEFINED_SIZE_T)
{
return false;
}
std::vector<QDateTime> timeStepDates = mainEclipseCase->results(RifReaderInterface::MATRIX_RESULTS)->timeStepDates(scalarIndexWithMaxTimeStepCount);
cvf::ref<RifReaderEclipseOutput> readerEclipseOutput = new RifReaderEclipseOutput;
if (!readerEclipseOutput->openAndReadActiveCellData(fname, timeStepDates, eclipseCase.p()))
{
return false;
}
readerEclipseOutput->close();
this->setReservoirData( eclipseCase.p() );
readerInterface = readerEclipseOutput;
}
results(RifReaderInterface::MATRIX_RESULTS)->setReaderInterface(readerInterface.p());
results(RifReaderInterface::FRACTURE_RESULTS)->setReaderInterface(readerInterface.p());
CVF_ASSERT(this->reservoirData());
CVF_ASSERT(readerInterface.notNull());
reservoirData()->computeActiveCellBoundingBoxes();
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::ref<RifReaderInterface> RimResultReservoir::createMockModel(QString modelName)
cvf::ref<RifReaderInterface> RimResultCase::createMockModel(QString modelName)
{
cvf::ref<RifReaderMockModel> mockFileInterface = new RifReaderMockModel;
cvf::ref<RigReservoir> reservoir = new RigReservoir;
cvf::ref<RigCaseData> reservoir = new RigCaseData;
if (modelName == "Result Mock Debug Model Simple")
{
@ -134,12 +170,16 @@ cvf::ref<RifReaderInterface> RimResultReservoir::createMockModel(QString modelNa
mockFileInterface->open("", reservoir.p());
{
size_t idx = reservoir->mainGrid()->cellIndexFromIJK(1, 3, 4);
reservoir->mainGrid()->cell(idx).setActiveIndexInMatrixModel(cvf::UNDEFINED_SIZE_T);
//TODO: Rewrite active cell info in mock models
//reservoir->mainGrid()->cell(idx).setActiveIndexInMatrixModel(cvf::UNDEFINED_SIZE_T);
}
{
size_t idx = reservoir->mainGrid()->cellIndexFromIJK(2, 2, 3);
reservoir->mainGrid()->cell(idx).setActiveIndexInMatrixModel(cvf::UNDEFINED_SIZE_T);
//TODO: Rewrite active cell info in mock models
//reservoir->mainGrid()->cell(idx).setActiveIndexInMatrixModel(cvf::UNDEFINED_SIZE_T);
}
}
else if (modelName == "Result Mock Debug Model With Results")
@ -184,7 +224,7 @@ cvf::ref<RifReaderInterface> RimResultReservoir::createMockModel(QString modelNa
}
m_rigReservoir = reservoir;
this->setReservoirData( reservoir.p() );
return mockFileInterface.p();
}
@ -193,7 +233,7 @@ cvf::ref<RifReaderInterface> RimResultReservoir::createMockModel(QString modelNa
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimResultReservoir::~RimResultReservoir()
RimResultCase::~RimResultCase()
{
reservoirViews.deleteAllChildObjects();
}
@ -201,7 +241,7 @@ RimResultReservoir::~RimResultReservoir()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimResultReservoir::locationOnDisc() const
QString RimResultCase::locationOnDisc() const
{
return caseDirectory;
}
@ -209,7 +249,7 @@ QString RimResultReservoir::locationOnDisc() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimResultReservoir::createAbsoluteFilenameFromCase(const QString& caseName)
QString RimResultCase::createAbsoluteFilenameFromCase(const QString& caseName)
{
QString candidate;

View File

@ -22,22 +22,23 @@
#include "cvfObject.h"
#include "cafPdmField.h"
#include "cafPdmObject.h"
#include "RimReservoir.h"
#include "RimCase.h"
class RifReaderInterface;
class RifReaderInterface;
class RigMainGrid;
//==================================================================================================
//
//
//
//==================================================================================================
class RimResultReservoir : public RimReservoir
class RimResultCase : public RimCase
{
CAF_PDM_HEADER_INIT;
public:
RimResultReservoir();
virtual ~RimResultReservoir();
RimResultCase();
virtual ~RimResultCase();
// Fields:
@ -45,6 +46,7 @@ public:
caf::PdmField<QString> caseDirectory;
virtual bool openEclipseGridFile();
bool openAndReadActiveCellData(RigCaseData* mainEclipseCase);
//virtual caf::PdmFieldHandle* userDescriptionField() { return &caseName;}

View File

@ -16,14 +16,14 @@
//
/////////////////////////////////////////////////////////////////////////////////
#include "RIStdInclude.h"
#include "RiaStdInclude.h"
#include "RimResultDefinition.h"
#include "RimReservoirView.h"
#include "RimReservoir.h"
#include "RigReservoirCellResults.h"
#include "RigReservoir.h"
#include "RimCase.h"
#include "RigCaseCellResultsData.h"
#include "RigCaseData.h"
#include "RigMainGrid.h"
#include "cafPdmUiListEditor.h"
@ -63,9 +63,9 @@ void RimResultDefinition::setReservoirView(RimReservoirView* ownerReservoirView)
// TODO: This code is executed before reservoir is read, and then porosity model is never set to zero
if (m_reservoirView->eclipseCase() &&
m_reservoirView->eclipseCase()->reservoirData() &&
m_reservoirView->eclipseCase()->reservoirData()->mainGrid() )
m_reservoirView->eclipseCase()->reservoirData()->activeCellInfo(RifReaderInterface::FRACTURE_RESULTS) )
{
if (m_reservoirView->eclipseCase()->reservoirData()->mainGrid()->globalFractureModelActiveCellCount() == 0)
if (m_reservoirView->eclipseCase()->reservoirData()->activeCellInfo(RifReaderInterface::FRACTURE_RESULTS)->globalActiveCellCount() == 0)
{
porosityModel.setUiHidden(true);
}
@ -92,9 +92,9 @@ QList<caf::PdmOptionItemInfo> RimResultDefinition::calculateValueOptions(const c
{
if (fieldNeedingOptions == &resultVariable)
{
if (m_reservoirView && m_reservoirView->gridCellResults())
if (m_reservoirView && m_reservoirView->currentGridCellResults())
{
QStringList varList = m_reservoirView->gridCellResults()->resultNames(resultType());
QStringList varList = m_reservoirView->currentGridCellResults()->cellResults()->resultNames(resultType());
QList<caf::PdmOptionItemInfo> optionList;
int i;
for (i = 0; i < varList.size(); ++i)
@ -119,8 +119,8 @@ size_t RimResultDefinition::gridScalarIndex() const
{
if (m_gridScalarResultIndex == cvf::UNDEFINED_SIZE_T)
{
const RigReservoirCellResults* gridCellResults = m_reservoirView->gridCellResults();
if (gridCellResults) m_gridScalarResultIndex = gridCellResults->findScalarResultIndex(resultType(), resultVariable());
const RimReservoirCellResultsStorage* gridCellResults = m_reservoirView->currentGridCellResults();
if (gridCellResults) m_gridScalarResultIndex = gridCellResults->cellResults()->findScalarResultIndex(resultType(), resultVariable());
}
return m_gridScalarResultIndex;
}
@ -130,7 +130,7 @@ size_t RimResultDefinition::gridScalarIndex() const
//--------------------------------------------------------------------------------------------------
void RimResultDefinition::loadResult()
{
RigReservoirCellResults* gridCellResults = m_reservoirView->gridCellResults();
RimReservoirCellResultsStorage* gridCellResults = m_reservoirView->currentGridCellResults();
if (gridCellResults)
{
m_gridScalarResultIndex = gridCellResults->findOrLoadScalarResult(resultType(), resultVariable);
@ -148,8 +148,8 @@ void RimResultDefinition::loadResult()
//--------------------------------------------------------------------------------------------------
bool RimResultDefinition::hasStaticResult() const
{
const RigReservoirCellResults* gridCellResults = m_reservoirView->gridCellResults();
if (hasResult() && gridCellResults->timeStepCount(m_gridScalarResultIndex) == 1 )
const RimReservoirCellResultsStorage* gridCellResults = m_reservoirView->currentGridCellResults();
if (hasResult() && gridCellResults->cellResults()->timeStepCount(m_gridScalarResultIndex) == 1 )
{
return true;
}
@ -166,7 +166,7 @@ bool RimResultDefinition::hasResult() const
{
if (m_gridScalarResultIndex != cvf::UNDEFINED_SIZE_T) return true;
const RigReservoirCellResults* gridCellResults = m_reservoirView->gridCellResults();
const RigCaseCellResultsData* gridCellResults = m_reservoirView->currentGridCellResults()->cellResults();
if (gridCellResults)
{
m_gridScalarResultIndex = gridCellResults->findScalarResultIndex(resultType(), resultVariable());
@ -182,7 +182,7 @@ bool RimResultDefinition::hasResult() const
//--------------------------------------------------------------------------------------------------
bool RimResultDefinition::hasDynamicResult() const
{
const RigReservoirCellResults* gridCellResults = m_reservoirView->gridCellResults();
const RigCaseCellResultsData* gridCellResults = m_reservoirView->currentGridCellResults()->cellResults();
if (hasResult() && gridCellResults->timeStepCount(m_gridScalarResultIndex) > 1 )
return true;
else

View File

@ -26,7 +26,7 @@
class RimReservoirView;
class RigReservoirCellResults;
class RigCaseCellResultsData;
//==================================================================================================
///

View File

@ -16,13 +16,13 @@
//
/////////////////////////////////////////////////////////////////////////////////
#include "RIStdInclude.h"
#include "RiaStdInclude.h"
#include "RimResultSlot.h"
#include "RimLegendConfig.h"
#include "RimReservoirView.h"
#include "RimReservoir.h"
#include "RIMainWindow.h"
#include "RimCase.h"
#include "RiuMainWindow.h"
#include "RimUiTreeModelPdm.h"
@ -91,7 +91,7 @@ void RimResultSlot::changeLegendConfig(QString resultVarNameOfNewLegend)
m_legendConfigData.v().erase(it);
m_legendConfigData.v().push_back(this->legendConfig());
this->legendConfig = newLegend;
RIMainWindow::instance()->uiPdmModel()->rebuildUiSubTree(this);
RiuMainWindow::instance()->uiPdmModel()->rebuildUiSubTree(this);
found = true;
break;
}
@ -105,7 +105,7 @@ void RimResultSlot::changeLegendConfig(QString resultVarNameOfNewLegend)
newLegend->resultVariableName = resultVarNameOfNewLegend;
m_legendConfigData.v().push_back(this->legendConfig());
this->legendConfig = newLegend;
RIMainWindow::instance()->uiPdmModel()->rebuildUiSubTree(this);
RiuMainWindow::instance()->uiPdmModel()->rebuildUiSubTree(this);
}
}

View File

@ -16,13 +16,13 @@
//
/////////////////////////////////////////////////////////////////////////////////
#include "RIStdInclude.h"
#include "RiaStdInclude.h"
#include "RimScriptCollection.h"
#include "cafPdmField.h"
#include "cafUtils.h"
#include "RIMainWindow.h"
#include "RiuMainWindow.h"
#include "RimUiTreeModelPdm.h"
#include "cafPdmUiFilePathEditor.h"
@ -161,7 +161,7 @@ void RimScriptCollection::fieldChangedByUi(const caf::PdmFieldHandle *changedFie
QFileInfo fi(directory);
this->setUiName(fi.baseName());
this->readContentFromDisc();
RimUiTreeModelPdm* treeModel = RIMainWindow::instance()->uiPdmModel();
RimUiTreeModelPdm* treeModel = RiuMainWindow::instance()->uiPdmModel();
if (treeModel) treeModel->rebuildUiSubTree(this);
}
}

View File

@ -0,0 +1,220 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RiaStdInclude.h"
#include "RimStatisticsCase.h"
#include "RimReservoirView.h"
#include "cafPdmUiOrdering.h"
#include "RimIdenticalGridCaseGroup.h"
#include "RigCaseData.h"
#include "RigCaseCellResultsData.h"
#include "RimStatisticsCaseEvaluator.h"
#include "RigMainGrid.h"
CAF_PDM_SOURCE_INIT(RimStatisticsCase, "RimStatisticalCalculation");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimStatisticsCase::RimStatisticsCase()
: RimCase()
{
CAF_PDM_InitObject("Case Group Statistics", ":/Histogram16x16.png", "", "");
CAF_PDM_InitField(&m_resultName, "ResultName", QString("PRESSURE"), "ResultName", "", "", "");
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimStatisticsCase::~RimStatisticsCase()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimStatisticsCase::setMainGrid(RigMainGrid* mainGrid)
{
CVF_ASSERT(mainGrid);
CVF_ASSERT(this->reservoirData());
reservoirData()->setMainGrid(mainGrid);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimStatisticsCase::openEclipseGridFile()
{
if (this->reservoirData()) return true;
cvf::ref<RigCaseData> eclipseCase = new RigCaseData;
CVF_ASSERT(parentStatisticsCaseCollection());
RimIdenticalGridCaseGroup* gridCaseGroup = parentStatisticsCaseCollection()->parentCaseGroup();
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));
this->setReservoirData( eclipseCase.p() );
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimStatisticsCase::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) const
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimCaseCollection* RimStatisticsCase::parentStatisticsCaseCollection()
{
std::vector<RimCaseCollection*> parentObjects;
this->parentObjectsOfType(parentObjects);
if (parentObjects.size() > 0)
{
return parentObjects[0];
}
return NULL;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimStatisticsCase::computeStatistics()
{
if (this->reservoirData() == NULL)
{
openEclipseGridFile();
}
RimIdenticalGridCaseGroup* gridCaseGroup = caseGroup();
CVF_ASSERT(gridCaseGroup);
gridCaseGroup->computeUnionOfActiveCells();
std::vector<RimCase*> sourceCases;
getSourceCases(sourceCases);
if (sourceCases.size() == 0)
{
return;
}
// 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)->cellResults()->maxTimeStepCount();
RimStatisticsConfig statisticsConfig;
std::vector<size_t> timeStepIndices;
for (size_t i = 0; i < timeStepCount; i++)
{
timeStepIndices.push_back(i);
}
RigCaseData* resultCase = reservoirData();
QList<QPair<RimDefines::ResultCatType, QString> > resultSpecification;
//resultSpecification.append(qMakePair(RimDefines::DYNAMIC_NATIVE, QString("PRESSURE")));
{
QStringList resultNames = sourceCases.at(0)->results(RifReaderInterface::MATRIX_RESULTS)->cellResults()->resultNames(RimDefines::DYNAMIC_NATIVE);
foreach(QString resultName, resultNames)
{
resultSpecification.append(qMakePair(RimDefines::DYNAMIC_NATIVE, resultName));
}
}
{
QStringList resultNames = sourceCases.at(0)->results(RifReaderInterface::MATRIX_RESULTS)->cellResults()->resultNames(RimDefines::STATIC_NATIVE);
foreach(QString resultName, resultNames)
{
resultSpecification.append(qMakePair(RimDefines::STATIC_NATIVE, resultName));
}
}
RimStatisticsCaseEvaluator stat(sourceCases, timeStepIndices, statisticsConfig, resultCase);
stat.evaluateForResults(resultSpecification);
for (size_t i = 0; i < reservoirViews().size(); i++)
{
RimReservoirView* reservoirView = reservoirViews()[i];
CVF_ASSERT(reservoirView);
reservoirView->scheduleGeometryRegen(RivReservoirViewPartMgr::ACTIVE);
reservoirView->createDisplayModelAndRedraw();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimStatisticsCase::getSourceCases(std::vector<RimCase*>& 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());
RimCase* sourceCase = gridCaseGroup->caseCollection->reservoirs[i];
sourceCases.push_back(sourceCase);
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimIdenticalGridCaseGroup* RimStatisticsCase::caseGroup()
{
RimCaseCollection* parentCollection = parentStatisticsCaseCollection();
if (parentCollection)
{
return parentCollection->parentCaseGroup();
}
return NULL;
}

View File

@ -0,0 +1,63 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cvfBase.h"
#include "cvfObject.h"
#include "cafPdmField.h"
#include "cafPdmObject.h"
#include "RimCase.h"
class RimIdenticalGridCaseGroup;
class RimResultDefinition;
class RimStatisticsCaseCollection;
class RigMainGrid;
//==================================================================================================
//
//
//
//==================================================================================================
class RimStatisticsCase : public RimCase
{
CAF_PDM_HEADER_INIT;
public:
RimStatisticsCase();
virtual ~RimStatisticsCase();
void setMainGrid(RigMainGrid* mainGrid);
virtual bool openEclipseGridFile();
caf::PdmField<QString> m_resultName;
RimCaseCollection* parentStatisticsCaseCollection();
virtual void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) const;
void computeStatistics();
private:
RimIdenticalGridCaseGroup* caseGroup();
void getSourceCases(std::vector<RimCase*>& sourceCases);
};

View File

@ -0,0 +1,63 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RiaStdInclude.h"
#include "RimReservoirView.h"
#include "RimStatisticsCaseCollection.h"
#include "RimIdenticalGridCaseGroup.h"
CAF_PDM_SOURCE_INIT(RimStatisticsCaseCollection, "RimStatisticalCollection");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimStatisticsCaseCollection::RimStatisticsCaseCollection()
: PdmObject()
{
CAF_PDM_InitObject("Derived Statistics", "", "", "");
CAF_PDM_InitFieldNoDefault(&cases, "Reservoirs", "", "", "", "");
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimStatisticsCaseCollection::~RimStatisticsCaseCollection()
{
cases.deleteAllChildObjects();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimIdenticalGridCaseGroup* RimStatisticsCaseCollection::parentCaseGroup()
{
std::vector<RimIdenticalGridCaseGroup*> parentObjects;
this->parentObjectsOfType(parentObjects);
if (parentObjects.size() > 0)
{
return parentObjects[0];
}
return NULL;
}

View File

@ -0,0 +1,49 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cvfBase.h"
#include "cvfObject.h"
#include "cafPdmField.h"
#include "cafPdmObject.h"
#include "RimStatisticsCase.h"
//==================================================================================================
//
//
//
//==================================================================================================
class RimStatisticsCaseCollection : public caf::PdmObject
{
CAF_PDM_HEADER_INIT;
public:
RimStatisticsCaseCollection();
virtual ~RimStatisticsCaseCollection();
caf::PdmPointersField<RimStatisticsCase*> cases;
RimIdenticalGridCaseGroup* parentCaseGroup();
private:
};

View File

@ -0,0 +1,425 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RiaStdInclude.h"
#include "RimStatisticsCaseEvaluator.h"
#include "RigCaseCellResultsData.h"
#include "RimReservoirView.h"
#include "RimCase.h"
#include "RigCaseData.h"
//#include "RigCaseData.h"
#include <QDebug>
#include "cafProgressInfo.h"
//--------------------------------------------------------------------------------------------------
/// An internal class to do the actual computations
//--------------------------------------------------------------------------------------------------
class RimStatisticsEvaluator
{
public:
RimStatisticsEvaluator(const std::vector<double>& values)
: m_values(values),
m_min(HUGE_VAL),
m_max(-HUGE_VAL),
m_mean(HUGE_VAL),
m_dev(HUGE_VAL)
{
}
void getStatistics(double& min, double& max, double& mean, double& dev, double& range)
{
evaluate();
min = m_min;
max = m_max;
mean = m_mean;
dev = m_dev;
range = m_max - m_min;
}
private:
void evaluate()
{
double sum = 0.0;
double sumSquared = 0.0;
size_t validValueCount = 0;
for (size_t i = 0; i < m_values.size(); i++)
{
double val = m_values[i];
if (val == HUGE_VAL) continue;
validValueCount++;
if (val < m_min) m_min = val;
if (val > m_max) m_max = val;
sum += val;
sumSquared += (val * val);
}
if (validValueCount > 0)
{
m_mean = sum / validValueCount;
// http://en.wikipedia.org/wiki/Standard_deviation#Rapid_calculation_methods
// Running standard deviation
double s0 = validValueCount;
double s1 = sum;
double s2 = sumSquared;
m_dev = cvf::Math::sqrt( (s0 * s2) - (s1 * s1) ) / s0;
}
}
private:
const std::vector<double>& m_values;
double m_min;
double m_max;
double m_mean;
double m_dev;
};
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimStatisticsCaseEvaluator::addNamedResult(RigCaseCellResultsData* destinationCellResults, RimDefines::ResultCatType resultType, const QString& resultName, size_t activeUnionCellCount)
{
// Use time step dates from first result in first source case
CVF_ASSERT(m_sourceCases.size() > 0);
std::vector<QDateTime> sourceTimeStepDates = m_sourceCases[0]->results(RifReaderInterface::MATRIX_RESULTS)->cellResults()->timeStepDates(0);
size_t destinationScalarResultIndex = destinationCellResults->addEmptyScalarResult(resultType, resultName, true);
CVF_ASSERT(destinationScalarResultIndex != cvf::UNDEFINED_SIZE_T);
destinationCellResults->setTimeStepDates(destinationScalarResultIndex, sourceTimeStepDates);
std::vector< std::vector<double> >& dataValues = destinationCellResults->cellScalarResults(destinationScalarResultIndex);
dataValues.resize(sourceTimeStepDates.size());
// Initializes the size of the destination dataset to active union cell count
for (size_t i = 0; i < sourceTimeStepDates.size(); i++)
{
dataValues[i].resize(activeUnionCellCount, HUGE_VAL);
}
}
QString createResultNameMin(const QString& resultName) { return resultName + "_MIN"; }
QString createResultNameMax(const QString& resultName) { return resultName + "_MAX"; }
QString createResultNameMean(const QString& resultName) { return resultName + "_MEAN"; }
QString createResultNameDev(const QString& resultName) { return resultName + "_DEV"; }
QString createResultNameRange(const QString& resultName) { return resultName + "_RANGE"; }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimStatisticsCaseEvaluator::buildSourceMetaData(RimDefines::ResultCatType resultType, const QString& resultName)
{
if (m_sourceCases.size() == 0) return;
std::vector<QDateTime> timeStepDates = m_sourceCases[0]->results(RifReaderInterface::MATRIX_RESULTS)->cellResults()->timeStepDates(0);
for (size_t caseIdx = 1; caseIdx < m_sourceCases.size(); caseIdx++)
{
RigCaseData* eclipseCase = m_sourceCases.at(caseIdx)->reservoirData();
RimReservoirCellResultsStorage* matrixResults = m_sourceCases[caseIdx]->results(RifReaderInterface::MATRIX_RESULTS);
size_t scalarResultIndex = matrixResults->findOrLoadScalarResult(resultType, resultName);
if (scalarResultIndex == cvf::UNDEFINED_SIZE_T)
{
size_t scalarResultIndex = matrixResults->cellResults()->addEmptyScalarResult(resultType, resultName, false);
matrixResults->cellResults()->setTimeStepDates(scalarResultIndex, timeStepDates);
std::vector< std::vector<double> >& dataValues = matrixResults->cellResults()->cellScalarResults(scalarResultIndex);
dataValues.resize(timeStepDates.size());
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimStatisticsCaseEvaluator::evaluateForResults(const QList<QPair<RimDefines::ResultCatType, QString> >& resultSpecification)
{
CVF_ASSERT(m_destinationCase);
size_t activeMatrixCellCount = m_destinationCase->activeCellInfo(RifReaderInterface::MATRIX_RESULTS)->globalActiveCellCount();
RigCaseCellResultsData* matrixResults = m_destinationCase->results(RifReaderInterface::MATRIX_RESULTS);
for (int i = 0; i < resultSpecification.size(); i++)
{
RimDefines::ResultCatType resultType = resultSpecification[i].first;
QString resultName = resultSpecification[i].second;
// Special handling if SOIL is asked for
// Build SGAS/SWAT meta data, SOIL is automatically generated as part of RigCaseCellResultsData::findOrLoadScalarResultForTimeStep
if (resultName.toUpper() == "SOIL")
{
size_t swatIndex = m_sourceCases.at(0)->results(RifReaderInterface::MATRIX_RESULTS)->cellResults()->findScalarResultIndex(resultType, "SWAT");
if (swatIndex != cvf::UNDEFINED_SIZE_T)
{
buildSourceMetaData(resultType, "SWAT");
}
size_t sgasIndex = m_sourceCases.at(0)->results(RifReaderInterface::MATRIX_RESULTS)->cellResults()->findScalarResultIndex(resultType, "SGAS");
if (sgasIndex != cvf::UNDEFINED_SIZE_T)
{
buildSourceMetaData(resultType, "SGAS");
}
}
else
{
// Meta info is loaded from disk for first case only
// Build metadata for all other source cases
buildSourceMetaData(resultType, resultName);
}
QString minResultName = createResultNameMin(resultName);
QString maxResultName = createResultNameMax(resultName);
QString meanResultName = createResultNameMean(resultName);
QString devResultName = createResultNameDev(resultName);
QString rangeResultName = createResultNameRange(resultName);
if (activeMatrixCellCount > 0)
{
addNamedResult(matrixResults, resultType, minResultName, activeMatrixCellCount);
addNamedResult(matrixResults, resultType, maxResultName, activeMatrixCellCount);
addNamedResult(matrixResults, resultType, meanResultName, activeMatrixCellCount);
addNamedResult(matrixResults, resultType, devResultName, activeMatrixCellCount);
addNamedResult(matrixResults, resultType, rangeResultName, activeMatrixCellCount);
}
}
if (activeMatrixCellCount > 0)
{
caf::ProgressInfo info(m_timeStepIndices.size(), "Computing Statistics");
for (size_t timeIndicesIdx = 0; timeIndicesIdx < m_timeStepIndices.size(); timeIndicesIdx++)
{
size_t timeStepIdx = m_timeStepIndices[timeIndicesIdx];
size_t gridCount = 0;
for (size_t gridIdx = 0; gridIdx < m_destinationCase->gridCount(); gridIdx++)
{
RigGridBase* grid = m_destinationCase->grid(gridIdx);
for (int i = 0; i < resultSpecification.size(); i++)
{
RimDefines::ResultCatType resultType = resultSpecification[i].first;
QString resultName = resultSpecification[i].second;
size_t dataAccessTimeStepIndex = timeStepIdx;
// Always evaluate statistics once, and always use time step index zero
if (resultType == RimDefines::STATIC_NATIVE)
{
if (timeIndicesIdx > 0) continue;
dataAccessTimeStepIndex = 0;
}
// Build data access objects for source scalar results
cvf::Collection<cvf::StructGridScalarDataAccess> dataAccesObjectList;
for (size_t caseIdx = 0; caseIdx < m_sourceCases.size(); caseIdx++)
{
RimCase* eclipseCase = m_sourceCases.at(caseIdx);
size_t scalarResultIndex = eclipseCase->results(RifReaderInterface::MATRIX_RESULTS)->findOrLoadScalarResultForTimeStep(resultType, resultName, dataAccessTimeStepIndex);
cvf::ref<cvf::StructGridScalarDataAccess> dataAccessObject = eclipseCase->reservoirData()->dataAccessObject(grid, RifReaderInterface::MATRIX_RESULTS, dataAccessTimeStepIndex, scalarResultIndex);
if (dataAccessObject.notNull())
{
dataAccesObjectList.push_back(dataAccessObject.p());
}
}
// Build data access objects form destination scalar results
cvf::ref<cvf::StructGridScalarDataAccess> dataAccessObjectMin = NULL;
cvf::ref<cvf::StructGridScalarDataAccess> dataAccessObjectMax = NULL;
cvf::ref<cvf::StructGridScalarDataAccess> dataAccessObjectMean = NULL;
cvf::ref<cvf::StructGridScalarDataAccess> dataAccessObjectDev = NULL;
cvf::ref<cvf::StructGridScalarDataAccess> dataAccessObjectRange = NULL;
{
size_t scalarResultIndex = matrixResults->findScalarResultIndex(resultType, createResultNameMin(resultName));
if (scalarResultIndex != cvf::UNDEFINED_SIZE_T)
{
dataAccessObjectMin = m_destinationCase->dataAccessObject(grid, RifReaderInterface::MATRIX_RESULTS, dataAccessTimeStepIndex, scalarResultIndex);
}
}
{
size_t scalarResultIndex = matrixResults->findScalarResultIndex(resultType, createResultNameMax(resultName));
if (scalarResultIndex != cvf::UNDEFINED_SIZE_T)
{
dataAccessObjectMax = m_destinationCase->dataAccessObject(grid, RifReaderInterface::MATRIX_RESULTS, dataAccessTimeStepIndex, scalarResultIndex);
}
}
{
size_t scalarResultIndex = matrixResults->findScalarResultIndex(resultType, createResultNameMean(resultName));
if (scalarResultIndex != cvf::UNDEFINED_SIZE_T)
{
dataAccessObjectMean = m_destinationCase->dataAccessObject(grid, RifReaderInterface::MATRIX_RESULTS, dataAccessTimeStepIndex, scalarResultIndex);
}
}
{
size_t scalarResultIndex = matrixResults->findScalarResultIndex(resultType, createResultNameDev(resultName));
if (scalarResultIndex != cvf::UNDEFINED_SIZE_T)
{
dataAccessObjectDev = m_destinationCase->dataAccessObject(grid, RifReaderInterface::MATRIX_RESULTS, dataAccessTimeStepIndex, scalarResultIndex);
}
}
{
size_t scalarResultIndex = matrixResults->findScalarResultIndex(resultType, createResultNameRange(resultName));
if (scalarResultIndex != cvf::UNDEFINED_SIZE_T)
{
dataAccessObjectRange = m_destinationCase->dataAccessObject(grid, RifReaderInterface::MATRIX_RESULTS, dataAccessTimeStepIndex, scalarResultIndex);
}
}
double min, max, mean, dev, range;
for (size_t cellIdx = 0; cellIdx < grid->cellCount(); cellIdx++)
{
std::vector<double> values(dataAccesObjectList.size(), HUGE_VAL);
size_t globalGridCellIdx = grid->globalGridCellIndex(cellIdx);
if (m_destinationCase->activeCellInfo(RifReaderInterface::MATRIX_RESULTS)->isActive(globalGridCellIdx))
{
bool foundAnyValidValues = false;
for (size_t caseIdx = 0; caseIdx < dataAccesObjectList.size(); caseIdx++)
{
double val = dataAccesObjectList.at(caseIdx)->cellScalar(cellIdx);
values[caseIdx] = val;
if (val != HUGE_VAL)
{
foundAnyValidValues = true;
}
}
min = HUGE_VAL;
max = HUGE_VAL;
mean = HUGE_VAL;
dev = HUGE_VAL;
range = HUGE_VAL;
if (foundAnyValidValues)
{
RimStatisticsEvaluator stat(values);
stat.getStatistics(min, max, mean, dev, range);
}
if (dataAccessObjectMin.notNull())
{
dataAccessObjectMin->setCellScalar(cellIdx, min);
}
if (dataAccessObjectMax.notNull())
{
dataAccessObjectMax->setCellScalar(cellIdx, max);
}
if (dataAccessObjectMean.notNull())
{
dataAccessObjectMean->setCellScalar(cellIdx, mean);
}
if (dataAccessObjectDev.notNull())
{
dataAccessObjectDev->setCellScalar(cellIdx, dev);
}
if (dataAccessObjectRange.notNull())
{
dataAccessObjectRange->setCellScalar(cellIdx, range);
}
}
}
}
}
for (size_t caseIdx = 0; caseIdx < m_sourceCases.size(); caseIdx++)
{
RimCase* eclipseCase = m_sourceCases.at(caseIdx);
// When one time step is completed, close all result files.
// Microsoft note: On Windows, the maximum number of files open at the same time is 512
// http://msdn.microsoft.com/en-us/library/kdfaxaay%28vs.71%29.aspx
//
eclipseCase->results(RifReaderInterface::MATRIX_RESULTS)->readerInterface()->close();
}
info.setProgress(timeIndicesIdx);
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimStatisticsCaseEvaluator::debugOutput(RimDefines::ResultCatType resultType, const QString& resultName, size_t timeStepIdx)
{
CVF_ASSERT(m_destinationCase);
qDebug() << resultName << "timeIdx : " << timeStepIdx;
size_t scalarResultIndex = m_destinationCase->results(RifReaderInterface::MATRIX_RESULTS)->findScalarResultIndex(resultType, resultName);
cvf::ref<cvf::StructGridScalarDataAccess> dataAccessObject = m_destinationCase->dataAccessObject(m_destinationCase->mainGrid(), RifReaderInterface::MATRIX_RESULTS, timeStepIdx, scalarResultIndex);
if (dataAccessObject.isNull()) return;
for (size_t cellIdx = 0; cellIdx < m_globalCellCount; cellIdx++)
{
qDebug() << dataAccessObject->cellScalar(cellIdx);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimStatisticsCaseEvaluator::RimStatisticsCaseEvaluator(const std::vector<RimCase*>& sourceCases, const std::vector<size_t>& timeStepIndices, const RimStatisticsConfig& statisticsConfig, RigCaseData* destinationCase)
: m_sourceCases(sourceCases),
m_statisticsConfig(statisticsConfig),
m_destinationCase(destinationCase),
m_globalCellCount(0),
m_timeStepIndices(timeStepIndices)
{
if (sourceCases.size() > 0)
{
m_globalCellCount = sourceCases[0]->reservoirData()->mainGrid()->cells().size();
}
CVF_ASSERT(m_destinationCase);
}

View File

@ -0,0 +1,79 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cvfBase.h"
#include "cvfObject.h"
#include "cvfCollection.h"
#include <vector>
#include <math.h>
#include <QPair>
#include "RimDefines.h"
class RimCase;
class RigCaseData;
class RigCaseCellResultsData;
class RimStatisticsConfig
{
public:
RimStatisticsConfig()
: m_min(true),
m_max(true),
m_mean(true),
m_stdDev(true)
{
}
public:
bool m_min;
bool m_max;
bool m_mean;
bool m_stdDev;
};
class RimStatisticsCaseEvaluator
{
public:
RimStatisticsCaseEvaluator(const std::vector<RimCase*>& sourceCases,
const std::vector<size_t>& timeStepIndices,
const RimStatisticsConfig& statisticsConfig,
RigCaseData* destinationCase);
void evaluateForResults(const QList<QPair<RimDefines::ResultCatType, QString> >& resultSpecification);
void debugOutput(RimDefines::ResultCatType resultType, const QString& resultName, size_t timeStepIdx);
private:
void addNamedResult(RigCaseCellResultsData* cellResults, RimDefines::ResultCatType resultType, const QString& resultName, size_t activeCellCount);
void buildSourceMetaData(RimDefines::ResultCatType resultType, const QString& resultName);
private:
std::vector<RimCase*> m_sourceCases;
std::vector<size_t> m_timeStepIndices;
size_t m_globalCellCount;
RimStatisticsConfig m_statisticsConfig;
RigCaseData* m_destinationCase;
};

View File

@ -16,7 +16,7 @@
//
/////////////////////////////////////////////////////////////////////////////////
#include "RIStdInclude.h"
#include "RiaStdInclude.h"
#include "RimUiTreeModelPdm.h"
#include "RimCellRangeFilter.h"
@ -27,14 +27,16 @@
#include "RimCellPropertyFilterCollection.h"
#include "RimReservoirView.h"
#include "RIViewer.h"
#include "RiuViewer.h"
#include "RimCalcScript.h"
#include "RIApplication.h"
#include "RIMainWindow.h"
#include "RiaApplication.h"
#include "RiuMainWindow.h"
#include "RimInputProperty.h"
#include "RimInputPropertyCollection.h"
#include "cafPdmField.h"
#include "RimInputReservoir.h"
#include "RimInputCase.h"
#include "RimStatisticsCase.h"
#include "RimResultCase.h"
//--------------------------------------------------------------------------------------------------
///
@ -49,9 +51,9 @@ RimUiTreeModelPdm::RimUiTreeModelPdm(QObject* parent)
}
//--------------------------------------------------------------------------------------------------
///
/// TO BE DELETED
//--------------------------------------------------------------------------------------------------
bool RimUiTreeModelPdm::insertRows(int position, int rows, const QModelIndex &parent /*= QModelIndex()*/)
bool RimUiTreeModelPdm::insertRows_special(int position, int rows, const QModelIndex &parent /*= QModelIndex()*/)
{
caf::PdmUiTreeItem* parentItem = getTreeItemFromIndex(parent);
@ -124,7 +126,7 @@ bool RimUiTreeModelPdm::deletePropertyFilter(const QModelIndex& itemIndex)
bool wasSomeFilterActive = propertyFilterCollection->hasActiveFilters();
// Remove Ui items pointing at the pdm object to delete
removeRow(itemIndex.row(), itemIndex.parent());
removeRows_special(itemIndex.row(), 1, itemIndex.parent());
propertyFilterCollection->remove(propertyFilter);
delete propertyFilter;
@ -138,6 +140,9 @@ bool RimUiTreeModelPdm::deletePropertyFilter(const QModelIndex& itemIndex)
{
propertyFilterCollection->reservoirView()->createDisplayModelAndRedraw();
}
clearClipboard();
return true;
}
@ -161,7 +166,7 @@ bool RimUiTreeModelPdm::deleteRangeFilter(const QModelIndex& itemIndex)
bool wasSomeFilterActive = rangeFilterCollection->hasActiveFilters();
// Remove Ui items pointing at the pdm object to delete
removeRow(itemIndex.row(), itemIndex.parent());
removeRows_special(itemIndex.row(), 1, itemIndex.parent());
rangeFilterCollection->remove(rangeFilter);
delete rangeFilter;
@ -176,6 +181,8 @@ bool RimUiTreeModelPdm::deleteRangeFilter(const QModelIndex& itemIndex)
rangeFilterCollection->reservoirView()->createDisplayModelAndRedraw();
}
clearClipboard();
return true;
}
@ -193,34 +200,51 @@ bool RimUiTreeModelPdm::deleteReservoirView(const QModelIndex& itemIndex)
CVF_ASSERT(reservoirView);
// Remove Ui items pointing at the pdm object to delete
removeRow(itemIndex.row(), itemIndex.parent());
removeRows_special(itemIndex.row(), 1, itemIndex.parent());
reservoirView->eclipseCase()->removeReservoirView(reservoirView);
delete reservoirView;
clearClipboard();
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimUiTreeModelPdm::deleteReservoir(const QModelIndex& itemIndex)
void RimUiTreeModelPdm::deleteReservoir(RimCase* reservoir)
{
CVF_ASSERT(itemIndex.isValid());
RimCaseCollection* caseCollection = reservoir->parentCaseCollection();
QModelIndex caseCollectionModelIndex = getModelIndexFromPdmObject(caseCollection);
if (!caseCollectionModelIndex.isValid()) return;
caf::PdmUiTreeItem* uiItem = getTreeItemFromIndex(itemIndex);
CVF_ASSERT(uiItem);
QModelIndex mi = getModelIndexFromPdmObjectRecursive(caseCollectionModelIndex, reservoir);
if (mi.isValid())
{
caf::PdmUiTreeItem* uiItem = getTreeItemFromIndex(mi);
CVF_ASSERT(uiItem);
RimReservoir* reservoir = dynamic_cast<RimReservoir*>(uiItem->dataObject().p());
CVF_ASSERT(reservoir);
// Remove Ui items pointing at the pdm object to delete
removeRows_special(mi.row(), 1, mi.parent());
}
// Remove Ui items pointing at the pdm object to delete
removeRow(itemIndex.row(), itemIndex.parent());
if (RimIdenticalGridCaseGroup::isStatisticsCaseCollection(caseCollection))
{
RimIdenticalGridCaseGroup* caseGroup = caseCollection->parentCaseGroup();
CVF_ASSERT(caseGroup);
RimProject* proj = RIApplication::instance()->project();
proj->reservoirs().removeChildObject(reservoir);
caseGroup->statisticsCaseCollection()->reservoirs.removeChildObject(reservoir);
}
else
{
RimProject* proj = RiaApplication::instance()->project();
proj->removeCaseFromAllGroups(reservoir);
}
delete reservoir;
clearClipboard();
}
//--------------------------------------------------------------------------------------------------
@ -322,24 +346,40 @@ RimReservoirView* RimUiTreeModelPdm::addReservoirView(const QModelIndex& itemInd
caf::PdmUiTreeItem* currentItem = getTreeItemFromIndex(itemIndex);
if (!currentItem) return NULL;
RimReservoirView* reservoirView = dynamic_cast<RimReservoirView*>(currentItem->dataObject().p());
if (!reservoirView) return NULL;
caf::PdmUiTreeItem* collectionItem = NULL;
RimReservoirView* insertedView = reservoirView->eclipseCase()->createAndAddReservoirView();
caf::PdmUiTreeItem* collectionItem = currentItem->parent();
bool itemIndexIsCollection = false;
QModelIndex collectionIndex;
if (dynamic_cast<RimReservoirView*>(currentItem->dataObject().p()))
{
collectionItem = currentItem->parent();
collectionIndex = itemIndex.parent();
}
else if (dynamic_cast<RimCase*>(currentItem->dataObject().p()))
{
collectionItem = currentItem;
collectionIndex = itemIndex;
}
int viewCount = rowCount(itemIndex.parent());
beginInsertRows(itemIndex.parent(), viewCount, viewCount);
if (collectionItem)
{
RimCase* rimReservoir = dynamic_cast<RimCase*>(collectionItem->dataObject().p());
RimReservoirView* insertedView = rimReservoir->createAndAddReservoirView();
caf::PdmUiTreeItem* childItem = new caf::PdmUiTreeItem(collectionItem, viewCount, insertedView);
int viewCount = rowCount(collectionIndex);
beginInsertRows(collectionIndex, viewCount, viewCount);
endInsertRows();
// NOTE: -1 as second argument indicates append
caf::PdmUiTreeItem* childItem = caf::UiTreeItemBuilderPdm::buildViewItems(collectionItem, -1, insertedView);
endInsertRows();
insertedView->loadDataAndUpdate();
insertedView->loadDataAndUpdate();
rebuildUiSubTree(insertedView);
return insertedView;
return insertedView;
}
return NULL;
}
@ -348,7 +388,7 @@ RimReservoirView* RimUiTreeModelPdm::addReservoirView(const QModelIndex& itemInd
//--------------------------------------------------------------------------------------------------
void RimUiTreeModelPdm::updateScriptPaths()
{
RimProject* proj = RIApplication::instance()->project();
RimProject* proj = RiaApplication::instance()->project();
if (!proj || !proj->scriptCollection()) return;
@ -368,7 +408,7 @@ void RimUiTreeModelPdm::updateScriptPaths()
//--------------------------------------------------------------------------------------------------
void RimUiTreeModelPdm::slotRefreshScriptTree(QString path)
{
RimProject* proj = RIApplication::instance()->project();
RimProject* proj = RiaApplication::instance()->project();
if (!proj || !proj->scriptCollection()) return;
@ -390,13 +430,11 @@ void RimUiTreeModelPdm::addInputProperty(const QModelIndex& itemIndex, const QSt
RimInputPropertyCollection* inputPropertyCollection = dynamic_cast<RimInputPropertyCollection*>(currentItem->dataObject().p());
CVF_ASSERT(inputPropertyCollection);
std::vector<caf::PdmObject*> parentObjects;
inputPropertyCollection->parentObjects(parentObjects);
std::vector<RimInputCase*> parentObjects;
inputPropertyCollection->parentObjectsOfType(parentObjects);
CVF_ASSERT(parentObjects.size() == 1);
RimInputReservoir* inputReservoir = dynamic_cast<RimInputReservoir*>(parentObjects[0]);
RimInputCase* inputReservoir = parentObjects[0];
CVF_ASSERT(inputReservoir);
if (inputReservoir)
{
@ -421,24 +459,361 @@ void RimUiTreeModelPdm::deleteInputProperty(const QModelIndex& itemIndex)
if (!inputProperty) return;
// Remove item from UI tree model before delete of project data structure
removeRow(itemIndex.row(), itemIndex.parent());
removeRows_special(itemIndex.row(), 1, itemIndex.parent());
std::vector<caf::PdmObject*> parentObjects;
object->parentObjects(parentObjects);
std::vector<RimInputPropertyCollection*> parentObjects;
object->parentObjectsOfType(parentObjects);
CVF_ASSERT(parentObjects.size() == 1);
RimInputPropertyCollection* inputPropertyCollection = dynamic_cast<RimInputPropertyCollection*>(parentObjects[0]);
RimInputPropertyCollection* inputPropertyCollection = parentObjects[0];
if (!inputPropertyCollection) return;
std::vector<caf::PdmObject*> parentObjects2;
inputPropertyCollection->parentObjects(parentObjects2);
std::vector<RimInputCase*> parentObjects2;
inputPropertyCollection->parentObjectsOfType(parentObjects2);
CVF_ASSERT(parentObjects2.size() == 1);
RimInputReservoir* inputReservoir = dynamic_cast<RimInputReservoir*>(parentObjects2[0]);
RimInputCase* inputReservoir = parentObjects2[0];
if (!inputReservoir) return;
inputReservoir->removeProperty(inputProperty);
delete inputProperty;
clearClipboard();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimStatisticsCase* RimUiTreeModelPdm::addStatisticalCalculation(const QModelIndex& itemIndex, QModelIndex& insertedModelIndex)
{
caf::PdmUiTreeItem* currentItem = getTreeItemFromIndex(itemIndex);
QModelIndex collectionIndex;
RimIdenticalGridCaseGroup* caseGroup = NULL;
caf::PdmUiTreeItem* parentCollectionItem = NULL;
int position = 0;
if (dynamic_cast<RimStatisticsCase*>(currentItem->dataObject().p()))
{
RimStatisticsCase* currentObject = dynamic_cast<RimStatisticsCase*>(currentItem->dataObject().p());
caseGroup = currentObject->parentStatisticsCaseCollection()->parentCaseGroup();
parentCollectionItem = currentItem->parent();
position = itemIndex.row();
collectionIndex = itemIndex.parent();
}
else if (dynamic_cast<RimCaseCollection*>(currentItem->dataObject().p()))
{
RimCaseCollection* statColl = dynamic_cast<RimCaseCollection*>(currentItem->dataObject().p());
caseGroup = statColl->parentCaseGroup();
parentCollectionItem = currentItem;
position = parentCollectionItem->childCount();
collectionIndex = itemIndex;
}
if (parentCollectionItem && caseGroup)
{
beginInsertRows(collectionIndex, position, position);
RimStatisticsCase* createdObject = caseGroup->createAndAppendStatisticsCase();
caf::PdmUiTreeItem* childItem = new caf::PdmUiTreeItem(parentCollectionItem, position, createdObject);
endInsertRows();
insertedModelIndex = index(position, 0, collectionIndex);
return createdObject;
}
else
{
return NULL;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimIdenticalGridCaseGroup* RimUiTreeModelPdm::addCaseGroup(const QModelIndex& itemIndex, QModelIndex& insertedModelIndex)
{
RimProject* proj = RiaApplication::instance()->project();
CVF_ASSERT(proj);
caf::PdmUiTreeItem* currentItem = getTreeItemFromIndex(itemIndex);
if (dynamic_cast<RimIdenticalGridCaseGroup*>(currentItem->dataObject().p()) ||
dynamic_cast<RimCase*>(currentItem->dataObject().p()))
{
QModelIndex rootIndex = itemIndex.parent();
caf::PdmUiTreeItem* rootTreeItem = currentItem->parent();
// New case group is inserted before the last item, the script item
int position = rootTreeItem->childCount() - 1;
beginInsertRows(rootIndex, position, position);
RimIdenticalGridCaseGroup* createdObject = new RimIdenticalGridCaseGroup;
proj->caseGroups().push_back(createdObject);
caf::PdmUiTreeItem* childItem = caf::UiTreeItemBuilderPdm::buildViewItems(rootTreeItem, position, createdObject);
endInsertRows();
insertedModelIndex = index(position, 0, rootIndex);
return createdObject;
}
return NULL;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimUiTreeModelPdm::addObjects(const QModelIndex& itemIndex, caf::PdmObjectGroup& pdmObjects)
{
RimProject* proj = RiaApplication::instance()->project();
CVF_ASSERT(proj);
caf::PdmUiTreeItem* currentItem = getTreeItemFromIndex(itemIndex);
RimIdenticalGridCaseGroup* gridCaseGroup = NULL;
RimCaseCollection* caseCollection = NULL;
if (dynamic_cast<RimIdenticalGridCaseGroup*>(currentItem->dataObject().p()))
{
gridCaseGroup = dynamic_cast<RimIdenticalGridCaseGroup*>(currentItem->dataObject().p());
caseCollection = gridCaseGroup->caseCollection();
}
else if (dynamic_cast<RimCaseCollection*>(currentItem->dataObject().p()))
{
caseCollection = dynamic_cast<RimCaseCollection*>(currentItem->dataObject().p());
CVF_ASSERT(caseCollection);
gridCaseGroup = caseCollection->parentCaseGroup();
}
else if (dynamic_cast<RimCase*>(currentItem->dataObject().p()))
{
RimCase* rimReservoir = dynamic_cast<RimCase*>(currentItem->dataObject().p());
CVF_ASSERT(rimReservoir);
caseCollection = rimReservoir->parentCaseCollection();
if (caseCollection)
{
gridCaseGroup = caseCollection->parentCaseGroup();
}
}
else
{
return;
}
if (gridCaseGroup)
{
std::vector<caf::PdmPointer<RimResultCase> > typedObjects;
pdmObjects.createCopyByType(&typedObjects);
RigCaseData* mainEclipseCase = NULL;
if (gridCaseGroup->caseCollection()->reservoirs().size() > 0)
{
RimCase* mainReservoir = gridCaseGroup->caseCollection()->reservoirs()[0];;
mainEclipseCase = mainReservoir->reservoirData();
}
for (size_t i = 0; i < typedObjects.size(); i++)
{
RimResultCase* rimResultReservoir = typedObjects[i];
if (gridCaseGroup->contains(rimResultReservoir))
{
continue;
}
if (gridCaseGroup->mainGrid() == NULL)
{
rimResultReservoir->openEclipseGridFile();
mainEclipseCase = rimResultReservoir->reservoirData();
}
else
{
if (!rimResultReservoir->openAndReadActiveCellData(mainEclipseCase))
{
CVF_ASSERT(false);
}
}
proj->insertCaseInCaseGroup(gridCaseGroup, rimResultReservoir);
caf::PdmObjectGroup::initAfterReadTraversal(rimResultReservoir);
{
QModelIndex rootIndex = getModelIndexFromPdmObject(caseCollection);
caf::PdmUiTreeItem* caseCollectionUiItem = getTreeItemFromIndex(rootIndex);
int position = rowCount(rootIndex);
beginInsertRows(rootIndex, position, position);
caf::PdmUiTreeItem* childItem = caf::UiTreeItemBuilderPdm::buildViewItems(caseCollectionUiItem, -1, rimResultReservoir);
endInsertRows();
}
for (size_t i = 0; i < rimResultReservoir->reservoirViews.size(); i++)
{
RimReservoirView* riv = rimResultReservoir->reservoirViews()[i];
riv->loadDataAndUpdate();
}
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimUiTreeModelPdm::deleteObjectFromPdmPointersField(const QModelIndex& itemIndex)
{
if (!itemIndex.isValid())
{
return false;
}
caf::PdmUiTreeItem* currentItem = getTreeItemFromIndex(itemIndex);
CVF_ASSERT(currentItem);
caf::PdmObject* currentPdmObject = currentItem->dataObject().p();
CVF_ASSERT(currentPdmObject);
std::vector<caf::PdmFieldHandle*> parentFields;
currentPdmObject->parentFields(parentFields);
if (parentFields.size() == 1)
{
beginRemoveRows(itemIndex.parent(), itemIndex.row(), itemIndex.row());
if (currentItem->parent())
{
currentItem->parent()->removeChildren(itemIndex.row(), 1);
}
endRemoveRows();
caf::PdmPointersField<RimIdenticalGridCaseGroup*>* caseGroup = dynamic_cast<caf::PdmPointersField<RimIdenticalGridCaseGroup*> *>(parentFields[0]);
if (caseGroup)
{
caseGroup->removeChildObject(currentPdmObject);
delete currentPdmObject;
}
}
clearClipboard();
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimUiTreeModelPdm::clearClipboard()
{
// We use QModelIndex to identify a selection on the clipboard
// When we delete or move an entity, the clipboard data might be invalid
QClipboard* clipboard = QApplication::clipboard();
if (clipboard)
{
if (dynamic_cast<const MimeDataWithIndexes*>(clipboard->mimeData()))
{
clipboard->clear();
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Qt::DropActions RimUiTreeModelPdm::supportedDropActions() const
{
return Qt::CopyAction | Qt::MoveAction;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Qt::ItemFlags RimUiTreeModelPdm::flags(const QModelIndex &index) const
{
Qt::ItemFlags defaultFlags = caf::UiTreeModelPdm::flags(index);
if (index.isValid())
{
caf::PdmUiTreeItem* currentItem = getTreeItemFromIndex(index);
CVF_ASSERT(currentItem);
CVF_ASSERT(currentItem->dataObject().p());
if (dynamic_cast<RimIdenticalGridCaseGroup*>(currentItem->dataObject().p()) ||
dynamic_cast<RimCaseCollection*>(currentItem->dataObject().p()))
{
return Qt::ItemIsDropEnabled | defaultFlags;
}
else if (dynamic_cast<RimCase*>(currentItem->dataObject().p()))
{
// TODO: Remember to handle reservoir holding the main grid
return Qt::ItemIsDragEnabled | defaultFlags;
}
}
return defaultFlags;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimUiTreeModelPdm::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)
{
const MimeDataWithIndexes* myMimeData = qobject_cast<const MimeDataWithIndexes*>(data);
if (myMimeData && parent.isValid())
{
caf::PdmObjectGroup pog;
for (int i = 0; i < myMimeData->indexes().size(); i++)
{
QModelIndex mi = myMimeData->indexes().at(i);
caf::PdmUiTreeItem* currentItem = getTreeItemFromIndex(mi);
caf::PdmObject* pdmObj = currentItem->dataObject().p();
pog.objects().push_back(pdmObj);
}
addObjects(parent, pog);
if (action == Qt::MoveAction)
{
std::vector<caf::PdmPointer<RimResultCase> > typedObjects;
pog.objectsByType(&typedObjects);
for (size_t i = 0; i < typedObjects.size(); i++)
{
RimCase* rimReservoir = typedObjects[i];
deleteReservoir(rimReservoir);
}
}
return true;
}
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QMimeData* RimUiTreeModelPdm::mimeData(const QModelIndexList &indexes) const
{
MimeDataWithIndexes* myObj = new MimeDataWithIndexes();
myObj->setIndexes(indexes);
return myObj;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QStringList RimUiTreeModelPdm::mimeTypes() const
{
QStringList types;
types << MimeDataWithIndexes::formatName();
return types;
}

View File

@ -20,15 +20,71 @@
#include "cafPdmObject.h"
#include "cafPdmPointer.h"
#include "cafPdmDocument.h"
#include "cafUiTreeModelPdm.h"
#include <QMimeData>
class QFileSystemWatcher;
class RimCellPropertyFilter;
class RimCellRangeFilter;
class RimCase;
class RimReservoirView;
class RimInputProperty;
class RimStatisticsCase;
class RimIdenticalGridCaseGroup;
//--------------------------------------------------------------------------------------------------
/// MimeData class used to carry a QModelIndexList
//--------------------------------------------------------------------------------------------------
class MimeDataWithIndexes : public QMimeData
{
Q_OBJECT
public:
MimeDataWithIndexes()
{
}
MimeDataWithIndexes(const MimeDataWithIndexes & other) : QMimeData()
{
setIndexes(other.indexes());
}
void setIndexes(const QModelIndexList & indexes)
{
m_indexes = indexes;
}
const QModelIndexList& indexes() const { return m_indexes; }
virtual bool hasFormat( const QString &mimetype ) const
{
return (mimetype == formatName());
}
virtual QStringList formats() const
{
QStringList supportedFormats = QMimeData::formats();
supportedFormats << formatName();
return supportedFormats;
}
static QString formatName()
{
return "MimeDataWithIndexes";
}
private:
QModelIndexList m_indexes;
};
Q_DECLARE_METATYPE(MimeDataWithIndexes)
//==================================================================================================
///
///
@ -40,31 +96,43 @@ class RimUiTreeModelPdm : public caf::UiTreeModelPdm
public:
RimUiTreeModelPdm(QObject* parent);
// Overrides
virtual bool insertRows(int position, int rows, const QModelIndex &parent = QModelIndex());
// TO BE DELETED, NOT USED
virtual bool insertRows_special(int position, int rows, const QModelIndex &parent = QModelIndex());
// Special edit methods
bool deleteRangeFilter(const QModelIndex& itemIndex);
bool deletePropertyFilter(const QModelIndex& itemIndex);
bool deleteReservoirView(const QModelIndex& itemIndex);
void deleteInputProperty(const QModelIndex& itemIndex);
void deleteReservoir(const QModelIndex& itemIndex);
bool deleteRangeFilter(const QModelIndex& itemIndex);
bool deletePropertyFilter(const QModelIndex& itemIndex);
bool deleteReservoirView(const QModelIndex& itemIndex);
void deleteInputProperty(const QModelIndex& itemIndex);
void deleteReservoir(RimCase* reservoir);
RimCellPropertyFilter* addPropertyFilter(const QModelIndex& itemIndex, QModelIndex& insertedModelIndex);
RimCellRangeFilter* addRangeFilter(const QModelIndex& itemIndex, QModelIndex& insertedModelIndex);
RimReservoirView* addReservoirView(const QModelIndex& itemIndex, QModelIndex& insertedModelIndex);
void addInputProperty(const QModelIndex& itemIndex, const QStringList& fileNames);
RimCellPropertyFilter* addPropertyFilter(const QModelIndex& itemIndex, QModelIndex& insertedModelIndex);
RimCellRangeFilter* addRangeFilter(const QModelIndex& itemIndex, QModelIndex& insertedModelIndex);
RimReservoirView* addReservoirView(const QModelIndex& itemIndex, QModelIndex& insertedModelIndex);
void addInputProperty(const QModelIndex& itemIndex, const QStringList& fileNames);
void addObjects(const QModelIndex& itemIndex, caf::PdmObjectGroup& pdmObjects);
RimStatisticsCase* addStatisticalCalculation(const QModelIndex& itemIndex, QModelIndex& insertedModelIndex);
RimIdenticalGridCaseGroup* addCaseGroup(const QModelIndex& itemIndex, QModelIndex& insertedModelIndex);
void updateScriptPaths();
bool deleteObjectFromPdmPointersField(const QModelIndex& itemIndex);
void updateScriptPaths();
virtual Qt::DropActions supportedDropActions() const;
virtual Qt::ItemFlags flags(const QModelIndex &index) const;
virtual bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent);
virtual QMimeData* mimeData(const QModelIndexList &indexes) const;
virtual QStringList mimeTypes() const;
private slots:
void slotRefreshScriptTree(QString path);
void slotRefreshScriptTree(QString path);
private:
QFileSystemWatcher* m_scriptChangeDetector;
void clearClipboard();
private:
QFileSystemWatcher* m_scriptChangeDetector;
};

View File

@ -16,21 +16,25 @@
//
/////////////////////////////////////////////////////////////////////////////////
#include "RIStdInclude.h"
#include "RiaStdInclude.h"
#include "cafPdmDocument.h"
#include "RimUiTreeView.h"
#include "RimUiTreeModelPdm.h"
#include "RimReservoirView.h"
#include "RimCalcScript.h"
#include "RIApplication.h"
#include "RIMainWindow.h"
#include "RiaApplication.h"
#include "RiuMainWindow.h"
#include "RimInputPropertyCollection.h"
#include "RimExportInputPropertySettings.h"
#include "RIPreferencesDialog.h"
#include "RiuPreferencesDialog.h"
#include "RifEclipseInputFileTools.h"
#include "RimInputReservoir.h"
#include "RimInputCase.h"
#include "RimBinaryExportSettings.h"
#include "RigReservoirCellResults.h"
#include "RigCaseCellResultsData.h"
#include "RimStatisticsCase.h"
#include "RimResultCase.h"
//--------------------------------------------------------------------------------------------------
///
@ -39,6 +43,16 @@ RimUiTreeView::RimUiTreeView(QWidget *parent /*= 0*/)
: QTreeView(parent)
{
setHeaderHidden(true);
m_pasteAction = new QAction(QString("Paste"), this);
connect(m_pasteAction, SIGNAL(triggered()), SLOT(slotPastePdmObjects()));
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimUiTreeView::~RimUiTreeView()
{
}
//--------------------------------------------------------------------------------------------------
@ -46,12 +60,15 @@ RimUiTreeView::RimUiTreeView(QWidget *parent /*= 0*/)
//--------------------------------------------------------------------------------------------------
void RimUiTreeView::contextMenuEvent(QContextMenuEvent* event)
{
m_pasteAction->setEnabled(hasClipboardValidData());
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
if (myModel)
{
caf::PdmUiTreeItem* uiItem = myModel->getTreeItemFromIndex(currentIndex());
if (uiItem && uiItem->dataObject())
{
// Range filters
if (dynamic_cast<RimReservoirView*>(uiItem->dataObject().p()))
{
@ -100,7 +117,7 @@ void RimUiTreeView::contextMenuEvent(QContextMenuEvent* event)
}
else if (dynamic_cast<RimCalcScript*>(uiItem->dataObject().p()))
{
RIApplication* app = RIApplication::instance();
RiaApplication* app = RiaApplication::instance();
QMenu menu;
{
@ -143,12 +160,52 @@ void RimUiTreeView::contextMenuEvent(QContextMenuEvent* event)
menu.addAction(QString("Save Property To File"), this, SLOT(slotWriteBinaryResultAsInputProperty()));
menu.exec(event->globalPos());
}
else if (dynamic_cast<RimReservoir*>(uiItem->dataObject().p()))
else if (dynamic_cast<RimStatisticsCaseCollection*>(uiItem->dataObject().p()))
{
QMenu menu;
menu.addAction(QString("New Statistcs Case"), this, SLOT(slotNewStatisticsCase()));
menu.exec(event->globalPos());
}
else if (dynamic_cast<RimStatisticsCase*>(uiItem->dataObject().p()))
{
QMenu menu;
menu.addAction(QString("New View"), this, SLOT(slotAddView()));
menu.addAction(QString("Compute"), this, SLOT(slotComputeStatistics()));
menu.addAction(QString("Close"), this, SLOT(slotCloseCase()));
menu.exec(event->globalPos());
}
else if (dynamic_cast<RimCase*>(uiItem->dataObject().p()))
{
QMenu menu;
menu.addAction(QString("Copy"), this, SLOT(slotCopyPdmObjectToClipboard()));
menu.addAction(m_pasteAction);
menu.addAction(QString("Close"), this, SLOT(slotCloseCase()));
menu.addAction(QString("New View"), this, SLOT(slotAddView()));
menu.addAction(QString("New Grid Case Group"), this, SLOT(slotAddCaseGroup()));
menu.exec(event->globalPos());
}
else if (dynamic_cast<RimIdenticalGridCaseGroup*>(uiItem->dataObject().p()))
{
QMenu menu;
menu.addAction(QString("New Grid Case Group"), this, SLOT(slotAddCaseGroup()));
menu.addAction(m_pasteAction);
menu.addAction(QString("Close"), this, SLOT(slotDeleteObjectFromPdmPointersField()));
menu.exec(event->globalPos());
}
else if (dynamic_cast<RimCaseCollection*>(uiItem->dataObject().p()))
{
QMenu menu;
menu.addAction(m_pasteAction);
// Check if parent field is a StatisticsCaseCollection
RimCaseCollection* rimCaseCollection = dynamic_cast<RimCaseCollection*>(uiItem->dataObject().p());
if (RimIdenticalGridCaseGroup::isStatisticsCaseCollection(rimCaseCollection))
{
menu.addAction(QString("New Statistics Case"), this, SLOT(slotNewStatisticsCase()));
}
menu.exec(event->globalPos());
}
}
}
}
@ -368,7 +425,7 @@ void RimUiTreeView::slotEditScript()
{
RimCalcScript* calcScript = dynamic_cast<RimCalcScript*>(uiItem->dataObject().p());
RIApplication* app = RIApplication::instance();
RiaApplication* app = RiaApplication::instance();
QString scriptEditor = app->scriptEditorPath();
if (!scriptEditor.isEmpty())
{
@ -380,7 +437,7 @@ void RimUiTreeView::slotEditScript()
if (!myProcess->waitForStarted(1000))
{
QMessageBox::warning(RIMainWindow::instance(), "Script editor", "Failed to start script editor executable\n" + scriptEditor);
QMessageBox::warning(RiuMainWindow::instance(), "Script editor", "Failed to start script editor executable\n" + scriptEditor);
}
}
}
@ -425,7 +482,7 @@ void RimUiTreeView::slotNewScript()
num++;
}
RIApplication* app = RIApplication::instance();
RiaApplication* app = RiaApplication::instance();
QString scriptEditor = app->scriptEditorPath();
if (!scriptEditor.isEmpty())
{
@ -437,7 +494,7 @@ void RimUiTreeView::slotNewScript()
if (!myProcess->waitForStarted(1000))
{
QMessageBox::warning(RIMainWindow::instance(), "Script editor", "Failed to start script editor executable\n" + scriptEditor);
QMessageBox::warning(RiuMainWindow::instance(), "Script editor", "Failed to start script editor executable\n" + scriptEditor);
}
}
}
@ -455,7 +512,7 @@ void RimUiTreeView::slotExecuteScript()
{
RimCalcScript* calcScript = dynamic_cast<RimCalcScript*>(uiItem->dataObject().p());
RIApplication* app = RIApplication::instance();
RiaApplication* app = RiaApplication::instance();
QString octavePath = app->octavePath();
if (!octavePath.isEmpty())
{
@ -482,7 +539,7 @@ void RimUiTreeView::slotExecuteScript()
arguments.append("-q");
arguments << calcScript->absolutePath();
RIApplication::instance()->launchProcess(octavePath, arguments);
RiaApplication::instance()->launchProcess(octavePath, arguments);
}
}
}
@ -496,12 +553,8 @@ void RimUiTreeView::slotAddView()
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
caf::PdmUiTreeItem* uiItem = myModel->getTreeItemFromIndex(currentIndex());
RimReservoirView* rimView = dynamic_cast<RimReservoirView*>(uiItem->dataObject().p());
if (rimView)
{
QModelIndex insertedIndex;
myModel->addReservoirView(index, insertedIndex);
}
QModelIndex insertedIndex;
myModel->addReservoirView(index, insertedIndex);
}
@ -515,7 +568,7 @@ void RimUiTreeView::slotDeleteView()
{
myModel->deleteReservoirView(currentIndex());
RIApplication* app = RIApplication::instance();
RiaApplication* app = RiaApplication::instance();
app->setActiveReservoirView(NULL);
}
}
@ -565,7 +618,7 @@ void RimUiTreeView::setModel(QAbstractItemModel* model)
//--------------------------------------------------------------------------------------------------
void RimUiTreeView::slotAddInputProperty()
{
RIApplication* app = RIApplication::instance();
RiaApplication* app = RiaApplication::instance();
QString defaultDir = app->defaultFileDialogDirectory("INPUT_FILES");
QStringList fileNames = QFileDialog::getOpenFileNames(this, "Select Eclipse Input Property Files", defaultDir, "All Files (*.* *)");
@ -623,7 +676,7 @@ void RimUiTreeView::slotWriteInputProperty()
if (!isResolved)
{
QMessageBox::warning(RIMainWindow::instance(), "Export failure", "Property is not resolved, and then it is not possible to export the property.");
QMessageBox::warning(RiuMainWindow::instance(), "Export failure", "Property is not resolved, and then it is not possible to export the property.");
return;
}
@ -633,20 +686,20 @@ void RimUiTreeView::slotWriteInputProperty()
exportSettings.eclipseKeyword = inputProperty->eclipseKeyword;
// Find input reservoir for this property
RimInputReservoir* inputReservoir = NULL;
RimInputCase* inputReservoir = NULL;
{
std::vector<caf::PdmObject*> parentObjects;
inputProperty->parentObjects(parentObjects);
std::vector<RimInputPropertyCollection*> parentObjects;
inputProperty->parentObjectsOfType(parentObjects);
CVF_ASSERT(parentObjects.size() == 1);
RimInputPropertyCollection* inputPropertyCollection = dynamic_cast<RimInputPropertyCollection*>(parentObjects[0]);
RimInputPropertyCollection* inputPropertyCollection = parentObjects[0];
if (!inputPropertyCollection) return;
std::vector<caf::PdmObject*> parentObjects2;
inputPropertyCollection->parentObjects(parentObjects2);
std::vector<RimInputCase*> parentObjects2;
inputPropertyCollection->parentObjectsOfType(parentObjects2);
CVF_ASSERT(parentObjects2.size() == 1);
inputReservoir = dynamic_cast<RimInputReservoir*>(parentObjects2[0]);
inputReservoir = parentObjects2[0];
}
if (!inputReservoir) return;
@ -654,7 +707,7 @@ void RimUiTreeView::slotWriteInputProperty()
{
QString projectFolder;
RIApplication* app = RIApplication::instance();
RiaApplication* app = RiaApplication::instance();
QString projectFileName = app->currentProjectFileName();
if (!projectFileName.isEmpty())
{
@ -671,7 +724,7 @@ void RimUiTreeView::slotWriteInputProperty()
exportSettings.fileName = outputFileName;
}
RIPreferencesDialog preferencesDialog(this, &exportSettings, "Export Eclipse Property to Text File");
RiuPreferencesDialog preferencesDialog(this, &exportSettings, "Export Eclipse Property to Text File");
if (preferencesDialog.exec() == QDialog::Accepted)
{
bool isOk = RifEclipseInputFileTools::writePropertyToTextFile(exportSettings.fileName, inputReservoir->reservoirData(), 0, inputProperty->resultName, exportSettings.eclipseKeyword);
@ -707,7 +760,7 @@ void RimUiTreeView::slotWriteBinaryResultAsInputProperty()
{
QString projectFolder;
RIApplication* app = RIApplication::instance();
RiaApplication* app = RiaApplication::instance();
QString projectFileName = app->currentProjectFileName();
if (!projectFileName.isEmpty())
{
@ -724,11 +777,11 @@ void RimUiTreeView::slotWriteBinaryResultAsInputProperty()
exportSettings.fileName = outputFileName;
}
RIPreferencesDialog preferencesDialog(this, &exportSettings, "Export Binary Eclipse Data to Text File");
RiuPreferencesDialog preferencesDialog(this, &exportSettings, "Export Binary Eclipse Data to Text File");
if (preferencesDialog.exec() == QDialog::Accepted)
{
size_t timeStep = resultSlot->reservoirView()->currentTimeStep();
RifReaderInterface::PorosityModelResultType porosityModel = RigReservoirCellResults::convertFromProjectModelPorosityModel(resultSlot->porosityModel());
RifReaderInterface::PorosityModelResultType porosityModel = RigCaseCellResultsData::convertFromProjectModelPorosityModel(resultSlot->porosityModel());
bool isOk = RifEclipseInputFileTools::writeBinaryResultToTextFile(exportSettings.fileName, resultSlot->reservoirView()->eclipseCase()->reservoirData(), porosityModel, timeStep, resultSlot->resultVariable, exportSettings.eclipseKeyword, exportSettings.undefinedValue);
if (!isOk)
@ -746,7 +799,203 @@ void RimUiTreeView::slotCloseCase()
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
if (myModel)
{
myModel->deleteReservoir(currentIndex());
QItemSelectionModel* m = selectionModel();
CVF_ASSERT(m);
caf::PdmObjectGroup group;
QModelIndexList mil = m->selectedRows();
for (int i = 0; i < mil.size(); i++)
{
caf::PdmUiTreeItem* uiItem = myModel->getTreeItemFromIndex(mil.at(i));
group.addObject(uiItem->dataObject().p());
}
std::vector<caf::PdmPointer<RimCase> > typedObjects;
group.objectsByType(&typedObjects);
for (size_t i = 0; i < typedObjects.size(); i++)
{
RimCase* rimReservoir = typedObjects[i];
myModel->deleteReservoir(rimReservoir);
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimUiTreeView::slotNewStatisticsCase()
{
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
if (myModel)
{
QModelIndex insertedIndex;
RimStatisticsCase* newObject = myModel->addStatisticalCalculation(currentIndex(), insertedIndex);
setCurrentIndex(insertedIndex);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimUiTreeView::slotComputeStatistics()
{
QModelIndex index = currentIndex();
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
caf::PdmUiTreeItem* uiItem = myModel->getTreeItemFromIndex(currentIndex());
RimStatisticsCase* statisticsCase = dynamic_cast<RimStatisticsCase*>(uiItem->dataObject().p());
if (!statisticsCase) return;
statisticsCase->computeStatistics();
if (statisticsCase->reservoirViews.size() == 0)
{
slotAddView();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimUiTreeView::slotAddCaseGroup()
{
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
if (myModel)
{
QModelIndex insertedIndex;
myModel->addCaseGroup(currentIndex(), insertedIndex);
setCurrentIndex(insertedIndex);
setExpanded(insertedIndex, true);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimUiTreeView::slotDeleteObjectFromPdmPointersField()
{
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
if (myModel)
{
myModel->deleteObjectFromPdmPointersField(currentIndex());
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimUiTreeView::slotCopyPdmObjectToClipboard()
{
QItemSelectionModel* m = selectionModel();
QModelIndexList mil = m->selectedRows();
if (mil.size() == 0)
{
return;
}
MimeDataWithIndexes* myObject = new MimeDataWithIndexes;
myObject->setIndexes(mil);
QClipboard* clipboard = QApplication::clipboard();
if (clipboard)
{
clipboard->setMimeData(myObject);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimUiTreeView::slotPastePdmObjects()
{
if (!currentIndex().isValid()) return;
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
if (!myModel) return;
caf::PdmObjectGroup objectGroup;
createPdmObjectsFromClipboard(&objectGroup);
if (objectGroup.objects().size() == 0) return;
myModel->addObjects(currentIndex(), objectGroup);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimUiTreeView::createPdmObjectsFromClipboard(caf::PdmObjectGroup* objectGroup)
{
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
if (!myModel) return;
QClipboard* clipboard = QApplication::clipboard();
if (!clipboard) return;
const MimeDataWithIndexes* mdWithIndexes = dynamic_cast<const MimeDataWithIndexes*>(clipboard->mimeData());
if (!mdWithIndexes) return;
QModelIndexList indexList = mdWithIndexes->indexes();
for (int i = 0; i < indexList.size(); i++)
{
caf::PdmUiTreeItem* uiItem = myModel->getTreeItemFromIndex(indexList.at(i));
objectGroup->addObject(uiItem->dataObject().p());
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimUiTreeView::keyPressEvent(QKeyEvent* keyEvent)
{
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
caf::PdmUiTreeItem* uiItem = myModel->getTreeItemFromIndex(currentIndex());
if (dynamic_cast<RimCase*>(uiItem->dataObject().p()))
{
if (keyEvent->matches(QKeySequence::Copy))
{
slotCopyPdmObjectToClipboard();
keyEvent->setAccepted(true);
return;
}
}
if (dynamic_cast<RimIdenticalGridCaseGroup*>(uiItem->dataObject().p())
|| dynamic_cast<RimCaseCollection*>(uiItem->dataObject().p())
|| dynamic_cast<RimCase*>(uiItem->dataObject().p()))
{
if (keyEvent->matches(QKeySequence::Paste))
{
slotPastePdmObjects();
keyEvent->setAccepted(true);
return;
}
}
QTreeView::keyPressEvent(keyEvent);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimUiTreeView::hasClipboardValidData()
{
QClipboard* clipboard = QApplication::clipboard();
if (clipboard)
{
if (dynamic_cast<const MimeDataWithIndexes*>(clipboard->mimeData()))
{
return true;
}
}
return false;
}

View File

@ -24,6 +24,10 @@
class QItemSelection;
namespace caf {
class PdmObjectGroup;
}
//==================================================================================================
///
///
@ -34,6 +38,7 @@ class RimUiTreeView : public QTreeView
public:
RimUiTreeView(QWidget *parent = 0);
~RimUiTreeView();
virtual void setModel(QAbstractItemModel* model);
@ -69,11 +74,28 @@ private slots:
void slotCloseCase();
void slotNewStatisticsCase();
void slotComputeStatistics();
void slotAddCaseGroup();
void slotDeleteObjectFromPdmPointersField();
void slotCopyPdmObjectToClipboard();
void slotPastePdmObjects();
void slotSelectionChanged(const QItemSelection & selected, const QItemSelection & deselected);
signals:
void selectedObjectChanged( caf::PdmObject* pdmObject );
private:
void createPdmObjectsFromClipboard(caf::PdmObjectGroup* objectGroup);
bool hasClipboardValidData();
virtual void keyPressEvent(QKeyEvent* keyEvent);
private:
QAction* m_pasteAction;
};

View File

@ -16,7 +16,7 @@
//
/////////////////////////////////////////////////////////////////////////////////
#include "RIStdInclude.h"
#include "RiaStdInclude.h"
#include "cafAppEnum.h"

View File

@ -24,7 +24,7 @@
#include "cafAppEnum.h"
#include "cafPdmFieldCvfColor.h"
#include "RigWellResults.h"
#include "RigSingleWellResultsData.h"
class RimReservoirView;
//==================================================================================================
@ -41,8 +41,8 @@ public:
void setReservoirView(RimReservoirView* ownerReservoirView);
void setWellResults(RigWellResults* wellResults) { m_wellResults = wellResults;}
RigWellResults* wellResults() { return m_wellResults.p();}
void setWellResults(RigSingleWellResultsData* wellResults) { m_wellResults = wellResults;}
RigSingleWellResultsData* wellResults() { return m_wellResults.p();}
virtual caf::PdmFieldHandle* userDescriptionField();
@ -61,7 +61,7 @@ public:
caf::PdmField<double> pipeRadiusScaleFactor;
private:
cvf::ref<RigWellResults> m_wellResults;
cvf::ref<RigSingleWellResultsData> m_wellResults;
RimReservoirView* m_reservoirView;
};

View File

@ -16,13 +16,13 @@
//
/////////////////////////////////////////////////////////////////////////////////
#include "RIStdInclude.h"
#include "RiaStdInclude.h"
#include "cafAppEnum.h"
#include "cafPdmFieldCvfColor.h"
#include "RigWellResults.h"
#include "RigSingleWellResultsData.h"
#include "RimWellCollection.h"
#include "RimWell.h"
#include "RimReservoirView.h"

View File

@ -0,0 +1,36 @@
# Use this workaround until we're on 2.8.3 on all platforms and can use CMAKE_CURRENT_LIST_DIR directly
if (${CMAKE_VERSION} VERSION_GREATER "2.8.2")
set(CEE_CURRENT_LIST_DIR ${CMAKE_CURRENT_LIST_DIR}/)
endif()
list(APPEND CODE_HEADER_FILES
${CEE_CURRENT_LIST_DIR}RigActiveCellInfo.h
${CEE_CURRENT_LIST_DIR}RigCell.h
${CEE_CURRENT_LIST_DIR}RigCaseData.h
${CEE_CURRENT_LIST_DIR}RigGridBase.h
${CEE_CURRENT_LIST_DIR}RigGridManager.h
${CEE_CURRENT_LIST_DIR}RigGridScalarDataAccess.h
${CEE_CURRENT_LIST_DIR}RigLocalGrid.h
${CEE_CURRENT_LIST_DIR}RigMainGrid.h
${CEE_CURRENT_LIST_DIR}RigReservoirBuilderMock.h
${CEE_CURRENT_LIST_DIR}RigCaseCellResultsData.h
${CEE_CURRENT_LIST_DIR}RigSingleWellResultsData.h
)
list(APPEND CODE_SOURCE_FILES
${CEE_CURRENT_LIST_DIR}RigActiveCellInfo.cpp
${CEE_CURRENT_LIST_DIR}RigCell.cpp
${CEE_CURRENT_LIST_DIR}RigCaseData.cpp
${CEE_CURRENT_LIST_DIR}RigGridBase.cpp
${CEE_CURRENT_LIST_DIR}RigGridManager.cpp
${CEE_CURRENT_LIST_DIR}RigGridScalarDataAccess.cpp
${CEE_CURRENT_LIST_DIR}RigLocalGrid.cpp
${CEE_CURRENT_LIST_DIR}RigMainGrid.cpp
${CEE_CURRENT_LIST_DIR}RigReservoirBuilderMock.cpp
${CEE_CURRENT_LIST_DIR}RigCaseCellResultsData.cpp
${CEE_CURRENT_LIST_DIR}RigSingleWellResultsData.cpp
)

View File

@ -22,10 +22,30 @@ include_directories(
${ResInsight_SOURCE_DIR}/cafProjectDataModel
${ResInsight_SOURCE_DIR}/CommonCode
#Remove when RigStatistics is out
${ResInsight_SOURCE_DIR}/ApplicationCode/ModelVisualization
)
file( GLOB CPP_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/../*.cpp )
file( GLOB UNIT_TEST_CPP_SOURCES *.cpp )
# Populate the filenames into variable lists
include ("${CMAKE_CURRENT_SOURCE_DIR}/../CMakeLists_files.cmake")
set( UNIT_TEST_CPP_SOURCES
${ResInsight_SOURCE_DIR}/cafUserInterface/cafProgressInfo.cpp
main.cpp
RigActiveCellInfo-Test.cpp
RigReservoir-Test.cpp
)
#############################################################################
# Adds folders for Visual Studio solution explorer (and for Xcode explorer)
#############################################################################
source_group( "UnitTests" FILES ${UNIT_TEST_CPP_SOURCES} )
set( LINK_LIBRARIES
@ -45,8 +65,9 @@ set( LINK_LIBRARIES
add_executable( ${ProjectName}
${CPP_SOURCES}
${CODE_SOURCE_FILES}
${UNIT_TEST_CPP_SOURCES}
${CMAKE_CURRENT_SOURCE_DIR}/../CMakeLists_files.cmake
${ResInsight_SOURCE_DIR}/ThirdParty/gtest/gtest-all.cc
)

View File

@ -0,0 +1,73 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "gtest/gtest.h"
#include "RigActiveCellInfo.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
TEST(RigActiveCellInfo, BasicTest)
{
RigActiveCellInfo rigActiveCellInfo;
size_t globalActiveCellCount = 10;
rigActiveCellInfo.setGlobalCellCount(globalActiveCellCount);
for (size_t i = 0; i < globalActiveCellCount; i++)
{
EXPECT_TRUE(rigActiveCellInfo.cellResultIndex(i) == cvf::UNDEFINED_SIZE_T);
EXPECT_FALSE(rigActiveCellInfo.isActive(i));
}
rigActiveCellInfo.setCellResultIndex(3, 1);
EXPECT_TRUE(rigActiveCellInfo.cellResultIndex(3) == 1);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
TEST(RigActiveCellInfo, GridCellCounts)
{
{
RigActiveCellInfo rigActiveCellInfo;
rigActiveCellInfo.setGridCount(3);
rigActiveCellInfo.setGridActiveCellCounts(0, 0);
rigActiveCellInfo.setGridActiveCellCounts(1, 1);
rigActiveCellInfo.setGridActiveCellCounts(2, 2);
rigActiveCellInfo.computeDerivedData();
EXPECT_TRUE(rigActiveCellInfo.globalActiveCellCount() == 3);
}
{
RigActiveCellInfo rigActiveCellInfo;
rigActiveCellInfo.setGridCount(3);
rigActiveCellInfo.setGridActiveCellCounts(0, 3 );
rigActiveCellInfo.setGridActiveCellCounts(1, 4 );
rigActiveCellInfo.setGridActiveCellCounts(2, 5 );
rigActiveCellInfo.computeDerivedData();
EXPECT_TRUE(rigActiveCellInfo.globalActiveCellCount() == 12);
}
}

View File

@ -18,19 +18,85 @@
//
/////////////////////////////////////////////////////////////////////////////////
#include "RIStdInclude.h"
#include "RiaStdInclude.h"
#include "gtest/gtest.h"
#include "RigReservoir.h"
#include "RigCaseData.h"
#include "RigGridManager.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
TEST(RigGridManager, BasicTest)
{
cvf::ref<RigMainGrid> mainGridA = new RigMainGrid;
cvf::ref<RigCaseData> eclipseCase = new RigCaseData;
eclipseCase->setMainGrid(mainGridA.p());
int count = mainGridA->refCount();
EXPECT_EQ(mainGridA->refCount(), 2);
RigGridManager gridCollection;
gridCollection.addCase(eclipseCase.p());
EXPECT_EQ(mainGridA->refCount(), 2);
cvf::ref<RigMainGrid> mainGridB = mainGridA;
EXPECT_EQ(mainGridA->refCount(), 3);
cvf::ref<RigMainGrid> existingGrid = gridCollection.findEqualGrid(mainGridB.p());
EXPECT_TRUE(existingGrid.notNull());
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
TEST(RigGridManager, EqualTests)
{
cvf::ref<RigMainGrid> mainGridA = new RigMainGrid;
mainGridA->nodes().push_back(cvf::Vec3d(0, 0, 0));
mainGridA->nodes().push_back(cvf::Vec3d(0, 0, 1));
mainGridA->nodes().push_back(cvf::Vec3d(0, 0, 2));
cvf::ref<RigCaseData> eclipseCase = new RigCaseData;
eclipseCase->setMainGrid(mainGridA.p());
RigGridManager gridCollection;
gridCollection.addCase(eclipseCase.p());
cvf::ref<RigMainGrid> mainGridB = new RigMainGrid;
cvf::ref<RigMainGrid> existingGrid = gridCollection.findEqualGrid(mainGridB.p());
EXPECT_TRUE(existingGrid.isNull());
mainGridB->nodes().push_back(cvf::Vec3d(0, 0, 0));
existingGrid = gridCollection.findEqualGrid(mainGridB.p());
EXPECT_TRUE(existingGrid.isNull());
// Insert nodes in opposite direction
mainGridB->nodes().push_back(cvf::Vec3d(0, 0, 2));
mainGridB->nodes().push_back(cvf::Vec3d(0, 0, 1));
existingGrid = gridCollection.findEqualGrid(mainGridB.p());
EXPECT_TRUE(existingGrid.isNull());
// Overwrite to match the node structure of mainGridA
mainGridB->nodes()[1] = cvf::Vec3d(0, 0, 1);
mainGridB->nodes()[2] = cvf::Vec3d(0, 0, 2);
existingGrid = gridCollection.findEqualGrid(mainGridB.p());
EXPECT_TRUE(existingGrid.notNull());
}
/*
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
TEST(RigReservoirTest, BasicTest)
{
cvf::ref<RigWellResults> wellCellTimeHistory = new RigWellResults;
cvf::ref<RigSingleWellResultsData> wellCellTimeHistory = new RigSingleWellResultsData;
QDateTime wellStartTime = QDateTime::currentDateTime();
@ -44,7 +110,7 @@ TEST(RigReservoirTest, BasicTest)
}
int resultTimeStepCount = 2 * wellTimeStepCount;
QList<QDateTime> resultTimes;
std::vector<QDateTime> resultTimes;
for (i = 0; i < resultTimeStepCount; i++)
{
resultTimes.push_back(QDateTime(wellStartTime).addMonths(i * 6));
@ -62,3 +128,5 @@ TEST(RigReservoirTest, BasicTest)
}
*/

View File

@ -16,7 +16,7 @@
//
/////////////////////////////////////////////////////////////////////////////////
#include "RIStdInclude.h"
#include "RiaStdInclude.h"
#include "cvfBase.h"

View File

@ -0,0 +1,188 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RigActiveCellInfo.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigActiveCellInfo::RigActiveCellInfo()
: m_globalActiveCellCount(0),
m_activeCellPositionMin(cvf::Vec3d::ZERO),
m_activeCellPositionMax(cvf::Vec3d::ZERO)
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigActiveCellInfo::setGlobalCellCount(size_t globalCellCount)
{
m_cellIndexToResultIndex.resize(globalCellCount, cvf::UNDEFINED_SIZE_T);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RigActiveCellInfo::isActive(size_t globalCellIndex) const
{
if (m_cellIndexToResultIndex.size() == 0)
{
return true;
}
CVF_TIGHT_ASSERT(globalCellIndex < m_cellIndexToResultIndex.size());
return m_cellIndexToResultIndex[globalCellIndex] != cvf::UNDEFINED_SIZE_T;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
size_t RigActiveCellInfo::cellResultIndex(size_t globalCellIndex) const
{
if (m_cellIndexToResultIndex.size() == 0)
{
return globalCellIndex;
}
CVF_TIGHT_ASSERT(globalCellIndex < m_cellIndexToResultIndex.size());
return m_cellIndexToResultIndex[globalCellIndex];
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigActiveCellInfo::setCellResultIndex(size_t globalCellIndex, size_t globalActiveCellIndex)
{
CVF_TIGHT_ASSERT(globalActiveCellIndex < m_cellIndexToResultIndex.size());
m_cellIndexToResultIndex[globalCellIndex] = globalActiveCellIndex;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigActiveCellInfo::setGridCount(size_t gridCount)
{
m_perGridActiveCellInfo.resize(gridCount);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigActiveCellInfo::setGridActiveCellCounts(size_t gridIndex, size_t activeCellCount)
{
CVF_ASSERT(gridIndex < m_perGridActiveCellInfo.size());
m_perGridActiveCellInfo[gridIndex].setActiveCellCount(activeCellCount);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigActiveCellInfo::computeDerivedData()
{
m_globalActiveCellCount = 0;
for (size_t i = 0; i < m_perGridActiveCellInfo.size(); i++)
{
m_globalActiveCellCount += m_perGridActiveCellInfo[i].activeCellCount();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
size_t RigActiveCellInfo::globalActiveCellCount() const
{
return m_globalActiveCellCount;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigActiveCellInfo::setIJKBoundingBox(const cvf::Vec3st& min, const cvf::Vec3st& max)
{
m_activeCellPositionMin = min;
m_activeCellPositionMax = max;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigActiveCellInfo::IJKBoundingBox(cvf::Vec3st& min, cvf::Vec3st& max) const
{
min = m_activeCellPositionMin;
max = m_activeCellPositionMax;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigActiveCellInfo::gridActiveCellCounts(size_t gridIndex, size_t& activeCellCount)
{
activeCellCount = m_perGridActiveCellInfo[gridIndex].activeCellCount();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::BoundingBox RigActiveCellInfo::geometryBoundingBox() const
{
return m_activeCellsBoundingBox;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigActiveCellInfo::setGeometryBoundingBox(cvf::BoundingBox bb)
{
m_activeCellsBoundingBox = bb;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigActiveCellInfo::clear()
{
m_perGridActiveCellInfo.clear();
m_cellIndexToResultIndex.clear();
m_globalActiveCellCount = 0;
m_activeCellPositionMin = cvf::Vec3st(0,0,0);
m_activeCellPositionMax = cvf::Vec3st(0,0,0);
m_activeCellsBoundingBox.reset();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
size_t RigActiveCellInfo::GridActiveCellCounts::activeCellCount() const
{
return m_activeCellCount;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigActiveCellInfo::GridActiveCellCounts::setActiveCellCount(size_t activeCellCount)
{
m_activeCellCount = activeCellCount;
}

View File

@ -0,0 +1,79 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cvfBase.h"
#include "cvfObject.h"
#include "cvfVector3.h"
#include "cvfBoundingBox.h"
#include <vector>
class RigActiveCellInfo : public cvf::Object
{
public:
RigActiveCellInfo();
void setGlobalCellCount(size_t globalCellCount);
bool isActive(size_t globalCellIndex) const;
size_t cellResultIndex(size_t globalCellIndex) const;
void setCellResultIndex(size_t globalCellIndex, size_t globalActiveCellIndex);
void setGridCount(size_t gridCount);
void setGridActiveCellCounts(size_t gridIndex, size_t activeCellCount);
void gridActiveCellCounts(size_t gridIndex, size_t& activeCellCount);
void computeDerivedData();
size_t globalActiveCellCount() const;
void setIJKBoundingBox(const cvf::Vec3st& min, const cvf::Vec3st& max);
void IJKBoundingBox(cvf::Vec3st& min, cvf::Vec3st& max) const;
cvf::BoundingBox geometryBoundingBox() const;
void setGeometryBoundingBox(cvf::BoundingBox bb);
void clear();
private:
class GridActiveCellCounts
{
public:
size_t activeCellCount() const;
void setActiveCellCount(size_t activeCellCount);
private:
size_t m_activeCellCount;
};
private:
std::vector<GridActiveCellCounts> m_perGridActiveCellInfo;
std::vector<size_t> m_cellIndexToResultIndex;
size_t m_globalActiveCellCount;
cvf::Vec3st m_activeCellPositionMin;
cvf::Vec3st m_activeCellPositionMax;
cvf::BoundingBox m_activeCellsBoundingBox;
};

View File

@ -16,28 +16,36 @@
//
/////////////////////////////////////////////////////////////////////////////////
#include "RIStdInclude.h"
#include "RigReservoirCellResults.h"
#include "RigCaseCellResultsData.h"
#include "RifReaderInterface.h"
#include "RigMainGrid.h"
#include <QDateTime>
#include <math.h>
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigReservoirCellResults::RigReservoirCellResults(RigMainGrid* ownerGrid)
RigCaseCellResultsData::RigCaseCellResultsData(RigMainGrid* ownerGrid)
{
CVF_ASSERT(ownerGrid != NULL);
m_ownerMainGrid = ownerGrid;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigCaseCellResultsData::setMainGrid(RigMainGrid* ownerGrid)
{
m_ownerMainGrid = ownerGrid;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigReservoirCellResults::minMaxCellScalarValues( size_t scalarResultIndex, double& min, double& max )
void RigCaseCellResultsData::minMaxCellScalarValues( size_t scalarResultIndex, double& min, double& max )
{
min = HUGE_VAL;
max = -HUGE_VAL;
@ -75,7 +83,7 @@ void RigReservoirCellResults::minMaxCellScalarValues( size_t scalarResultIndex,
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigReservoirCellResults::minMaxCellScalarValues(size_t scalarResultIndex, size_t timeStepIndex, double& min, double& max)
void RigCaseCellResultsData::minMaxCellScalarValues(size_t scalarResultIndex, size_t timeStepIndex, double& min, double& max)
{
min = HUGE_VAL;
max = -HUGE_VAL;
@ -129,7 +137,7 @@ void RigReservoirCellResults::minMaxCellScalarValues(size_t scalarResultIndex, s
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const std::vector<size_t>& RigReservoirCellResults::cellScalarValuesHistogram(size_t scalarResultIndex)
const std::vector<size_t>& RigCaseCellResultsData::cellScalarValuesHistogram(size_t scalarResultIndex)
{
CVF_ASSERT(scalarResultIndex < resultCount());
@ -170,7 +178,7 @@ const std::vector<size_t>& RigReservoirCellResults::cellScalarValuesHistogram(si
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigReservoirCellResults::p10p90CellScalarValues(size_t scalarResultIndex, double& p10, double& p90)
void RigCaseCellResultsData::p10p90CellScalarValues(size_t scalarResultIndex, double& p10, double& p90)
{
const std::vector<size_t>& histogr = cellScalarValuesHistogram( scalarResultIndex);
p10 = m_p10p90[scalarResultIndex].first;
@ -180,7 +188,7 @@ void RigReservoirCellResults::p10p90CellScalarValues(size_t scalarResultIndex, d
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigReservoirCellResults::meanCellScalarValues(size_t scalarResultIndex, double& meanValue)
void RigCaseCellResultsData::meanCellScalarValues(size_t scalarResultIndex, double& meanValue)
{
CVF_ASSERT(scalarResultIndex < resultCount());
@ -216,7 +224,7 @@ void RigReservoirCellResults::meanCellScalarValues(size_t scalarResultIndex, dou
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
size_t RigReservoirCellResults::resultCount() const
size_t RigCaseCellResultsData::resultCount() const
{
return m_cellScalarResults.size();
}
@ -224,7 +232,7 @@ size_t RigReservoirCellResults::resultCount() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
size_t RigReservoirCellResults::timeStepCount(size_t scalarResultIndex) const
size_t RigCaseCellResultsData::timeStepCount(size_t scalarResultIndex) const
{
CVF_TIGHT_ASSERT(scalarResultIndex < resultCount());
@ -234,7 +242,17 @@ size_t RigReservoirCellResults::timeStepCount(size_t scalarResultIndex) const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector< std::vector<double> > & RigReservoirCellResults::cellScalarResults( size_t scalarResultIndex )
const std::vector< std::vector<double> > & RigCaseCellResultsData::cellScalarResults( size_t scalarResultIndex ) const
{
CVF_TIGHT_ASSERT(scalarResultIndex < resultCount());
return m_cellScalarResults[scalarResultIndex];
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector< std::vector<double> > & RigCaseCellResultsData::cellScalarResults( size_t scalarResultIndex )
{
CVF_TIGHT_ASSERT(scalarResultIndex < resultCount());
@ -244,7 +262,18 @@ std::vector< std::vector<double> > & RigReservoirCellResults::cellScalarResults(
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RigReservoirCellResults::cellScalarResult(size_t timeStepIndex, size_t scalarResultIndex, size_t resultValueIndex)
std::vector<double>& RigCaseCellResultsData::cellScalarResults(size_t scalarResultIndex, size_t timeStepIndex)
{
CVF_TIGHT_ASSERT(scalarResultIndex < resultCount());
CVF_TIGHT_ASSERT(timeStepIndex < m_cellScalarResults[scalarResultIndex].size());
return m_cellScalarResults[scalarResultIndex][timeStepIndex];
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RigCaseCellResultsData::cellScalarResult( size_t scalarResultIndex, size_t timeStepIndex, size_t resultValueIndex)
{
if (scalarResultIndex < resultCount() &&
timeStepIndex < m_cellScalarResults[scalarResultIndex].size() &&
@ -259,78 +288,11 @@ double RigReservoirCellResults::cellScalarResult(size_t timeStepIndex, size_t sc
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
size_t RigReservoirCellResults::findOrLoadScalarResult(RimDefines::ResultCatType type, const QString& resultName)
{
size_t resultGridIndex = cvf::UNDEFINED_SIZE_T;
resultGridIndex = findScalarResultIndex(type, resultName);
if (resultGridIndex == cvf::UNDEFINED_SIZE_T) return cvf::UNDEFINED_SIZE_T;
if (cellScalarResults(resultGridIndex).size()) return resultGridIndex;
if (type == RimDefines::GENERATED)
{
return cvf::UNDEFINED_SIZE_T;
}
if (m_readerInterface.notNull())
{
// Add one more result to result container
size_t timeStepCount = m_resultInfos[resultGridIndex].m_timeStepDates.size();
bool resultLoadingSucess = true;
if (type == RimDefines::DYNAMIC_NATIVE && timeStepCount > 0)
{
m_cellScalarResults[resultGridIndex].resize(timeStepCount);
size_t i;
for (i = 0; i < timeStepCount; i++)
{
std::vector<double>& values = m_cellScalarResults[resultGridIndex][i];
if (!m_readerInterface->dynamicResult(resultName, RifReaderInterface::MATRIX_RESULTS, i, &values))
{
resultLoadingSucess = false;
}
}
}
else if (type == RimDefines::STATIC_NATIVE)
{
m_cellScalarResults[resultGridIndex].resize(1);
std::vector<double>& values = m_cellScalarResults[resultGridIndex][0];
if (!m_readerInterface->staticResult(resultName, RifReaderInterface::MATRIX_RESULTS, &values))
{
resultLoadingSucess = false;
}
}
if (!resultLoadingSucess)
{
// Remove last scalar result because loading of result failed
m_cellScalarResults[resultGridIndex].clear();
}
}
return resultGridIndex;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigReservoirCellResults::setReaderInterface(RifReaderInterface* readerInterface)
{
m_readerInterface = readerInterface;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
size_t RigReservoirCellResults::findScalarResultIndex(RimDefines::ResultCatType type, const QString& resultName) const
size_t RigCaseCellResultsData::findScalarResultIndex(RimDefines::ResultCatType type, const QString& resultName) const
{
std::vector<ResultInfo>::const_iterator it;
for (it = m_resultInfos.begin(); it != m_resultInfos.end(); it++)
@ -347,7 +309,7 @@ size_t RigReservoirCellResults::findScalarResultIndex(RimDefines::ResultCatType
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
size_t RigReservoirCellResults::findScalarResultIndex(const QString& resultName) const
size_t RigCaseCellResultsData::findScalarResultIndex(const QString& resultName) const
{
size_t scalarResultIndex = cvf::UNDEFINED_SIZE_T;
@ -371,227 +333,11 @@ size_t RigReservoirCellResults::findScalarResultIndex(const QString& resultName)
return scalarResultIndex;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigReservoirCellResults::loadOrComputeSOIL()
{
size_t soilResultGridIndex = findOrLoadScalarResult(RimDefines::DYNAMIC_NATIVE, "SOIL");
if (soilResultGridIndex == cvf::UNDEFINED_SIZE_T)
{
size_t scalarIndexSWAT = findOrLoadScalarResult(RimDefines::DYNAMIC_NATIVE, "SWAT");
size_t scalarIndexSGAS = findOrLoadScalarResult(RimDefines::DYNAMIC_NATIVE, "SGAS");
// Early exit if none of SWAT or SGAS is present
if (scalarIndexSWAT == cvf::UNDEFINED_SIZE_T && scalarIndexSGAS == cvf::UNDEFINED_SIZE_T)
{
return;
}
soilResultGridIndex = addEmptyScalarResult(RimDefines::DYNAMIC_NATIVE, "SOIL");
const std::vector< std::vector<double> >* swat = NULL;
const std::vector< std::vector<double> >* sgas = NULL;
if (scalarIndexSWAT != cvf::UNDEFINED_SIZE_T)
{
swat = &(cellScalarResults(scalarIndexSWAT));
}
if (scalarIndexSGAS != cvf::UNDEFINED_SIZE_T)
{
sgas = &(cellScalarResults(scalarIndexSGAS));
}
size_t soilResultValueCount = 0;
size_t soilTimeStepCount = 0;
if (swat)
{
soilResultValueCount = swat->at(0).size();
soilTimeStepCount = m_resultInfos[scalarIndexSWAT].m_timeStepDates.size();
}
if (sgas)
{
soilResultValueCount = qMax(soilResultValueCount, sgas->at(0).size());
size_t sgasTimeStepCount = m_resultInfos[scalarIndexSGAS].m_timeStepDates.size();
soilTimeStepCount = qMax(soilTimeStepCount, sgasTimeStepCount);
}
m_cellScalarResults[soilResultGridIndex].resize(soilTimeStepCount);
std::vector< std::vector<double> >& soil = cellScalarResults(soilResultGridIndex);
int timeStepIdx = 0;
for (timeStepIdx = 0; timeStepIdx < static_cast<int>(soilTimeStepCount); timeStepIdx++)
{
soil[timeStepIdx].resize(soilResultValueCount);
#pragma omp parallel for
for (int idx = 0; idx < static_cast<int>(soilResultValueCount); idx++)
{
double soilValue = 1.0;
if (sgas)
{
soilValue -= sgas->at(timeStepIdx)[idx];
}
if (swat)
{
soilValue -= swat->at(timeStepIdx)[idx];
}
soil[timeStepIdx][idx] = soilValue;
}
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigReservoirCellResults::computeDepthRelatedResults()
{
size_t depthResultGridIndex = findOrLoadScalarResult(RimDefines::STATIC_NATIVE, "DEPTH");
size_t dxResultGridIndex = findOrLoadScalarResult(RimDefines::STATIC_NATIVE, "DX");
size_t dyResultGridIndex = findOrLoadScalarResult(RimDefines::STATIC_NATIVE, "DY");
size_t dzResultGridIndex = findOrLoadScalarResult(RimDefines::STATIC_NATIVE, "DZ");
size_t topsResultGridIndex = findOrLoadScalarResult(RimDefines::STATIC_NATIVE, "TOPS");
size_t bottomResultGridIndex = findOrLoadScalarResult(RimDefines::STATIC_NATIVE, "BOTTOM");
bool computeDepth = false;
bool computeDx = false;
bool computeDy = false;
bool computeDz = false;
bool computeTops = false;
bool computeBottom = false;
size_t resultValueCount = m_ownerMainGrid->cells().size();
if (depthResultGridIndex == cvf::UNDEFINED_SIZE_T)
{
depthResultGridIndex = addStaticScalarResult(RimDefines::STATIC_NATIVE, "DEPTH", resultValueCount);
computeDepth = true;
}
if (dxResultGridIndex == cvf::UNDEFINED_SIZE_T)
{
dxResultGridIndex = addStaticScalarResult(RimDefines::STATIC_NATIVE, "DX", resultValueCount);
computeDx = true;
}
if (dyResultGridIndex == cvf::UNDEFINED_SIZE_T)
{
dyResultGridIndex = addStaticScalarResult(RimDefines::STATIC_NATIVE, "DY", resultValueCount);
computeDy = true;
}
if (dzResultGridIndex == cvf::UNDEFINED_SIZE_T)
{
dzResultGridIndex = addStaticScalarResult(RimDefines::STATIC_NATIVE, "DZ", resultValueCount);
computeDz = true;
}
if (topsResultGridIndex == cvf::UNDEFINED_SIZE_T)
{
topsResultGridIndex = addStaticScalarResult(RimDefines::STATIC_NATIVE, "TOPS", resultValueCount);
computeTops = true;
}
if (bottomResultGridIndex == cvf::UNDEFINED_SIZE_T)
{
bottomResultGridIndex = addStaticScalarResult(RimDefines::STATIC_NATIVE, "BOTTOM", resultValueCount);
computeBottom = true;
}
std::vector< std::vector<double> >& depth = cellScalarResults(depthResultGridIndex);
std::vector< std::vector<double> >& dx = cellScalarResults(dxResultGridIndex);
std::vector< std::vector<double> >& dy = cellScalarResults(dyResultGridIndex);
std::vector< std::vector<double> >& dz = cellScalarResults(dzResultGridIndex);
std::vector< std::vector<double> >& tops = cellScalarResults(topsResultGridIndex);
std::vector< std::vector<double> >& bottom = cellScalarResults(bottomResultGridIndex);
bool computeValuesForActiveCellsOnly = m_ownerMainGrid->globalMatrixModelActiveCellCount() > 0;
size_t cellIdx = 0;
for (cellIdx = 0; cellIdx < m_ownerMainGrid->cells().size(); cellIdx++)
{
const RigCell& cell = m_ownerMainGrid->cells()[cellIdx];
if (computeValuesForActiveCellsOnly && !cell.isActiveInMatrixModel())
{
continue;
}
if (computeDepth)
{
depth[0][cellIdx] = cvf::Math::abs(cell.center().z());
}
if (computeDx)
{
cvf::Vec3d cellWidth = cell.faceCenter(cvf::StructGridInterface::NEG_I) - cell.faceCenter(cvf::StructGridInterface::POS_I);
dx[0][cellIdx] = cvf::Math::abs(cellWidth.x());
}
if (computeDy)
{
cvf::Vec3d cellWidth = cell.faceCenter(cvf::StructGridInterface::NEG_J) - cell.faceCenter(cvf::StructGridInterface::POS_J);
dy[0][cellIdx] = cvf::Math::abs(cellWidth.y());
}
if (computeDz)
{
cvf::Vec3d cellWidth = cell.faceCenter(cvf::StructGridInterface::NEG_K) - cell.faceCenter(cvf::StructGridInterface::POS_K);
dz[0][cellIdx] = cvf::Math::abs(cellWidth.z());
}
if (computeTops)
{
tops[0][cellIdx] = cvf::Math::abs(cell.faceCenter(cvf::StructGridInterface::NEG_K).z());
}
if (computeBottom)
{
bottom[0][cellIdx] = cvf::Math::abs(cell.faceCenter(cvf::StructGridInterface::POS_K).z());
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
size_t RigReservoirCellResults::findOrLoadScalarResult(const QString& resultName)
{
size_t scalarResultIndex = cvf::UNDEFINED_SIZE_T;
scalarResultIndex = this->findOrLoadScalarResult(RimDefines::STATIC_NATIVE, resultName);
if (scalarResultIndex == cvf::UNDEFINED_SIZE_T)
{
scalarResultIndex = this->findOrLoadScalarResult(RimDefines::DYNAMIC_NATIVE, resultName);
}
if (scalarResultIndex == cvf::UNDEFINED_SIZE_T)
{
scalarResultIndex = this->findScalarResultIndex(RimDefines::GENERATED, resultName);
}
if (scalarResultIndex == cvf::UNDEFINED_SIZE_T)
{
scalarResultIndex = this->findScalarResultIndex(RimDefines::INPUT_PROPERTY, resultName);
}
return scalarResultIndex;
}
//--------------------------------------------------------------------------------------------------
/// Adds an empty scalar set, and returns the scalarResultIndex to it.
/// if resultName already exists, it returns the scalarResultIndex to the existing result.
//--------------------------------------------------------------------------------------------------
size_t RigReservoirCellResults::addEmptyScalarResult(RimDefines::ResultCatType type, const QString& resultName)
size_t RigCaseCellResultsData::addEmptyScalarResult(RimDefines::ResultCatType type, const QString& resultName, bool needsToBeStored)
{
size_t scalarResultIndex = cvf::UNDEFINED_SIZE_T;
@ -600,7 +346,7 @@ size_t RigReservoirCellResults::addEmptyScalarResult(RimDefines::ResultCatType t
{
scalarResultIndex = this->resultCount();
m_cellScalarResults.push_back(std::vector<std::vector<double> >());
ResultInfo resInfo(type, resultName, scalarResultIndex);
ResultInfo resInfo(type, needsToBeStored, resultName, scalarResultIndex);
m_resultInfos.push_back(resInfo);
}
@ -610,7 +356,7 @@ size_t RigReservoirCellResults::addEmptyScalarResult(RimDefines::ResultCatType t
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QStringList RigReservoirCellResults::resultNames(RimDefines::ResultCatType resType) const
QStringList RigCaseCellResultsData::resultNames(RimDefines::ResultCatType resType) const
{
QStringList varList;
std::vector<ResultInfo>::const_iterator it;
@ -627,7 +373,7 @@ QStringList RigReservoirCellResults::resultNames(RimDefines::ResultCatType resTy
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigReservoirCellResults::recalculateMinMax(size_t scalarResultIndex)
void RigCaseCellResultsData::recalculateMinMax(size_t scalarResultIndex)
{
// Make sure cached max min values are recalculated next time asked for, since
// the data could be changed.
@ -646,26 +392,22 @@ void RigReservoirCellResults::recalculateMinMax(size_t scalarResultIndex)
//--------------------------------------------------------------------------------------------------
/// Returns whether the result data in question is addressed by Active Cell Index
//--------------------------------------------------------------------------------------------------
bool RigReservoirCellResults::isUsingGlobalActiveIndex(size_t scalarResultIndex) const
bool RigCaseCellResultsData::isUsingGlobalActiveIndex(size_t scalarResultIndex) const
{
CVF_TIGHT_ASSERT(scalarResultIndex < m_cellScalarResults.size());
if (!m_cellScalarResults[scalarResultIndex].size()) return true;
size_t firstTimeStepResultValueCount = m_cellScalarResults[scalarResultIndex][0].size();
if (firstTimeStepResultValueCount == m_ownerMainGrid->globalMatrixModelActiveCellCount()) return true;
if (firstTimeStepResultValueCount == m_ownerMainGrid->globalFractureModelActiveCellCount()) return true;
if (firstTimeStepResultValueCount == m_ownerMainGrid->cells().size()) return false;
CVF_TIGHT_ASSERT(false); // Wrong number of results
return false;
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QDateTime RigReservoirCellResults::timeStepDate(size_t scalarResultIndex, size_t timeStepIndex) const
QDateTime RigCaseCellResultsData::timeStepDate(size_t scalarResultIndex, size_t timeStepIndex) const
{
if (scalarResultIndex < m_resultInfos.size() && (size_t)(m_resultInfos[scalarResultIndex].m_timeStepDates.size()) > timeStepIndex)
return m_resultInfos[scalarResultIndex].m_timeStepDates[static_cast<int>(timeStepIndex)];
@ -676,41 +418,56 @@ QDateTime RigReservoirCellResults::timeStepDate(size_t scalarResultIndex, size_t
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QList<QDateTime> RigReservoirCellResults::timeStepDates(size_t scalarResultIndex) const
std::vector<QDateTime> RigCaseCellResultsData::timeStepDates(size_t scalarResultIndex) const
{
if (scalarResultIndex < m_resultInfos.size() )
return m_resultInfos[scalarResultIndex].m_timeStepDates;
else
return QList<QDateTime>();
return std::vector<QDateTime>();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigReservoirCellResults::setTimeStepDates(size_t scalarResultIndex, const QList<QDateTime>& dates)
void RigCaseCellResultsData::setTimeStepDates(size_t scalarResultIndex, const std::vector<QDateTime>& dates)
{
CVF_ASSERT(scalarResultIndex < m_resultInfos.size() );
m_resultInfos[scalarResultIndex].m_timeStepDates = dates;
std::vector< std::vector<double> >& dataValues = this->cellScalarResults(scalarResultIndex);
dataValues.resize(dates.size());
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
size_t RigReservoirCellResults::maxTimeStepCount() const
size_t RigCaseCellResultsData::maxTimeStepCount(size_t* scalarResultIndexWithMostTimeSteps) const
{
size_t maxTsCount = 0;
for (size_t i = 0; i < m_cellScalarResults.size(); ++i)
size_t scalarResultIndexWithMaxTsCount = cvf::UNDEFINED_SIZE_T;
for (size_t i = 0; i < m_resultInfos.size(); i++)
{
maxTsCount = m_cellScalarResults[i].size() > maxTsCount ? m_cellScalarResults[i].size() : maxTsCount;
if (m_resultInfos[i].m_timeStepDates.size() > maxTsCount)
{
maxTsCount = m_resultInfos[i].m_timeStepDates.size();
scalarResultIndexWithMaxTsCount = i;
}
}
if (scalarResultIndexWithMostTimeSteps)
{
*scalarResultIndexWithMostTimeSteps = scalarResultIndexWithMaxTsCount;
}
return maxTsCount;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RigReservoirCellResults::makeResultNameUnique(const QString& resultNameProposal) const
QString RigCaseCellResultsData::makeResultNameUnique(const QString& resultNameProposal) const
{
QString newResultName = resultNameProposal;
size_t resultIndex = cvf::UNDEFINED_SIZE_T;
@ -732,7 +489,7 @@ QString RigReservoirCellResults::makeResultNameUnique(const QString& resultNameP
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigReservoirCellResults::removeResult(const QString& resultName)
void RigCaseCellResultsData::removeResult(const QString& resultName)
{
size_t resultIdx = findScalarResultIndex(resultName);
if (resultIdx == cvf::UNDEFINED_SIZE_T) return;
@ -745,20 +502,23 @@ void RigReservoirCellResults::removeResult(const QString& resultName)
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigReservoirCellResults::clearAllResults()
void RigCaseCellResultsData::clearAllResults()
{
for (size_t i = 0; i < m_cellScalarResults.size(); i++)
{
m_cellScalarResults[i].clear();
}
m_cellScalarResults.clear();
m_maxMinValues.clear();
m_histograms.clear();
m_p10p90.clear();
m_meanValues.clear();
m_maxMinValuesPrTs.clear();
m_resultInfos.clear();
}
//--------------------------------------------------------------------------------------------------
/// Add a result with given type and name, and allocate one result vector for the static result values
//--------------------------------------------------------------------------------------------------
size_t RigReservoirCellResults::addStaticScalarResult(RimDefines::ResultCatType type, const QString& resultName, size_t resultValueCount)
size_t RigCaseCellResultsData::addStaticScalarResult(RimDefines::ResultCatType type, const QString& resultName, bool needsToBeStored, size_t resultValueCount)
{
size_t resultIdx = addEmptyScalarResult(type, resultName);
size_t resultIdx = addEmptyScalarResult(type, resultName, needsToBeStored);
m_cellScalarResults[resultIdx].push_back(std::vector<double>());
m_cellScalarResults[resultIdx][0].resize(resultValueCount, HUGE_VAL);
@ -769,7 +529,7 @@ size_t RigReservoirCellResults::addStaticScalarResult(RimDefines::ResultCatType
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RifReaderInterface::PorosityModelResultType RigReservoirCellResults::convertFromProjectModelPorosityModel(RimDefines::PorosityModelType porosityModel)
RifReaderInterface::PorosityModelResultType RigCaseCellResultsData::convertFromProjectModelPorosityModel(RimDefines::PorosityModelType porosityModel)
{
if (porosityModel == RimDefines::MATRIX_MODEL) return RifReaderInterface::MATRIX_RESULTS;

View File

@ -30,79 +30,89 @@ class RigMainGrid;
//==================================================================================================
/// Class containing the results for the complete number of active cells. Both main grid and LGR's
//==================================================================================================
class RigReservoirCellResults : public cvf::Object
class RigCaseCellResultsData : public cvf::Object
{
public:
RigReservoirCellResults(RigMainGrid* ownerGrid);
RigCaseCellResultsData(RigMainGrid* ownerGrid);
void setReaderInterface(RifReaderInterface* readerInterface);
void setMainGrid(RigMainGrid* ownerGrid);
// Max and min values of the results
void recalculateMinMax(size_t scalarResultIndex);
void minMaxCellScalarValues(size_t scalarResultIndex, double& min, double& max);
void minMaxCellScalarValues(size_t scalarResultIndex, size_t timeStepIndex, double& min, double& max);
const std::vector<size_t>& cellScalarValuesHistogram(size_t scalarResultIndex);
void p10p90CellScalarValues(size_t scalarResultIndex, double& p10, double& p90);
void meanCellScalarValues(size_t scalarResultIndex, double& meanValue);
void recalculateMinMax(size_t scalarResultIndex);
void minMaxCellScalarValues(size_t scalarResultIndex, double& min, double& max);
void minMaxCellScalarValues(size_t scalarResultIndex, size_t timeStepIndex, double& min, double& max);
const std::vector<size_t>& cellScalarValuesHistogram(size_t scalarResultIndex);
void p10p90CellScalarValues(size_t scalarResultIndex, double& p10, double& p90);
void meanCellScalarValues(size_t scalarResultIndex, double& meanValue);
// Access meta-information about the results
size_t resultCount() const;
size_t timeStepCount(size_t scalarResultIndex) const;
size_t maxTimeStepCount() const;
QStringList resultNames(RimDefines::ResultCatType type) const;
bool isUsingGlobalActiveIndex(size_t scalarResultIndex) const;
size_t resultCount() const;
size_t timeStepCount(size_t scalarResultIndex) const;
size_t maxTimeStepCount(size_t* scalarResultIndex = NULL) const;
QStringList resultNames(RimDefines::ResultCatType type) const;
bool isUsingGlobalActiveIndex(size_t scalarResultIndex) const;
QDateTime timeStepDate(size_t scalarResultIndex, size_t timeStepIndex) const;
QList<QDateTime> timeStepDates(size_t scalarResultIndex) const;
void setTimeStepDates(size_t scalarResultIndex, const QList<QDateTime>& dates);
QDateTime timeStepDate(size_t scalarResultIndex, size_t timeStepIndex) const;
std::vector<QDateTime> timeStepDates(size_t scalarResultIndex) const;
void setTimeStepDates(size_t scalarResultIndex, const std::vector<QDateTime>& dates);
// Find or create a slot for the results
size_t findOrLoadScalarResult(RimDefines::ResultCatType type, const QString& resultName);
size_t findOrLoadScalarResult(const QString& resultName); ///< Simplified search. Assumes unique names across types.
size_t findScalarResultIndex(RimDefines::ResultCatType type, const QString& resultName) const;
size_t findScalarResultIndex(const QString& resultName) const;
size_t addEmptyScalarResult(RimDefines::ResultCatType type, const QString& resultName);
QString makeResultNameUnique(const QString& resultNameProposal) const;
void removeResult(const QString& resultName);
void clearAllResults();
size_t findScalarResultIndex(RimDefines::ResultCatType type, const QString& resultName) const;
size_t findScalarResultIndex(const QString& resultName) const;
void loadOrComputeSOIL();
void computeDepthRelatedResults();
size_t addEmptyScalarResult(RimDefines::ResultCatType type, const QString& resultName, bool needsToBeStored);
QString makeResultNameUnique(const QString& resultNameProposal) const;
void removeResult(const QString& resultName);
void clearAllResults();
// Access the results data
std::vector< std::vector<double> > & cellScalarResults(size_t scalarResultIndex);
double cellScalarResult(size_t timeStepIndex, size_t scalarResultIndex, size_t resultValueIndex);
const std::vector< std::vector<double> > & cellScalarResults(size_t scalarResultIndex) const;
std::vector< std::vector<double> > & cellScalarResults(size_t scalarResultIndex);
std::vector<double>& cellScalarResults(size_t scalarResultIndex, size_t timeStepIndex);
double cellScalarResult(size_t scalarResultIndex, size_t timeStepIndex, size_t resultValueIndex);
static RifReaderInterface::PorosityModelResultType convertFromProjectModelPorosityModel(RimDefines::PorosityModelType porosityModel);
private:
size_t addStaticScalarResult(RimDefines::ResultCatType type, const QString& resultName, size_t resultValueCount);
private:
std::vector< std::vector< std::vector<double> > > m_cellScalarResults; ///< Scalar results for each timestep for each Result index (ResultVariable)
std::vector< std::pair<double, double> > m_maxMinValues; ///< Max min values for each Result index
std::vector< std::vector<size_t> > m_histograms; ///< Histogram for each Result Index
std::vector< std::pair<double, double> > m_p10p90; ///< P10 and p90 values for each Result Index
std::vector< double > m_meanValues; ///< Mean value for each Result Index
std::vector< std::vector< std::pair<double, double> > > m_maxMinValuesPrTs; ///< Max min values for each timestep and Result index
public:
class ResultInfo
{
public:
ResultInfo(RimDefines::ResultCatType resultType, QString resultName, size_t gridScalarResultIndex)
: m_resultType(resultType), m_resultName(resultName), m_gridScalarResultIndex(gridScalarResultIndex) { }
ResultInfo(RimDefines::ResultCatType resultType, bool needsToBeStored, QString resultName, size_t gridScalarResultIndex)
: m_resultType(resultType), m_needsToBeStored(needsToBeStored), m_resultName(resultName), m_gridScalarResultIndex(gridScalarResultIndex) { }
public:
RimDefines::ResultCatType m_resultType;
bool m_needsToBeStored;
QString m_resultName;
size_t m_gridScalarResultIndex;
QList<QDateTime> m_timeStepDates;
std::vector<QDateTime> m_timeStepDates;
};
const std::vector<ResultInfo>& infoForEachResultIndex() { return m_resultInfos;}
public:
size_t addStaticScalarResult(RimDefines::ResultCatType type,
const QString& resultName,
bool needsToBeStored,
size_t resultValueCount);
private:
std::vector< std::vector< std::vector<double> > > m_cellScalarResults; ///< Scalar results on the complete reservoir for each Result index (ResultVariable) and timestep
std::vector< std::pair<double, double> > m_maxMinValues; ///< Max min values for each Result index
std::vector< std::vector<size_t> > m_histograms; ///< Histogram for each Result Index
std::vector< std::pair<double, double> > m_p10p90; ///< P10 and p90 values for each Result Index
std::vector< double > m_meanValues; ///< Mean value for each Result Index
std::vector< std::vector< std::pair<double, double> > > m_maxMinValuesPrTs; ///< Max min values for each Result index and timestep
private:
std::vector<ResultInfo> m_resultInfos;
cvf::ref<RifReaderInterface> m_readerInterface;
RigMainGrid* m_ownerMainGrid;
};

Some files were not shown because too many files have changed in this diff Show More