No files matched your search
@@ -18,46 +18,61 @@
|
||||
|
||||
#include "RiaStdInclude.h"
|
||||
|
||||
#include "cafLog.h"
|
||||
#include "RiaApplication.h"
|
||||
|
||||
#include "cafEffectCache.h"
|
||||
#include "cafUtils.h"
|
||||
|
||||
#include "cvfPart.h"
|
||||
|
||||
#include "cvfStructGridGeometryGenerator.h"
|
||||
#include "cafAppEnum.h"
|
||||
|
||||
#include "RiaVersionInfo.h"
|
||||
#include "RiaBaseDefs.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
//
|
||||
#include "RiuMainWindow.h"
|
||||
#include "RiuViewer.h"
|
||||
#include "RiuProcessMonitor.h"
|
||||
#include "RiaPreferences.h"
|
||||
|
||||
//
|
||||
#include "RimResultCase.h"
|
||||
#include "RimInputCase.h"
|
||||
#include "RimReservoirView.h"
|
||||
|
||||
#include "RigCaseData.h"
|
||||
#include "RigCell.h"
|
||||
#include "RigReservoirBuilderMock.h"
|
||||
|
||||
#include <QSettings>
|
||||
#include "cafPdmDocument.h"
|
||||
#include "RifReaderMockModel.h"
|
||||
#include "RimWellPath.h"
|
||||
#include "RimWellPathCollection.h"
|
||||
#include "RimOilField.h"
|
||||
#include "RimAnalysisModels.h"
|
||||
|
||||
#include "cafCeetronNavigation.h"
|
||||
#include "cafCadNavigation.h"
|
||||
#include "RiaSocketServer.h"
|
||||
#include "cafUiProcess.h"
|
||||
|
||||
//
|
||||
#include "RimUiTreeModelPdm.h"
|
||||
#include "RiaImageCompareReporter.h"
|
||||
#include "RiaImageFileCompare.h"
|
||||
#include "cafProgressInfo.h"
|
||||
#include "RigGridManager.h"
|
||||
|
||||
#include "RimProject.h"
|
||||
|
||||
#include "RimResultSlot.h"
|
||||
|
||||
#include "RimIdenticalGridCaseGroup.h"
|
||||
#include "RimInputPropertyCollection.h"
|
||||
|
||||
#include "RimDefines.h"
|
||||
#include "RimScriptCollection.h"
|
||||
#include "RimCaseCollection.h"
|
||||
|
||||
////////////
|
||||
|
||||
#include "cafPdmFieldCvfColor.h"
|
||||
#include "cafPdmFieldCvfMat4d.h"
|
||||
#include "RimReservoirCellResultsCacher.h"
|
||||
#include "RimCellEdgeResultSlot.h"
|
||||
#include "RimCellRangeFilterCollection.h"
|
||||
#include "RimCellPropertyFilterCollection.h"
|
||||
#include "Rim3dOverlayInfoConfig.h"
|
||||
#include "RimWellCollection.h"
|
||||
|
||||
namespace caf
|
||||
{
|
||||
template<>
|
||||
@@ -267,58 +282,48 @@ bool RiaApplication::loadProject(const QString& projectFileName)
|
||||
|
||||
///////
|
||||
// Load the external data, and initialize stuff that needs specific ordering
|
||||
|
||||
// VL check regarding specific order mentioned in comment above...
|
||||
|
||||
m_preferences->lastUsedProjectFileName = projectFileName;
|
||||
writePreferences();
|
||||
|
||||
for (size_t cgIdx = 0; cgIdx < m_project->caseGroups.size(); ++cgIdx)
|
||||
for (size_t oilFieldIdx = 0; oilFieldIdx < m_project->oilFields().size(); oilFieldIdx++)
|
||||
{
|
||||
// Load the Main case of each IdenticalGridCaseGroup
|
||||
RimOilField* oilField = m_project->oilFields[oilFieldIdx];
|
||||
RimAnalysisModels* analysisModels = oilField ? oilField->analysisModels() : NULL;
|
||||
if (analysisModels == NULL) continue;
|
||||
|
||||
RimIdenticalGridCaseGroup* igcg = m_project->caseGroups[cgIdx];
|
||||
igcg->loadMainCaseAndActiveCellInfo();
|
||||
for (size_t cgIdx = 0; cgIdx < analysisModels->caseGroups.size(); ++cgIdx)
|
||||
{
|
||||
// Load the Main case of each IdenticalGridCaseGroup
|
||||
RimIdenticalGridCaseGroup* igcg = analysisModels->caseGroups[cgIdx];
|
||||
igcg->loadMainCaseAndActiveCellInfo(); // VL is this supposed to be done for each RimOilField?
|
||||
}
|
||||
}
|
||||
|
||||
// Add well paths for each oil field
|
||||
for (size_t oilFieldIdx = 0; oilFieldIdx < m_project->oilFields().size(); oilFieldIdx++)
|
||||
{
|
||||
RimOilField* oilField = m_project->oilFields[oilFieldIdx];
|
||||
if (oilField == NULL) continue;
|
||||
if (oilField->wellPathCollection == NULL)
|
||||
{
|
||||
//printf("Create well path collection for oil field %i in loadProject.\n", oilFieldIdx);
|
||||
oilField->wellPathCollection = new RimWellPathCollection();
|
||||
oilField->wellPathCollection->setProject(m_project);
|
||||
}
|
||||
|
||||
if (oilField->wellPathCollection) oilField->wellPathCollection->readWellPathFiles();
|
||||
}
|
||||
|
||||
// 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]);
|
||||
}
|
||||
|
||||
for (size_t cgIdx = 0; cgIdx < m_project->caseGroups().size(); ++cgIdx)
|
||||
{
|
||||
// Add all statistics cases as well
|
||||
if (m_project->caseGroups[cgIdx]->statisticsCaseCollection())
|
||||
{
|
||||
caf::PdmPointersField<RimCase*> & statCases = m_project->caseGroups[cgIdx]->statisticsCaseCollection()->reservoirs();
|
||||
for (size_t scIdx = 0; scIdx < statCases.size(); ++scIdx)
|
||||
{
|
||||
casesToLoad.push_back(statCases[scIdx]);
|
||||
}
|
||||
}
|
||||
|
||||
// Add all source cases in a case group with a view attached
|
||||
if (m_project->caseGroups[cgIdx]->caseCollection())
|
||||
{
|
||||
caf::PdmPointersField<RimCase*> & sourceCases = m_project->caseGroups[cgIdx]->caseCollection()->reservoirs();
|
||||
for (size_t scIdx = 0; scIdx < sourceCases.size(); ++scIdx)
|
||||
{
|
||||
if (sourceCases[scIdx]->reservoirViews().size() > 0)
|
||||
{
|
||||
casesToLoad.push_back(sourceCases[scIdx]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
std::vector<RimCase*> casesToLoad;
|
||||
m_project->allCases(casesToLoad);
|
||||
|
||||
caf::ProgressInfo caseProgress(casesToLoad.size() , "Reading Cases");
|
||||
|
||||
|
||||
for (size_t cIdx = 0; cIdx < casesToLoad.size(); ++cIdx)
|
||||
{
|
||||
RimCase* ri = casesToLoad[cIdx];
|
||||
@@ -337,7 +342,7 @@ bool RiaApplication::loadProject(const QString& projectFileName)
|
||||
viewProgress.setProgressDescription(riv->name());
|
||||
|
||||
riv->loadDataAndUpdate();
|
||||
|
||||
this->setActiveReservoirView(riv);
|
||||
viewProgress.incrementProgress();
|
||||
}
|
||||
|
||||
@@ -350,6 +355,30 @@ bool RiaApplication::loadProject(const QString& projectFileName)
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Add a list of well path file paths (JSON files) to the well path collection
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaApplication::addWellPathsToModel(QList<QString> wellPathFilePaths)
|
||||
{
|
||||
if (m_project == NULL || m_project->oilFields.size() < 1) return;
|
||||
|
||||
RimOilField* oilField = m_project->activeOilField();
|
||||
if (oilField == NULL) return;
|
||||
|
||||
if (oilField->wellPathCollection == NULL)
|
||||
{
|
||||
//printf("Create well path collection.\n");
|
||||
oilField->wellPathCollection = new RimWellPathCollection();
|
||||
oilField->wellPathCollection->setProject(m_project);
|
||||
RiuMainWindow::instance()->uiPdmModel()->updateUiSubTree(m_project);
|
||||
}
|
||||
|
||||
if (oilField->wellPathCollection) oilField->wellPathCollection->addWellPaths(wellPathFilePaths);
|
||||
|
||||
RiuMainWindow::instance()->uiPdmModel()->updateUiSubTree(oilField->wellPathCollection);
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -467,8 +496,7 @@ bool RiaApplication::closeProject(bool askToSaveIfDirty)
|
||||
|
||||
onProjectOpenedOrClosed();
|
||||
|
||||
return true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -517,7 +545,10 @@ bool RiaApplication::openEclipseCase(const QString& caseName, const QString& cas
|
||||
RimResultCase* rimResultReservoir = new RimResultCase();
|
||||
rimResultReservoir->setCaseInfo(caseName, caseFileName);
|
||||
|
||||
m_project->reservoirs.push_back(rimResultReservoir);
|
||||
RimAnalysisModels* analysisModels = m_project->activeOilField() ? m_project->activeOilField()->analysisModels() : NULL;
|
||||
if (analysisModels == NULL) return false;
|
||||
|
||||
analysisModels->cases.push_back(rimResultReservoir);
|
||||
|
||||
RimReservoirView* riv = rimResultReservoir->createAndAddReservoirView();
|
||||
|
||||
@@ -534,12 +565,8 @@ bool RiaApplication::openEclipseCase(const QString& caseName, const QString& cas
|
||||
}
|
||||
|
||||
RimUiTreeModelPdm* uiModel = RiuMainWindow::instance()->uiPdmModel();
|
||||
caf::PdmUiTreeItem* projectTreeItem = uiModel->treeItemRoot();
|
||||
|
||||
// New case is inserted before the last item, the script item
|
||||
int position = projectTreeItem->childCount() - 1;
|
||||
|
||||
uiModel->addToParentAndBuildUiItems(projectTreeItem, position, rimResultReservoir);
|
||||
uiModel->updateUiSubTree(analysisModels);
|
||||
|
||||
RiuMainWindow::instance()->setCurrentObjectInTreeView(riv->cellResult());
|
||||
|
||||
@@ -553,10 +580,15 @@ bool RiaApplication::openEclipseCase(const QString& caseName, const QString& cas
|
||||
bool RiaApplication::openInputEclipseCase(const QString& caseName, const QStringList& caseFileNames)
|
||||
{
|
||||
RimInputCase* rimInputReservoir = new RimInputCase();
|
||||
m_project->assignCaseIdToCase(rimInputReservoir);
|
||||
|
||||
rimInputReservoir->caseUserDescription = caseName;
|
||||
rimInputReservoir->openDataFileSet(caseFileNames);
|
||||
|
||||
m_project->reservoirs.push_back(rimInputReservoir);
|
||||
RimAnalysisModels* analysisModels = m_project->activeOilField() ? m_project->activeOilField()->analysisModels() : NULL;
|
||||
if (analysisModels == NULL) return false;
|
||||
|
||||
analysisModels->cases.push_back(rimInputReservoir);
|
||||
|
||||
RimReservoirView* riv = rimInputReservoir->createAndAddReservoirView();
|
||||
|
||||
@@ -571,12 +603,7 @@ bool RiaApplication::openInputEclipseCase(const QString& caseName, const QString
|
||||
}
|
||||
|
||||
RimUiTreeModelPdm* uiModel = RiuMainWindow::instance()->uiPdmModel();
|
||||
caf::PdmUiTreeItem* projectTreeItem = uiModel->treeItemRoot();
|
||||
|
||||
// New case is inserted before the last item, the script item
|
||||
int position = projectTreeItem->childCount() - 1;
|
||||
|
||||
uiModel->addToParentAndBuildUiItems(projectTreeItem, position, rimInputReservoir);
|
||||
uiModel->updateUiSubTree(analysisModels);
|
||||
|
||||
RiuMainWindow::instance()->setCurrentObjectInTreeView(riv->cellResult());
|
||||
|
||||
@@ -966,9 +993,16 @@ void RiaApplication::slotWorkerProcessFinished(int exitCode, QProcess::ExitStatu
|
||||
return;
|
||||
}
|
||||
|
||||
//MFLog::info("Simulation completed successfully.");
|
||||
|
||||
//MFMainWindow::instance()->slotLoadResultsFromSimulationFolder();
|
||||
// If multiple cases are present, invoke launchProcess() which will set next current case, and run script on this case
|
||||
if (m_currentCaseIds.size() > 0)
|
||||
{
|
||||
launchProcess(m_currentProgram, m_currentArguments);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Disable concept of current case
|
||||
m_socketServer->setCurrentCaseId(-1);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -978,6 +1012,20 @@ bool RiaApplication::launchProcess(const QString& program, const QStringList& ar
|
||||
{
|
||||
if (m_workerProcess == NULL)
|
||||
{
|
||||
// If multiple cases are present, pop the first case ID from the list and set as current case
|
||||
if (m_currentCaseIds.size() > 0)
|
||||
{
|
||||
int nextCaseId = m_currentCaseIds.front();
|
||||
m_currentCaseIds.pop_front();
|
||||
|
||||
m_socketServer->setCurrentCaseId(nextCaseId);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Disable current case concept
|
||||
m_socketServer->setCurrentCaseId(-1);
|
||||
}
|
||||
|
||||
m_workerProcess = new caf::UiProcess(this);
|
||||
connect(m_workerProcess, SIGNAL(finished(int, QProcess::ExitStatus)), SLOT(slotWorkerProcessFinished(int, QProcess::ExitStatus)));
|
||||
|
||||
@@ -1005,6 +1053,20 @@ bool RiaApplication::launchProcess(const QString& program, const QStringList& ar
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RiaApplication::launchProcessForMultipleCases(const QString& program, const QStringList& arguments, const std::vector<int>& caseIds)
|
||||
{
|
||||
m_currentCaseIds.clear();
|
||||
std::copy( caseIds.begin(), caseIds.end(), std::back_inserter( m_currentCaseIds ) );
|
||||
|
||||
m_currentProgram = program;
|
||||
m_currentArguments = arguments;
|
||||
|
||||
return launchProcess(m_currentProgram, m_currentArguments);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Read fields of a Pdm object using QSettings
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -1086,7 +1148,7 @@ void RiaApplication::applyPreferences()
|
||||
{
|
||||
this->project()->setScriptDirectories(m_preferences->scriptDirectories());
|
||||
RimUiTreeModelPdm* treeModel = RiuMainWindow::instance()->uiPdmModel();
|
||||
if (treeModel) treeModel->rebuildUiSubTree(this->project()->scriptCollection());
|
||||
if (treeModel) treeModel->updateUiSubTree(this->project()->scriptCollection());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1164,9 +1226,9 @@ void RiaApplication::saveSnapshotPromtpForFilename()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaApplication::saveSnapshotAs(const QString& fileName)
|
||||
{
|
||||
if (m_activeReservoirView && m_activeReservoirView->viewer())
|
||||
QImage image = grabFrameBufferImage();
|
||||
if (!image.isNull())
|
||||
{
|
||||
QImage image = m_activeReservoirView->viewer()->grabFrameBuffer();
|
||||
if (image.save(fileName))
|
||||
{
|
||||
qDebug() << "Saved snapshot image to " << fileName;
|
||||
@@ -1183,12 +1245,11 @@ void RiaApplication::saveSnapshotAs(const QString& fileName)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaApplication::copySnapshotToClipboard()
|
||||
{
|
||||
if (m_activeReservoirView && m_activeReservoirView->viewer())
|
||||
{
|
||||
QImage image = m_activeReservoirView->viewer()->grabFrameBuffer();
|
||||
|
||||
QClipboard* clipboard = QApplication::clipboard();
|
||||
if (clipboard)
|
||||
{
|
||||
QImage image = grabFrameBufferImage();
|
||||
if (!image.isNull())
|
||||
{
|
||||
clipboard->setImage(image);
|
||||
}
|
||||
@@ -1218,9 +1279,12 @@ void RiaApplication::saveSnapshotForAllViews(const QString& snapshotFolderName)
|
||||
QString snapshotPath = projectDir.absolutePath();
|
||||
snapshotPath += "/" + snapshotFolderName;
|
||||
|
||||
for (size_t i = 0; i < m_project->reservoirs().size(); ++i)
|
||||
RimAnalysisModels* analysisModels = m_project->activeOilField() ? m_project->activeOilField()->analysisModels() : NULL;
|
||||
if (analysisModels == NULL) return;
|
||||
|
||||
for (size_t i = 0; i < analysisModels->cases().size(); ++i)
|
||||
{
|
||||
RimCase* ri = m_project->reservoirs()[i];
|
||||
RimCase* ri = analysisModels->cases()[i];
|
||||
if (!ri) continue;
|
||||
|
||||
for (size_t j = 0; j < ri->reservoirViews().size(); j++)
|
||||
@@ -1413,7 +1477,11 @@ bool RiaApplication::addEclipseCases(const QStringList& fileNames)
|
||||
rimResultReservoir->readGridDimensions(mainCaseGridDimensions);
|
||||
|
||||
mainResultCase = rimResultReservoir;
|
||||
gridCaseGroup = m_project->createIdenticalCaseGroupFromMainCase(mainResultCase);
|
||||
RimOilField* oilField = m_project->activeOilField();
|
||||
if (oilField && oilField->analysisModels())
|
||||
{
|
||||
gridCaseGroup = oilField->analysisModels->createIdenticalCaseGroupFromMainCase(mainResultCase);
|
||||
}
|
||||
}
|
||||
|
||||
caf::ProgressInfo info(fileNames.size(), "Reading Active Cell data");
|
||||
@@ -1436,7 +1504,11 @@ bool RiaApplication::addEclipseCases(const QStringList& fileNames)
|
||||
{
|
||||
if (rimResultReservoir->openAndReadActiveCellData(mainResultCase->reservoirData()))
|
||||
{
|
||||
m_project->insertCaseInCaseGroup(gridCaseGroup, rimResultReservoir);
|
||||
RimOilField* oilField = m_project->activeOilField();
|
||||
if (oilField && oilField->analysisModels())
|
||||
{
|
||||
oilField->analysisModels()->insertCaseInCaseGroup(gridCaseGroup, rimResultReservoir);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1452,12 +1524,8 @@ bool RiaApplication::addEclipseCases(const QStringList& fileNames)
|
||||
}
|
||||
|
||||
RimUiTreeModelPdm* uiModel = RiuMainWindow::instance()->uiPdmModel();
|
||||
caf::PdmUiTreeItem* projectTreeItem = uiModel->treeItemRoot();
|
||||
|
||||
// New case is inserted before the last item, the script item
|
||||
int position = projectTreeItem->childCount() - 1;
|
||||
|
||||
uiModel->addToParentAndBuildUiItems(projectTreeItem, position, gridCaseGroup);
|
||||
|
||||
uiModel->updateUiSubTree( m_project->activeOilField()->analysisModels());
|
||||
|
||||
if (gridCaseGroup->statisticsCaseCollection()->reservoirs.size() > 0)
|
||||
{
|
||||
@@ -1479,3 +1547,34 @@ cvf::Font* RiaApplication::standardFont()
|
||||
|
||||
return m_standardFont.p();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QImage RiaApplication::grabFrameBufferImage()
|
||||
{
|
||||
QImage image;
|
||||
if (m_activeReservoirView && m_activeReservoirView->viewer())
|
||||
{
|
||||
m_activeReservoirView->viewer()->repaint();
|
||||
|
||||
GLint currentReadBuffer;
|
||||
glGetIntegerv(GL_READ_BUFFER, ¤tReadBuffer);
|
||||
|
||||
glReadBuffer(GL_FRONT);
|
||||
image = m_activeReservoirView->viewer()->grabFrameBuffer();
|
||||
|
||||
glReadBuffer(currentReadBuffer);
|
||||
}
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimProject* RiaApplication::project()
|
||||
{
|
||||
return m_project;
|
||||
}
|
||||
|
||||
@@ -17,17 +17,15 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
#include <QtGui/QApplication>
|
||||
#include <QApplication>
|
||||
#include <QProcess>
|
||||
#include "cafPdmObject.h"
|
||||
#include "cafPdmField.h"
|
||||
#include "cvfBase.h"
|
||||
#include "cvfObject.h"
|
||||
|
||||
#include "cvfScalarMapperUniformLevels.h"
|
||||
#include "cvfOverlayScalarMapperLegend.h"
|
||||
#include "RimReservoirView.h"
|
||||
#include "cvfFont.h"
|
||||
|
||||
#include <iostream>
|
||||
#include "RimProject.h"
|
||||
|
||||
class RIProcess;
|
||||
class RigCaseData;
|
||||
@@ -35,6 +33,8 @@ class RimCase;
|
||||
class Drawable;
|
||||
class RiaSocketServer;
|
||||
class RiaPreferences;
|
||||
class RimReservoirView;
|
||||
class RimProject;
|
||||
|
||||
namespace caf
|
||||
{
|
||||
@@ -68,7 +68,7 @@ public:
|
||||
RimReservoirView* activeReservoirView();
|
||||
const RimReservoirView* activeReservoirView() const;
|
||||
|
||||
RimProject* project() {return m_project;}
|
||||
RimProject* project();
|
||||
|
||||
void createMockModel();
|
||||
void createResultsMockModel();
|
||||
@@ -90,7 +90,8 @@ public:
|
||||
bool saveProjectAs(const QString& fileName);
|
||||
bool saveProjectPromptForFileName();
|
||||
bool closeProject(bool askToSaveIfDirty);
|
||||
|
||||
void addWellPathsToModel(QList<QString> wellPathFilePaths);
|
||||
|
||||
void copySnapshotToClipboard();
|
||||
void saveSnapshotPromtpForFilename();
|
||||
void saveSnapshotAs(const QString& fileName);
|
||||
@@ -114,6 +115,7 @@ public:
|
||||
QString octavePath() const;
|
||||
|
||||
bool launchProcess(const QString& program, const QStringList& arguments);
|
||||
bool launchProcessForMultipleCases(const QString& program, const QStringList& arguments, const std::vector<int>& caseIds);
|
||||
void terminateProcess();
|
||||
|
||||
RiaPreferences* preferences();
|
||||
@@ -127,7 +129,7 @@ private:
|
||||
void onProjectOpenedOrClosed();
|
||||
void setWindowCaptionFromAppState();
|
||||
|
||||
|
||||
QImage grabFrameBufferImage();
|
||||
|
||||
private slots:
|
||||
void slotWorkerProcessFinished(int exitCode, QProcess::ExitStatus exitStatus);
|
||||
@@ -141,6 +143,12 @@ private:
|
||||
|
||||
caf::UiProcess* m_workerProcess;
|
||||
|
||||
// Execute for all settings
|
||||
std::list<int> m_currentCaseIds;
|
||||
QString m_currentProgram;
|
||||
QStringList m_currentArguments;
|
||||
|
||||
|
||||
RiaPreferences* m_preferences;
|
||||
|
||||
std::map<QString, QString> m_fileDialogDefaultDirectories;
|
||||
|
||||
@@ -18,7 +18,9 @@
|
||||
|
||||
#include "RiaStdInclude.h"
|
||||
#include "RiaPreferences.h"
|
||||
|
||||
#include "cafPdmUiFilePathEditor.h"
|
||||
#include "cafPdmFieldCvfColor.h"
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RiaPreferences, "RiaPreferences");
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -26,7 +28,7 @@ CAF_PDM_SOURCE_INIT(RiaPreferences, "RiaPreferences");
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiaPreferences::RiaPreferences(void)
|
||||
{
|
||||
CAF_PDM_InitField(&navigationPolicy, "navigationPolicy", caf::AppEnum<RiaApplication::RINavigationPolicy>(RiaApplication::NAVIGATION_POLICY_CAD), "Navigation mode", "", "", "");
|
||||
CAF_PDM_InitField(&navigationPolicy, "navigationPolicy", caf::AppEnum<RiaApplication::RINavigationPolicy>(RiaApplication::NAVIGATION_POLICY_CEETRON), "Navigation mode", "", "", "");
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&scriptDirectories, "scriptDirectory", "Shared Script Folder(s)", "", "", "");
|
||||
scriptDirectories.setUiEditorTypeName(caf::PdmUiFilePathEditor::uiEditorTypeName());
|
||||
@@ -37,6 +39,8 @@ RiaPreferences::RiaPreferences(void)
|
||||
CAF_PDM_InitField(&octaveExecutable, "octaveExecutable", QString("octave"), "Octave", "", "", "");
|
||||
octaveExecutable.setUiEditorTypeName(caf::PdmUiFilePathEditor::uiEditorTypeName());
|
||||
|
||||
CAF_PDM_InitField(&ssihubAddress, "ssihubAddress", QString("http://"), "ssihub Address", "", "", "");
|
||||
|
||||
CAF_PDM_InitField(&defaultGridLines, "defaultGridLines", true, "Gridlines", "", "", "");
|
||||
CAF_PDM_InitField(&defaultGridLineColors, "defaultGridLineColors", cvf::Color3f(0.92f, 0.92f, 0.92f), "Mesh color", "", "", "");
|
||||
CAF_PDM_InitField(&defaultFaultGridLineColors, "defaultFaultGridLineColors", cvf::Color3f(0.08f, 0.08f, 0.08f), "Mesh color along faults", "", "", "");
|
||||
|
||||
@@ -18,9 +18,13 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cafPdmObject.h"
|
||||
#include "RiaApplication.h"
|
||||
|
||||
#include "cafPdmObject.h"
|
||||
#include "cafPdmField.h"
|
||||
#include "cafAppEnum.h"
|
||||
|
||||
|
||||
class RiaPreferences : public caf::PdmObject
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
@@ -37,6 +41,7 @@ public: // Pdm Fields
|
||||
caf::PdmField<QString> scriptDirectories;
|
||||
caf::PdmField<QString> scriptEditorExecutable;
|
||||
caf::PdmField<QString> octaveExecutable;
|
||||
caf::PdmField<QString> ssihubAddress;
|
||||
|
||||
caf::PdmField<int> defaultScaleFactorZ;
|
||||
caf::PdmField<bool> defaultGridLines;
|
||||
|
||||
@@ -48,15 +48,22 @@ set( USER_INTERFACE_FILES
|
||||
UserInterface/RiuProcessMonitor.cpp
|
||||
)
|
||||
|
||||
set( SOCKET_INTERFACE_FILES
|
||||
SocketInterface/RiaSocketServer.cpp
|
||||
SocketInterface/RiaProjectInfoCommands.cpp
|
||||
SocketInterface/RiaCaseInfoCommands.cpp
|
||||
SocketInterface/RiaGeometryCommands.cpp
|
||||
SocketInterface/RiaPropertyDataCommands.cpp
|
||||
SocketInterface/RiaSocketTools.cpp
|
||||
)
|
||||
|
||||
|
||||
list( APPEND CPP_SOURCES
|
||||
${APPLICATION_FILES}
|
||||
${USER_INTERFACE_FILES}
|
||||
${SOCKET_INTERFACE_FILES}
|
||||
)
|
||||
|
||||
list( APPEND CPP_SOURCES
|
||||
SocketInterface/RiaSocketServer.cpp
|
||||
)
|
||||
|
||||
|
||||
list( APPEND REFERENCED_CMAKE_FILES
|
||||
@@ -75,6 +82,8 @@ list( APPEND CPP_SOURCES
|
||||
${CODE_SOURCE_FILES}
|
||||
)
|
||||
|
||||
add_subdirectory(ssihubInterface)
|
||||
|
||||
|
||||
# Define files for MOC-ing
|
||||
set ( QT_MOC_HEADERS
|
||||
@@ -179,6 +188,7 @@ precompiled_header( RAW_SOURCES ALL_INCLUDES ${GCC_PCH_TARGET} ${PCH_NAME} ${PCH
|
||||
source_group( "Application" FILES ${APPLICATION_FILES} )
|
||||
source_group( "ModelVisualization" FILES ${MODEL_VISUALIZATION_FILES} )
|
||||
source_group( "UserInterface" FILES ${USER_INTERFACE_FILES} )
|
||||
source_group( "SocketInterface" FILES ${SOCKET_INTERFACE_FILES} )
|
||||
|
||||
|
||||
add_executable(ResInsight
|
||||
@@ -205,6 +215,8 @@ set( LINK_LIBRARIES
|
||||
LibGeometry
|
||||
LibCore
|
||||
|
||||
ssihubInterface
|
||||
|
||||
ecl
|
||||
ert_util
|
||||
ert_geometry
|
||||
@@ -229,7 +241,7 @@ target_link_libraries( ResInsight ${LINK_LIBRARIES} ${EXTERNAL_LINK_LIBRARIES})
|
||||
if (MSVC)
|
||||
|
||||
# Qt DLLs
|
||||
set (QTLIBLIST QtCore QtCored QtGui QtGuid QtOpenGl QtOpenGld QtNetwork QtNetworkd)
|
||||
set (QTLIBLIST QtCore QtCored QtGui QtGuid QtOpenGl QtOpenGld QtNetwork QtNetworkd QtScript QtScriptd QtScriptTools QtScriptToolsd)
|
||||
foreach (qtlib ${QTLIBLIST})
|
||||
add_custom_command(TARGET ResInsight POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
@@ -261,6 +273,8 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||
${QT_LIBRARY_DIR}/libQtGui.so*
|
||||
${QT_LIBRARY_DIR}/libQtOpenGL.so*
|
||||
${QT_LIBRARY_DIR}/libQtNetwork.so*
|
||||
${QT_LIBRARY_DIR}/libQtScript.so*
|
||||
${QT_LIBRARY_DIR}/libQtScriptTools.so*
|
||||
)
|
||||
|
||||
endif()
|
||||
@@ -274,6 +288,8 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
|
||||
${QT_BINARY_DIR}/QtGui4.dll
|
||||
${QT_BINARY_DIR}/QtOpenGL4.dll
|
||||
${QT_BINARY_DIR}/QtNetwork4.dll
|
||||
${QT_BINARY_DIR}/QtScript4.dll
|
||||
${QT_BINARY_DIR}/QtScriptTools4.dll
|
||||
)
|
||||
endif()
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ ${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}RifJsonEncodeDecode.h
|
||||
${CEE_CURRENT_LIST_DIR}RifReaderInterface.h
|
||||
${CEE_CURRENT_LIST_DIR}RifReaderMockModel.h
|
||||
)
|
||||
@@ -24,6 +25,7 @@ ${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}RifJsonEncodeDecode.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RifReaderMockModel.cpp
|
||||
)
|
||||
|
||||
|
||||
@@ -94,7 +94,7 @@ target_link_libraries( ${ProjectName} ${LINK_LIBRARIES} ${EXTERNAL_LINK_LIBRARIE
|
||||
if (MSVC)
|
||||
|
||||
# Qt DLLs
|
||||
set (QTLIBLIST QtCore QtCored QtGui QtGuid QtOpenGl QtOpenGld QtNetwork QtNetworkd)
|
||||
set (QTLIBLIST QtCore QtCored QtGui QtGuid QtOpenGl QtOpenGld QtNetwork QtNetworkd QtScript QtScriptd QtScriptTools QtScriptToolsd)
|
||||
foreach (qtlib ${QTLIBLIST})
|
||||
add_custom_command(TARGET ${ProjectName} POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
|
||||
@@ -0,0 +1,143 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2011-2013 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.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Json parser based on code example found on:
|
||||
// http://stackoverflow.com/questions/4169988/easiest-way-to-parse-json-in-qt-4-7
|
||||
|
||||
#include "RifJsonEncodeDecode.h"
|
||||
|
||||
#include <QtCore/QFile>
|
||||
#include <QtCore/QString>
|
||||
#include <QtScript/QScriptEngine>
|
||||
#include <QtScript/QScriptValueIterator>
|
||||
|
||||
|
||||
QMap<QString, QVariant> JsonReader::decodeFile(QString filePath)
|
||||
{
|
||||
QFile file;
|
||||
file.setFileName(filePath);
|
||||
file.open(QIODevice::ReadOnly);
|
||||
QByteArray byteArray = file.readAll();
|
||||
file.close();
|
||||
QString jsonString(byteArray);
|
||||
Json json;
|
||||
return json.decode(jsonString);
|
||||
}
|
||||
|
||||
|
||||
#if IMPL_DUMP_TO_FILE
|
||||
void JsonReader::dumpToFile(std::vector<cvf::Vec3d>& points, QString filePath)
|
||||
{
|
||||
QFile file;
|
||||
file.setFileName(filePath);
|
||||
file.open(QIODevice::WriteOnly);
|
||||
for (size_t idx = 0; idx < points.size(); idx++)
|
||||
{
|
||||
cvf::Vec3d point = points[idx];
|
||||
QString string;
|
||||
string.sprintf("(%0.10e, %0.10e, %0.10e)\n", point.x(), point.y(), point.z());
|
||||
QByteArray byteArray(string.toAscii());
|
||||
file.write(byteArray);
|
||||
}
|
||||
file.close();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
QString Json::encode(const QMap<QString,QVariant> &map)
|
||||
{
|
||||
QScriptEngine engine;
|
||||
engine.evaluate("function toString() { return JSON.stringify(this) }");
|
||||
|
||||
QScriptValue toString = engine.globalObject().property("toString");
|
||||
QScriptValue obj = encodeInner(map, &engine);
|
||||
return toString.call(obj).toString();
|
||||
|
||||
}
|
||||
|
||||
QMap<QString, QVariant> Json::decode(const QString &jsonStr)
|
||||
{
|
||||
QScriptValue object;
|
||||
QScriptEngine engine;
|
||||
object = engine.evaluate("(" + jsonStr + ")");
|
||||
return decodeInner(object);
|
||||
}
|
||||
|
||||
QScriptValue Json::encodeInner(const QMap<QString,QVariant> &map, QScriptEngine* engine)
|
||||
{
|
||||
QScriptValue obj = engine->newObject();
|
||||
QMapIterator<QString, QVariant> i(map);
|
||||
while (i.hasNext()) {
|
||||
i.next();
|
||||
if (i.value().type() == QVariant::String)
|
||||
obj.setProperty(i.key(), i.value().toString());
|
||||
else if (i.value().type() == QVariant::Int)
|
||||
obj.setProperty(i.key(), i.value().toInt());
|
||||
else if (i.value().type() == QVariant::Double)
|
||||
obj.setProperty(i.key(), i.value().toDouble());
|
||||
else if (i.value().type() == QVariant::List)
|
||||
obj.setProperty(i.key(), qScriptValueFromSequence(engine, i.value().toList()));
|
||||
else if (i.value().type() == QVariant::Map)
|
||||
obj.setProperty(i.key(), encodeInner(i.value().toMap(), engine));
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
|
||||
QMap<QString, QVariant> Json::decodeInner(QScriptValue object)
|
||||
{
|
||||
QMap<QString, QVariant> map;
|
||||
QScriptValueIterator it(object);
|
||||
while (it.hasNext()) {
|
||||
it.next();
|
||||
if (it.value().isArray())
|
||||
map.insert(it.name(),QVariant(decodeInnerToList(it.value())));
|
||||
else if (it.value().isNumber())
|
||||
map.insert(it.name(),QVariant(it.value().toNumber()));
|
||||
else if (it.value().isString())
|
||||
map.insert(it.name(),QVariant(it.value().toString()));
|
||||
else if (it.value().isNull())
|
||||
map.insert(it.name(),QVariant());
|
||||
else if(it.value().isObject())
|
||||
map.insert(it.name(),QVariant(decodeInner(it.value())));
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
QList<QVariant> Json::decodeInnerToList(QScriptValue arrayValue)
|
||||
{
|
||||
QList<QVariant> list;
|
||||
QScriptValueIterator it(arrayValue);
|
||||
while (it.hasNext()) {
|
||||
it.next();
|
||||
if (it.name() == "length")
|
||||
continue;
|
||||
|
||||
if (it.value().isArray())
|
||||
list.append(QVariant(decodeInnerToList(it.value())));
|
||||
else if (it.value().isNumber())
|
||||
list.append(QVariant(it.value().toNumber()));
|
||||
else if (it.value().isString())
|
||||
list.append(QVariant(it.value().toString()));
|
||||
else if (it.value().isNull())
|
||||
list.append(QVariant());
|
||||
else if(it.value().isObject())
|
||||
list.append(QVariant(decodeInner(it.value())));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2011-2013 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.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Json parser based on code example found on:
|
||||
// http://stackoverflow.com/questions/4169988/easiest-way-to-parse-json-in-qt-4-7
|
||||
|
||||
//#define IMPL_DUMP_TO_FILE
|
||||
|
||||
#include <QtCore/QVariant>
|
||||
#include <QtCore/QMap>
|
||||
#include <QtCore/QList>
|
||||
#include <QtCore/QString>
|
||||
#include <QtScript/QScriptValue>
|
||||
|
||||
#if IMPL_DUMP_TO_FILE
|
||||
#include <vector>
|
||||
#include <cvfVector3.h>
|
||||
#endif
|
||||
|
||||
class QScriptEngine;
|
||||
|
||||
class JsonReader
|
||||
{
|
||||
public:
|
||||
QMap<QString, QVariant> decodeFile(QString filePath);
|
||||
|
||||
#if IMPL_DUMP_TO_FILE
|
||||
void dumpToFile(std::vector<cvf::Vec3d>& points, QString filePath);
|
||||
#endif
|
||||
};
|
||||
|
||||
class Json
|
||||
{
|
||||
public:
|
||||
Json() {};
|
||||
QString encode(const QMap<QString,QVariant> &map);
|
||||
QMap<QString, QVariant> decode(const QString &jsonStr);
|
||||
|
||||
private:
|
||||
QScriptValue encodeInner(const QMap<QString,QVariant> &map, QScriptEngine* engine);
|
||||
QMap<QString, QVariant> decodeInner(QScriptValue object);
|
||||
QList<QVariant> decodeInnerToList(QScriptValue arrayValue);
|
||||
};
|
||||
@@ -141,10 +141,6 @@ bool transferGridCellData(RigMainGrid* mainGrid, RigActiveCellInfo* activeCellIn
|
||||
cell.setParentCellIndex(parentCellIndex);
|
||||
}
|
||||
|
||||
// Coarse cell info
|
||||
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)
|
||||
@@ -308,7 +304,8 @@ bool RifReaderEclipseOutput::transferGeometry(const ecl_grid_type* mainEclGrid,
|
||||
activeCellInfo->setGridActiveCellCounts(0, globalMatrixActiveSize);
|
||||
fractureActiveCellInfo->setGridActiveCellCounts(0, globalFractureActiveSize);
|
||||
|
||||
|
||||
transferCoarseningInfo(mainEclGrid, mainGrid);
|
||||
|
||||
|
||||
for (lgrIdx = 0; lgrIdx < numLGRs; ++lgrIdx)
|
||||
{
|
||||
@@ -327,6 +324,9 @@ bool RifReaderEclipseOutput::transferGeometry(const ecl_grid_type* mainEclGrid,
|
||||
|
||||
activeCellInfo->setGridActiveCellCounts(lgrIdx + 1, matrixActiveCellCount);
|
||||
fractureActiveCellInfo->setGridActiveCellCounts(lgrIdx + 1, fractureActiveCellCount);
|
||||
|
||||
transferCoarseningInfo(localEclGrid, localGrid);
|
||||
|
||||
progInfo.setProgress(3 + lgrIdx);
|
||||
}
|
||||
|
||||
@@ -360,6 +360,7 @@ bool RifReaderEclipseOutput::open(const QString& fileName, RigCaseData* eclipseC
|
||||
m_filesWithSameBaseName = fileSet;
|
||||
|
||||
// Read geometry
|
||||
// Todo: Needs to check existence of file before calling ert, else it will abort
|
||||
ecl_grid_type * mainEclGrid = ecl_grid_alloc( fileName.toAscii().data() );
|
||||
|
||||
progInfo.incrementProgress();
|
||||
@@ -1024,3 +1025,25 @@ std::vector<QDateTime> RifReaderEclipseOutput::timeSteps()
|
||||
return m_timeSteps;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RifReaderEclipseOutput::transferCoarseningInfo(const ecl_grid_type* eclGrid, RigGridBase* grid)
|
||||
{
|
||||
int coarseGroupCount = ecl_grid_get_num_coarse_groups(eclGrid);
|
||||
for (int i = 0; i < coarseGroupCount; i++)
|
||||
{
|
||||
ecl_coarse_cell_type* coarse_cell = ecl_grid_iget_coarse_group(eclGrid, i);
|
||||
CVF_ASSERT(coarse_cell);
|
||||
|
||||
size_t i1 = static_cast<size_t>(ecl_coarse_cell_get_i1(coarse_cell));
|
||||
size_t i2 = static_cast<size_t>(ecl_coarse_cell_get_i2(coarse_cell));
|
||||
size_t j1 = static_cast<size_t>(ecl_coarse_cell_get_j1(coarse_cell));
|
||||
size_t j2 = static_cast<size_t>(ecl_coarse_cell_get_j2(coarse_cell));
|
||||
size_t k1 = static_cast<size_t>(ecl_coarse_cell_get_k1(coarse_cell));
|
||||
size_t k2 = static_cast<size_t>(ecl_coarse_cell_get_k2(coarse_cell));
|
||||
|
||||
grid->addCoarseningBox(i1, i2, j1, j2, k1, k2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,6 +51,7 @@ public:
|
||||
bool dynamicResult(const QString& result, PorosityModelResultType matrixOrFracture, size_t stepIndex, std::vector<double>* values);
|
||||
|
||||
static bool transferGeometry(const ecl_grid_type* mainEclGrid, RigCaseData* eclipseCase);
|
||||
static void transferCoarseningInfo(const ecl_grid_type* eclGrid, RigGridBase* grid);
|
||||
|
||||
private:
|
||||
bool readActiveCellInfo();
|
||||
|
||||
@@ -11,6 +11,8 @@ ${CEE_CURRENT_LIST_DIR}RivReservoirPartMgr.h
|
||||
${CEE_CURRENT_LIST_DIR}RivReservoirViewPartMgr.h
|
||||
${CEE_CURRENT_LIST_DIR}RivPipeGeometryGenerator.h
|
||||
${CEE_CURRENT_LIST_DIR}RivReservoirPipesPartMgr.h
|
||||
${CEE_CURRENT_LIST_DIR}RivWellPathPartMgr.h
|
||||
${CEE_CURRENT_LIST_DIR}RivWellPathCollectionPartMgr.h
|
||||
${CEE_CURRENT_LIST_DIR}RivWellPipesPartMgr.h
|
||||
${CEE_CURRENT_LIST_DIR}RivWellHeadPartMgr.h
|
||||
)
|
||||
@@ -22,6 +24,8 @@ ${CEE_CURRENT_LIST_DIR}RivReservoirPartMgr.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RivReservoirViewPartMgr.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RivPipeGeometryGenerator.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RivReservoirPipesPartMgr.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RivWellPathPartMgr.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RivWellPathCollectionPartMgr.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RivWellPipesPartMgr.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RivWellHeadPartMgr.cpp
|
||||
)
|
||||
|
||||
@@ -44,6 +44,8 @@
|
||||
#include <QFile>
|
||||
#include <QTextStream>
|
||||
|
||||
#include "RimCase.h"
|
||||
|
||||
#include "RimReservoirView.h"
|
||||
#include "RimResultSlot.h"
|
||||
|
||||
@@ -53,7 +55,16 @@
|
||||
#include "RigCaseData.h"
|
||||
#include "RigActiveCellInfo.h"
|
||||
|
||||
#include "RimReservoirCellResultsCacher.h"
|
||||
|
||||
#include "cafPdmFieldCvfMat4d.h"
|
||||
#include "cafPdmFieldCvfColor.h"
|
||||
#include "RimResultSlot.h"
|
||||
#include "RimCellEdgeResultSlot.h"
|
||||
#include "RimCellRangeFilterCollection.h"
|
||||
#include "RimCellPropertyFilterCollection.h"
|
||||
#include "RimWellCollection.h"
|
||||
#include "Rim3dOverlayInfoConfig.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RiaStdInclude.h"
|
||||
#include "RivGridPartMgr.h"
|
||||
|
||||
#include "cvfPart.h"
|
||||
#include "cafEffectGenerator.h"
|
||||
#include "cvfStructGrid.h"
|
||||
@@ -27,12 +27,22 @@
|
||||
#include "RimReservoirView.h"
|
||||
#include "RimResultSlot.h"
|
||||
#include "RimCellEdgeResultSlot.h"
|
||||
#include "RigGridScalarDataAccess.h"
|
||||
#include "RigCaseCellResultsData.h"
|
||||
#include "RigCaseData.h"
|
||||
#include "RiaApplication.h"
|
||||
#include "RiaPreferences.h"
|
||||
|
||||
#include "RimCase.h"
|
||||
#include "RimWellCollection.h"
|
||||
#include "cafPdmFieldCvfMat4d.h"
|
||||
#include "cafPdmFieldCvfColor.h"
|
||||
#include "RimCellRangeFilterCollection.h"
|
||||
#include "RimCellPropertyFilterCollection.h"
|
||||
#include "Rim3dOverlayInfoConfig.h"
|
||||
#include "RimReservoirCellResultsCacher.h"
|
||||
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
#include "cvfBase.h"
|
||||
#include "cvfObject.h"
|
||||
|
||||
#include "cvfStructGridGeometryGenerator.h"
|
||||
#include "RigGridBase.h"
|
||||
|
||||
@@ -469,7 +469,7 @@ void RivPipeGeometryGenerator::updateFilteredPipeCenterCoords()
|
||||
if (m_filteredPipeCenterCoords.size() > 0) return;
|
||||
|
||||
|
||||
double distanceTolerance = 1e-10;
|
||||
double squareDistanceTolerance = 1e-4*1e-4;
|
||||
double angleTolerance = 1e-5;
|
||||
|
||||
size_t firstSegmentWithLength = 0;
|
||||
@@ -477,7 +477,8 @@ void RivPipeGeometryGenerator::updateFilteredPipeCenterCoords()
|
||||
for (i = 0; i < m_originalPipeCenterCoords->size() - 1; i++)
|
||||
{
|
||||
cvf::Vec3d candidateDir = (*m_originalPipeCenterCoords)[i] - (*m_originalPipeCenterCoords)[i+1];
|
||||
if (candidateDir.normalize())
|
||||
double dirLengthSq = candidateDir.lengthSquared();
|
||||
if (dirLengthSq > squareDistanceTolerance && candidateDir.normalize())
|
||||
{
|
||||
firstSegmentWithLength = i;
|
||||
break;
|
||||
@@ -502,14 +503,15 @@ void RivPipeGeometryGenerator::updateFilteredPipeCenterCoords()
|
||||
cvf::Vec3d directionAB = coordB - coordA;
|
||||
|
||||
// Skip segment lengths below tolerance
|
||||
if (directionAB.lengthSquared() > distanceTolerance)
|
||||
double dirLengthSq = directionAB.lengthSquared();
|
||||
if (directionAB.lengthSquared() > squareDistanceTolerance)
|
||||
{
|
||||
lastValidDirectionAB = directionAB.getNormalized();
|
||||
lastValidSegment = i;
|
||||
}
|
||||
|
||||
cvf::Vec3d directionBC = coordC - coordB;
|
||||
if (directionBC.lengthSquared() < distanceTolerance)
|
||||
if (directionBC.lengthSquared() < squareDistanceTolerance)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -550,7 +552,7 @@ void RivPipeGeometryGenerator::updateFilteredPipeCenterCoords()
|
||||
cvf::Vec3d coordB = m_originalPipeCenterCoords->get(m_originalPipeCenterCoords->size() - 1);
|
||||
|
||||
cvf::Vec3d directionAB = coordB - coordA;
|
||||
if (directionAB.lengthSquared() > distanceTolerance)
|
||||
if (directionAB.lengthSquared() > squareDistanceTolerance)
|
||||
{
|
||||
m_filteredPipeCenterCoords.push_back(m_originalPipeCenterCoords->get(m_originalPipeCenterCoords->size() - 1));
|
||||
}
|
||||
|
||||
@@ -23,7 +23,14 @@
|
||||
#include "RimWellCollection.h"
|
||||
#include "RivWellPipesPartMgr.h"
|
||||
#include "RivWellHeadPartMgr.h"
|
||||
#include "RimCellEdgeResultSlot.h"
|
||||
|
||||
#include "cafPdmFieldCvfMat4d.h"
|
||||
#include "cafPdmFieldCvfColor.h"
|
||||
#include "RimResultSlot.h"
|
||||
#include "RimCellRangeFilterCollection.h"
|
||||
#include "RimCellPropertyFilterCollection.h"
|
||||
#include "Rim3dOverlayInfoConfig.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
|
||||
@@ -24,6 +24,19 @@
|
||||
#include "RigGridBase.h"
|
||||
#include "RigCaseCellResultsData.h"
|
||||
#include "RigGridScalarDataAccess.h"
|
||||
#include "RimCase.h"
|
||||
#include "RimCellRangeFilterCollection.h"
|
||||
#include "RimWellCollection.h"
|
||||
#include "RimCellPropertyFilterCollection.h"
|
||||
#include "RimResultDefinition.h"
|
||||
|
||||
#include "cafPdmFieldCvfMat4d.h"
|
||||
#include "cafPdmFieldCvfColor.h"
|
||||
|
||||
#include "RimResultSlot.h"
|
||||
#include "RimCellEdgeResultSlot.h"
|
||||
#include "Rim3dOverlayInfoConfig.h"
|
||||
#include "RimReservoirCellResultsCacher.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
@@ -730,4 +743,4 @@ RivReservoirPartMgr * RivReservoirViewPartMgr::reservoirPartManager(ReservoirGeo
|
||||
{
|
||||
return &m_geometries[geometryType];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -35,6 +35,18 @@
|
||||
#include "cvfqtUtils.h"
|
||||
|
||||
#include "RimReservoirView.h"
|
||||
#include "RimWellCollection.h"
|
||||
#include "cafPdmFieldCvfMat4d.h"
|
||||
#include "RimCellEdgeResultSlot.h"
|
||||
#include "RimCellRangeFilterCollection.h"
|
||||
#include "RimCellPropertyFilterCollection.h"
|
||||
#include "Rim3dOverlayInfoConfig.h"
|
||||
#include "RimReservoirCellResultsCacher.h"
|
||||
#include "RimResultSlot.h"
|
||||
#include "RimLegendConfig.h"
|
||||
|
||||
#include "RimCase.h"
|
||||
#include "RimWell.h"
|
||||
|
||||
#include "RigCaseData.h"
|
||||
#include "RigCell.h"
|
||||
@@ -239,7 +251,6 @@ void RivWellHeadPartMgr::buildWellHeadParts(size_t frameIndex)
|
||||
drawableText->setDrawBorder(false);
|
||||
drawableText->setDrawBackground(false);
|
||||
drawableText->setVerticalAlignment(cvf::TextDrawer::CENTER);
|
||||
//drawableText->setTextColor(cvf::Color3f(0.08f, 0.08f, 0.08f));
|
||||
drawableText->setTextColor(cvf::Color3f(0.92f, 0.92f, 0.92f));
|
||||
|
||||
cvf::String cvfString = cvfqt::Utils::fromQString(well->name());
|
||||
@@ -254,7 +265,7 @@ void RivWellHeadPartMgr::buildWellHeadParts(size_t frameIndex)
|
||||
cvf::ref<cvf::Effect> eff = new cvf::Effect;
|
||||
|
||||
part->setEffect(eff.p());
|
||||
part->setPriority(1000);
|
||||
part->setPriority(11);
|
||||
|
||||
m_wellHeadParts.push_back(part.p());
|
||||
}
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 "RivWellPathCollectionPartMgr.h"
|
||||
#include "RimProject.h"
|
||||
#include "RimCase.h"
|
||||
#include "RimIdenticalGridCaseGroup.h"
|
||||
#include "RimScriptCollection.h"
|
||||
#include "RimReservoirView.h"
|
||||
#include "RimReservoirCellResultsCacher.h"
|
||||
#include "RimCaseCollection.h"
|
||||
#include "RimResultSlot.h"
|
||||
#include "RimCellEdgeResultSlot.h"
|
||||
#include "RimCellPropertyFilterCollection.h"
|
||||
#include "RimWellCollection.h"
|
||||
#include "Rim3dOverlayInfoConfig.h"
|
||||
#include "RimWellPathCollection.h"
|
||||
#include "RivWellPathPartMgr.h"
|
||||
#include "RimWellPathCollection.h"
|
||||
#include "RimCellRangeFilterCollection.h"
|
||||
#include "RimOilField.h"
|
||||
#include "RimAnalysisModels.h"
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RivWellPathCollectionPartMgr::RivWellPathCollectionPartMgr(RimWellPathCollection* wellPathCollection)
|
||||
{
|
||||
m_wellPathCollection = wellPathCollection;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RivWellPathCollectionPartMgr::~RivWellPathCollectionPartMgr()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivWellPathCollectionPartMgr::scheduleGeometryRegen()
|
||||
{
|
||||
for (size_t wIdx = 0; wIdx < m_wellPathCollection->wellPaths.size(); wIdx++)
|
||||
{
|
||||
m_wellPathCollection->wellPaths[wIdx]->partMgr()->scheduleGeometryRegen();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivWellPathCollectionPartMgr::setScaleTransform(cvf::Transform * scaleTransform)
|
||||
{
|
||||
for (size_t wIdx = 0; wIdx < m_wellPathCollection->wellPaths.size(); wIdx++)
|
||||
{
|
||||
m_wellPathCollection->wellPaths[wIdx]->partMgr()->setScaleTransform(scaleTransform);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivWellPathCollectionPartMgr::appendStaticGeometryPartsToModel(cvf::ModelBasicList* model, cvf::Vec3d displayModelOffset, cvf::Transform* scaleTransform, double characteristicCellSize, cvf::BoundingBox boundingBox)
|
||||
{
|
||||
setScaleTransform(scaleTransform);
|
||||
|
||||
if (m_wellPathCollection->wellPathVisibility() == RimWellPathCollection::FORCE_ALL_OFF) return;
|
||||
|
||||
for (size_t wIdx = 0; wIdx < m_wellPathCollection->wellPaths.size(); wIdx++)
|
||||
{
|
||||
RivWellPathPartMgr* partMgr = m_wellPathCollection->wellPaths[wIdx]->partMgr();
|
||||
partMgr->setScaleTransform(scaleTransform);
|
||||
partMgr->appendStaticGeometryPartsToModel(model, displayModelOffset, characteristicCellSize, boundingBox);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 "cvfCollection.h"
|
||||
#include "cafPdmPointer.h"
|
||||
|
||||
class RimWellPathCollection;
|
||||
class RimProject;
|
||||
class RivWellPathPartMgr;
|
||||
|
||||
class RivWellPathCollectionPartMgr : public cvf::Object
|
||||
{
|
||||
public:
|
||||
RivWellPathCollectionPartMgr(RimWellPathCollection* wellPathCollection);
|
||||
~RivWellPathCollectionPartMgr();
|
||||
|
||||
void scheduleGeometryRegen();
|
||||
|
||||
void setScaleTransform(cvf::Transform * scaleTransform);
|
||||
|
||||
void appendStaticGeometryPartsToModel(
|
||||
cvf::ModelBasicList* model,
|
||||
cvf::Vec3d displayModelOffset,
|
||||
cvf::Transform* scaleTransform,
|
||||
double characteristicCellSize,
|
||||
cvf::BoundingBox boundingBox);
|
||||
|
||||
private:
|
||||
caf::PdmPointer<RimWellPathCollection> m_wellPathCollection;
|
||||
cvf::ref<cvf::Transform> m_scaleTransform;
|
||||
};
|
||||
@@ -0,0 +1,280 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 "cvfLibCore.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
#include "RimCase.h"
|
||||
#include "RimProject.h"
|
||||
#include "RimWellPathCollection.h"
|
||||
#include "RimReservoirCellResultsCacher.h"
|
||||
#include "RimIdenticalGridCaseGroup.h"
|
||||
#include "RimScriptCollection.h"
|
||||
#include "RimCaseCollection.h"
|
||||
#include "RimResultSlot.h"
|
||||
#include "RimCellEdgeResultSlot.h"
|
||||
#include "RimCellRangeFilterCollection.h"
|
||||
#include "RimCellPropertyFilterCollection.h"
|
||||
#include "RimWellCollection.h"
|
||||
#include "Rim3dOverlayInfoConfig.h"
|
||||
#include "RimReservoirView.h"
|
||||
#include "RigCaseData.h"
|
||||
#include "RigCell.h"
|
||||
#include "RivWellPathPartMgr.h"
|
||||
#include "RimWellPath.h"
|
||||
#include "RivPipeGeometryGenerator.h"
|
||||
#include "cvfModelBasicList.h"
|
||||
#include "cvfTransform.h"
|
||||
#include "cvfPart.h"
|
||||
#include "cvfScalarMapperDiscreteLinear.h"
|
||||
#include "cvfDrawableGeo.h"
|
||||
#include "cvfDrawableText.h"
|
||||
#include "cvfRay.h"
|
||||
#include "cafEffectGenerator.h"
|
||||
#include "cvfqtUtils.h"
|
||||
#include "RimOilField.h"
|
||||
#include "RimAnalysisModels.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RivWellPathPartMgr::RivWellPathPartMgr(RimWellPathCollection* wellPathCollection, RimWellPath* wellPath)
|
||||
{
|
||||
m_wellPathCollection = wellPathCollection;
|
||||
m_rimWellPath = wellPath;
|
||||
|
||||
m_needsTransformUpdate = true;
|
||||
|
||||
// Setup a scalar mapper
|
||||
cvf::ref<cvf::ScalarMapperDiscreteLinear> scalarMapper = new cvf::ScalarMapperDiscreteLinear;
|
||||
cvf::Color3ubArray legendColors;
|
||||
legendColors.resize(4);
|
||||
legendColors[0] = cvf::Color3::GRAY;
|
||||
legendColors[1] = cvf::Color3::GREEN;
|
||||
legendColors[2] = cvf::Color3::BLUE;
|
||||
legendColors[3] = cvf::Color3::RED;
|
||||
scalarMapper->setColors(legendColors);
|
||||
scalarMapper->setRange(0.0 , 4.0);
|
||||
scalarMapper->setLevelCount(4, true);
|
||||
|
||||
m_scalarMapper = scalarMapper;
|
||||
|
||||
caf::ScalarMapperEffectGenerator surfEffGen(scalarMapper.p(), true);
|
||||
m_scalarMapperSurfaceEffect = surfEffGen.generateEffect();
|
||||
|
||||
caf::ScalarMapperMeshEffectGenerator meshEffGen(scalarMapper.p());
|
||||
m_scalarMapperMeshEffect = meshEffGen.generateEffect();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RivWellPathPartMgr::~RivWellPathPartMgr()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivWellPathPartMgr::buildWellPathParts(cvf::Vec3d displayModelOffset, double characteristicCellSize, cvf::BoundingBox boundingBox)
|
||||
{
|
||||
if (m_wellPathCollection.isNull()) return;
|
||||
|
||||
RigWellPath* wellPathGeometry = m_rimWellPath->wellPathGeometry();
|
||||
if (!wellPathGeometry) return;
|
||||
|
||||
if (wellPathGeometry->m_wellPathPoints.size() < 2) return;
|
||||
|
||||
m_wellBranches.clear();
|
||||
double wellPathRadius = m_wellPathCollection->wellPathRadiusScaleFactor() * m_rimWellPath->wellPathRadiusScaleFactor() * characteristicCellSize;
|
||||
|
||||
// cvf::Vec3d firstPoint = wellPathGeometry->m_wellPathPoints[0];
|
||||
// firstPoint -= displayModelOffset;
|
||||
// firstPoint.transformPoint(m_scaleTransform->worldTransform());
|
||||
// printf("Well path start pos = (%f, %f, %f)\n", firstPoint.x(), firstPoint.y(), firstPoint.z());
|
||||
cvf::Vec3d textPosition = wellPathGeometry->m_wellPathPoints[0];
|
||||
|
||||
// Generate well path as pipe structure
|
||||
{
|
||||
m_wellBranches.push_back(RivPipeBranchData());
|
||||
RivPipeBranchData& pbd = m_wellBranches.back();
|
||||
|
||||
pbd.m_pipeGeomGenerator = new RivPipeGeometryGenerator;
|
||||
|
||||
pbd.m_pipeGeomGenerator->setRadius(wellPathRadius);
|
||||
pbd.m_pipeGeomGenerator->setCrossSectionVertexCount(m_wellPathCollection->wellPathCrossSectionVertexCount());
|
||||
pbd.m_pipeGeomGenerator->setPipeColor( m_rimWellPath->wellPathColor());
|
||||
|
||||
cvf::ref<cvf::Vec3dArray> cvfCoords = new cvf::Vec3dArray;
|
||||
if (m_wellPathCollection->wellPathClip)
|
||||
{
|
||||
std::vector<cvf::Vec3d> clippedPoints;
|
||||
for (size_t idx = 0; idx < wellPathGeometry->m_wellPathPoints.size(); idx++)
|
||||
{
|
||||
cvf::Vec3d point = wellPathGeometry->m_wellPathPoints[idx];
|
||||
if (point.z() < (boundingBox.max().z() + m_wellPathCollection->wellPathClipZDistance))
|
||||
clippedPoints.push_back(point);
|
||||
}
|
||||
if (clippedPoints.size() < 2) return;
|
||||
|
||||
textPosition = clippedPoints[0];
|
||||
cvfCoords->assign(clippedPoints);
|
||||
}
|
||||
else
|
||||
{
|
||||
cvfCoords->assign(wellPathGeometry->m_wellPathPoints);
|
||||
}
|
||||
|
||||
// Scale the centerline coordinates using the Z-scale transform of the grid and correct for the display offset.
|
||||
for (size_t cIdx = 0; cIdx < cvfCoords->size(); ++cIdx)
|
||||
{
|
||||
cvf::Vec4d transfCoord = m_scaleTransform->worldTransform() * cvf::Vec4d((*cvfCoords)[cIdx] - displayModelOffset, 1);
|
||||
(*cvfCoords)[cIdx][0] = transfCoord[0];
|
||||
(*cvfCoords)[cIdx][1] = transfCoord[1];
|
||||
(*cvfCoords)[cIdx][2] = transfCoord[2];
|
||||
}
|
||||
|
||||
pbd.m_pipeGeomGenerator->setPipeCenterCoords(cvfCoords.p());
|
||||
pbd.m_surfaceDrawable = pbd.m_pipeGeomGenerator->createPipeSurface();
|
||||
pbd.m_centerLineDrawable = pbd.m_pipeGeomGenerator->createCenterLine();
|
||||
|
||||
if (pbd.m_surfaceDrawable.notNull())
|
||||
{
|
||||
pbd.m_surfacePart = new cvf::Part;
|
||||
pbd.m_surfacePart->setDrawable(pbd.m_surfaceDrawable.p());
|
||||
//printf("Well Path triangleCount = %i (%i points in well path)\n", pbd.m_surfaceDrawable->triangleCount(), wellPathGeometry->m_wellPathPoints.size());
|
||||
|
||||
caf::SurfaceEffectGenerator surfaceGen(cvf::Color4f(m_rimWellPath->wellPathColor()), true);
|
||||
cvf::ref<cvf::Effect> eff = surfaceGen.generateEffect();
|
||||
|
||||
pbd.m_surfacePart->setEffect(eff.p());
|
||||
}
|
||||
|
||||
if (pbd.m_centerLineDrawable.notNull())
|
||||
{
|
||||
pbd.m_centerLinePart = new cvf::Part;
|
||||
pbd.m_centerLinePart->setDrawable(pbd.m_centerLineDrawable.p());
|
||||
//printf("Well Path vertexCount = %i\n", pbd.m_centerLineDrawable->vertexCount());
|
||||
|
||||
caf::MeshEffectGenerator gen(m_rimWellPath->wellPathColor());
|
||||
cvf::ref<cvf::Effect> eff = gen.generateEffect();
|
||||
|
||||
pbd.m_centerLinePart->setEffect(eff.p());
|
||||
}
|
||||
}
|
||||
|
||||
// Generate label with well path name
|
||||
textPosition -= displayModelOffset;
|
||||
textPosition.transformPoint(m_scaleTransform->worldTransform());
|
||||
textPosition.z() += characteristicCellSize; // * m_rimReservoirView->wellCollection()->wellHeadScaleFactor();
|
||||
textPosition.z() += 1.2 * characteristicCellSize;
|
||||
|
||||
m_wellLabelPart = NULL;
|
||||
if (m_wellPathCollection->showWellPathLabel() && m_rimWellPath->showWellPathLabel())
|
||||
{
|
||||
cvf::Font* standardFont = RiaApplication::instance()->standardFont();
|
||||
|
||||
cvf::ref<cvf::DrawableText> drawableText = new cvf::DrawableText;
|
||||
drawableText->setFont(standardFont);
|
||||
drawableText->setCheckPosVisible(false);
|
||||
drawableText->setDrawBorder(false);
|
||||
drawableText->setDrawBackground(false);
|
||||
drawableText->setVerticalAlignment(cvf::TextDrawer::CENTER);
|
||||
//drawableText->setTextColor(cvf::Color3f(0.08f, 0.08f, 0.08f));
|
||||
drawableText->setTextColor(cvf::Color3f(0.92f, 0.92f, 0.92f));
|
||||
|
||||
cvf::String cvfString = cvfqt::Utils::fromQString(m_rimWellPath->name());
|
||||
|
||||
cvf::Vec3f textCoord(textPosition);
|
||||
drawableText->addText(cvfString, textCoord);
|
||||
|
||||
cvf::ref<cvf::Part> part = new cvf::Part;
|
||||
part->setName("RivWellHeadPartMgr: text " + cvfString);
|
||||
part->setDrawable(drawableText.p());
|
||||
|
||||
cvf::ref<cvf::Effect> eff = new cvf::Effect;
|
||||
|
||||
part->setEffect(eff.p());
|
||||
part->setPriority(1000);
|
||||
|
||||
m_wellLabelPart = part;
|
||||
}
|
||||
|
||||
m_needsTransformUpdate = false;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivWellPathPartMgr::appendStaticGeometryPartsToModel(cvf::ModelBasicList* model, cvf::Vec3d displayModelOffset, double characteristicCellSize, cvf::BoundingBox boundingBox)
|
||||
{
|
||||
if (m_wellPathCollection.isNull()) return;
|
||||
if (m_rimWellPath.isNull()) return;
|
||||
|
||||
if (m_wellPathCollection->wellPathVisibility() == RimWellPathCollection::FORCE_ALL_OFF)
|
||||
return;
|
||||
|
||||
if (m_wellPathCollection->wellPathVisibility() != RimWellPathCollection::FORCE_ALL_ON && m_rimWellPath->showWellPath() == false )
|
||||
return;
|
||||
|
||||
if (m_needsTransformUpdate)
|
||||
{
|
||||
//printf("G");
|
||||
buildWellPathParts(displayModelOffset, characteristicCellSize, boundingBox);
|
||||
}
|
||||
else
|
||||
{
|
||||
//printf("s");
|
||||
}
|
||||
|
||||
if (m_wellBranches.size() < 1)
|
||||
{
|
||||
//printf("RivWellPathPartMgr::appendStaticGeometryPartsToModel: There are no well branches in well \"%s\"!!!\n", (const char*) m_rimWellPath->name().toLocal8Bit());
|
||||
}
|
||||
|
||||
std::list<RivPipeBranchData>::iterator it;
|
||||
for (it = m_wellBranches.begin(); it != m_wellBranches.end(); it++)
|
||||
{
|
||||
if (it->m_surfacePart.notNull())
|
||||
{
|
||||
//printf("a");
|
||||
model->addPart(it->m_surfacePart.p());
|
||||
}
|
||||
if (it->m_centerLinePart.notNull())
|
||||
{
|
||||
model->addPart(it->m_centerLinePart.p());
|
||||
}
|
||||
}
|
||||
|
||||
if (m_wellLabelPart.notNull())
|
||||
{
|
||||
model->addPart(m_wellLabelPart.p());
|
||||
}
|
||||
}
|
||||
|
||||
void RivWellPathPartMgr::setScaleTransform( cvf::Transform * scaleTransform )
|
||||
{
|
||||
if (m_scaleTransform.isNull() || m_scaleTransform.p() != scaleTransform)
|
||||
{
|
||||
m_scaleTransform = scaleTransform;
|
||||
scheduleGeometryRegen();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 "cafPdmPointer.h"
|
||||
#include "cvfBoundingBox.h"
|
||||
#include <list>
|
||||
|
||||
namespace cvf
|
||||
{
|
||||
class Part;
|
||||
class ModelBasicList;
|
||||
class Transform;
|
||||
class Effect;
|
||||
}
|
||||
|
||||
class RivPipeGeometryGenerator;
|
||||
class RimProject;
|
||||
class RimWellPath;
|
||||
class RimWellPathCollection;
|
||||
|
||||
class RivWellPathPartMgr : public cvf::Object
|
||||
{
|
||||
public:
|
||||
RivWellPathPartMgr(RimWellPathCollection* wellPathCollection, RimWellPath* wellPath);
|
||||
~RivWellPathPartMgr();
|
||||
|
||||
void setScaleTransform(cvf::Transform * scaleTransform);
|
||||
|
||||
void scheduleGeometryRegen() { m_needsTransformUpdate = true; }//printf("R"); }
|
||||
|
||||
void appendStaticGeometryPartsToModel(cvf::ModelBasicList* model, cvf::Vec3d displayModelOffset, double characteristicCellSize, cvf::BoundingBox boundingBox);
|
||||
|
||||
private:
|
||||
caf::PdmPointer<RimWellPathCollection> m_wellPathCollection;
|
||||
caf::PdmPointer<RimWellPath> m_rimWellPath;
|
||||
|
||||
cvf::ref<cvf::Transform> m_scaleTransform;
|
||||
bool m_needsTransformUpdate;
|
||||
|
||||
void buildWellPathParts(cvf::Vec3d displayModelOffset, double characteristicCellSize, cvf::BoundingBox boundingBox);
|
||||
|
||||
struct RivPipeBranchData
|
||||
{
|
||||
cvf::ref<RivPipeGeometryGenerator> m_pipeGeomGenerator;
|
||||
cvf::ref<cvf::Part> m_surfacePart;
|
||||
cvf::ref<cvf::DrawableGeo> m_surfaceDrawable;
|
||||
cvf::ref<cvf::Part> m_centerLinePart;
|
||||
cvf::ref<cvf::DrawableGeo> m_centerLineDrawable;
|
||||
};
|
||||
|
||||
RivPipeBranchData m_pipeBranchData;
|
||||
std::list<RivPipeBranchData> m_wellBranches;
|
||||
cvf::ref<cvf::Part> m_wellLabelPart;
|
||||
|
||||
cvf::ref<cvf::ScalarMapper> m_scalarMapper;
|
||||
cvf::ref<cvf::Effect> m_scalarMapperSurfaceEffect;
|
||||
cvf::ref<cvf::Effect> m_scalarMapperMeshEffect;
|
||||
};
|
||||
@@ -16,22 +16,37 @@
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RivWellPipesPartMgr.h"
|
||||
|
||||
#include "cvfLibCore.h"
|
||||
|
||||
#include "RimCase.h"
|
||||
#include "RigCaseData.h"
|
||||
#include "RivWellPipesPartMgr.h"
|
||||
#include "RigCell.h"
|
||||
#include "RivPipeGeometryGenerator.h"
|
||||
#include "cvfModelBasicList.h"
|
||||
#include "cvfTransform.h"
|
||||
#include "cvfPart.h"
|
||||
#include "cvfScalarMapperDiscreteLinear.h"
|
||||
#include "cvfDrawableGeo.h"
|
||||
#include "cvfRay.h"
|
||||
|
||||
#include "cafEffectGenerator.h"
|
||||
#include "cafPdmFieldCvfColor.h"
|
||||
#include "cafPdmFieldCvfMat4d.h"
|
||||
|
||||
#include "RigCaseData.h"
|
||||
#include "RigCell.h"
|
||||
#include "RivPipeGeometryGenerator.h"
|
||||
|
||||
#include "RimCase.h"
|
||||
#include "RimReservoirView.h"
|
||||
#include "RimWellCollection.h"
|
||||
#include "RimReservoirCellResultsCacher.h"
|
||||
|
||||
#include "RimResultSlot.h"
|
||||
#include "RimCellEdgeResultSlot.h"
|
||||
#include "RimCellRangeFilterCollection.h"
|
||||
#include "RimCellPropertyFilterCollection.h"
|
||||
#include "Rim3dOverlayInfoConfig.h"
|
||||
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
|
||||
@@ -18,6 +18,10 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cvfBase.h"
|
||||
#include "cvfObject.h"
|
||||
#include "cvfVector3.h"
|
||||
|
||||
#include "cafPdmPointer.h"
|
||||
#include <list>
|
||||
#include "RigSingleWellResultsData.h"
|
||||
@@ -28,6 +32,8 @@ namespace cvf
|
||||
class ModelBasicList;
|
||||
class Transform;
|
||||
class Effect;
|
||||
class DrawableGeo;
|
||||
class ScalarMapper;
|
||||
}
|
||||
|
||||
class RivPipeGeometryGenerator;
|
||||
|
||||
@@ -5,6 +5,7 @@ if (${CMAKE_VERSION} VERSION_GREATER "2.8.2")
|
||||
endif()
|
||||
|
||||
set (SOURCE_GROUP_HEADER_FILES
|
||||
${CEE_CURRENT_LIST_DIR}RimAnalysisModels.h
|
||||
${CEE_CURRENT_LIST_DIR}RimCaseCollection.h
|
||||
${CEE_CURRENT_LIST_DIR}RimCellFilter.h
|
||||
${CEE_CURRENT_LIST_DIR}RimCellPropertyFilter.h
|
||||
@@ -13,6 +14,7 @@ ${CEE_CURRENT_LIST_DIR}RimCellRangeFilter.h
|
||||
${CEE_CURRENT_LIST_DIR}RimCellRangeFilterCollection.h
|
||||
${CEE_CURRENT_LIST_DIR}RimDefines.h
|
||||
${CEE_CURRENT_LIST_DIR}RimLegendConfig.h
|
||||
${CEE_CURRENT_LIST_DIR}RimOilField.h
|
||||
${CEE_CURRENT_LIST_DIR}RimProject.h
|
||||
${CEE_CURRENT_LIST_DIR}RimCase.h
|
||||
${CEE_CURRENT_LIST_DIR}RimIdenticalGridCaseGroup.h
|
||||
@@ -26,6 +28,8 @@ ${CEE_CURRENT_LIST_DIR}RimResultSlot.h
|
||||
${CEE_CURRENT_LIST_DIR}RimCellEdgeResultSlot.h
|
||||
${CEE_CURRENT_LIST_DIR}RimWell.h
|
||||
${CEE_CURRENT_LIST_DIR}RimWellCollection.h
|
||||
${CEE_CURRENT_LIST_DIR}RimWellPath.h
|
||||
${CEE_CURRENT_LIST_DIR}RimWellPathCollection.h
|
||||
${CEE_CURRENT_LIST_DIR}RimScriptCollection.h
|
||||
${CEE_CURRENT_LIST_DIR}RimStatisticsCase.h
|
||||
${CEE_CURRENT_LIST_DIR}RimStatisticsCaseCollection.h
|
||||
@@ -41,6 +45,7 @@ ${CEE_CURRENT_LIST_DIR}RimMimeData.h
|
||||
)
|
||||
|
||||
set (SOURCE_GROUP_SOURCE_FILES
|
||||
${CEE_CURRENT_LIST_DIR}RimAnalysisModels.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RimCaseCollection.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RimCellFilter.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RimCellPropertyFilter.cpp
|
||||
@@ -49,6 +54,7 @@ ${CEE_CURRENT_LIST_DIR}RimCellRangeFilter.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RimCellRangeFilterCollection.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RimDefines.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RimLegendConfig.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RimOilField.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RimProject.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RimCase.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RimIdenticalGridCaseGroup.cpp
|
||||
@@ -62,6 +68,8 @@ ${CEE_CURRENT_LIST_DIR}RimResultSlot.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RimCellEdgeResultSlot.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RimWell.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RimWellCollection.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RimWellPath.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RimWellPathCollection.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RimScriptCollection.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RimStatisticsCase.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RimStatisticsCaseCollection.cpp
|
||||
|
||||
@@ -16,14 +16,21 @@
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RiaStdInclude.h"
|
||||
|
||||
#include "Rim3dOverlayInfoConfig.h"
|
||||
|
||||
#include "RimReservoirView.h"
|
||||
#include "RiuViewer.h"
|
||||
#include "RimCase.h"
|
||||
#include "RigCaseData.h"
|
||||
#include "RigMainGrid.h"
|
||||
#include "RimResultSlot.h"
|
||||
#include "RimCellEdgeResultSlot.h"
|
||||
#include "RimReservoirCellResultsCacher.h"
|
||||
|
||||
#include "RimCellPropertyFilterCollection.h"
|
||||
#include "RimCellRangeFilterCollection.h"
|
||||
|
||||
#include "RimWellCollection.h"
|
||||
#include "cafPdmFieldCvfMat4d.h"
|
||||
#include "RigCaseCellResultsData.h"
|
||||
|
||||
CAF_PDM_SOURCE_INIT(Rim3dOverlayInfoConfig, "View3dOverlayInfoConfig");
|
||||
|
||||
@@ -23,6 +23,9 @@
|
||||
#include "cafPdmField.h"
|
||||
#include "cafAppEnum.h"
|
||||
|
||||
#include "cvfAssert.h"
|
||||
|
||||
#include "cvfVector2.h"
|
||||
|
||||
class RimReservoirView;
|
||||
//==================================================================================================
|
||||
|
||||
@@ -0,0 +1,215 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 "RimAnalysisModels.h"
|
||||
#include "RiaApplication.h"
|
||||
#include "RimProject.h"
|
||||
#include "cafAppEnum.h"
|
||||
#include "RimReservoirView.h"
|
||||
|
||||
#include "RimIdenticalGridCaseGroup.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
#include "RiaVersionInfo.h"
|
||||
|
||||
#include "RigGridManager.h"
|
||||
#include "RigCaseData.h"
|
||||
#include "RimResultCase.h"
|
||||
#include "RimWellPathCollection.h"
|
||||
|
||||
|
||||
#include "cafPdmFieldCvfColor.h"
|
||||
#include "cafPdmFieldCvfMat4d.h"
|
||||
#include "RimReservoirCellResultsCacher.h"
|
||||
#include "RimCellEdgeResultSlot.h"
|
||||
#include "RimCellRangeFilterCollection.h"
|
||||
#include "RimCellPropertyFilterCollection.h"
|
||||
#include "Rim3dOverlayInfoConfig.h"
|
||||
#include "RimWellCollection.h"
|
||||
#include "RimCaseCollection.h"
|
||||
#include "RimResultSlot.h"
|
||||
#include "RimStatisticsCase.h"
|
||||
#include "RimOilField.h"
|
||||
#include "RimScriptCollection.h"
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimAnalysisModels, "ResInsightAnalysisModels");
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimAnalysisModels::RimAnalysisModels(void)
|
||||
{
|
||||
CAF_PDM_InitObject("Grid Models", ":/Cases16x16.png", "", "");
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&cases, "Reservoirs", "", "", "", "");
|
||||
CAF_PDM_InitFieldNoDefault(&caseGroups, "CaseGroups", "", "", "", "");
|
||||
|
||||
m_gridCollection = new RigGridManager;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimAnalysisModels::~RimAnalysisModels(void)
|
||||
{
|
||||
close();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimAnalysisModels::close()
|
||||
{
|
||||
m_gridCollection->clear();
|
||||
|
||||
cases.deleteAllChildObjects();
|
||||
caseGroups.deleteAllChildObjects();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimIdenticalGridCaseGroup* RimAnalysisModels::createIdenticalCaseGroupFromMainCase(RimCase* mainCase)
|
||||
{
|
||||
CVF_ASSERT(mainCase);
|
||||
|
||||
RigCaseData* rigEclipseCase = mainCase->reservoirData();
|
||||
RigMainGrid* equalGrid = registerCaseInGridCollection(rigEclipseCase);
|
||||
CVF_ASSERT(equalGrid);
|
||||
|
||||
RimIdenticalGridCaseGroup* group = new RimIdenticalGridCaseGroup;
|
||||
assert(RiaApplication::instance()->project());
|
||||
RiaApplication::instance()->project()->assignIdToCaseGroup(group);
|
||||
|
||||
RimCase* createdCase = group->createAndAppendStatisticsCase();
|
||||
RiaApplication::instance()->project()->assignCaseIdToCase(createdCase);
|
||||
|
||||
group->addCase(mainCase);
|
||||
caseGroups().push_back(group);
|
||||
|
||||
return group;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimAnalysisModels::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;
|
||||
assert(RiaApplication::instance()->project());
|
||||
RiaApplication::instance()->project()->assignIdToCaseGroup(group);
|
||||
|
||||
group->addCase(rimReservoir);
|
||||
|
||||
caseGroups().push_back(group);
|
||||
}
|
||||
|
||||
// Remove reservoir from main container
|
||||
cases().removeChildObject(rimReservoir);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimAnalysisModels::removeCaseFromAllGroups(RimCase* reservoir)
|
||||
{
|
||||
m_gridCollection->removeCase(reservoir->reservoirData());
|
||||
|
||||
for (size_t i = 0; i < caseGroups.size(); i++)
|
||||
{
|
||||
RimIdenticalGridCaseGroup* cg = caseGroups()[i];
|
||||
|
||||
cg->removeCase(reservoir);
|
||||
}
|
||||
|
||||
cases().removeChildObject(reservoir);
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RigMainGrid* RimAnalysisModels::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 RimAnalysisModels::insertCaseInCaseGroup(RimIdenticalGridCaseGroup* caseGroup, RimCase* rimReservoir)
|
||||
{
|
||||
CVF_ASSERT(rimReservoir);
|
||||
|
||||
RigCaseData* rigEclipseCase = rimReservoir->reservoirData();
|
||||
registerCaseInGridCollection(rigEclipseCase);
|
||||
|
||||
caseGroup->addCase(rimReservoir);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 "cafPdmDocument.h"
|
||||
|
||||
class RimCase;
|
||||
class RigGridManager;
|
||||
class RimIdenticalGridCaseGroup;
|
||||
class RigMainGrid;
|
||||
class RigCaseData;
|
||||
class RimWellPathCollection;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
///
|
||||
//==================================================================================================
|
||||
class RimAnalysisModels : public caf::PdmObject
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
public:
|
||||
RimAnalysisModels(void);
|
||||
virtual ~RimAnalysisModels(void);
|
||||
|
||||
caf::PdmPointersField<RimCase*> cases;
|
||||
caf::PdmPointersField<RimIdenticalGridCaseGroup*> caseGroups;
|
||||
|
||||
void close();
|
||||
|
||||
RimIdenticalGridCaseGroup* createIdenticalCaseGroupFromMainCase(RimCase* mainCase);
|
||||
void insertCaseInCaseGroup(RimIdenticalGridCaseGroup* caseGroup, RimCase* rimReservoir);
|
||||
void moveEclipseCaseIntoCaseGroup(RimCase* rimReservoir);
|
||||
void removeCaseFromAllGroups(RimCase* rimReservoir);
|
||||
|
||||
private:
|
||||
RigMainGrid* registerCaseInGridCollection(RigCaseData* rigEclipseCase);
|
||||
cvf::ref<RigGridManager> m_gridCollection;
|
||||
};
|
||||
@@ -16,13 +16,29 @@
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RiaStdInclude.h"
|
||||
//#include "RiaStdInclude.h"
|
||||
#include "RimCase.h"
|
||||
|
||||
#include <QFile>
|
||||
#include <QFileInfo>
|
||||
#include <QDir>
|
||||
|
||||
#include "RifReaderEclipseOutput.h"
|
||||
#include "RifReaderMockModel.h"
|
||||
|
||||
#include "RimCase.h"
|
||||
#include "RimReservoirView.h"
|
||||
#include "cafPdmFieldCvfMat4d.h"
|
||||
#include "cafPdmFieldCvfColor.h"
|
||||
#include "RimCellRangeFilter.h"
|
||||
#include "RimCellRangeFilterCollection.h"
|
||||
#include "RimCellPropertyFilter.h"
|
||||
#include "RimCellPropertyFilterCollection.h"
|
||||
#include "Rim3dOverlayInfoConfig.h"
|
||||
#include "RimIdenticalGridCaseGroup.h"
|
||||
#include "RimWellCollection.h"
|
||||
#include "RimWellPathCollection.h"
|
||||
|
||||
#include "RimScriptCollection.h"
|
||||
|
||||
#include "RigCaseData.h"
|
||||
#include "RigMainGrid.h"
|
||||
@@ -30,11 +46,19 @@
|
||||
|
||||
#include "cvfAssert.h"
|
||||
|
||||
#include "cafPdmFieldCvfColor.h"
|
||||
|
||||
#include "cafPdmUiPushButtonEditor.h"
|
||||
|
||||
#include <QString>
|
||||
#include "RimProject.h"
|
||||
#include "RimReservoirCellResultsCacher.h"
|
||||
#include "RimResultSlot.h"
|
||||
#include "RimCellPropertyFilterCollection.h"
|
||||
#include "RimCellEdgeResultSlot.h"
|
||||
#include "RimCaseCollection.h"
|
||||
#include "RimOilField.h"
|
||||
#include "RimAnalysisModels.h"
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimCase, "RimReservoir");
|
||||
|
||||
@@ -44,6 +68,10 @@ CAF_PDM_SOURCE_INIT(RimCase, "RimReservoir");
|
||||
RimCase::RimCase()
|
||||
{
|
||||
CAF_PDM_InitField(&caseUserDescription, "CaseUserDescription", QString(), "Case name", "", "" ,"");
|
||||
|
||||
CAF_PDM_InitField(&caseId, "CaseId", -1, "Case ID", "", "" ,"");
|
||||
caseId.setUiReadOnly(true);
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&reservoirViews, "ReservoirViews", "", "", "", "");
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&m_matrixModelResults, "MatrixModelResults", "", "", "", "");
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
#include "cvfObject.h"
|
||||
#include "cafPdmField.h"
|
||||
#include "cafPdmObject.h"
|
||||
#include "RimReservoirCellResultsCacher.h"
|
||||
#include "RifReaderInterface.h"
|
||||
|
||||
class QString;
|
||||
@@ -32,7 +31,7 @@ class RigGridBase;
|
||||
class RimReservoirView;
|
||||
class RimCaseCollection;
|
||||
class RimIdenticalGridCaseGroup;
|
||||
//class RimReservoirCellResultsCacher;
|
||||
class RimReservoirCellResultsStorage;
|
||||
|
||||
//==================================================================================================
|
||||
//
|
||||
@@ -49,6 +48,7 @@ public:
|
||||
|
||||
// Fields:
|
||||
caf::PdmField<QString> caseUserDescription;
|
||||
caf::PdmField<int> caseId;
|
||||
caf::PdmField<bool> releaseResultMemory;
|
||||
caf::PdmPointersField<RimReservoirView*> reservoirViews;
|
||||
caf::PdmField<bool> flipXAxis;
|
||||
|
||||
@@ -16,14 +16,24 @@
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RiaStdInclude.h"
|
||||
|
||||
|
||||
#include "RimCaseCollection.h"
|
||||
#include "RimCase.h"
|
||||
|
||||
#include "RimReservoirView.h"
|
||||
#include "RimIdenticalGridCaseGroup.h"
|
||||
|
||||
#include "cafPdmFieldCvfColor.h"
|
||||
#include "cafPdmFieldCvfMat4d.h"
|
||||
|
||||
#include "RimReservoirCellResultsCacher.h"
|
||||
#include "RimResultSlot.h"
|
||||
|
||||
#include "RimCellEdgeResultSlot.h"
|
||||
#include "RimCellRangeFilterCollection.h"
|
||||
#include "RimCellPropertyFilterCollection.h"
|
||||
#include "Rim3dOverlayInfoConfig.h"
|
||||
#include "RimWellCollection.h"
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimCaseCollection, "RimCaseCollection");
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -18,13 +18,11 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cvfBase.h"
|
||||
#include "cvfObject.h"
|
||||
#include "cafPdmField.h"
|
||||
#include "cafPdmObject.h"
|
||||
|
||||
#include "RimStatisticsCase.h"
|
||||
|
||||
class RimCase;
|
||||
class RimIdenticalGridCaseGroup;
|
||||
|
||||
//==================================================================================================
|
||||
//
|
||||
|
||||
@@ -16,18 +16,21 @@
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RiaStdInclude.h"
|
||||
|
||||
#include "RimCellEdgeResultSlot.h"
|
||||
#include "RimReservoirCellResultsCacher.h"
|
||||
|
||||
#include "RimLegendConfig.h"
|
||||
#include "RimReservoirView.h"
|
||||
#include "RimCase.h"
|
||||
#include "RimReservoirView.h"
|
||||
#include "RigCaseCellResultsData.h"
|
||||
#include "RigCaseData.h"
|
||||
|
||||
#include "cafPdmUiListEditor.h"
|
||||
|
||||
#include "cafPdmFieldCvfColor.h"
|
||||
#include "cafPdmFieldCvfMat4d.h"
|
||||
#include "RimResultSlot.h"
|
||||
#include "RimCellRangeFilterCollection.h"
|
||||
#include "RimCellPropertyFilterCollection.h"
|
||||
#include "Rim3dOverlayInfoConfig.h"
|
||||
#include "RimWellCollection.h"
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimCellEdgeResultSlot, "CellEdgeResultSlot");
|
||||
|
||||
@@ -331,3 +334,29 @@ void RimCellEdgeResultSlot::minMaxCellEdgeValues(double& min, double& max)
|
||||
max = globalMax;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimCellEdgeResultSlot::posNegClosestToZero(double& pos, double& neg)
|
||||
{
|
||||
pos = HUGE_VAL;
|
||||
neg = -HUGE_VAL;
|
||||
|
||||
size_t resultIndices[6];
|
||||
this->gridScalarIndices(resultIndices);
|
||||
|
||||
size_t idx;
|
||||
for (idx = 0; idx < 6; idx++)
|
||||
{
|
||||
if (resultIndices[idx] == cvf::UNDEFINED_SIZE_T) continue;
|
||||
|
||||
{
|
||||
double localPos, localNeg;
|
||||
m_reservoirView->currentGridCellResults()->cellResults()->posNegClosestToZero(resultIndices[idx], localPos, localNeg);
|
||||
|
||||
if (localPos > 0 && localPos < pos) pos = localPos;
|
||||
if (localNeg < 0 && localNeg > neg) neg = localNeg;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,11 +19,13 @@
|
||||
#pragma once
|
||||
|
||||
#include "cafPdmObject.h"
|
||||
#include "RimLegendConfig.h"
|
||||
#include "cafPdmField.h"
|
||||
#include "cafAppEnum.h"
|
||||
#include "RimDefines.h"
|
||||
|
||||
class RigCaseCellResultsData;
|
||||
class RimLegendConfig;
|
||||
class RimReservoirView;
|
||||
|
||||
namespace caf
|
||||
{
|
||||
@@ -73,6 +75,7 @@ public:
|
||||
bool hasResult() const;
|
||||
|
||||
void minMaxCellEdgeValues(double& min, double& max);
|
||||
void posNegClosestToZero(double& pos, double& neg);
|
||||
protected:
|
||||
|
||||
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue);
|
||||
|
||||
@@ -16,16 +16,14 @@
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RiaStdInclude.h"
|
||||
|
||||
#include "RimReservoirView.h"
|
||||
#include "RimCellPropertyFilter.h"
|
||||
#include "RimResultDefinition.h"
|
||||
#include "cvfMath.h"
|
||||
|
||||
#include "RimCellPropertyFilterCollection.h"
|
||||
#include "RigGridBase.h"
|
||||
#include "RigCaseCellResultsData.h"
|
||||
|
||||
#include "cafPdmUiDoubleSliderEditor.h"
|
||||
|
||||
#include "RimReservoirCellResultsCacher.h"
|
||||
|
||||
|
||||
namespace caf
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
#include "RimDefines.h"
|
||||
#include "RimCellFilter.h"
|
||||
#include "cvfStructGridGeometryGenerator.h"
|
||||
//#include "cvfStructGridGeometryGenerator.h"
|
||||
|
||||
class RimReservoirView;
|
||||
class RimCellPropertyFilterCollection;
|
||||
|
||||
@@ -16,13 +16,18 @@
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RiaStdInclude.h"
|
||||
|
||||
#include "RimCellPropertyFilterCollection.h"
|
||||
|
||||
#include "RimReservoirView.h"
|
||||
#include "RigGridBase.h"
|
||||
#include "RigCaseCellResultsData.h"
|
||||
#include "RimResultDefinition.h"
|
||||
#include "RimResultSlot.h"
|
||||
|
||||
#include "cafPdmFieldCvfColor.h"
|
||||
#include "cafPdmFieldCvfMat4d.h"
|
||||
#include "RimCellRangeFilterCollection.h"
|
||||
#include "Rim3dOverlayInfoConfig.h"
|
||||
#include "RimWellCollection.h"
|
||||
#include "RimCellEdgeResultSlot.h"
|
||||
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimCellPropertyFilterCollection, "CellPropertyFilters");
|
||||
|
||||
@@ -16,12 +16,23 @@
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RiaStdInclude.h"
|
||||
//#include "RiaStdInclude.h"
|
||||
|
||||
#include "RimCellRangeFilter.h"
|
||||
#include "RimCellRangeFilterCollection.h"
|
||||
#include "RimReservoirView.h"
|
||||
#include "RigCaseData.h"
|
||||
#include "RimCase.h"
|
||||
|
||||
#include "cafPdmFieldCvfMat4d.h"
|
||||
#include "cafPdmFieldCvfColor.h"
|
||||
#include "RimResultSlot.h"
|
||||
#include "RimCellEdgeResultSlot.h"
|
||||
#include "RimCellRangeFilterCollection.h"
|
||||
#include "RimCellPropertyFilterCollection.h"
|
||||
#include "RimWellCollection.h"
|
||||
#include "Rim3dOverlayInfoConfig.h"
|
||||
#include "RimReservoirCellResultsCacher.h"
|
||||
|
||||
#include "cafPdmUiSliderEditor.h"
|
||||
|
||||
@@ -269,7 +280,7 @@ RigGridBase* RimCellRangeFilter::selectedGrid()
|
||||
CVF_ASSERT(mainGrid);
|
||||
|
||||
RigGridBase* grid = NULL;
|
||||
if (gridIndex() >= mainGrid->gridCount())
|
||||
if (static_cast<size_t>(gridIndex()) >= mainGrid->gridCount())
|
||||
{
|
||||
gridIndex = 0;
|
||||
}
|
||||
|
||||
@@ -16,13 +16,20 @@
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RiaStdInclude.h"
|
||||
//#include "RiaStdInclude.h"
|
||||
|
||||
#include "RimCellRangeFilterCollection.h"
|
||||
|
||||
#include "RimCase.h"
|
||||
#include "RimReservoirView.h"
|
||||
#include "RigCaseData.h"
|
||||
|
||||
#include "cafPdmFieldCvfMat4d.h"
|
||||
#include "cafPdmFieldCvfColor.h"
|
||||
#include "RimResultSlot.h"
|
||||
#include "RimCellEdgeResultSlot.h"
|
||||
#include "Rim3dOverlayInfoConfig.h"
|
||||
#include "RimCellPropertyFilterCollection.h"
|
||||
#include "RimReservoirCellResultsCacher.h"
|
||||
#include "RimWellCollection.h"
|
||||
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimCellRangeFilterCollection, "CellRangeFilterCollection");
|
||||
@@ -73,7 +80,7 @@ void RimCellRangeFilterCollection::compoundCellRangeFilter(cvf::CellRangeFilter*
|
||||
{
|
||||
RimCellRangeFilter* rangeFilter = *it;
|
||||
|
||||
if (rangeFilter && rangeFilter->active && rangeFilter->gridIndex() == grid->gridIndex())
|
||||
if (rangeFilter && rangeFilter->active() && static_cast<size_t>(rangeFilter->gridIndex()) == grid->gridIndex())
|
||||
{
|
||||
if (rangeFilter->filterMode == RimCellFilter::INCLUDE)
|
||||
{
|
||||
|
||||
@@ -17,20 +17,33 @@
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RiaStdInclude.h"
|
||||
|
||||
#include "RimIdenticalGridCaseGroup.h"
|
||||
#include "RimCaseCollection.h"
|
||||
|
||||
#include "RimCase.h"
|
||||
#include "RimReservoirView.h"
|
||||
#include "RigCaseData.h"
|
||||
#include "RigCaseCellResultsData.h"
|
||||
|
||||
#include "RimResultSlot.h"
|
||||
#include "RimCellEdgeResultSlot.h"
|
||||
#include "RimStatisticsCase.h"
|
||||
#include "RimStatisticsCaseCollection.h"
|
||||
|
||||
#include "RimResultCase.h"
|
||||
#include "cafProgressInfo.h"
|
||||
#include "RigActiveCellInfo.h"
|
||||
#include "RigActiveCellInfo.h"
|
||||
|
||||
#include "RigGridManager.h"
|
||||
#include "RimReservoirCellResultsCacher.h"
|
||||
|
||||
|
||||
#include "cafPdmFieldCvfColor.h"
|
||||
#include "cafPdmFieldCvfMat4d.h"
|
||||
#include "RimCellRangeFilterCollection.h"
|
||||
#include "RimCellPropertyFilterCollection.h"
|
||||
#include "Rim3dOverlayInfoConfig.h"
|
||||
#include "RimWellCollection.h"
|
||||
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimIdenticalGridCaseGroup, "RimIdenticalGridCaseGroup");
|
||||
@@ -44,6 +57,9 @@ RimIdenticalGridCaseGroup::RimIdenticalGridCaseGroup()
|
||||
|
||||
CAF_PDM_InitField(&name, "UserDescription", QString("Grid Case Group"), "Name", "", "", "");
|
||||
|
||||
CAF_PDM_InitField(&groupId, "GroupId", -1, "Case Group ID", "", "" ,"");
|
||||
groupId.setUiReadOnly(true);
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&statisticsCaseCollection, "StatisticsCaseCollection", "Derived Statistics", ":/Histograms16x16.png", "", "");
|
||||
CAF_PDM_InitFieldNoDefault(&caseCollection, "CaseCollection", "Cases", ":/Cases16x16.png", "", "");
|
||||
|
||||
|
||||
@@ -23,8 +23,11 @@
|
||||
#include "cafPdmField.h"
|
||||
#include "cafPdmObject.h"
|
||||
|
||||
#include "RimStatisticsCaseCollection.h"
|
||||
#include "RimCaseCollection.h"
|
||||
#include "RifReaderInterface.h"
|
||||
|
||||
//#include "RimStatisticsCaseCollection.h"
|
||||
class RimCaseCollection;
|
||||
class RimStatisticsCase;
|
||||
|
||||
class RimCase;
|
||||
class RigMainGrid;
|
||||
@@ -44,6 +47,7 @@ public:
|
||||
virtual ~RimIdenticalGridCaseGroup();
|
||||
|
||||
caf::PdmField<QString> name;
|
||||
caf::PdmField<int> groupId;
|
||||
caf::PdmField<RimCaseCollection*> caseCollection;
|
||||
caf::PdmField<RimCaseCollection*> statisticsCaseCollection;
|
||||
|
||||
|
||||
@@ -16,20 +16,18 @@
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RiaStdInclude.h"
|
||||
//#include "RiaStdInclude.h"
|
||||
|
||||
#include "RimInputCase.h"
|
||||
#include "RimInputProperty.h"
|
||||
#include "RimInputPropertyCollection.h"
|
||||
#include "RimReservoirCellResultsCacher.h"
|
||||
#include <QFileInfo>
|
||||
|
||||
#include "RimReservoirView.h"
|
||||
|
||||
#include "RifReaderEclipseInput.h"
|
||||
|
||||
#include "RigCaseData.h"
|
||||
#include "RigCaseCellResultsData.h"
|
||||
|
||||
#include "cvfAssert.h"
|
||||
|
||||
#include <QString>
|
||||
#include "RifReaderMockModel.h"
|
||||
#include "RifEclipseInputFileTools.h"
|
||||
#include "cafProgressInfo.h"
|
||||
@@ -37,6 +35,15 @@
|
||||
#include "RiaApplication.h"
|
||||
#include "RiaPreferences.h"
|
||||
|
||||
#include "cafPdmFieldCvfColor.h"
|
||||
#include "cafPdmFieldCvfMat4d.h"
|
||||
|
||||
#include "RimCellEdgeResultSlot.h"
|
||||
#include "RimResultSlot.h"
|
||||
#include "RimCellRangeFilterCollection.h"
|
||||
#include "RimCellPropertyFilterCollection.h"
|
||||
#include "Rim3dOverlayInfoConfig.h"
|
||||
#include "RimWellCollection.h"
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimInputCase, "RimInputReservoir");
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -24,12 +24,10 @@
|
||||
#include "cafPdmObject.h"
|
||||
|
||||
#include "RimCase.h"
|
||||
#include "RimInputPropertyCollection.h"
|
||||
|
||||
|
||||
class QString;
|
||||
|
||||
class RifReaderInterface;
|
||||
class RimInputPropertyCollection;
|
||||
class RimInputProperty;
|
||||
|
||||
//==================================================================================================
|
||||
//
|
||||
|
||||
@@ -16,15 +16,29 @@
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RiaStdInclude.h"
|
||||
|
||||
#include "RimLegendConfig.h"
|
||||
|
||||
#include "RimReservoirView.h"
|
||||
#include "cafFactory.h"
|
||||
#include "cafPdmUiLineEditor.h"
|
||||
#include "cafPdmUiComboBoxEditor.h"
|
||||
|
||||
#include "cvfScalarMapperDiscreteLog.h"
|
||||
#include "cvfScalarMapperContinuousLog.h"
|
||||
#include "cvfScalarMapperContinuousLinear.h"
|
||||
#include "cvfOverlayScalarMapperLegend.h"
|
||||
#include "cvfScalarMapperDiscreteLinear.h"
|
||||
#include <cmath>
|
||||
|
||||
#include "RiaApplication.h"
|
||||
#include "cafPdmFieldCvfMat4d.h"
|
||||
#include "cafPdmFieldCvfColor.h"
|
||||
#include "RimResultSlot.h"
|
||||
#include "RimCellEdgeResultSlot.h"
|
||||
#include "RimCellRangeFilterCollection.h"
|
||||
#include "RimCellPropertyFilterCollection.h"
|
||||
#include "RimWellCollection.h"
|
||||
#include "Rim3dOverlayInfoConfig.h"
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimLegendConfig, "Legend");
|
||||
|
||||
@@ -83,7 +97,11 @@ RimLegendConfig::RimLegendConfig()
|
||||
: m_globalAutoMax(cvf::UNDEFINED_DOUBLE),
|
||||
m_globalAutoMin(cvf::UNDEFINED_DOUBLE),
|
||||
m_localAutoMax(cvf::UNDEFINED_DOUBLE),
|
||||
m_localAutoMin(cvf::UNDEFINED_DOUBLE)
|
||||
m_localAutoMin(cvf::UNDEFINED_DOUBLE),
|
||||
m_globalAutoPosClosestToZero(0),
|
||||
m_globalAutoNegClosestToZero(0),
|
||||
m_localAutoPosClosestToZero(0),
|
||||
m_localAutoNegClosestToZero(0)
|
||||
{
|
||||
CAF_PDM_InitObject("Legend Definition", ":/Legend.png", "", "");
|
||||
CAF_PDM_InitField(&m_numLevels, "NumberOfLevels", 8, "Number of levels", "", "","");
|
||||
@@ -160,28 +178,78 @@ void RimLegendConfig::updateLegend()
|
||||
{
|
||||
double adjustedMin = cvf::UNDEFINED_DOUBLE;
|
||||
double adjustedMax = cvf::UNDEFINED_DOUBLE;
|
||||
|
||||
double posClosestToZero = cvf::UNDEFINED_DOUBLE;
|
||||
double negClosestToZero = cvf::UNDEFINED_DOUBLE;
|
||||
|
||||
if (m_rangeMode == AUTOMATIC_ALLTIMESTEPS)
|
||||
{
|
||||
adjustedMin = adjust(m_globalAutoMin, m_precision);
|
||||
adjustedMax = adjust(m_globalAutoMax, m_precision);
|
||||
|
||||
posClosestToZero = m_globalAutoPosClosestToZero;
|
||||
negClosestToZero = m_globalAutoNegClosestToZero;
|
||||
}
|
||||
else if (m_rangeMode == AUTOMATIC_CURRENT_TIMESTEP)
|
||||
{
|
||||
adjustedMin = adjust(m_localAutoMin, m_precision);
|
||||
adjustedMax = adjust(m_localAutoMax, m_precision);
|
||||
|
||||
posClosestToZero = m_localAutoPosClosestToZero;
|
||||
negClosestToZero = m_localAutoNegClosestToZero;
|
||||
}
|
||||
else
|
||||
{
|
||||
adjustedMin = adjust(m_userDefinedMinValue, m_precision);
|
||||
adjustedMax = adjust(m_userDefinedMaxValue, m_precision);
|
||||
|
||||
posClosestToZero = m_globalAutoPosClosestToZero;
|
||||
negClosestToZero = m_globalAutoNegClosestToZero;
|
||||
}
|
||||
|
||||
|
||||
m_linDiscreteScalarMapper->setRange(adjustedMin, adjustedMax);
|
||||
m_linSmoothScalarMapper->setRange(adjustedMin, adjustedMax);
|
||||
|
||||
if (m_mappingMode == LOG10_CONTINUOUS || m_mappingMode == LOG10_DISCRETE)
|
||||
{
|
||||
if (adjustedMin != adjustedMax)
|
||||
{
|
||||
if (adjustedMin == 0)
|
||||
{
|
||||
if (adjustedMax > adjustedMin)
|
||||
{
|
||||
adjustedMin = posClosestToZero;
|
||||
}
|
||||
else
|
||||
{
|
||||
adjustedMin = negClosestToZero;
|
||||
}
|
||||
}
|
||||
else if (adjustedMax == 0)
|
||||
{
|
||||
if (adjustedMin > adjustedMax)
|
||||
{
|
||||
adjustedMax = posClosestToZero;
|
||||
}
|
||||
else
|
||||
{
|
||||
adjustedMax = negClosestToZero;
|
||||
}
|
||||
}
|
||||
else if (adjustedMin < 0 && adjustedMax > 0)
|
||||
{
|
||||
adjustedMin = posClosestToZero;
|
||||
}
|
||||
else if (adjustedMax < 0 && adjustedMin > 0)
|
||||
{
|
||||
adjustedMin = negClosestToZero;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_logDiscreteScalarMapper->setRange(adjustedMin, adjustedMax);
|
||||
m_logSmoothScalarMapper->setRange(adjustedMin, adjustedMax);
|
||||
m_linSmoothScalarMapper->setRange(adjustedMin, adjustedMax);
|
||||
|
||||
cvf::Color3ubArray legendColors;
|
||||
switch (m_colorRangeMode())
|
||||
@@ -441,3 +509,21 @@ double RimLegendConfig::adjust(double domainValue, double precision)
|
||||
return newDomainValue;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimLegendConfig::setClosestToZeroValues(double globalPosClosestToZero, double globalNegClosestToZero, double localPosClosestToZero, double localNegClosestToZero)
|
||||
{
|
||||
m_globalAutoPosClosestToZero = globalPosClosestToZero;
|
||||
m_globalAutoNegClosestToZero = globalNegClosestToZero;
|
||||
m_localAutoPosClosestToZero = localPosClosestToZero;
|
||||
m_localAutoNegClosestToZero = localNegClosestToZero;
|
||||
|
||||
if (m_globalAutoPosClosestToZero == HUGE_VAL) m_globalAutoPosClosestToZero = 0;
|
||||
if (m_globalAutoNegClosestToZero == -HUGE_VAL) m_globalAutoNegClosestToZero = 0;
|
||||
if (m_localAutoPosClosestToZero == HUGE_VAL) m_localAutoPosClosestToZero = 0;
|
||||
if (m_localAutoNegClosestToZero == -HUGE_VAL) m_localAutoNegClosestToZero = 0;
|
||||
|
||||
updateLegend();
|
||||
}
|
||||
|
||||
@@ -17,17 +17,28 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
#include "cvfBase.h"
|
||||
#include "cvfObject.h"
|
||||
#include "cvfVector2.h"
|
||||
#include "cvfArray.h"
|
||||
|
||||
#include "cafPdmObject.h"
|
||||
#include "cafPdmPointer.h"
|
||||
#include "cafPdmField.h"
|
||||
#include "cafPdmPointer.h"
|
||||
#include "cafAppEnum.h"
|
||||
#include "cvfScalarMapperContinuousLog.h"
|
||||
#include "cvfScalarMapperContinuousLinear.h"
|
||||
#include "cvfOverlayScalarMapperLegend.h"
|
||||
#include "cvfScalarMapperDiscreteLinear.h"
|
||||
|
||||
namespace cvf
|
||||
{
|
||||
class ScalarMapperContinuousLog;
|
||||
class ScalarMapperContinuousLinear;
|
||||
class OverlayScalarMapperLegend;
|
||||
class ScalarMapperDiscreteLinear;
|
||||
class ScalarMapperDiscreteLog;
|
||||
class ScalarMapper;
|
||||
}
|
||||
|
||||
class RimReservoirView;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
///
|
||||
@@ -75,6 +86,7 @@ public:
|
||||
void recreateLegend();
|
||||
void setColorRangeMode(ColorRangesType colorMode);
|
||||
void setAutomaticRanges(double globalMin, double globalMax, double localMin, double localMax);
|
||||
void setClosestToZeroValues(double globalPosClosestToZero, double globalNegClosestToZero, double localPosClosestToZero, double localNegClosestToZero);
|
||||
void setPosition(cvf::Vec2ui position);
|
||||
|
||||
cvf::ScalarMapper* scalarMapper() { return m_currentScalarMapper.p(); }
|
||||
@@ -105,6 +117,11 @@ private:
|
||||
double m_localAutoMax;
|
||||
double m_localAutoMin;
|
||||
|
||||
double m_globalAutoPosClosestToZero;
|
||||
double m_globalAutoNegClosestToZero;
|
||||
double m_localAutoPosClosestToZero;
|
||||
double m_localAutoNegClosestToZero;
|
||||
|
||||
cvf::Vec2ui m_position;
|
||||
|
||||
// Fields
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 "RimOilField.h"
|
||||
#include "cafAppEnum.h"
|
||||
#include "RimReservoirView.h"
|
||||
|
||||
#include "RimIdenticalGridCaseGroup.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
#include "RiaVersionInfo.h"
|
||||
|
||||
#include "RigGridManager.h"
|
||||
#include "RigCaseData.h"
|
||||
#include "RimResultCase.h"
|
||||
#include "RimWellPathCollection.h"
|
||||
#include "RimAnalysisModels.h"
|
||||
|
||||
#include "cafPdmFieldCvfColor.h"
|
||||
#include "cafPdmFieldCvfMat4d.h"
|
||||
#include "RimReservoirCellResultsCacher.h"
|
||||
#include "RimCellEdgeResultSlot.h"
|
||||
#include "RimCellRangeFilterCollection.h"
|
||||
#include "RimCellPropertyFilterCollection.h"
|
||||
#include "Rim3dOverlayInfoConfig.h"
|
||||
#include "RimWellCollection.h"
|
||||
#include "RimCaseCollection.h"
|
||||
#include "RimResultSlot.h"
|
||||
#include "RimStatisticsCase.h"
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimOilField, "ResInsightOilField");
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimOilField::RimOilField(void)
|
||||
{
|
||||
CAF_PDM_InitObject("Oil Field", "", "", "");
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&analysisModels, "AnalysisModels", "Grid Models", ":/GridModels.png", "", "");
|
||||
CAF_PDM_InitFieldNoDefault(&wellPathCollection, "WellPathCollection", "Well Paths", ":/WellCollection.png", "", "");
|
||||
|
||||
analysisModels = new RimAnalysisModels();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimOilField::~RimOilField(void)
|
||||
{
|
||||
if (wellPathCollection()) delete wellPathCollection();
|
||||
if (analysisModels()) delete analysisModels();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 "cafPdmDocument.h"
|
||||
|
||||
class RimCase;
|
||||
class RigGridManager;
|
||||
class RimIdenticalGridCaseGroup;
|
||||
class RigMainGrid;
|
||||
class RigCaseData;
|
||||
class RimWellPathCollection;
|
||||
class RimAnalysisModels;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
///
|
||||
//==================================================================================================
|
||||
class RimOilField : public caf::PdmObject
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
public:
|
||||
RimOilField(void);
|
||||
virtual ~RimOilField(void);
|
||||
|
||||
caf::PdmField<RimAnalysisModels*> analysisModels;
|
||||
caf::PdmField<RimWellPathCollection*> wellPathCollection;
|
||||
|
||||
};
|
||||
@@ -19,14 +19,36 @@
|
||||
#include "RiaStdInclude.h"
|
||||
|
||||
#include "RimProject.h"
|
||||
#include "cafAppEnum.h"
|
||||
|
||||
#include "RimOilField.h"
|
||||
#include "RimAnalysisModels.h"
|
||||
|
||||
#include "RimReservoirView.h"
|
||||
#include "RimScriptCollection.h"
|
||||
#include "RimIdenticalGridCaseGroup.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
#include "RiaVersionInfo.h"
|
||||
|
||||
#include "RigGridManager.h"
|
||||
#include "RigCaseData.h"
|
||||
#include "RimResultCase.h"
|
||||
#include "RimWellPathCollection.h"
|
||||
|
||||
|
||||
#include "cafPdmFieldCvfColor.h"
|
||||
#include "cafPdmFieldCvfMat4d.h"
|
||||
#include "RimReservoirCellResultsCacher.h"
|
||||
#include "RimCellEdgeResultSlot.h"
|
||||
#include "RimCellRangeFilterCollection.h"
|
||||
#include "RimCellPropertyFilterCollection.h"
|
||||
#include "Rim3dOverlayInfoConfig.h"
|
||||
#include "RimWellCollection.h"
|
||||
#include "RimCaseCollection.h"
|
||||
#include "RimResultSlot.h"
|
||||
#include "RimStatisticsCase.h"
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimProject, "ResInsightProject");
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
@@ -36,23 +58,39 @@ RimProject::RimProject(void)
|
||||
CAF_PDM_InitFieldNoDefault(&m_projectFileVersionString, "ProjectFileVersionString", "", "", "", "");
|
||||
m_projectFileVersionString.setUiHidden(true);
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&reservoirs, "Reservoirs", "", "", "", "");
|
||||
CAF_PDM_InitFieldNoDefault(&caseGroups, "CaseGroups", "", "", "", "");
|
||||
CAF_PDM_InitField(&nextValidCaseId, "NextValidCaseId", 0, "Next Valid Case ID", "", "" ,"");
|
||||
nextValidCaseId.setUiHidden(true);
|
||||
|
||||
CAF_PDM_InitField(&nextValidCaseGroupId, "NextValidCaseGroupId", 0, "Next Valid Case Group ID", "", "" ,"");
|
||||
nextValidCaseGroupId.setUiHidden(true);
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&oilFields, "OilFields", "Oil Fields", "", "", "");
|
||||
oilFields.setUiHidden(true);
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&scriptCollection, "ScriptCollection", "Scripts", ":/Default.png", "", "");
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&treeViewState, "TreeViewState", "", "", "", "");
|
||||
treeViewState.setUiHidden(true);
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(¤tModelIndexPath, "TreeViewCurrentModelIndexPath", "", "", "", "");
|
||||
currentModelIndexPath.setUiHidden(true);
|
||||
|
||||
// Obsolete fields. The content is moved to OilFields and friends
|
||||
CAF_PDM_InitFieldNoDefault(&casesObsolete, "Reservoirs", "", "", "", "");
|
||||
casesObsolete.setUiHidden(true);
|
||||
casesObsolete.setIOWritable(false); // read but not write, they will be moved into RimAnalysisGroups
|
||||
CAF_PDM_InitFieldNoDefault(&caseGroupsObsolete, "CaseGroups", "", "", "", "");
|
||||
caseGroupsObsolete.setUiHidden(true);
|
||||
caseGroupsObsolete.setIOWritable(false); // read but not write, they will be moved into RimAnalysisGroups
|
||||
|
||||
// Initialization
|
||||
|
||||
scriptCollection = new RimScriptCollection();
|
||||
scriptCollection->directory.setUiHidden(true);
|
||||
|
||||
m_gridCollection = new RigGridManager;
|
||||
// For now, create a default first oilfield that contains the rest of the project
|
||||
oilFields.push_back(new RimOilField);
|
||||
|
||||
initAfterRead();
|
||||
initScriptDirectories();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -62,9 +100,8 @@ RimProject::~RimProject(void)
|
||||
{
|
||||
close();
|
||||
|
||||
oilFields.deleteAllChildObjects();
|
||||
if (scriptCollection()) delete scriptCollection();
|
||||
|
||||
reservoirs.deleteAllChildObjects();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -72,18 +109,23 @@ RimProject::~RimProject(void)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimProject::close()
|
||||
{
|
||||
m_gridCollection->clear();
|
||||
oilFields.deleteAllChildObjects();
|
||||
oilFields.push_back(new RimOilField);
|
||||
|
||||
reservoirs.deleteAllChildObjects();
|
||||
caseGroups.deleteAllChildObjects();
|
||||
casesObsolete.deleteAllChildObjects();
|
||||
caseGroupsObsolete.deleteAllChildObjects();
|
||||
|
||||
fileName = "";
|
||||
|
||||
nextValidCaseId = 0;
|
||||
nextValidCaseGroupId = 0;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimProject::initAfterRead()
|
||||
void RimProject::initScriptDirectories()
|
||||
{
|
||||
//
|
||||
// TODO : Must store content of scripts in project file and notify user if stored content is different from disk on execute and edit
|
||||
@@ -92,6 +134,135 @@ void RimProject::initAfterRead()
|
||||
QString scriptDirectories = app->scriptDirectories();
|
||||
|
||||
this->setScriptDirectories(scriptDirectories);
|
||||
|
||||
// Find largest used caseId read from file and make sure all cases have a valid caseId
|
||||
{
|
||||
int largestId = -1;
|
||||
|
||||
std::vector<RimCase*> cases;
|
||||
allCases(cases);
|
||||
|
||||
for (size_t i = 0; i < cases.size(); i++)
|
||||
{
|
||||
if (cases[i]->caseId > largestId)
|
||||
{
|
||||
largestId = cases[i]->caseId;
|
||||
}
|
||||
}
|
||||
|
||||
if (largestId > this->nextValidCaseId)
|
||||
{
|
||||
this->nextValidCaseId = largestId + 1;
|
||||
}
|
||||
|
||||
// Assign case Id to cases with an invalid case Id
|
||||
for (size_t i = 0; i < cases.size(); i++)
|
||||
{
|
||||
if (cases[i]->caseId < 0)
|
||||
{
|
||||
assignCaseIdToCase(cases[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Find largest used groupId read from file and make sure all groups have a valid groupId
|
||||
RimAnalysisModels* analysisModels = activeOilField() ? activeOilField()->analysisModels() : NULL;
|
||||
if (analysisModels)
|
||||
{
|
||||
int largestGroupId = -1;
|
||||
|
||||
for (size_t i = 0; i < analysisModels->caseGroups().size(); i++)
|
||||
{
|
||||
RimIdenticalGridCaseGroup* cg = analysisModels->caseGroups()[i];
|
||||
|
||||
if (cg->groupId > largestGroupId)
|
||||
{
|
||||
largestGroupId = cg->groupId;
|
||||
}
|
||||
}
|
||||
|
||||
if (largestGroupId > this->nextValidCaseGroupId)
|
||||
{
|
||||
this->nextValidCaseGroupId = largestGroupId + 1;
|
||||
}
|
||||
|
||||
// Assign group Id to groups with an invalid Id
|
||||
for (size_t i = 0; i < analysisModels->caseGroups().size(); i++)
|
||||
{
|
||||
RimIdenticalGridCaseGroup* cg = analysisModels->caseGroups()[i];
|
||||
|
||||
if (cg->groupId < 0)
|
||||
{
|
||||
assignIdToCaseGroup(cg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimProject::initAfterRead()
|
||||
{
|
||||
initScriptDirectories();
|
||||
|
||||
// Create an empty oil field in case the project did not contain one
|
||||
if (oilFields.size() < 1)
|
||||
{
|
||||
oilFields.push_back(new RimOilField);
|
||||
}
|
||||
|
||||
// Handle old project files with obsolete structure.
|
||||
// Move caseGroupsObsolete and casesObsolete to oilFields()[idx]->analysisModels()
|
||||
RimAnalysisModels* analysisModels = activeOilField() ? activeOilField()->analysisModels() : NULL;
|
||||
bool movedOneRimIdenticalGridCaseGroup = false;
|
||||
for (size_t cgIdx = 0; cgIdx < caseGroupsObsolete.size(); ++cgIdx)
|
||||
{
|
||||
RimIdenticalGridCaseGroup* sourceCaseGroup = caseGroupsObsolete[cgIdx];
|
||||
if (analysisModels)
|
||||
{
|
||||
analysisModels->caseGroups.push_back(sourceCaseGroup);
|
||||
//printf("Moved m_project->caseGroupsObsolete[%i] to first oil fields analysis models\n", cgIdx);
|
||||
movedOneRimIdenticalGridCaseGroup = true; // moved at least one so assume the others will be moved too...
|
||||
}
|
||||
}
|
||||
|
||||
if (movedOneRimIdenticalGridCaseGroup)
|
||||
{
|
||||
caseGroupsObsolete.clear();
|
||||
}
|
||||
|
||||
bool movedOneRimCase = false;
|
||||
for (size_t cIdx = 0; cIdx < casesObsolete().size(); ++cIdx)
|
||||
{
|
||||
RimCase* sourceCase = casesObsolete[cIdx];
|
||||
if (analysisModels)
|
||||
{
|
||||
analysisModels->cases.push_back(sourceCase);
|
||||
//printf("Moved m_project->casesObsolete[%i] to first oil fields analysis models\n", cIdx);
|
||||
movedOneRimCase = true; // moved at least one so assume the others will be moved too...
|
||||
}
|
||||
}
|
||||
|
||||
if (movedOneRimCase)
|
||||
{
|
||||
casesObsolete.clear();
|
||||
}
|
||||
|
||||
if (casesObsolete().size() > 0 || caseGroupsObsolete.size() > 0)
|
||||
{
|
||||
printf("RimProject::initAfterRead: Was not able to move all cases (%i left) or caseGroups (%i left) from Project to analysisModels",
|
||||
casesObsolete().size(), caseGroupsObsolete.size());
|
||||
}
|
||||
|
||||
// Set project pointer to each well path
|
||||
for (size_t oilFieldIdx = 0; oilFieldIdx < oilFields().size(); oilFieldIdx++)
|
||||
{
|
||||
RimOilField* oilField = oilFields[oilFieldIdx];
|
||||
if (oilField == NULL || oilField->wellPathCollection == NULL) continue;
|
||||
oilField->wellPathCollection->setProject(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -137,129 +308,6 @@ QString RimProject::projectFileVersionString() const
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimIdenticalGridCaseGroup* RimProject::createIdenticalCaseGroupFromMainCase(RimCase* mainCase)
|
||||
{
|
||||
CVF_ASSERT(mainCase);
|
||||
|
||||
RigCaseData* rigEclipseCase = mainCase->reservoirData();
|
||||
RigMainGrid* equalGrid = registerCaseInGridCollection(rigEclipseCase);
|
||||
CVF_ASSERT(equalGrid);
|
||||
|
||||
RimIdenticalGridCaseGroup* group = new RimIdenticalGridCaseGroup;
|
||||
group->createAndAppendStatisticsCase();
|
||||
group->addCase(mainCase);
|
||||
caseGroups().push_back(group);
|
||||
|
||||
return group;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
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);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -270,30 +318,147 @@ void RimProject::setProjectFileNameAndUpdateDependencies(const QString& fileName
|
||||
// Replace with the new actual filename
|
||||
this->fileName = fileName;
|
||||
|
||||
// Loop over all reservoirs and update file path
|
||||
|
||||
QFileInfo fileInfo(fileName);
|
||||
QString newProjectPath = fileInfo.path();
|
||||
|
||||
QFileInfo fileInfoOld(oldProjectFileName);
|
||||
QString oldProjectPath = fileInfoOld.path();
|
||||
|
||||
// Loop over all cases and update file path
|
||||
|
||||
for (size_t i = 0; i < reservoirs.size(); i++)
|
||||
std::vector<RimCase*> cases;
|
||||
allCases(cases);
|
||||
for (size_t i = 0; i < cases.size(); i++)
|
||||
{
|
||||
reservoirs[i]->updateFilePathsFromProjectPath(newProjectPath, oldProjectPath);
|
||||
cases[i]->updateFilePathsFromProjectPath(newProjectPath, oldProjectPath);
|
||||
}
|
||||
}
|
||||
|
||||
// Case groups : Loop over all reservoirs in and update file path
|
||||
|
||||
for (size_t i = 0; i < caseGroups.size(); i++)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimProject::assignCaseIdToCase(RimCase* reservoirCase)
|
||||
{
|
||||
if (reservoirCase)
|
||||
{
|
||||
RimIdenticalGridCaseGroup* cg = caseGroups()[i];
|
||||
reservoirCase->caseId = nextValidCaseId;
|
||||
|
||||
for (size_t j = 0; j < cg->caseCollection()->reservoirs().size(); j++)
|
||||
nextValidCaseId = nextValidCaseId + 1;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimProject::assignIdToCaseGroup(RimIdenticalGridCaseGroup* caseGroup)
|
||||
{
|
||||
if (caseGroup)
|
||||
{
|
||||
caseGroup->groupId = nextValidCaseGroupId;
|
||||
|
||||
nextValidCaseGroupId = nextValidCaseGroupId + 1;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimProject::allCases(std::vector<RimCase*>& cases)
|
||||
{
|
||||
for (size_t oilFieldIdx = 0; oilFieldIdx < oilFields().size(); oilFieldIdx++)
|
||||
{
|
||||
RimOilField* oilField = oilFields[oilFieldIdx];
|
||||
RimAnalysisModels* analysisModels = oilField ? oilField->analysisModels() : NULL;
|
||||
if (analysisModels == NULL) continue;
|
||||
|
||||
for (size_t caseIdx = 0; caseIdx < analysisModels->cases.size(); caseIdx++)
|
||||
{
|
||||
cg->caseCollection()->reservoirs()[j]->updateFilePathsFromProjectPath(newProjectPath, oldProjectPath);
|
||||
cases.push_back(analysisModels->cases[caseIdx]);
|
||||
}
|
||||
for (size_t cgIdx = 0; cgIdx < analysisModels->caseGroups.size(); cgIdx++)
|
||||
{
|
||||
// Load the Main case of each IdenticalGridCaseGroup
|
||||
RimIdenticalGridCaseGroup* cg = analysisModels->caseGroups[cgIdx];
|
||||
if (cg == NULL) continue;
|
||||
|
||||
for (size_t caseIdx = 0; caseIdx < cg->statisticsCaseCollection()->reservoirs.size(); caseIdx++)
|
||||
{
|
||||
cases.push_back(cg->statisticsCaseCollection()->reservoirs[caseIdx]);
|
||||
}
|
||||
|
||||
for (size_t caseIdx = 0; caseIdx < cg->caseCollection()->reservoirs.size(); caseIdx++)
|
||||
{
|
||||
cases.push_back(cg->caseCollection()->reservoirs[caseIdx]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimProject::createDisplayModelAndRedrawAllViews()
|
||||
{
|
||||
std::vector<RimCase*> cases;
|
||||
allCases(cases);
|
||||
for (size_t caseIdx = 0; caseIdx < cases.size(); caseIdx++)
|
||||
{
|
||||
RimCase* rimCase = cases[caseIdx];
|
||||
if (rimCase == NULL) continue;
|
||||
|
||||
for (size_t viewIdx = 0; viewIdx < rimCase->reservoirViews.size(); viewIdx++)
|
||||
{
|
||||
RimReservoirView* reservoirView = rimCase->reservoirViews[viewIdx];
|
||||
reservoirView->createDisplayModelAndRedraw();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Currently there will be only one oil field in Resinsight, so return hardcoded first oil field
|
||||
/// from the RimOilField collection.
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimOilField* RimProject::activeOilField()
|
||||
{
|
||||
CVF_ASSERT(oilFields.size() == 1);
|
||||
|
||||
return oilFields[0];
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimProject::computeUtmAreaOfInterest(double* north, double* south, double* east, double* west)
|
||||
{
|
||||
CVF_ASSERT(north && south && east && west);
|
||||
std::vector<RimCase*> cases;
|
||||
allCases(cases);
|
||||
|
||||
cvf::BoundingBox projectBB;
|
||||
|
||||
for (size_t i = 0; i < cases.size(); i++)
|
||||
{
|
||||
RimCase* rimCase = cases[i];
|
||||
|
||||
if (rimCase && rimCase->reservoirData())
|
||||
{
|
||||
for (size_t gridIdx = 0; gridIdx < rimCase->reservoirData()->gridCount(); gridIdx++ )
|
||||
{
|
||||
RigGridBase* rigGrid = rimCase->reservoirData()->grid(gridIdx);
|
||||
|
||||
projectBB.add(rigGrid->boundingBox());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (projectBB.isValid())
|
||||
{
|
||||
*north = projectBB.max().y();
|
||||
*south = projectBB.min().y();
|
||||
|
||||
*west = projectBB.min().x();
|
||||
*east = projectBB.max().x();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,11 +19,15 @@
|
||||
#pragma once
|
||||
|
||||
#include "cafPdmDocument.h"
|
||||
#include "RimScriptCollection.h"
|
||||
#include "RimIdenticalGridCaseGroup.h"
|
||||
|
||||
class RimOilField;
|
||||
class RimCase;
|
||||
class RigGridManager;
|
||||
class RimScriptCollection;
|
||||
class RimIdenticalGridCaseGroup;
|
||||
class RigMainGrid;
|
||||
class RigCaseData;
|
||||
class RimWellPathCollection;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
@@ -34,38 +38,40 @@ class RimProject : public caf::PdmDocument
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
public:
|
||||
caf::PdmPointersField<RimCase*> reservoirs;
|
||||
caf::PdmPointersField<RimIdenticalGridCaseGroup*> caseGroups;
|
||||
caf::PdmField<RimScriptCollection*> scriptCollection;
|
||||
caf::PdmField<QString> treeViewState;
|
||||
caf::PdmField<QString> currentModelIndexPath;
|
||||
|
||||
void setScriptDirectories(const QString& scriptDirectories);
|
||||
|
||||
QString projectFileVersionString() const;
|
||||
|
||||
RimProject(void);
|
||||
virtual ~RimProject(void);
|
||||
|
||||
void close();
|
||||
caf::PdmPointersField<RimOilField*> oilFields;
|
||||
caf::PdmField<RimScriptCollection*> scriptCollection;
|
||||
caf::PdmField<QString> treeViewState;
|
||||
caf::PdmField<QString> currentModelIndexPath;
|
||||
caf::PdmField<int> nextValidCaseId; // Unique case ID within a project, used to identify a case from Octave scripts
|
||||
caf::PdmField<int> nextValidCaseGroupId; // Unique case group ID within a project, used to identify a case group from Octave scripts
|
||||
caf::PdmPointersField<RimCase*> casesObsolete; // obsolete
|
||||
caf::PdmPointersField<RimIdenticalGridCaseGroup*> caseGroupsObsolete; // obsolete
|
||||
|
||||
RimIdenticalGridCaseGroup* createIdenticalCaseGroupFromMainCase(RimCase* mainCase);
|
||||
void insertCaseInCaseGroup(RimIdenticalGridCaseGroup* caseGroup, RimCase* rimReservoir);
|
||||
void setScriptDirectories(const QString& scriptDirectories);
|
||||
QString projectFileVersionString() const;
|
||||
void close();
|
||||
|
||||
void moveEclipseCaseIntoCaseGroup(RimCase* rimReservoir);
|
||||
void removeCaseFromAllGroups(RimCase* rimReservoir);
|
||||
void setProjectFileNameAndUpdateDependencies(const QString& fileName);
|
||||
|
||||
void setProjectFileNameAndUpdateDependencies(const QString& fileName);
|
||||
|
||||
private:
|
||||
RigMainGrid* registerCaseInGridCollection(RigCaseData* rigEclipseCase);
|
||||
void assignCaseIdToCase(RimCase* reservoirCase);
|
||||
void assignIdToCaseGroup(RimIdenticalGridCaseGroup* caseGroup);
|
||||
|
||||
void allCases(std::vector<RimCase*>& cases); // VL endre impl
|
||||
void createDisplayModelAndRedrawAllViews(); // VL endre impl
|
||||
|
||||
void computeUtmAreaOfInterest(double* north, double* south, double* east, double* west);
|
||||
|
||||
RimOilField* activeOilField();
|
||||
|
||||
protected:
|
||||
// Overridden methods
|
||||
virtual void initAfterRead();
|
||||
virtual void setupBeforeSave();
|
||||
void initScriptDirectories();
|
||||
virtual void initAfterRead();
|
||||
virtual void setupBeforeSave();
|
||||
|
||||
private:
|
||||
caf::PdmField<QString> m_projectFileVersionString;
|
||||
cvf::ref<RigGridManager> m_gridCollection;
|
||||
};
|
||||
@@ -16,13 +16,37 @@
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RiaStdInclude.h"
|
||||
//#include "RiaStdInclude.h"
|
||||
#include <QFile>
|
||||
#include <QFileInfo>
|
||||
#include <QDir>
|
||||
#include <QDebug>
|
||||
#include <QUuid>
|
||||
|
||||
#include "RimReservoirCellResultsCacher.h"
|
||||
#include "RigCaseCellResultsData.h"
|
||||
#include "RiaApplication.h"
|
||||
#include "RigMainGrid.h"
|
||||
#include "RigCell.h"
|
||||
#include "cafProgressInfo.h"
|
||||
#include "RimProject.h"
|
||||
#include "RimCase.h"
|
||||
#include "RimCaseCollection.h"
|
||||
#include "RimIdenticalGridCaseGroup.h"
|
||||
#include "RimScriptCollection.h"
|
||||
#include "RimReservoirView.h"
|
||||
|
||||
#include "cafPdmFieldCvfMat4d.h"
|
||||
#include "cafPdmFieldCvfColor.h"
|
||||
#include "RimResultSlot.h"
|
||||
#include "RimCellEdgeResultSlot.h"
|
||||
#include "RimCellRangeFilterCollection.h"
|
||||
#include "RimCellPropertyFilterCollection.h"
|
||||
#include "RimWellCollection.h"
|
||||
#include "Rim3dOverlayInfoConfig.h"
|
||||
#include "RimWellPathCollection.h"
|
||||
#include "RimOilField.h"
|
||||
#include "RimAnalysisModels.h"
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimReservoirCellResultsStorage, "ReservoirCellResultStorage");
|
||||
|
||||
|
||||
@@ -19,6 +19,9 @@
|
||||
#pragma once
|
||||
|
||||
#include <QDateTime>
|
||||
|
||||
#include "cvfBase.h"
|
||||
#include "cvfObject.h"
|
||||
#include "cafPdmField.h"
|
||||
#include "cafPdmObject.h"
|
||||
#include "cafAppEnum.h"
|
||||
@@ -37,8 +40,8 @@ public:
|
||||
virtual ~RimReservoirCellResultsStorage();
|
||||
|
||||
void setCellResults(RigCaseCellResultsData* cellResults);
|
||||
RigCaseCellResultsData* cellResults() { return m_cellResults; }
|
||||
const RigCaseCellResultsData* cellResults() const { return m_cellResults; }
|
||||
RigCaseCellResultsData* cellResults() { return m_cellResults; }
|
||||
const RigCaseCellResultsData* cellResults() const { return m_cellResults; }
|
||||
|
||||
size_t storedResultsCount();
|
||||
|
||||
@@ -67,10 +70,10 @@ private:
|
||||
// Fields
|
||||
caf::PdmField<QString> m_resultCacheFileName;
|
||||
caf::PdmPointersField<RimReservoirCellResultsStorageEntryInfo*>
|
||||
m_resultCacheMetaData;
|
||||
m_resultCacheMetaData;
|
||||
|
||||
cvf::ref<RifReaderInterface> m_readerInterface;
|
||||
RigCaseCellResultsData* m_cellResults;
|
||||
RigCaseCellResultsData* m_cellResults;
|
||||
RigMainGrid* m_ownerMainGrid;
|
||||
};
|
||||
|
||||
|
||||
@@ -16,10 +16,36 @@
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RiaStdInclude.h"
|
||||
#include "RiuViewer.h"
|
||||
|
||||
//#include "RiaStdInclude.h"
|
||||
#include "RimReservoirView.h"
|
||||
#include "RiuViewer.h"
|
||||
#include "cvfViewport.h"
|
||||
#include "cvfModelBasicList.h"
|
||||
#include "cvfPart.h"
|
||||
#include "cvfDrawable.h"
|
||||
#include "cvfScene.h"
|
||||
|
||||
#include "cafPdmFieldCvfMat4d.h"
|
||||
#include "cafPdmFieldCvfColor.h"
|
||||
#include <QMessageBox>
|
||||
|
||||
|
||||
#include "RimProject.h"
|
||||
#include "RimCase.h"
|
||||
#include "RimResultSlot.h"
|
||||
#include "RimCellEdgeResultSlot.h"
|
||||
#include "RimCellRangeFilter.h"
|
||||
#include "RimCellRangeFilterCollection.h"
|
||||
#include "RimCellPropertyFilter.h"
|
||||
#include "RimCellPropertyFilterCollection.h"
|
||||
#include "Rim3dOverlayInfoConfig.h"
|
||||
#include "RimWellPathCollection.h"
|
||||
#include "RimIdenticalGridCaseGroup.h"
|
||||
#include "RimScriptCollection.h"
|
||||
#include "RimCaseCollection.h"
|
||||
#include "RimOilField.h"
|
||||
#include "RimAnalysisModels.h"
|
||||
|
||||
#include "RiuMainWindow.h"
|
||||
#include "RigGridBase.h"
|
||||
#include "RigCaseData.h"
|
||||
@@ -28,13 +54,10 @@
|
||||
|
||||
#include "cafEffectGenerator.h"
|
||||
#include "cafFrameAnimationControl.h"
|
||||
#include "RimCellRangeFilter.h"
|
||||
#include "RimCellRangeFilterCollection.h"
|
||||
|
||||
#include "cvfStructGridGeometryGenerator.h"
|
||||
#include "RigCaseCellResultsData.h"
|
||||
#include "RivCellEdgeEffectGenerator.h"
|
||||
#include "RimCellEdgeResultSlot.h"
|
||||
#include "cvfqtUtils.h"
|
||||
#include "RivReservoirViewPartMgr.h"
|
||||
#include "RivReservoirPipesPartMgr.h"
|
||||
@@ -44,6 +67,11 @@
|
||||
#include "RimCase.h"
|
||||
#include "Rim3dOverlayInfoConfig.h"
|
||||
#include "RigGridScalarDataAccess.h"
|
||||
#include "RimReservoirCellResultsCacher.h"
|
||||
#include "RivWellPathCollectionPartMgr.h"
|
||||
#include "cvfOverlayScalarMapperLegend.h"
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
namespace caf {
|
||||
|
||||
@@ -326,6 +354,11 @@ void RimReservoirView::fieldChangedByUi(const caf::PdmFieldHandle* changedField,
|
||||
{
|
||||
if (scaleZ < 1) scaleZ = 1;
|
||||
|
||||
// Regenerate well paths
|
||||
RimOilField* oilFields = RiaApplication::instance()->project() ? RiaApplication::instance()->project()->activeOilField() : NULL;
|
||||
RimWellPathCollection* wellPathCollection = (oilFields) ? oilFields->wellPathCollection() : NULL;
|
||||
if (wellPathCollection) wellPathCollection->wellPathCollectionPartMgr()->scheduleGeometryRegen();
|
||||
|
||||
if (m_viewer)
|
||||
{
|
||||
cvf::Vec3d poi = m_viewer->pointOfInterest();
|
||||
@@ -449,6 +482,8 @@ void RimReservoirView::updateScaleTransform()
|
||||
if (m_viewer) m_viewer->updateCachedValuesInScene();
|
||||
}
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Create display model,
|
||||
/// or at least empty scenes as frames that is delivered to the viewer
|
||||
@@ -492,7 +527,7 @@ void RimReservoirView::createDisplayModel()
|
||||
timeStepIndices.push_back(0);
|
||||
}
|
||||
|
||||
updateLegends();
|
||||
|
||||
|
||||
cvf::Collection<cvf::ModelBasicList> frameModels;
|
||||
size_t timeIdx;
|
||||
@@ -544,7 +579,6 @@ void RimReservoirView::createDisplayModel()
|
||||
geometryTypesToAdd.push_back(RivReservoirViewPartMgr::INACTIVE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
size_t frameIdx;
|
||||
for (frameIdx = 0; frameIdx < frameModels.size(); ++frameIdx)
|
||||
@@ -560,8 +594,7 @@ void RimReservoirView::createDisplayModel()
|
||||
|
||||
m_visibleGridParts = geometryTypesToAdd;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Compute triangle count, Debug only
|
||||
|
||||
if (false)
|
||||
@@ -611,6 +644,8 @@ void RimReservoirView::createDisplayModel()
|
||||
m_viewer->slotSetCurrentFrame(m_currentTimeStep);
|
||||
}
|
||||
|
||||
overlayInfoConfig()->update3DInfo();
|
||||
updateLegends();
|
||||
}
|
||||
|
||||
|
||||
@@ -619,7 +654,7 @@ void RimReservoirView::createDisplayModel()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimReservoirView::updateCurrentTimeStep()
|
||||
{
|
||||
|
||||
//printf("########## updateCurrentTimeStep for frame %i ##########\n", m_currentTimeStep.v());
|
||||
std::vector<RivReservoirViewPartMgr::ReservoirGeometryCacheType> geometriesToRecolor;
|
||||
|
||||
if (this->propertyFilterCollection()->hasActiveFilters())
|
||||
@@ -684,35 +719,75 @@ void RimReservoirView::updateCurrentTimeStep()
|
||||
}
|
||||
}
|
||||
|
||||
// Well pipes
|
||||
// Well pipes and well paths
|
||||
if (m_viewer)
|
||||
{
|
||||
cvf::Scene* frameScene = m_viewer->frame(m_currentTimeStep);
|
||||
if (frameScene)
|
||||
{
|
||||
cvf::String modelName = "WellPipeModel";
|
||||
std::vector<cvf::Model*> models;
|
||||
// Well pipes
|
||||
// ----------
|
||||
cvf::String wellPipeModelName = "WellPipeModel";
|
||||
std::vector<cvf::Model*> wellPipeModels;
|
||||
for (cvf::uint i = 0; i < frameScene->modelCount(); i++)
|
||||
{
|
||||
if (frameScene->model(i)->name() == modelName)
|
||||
if (frameScene->model(i)->name() == wellPipeModelName)
|
||||
{
|
||||
models.push_back(frameScene->model(i));
|
||||
wellPipeModels.push_back(frameScene->model(i));
|
||||
}
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < models.size(); i++)
|
||||
for (size_t i = 0; i < wellPipeModels.size(); i++)
|
||||
{
|
||||
frameScene->removeModel(models[i]);
|
||||
//printf("updateCurrentTimeStep: Remove WellPipeModel %i from frameScene, for frame %i\n", i, m_currentTimeStep.v());
|
||||
frameScene->removeModel(wellPipeModels[i]);
|
||||
}
|
||||
|
||||
cvf::ref<cvf::ModelBasicList> pipeModel = new cvf::ModelBasicList;
|
||||
pipeModel->setName(modelName);
|
||||
cvf::ref<cvf::ModelBasicList> wellPipeModelBasicList = new cvf::ModelBasicList;
|
||||
wellPipeModelBasicList->setName(wellPipeModelName);
|
||||
|
||||
m_pipesPartManager->appendDynamicGeometryPartsToModel(pipeModel.p(), m_currentTimeStep);
|
||||
m_pipesPartManager->appendDynamicGeometryPartsToModel(wellPipeModelBasicList.p(), m_currentTimeStep);
|
||||
m_pipesPartManager->updatePipeResultColor(m_currentTimeStep);
|
||||
|
||||
pipeModel->updateBoundingBoxesRecursive();
|
||||
frameScene->addModel(pipeModel.p());
|
||||
wellPipeModelBasicList->updateBoundingBoxesRecursive();
|
||||
//printf("updateCurrentTimeStep: Add WellPipeModel to frameScene\n");
|
||||
frameScene->addModel(wellPipeModelBasicList.p());
|
||||
|
||||
// Well paths
|
||||
// ----------
|
||||
cvf::String wellPathModelName = "WellPathModel";
|
||||
std::vector<cvf::Model*> wellPathModels;
|
||||
for (cvf::uint i = 0; i < frameScene->modelCount(); i++)
|
||||
{
|
||||
if (frameScene->model(i)->name() == wellPathModelName)
|
||||
{
|
||||
wellPathModels.push_back(frameScene->model(i));
|
||||
}
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < wellPathModels.size(); i++)
|
||||
{
|
||||
//printf("updateCurrentTimeStep: Remove WellPathModel %i from frameScene, for frame %i\n", i, m_currentTimeStep.v());
|
||||
frameScene->removeModel(wellPathModels[i]);
|
||||
}
|
||||
|
||||
// Append static Well Paths to model
|
||||
cvf::ref<cvf::ModelBasicList> wellPathModelBasicList = new cvf::ModelBasicList;
|
||||
wellPathModelBasicList->setName(wellPathModelName);
|
||||
RimOilField* oilFields = (RiaApplication::instance()->project()) ? RiaApplication::instance()->project()->activeOilField() : NULL;
|
||||
RimWellPathCollection* wellPathCollection = (oilFields) ? oilFields->wellPathCollection() : NULL;
|
||||
RivWellPathCollectionPartMgr* wellPathCollectionPartMgr = (wellPathCollection) ? wellPathCollection->wellPathCollectionPartMgr() : NULL;
|
||||
if (wellPathCollectionPartMgr)
|
||||
{
|
||||
//printf("updateCurrentTimeStep: Append well paths for frame %i: ", m_currentTimeStep.v());
|
||||
cvf::Vec3d displayModelOffset = eclipseCase()->reservoirData()->mainGrid()->displayModelOffset();
|
||||
double characteristicCellSize = eclipseCase()->reservoirData()->mainGrid()->characteristicIJCellSize();
|
||||
cvf::BoundingBox boundingBox = currentActiveCellInfo()->geometryBoundingBox();
|
||||
wellPathCollectionPartMgr->appendStaticGeometryPartsToModel(wellPathModelBasicList.p(), displayModelOffset, m_reservoirGridPartManager->scaleTransform(), characteristicCellSize, boundingBox);
|
||||
//printf("\n");
|
||||
}
|
||||
wellPathModelBasicList->updateBoundingBoxesRecursive();
|
||||
frameScene->addModel(wellPathModelBasicList.p());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -775,7 +850,6 @@ void RimReservoirView::loadDataAndUpdate()
|
||||
setDefaultView();
|
||||
}
|
||||
|
||||
overlayInfoConfig()->update3DInfo();
|
||||
}
|
||||
|
||||
|
||||
@@ -1114,19 +1188,27 @@ void RimReservoirView::updateLegends()
|
||||
if (this->cellResult()->hasResult())
|
||||
{
|
||||
double globalMin, globalMax;
|
||||
double globalPosClosestToZero, globalNegClosestToZero;
|
||||
results->minMaxCellScalarValues(this->cellResult()->gridScalarIndex(), globalMin, globalMax);
|
||||
results->posNegClosestToZero(this->cellResult()->gridScalarIndex(), globalPosClosestToZero, globalNegClosestToZero);
|
||||
|
||||
double localMin, localMax;
|
||||
double localPosClosestToZero, localNegClosestToZero;
|
||||
if (this->cellResult()->hasDynamicResult())
|
||||
{
|
||||
results->minMaxCellScalarValues(this->cellResult()->gridScalarIndex(), m_currentTimeStep, localMin, localMax);
|
||||
results->posNegClosestToZero(this->cellResult()->gridScalarIndex(), m_currentTimeStep, localPosClosestToZero, localNegClosestToZero);
|
||||
}
|
||||
else
|
||||
{
|
||||
localMin = globalMin;
|
||||
localMax = globalMax;
|
||||
|
||||
localPosClosestToZero = globalPosClosestToZero;
|
||||
localNegClosestToZero = globalNegClosestToZero;
|
||||
}
|
||||
|
||||
this->cellResult()->legendConfig->setClosestToZeroValues(globalPosClosestToZero, globalNegClosestToZero, localPosClosestToZero, localNegClosestToZero);
|
||||
this->cellResult()->legendConfig->setAutomaticRanges(globalMin, globalMax, localMin, localMax);
|
||||
|
||||
m_viewer->setColorLegend1(this->cellResult()->legendConfig->legend());
|
||||
@@ -1134,6 +1216,7 @@ void RimReservoirView::updateLegends()
|
||||
}
|
||||
else
|
||||
{
|
||||
this->cellResult()->legendConfig->setClosestToZeroValues(0, 0, 0, 0);
|
||||
this->cellResult()->legendConfig->setAutomaticRanges(cvf::UNDEFINED_DOUBLE, cvf::UNDEFINED_DOUBLE, cvf::UNDEFINED_DOUBLE, cvf::UNDEFINED_DOUBLE);
|
||||
m_viewer->setColorLegend1(NULL);
|
||||
}
|
||||
@@ -1141,8 +1224,13 @@ void RimReservoirView::updateLegends()
|
||||
if (this->cellEdgeResult()->hasResult())
|
||||
{
|
||||
double globalMin, globalMax;
|
||||
double globalPosClosestToZero, globalNegClosestToZero;
|
||||
this->cellEdgeResult()->minMaxCellEdgeValues(globalMin, globalMax);
|
||||
this->cellEdgeResult()->posNegClosestToZero(globalPosClosestToZero, globalNegClosestToZero);
|
||||
|
||||
this->cellEdgeResult()->legendConfig->setClosestToZeroValues(globalPosClosestToZero, globalNegClosestToZero, globalPosClosestToZero, globalNegClosestToZero);
|
||||
this->cellEdgeResult()->legendConfig->setAutomaticRanges(globalMin, globalMax, globalMin, globalMax);
|
||||
|
||||
m_viewer->setColorLegend2(this->cellEdgeResult()->legendConfig->legend());
|
||||
this->cellEdgeResult()->legendConfig->legend()->setTitle(cvfqt::Utils::fromQString(QString("Edge Results: \n") + this->cellEdgeResult()->resultVariable));
|
||||
|
||||
@@ -1150,6 +1238,7 @@ void RimReservoirView::updateLegends()
|
||||
else
|
||||
{
|
||||
m_viewer->setColorLegend2(NULL);
|
||||
this->cellEdgeResult()->legendConfig->setClosestToZeroValues(0, 0, 0, 0);
|
||||
this->cellEdgeResult()->legendConfig->setAutomaticRanges(cvf::UNDEFINED_DOUBLE, cvf::UNDEFINED_DOUBLE, cvf::UNDEFINED_DOUBLE, cvf::UNDEFINED_DOUBLE);
|
||||
}
|
||||
}
|
||||
@@ -1355,8 +1444,6 @@ void RimReservoirView::updateDisplayModelForWellResults()
|
||||
createDisplayModel();
|
||||
updateDisplayModelVisibility();
|
||||
|
||||
overlayInfoConfig()->update3DInfo();
|
||||
|
||||
if (animationMode && m_viewer)
|
||||
{
|
||||
m_viewer->slotSetCurrentFrame(m_currentTimeStep);
|
||||
|
||||
@@ -18,31 +18,37 @@
|
||||
|
||||
#pragma once
|
||||
#include "cafPdmObject.h"
|
||||
#include "cafPdmField.h"
|
||||
#include "cafAppEnum.h"
|
||||
|
||||
#include "cvfBase.h"
|
||||
#include "cvfObject.h"
|
||||
|
||||
#include "cafPdmFieldCvfMat4d.h"
|
||||
#include "cafPdmFieldCvfColor.h"
|
||||
|
||||
#include <QPointer>
|
||||
#include <QString>
|
||||
|
||||
#include "RimCase.h"
|
||||
#include "RimResultSlot.h"
|
||||
#include "RimCellEdgeResultSlot.h"
|
||||
#include "RimCellRangeFilter.h"
|
||||
#include "RimCellRangeFilterCollection.h"
|
||||
#include "RimCellPropertyFilter.h"
|
||||
#include "RimCellPropertyFilterCollection.h"
|
||||
#include "Rim3dOverlayInfoConfig.h"
|
||||
|
||||
#include "cvfMatrix4.h"
|
||||
#include "cvfStructGridGeometryGenerator.h"
|
||||
#include "cafPdmFieldCvfMat4d.h"
|
||||
class RimCase;
|
||||
class RimResultSlot;
|
||||
class RimCellEdgeResultSlot;
|
||||
class RimCellRangeFilter;
|
||||
class RimCellRangeFilterCollection;
|
||||
class RimCellPropertyFilter;
|
||||
class RimCellPropertyFilterCollection;
|
||||
class Rim3dOverlayInfoConfig;
|
||||
class RimReservoirCellResultsStorage;
|
||||
class RimWellCollection;
|
||||
class RigActiveCellInfo;
|
||||
|
||||
#include "RivReservoirViewPartMgr.h"
|
||||
#include "RivReservoirPipesPartMgr.h"
|
||||
class RivReservoirPipesPartMgr;
|
||||
|
||||
class RiuViewer;
|
||||
class RigGridBase;
|
||||
class RigGridCellFaceVisibilityFilter;
|
||||
|
||||
class RimReservoirCellResultsStorage;
|
||||
namespace cvf
|
||||
{
|
||||
class Transform;
|
||||
|
||||
@@ -28,7 +28,22 @@
|
||||
#include "RimProject.h"
|
||||
#include "RifEclipseOutputFileTools.h"
|
||||
#include "RiaApplication.h"
|
||||
#include "RimIdenticalGridCaseGroup.h"
|
||||
#include "RimScriptCollection.h"
|
||||
#include "RimCaseCollection.h"
|
||||
#include "RimReservoirCellResultsCacher.h"
|
||||
#include "RimWellPathCollection.h"
|
||||
|
||||
#include "cafPdmFieldCvfMat4d.h"
|
||||
#include "cafPdmFieldCvfColor.h"
|
||||
#include "RimResultSlot.h"
|
||||
#include "RimCellEdgeResultSlot.h"
|
||||
#include "RimCellRangeFilterCollection.h"
|
||||
#include "RimCellPropertyFilterCollection.h"
|
||||
#include "RimWellCollection.h"
|
||||
#include "Rim3dOverlayInfoConfig.h"
|
||||
#include "RimOilField.h"
|
||||
#include "RimAnalysisModels.h"
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimResultCase, "EclipseCase");
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -37,7 +52,7 @@ CAF_PDM_SOURCE_INIT(RimResultCase, "EclipseCase");
|
||||
RimResultCase::RimResultCase()
|
||||
: RimCase()
|
||||
{
|
||||
CAF_PDM_InitObject("Eclipse Case", ":/AppLogo48x48.png", "", "");
|
||||
CAF_PDM_InitObject("Eclipse Case", ":/Case48x48.png", "", "");
|
||||
|
||||
CAF_PDM_InitField(&caseFileName, "CaseFileName", QString(), "Case file name", "", "" ,"");
|
||||
caseFileName.setUiReadOnly(true);
|
||||
@@ -48,9 +63,9 @@ RimResultCase::RimResultCase()
|
||||
caseDirectory.setUiHidden(true);
|
||||
|
||||
flipXAxis.setIOWritable(true);
|
||||
flipXAxis.setUiHidden(true);
|
||||
//flipXAxis.setUiHidden(true);
|
||||
flipYAxis.setIOWritable(true);
|
||||
flipYAxis.setUiHidden(true);
|
||||
//flipYAxis.setUiHidden(true);
|
||||
|
||||
m_activeCellInfoIsReadFromFile = false;
|
||||
m_gridAndWellDataIsReadFromFile = false;
|
||||
@@ -289,8 +304,11 @@ void RimResultCase::updateFilePathsFromProjectPath(const QString& newProjectPath
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimResultCase::setCaseInfo(const QString& userDescription, const QString& caseFileName)
|
||||
{
|
||||
this->caseUserDescription = userDescription;
|
||||
this->caseFileName = caseFileName;
|
||||
this->caseUserDescription = userDescription;
|
||||
this->caseFileName = caseFileName;
|
||||
|
||||
RimProject* proj = RiaApplication::instance()->project();
|
||||
proj->assignCaseIdToCase(this);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -310,3 +328,13 @@ void RimResultCase::initAfterRead()
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimResultCase::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering)
|
||||
{
|
||||
uiOrdering.add(&caseUserDescription);
|
||||
uiOrdering.add(&caseId);
|
||||
uiOrdering.add(&caseFileName);
|
||||
}
|
||||
|
||||
@@ -56,6 +56,8 @@ private:
|
||||
|
||||
virtual void initAfterRead();
|
||||
|
||||
virtual void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering );
|
||||
|
||||
// Fields:
|
||||
caf::PdmField<QString> caseFileName;
|
||||
|
||||
|
||||
@@ -16,9 +16,10 @@
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RiaStdInclude.h"
|
||||
//#include "RiaStdInclude.h"
|
||||
|
||||
#include "RimResultDefinition.h"
|
||||
#include "RimReservoirCellResultsCacher.h"
|
||||
|
||||
#include "RimReservoirView.h"
|
||||
#include "RimCase.h"
|
||||
@@ -28,13 +29,22 @@
|
||||
#include "cafPdmUiListEditor.h"
|
||||
|
||||
|
||||
#include "cafPdmFieldCvfMat4d.h"
|
||||
#include "cafPdmFieldCvfColor.h"
|
||||
#include "RimResultSlot.h"
|
||||
#include "RimCellEdgeResultSlot.h"
|
||||
#include "RimCellRangeFilterCollection.h"
|
||||
#include "RimCellPropertyFilterCollection.h"
|
||||
#include "RimWellCollection.h"
|
||||
#include "Rim3dOverlayInfoConfig.h"
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimResultDefinition, "ResultDefinition");
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimResultDefinition::RimResultDefinition()
|
||||
: m_gridScalarResultIndex(cvf::UNDEFINED_SIZE_T)
|
||||
//: m_gridScalarResultIndex(cvf::UNDEFINED_SIZE_T)
|
||||
{
|
||||
CAF_PDM_InitObject("Result Definition", "", "", "");
|
||||
|
||||
@@ -170,12 +180,12 @@ QList<caf::PdmOptionItemInfo> RimResultDefinition::calculateValueOptions(const c
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
size_t RimResultDefinition::gridScalarIndex() const
|
||||
{
|
||||
if (m_gridScalarResultIndex == cvf::UNDEFINED_SIZE_T)
|
||||
{
|
||||
const RimReservoirCellResultsStorage* gridCellResults = this->currentGridCellResults();
|
||||
if (gridCellResults) m_gridScalarResultIndex = gridCellResults->cellResults()->findScalarResultIndex(m_resultType(), m_resultVariable());
|
||||
}
|
||||
return m_gridScalarResultIndex;
|
||||
size_t gridScalarResultIndex = cvf::UNDEFINED_SIZE_T;
|
||||
|
||||
const RimReservoirCellResultsStorage* gridCellResults = this->currentGridCellResults();
|
||||
if (gridCellResults) gridScalarResultIndex = gridCellResults->cellResults()->findScalarResultIndex(m_resultType(), m_resultVariable());
|
||||
|
||||
return gridScalarResultIndex;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -186,12 +196,9 @@ void RimResultDefinition::loadResult()
|
||||
RimReservoirCellResultsStorage* gridCellResults = this->currentGridCellResults();
|
||||
if (gridCellResults)
|
||||
{
|
||||
m_gridScalarResultIndex = gridCellResults->findOrLoadScalarResult(m_resultType(), m_resultVariable);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_gridScalarResultIndex = cvf::UNDEFINED_SIZE_T;
|
||||
gridCellResults->findOrLoadScalarResult(m_resultType(), m_resultVariable);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -202,7 +209,9 @@ void RimResultDefinition::loadResult()
|
||||
bool RimResultDefinition::hasStaticResult() const
|
||||
{
|
||||
const RimReservoirCellResultsStorage* gridCellResults = this->currentGridCellResults();
|
||||
if (hasResult() && gridCellResults->cellResults()->timeStepCount(m_gridScalarResultIndex) == 1 )
|
||||
size_t gridScalarResultIndex = this->gridScalarIndex();
|
||||
|
||||
if (hasResult() && gridCellResults->cellResults()->timeStepCount(gridScalarResultIndex) == 1 )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -217,13 +226,12 @@ bool RimResultDefinition::hasStaticResult() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimResultDefinition::hasResult() const
|
||||
{
|
||||
if (m_gridScalarResultIndex != cvf::UNDEFINED_SIZE_T) return true;
|
||||
|
||||
if (this->currentGridCellResults() && this->currentGridCellResults()->cellResults())
|
||||
{
|
||||
const RigCaseCellResultsData* gridCellResults = this->currentGridCellResults()->cellResults();
|
||||
m_gridScalarResultIndex = gridCellResults->findScalarResultIndex(m_resultType(), m_resultVariable());
|
||||
return m_gridScalarResultIndex != cvf::UNDEFINED_SIZE_T;
|
||||
size_t gridScalarResultIndex = gridCellResults->findScalarResultIndex(m_resultType(), m_resultVariable());
|
||||
return gridScalarResultIndex != cvf::UNDEFINED_SIZE_T;
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -245,7 +253,8 @@ bool RimResultDefinition::hasDynamicResult() const
|
||||
if (this->currentGridCellResults() && this->currentGridCellResults()->cellResults())
|
||||
{
|
||||
const RigCaseCellResultsData* gridCellResults = this->currentGridCellResults()->cellResults();
|
||||
if (gridCellResults->timeStepCount(m_gridScalarResultIndex) > 1 )
|
||||
size_t gridScalarResultIndex = this->gridScalarIndex();
|
||||
if (gridCellResults->timeStepCount(gridScalarResultIndex) > 1 )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ protected:
|
||||
caf::PdmField<QString> m_resultVariableUiField;
|
||||
|
||||
|
||||
mutable size_t m_gridScalarResultIndex;
|
||||
//mutable size_t m_gridScalarResultIndex;
|
||||
|
||||
caf::PdmPointer<RimReservoirView> m_reservoirView;
|
||||
|
||||
|
||||
@@ -26,6 +26,17 @@
|
||||
#include "RimUiTreeModelPdm.h"
|
||||
|
||||
|
||||
#include "cafPdmFieldCvfMat4d.h"
|
||||
#include "cafPdmFieldCvfColor.h"
|
||||
#include "RimResultSlot.h"
|
||||
#include "RimCellEdgeResultSlot.h"
|
||||
#include "RimCellRangeFilterCollection.h"
|
||||
#include "RimCellPropertyFilterCollection.h"
|
||||
#include "RimWellCollection.h"
|
||||
#include "Rim3dOverlayInfoConfig.h"
|
||||
|
||||
#include "RimReservoirCellResultsCacher.h"
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimResultSlot, "ResultSlot");
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -91,7 +102,7 @@ void RimResultSlot::changeLegendConfig(QString resultVarNameOfNewLegend)
|
||||
m_legendConfigData.v().erase(it);
|
||||
m_legendConfigData.v().push_back(this->legendConfig());
|
||||
this->legendConfig = newLegend;
|
||||
RiuMainWindow::instance()->uiPdmModel()->rebuildUiSubTree(this);
|
||||
RiuMainWindow::instance()->uiPdmModel()->updateUiSubTree(this);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
@@ -105,7 +116,7 @@ void RimResultSlot::changeLegendConfig(QString resultVarNameOfNewLegend)
|
||||
newLegend->resultVariableName = resultVarNameOfNewLegend;
|
||||
m_legendConfigData.v().push_back(this->legendConfig());
|
||||
this->legendConfig = newLegend;
|
||||
RiuMainWindow::instance()->uiPdmModel()->rebuildUiSubTree(this);
|
||||
RiuMainWindow::instance()->uiPdmModel()->updateUiSubTree(this);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -174,7 +174,7 @@ void RimScriptCollection::fieldChangedByUi(const caf::PdmFieldHandle *changedFie
|
||||
this->setUiName(fi.baseName());
|
||||
this->readContentFromDisc();
|
||||
RimUiTreeModelPdm* treeModel = RiuMainWindow::instance()->uiPdmModel();
|
||||
if (treeModel) treeModel->rebuildUiSubTree(this);
|
||||
if (treeModel) treeModel->updateUiSubTree(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -32,6 +32,19 @@
|
||||
#include "RiuMainWindow.h"
|
||||
#include "RimUiTreeModelPdm.h"
|
||||
#include "cafProgressInfo.h"
|
||||
#include "RimCaseCollection.h"
|
||||
|
||||
|
||||
#include "cafPdmFieldCvfMat4d.h"
|
||||
#include "cafPdmFieldCvfColor.h"
|
||||
#include "RimResultSlot.h"
|
||||
#include "RimCellEdgeResultSlot.h"
|
||||
#include "RimCellRangeFilterCollection.h"
|
||||
#include "RimCellPropertyFilterCollection.h"
|
||||
#include "RimWellCollection.h"
|
||||
#include "Rim3dOverlayInfoConfig.h"
|
||||
|
||||
#include "RimReservoirCellResultsCacher.h"
|
||||
|
||||
namespace caf {
|
||||
template<>
|
||||
@@ -318,6 +331,8 @@ void RimStatisticsCase::defineUiOrdering(QString uiConfigName, caf::PdmUiOrderin
|
||||
updatePercentileUiVisibility();
|
||||
|
||||
uiOrdering.add(&caseUserDescription);
|
||||
|
||||
uiOrdering.add(&caseId);
|
||||
uiOrdering.add(&m_calculateEditCommand);
|
||||
uiOrdering.add(&m_selectionSummary);
|
||||
|
||||
@@ -495,7 +510,7 @@ void RimStatisticsCase::setWellResultsAndUpdateViews(const cvf::Collection<RigSi
|
||||
reservoirView->wellCollection()->wells.deleteAllChildObjects();
|
||||
reservoirView->updateDisplayModelForWellResults();
|
||||
|
||||
treeModel->rebuildUiSubTree(reservoirView->wellCollection());
|
||||
treeModel->updateUiSubTree(reservoirView->wellCollection());
|
||||
|
||||
progInfo.incrementProgress();
|
||||
}
|
||||
@@ -635,6 +650,15 @@ void RimStatisticsCase::clearComputedStatistics()
|
||||
reservoirData()->results(RifReaderInterface::MATRIX_RESULTS)->clearAllResults();
|
||||
reservoirData()->results(RifReaderInterface::FRACTURE_RESULTS)->clearAllResults();
|
||||
|
||||
for (size_t i = 0; i < reservoirViews().size(); i++)
|
||||
{
|
||||
RimReservoirView* reservoirView = reservoirViews()[i];
|
||||
CVF_ASSERT(reservoirView);
|
||||
|
||||
reservoirView->scheduleGeometryRegen(RivReservoirViewPartMgr::ACTIVE);
|
||||
reservoirView->createDisplayModelAndRedraw();
|
||||
}
|
||||
|
||||
this->updateConnectedEditors();
|
||||
}
|
||||
|
||||
|
||||
@@ -22,8 +22,10 @@
|
||||
#include "cvfObject.h"
|
||||
#include "cafPdmField.h"
|
||||
#include "cafPdmObject.h"
|
||||
#include "cafAppEnum.h"
|
||||
|
||||
#include "RimCase.h"
|
||||
#include "RimDefines.h"
|
||||
|
||||
class RimIdenticalGridCaseGroup;
|
||||
class RimResultDefinition;
|
||||
|
||||
@@ -22,6 +22,17 @@
|
||||
|
||||
#include "RimStatisticsCaseCollection.h"
|
||||
#include "RimIdenticalGridCaseGroup.h"
|
||||
#include "RimCaseCollection.h"
|
||||
|
||||
#include "cafPdmFieldCvfMat4d.h"
|
||||
#include "cafPdmFieldCvfColor.h"
|
||||
#include "RimResultSlot.h"
|
||||
#include "RimCellEdgeResultSlot.h"
|
||||
#include "RimCellRangeFilterCollection.h"
|
||||
#include "RimCellPropertyFilterCollection.h"
|
||||
#include "RimWellCollection.h"
|
||||
#include "Rim3dOverlayInfoConfig.h"
|
||||
#include "RimReservoirCellResultsCacher.h"
|
||||
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimStatisticsCaseCollection, "RimStatisticalCollection");
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
#include "RiaStdInclude.h"
|
||||
//#include "RiaStdInclude.h"
|
||||
|
||||
#include "RimStatisticsCaseEvaluator.h"
|
||||
#include "RigCaseCellResultsData.h"
|
||||
@@ -23,6 +23,17 @@
|
||||
#include "RimCase.h"
|
||||
#include "RigCaseData.h"
|
||||
#include "RigStatisticsMath.h"
|
||||
#include "RimReservoirCellResultsCacher.h"
|
||||
|
||||
|
||||
#include "cafPdmFieldCvfMat4d.h"
|
||||
#include "cafPdmFieldCvfColor.h"
|
||||
#include "RimResultSlot.h"
|
||||
#include "RimCellEdgeResultSlot.h"
|
||||
#include "RimCellRangeFilterCollection.h"
|
||||
#include "RimCellPropertyFilterCollection.h"
|
||||
#include "RimWellCollection.h"
|
||||
#include "Rim3dOverlayInfoConfig.h"
|
||||
|
||||
//#include "RigCaseData.h"
|
||||
#include <QDebug>
|
||||
@@ -74,7 +85,7 @@ void RimStatisticsCaseEvaluator::buildSourceMetaData(RifReaderInterface::Porosit
|
||||
for (size_t caseIdx = 1; caseIdx < m_sourceCases.size(); caseIdx++)
|
||||
{
|
||||
RimReservoirCellResultsStorage* cellResultsStorage = m_sourceCases[caseIdx]->results(poroModel);
|
||||
size_t scalarResultIndex = cellResultsStorage->findOrLoadScalarResult(resultType, resultName);
|
||||
size_t scalarResultIndex = cellResultsStorage->cellResults()->findScalarResultIndex(resultType, resultName);
|
||||
if (scalarResultIndex == cvf::UNDEFINED_SIZE_T)
|
||||
{
|
||||
size_t scalarResultIndex = cellResultsStorage->cellResults()->addEmptyScalarResult(resultType, resultName, false);
|
||||
@@ -164,11 +175,11 @@ void RimStatisticsCaseEvaluator::evaluateForResults(const QList<ResSpec>& result
|
||||
{
|
||||
RigGridBase* grid = m_destinationCase->grid(gridIdx);
|
||||
|
||||
for (int i = 0; i < resultSpecification.size(); i++)
|
||||
for (int resSpecIdx = 0; resSpecIdx < resultSpecification.size(); resSpecIdx++)
|
||||
{
|
||||
RifReaderInterface::PorosityModelResultType poroModel = resultSpecification[i].m_poroModel;
|
||||
RimDefines::ResultCatType resultType = resultSpecification[i].m_resType;
|
||||
QString resultName = resultSpecification[i].m_resVarName;
|
||||
RifReaderInterface::PorosityModelResultType poroModel = resultSpecification[resSpecIdx].m_poroModel;
|
||||
RimDefines::ResultCatType resultType = resultSpecification[resSpecIdx].m_resType;
|
||||
QString resultName = resultSpecification[resSpecIdx].m_resVarName;
|
||||
|
||||
size_t activeCellCount = m_destinationCase->activeCellInfo(poroModel)->globalActiveCellCount();
|
||||
|
||||
@@ -191,11 +202,11 @@ void RimStatisticsCaseEvaluator::evaluateForResults(const QList<ResSpec>& result
|
||||
cvf::Collection<cvf::StructGridScalarDataAccess> sourceDataAccessList;
|
||||
for (size_t caseIdx = 0; caseIdx < m_sourceCases.size(); caseIdx++)
|
||||
{
|
||||
RimCase* eclipseCase = m_sourceCases.at(caseIdx);
|
||||
RimCase* sourceCase = m_sourceCases.at(caseIdx);
|
||||
|
||||
size_t scalarResultIndex = eclipseCase->results(poroModel)->findOrLoadScalarResultForTimeStep(resultType, resultName, dataAccessTimeStepIndex);
|
||||
size_t scalarResultIndex = sourceCase->results(poroModel)->findOrLoadScalarResultForTimeStep(resultType, resultName, dataAccessTimeStepIndex);
|
||||
|
||||
cvf::ref<cvf::StructGridScalarDataAccess> dataAccessObject = eclipseCase->reservoirData()->dataAccessObject(grid, poroModel, dataAccessTimeStepIndex, scalarResultIndex);
|
||||
cvf::ref<cvf::StructGridScalarDataAccess> dataAccessObject = sourceCase->reservoirData()->dataAccessObject(grid, poroModel, dataAccessTimeStepIndex, scalarResultIndex);
|
||||
if (dataAccessObject.notNull())
|
||||
{
|
||||
sourceDataAccessList.push_back(dataAccessObject.p());
|
||||
@@ -230,9 +241,11 @@ void RimStatisticsCaseEvaluator::evaluateForResults(const QList<ResSpec>& result
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<double> statParams(STAT_PARAM_COUNT, HUGE_VAL);
|
||||
std::vector<double> values(sourceDataAccessList.size(), HUGE_VAL);
|
||||
// Loop over the cells in the grid, get the case values, and calculate the cell statistics
|
||||
|
||||
for (size_t cellIdx = 0; cellIdx < grid->cellCount(); cellIdx++)
|
||||
#pragma omp parallel for schedule(dynamic) firstprivate(statParams, values)
|
||||
for (int cellIdx = 0; static_cast<size_t>(cellIdx) < grid->cellCount(); cellIdx++)
|
||||
{
|
||||
|
||||
size_t globalGridCellIdx = grid->globalGridCellIndex(cellIdx);
|
||||
@@ -240,7 +253,7 @@ void RimStatisticsCaseEvaluator::evaluateForResults(const QList<ResSpec>& result
|
||||
{
|
||||
// Extract the cell values from each of the cases and assemble them into one vector
|
||||
|
||||
std::vector<double> values(sourceDataAccessList.size(), HUGE_VAL);
|
||||
|
||||
|
||||
bool foundAnyValidValues = false;
|
||||
for (size_t caseIdx = 0; caseIdx < sourceDataAccessList.size(); caseIdx++)
|
||||
@@ -255,7 +268,7 @@ void RimStatisticsCaseEvaluator::evaluateForResults(const QList<ResSpec>& result
|
||||
}
|
||||
|
||||
// Do the real statistics calculations
|
||||
std::vector<double> statParams(STAT_PARAM_COUNT, HUGE_VAL);
|
||||
|
||||
|
||||
if (foundAnyValidValues)
|
||||
{
|
||||
@@ -316,13 +329,21 @@ void RimStatisticsCaseEvaluator::evaluateForResults(const QList<ResSpec>& result
|
||||
}
|
||||
}
|
||||
|
||||
// When one time step is completed, close all result files.
|
||||
// When one time step is completed, free memory and clean up
|
||||
// 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
|
||||
|
||||
for (size_t caseIdx = 0; caseIdx < m_sourceCases.size(); caseIdx++)
|
||||
{
|
||||
RimCase* eclipseCase = m_sourceCases.at(caseIdx);
|
||||
|
||||
if (!eclipseCase->reservoirViews.size())
|
||||
{
|
||||
eclipseCase->results(RifReaderInterface::MATRIX_RESULTS)->cellResults()->freeAllocatedResultsData();
|
||||
eclipseCase->results(RifReaderInterface::FRACTURE_RESULTS)->cellResults()->freeAllocatedResultsData();
|
||||
}
|
||||
|
||||
// Todo : These calls really do nothing right now the access actually closes automatically in ert i belive ...
|
||||
eclipseCase->results(RifReaderInterface::MATRIX_RESULTS)->readerInterface()->close();
|
||||
eclipseCase->results(RifReaderInterface::FRACTURE_RESULTS)->readerInterface()->close();
|
||||
}
|
||||
|
||||
@@ -41,6 +41,22 @@
|
||||
#include "RimCase.h"
|
||||
#include "RigCaseData.h"
|
||||
#include "RimMimeData.h"
|
||||
#include "RimCaseCollection.h"
|
||||
#include "RimIdenticalGridCaseGroup.h"
|
||||
#include "RimProject.h"
|
||||
#include "RimScriptCollection.h"
|
||||
#include "RimWellCollection.h"
|
||||
#include "cafPdmFieldCvfMat4d.h"
|
||||
#include "cafPdmFieldCvfColor.h"
|
||||
#include "RimResultSlot.h"
|
||||
#include "RimCellEdgeResultSlot.h"
|
||||
#include "Rim3dOverlayInfoConfig.h"
|
||||
#include "RimReservoirCellResultsCacher.h"
|
||||
#include "RimWellPathCollection.h"
|
||||
#include "RimOilField.h"
|
||||
#include "RimAnalysisModels.h"
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
@@ -221,32 +237,34 @@ void RimUiTreeModelPdm::deleteReservoir(RimCase* reservoir)
|
||||
{
|
||||
if (reservoir->parentCaseCollection())
|
||||
{
|
||||
RimCaseCollection* caseCollection = reservoir->parentCaseCollection();
|
||||
QModelIndex caseCollectionModelIndex = getModelIndexFromPdmObject(caseCollection);
|
||||
if (!caseCollectionModelIndex.isValid()) return;
|
||||
RimCaseCollection* caseCollection = reservoir->parentCaseCollection();
|
||||
QModelIndex caseCollectionModelIndex = getModelIndexFromPdmObject(caseCollection);
|
||||
if (!caseCollectionModelIndex.isValid()) return;
|
||||
|
||||
QModelIndex mi = getModelIndexFromPdmObjectRecursive(caseCollectionModelIndex, reservoir);
|
||||
if (mi.isValid())
|
||||
{
|
||||
caf::PdmUiTreeItem* uiItem = getTreeItemFromIndex(mi);
|
||||
CVF_ASSERT(uiItem);
|
||||
QModelIndex mi = getModelIndexFromPdmObjectRecursive(caseCollectionModelIndex, reservoir);
|
||||
if (mi.isValid())
|
||||
{
|
||||
caf::PdmUiTreeItem* uiItem = getTreeItemFromIndex(mi);
|
||||
CVF_ASSERT(uiItem);
|
||||
|
||||
// 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
|
||||
removeRows_special(mi.row(), 1, mi.parent());
|
||||
}
|
||||
|
||||
if (RimIdenticalGridCaseGroup::isStatisticsCaseCollection(caseCollection))
|
||||
{
|
||||
RimIdenticalGridCaseGroup* caseGroup = caseCollection->parentCaseGroup();
|
||||
CVF_ASSERT(caseGroup);
|
||||
if (RimIdenticalGridCaseGroup::isStatisticsCaseCollection(caseCollection))
|
||||
{
|
||||
RimIdenticalGridCaseGroup* caseGroup = caseCollection->parentCaseGroup();
|
||||
CVF_ASSERT(caseGroup);
|
||||
|
||||
caseGroup->statisticsCaseCollection()->reservoirs.removeChildObject(reservoir);
|
||||
}
|
||||
else
|
||||
{
|
||||
RimProject* proj = RiaApplication::instance()->project();
|
||||
proj->removeCaseFromAllGroups(reservoir);
|
||||
}
|
||||
caseGroup->statisticsCaseCollection()->reservoirs.removeChildObject(reservoir);
|
||||
}
|
||||
else
|
||||
{
|
||||
RimProject* proj = RiaApplication::instance()->project();
|
||||
RimOilField* activeOilField = proj ? proj->activeOilField() : NULL;
|
||||
RimAnalysisModels* analysisModels = (activeOilField) ? activeOilField->analysisModels() : NULL;
|
||||
if (analysisModels) analysisModels->removeCaseFromAllGroups(reservoir);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -261,7 +279,9 @@ void RimUiTreeModelPdm::deleteReservoir(RimCase* reservoir)
|
||||
removeRows_special(mi.row(), 1, mi.parent());
|
||||
}
|
||||
|
||||
proj->removeCaseFromAllGroups(reservoir);
|
||||
RimOilField* activeOilField = proj ? proj->activeOilField() : NULL;
|
||||
RimAnalysisModels* analysisModels = (activeOilField) ? activeOilField->analysisModels() : NULL;
|
||||
if (analysisModels) analysisModels->removeCaseFromAllGroups(reservoir);
|
||||
}
|
||||
|
||||
delete reservoir;
|
||||
@@ -445,7 +465,7 @@ void RimUiTreeModelPdm::slotRefreshScriptTree(QString path)
|
||||
if (changedSColl)
|
||||
{
|
||||
changedSColl->readContentFromDisc();
|
||||
this->rebuildUiSubTree(changedSColl);
|
||||
this->updateUiSubTree(changedSColl);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -470,7 +490,7 @@ void RimUiTreeModelPdm::addInputProperty(const QModelIndex& itemIndex, const QSt
|
||||
inputReservoir->openDataFileSet(fileNames);
|
||||
}
|
||||
|
||||
this->rebuildUiSubTree(inputPropertyCollection);
|
||||
this->updateUiSubTree(inputPropertyCollection);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -544,7 +564,10 @@ RimStatisticsCase* RimUiTreeModelPdm::addStatisticalCalculation(const QModelInde
|
||||
{
|
||||
beginInsertRows(collectionIndex, position, position);
|
||||
|
||||
RimProject* proj = RiaApplication::instance()->project();
|
||||
RimStatisticsCase* createdObject = caseGroup->createAndAppendStatisticsCase();
|
||||
proj->assignCaseIdToCase(createdObject);
|
||||
|
||||
caf::PdmUiTreeItem* childItem = new caf::PdmUiTreeItem(parentCollectionItem, position, createdObject);
|
||||
|
||||
endInsertRows();
|
||||
@@ -582,9 +605,16 @@ RimIdenticalGridCaseGroup* RimUiTreeModelPdm::addCaseGroup(QModelIndex& inserted
|
||||
beginInsertRows(rootIndex, position, position);
|
||||
|
||||
RimIdenticalGridCaseGroup* createdObject = new RimIdenticalGridCaseGroup;
|
||||
createdObject->createAndAppendStatisticsCase();
|
||||
proj->assignIdToCaseGroup(createdObject);
|
||||
|
||||
RimCase* createdReservoir = createdObject->createAndAppendStatisticsCase();
|
||||
proj->assignCaseIdToCase(createdReservoir);
|
||||
createdObject->name = QString("Grid Case Group %1").arg(position + 1);
|
||||
proj->caseGroups().push_back(createdObject);
|
||||
RimAnalysisModels* analysisModels = proj->activeOilField() ? proj->activeOilField()->analysisModels() : NULL;
|
||||
if (analysisModels)
|
||||
{
|
||||
analysisModels->caseGroups().push_back(createdObject);
|
||||
}
|
||||
|
||||
caf::PdmUiTreeItem* childItem = caf::UiTreeItemBuilderPdm::buildViewItems(rootTreeItem, position, createdObject);
|
||||
endInsertRows();
|
||||
@@ -630,6 +660,8 @@ void RimUiTreeModelPdm::addObjects(const QModelIndex& itemIndex, caf::PdmObjectG
|
||||
{
|
||||
RimResultCase* rimResultReservoir = typedObjects[i];
|
||||
|
||||
proj->assignCaseIdToCase(rimResultReservoir);
|
||||
|
||||
if (gridCaseGroup->contains(rimResultReservoir))
|
||||
{
|
||||
continue;
|
||||
@@ -659,7 +691,9 @@ void RimUiTreeModelPdm::addObjects(const QModelIndex& itemIndex, caf::PdmObjectG
|
||||
}
|
||||
}
|
||||
|
||||
proj->insertCaseInCaseGroup(gridCaseGroup, rimResultReservoir);
|
||||
RimOilField* activeOilField = proj ? proj->activeOilField() : NULL;
|
||||
RimAnalysisModels* analysisModels = (activeOilField) ? activeOilField->analysisModels() : NULL;
|
||||
if (analysisModels) analysisModels->insertCaseInCaseGroup(gridCaseGroup, rimResultReservoir);
|
||||
|
||||
caf::PdmObjectGroup::initAfterReadTraversal(rimResultReservoir);
|
||||
|
||||
|
||||
@@ -16,10 +16,18 @@
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RiaStdInclude.h"
|
||||
//#include "RiaStdInclude.h"
|
||||
|
||||
#include "cafPdmDocument.h"
|
||||
|
||||
#include <QAction>
|
||||
#include <QMenu>
|
||||
#include <QContextMenuEvent>
|
||||
#include <QMessageBox>
|
||||
#include <QFileInfo>
|
||||
#include <QFileDialog>
|
||||
#include <QClipboard>
|
||||
|
||||
#include "RimUiTreeView.h"
|
||||
#include "RimUiTreeModelPdm.h"
|
||||
#include "RimReservoirView.h"
|
||||
@@ -38,6 +46,27 @@
|
||||
#include "RimResultCase.h"
|
||||
#include "RimMimeData.h"
|
||||
|
||||
#include "RimCellRangeFilterCollection.h"
|
||||
#include "RimCellPropertyFilterCollection.h"
|
||||
#include "RimResultSlot.h"
|
||||
#include "RimStatisticsCaseCollection.h"
|
||||
#include "RimIdenticalGridCaseGroup.h"
|
||||
#include "RimCaseCollection.h"
|
||||
#include "RimScriptCollection.h"
|
||||
#include "RimWell.h"
|
||||
#include "RimCellEdgeResultSlot.h"
|
||||
#include "RimWellCollection.h"
|
||||
#include "RimWellPathCollection.h"
|
||||
#include "RimReservoirCellResultsCacher.h"
|
||||
#include "Rim3dOverlayInfoConfig.h"
|
||||
|
||||
#include "cafPdmFieldCvfColor.h"
|
||||
#include "cafPdmFieldCvfMat4d.h"
|
||||
#include "RimProject.h"
|
||||
#include "RimOilField.h"
|
||||
#include "RimAnalysisModels.h"
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -153,7 +182,7 @@ void RimUiTreeView::contextMenuEvent(QContextMenuEvent* event)
|
||||
}
|
||||
else if (dynamic_cast<RimStatisticsCaseCollection*>(uiItem->dataObject().p()))
|
||||
{
|
||||
menu.addAction(QString("New Statistcs Case"), this, SLOT(slotNewStatisticsCase()));
|
||||
menu.addAction(QString("New Statistics Case"), this, SLOT(slotNewStatisticsCase()));
|
||||
}
|
||||
else if (dynamic_cast<RimStatisticsCase*>(uiItem->dataObject().p()))
|
||||
{
|
||||
@@ -192,6 +221,40 @@ void RimUiTreeView::contextMenuEvent(QContextMenuEvent* event)
|
||||
menu.addAction(QString("Delete Script Path"), this, SLOT(slotDeleteScriptPath()));
|
||||
}
|
||||
|
||||
// Execute script on selection of cases
|
||||
RiuMainWindow* ruiMainWindow = RiuMainWindow::instance();
|
||||
if (ruiMainWindow)
|
||||
{
|
||||
std::vector<RimCase*> cases;
|
||||
ruiMainWindow->selectedCases(cases);
|
||||
|
||||
if (cases.size() > 0)
|
||||
{
|
||||
QMenu* executeMenu = menu.addMenu("Execute script");
|
||||
|
||||
RiaApplication* app = RiaApplication::instance();
|
||||
RimProject* proj = app->project();
|
||||
if (proj && proj->scriptCollection())
|
||||
{
|
||||
RimScriptCollection* rootScriptCollection = proj->scriptCollection();
|
||||
|
||||
// Root script collection holds a list of subdirectories of user defined script folders
|
||||
for (size_t i = 0; i < rootScriptCollection->subDirectories.size(); i++)
|
||||
{
|
||||
RimScriptCollection* subDir = rootScriptCollection->subDirectories[i];
|
||||
|
||||
if (subDir)
|
||||
{
|
||||
appendScriptItems(executeMenu, subDir);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
menu.addSeparator();
|
||||
menu.addMenu(executeMenu);
|
||||
}
|
||||
}
|
||||
|
||||
appendToggleItemActions(menu);
|
||||
menu.exec(event->globalPos());
|
||||
}
|
||||
@@ -491,6 +554,83 @@ void RimUiTreeView::slotExecuteScript()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimUiTreeView::slotExecuteScriptForSelectedCases()
|
||||
{
|
||||
QAction* action = qobject_cast<QAction*>(sender());
|
||||
|
||||
if (!action) return;
|
||||
|
||||
QString encodedModelIndex = action->data().toString();
|
||||
QModelIndex mi = RimUiTreeView::getModelIndexFromString(model(), encodedModelIndex);
|
||||
|
||||
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
|
||||
caf::PdmUiTreeItem* uiItem = myModel->getTreeItemFromIndex(mi);
|
||||
if (uiItem)
|
||||
{
|
||||
RimCalcScript* calcScript = dynamic_cast<RimCalcScript*>(uiItem->dataObject().p());
|
||||
if (!calcScript) return;
|
||||
|
||||
RiaApplication* app = RiaApplication::instance();
|
||||
QString octavePath = app->octavePath();
|
||||
if (!octavePath.isEmpty())
|
||||
{
|
||||
// http://www.gnu.org/software/octave/doc/interpreter/Command-Line-Options.html#Command-Line-Options
|
||||
|
||||
// -p path
|
||||
// Add path to the head of the search path for function files. The value of path specified on the command line
|
||||
// will override any value of OCTAVE_PATH found in the environment, but not any commands in the system or
|
||||
// user startup files that set the internal load path through one of the path functions.
|
||||
|
||||
// -q
|
||||
// Don't print the usual greeting and version message at startup.
|
||||
|
||||
|
||||
// TODO: Must rename RimCalcScript::absolutePath to absoluteFileName, as the code below is confusing
|
||||
// absolutePath() is a function in QFileInfo
|
||||
QFileInfo fi(calcScript->absolutePath());
|
||||
QString octaveFunctionSearchPath = fi.absolutePath();
|
||||
|
||||
QStringList arguments;
|
||||
arguments.append("--path");
|
||||
arguments << octaveFunctionSearchPath;
|
||||
|
||||
arguments.append("-q");
|
||||
arguments << calcScript->absolutePath();
|
||||
|
||||
// Get case ID from selected cases in selection model
|
||||
std::vector<int> caseIdsInSelection;
|
||||
{
|
||||
QItemSelectionModel* m = selectionModel();
|
||||
CVF_ASSERT(m);
|
||||
|
||||
caf::PdmObjectGroup group;
|
||||
|
||||
QModelIndexList mil = m->selectedRows();
|
||||
populateObjectGroupFromModelIndexList(mil, &group);
|
||||
|
||||
std::vector<caf::PdmPointer<RimCase> > typedObjects;
|
||||
group.objectsByType(&typedObjects);
|
||||
|
||||
for (size_t i = 0; i < typedObjects.size(); i++)
|
||||
{
|
||||
RimCase* rimReservoir = typedObjects[i];
|
||||
caseIdsInSelection.push_back(rimReservoir->caseId);
|
||||
}
|
||||
}
|
||||
|
||||
if (caseIdsInSelection.size() > 0)
|
||||
{
|
||||
RiaApplication::instance()->launchProcessForMultipleCases(octavePath, arguments, caseIdsInSelection);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -761,11 +901,7 @@ void RimUiTreeView::slotCloseCase()
|
||||
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());
|
||||
}
|
||||
populateObjectGroupFromModelIndexList(mil, &group);
|
||||
|
||||
std::vector<caf::PdmPointer<RimCase> > typedObjects;
|
||||
group.objectsByType(&typedObjects);
|
||||
@@ -904,11 +1040,7 @@ void RimUiTreeView::createPdmObjectsFromClipboard(caf::PdmObjectGroup* objectGro
|
||||
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());
|
||||
}
|
||||
populateObjectGroupFromModelIndexList(indexList, objectGroup);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -1205,7 +1337,7 @@ void RimUiTreeView::storeTreeViewStateToString(QString& treeViewState)
|
||||
/// Find index based of an encode QString <row> <column>;<row> <column>;...;<row> <column>
|
||||
/// Set the decoded index as current index in the QAbstractItemView
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimUiTreeView::applyCurrentIndexFromString(QAbstractItemView& itemView, const QString& currentIndexString)
|
||||
QModelIndex RimUiTreeView::getModelIndexFromString(QAbstractItemModel* model, const QString& currentIndexString)
|
||||
{
|
||||
QStringList modelIndexStringList = currentIndexString.split(";");
|
||||
|
||||
@@ -1220,33 +1352,33 @@ void RimUiTreeView::applyCurrentIndexFromString(QAbstractItemView& itemView, con
|
||||
int row = items[0].toInt();
|
||||
int col = items[1].toInt();
|
||||
|
||||
mi = itemView.model()->index(row, col, mi);
|
||||
mi = model->index(row, col, mi);
|
||||
}
|
||||
|
||||
if (mi.isValid())
|
||||
{
|
||||
itemView.setCurrentIndex(mi);
|
||||
}
|
||||
return mi;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Store path to current index in item view using follwoing encoding into a QString <row> <column>;<row> <column>;...;<row> <column>
|
||||
/// Store path to model index in item view using follwoing encoding into a QString <row> <column>;<row> <column>;...;<row> <column>
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimUiTreeView::storeCurrentIndexToString(const QAbstractItemView& itemView, QString& currentIndexString)
|
||||
void RimUiTreeView::encodeStringFromModelIndex(const QModelIndex mi, QString& encodedModelIndex)
|
||||
{
|
||||
QModelIndex mi = itemView.currentIndex();
|
||||
if (!mi.isValid()) return;
|
||||
|
||||
QString path = QString("%1 %2").arg(mi.row()).arg(mi.column());
|
||||
mi = mi.parent();
|
||||
QModelIndex localModelIdx = mi;
|
||||
|
||||
while (mi.isValid())
|
||||
while (localModelIdx.isValid())
|
||||
{
|
||||
path = QString("%1 %2;").arg(mi.row()).arg(mi.column()) + path;
|
||||
mi = mi.parent();
|
||||
if (encodedModelIndex.isEmpty())
|
||||
{
|
||||
encodedModelIndex = QString("%1 %2").arg(localModelIdx.row()).arg(localModelIdx.column()) + encodedModelIndex;
|
||||
}
|
||||
else
|
||||
{
|
||||
encodedModelIndex = QString("%1 %2;").arg(localModelIdx.row()).arg(localModelIdx.column()) + encodedModelIndex;
|
||||
}
|
||||
localModelIdx = localModelIdx.parent();
|
||||
}
|
||||
|
||||
currentIndexString = path;
|
||||
}
|
||||
|
||||
|
||||
@@ -1441,3 +1573,63 @@ void RimUiTreeView::slotToggleItemsOff()
|
||||
executeSelectionToggleOperation(TOGGLE_OFF);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimUiTreeView::populateObjectGroupFromModelIndexList(const QModelIndexList& modelIndexList, caf::PdmObjectGroup* objectGroup)
|
||||
{
|
||||
CVF_ASSERT(objectGroup);
|
||||
|
||||
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
|
||||
if (!myModel) return;
|
||||
|
||||
for (int i = 0; i < modelIndexList.size(); i++)
|
||||
{
|
||||
caf::PdmUiTreeItem* uiItem = myModel->getTreeItemFromIndex(modelIndexList.at(i));
|
||||
|
||||
if (uiItem && uiItem->dataObject() && uiItem->dataObject().p())
|
||||
{
|
||||
objectGroup->addObject(uiItem->dataObject().p());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimUiTreeView::appendScriptItems(QMenu* menu, RimScriptCollection* scriptCollection)
|
||||
{
|
||||
CVF_ASSERT(menu);
|
||||
|
||||
QDir dir(scriptCollection->directory);
|
||||
QMenu* subMenu = menu->addMenu(dir.dirName());
|
||||
|
||||
for (size_t i = 0; i < scriptCollection->calcScripts.size(); i++)
|
||||
{
|
||||
RimCalcScript* calcScript = scriptCollection->calcScripts[i];
|
||||
QFileInfo fi(calcScript->absolutePath());
|
||||
|
||||
QString menuText = fi.baseName();
|
||||
QAction* scriptAction = subMenu->addAction(menuText, this, SLOT(slotExecuteScriptForSelectedCases()));
|
||||
|
||||
QModelIndex mi;
|
||||
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
|
||||
if (myModel)
|
||||
{
|
||||
mi = myModel->getModelIndexFromPdmObject(calcScript);
|
||||
}
|
||||
|
||||
QString encodedModelIndex;
|
||||
RimUiTreeView::encodeStringFromModelIndex(mi, encodedModelIndex);
|
||||
|
||||
scriptAction->setData(QVariant(encodedModelIndex));
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < scriptCollection->subDirectories.size(); i++)
|
||||
{
|
||||
RimScriptCollection* subDir = scriptCollection->subDirectories[i];
|
||||
|
||||
appendScriptItems(subMenu, subDir);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
class QItemSelection;
|
||||
class RimIdenticalGridCaseGroup;
|
||||
class RimScriptCollection;
|
||||
|
||||
namespace caf {
|
||||
class PdmObjectGroup;
|
||||
@@ -46,8 +47,10 @@ public:
|
||||
void applyTreeViewStateFromString(const QString& treeViewState);
|
||||
void storeTreeViewStateToString(QString& treeViewState);
|
||||
|
||||
static void applyCurrentIndexFromString(QAbstractItemView& itemView, const QString& currentIndexString);
|
||||
static void storeCurrentIndexToString(const QAbstractItemView& itemView, QString& currentIndexString);
|
||||
void populateObjectGroupFromModelIndexList(const QModelIndexList& modelIndexList, caf::PdmObjectGroup* objectGroup);
|
||||
|
||||
static QModelIndex getModelIndexFromString(QAbstractItemModel* model, const QString& currentIndexString);
|
||||
static void encodeStringFromModelIndex(const QModelIndex mi, QString& currentIndexString);
|
||||
|
||||
protected:
|
||||
void contextMenuEvent(QContextMenuEvent* event);
|
||||
@@ -68,6 +71,7 @@ private slots:
|
||||
void slotEditScript();
|
||||
void slotNewScript();
|
||||
void slotExecuteScript();
|
||||
void slotExecuteScriptForSelectedCases();
|
||||
|
||||
void slotAddView();
|
||||
void slotDeleteView();
|
||||
@@ -126,6 +130,8 @@ private:
|
||||
void appendToggleItemActions(QMenu& contextMenu);
|
||||
|
||||
void setExpandedUpToRoot(const QModelIndex& itemIndex);
|
||||
|
||||
void appendScriptItems(QMenu* menu, RimScriptCollection* scriptCollection);
|
||||
private:
|
||||
QAction* m_pasteAction;
|
||||
};
|
||||
|
||||
@@ -16,15 +16,22 @@
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RiaStdInclude.h"
|
||||
//#include "RiaStdInclude.h"
|
||||
#include "RimWell.h"
|
||||
|
||||
|
||||
#include "cafAppEnum.h"
|
||||
#include "cafPdmField.h"
|
||||
#include "RimWell.h"
|
||||
#include "RivReservoirViewPartMgr.h"
|
||||
#include "RimReservoirView.h"
|
||||
|
||||
#include "RimWellCollection.h"
|
||||
#include "cafPdmFieldCvfMat4d.h"
|
||||
#include "cafPdmFieldCvfColor.h"
|
||||
#include "RimResultSlot.h"
|
||||
#include "RimCellEdgeResultSlot.h"
|
||||
#include "Rim3dOverlayInfoConfig.h"
|
||||
#include "RimCellPropertyFilterCollection.h"
|
||||
#include "RimCellRangeFilterCollection.h"
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimWell, "Well");
|
||||
|
||||
|
||||
@@ -16,17 +16,20 @@
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RiaStdInclude.h"
|
||||
|
||||
#include "RimWellCollection.h"
|
||||
|
||||
#include "cafAppEnum.h"
|
||||
#include "cafPdmFieldCvfColor.h"
|
||||
|
||||
#include "RigSingleWellResultsData.h"
|
||||
#include "RimWellCollection.h"
|
||||
#include "RimWell.h"
|
||||
#include "cafPdmFieldCvfMat4d.h"
|
||||
#include "RimReservoirView.h"
|
||||
|
||||
#include "RimResultSlot.h"
|
||||
#include "RimCellRangeFilterCollection.h"
|
||||
#include "RimCellPropertyFilterCollection.h"
|
||||
|
||||
#include "Rim3dOverlayInfoConfig.h"
|
||||
#include "RimCellEdgeResultSlot.h"
|
||||
|
||||
namespace caf
|
||||
{
|
||||
template<>
|
||||
|
||||
@@ -0,0 +1,237 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 "cafAppEnum.h"
|
||||
#include "cafPdmField.h"
|
||||
#include "RimWellPath.h"
|
||||
#include "RimWellPathCollection.h"
|
||||
#include "RimProject.h"
|
||||
#include "RimCase.h"
|
||||
#include "RivWellPathPartMgr.h"
|
||||
#include "RifJsonEncodeDecode.h"
|
||||
#include "RimIdenticalGridCaseGroup.h"
|
||||
#include "RimScriptCollection.h"
|
||||
#include "RimReservoirView.h"
|
||||
#include "RimReservoirCellResultsCacher.h"
|
||||
#include "RimCaseCollection.h"
|
||||
#include "RimResultSlot.h"
|
||||
#include "RimCellEdgeResultSlot.h"
|
||||
#include "RimCellRangeFilterCollection.h"
|
||||
#include "RimCellPropertyFilterCollection.h"
|
||||
#include "RimWellCollection.h"
|
||||
#include "Rim3dOverlayInfoConfig.h"
|
||||
#include "RimOilField.h"
|
||||
#include "RimAnalysisModels.h"
|
||||
#include <fstream>
|
||||
#include <limits>
|
||||
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimWellPath, "WellPath");
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimWellPath::RimWellPath()
|
||||
{
|
||||
CAF_PDM_InitObject("WellPath", ":/Well.png", "", "");
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&name, "WellPathName", "Name", "", "", "");
|
||||
name.setUiReadOnly(true);
|
||||
name.setIOWritable(false);
|
||||
name.setIOReadable(false);
|
||||
name.setUiHidden(true);
|
||||
CAF_PDM_InitFieldNoDefault(&id, "WellPathId", "Id", "", "", "");
|
||||
id.setUiReadOnly(true);
|
||||
id.setIOWritable(false);
|
||||
id.setIOReadable(false);
|
||||
CAF_PDM_InitFieldNoDefault(&sourceSystem, "SourceSystem", "Source System", "", "", "");
|
||||
sourceSystem.setUiReadOnly(true);
|
||||
sourceSystem.setIOWritable(false);
|
||||
sourceSystem.setIOReadable(false);
|
||||
CAF_PDM_InitFieldNoDefault(&utmZone, "UTMZone", "UTM Zone", "", "", "");
|
||||
utmZone.setUiReadOnly(true);
|
||||
utmZone.setIOWritable(false);
|
||||
utmZone.setIOReadable(false);
|
||||
CAF_PDM_InitFieldNoDefault(&updateDate, "WellPathUpdateDate", "Update Date", "", "", "");
|
||||
updateDate.setUiReadOnly(true);
|
||||
updateDate.setIOWritable(false);
|
||||
updateDate.setIOReadable(false);
|
||||
CAF_PDM_InitFieldNoDefault(&updateUser, "WellPathUpdateUser", "Update User", "", "", "");
|
||||
updateUser.setUiReadOnly(true);
|
||||
updateUser.setIOWritable(false);
|
||||
updateUser.setIOReadable(false);
|
||||
CAF_PDM_InitFieldNoDefault(&m_surveyType, "WellPathSurveyType", "Survey Type", "", "", "");
|
||||
m_surveyType.setUiReadOnly(true);
|
||||
m_surveyType.setIOWritable(false);
|
||||
m_surveyType.setIOReadable(false);
|
||||
|
||||
CAF_PDM_InitField(&filepath, "WellPathFilepath", QString(""), "Filepath", "", "", "");
|
||||
filepath.setUiReadOnly(true);
|
||||
CAF_PDM_InitField(&wellPathIndexInFile, "WellPathNumberInFile", -1, "Well Number in file", "", "", "");
|
||||
wellPathIndexInFile.setUiReadOnly(true);
|
||||
|
||||
CAF_PDM_InitField(&showWellPathLabel, "ShowWellPathLabel", true, "Show well path label", "", "", "");
|
||||
|
||||
CAF_PDM_InitField(&showWellPath, "ShowWellPath", true, "Show well path", "", "", "");
|
||||
showWellPath.setUiHidden(true);
|
||||
|
||||
CAF_PDM_InitField(&wellPathRadiusScaleFactor, "WellPathRadiusScale", 1.0, "Well path radius scale", "", "", "");
|
||||
CAF_PDM_InitField(&wellPathColor, "WellPathColor", cvf::Color3f(0.999f, 0.333f, 0.999f), "Well path color", "", "", "");
|
||||
|
||||
m_wellPath = NULL;
|
||||
m_project = NULL;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimWellPath::~RimWellPath()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
caf::PdmFieldHandle* RimWellPath::userDescriptionField()
|
||||
{
|
||||
return &name;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellPath::setSurveyType(QString surveyType)
|
||||
{
|
||||
m_surveyType = surveyType;
|
||||
if (m_surveyType == "PLAN")
|
||||
wellPathColor = cvf::Color3f(0.999f, 0.333f, 0.0f);
|
||||
else if (m_surveyType == "PROTOTYPE")
|
||||
wellPathColor = cvf::Color3f(0.0f, 0.333f, 0.999f);
|
||||
}
|
||||
|
||||
|
||||
RivWellPathPartMgr* RimWellPath::partMgr()
|
||||
{
|
||||
if (m_wellPathPartMgr.isNull())
|
||||
{
|
||||
m_wellPathPartMgr = new RivWellPathPartMgr(m_wellPathCollection, this);
|
||||
}
|
||||
|
||||
return m_wellPathPartMgr.p();
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellPath::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
|
||||
{
|
||||
partMgr()->scheduleGeometryRegen();
|
||||
if (m_project) m_project->createDisplayModelAndRedrawAllViews();
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
caf::PdmFieldHandle* RimWellPath::objectToggleField()
|
||||
{
|
||||
return &showWellPath;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Read JSON file containing well path data
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellPath::readWellPathFile()
|
||||
{
|
||||
QFileInfo fi(filepath());
|
||||
|
||||
if (fi.suffix().compare("json") == 0)
|
||||
{
|
||||
this->readJsonWellPathFile();
|
||||
}
|
||||
else
|
||||
{
|
||||
this->readAsciiWellPathFile();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Read JSON file containing well path data
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellPath::readJsonWellPathFile()
|
||||
{
|
||||
RigWellPath* wellPathGeom = new RigWellPath();
|
||||
JsonReader jsonReader;
|
||||
QMap<QString, QVariant> jsonMap = jsonReader.decodeFile(filepath);
|
||||
|
||||
// General well info
|
||||
|
||||
name = jsonMap["name"].toString();
|
||||
id = jsonMap["id"].toString();
|
||||
sourceSystem = jsonMap["sourceSystem"].toString();
|
||||
utmZone = jsonMap["utmZone"].toString();
|
||||
updateUser = jsonMap["updateUser"].toString();
|
||||
|
||||
setSurveyType(jsonMap["surveyType"].toString());
|
||||
|
||||
// Convert updateDate from the following format:
|
||||
// "Number of milliseconds elapsed since midnight Coordinated Universal Time (UTC)
|
||||
// of January 1, 1970, not counting leap seconds"
|
||||
|
||||
QString updateDateStr = jsonMap["updateDate"].toString().trimmed();
|
||||
uint updateDateUint = updateDateStr.toULongLong() / 1000; // should be within 32 bit, maximum number is 4294967295 which corresponds to year 2106
|
||||
QDateTime updateDateTime;
|
||||
updateDateTime.setTime_t(updateDateUint);
|
||||
|
||||
updateDate = updateDateTime.toString("d MMMM yyyy");
|
||||
|
||||
// Well path points
|
||||
|
||||
double datumElevation = jsonMap["datumElevation"].toDouble();
|
||||
|
||||
QList<QVariant> pathList = jsonMap["path"].toList();
|
||||
foreach (QVariant point, pathList)
|
||||
{
|
||||
QMap<QString, QVariant> coordinateMap = point.toMap();
|
||||
cvf::Vec3d vec3d(coordinateMap["east"].toDouble(), coordinateMap["north"].toDouble(), -(coordinateMap["tvd"].toDouble() - datumElevation));
|
||||
wellPathGeom->m_wellPathPoints.push_back(vec3d);
|
||||
}
|
||||
|
||||
//jsonReader.dumpToFile(wellPathGeom->m_wellPathPoints, "c:\\temp\\jsonpoints.txt");
|
||||
setWellPathGeometry(wellPathGeom);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellPath::readAsciiWellPathFile()
|
||||
{
|
||||
RimWellPathAsciiFileReader::WellData wpData = m_wellPathCollection->asciiFileReader()->readWellData(filepath(), wellPathIndexInFile());
|
||||
this->name = wpData.m_name;
|
||||
|
||||
setWellPathGeometry(wpData.m_wellPathGeometry.p());
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 "cafPdmField.h"
|
||||
#include "cafPdmObject.h"
|
||||
#include "cafPdmPointer.h"
|
||||
#include "cafAppEnum.h"
|
||||
#include "cafPdmFieldCvfColor.h"
|
||||
#include "RigWellPath.h"
|
||||
|
||||
class RimProject;
|
||||
class RivWellPathPartMgr;
|
||||
class RimWellPathCollection;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
///
|
||||
//==================================================================================================
|
||||
class RimWellPath : public caf::PdmObject
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
public:
|
||||
|
||||
RimWellPath();
|
||||
virtual ~RimWellPath();
|
||||
|
||||
void setProject(RimProject* project) { m_project = project; }
|
||||
void setCollection(RimWellPathCollection* collection) { m_wellPathCollection = collection; }
|
||||
|
||||
virtual caf::PdmFieldHandle* userDescriptionField();
|
||||
virtual caf::PdmFieldHandle* objectToggleField();
|
||||
|
||||
virtual void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue );
|
||||
|
||||
caf::PdmField<QString> name;
|
||||
|
||||
caf::PdmField<QString> filepath;
|
||||
caf::PdmField<int> wellPathIndexInFile; // -1 means none.
|
||||
|
||||
caf::PdmField<bool> showWellPathLabel;
|
||||
|
||||
caf::PdmField<bool> showWellPath;
|
||||
caf::PdmField<cvf::Color3f> wellPathColor;
|
||||
caf::PdmField<double> wellPathRadiusScaleFactor;
|
||||
|
||||
RigWellPath* wellPathGeometry() { return m_wellPath.p(); }
|
||||
RivWellPathPartMgr* partMgr();
|
||||
|
||||
void readWellPathFile();
|
||||
|
||||
|
||||
private:
|
||||
|
||||
void setWellPathGeometry(RigWellPath* wellPathModel) { m_wellPath = wellPathModel; }
|
||||
void readJsonWellPathFile();
|
||||
void readAsciiWellPathFile();
|
||||
QString surveyType() { return m_surveyType; }
|
||||
void setSurveyType(QString surveyType);
|
||||
|
||||
|
||||
caf::PdmField<QString> id;
|
||||
caf::PdmField<QString> sourceSystem;
|
||||
caf::PdmField<QString> utmZone;
|
||||
caf::PdmField<QString> updateDate;
|
||||
caf::PdmField<QString> updateUser;
|
||||
|
||||
caf::PdmField<QString> m_surveyType;
|
||||
|
||||
cvf::ref<RigWellPath> m_wellPath;
|
||||
cvf::ref<RivWellPathPartMgr> m_wellPathPartMgr;
|
||||
caf::PdmPointer<RimWellPathCollection> m_wellPathCollection;
|
||||
RimProject* m_project;
|
||||
};
|
||||
@@ -0,0 +1,306 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 "cafAppEnum.h"
|
||||
#include "cafPdmFieldCvfColor.h"
|
||||
|
||||
#include "RimWellPathCollection.h"
|
||||
#include "RimWellPath.h"
|
||||
#include "RivWellPathCollectionPartMgr.h"
|
||||
#include "RimProject.h"
|
||||
#include "RimCase.h"
|
||||
#include "RimIdenticalGridCaseGroup.h"
|
||||
#include "RimScriptCollection.h"
|
||||
#include "RimReservoirView.h"
|
||||
#include "Rim3dOverlayInfoConfig.h"
|
||||
#include "RimReservoirCellResultsCacher.h"
|
||||
#include "RimCaseCollection.h"
|
||||
#include "RimResultSlot.h"
|
||||
#include "RimCellEdgeResultSlot.h"
|
||||
#include "RimCellRangeFilterCollection.h"
|
||||
#include "RimCellPropertyFilterCollection.h"
|
||||
#include "RimWellCollection.h"
|
||||
#include "RimOilField.h"
|
||||
#include "RimAnalysisModels.h"
|
||||
#include <fstream>
|
||||
|
||||
namespace caf
|
||||
{
|
||||
template<>
|
||||
void RimWellPathCollection::WellVisibilityEnum::setUp()
|
||||
{
|
||||
addItem(RimWellPathCollection::FORCE_ALL_OFF, "FORCE_ALL_OFF", "Off");
|
||||
addItem(RimWellPathCollection::ALL_ON, "ALL_ON", "Individual");
|
||||
addItem(RimWellPathCollection::FORCE_ALL_ON, "FORCE_ALL_ON", "On");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimWellPathCollection, "WellPaths");
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimWellPathCollection::RimWellPathCollection()
|
||||
{
|
||||
CAF_PDM_InitObject("Wells", ":/WellCollection.png", "", "");
|
||||
|
||||
CAF_PDM_InitField(&showWellPathLabel, "ShowWellPathLabel", true, "Show well path labels", "", "", "");
|
||||
|
||||
CAF_PDM_InitField(&wellPathVisibility, "GlobalWellPathVisibility", WellVisibilityEnum(ALL_ON), "Global well path visibility", "", "", "");
|
||||
|
||||
CAF_PDM_InitField(&wellPathRadiusScaleFactor, "WellPathRadiusScale", 0.1, "Well Path radius scale", "", "", "");
|
||||
CAF_PDM_InitField(&wellPathCrossSectionVertexCount, "WellPathVertexCount", 12, "Well Path vertex count", "", "", "");
|
||||
wellPathCrossSectionVertexCount.setIOWritable(false);
|
||||
wellPathCrossSectionVertexCount.setIOReadable(false);
|
||||
wellPathCrossSectionVertexCount.setUiHidden(true);
|
||||
CAF_PDM_InitField(&wellPathClip, "WellPathClip", true, "Clip Well Paths", "", "", "");
|
||||
CAF_PDM_InitField(&wellPathClipZDistance, "WellPathClipZDistance", 100, "Well path clipping depth distance", "", "", "");
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&wellPaths, "WellPaths", "Well Paths", "", "", "");
|
||||
|
||||
m_wellPathCollectionPartManager = new RivWellPathCollectionPartMgr(this);
|
||||
m_project = NULL;
|
||||
|
||||
m_asciiFileReader = new RimWellPathAsciiFileReader;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimWellPathCollection::~RimWellPathCollection()
|
||||
{
|
||||
wellPaths.deleteAllChildObjects();
|
||||
delete m_asciiFileReader;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellPathCollection::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
|
||||
{
|
||||
m_wellPathCollectionPartManager->scheduleGeometryRegen();
|
||||
if (m_project) m_project->createDisplayModelAndRedrawAllViews();
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellPathCollection::setProject( RimProject* project )
|
||||
{
|
||||
m_project = project;
|
||||
for (size_t wellPathIdx = 0; wellPathIdx < wellPaths.size(); wellPathIdx++)
|
||||
{
|
||||
wellPaths[wellPathIdx]->setProject(m_project);
|
||||
wellPaths[wellPathIdx]->setCollection(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Read JSON files containing well path data
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellPathCollection::readWellPathFiles()
|
||||
{
|
||||
for (size_t wpIdx = 0; wpIdx < wellPaths.size(); wpIdx++)
|
||||
{
|
||||
wellPaths[wpIdx]->readWellPathFile();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellPathCollection::addWellPaths( QStringList filePaths )
|
||||
{
|
||||
foreach (QString filePath, filePaths)
|
||||
{
|
||||
// Check if this file is already open
|
||||
bool alreadyOpen = false;
|
||||
for (size_t wpIdx = 0; wpIdx < wellPaths.size(); wpIdx++)
|
||||
{
|
||||
QFile f1;
|
||||
f1.setFileName(filePath);
|
||||
QString s1 = f1.fileName();
|
||||
QFile f2;
|
||||
f2.setFileName(wellPaths[wpIdx]->filepath());
|
||||
QString s2 = f2.fileName();
|
||||
if (s1 == s2)
|
||||
{
|
||||
//printf("Attempting to open well path JSON file that is already open:\n %s\n", (const char*) filePath.toLocal8Bit());
|
||||
alreadyOpen = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!alreadyOpen)
|
||||
{
|
||||
QFileInfo fi(filePath);
|
||||
|
||||
if (fi.suffix().compare("json") == 0)
|
||||
{
|
||||
RimWellPath* wellPath = new RimWellPath();
|
||||
wellPath->setProject(m_project);
|
||||
wellPath->setCollection(this);
|
||||
wellPath->filepath = filePath;
|
||||
wellPaths.push_back(wellPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Create Well path objects for all the paths in the assumed ascii file
|
||||
size_t wellPathCount = this->m_asciiFileReader->wellDataCount(filePath);
|
||||
for (size_t i = 0; i < wellPathCount; ++i)
|
||||
{
|
||||
RimWellPath* wellPath = new RimWellPath();
|
||||
wellPath->setProject(m_project);
|
||||
wellPath->setCollection(this);
|
||||
wellPath->filepath = filePath;
|
||||
wellPath->wellPathIndexInFile = static_cast<int>(i);
|
||||
wellPaths.push_back(wellPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
readWellPathFiles();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellPathAsciiFileReader::readAllWellData(QString filePath)
|
||||
{
|
||||
std::map<QString, std::vector<WellData> >::iterator it = m_fileNameToWellDataGroupMap.find(filePath);
|
||||
|
||||
// If we have the file in the map, assume it is already read.
|
||||
if (it != m_fileNameToWellDataGroupMap.end())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Create the data container
|
||||
std::vector<WellData>& fileWellDataArray = m_fileNameToWellDataGroupMap[filePath];
|
||||
|
||||
std::ifstream stream(filePath.toLatin1().data());
|
||||
double x(HUGE_VAL), y(HUGE_VAL), tvd(HUGE_VAL), md(HUGE_VAL);
|
||||
|
||||
while(stream.good())
|
||||
{
|
||||
stream >> x;
|
||||
if (stream.good())
|
||||
{
|
||||
stream >> y >> tvd >> md;
|
||||
if (!stream.good())
|
||||
{
|
||||
// -999 or otherwise to few numbers before some word
|
||||
if (x != -999)
|
||||
{
|
||||
// Error in file: missing numbers at this line
|
||||
|
||||
}
|
||||
stream.clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!fileWellDataArray.size() )
|
||||
{
|
||||
fileWellDataArray.push_back(WellData());
|
||||
fileWellDataArray.back().m_wellPathGeometry = new RigWellPath();
|
||||
}
|
||||
|
||||
cvf::Vec3d wellPoint(x, y, -tvd);
|
||||
fileWellDataArray.back().m_wellPathGeometry->m_wellPathPoints.push_back(wellPoint);
|
||||
|
||||
x = HUGE_VAL;
|
||||
y = HUGE_VAL;
|
||||
tvd = HUGE_VAL;
|
||||
md = HUGE_VAL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Could not read one double.
|
||||
// we assume there is a comment line or a well path description
|
||||
stream.clear();
|
||||
|
||||
std::string line;
|
||||
std::getline(stream, line, '\n');
|
||||
size_t quoteStartIdx = line.find_first_of("'`´’‘");
|
||||
size_t quoteEndIdx = line.find_last_of("'`´’‘");
|
||||
|
||||
if (quoteStartIdx < line.size() -1 )
|
||||
{
|
||||
// Create a new Well data
|
||||
fileWellDataArray.push_back(WellData());
|
||||
fileWellDataArray.back().m_wellPathGeometry = new RigWellPath();
|
||||
|
||||
// Extract the text between the quotes
|
||||
std::string wellName = line.substr(quoteStartIdx + 1, quoteEndIdx - 1 - quoteStartIdx);
|
||||
fileWellDataArray.back().m_name = wellName.c_str();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimWellPathAsciiFileReader::WellData RimWellPathAsciiFileReader::readWellData(QString filePath, int indexInFile)
|
||||
{
|
||||
this->readAllWellData(filePath);
|
||||
|
||||
std::map<QString, std::vector<WellData> >::iterator it = m_fileNameToWellDataGroupMap.find(filePath);
|
||||
|
||||
CVF_ASSERT(it != m_fileNameToWellDataGroupMap.end());
|
||||
|
||||
if (indexInFile < it->second.size())
|
||||
{
|
||||
return it->second[indexInFile];
|
||||
}
|
||||
else
|
||||
{
|
||||
// Error : The ascii well path file does not contain that many wellpaths
|
||||
return WellData();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
size_t RimWellPathAsciiFileReader::wellDataCount(QString filePath)
|
||||
{
|
||||
std::map<QString, std::vector<WellData> >::iterator it = m_fileNameToWellDataGroupMap.find(filePath);
|
||||
|
||||
// If we have the file in the map, assume it is already read.
|
||||
if (it != m_fileNameToWellDataGroupMap.end())
|
||||
{
|
||||
return it->second.size();
|
||||
}
|
||||
|
||||
this->readAllWellData(filePath);
|
||||
it = m_fileNameToWellDataGroupMap.find(filePath);
|
||||
CVF_ASSERT(it != m_fileNameToWellDataGroupMap.end());
|
||||
|
||||
return it->second.size();;
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 "cafPdmField.h"
|
||||
#include "cafPdmObject.h"
|
||||
#include "cafPdmPointer.h"
|
||||
#include "cafAppEnum.h"
|
||||
#include <QString>
|
||||
|
||||
#include "RimWellPath.h"
|
||||
|
||||
class RivWellPathCollectionPartMgr;
|
||||
class RimWellPathAsciiFileReader;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
///
|
||||
//==================================================================================================
|
||||
class RimWellPathCollection : public caf::PdmObject
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
public:
|
||||
|
||||
RimWellPathCollection();
|
||||
virtual ~RimWellPathCollection();
|
||||
|
||||
void setProject(RimProject* project);
|
||||
|
||||
enum WellVisibilityType
|
||||
{
|
||||
FORCE_ALL_OFF,
|
||||
ALL_ON,
|
||||
FORCE_ALL_ON
|
||||
};
|
||||
typedef caf::AppEnum<RimWellPathCollection::WellVisibilityType> WellVisibilityEnum;
|
||||
|
||||
caf::PdmField<bool> showWellPathLabel;
|
||||
|
||||
caf::PdmField<WellVisibilityEnum> wellPathVisibility;
|
||||
caf::PdmField<double> wellPathRadiusScaleFactor;
|
||||
caf::PdmField<int> wellPathCrossSectionVertexCount;
|
||||
caf::PdmField<bool> wellPathClip;
|
||||
caf::PdmField<int> wellPathClipZDistance;
|
||||
|
||||
caf::PdmPointersField<RimWellPath*> wellPaths;
|
||||
|
||||
|
||||
RivWellPathCollectionPartMgr* wellPathCollectionPartMgr() { return m_wellPathCollectionPartManager.p(); }
|
||||
|
||||
void readWellPathFiles();
|
||||
void addWellPaths(QStringList filePaths);
|
||||
RimWellPathAsciiFileReader* asciiFileReader() {return m_asciiFileReader;}
|
||||
|
||||
virtual void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue );
|
||||
|
||||
private:
|
||||
caf::PdmPointer<RimProject> m_project;
|
||||
cvf::ref<RivWellPathCollectionPartMgr> m_wellPathCollectionPartManager;
|
||||
|
||||
RimWellPathAsciiFileReader* m_asciiFileReader;
|
||||
};
|
||||
|
||||
|
||||
class RimWellPathAsciiFileReader
|
||||
{
|
||||
public:
|
||||
struct WellData
|
||||
{
|
||||
QString m_name;
|
||||
cvf::ref<RigWellPath> m_wellPathGeometry;
|
||||
};
|
||||
|
||||
WellData readWellData(QString filePath, int indexInFile);
|
||||
size_t wellDataCount(QString filePath);
|
||||
|
||||
private:
|
||||
|
||||
void readAllWellData(QString filePath);
|
||||
|
||||
std::map<QString, std::vector<WellData> > m_fileNameToWellDataGroupMap;
|
||||
};
|
||||
@@ -17,6 +17,7 @@ ${CEE_CURRENT_LIST_DIR}RigReservoirBuilderMock.h
|
||||
${CEE_CURRENT_LIST_DIR}RigCaseCellResultsData.h
|
||||
${CEE_CURRENT_LIST_DIR}RigSingleWellResultsData.h
|
||||
${CEE_CURRENT_LIST_DIR}RigStatisticsMath.h
|
||||
${CEE_CURRENT_LIST_DIR}RigWellPath.h
|
||||
)
|
||||
|
||||
set (SOURCE_GROUP_SOURCE_FILES
|
||||
@@ -32,6 +33,7 @@ ${CEE_CURRENT_LIST_DIR}RigReservoirBuilderMock.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RigCaseCellResultsData.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RigSingleWellResultsData.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RigStatisticsMath.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RigWellPath.cpp
|
||||
)
|
||||
|
||||
list(APPEND CODE_HEADER_FILES
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RigActiveCellInfo::RigActiveCellInfo()
|
||||
: m_globalActiveCellCount(0),
|
||||
m_globalCellResultCount(0),
|
||||
m_activeCellPositionMin(cvf::Vec3d::ZERO),
|
||||
m_activeCellPositionMax(cvf::Vec3d::ZERO)
|
||||
{
|
||||
@@ -38,6 +39,22 @@ void RigActiveCellInfo::setGlobalCellCount(size_t globalCellCount)
|
||||
m_cellIndexToResultIndex.resize(globalCellCount, cvf::UNDEFINED_SIZE_T);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
size_t RigActiveCellInfo::globalCellCount() const
|
||||
{
|
||||
return m_cellIndexToResultIndex.size();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
size_t RigActiveCellInfo::globalCellResultCount() const
|
||||
{
|
||||
return m_globalCellResultCount;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -71,11 +88,16 @@ size_t RigActiveCellInfo::cellResultIndex(size_t globalCellIndex) const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RigActiveCellInfo::setCellResultIndex(size_t globalCellIndex, size_t globalActiveCellIndex)
|
||||
void RigActiveCellInfo::setCellResultIndex(size_t globalCellIndex, size_t globalCellResultIndex)
|
||||
{
|
||||
CVF_TIGHT_ASSERT(globalActiveCellIndex < m_cellIndexToResultIndex.size());
|
||||
CVF_TIGHT_ASSERT(globalCellResultIndex < m_cellIndexToResultIndex.size());
|
||||
|
||||
m_cellIndexToResultIndex[globalCellIndex] = globalActiveCellIndex;
|
||||
m_cellIndexToResultIndex[globalCellIndex] = globalCellResultIndex;
|
||||
|
||||
if (globalCellResultIndex >= m_globalCellResultCount)
|
||||
{
|
||||
m_globalCellResultCount = globalCellResultIndex + 1;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -33,18 +33,19 @@ public:
|
||||
RigActiveCellInfo();
|
||||
|
||||
void setGlobalCellCount(size_t globalCellCount);
|
||||
size_t globalCellCount() const;
|
||||
size_t globalActiveCellCount() const;
|
||||
size_t globalCellResultCount() const;
|
||||
|
||||
bool isActive(size_t globalCellIndex) const;
|
||||
size_t cellResultIndex(size_t globalCellIndex) const;
|
||||
void setCellResultIndex(size_t globalCellIndex, size_t globalActiveCellIndex);
|
||||
void setCellResultIndex(size_t globalCellIndex, size_t globalResultCellIndex);
|
||||
|
||||
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;
|
||||
|
||||
@@ -71,6 +72,7 @@ private:
|
||||
std::vector<size_t> m_cellIndexToResultIndex;
|
||||
|
||||
size_t m_globalActiveCellCount;
|
||||
size_t m_globalCellResultCount;
|
||||
|
||||
cvf::Vec3st m_activeCellPositionMin;
|
||||
cvf::Vec3st m_activeCellPositionMax;
|
||||
|
||||
@@ -91,7 +91,11 @@ void RigCaseCellResultsData::minMaxCellScalarValues(size_t scalarResultIndex, si
|
||||
max = -HUGE_VAL;
|
||||
|
||||
CVF_ASSERT(scalarResultIndex < resultCount());
|
||||
CVF_ASSERT(timeStepIndex < m_cellScalarResults[scalarResultIndex].size() );
|
||||
|
||||
if (timeStepIndex >= m_cellScalarResults[scalarResultIndex].size())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (scalarResultIndex >= m_maxMinValuesPrTs.size())
|
||||
{
|
||||
@@ -517,6 +521,24 @@ void RigCaseCellResultsData::clearAllResults()
|
||||
m_resultInfos.clear();
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Removes all the actual numbers put into this object, and frees up the memory.
|
||||
/// Does not touch the metadata in any way
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RigCaseCellResultsData::freeAllocatedResultsData()
|
||||
{
|
||||
for (size_t resultIdx = 0; resultIdx < m_cellScalarResults.size(); ++resultIdx)
|
||||
{
|
||||
for (size_t tsIdx = 0; tsIdx < m_cellScalarResults[resultIdx].size(); ++tsIdx)
|
||||
{
|
||||
// Using swap with an empty vector as that is the safest way to really get rid of the allocated data in a vector
|
||||
std::vector<double> empty;
|
||||
m_cellScalarResults[resultIdx][tsIdx].swap(empty);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Add a result with given type and name, and allocate one result vector for the static result values
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -572,3 +594,99 @@ void RigCaseCellResultsData::setMustBeCalculated(size_t scalarResultIndex)
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RigCaseCellResultsData::posNegClosestToZero(size_t scalarResultIndex, double& pos, double& neg)
|
||||
{
|
||||
pos = HUGE_VAL;
|
||||
neg = -HUGE_VAL;
|
||||
|
||||
CVF_ASSERT(scalarResultIndex < resultCount());
|
||||
|
||||
// Extend array and cache vars
|
||||
|
||||
if (scalarResultIndex >= m_posNegClosestToZero.size() )
|
||||
{
|
||||
m_posNegClosestToZero.resize(scalarResultIndex+1, std::make_pair(HUGE_VAL, -HUGE_VAL));
|
||||
}
|
||||
|
||||
if (m_posNegClosestToZero[scalarResultIndex].first != HUGE_VAL)
|
||||
{
|
||||
pos = m_posNegClosestToZero[scalarResultIndex].first;
|
||||
neg = m_posNegClosestToZero[scalarResultIndex].second;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
size_t i;
|
||||
for (i = 0; i < timeStepCount(scalarResultIndex); i++)
|
||||
{
|
||||
double tsNeg, tsPos;
|
||||
posNegClosestToZero(scalarResultIndex, i, tsPos, tsNeg);
|
||||
if (tsNeg > neg && tsNeg < 0) neg = tsNeg;
|
||||
if (tsPos < pos && tsPos > 0) pos = tsPos;
|
||||
}
|
||||
|
||||
m_posNegClosestToZero[scalarResultIndex].first = pos;
|
||||
m_posNegClosestToZero[scalarResultIndex].second= neg;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RigCaseCellResultsData::posNegClosestToZero(size_t scalarResultIndex, size_t timeStepIndex, double& pos, double& neg)
|
||||
{
|
||||
pos = HUGE_VAL;
|
||||
neg = -HUGE_VAL;
|
||||
|
||||
CVF_ASSERT(scalarResultIndex < resultCount());
|
||||
|
||||
if (timeStepIndex >= m_cellScalarResults[scalarResultIndex].size())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (scalarResultIndex >= m_posNegClosestToZeroPrTs.size())
|
||||
{
|
||||
m_posNegClosestToZeroPrTs.resize(scalarResultIndex+1);
|
||||
}
|
||||
|
||||
if (timeStepIndex >= m_posNegClosestToZeroPrTs[scalarResultIndex].size())
|
||||
{
|
||||
m_posNegClosestToZeroPrTs[scalarResultIndex].resize(timeStepIndex+1, std::make_pair(HUGE_VAL, -HUGE_VAL));
|
||||
}
|
||||
|
||||
if (m_posNegClosestToZeroPrTs[scalarResultIndex][timeStepIndex].first != HUGE_VAL)
|
||||
{
|
||||
pos = m_posNegClosestToZeroPrTs[scalarResultIndex][timeStepIndex].first;
|
||||
neg = m_posNegClosestToZeroPrTs[scalarResultIndex][timeStepIndex].second;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<double>& values = m_cellScalarResults[scalarResultIndex][timeStepIndex];
|
||||
|
||||
size_t i;
|
||||
for (i = 0; i < values.size(); i++)
|
||||
{
|
||||
if (values[i] == HUGE_VAL)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (values[i] < pos && values[i] > 0)
|
||||
{
|
||||
pos = values[i];
|
||||
}
|
||||
|
||||
if (values[i] > neg && values[i] < 0)
|
||||
{
|
||||
neg = values[i];
|
||||
}
|
||||
}
|
||||
|
||||
m_posNegClosestToZeroPrTs[scalarResultIndex][timeStepIndex].first = pos;
|
||||
m_posNegClosestToZeroPrTs[scalarResultIndex][timeStepIndex].second= neg;
|
||||
}
|
||||
|
||||
@@ -41,6 +41,8 @@ public:
|
||||
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);
|
||||
void posNegClosestToZero(size_t scalarResultIndex, double& pos, double& neg);
|
||||
void posNegClosestToZero(size_t scalarResultIndex, size_t timeStepIndex, double& pos, double& neg);
|
||||
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);
|
||||
@@ -66,6 +68,7 @@ public:
|
||||
|
||||
void removeResult(const QString& resultName);
|
||||
void clearAllResults();
|
||||
void freeAllocatedResultsData();
|
||||
|
||||
// Access the results data
|
||||
|
||||
@@ -107,11 +110,13 @@ public:
|
||||
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::pair<double, double> > m_posNegClosestToZero;
|
||||
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
|
||||
std::vector< std::vector< std::pair<double, double> > > m_posNegClosestToZeroPrTs;
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -178,10 +178,11 @@ void RigCaseData::computeWellCellsPrGrid()
|
||||
gridIndex = wellSegment.m_wellCells[cdIdx].m_gridIndex;
|
||||
gridCellIndex = wellSegment.m_wellCells[cdIdx].m_gridCellIndex;
|
||||
|
||||
CVF_ASSERT(gridIndex < m_wellCellsInGrid.size() && gridCellIndex < m_wellCellsInGrid[gridIndex]->size());
|
||||
|
||||
m_wellCellsInGrid[gridIndex]->set(gridCellIndex, true);
|
||||
m_gridCellToWellIndex[gridIndex]->set(gridCellIndex, static_cast<cvf::uint>(wIdx));
|
||||
if(gridIndex < m_wellCellsInGrid.size() && gridCellIndex < m_wellCellsInGrid[gridIndex]->size())
|
||||
{
|
||||
m_wellCellsInGrid[gridIndex]->set(gridCellIndex, true);
|
||||
m_gridCellToWellIndex[gridIndex]->set(gridCellIndex, static_cast<cvf::uint>(wIdx));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ RigCell::RigCell() :
|
||||
m_hostGrid(NULL),
|
||||
m_isInvalid(false),
|
||||
m_cellIndex(cvf::UNDEFINED_SIZE_T),
|
||||
m_isInCoarseCell(false)
|
||||
m_coarseningBoxIndex(cvf::UNDEFINED_SIZE_T)
|
||||
{
|
||||
memcpy(m_cornerIndices.m_array, undefinedCornersArray, 8*sizeof(size_t));
|
||||
|
||||
|
||||
@@ -54,8 +54,8 @@ public:
|
||||
size_t mainGridCellIndex() const { return m_mainGridCellIndex; }
|
||||
void setMainGridCellIndex(size_t mainGridCellContainingThisCell) { m_mainGridCellIndex = mainGridCellContainingThisCell; }
|
||||
|
||||
bool isInCoarseCell() const { return m_isInCoarseCell; }
|
||||
void setInCoarseCell(bool isInCoarseCell) { m_isInCoarseCell = isInCoarseCell; }
|
||||
size_t coarseningBoxIndex() const { return m_coarseningBoxIndex; }
|
||||
void setCoarseningBoxIndex(size_t coarseningBoxIndex) { m_coarseningBoxIndex = coarseningBoxIndex; }
|
||||
|
||||
void setCellFaceFault(cvf::StructGridInterface::FaceType face) { m_cellFaceFaults[face] = true; }
|
||||
bool isCellFaceFault(cvf::StructGridInterface::FaceType face) const { return m_cellFaceFaults[face]; }
|
||||
@@ -71,9 +71,10 @@ private:
|
||||
RigGridBase* m_hostGrid;
|
||||
RigLocalGrid* m_subGrid;
|
||||
|
||||
size_t m_parentCellIndex; ///< Grid cell index of the cell in the parent grid containing this cell
|
||||
size_t m_parentCellIndex; ///< Grid cell index of the cell in the parent grid containing this cell
|
||||
size_t m_mainGridCellIndex;
|
||||
bool m_isInCoarseCell;
|
||||
|
||||
size_t m_coarseningBoxIndex; ///< If defined, index into list of coarsening boxes in RigGridBase
|
||||
|
||||
bool m_cellFaceFaults[6];
|
||||
|
||||
|
||||
@@ -457,6 +457,83 @@ size_t RigGridBase::globalGridCellIndex(size_t localGridCellIndex) const
|
||||
return m_indexToStartOfCells + localGridCellIndex;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
size_t RigGridBase::addCoarseningBox(size_t i1, size_t i2, size_t j1, size_t j2, size_t k1, size_t k2)
|
||||
{
|
||||
caf::SizeTArray6 box;
|
||||
box[0] = i1;
|
||||
box[1] = i2;
|
||||
box[2] = j1;
|
||||
box[3] = j2;
|
||||
box[4] = k1;
|
||||
box[5] = k2;
|
||||
|
||||
m_coarseningBoxInfo.push_back(box);
|
||||
|
||||
size_t coarseningBoxIndex = m_coarseningBoxInfo.size() - 1;
|
||||
|
||||
for (size_t k = k1; k <= k2; k++)
|
||||
{
|
||||
for (size_t j = j1; j <= j2; j++)
|
||||
{
|
||||
for (size_t i = i1; i <= i2; i++)
|
||||
{
|
||||
size_t cellIdx = this->cellIndexFromIJK(i, j, k);
|
||||
|
||||
RigCell& c = this->cell(cellIdx);
|
||||
CVF_ASSERT(c.coarseningBoxIndex() == cvf::UNDEFINED_SIZE_T);
|
||||
|
||||
c.setCoarseningBoxIndex(coarseningBoxIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return coarseningBoxIndex;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RigGridBase::coarseningBox(size_t coarseningBoxIndex, size_t* i1, size_t* i2, size_t* j1, size_t* j2, size_t* k1, size_t* k2) const
|
||||
{
|
||||
CVF_ASSERT(coarseningBoxIndex < m_coarseningBoxInfo.size());
|
||||
|
||||
CVF_ASSERT(i1 && i2 && j1 && j2 && k1 && k2);
|
||||
|
||||
caf::SizeTArray6 box = m_coarseningBoxInfo[coarseningBoxIndex];
|
||||
*i1 = box[0];
|
||||
*i2 = box[1];
|
||||
*j1 = box[2];
|
||||
*j2 = box[3];
|
||||
*k1 = box[4];
|
||||
*k2 = box[5];
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::BoundingBox RigGridBase::boundingBox()
|
||||
{
|
||||
if (!m_boundingBox.isValid())
|
||||
{
|
||||
cvf::Vec3d cornerVerts[8];
|
||||
|
||||
for (size_t i = 0; i < cellCount(); i++)
|
||||
{
|
||||
cellCornerVertices(i, cornerVerts);
|
||||
|
||||
for (size_t j = 0; j < 8; j++)
|
||||
{
|
||||
m_boundingBox.add(cornerVerts[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return m_boundingBox;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "cvfBase.h"
|
||||
|
||||
#include "cvfVector3.h"
|
||||
#include "cvfBoundingBox.h"
|
||||
|
||||
#include "cvfStructGrid.h"
|
||||
#include "cvfStructGridGeometryGenerator.h"
|
||||
@@ -29,6 +30,7 @@
|
||||
#include <string>
|
||||
#include "cvfStructGridScalarDataAccess.h"
|
||||
#include "RifReaderInterface.h"
|
||||
#include "cafFixedArray.h"
|
||||
|
||||
|
||||
class RigMainGrid;
|
||||
@@ -63,6 +65,13 @@ public:
|
||||
void computeFaults();
|
||||
bool isMainGrid() const;
|
||||
RigMainGrid* mainGrid() const { return m_mainGrid; }
|
||||
|
||||
size_t coarseningBoxCount() const { return m_coarseningBoxInfo.size(); }
|
||||
size_t addCoarseningBox(size_t i1, size_t i2, size_t j1, size_t j2, size_t k1, size_t k2);
|
||||
|
||||
void coarseningBox(size_t coarseningBoxIndex, size_t* i1, size_t* i2, size_t* j1, size_t* j2, size_t* k1, size_t* k2) const;
|
||||
|
||||
cvf::BoundingBox boundingBox();
|
||||
|
||||
protected:
|
||||
friend class RigMainGrid;//::initAllSubGridsParentGridPointer();
|
||||
@@ -100,7 +109,9 @@ private:
|
||||
size_t m_indexToStartOfCells; ///< Index into the global cell array stored in main-grid where this grids cells starts.
|
||||
size_t m_gridIndex; ///< The LGR index of this grid. Starts with 1. Main grid has index 0.
|
||||
RigMainGrid* m_mainGrid;
|
||||
cvf::BoundingBox m_boundingBox;
|
||||
|
||||
std::vector<caf::SizeTArray6> m_coarseningBoxInfo;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -92,13 +92,13 @@ public:
|
||||
m_reservoirResultValues(reservoirResultValues),
|
||||
m_activeCellInfo(activeCellInfo)
|
||||
{
|
||||
CVF_ASSERT(reservoirResultValues != NULL);
|
||||
|
||||
CVF_ASSERT(grid != NULL);
|
||||
}
|
||||
|
||||
virtual double cellScalar(size_t gridLocalCellIndex) const
|
||||
{
|
||||
if (m_reservoirResultValues->size() == 0 ) return HUGE_VAL;
|
||||
if (m_reservoirResultValues == NULL || m_reservoirResultValues->size() == 0 ) return HUGE_VAL;
|
||||
|
||||
size_t globalGridCellIndex = m_grid->globalGridCellIndex(gridLocalCellIndex);
|
||||
size_t resultValueIndex = m_activeCellInfo->cellResultIndex(globalGridCellIndex);
|
||||
@@ -117,7 +117,7 @@ public:
|
||||
size_t globalGridCellIndex = m_grid->globalGridCellIndex(gridLocalCellIndex);
|
||||
size_t resultValueIndex = m_activeCellInfo->cellResultIndex(globalGridCellIndex);
|
||||
|
||||
CVF_TIGHT_ASSERT(resultValueIndex < m_reservoirResultValues->size());
|
||||
CVF_TIGHT_ASSERT(m_reservoirResultValues != NULL && resultValueIndex < m_reservoirResultValues->size());
|
||||
|
||||
(*m_reservoirResultValues)[resultValueIndex] = scalarValue;
|
||||
}
|
||||
@@ -151,12 +151,12 @@ cvf::ref<cvf::StructGridScalarDataAccess> RigGridScalarDataAccessFactory::create
|
||||
}
|
||||
|
||||
std::vector< std::vector<double> >& scalarSetResults = eclipseCase->results(porosityModel)->cellScalarResults(scalarSetIndex);
|
||||
if (timeStepIndex >= scalarSetResults.size())
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
std::vector<double>* resultValues = &(scalarSetResults[timeStepIndex]);
|
||||
std::vector<double>* resultValues = NULL;
|
||||
if (timeStepIndex < scalarSetResults.size())
|
||||
{
|
||||
resultValues = &(scalarSetResults[timeStepIndex]);
|
||||
}
|
||||
|
||||
bool useGlobalActiveIndex = eclipseCase->results(porosityModel)->isUsingGlobalActiveIndex(scalarSetIndex);
|
||||
if (useGlobalActiveIndex)
|
||||
|
||||
@@ -47,8 +47,6 @@ public:
|
||||
|
||||
void computeCachedData();
|
||||
|
||||
cvf::BoundingBox matrixModelActiveCellsBoundingBox() const;
|
||||
|
||||
// Overrides
|
||||
virtual cvf::Vec3d displayModelOffset() const;
|
||||
void setDisplayModelOffset(cvf::Vec3d offset);
|
||||
|
||||
@@ -254,6 +254,19 @@ void RigReservoirBuilderMock::populateReservoir(RigCaseData* eclipseCase)
|
||||
{
|
||||
activeCellInfo->setCellResultIndex(i, i);
|
||||
}
|
||||
|
||||
activeCellInfo->setGridCount(1);
|
||||
activeCellInfo->setGridActiveCellCounts(0, eclipseCase->mainGrid()->cells().size());
|
||||
activeCellInfo->computeDerivedData();
|
||||
|
||||
// Add grid coarsening for main grid
|
||||
if (cellDimension().x() > 4 &&
|
||||
cellDimension().y() > 5 &&
|
||||
cellDimension().z() > 6)
|
||||
{
|
||||
eclipseCase->mainGrid()->addCoarseningBox(1, 2, 1, 3, 1, 4);
|
||||
eclipseCase->mainGrid()->addCoarseningBox(3, 4, 4, 5, 5, 6);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,187 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 "RigWellPath.h"
|
||||
#include <map>
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
// void RigWellPath::computeStaticWellCellPath()
|
||||
// {
|
||||
// if (m_wellCellsTimeSteps.size() == 0) return;
|
||||
//
|
||||
// std::map < size_t, std::list< RigWellResultCell > > staticWellBranches;
|
||||
//
|
||||
// // Add ResultCell data from the first timestep to the final result.
|
||||
//
|
||||
// for (size_t bIdx = 0; bIdx < m_wellCellsTimeSteps[0].m_wellResultBranches.size(); ++bIdx)
|
||||
// {
|
||||
// size_t branchNumber = m_wellCellsTimeSteps[0].m_wellResultBranches[bIdx].m_branchNumber;
|
||||
// std::vector<RigWellResultCell>& frameCells = m_wellCellsTimeSteps[0].m_wellResultBranches[bIdx].m_wellCells;
|
||||
//
|
||||
// std::list< RigWellResultCell >& branch = staticWellBranches[branchNumber];
|
||||
//
|
||||
// for(size_t cIdx = 0; cIdx < frameCells.size(); ++cIdx)
|
||||
// {
|
||||
// branch.push_back(frameCells[cIdx]);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//
|
||||
//
|
||||
// for (size_t tIdx = 1; tIdx < m_wellCellsTimeSteps.size(); ++tIdx)
|
||||
// {
|
||||
// // Merge well branches separately
|
||||
//
|
||||
// for (size_t bIdx = 0; bIdx < m_wellCellsTimeSteps[tIdx].m_wellResultBranches.size(); ++bIdx)
|
||||
// {
|
||||
// size_t branchNumber = m_wellCellsTimeSteps[tIdx].m_wellResultBranches[bIdx].m_branchNumber;
|
||||
// std::vector<RigWellResultCell>& resBranch = m_wellCellsTimeSteps[tIdx].m_wellResultBranches[bIdx].m_wellCells;
|
||||
//
|
||||
// std::list< RigWellResultCell >& stBranch = staticWellBranches[branchNumber];
|
||||
// std::list< RigWellResultCell >::iterator it;
|
||||
// std::list< RigWellResultCell >::iterator sStartIt;
|
||||
// std::list< RigWellResultCell >::iterator sEndIt;
|
||||
// size_t rStartIdx;
|
||||
// size_t rEndIdx;
|
||||
//
|
||||
//
|
||||
// size_t sGridIdx;
|
||||
// size_t sCellIdx;
|
||||
// size_t rGridIdx;
|
||||
// size_t rCellIdx;
|
||||
//
|
||||
// // First detect if we have cells on the start of the result frame, that is not in the static frame
|
||||
// {
|
||||
// sEndIt = stBranch.begin();
|
||||
// bool found = false;
|
||||
// if (stBranch.size())
|
||||
// {
|
||||
// sGridIdx = sEndIt->m_gridIndex;
|
||||
// sCellIdx = sEndIt->m_gridCellIndex;
|
||||
//
|
||||
// for (rEndIdx = 0; !found && rEndIdx < resBranch.size(); ++rEndIdx)
|
||||
// {
|
||||
// rGridIdx = resBranch[rEndIdx].m_gridIndex;
|
||||
// rCellIdx = resBranch[rEndIdx].m_gridCellIndex;
|
||||
//
|
||||
// if (sGridIdx == rGridIdx && sCellIdx == rCellIdx) { found = true; break; }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (found)
|
||||
// {
|
||||
// if (rEndIdx > 0)
|
||||
// {
|
||||
// // Found cells in start, merge them in
|
||||
// for (size_t cIdx = 0; cIdx < rEndIdx; ++cIdx)
|
||||
// {
|
||||
// stBranch.insert(sEndIt, resBranch[cIdx]);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// // The result probably starts later in the well
|
||||
// rEndIdx = 0;
|
||||
// }
|
||||
//
|
||||
// sStartIt = sEndIt;
|
||||
// rStartIdx = rEndIdx;
|
||||
// }
|
||||
//
|
||||
// // Now find all result cells in ranges between pairs in the static path
|
||||
// // If the result has items that "compete" with those in the static path,
|
||||
// // those items are inserted after the ones in the static path. This
|
||||
// // is not neccesarily correct. They could be in front, and also merged in
|
||||
// // strange ways. A geometric test could make this more robust, but we will
|
||||
// // not solve before we see that it actually ends up as a problem
|
||||
//
|
||||
// if (sEndIt != stBranch.end()) ++sEndIt;
|
||||
// for ( ; sEndIt != stBranch.end() ; ++sEndIt)
|
||||
// {
|
||||
// sGridIdx = sEndIt->m_gridIndex;
|
||||
// sCellIdx = sEndIt->m_gridCellIndex;
|
||||
//
|
||||
// bool found = false;
|
||||
// for (rEndIdx += 1; !found && rEndIdx < resBranch.size(); ++rEndIdx)
|
||||
// {
|
||||
// rGridIdx = resBranch[rEndIdx].m_gridIndex;
|
||||
// rCellIdx = resBranch[rEndIdx].m_gridCellIndex;
|
||||
//
|
||||
// if (sGridIdx == rGridIdx && sCellIdx == rCellIdx) { found = true; break; }
|
||||
// }
|
||||
//
|
||||
// if (found)
|
||||
// {
|
||||
// if (rEndIdx - rStartIdx > 1)
|
||||
// {
|
||||
// // Found cell range in result that we do not have in the static result, merge them in
|
||||
// for (size_t cIdx = rStartIdx + 1; cIdx < rEndIdx; ++cIdx)
|
||||
// {
|
||||
// stBranch.insert(sEndIt, resBranch[cIdx]);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// // The static path probably has some extra cells
|
||||
// rEndIdx = rStartIdx;
|
||||
// }
|
||||
//
|
||||
// sStartIt = sEndIt;
|
||||
// rStartIdx = rEndIdx;
|
||||
// }
|
||||
//
|
||||
// // Then add cells from the end of the resultpath not present in the static path
|
||||
// for (size_t cIdx = rEndIdx + 1; cIdx < resBranch.size(); ++cIdx)
|
||||
// {
|
||||
// stBranch.push_back(resBranch[cIdx]);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // Populate the static well info
|
||||
//
|
||||
// std::map < size_t, std::list< RigWellResultCell > >::iterator bIt;
|
||||
//
|
||||
// m_staticWellCells.m_wellResultBranches.clear();
|
||||
// m_staticWellCells.m_wellHead = m_wellCellsTimeSteps[0].m_wellHead;
|
||||
//
|
||||
// for (bIt = staticWellBranches.begin(); bIt != staticWellBranches.end(); ++bIt)
|
||||
// {
|
||||
// RigWellResultBranch rigBranch;
|
||||
// rigBranch.m_branchNumber = bIt->first;
|
||||
//
|
||||
// std::list< RigWellResultCell >& branch = bIt->second;
|
||||
// std::list< RigWellResultCell >::iterator cIt;
|
||||
//
|
||||
// for (cIt = branch.begin(); cIt != branch.end(); ++cIt)
|
||||
// {
|
||||
// RigWellResultCell rwc = *cIt;
|
||||
// rwc.m_isOpen = false; // Reset the dynamic property
|
||||
// rigBranch.m_wellCells.push_back(*cIt);
|
||||
// }
|
||||
//
|
||||
// m_staticWellCells.m_wellResultBranches.push_back(rigBranch);
|
||||
// }
|
||||
// }
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 "cvfMath.h"
|
||||
#include "cvfVector3.h"
|
||||
|
||||
#include "RimDefines.h"
|
||||
#include <QDateTime>
|
||||
#include <vector>
|
||||
|
||||
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RigWellPath : public cvf::Object
|
||||
{
|
||||
public:
|
||||
std::vector<cvf::Vec3d> m_wellPathPoints;
|
||||
};
|
||||
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 9.4 KiB |
|
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 3.3 KiB |
|
After Width: | Height: | Size: 2.8 KiB |
|
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.5 KiB |
|
After Width: | Height: | Size: 320 B |
@@ -38,6 +38,8 @@
|
||||
<file>SnapShotSave.png</file>
|
||||
<file>SnapShotSaveViews.png</file>
|
||||
<file>draw_style_faults_24x24.png</file>
|
||||
<file>Case48x48.png</file>
|
||||
<file>GridModels.png</file>
|
||||
</qresource>
|
||||
<qresource prefix="/Shader/">
|
||||
<file>fs_CellFace.glsl</file>
|
||||
|
||||
@@ -0,0 +1,550 @@
|
||||
//
|
||||
// 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 "RiaSocketCommand.h"
|
||||
#include "RiaSocketServer.h"
|
||||
#include "RiaSocketTools.h"
|
||||
|
||||
#include "RimReservoirView.h"
|
||||
#include "RimResultSlot.h"
|
||||
#include "RimCellEdgeResultSlot.h"
|
||||
#include "RimCellRangeFilterCollection.h"
|
||||
#include "RimCellPropertyFilterCollection.h"
|
||||
#include "RimWellCollection.h"
|
||||
#include "Rim3dOverlayInfoConfig.h"
|
||||
#include "RimReservoirCellResultsCacher.h"
|
||||
|
||||
#include "RimCase.h"
|
||||
#include "RigCaseData.h"
|
||||
#include "RigCaseCellResultsData.h"
|
||||
|
||||
#include <QTcpSocket>
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// OBSOLETE, to be deleted
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
class RiaGetMainGridDimensions: public RiaSocketCommand
|
||||
{
|
||||
public:
|
||||
static QString commandName () { return QString("GetMainGridDimensions"); }
|
||||
|
||||
virtual bool interpretCommand(RiaSocketServer* server, const QList<QByteArray>& args, QDataStream& socketStream)
|
||||
{
|
||||
|
||||
RimCase* rimCase = RiaSocketTools::findCaseFromArgs(server, args);
|
||||
if (!rimCase) return true;
|
||||
|
||||
// Write data back to octave: I, J, K dimensions
|
||||
|
||||
size_t iCount = 0;
|
||||
size_t jCount = 0;
|
||||
size_t kCount = 0;
|
||||
|
||||
if (rimCase && rimCase->reservoirData() && rimCase->reservoirData()->mainGrid())
|
||||
{
|
||||
iCount = rimCase->reservoirData()->mainGrid()->cellCountI();
|
||||
jCount = rimCase->reservoirData()->mainGrid()->cellCountJ();
|
||||
kCount = rimCase->reservoirData()->mainGrid()->cellCountK();
|
||||
}
|
||||
|
||||
socketStream << (quint64)iCount << (quint64)jCount << (quint64)kCount;
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
static bool RiaGetMainGridDimensions_init = RiaSocketCommandFactory::instance()->registerCreator<RiaGetMainGridDimensions>(RiaGetMainGridDimensions::commandName());
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
class RiaGetActiveCellInfo: public RiaSocketCommand
|
||||
{
|
||||
public:
|
||||
static QString commandName () { return QString("GetActiveCellInfo"); }
|
||||
|
||||
virtual bool interpretCommand(RiaSocketServer* server, const QList<QByteArray>& args, QDataStream& socketStream)
|
||||
{
|
||||
RimCase* rimCase = RiaSocketTools::findCaseFromArgs(server, args);
|
||||
if (!rimCase) return true;
|
||||
|
||||
RifReaderInterface::PorosityModelResultType porosityModel = RifReaderInterface::MATRIX_RESULTS;
|
||||
|
||||
if (args.size() > 2)
|
||||
{
|
||||
QString prorosityModelString = args[2];
|
||||
if (prorosityModelString.toUpper() == "FRACTURE")
|
||||
{
|
||||
porosityModel = RifReaderInterface::FRACTURE_RESULTS;
|
||||
}
|
||||
}
|
||||
|
||||
// Write data back to octave: columnCount, bytesPrTimestep, GridNr I J K ParentGridNr PI PJ PK CoarseBoxIdx
|
||||
|
||||
caf::FixedArray<std::vector<qint32>, 9> activeCellInfo;
|
||||
if (!(rimCase && rimCase->reservoirData() && rimCase->reservoirData()->mainGrid()) )
|
||||
{
|
||||
// No data available
|
||||
socketStream << (quint64)0 << (quint64)0 ;
|
||||
return true;
|
||||
}
|
||||
|
||||
calculateMatrixModelActiveCellInfo(rimCase, porosityModel,
|
||||
activeCellInfo[0],
|
||||
activeCellInfo[1],
|
||||
activeCellInfo[2],
|
||||
activeCellInfo[3],
|
||||
activeCellInfo[4],
|
||||
activeCellInfo[5],
|
||||
activeCellInfo[6],
|
||||
activeCellInfo[7],
|
||||
activeCellInfo[8]);
|
||||
|
||||
// First write column count
|
||||
quint64 columnCount = (quint64)9;
|
||||
socketStream << columnCount;
|
||||
|
||||
// then the byte-size of the size of one column
|
||||
size_t timestepResultCount = activeCellInfo[0].size();
|
||||
quint64 timestepByteCount = (quint64)(timestepResultCount*sizeof(qint32));
|
||||
socketStream << timestepByteCount;
|
||||
|
||||
// Then write the data.
|
||||
|
||||
for (size_t tIdx = 0; tIdx < columnCount; ++tIdx)
|
||||
{
|
||||
#if 1 // Write data as raw bytes, fast but does not handle byteswapping
|
||||
server->currentClient()->write((const char *)activeCellInfo[tIdx].data(), timestepByteCount);
|
||||
#else // Write data using QDataStream, does byteswapping for us. Must use QDataStream on client as well
|
||||
for (size_t cIdx = 0; cIdx < activeCellInfo[tIdx].size(); ++cIdx)
|
||||
{
|
||||
socketStream << activeCellInfo[tIdx][cIdx];
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static void calculateMatrixModelActiveCellInfo(RimCase* reservoirCase, RifReaderInterface::PorosityModelResultType porosityModel, std::vector<qint32>& gridNumber, std::vector<qint32>& cellI, std::vector<qint32>& cellJ, std::vector<qint32>& cellK, std::vector<qint32>& parentGridNumber, std::vector<qint32>& hostCellI, std::vector<qint32>& hostCellJ, std::vector<qint32>& hostCellK, std::vector<qint32>& globalCoarseningBoxIdx)
|
||||
{
|
||||
gridNumber.clear();
|
||||
cellI.clear();
|
||||
cellJ.clear();
|
||||
cellK.clear();
|
||||
parentGridNumber.clear();
|
||||
hostCellI.clear();
|
||||
hostCellJ.clear();
|
||||
hostCellK.clear();
|
||||
globalCoarseningBoxIdx.clear();
|
||||
|
||||
if (!reservoirCase || !reservoirCase->reservoirData() || !reservoirCase->reservoirData()->mainGrid())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
RigActiveCellInfo* actCellInfo = reservoirCase->reservoirData()->activeCellInfo(porosityModel);
|
||||
size_t numMatrixModelActiveCells = actCellInfo->globalActiveCellCount();
|
||||
|
||||
gridNumber.reserve(numMatrixModelActiveCells);
|
||||
cellI.reserve(numMatrixModelActiveCells);
|
||||
cellJ.reserve(numMatrixModelActiveCells);
|
||||
cellK.reserve(numMatrixModelActiveCells);
|
||||
parentGridNumber.reserve(numMatrixModelActiveCells);
|
||||
hostCellI.reserve(numMatrixModelActiveCells);
|
||||
hostCellJ.reserve(numMatrixModelActiveCells);
|
||||
hostCellK.reserve(numMatrixModelActiveCells);
|
||||
globalCoarseningBoxIdx.reserve(numMatrixModelActiveCells);
|
||||
|
||||
const std::vector<RigCell>& globalCells = reservoirCase->reservoirData()->mainGrid()->cells();
|
||||
|
||||
|
||||
std::vector<size_t> globalCoarseningBoxIndexStart;
|
||||
{
|
||||
size_t globalCoarseningBoxCount = 0;
|
||||
|
||||
for (size_t gridIdx = 0; gridIdx < reservoirCase->reservoirData()->gridCount(); gridIdx++)
|
||||
{
|
||||
globalCoarseningBoxIndexStart.push_back(globalCoarseningBoxCount);
|
||||
|
||||
RigGridBase* grid = reservoirCase->reservoirData()->grid(gridIdx);
|
||||
|
||||
size_t localCoarseningBoxCount = grid->coarseningBoxCount();
|
||||
globalCoarseningBoxCount += localCoarseningBoxCount;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
for (size_t cIdx = 0; cIdx < globalCells.size(); ++cIdx)
|
||||
{
|
||||
if (actCellInfo->isActive(cIdx))
|
||||
{
|
||||
RigGridBase* grid = globalCells[cIdx].hostGrid();
|
||||
CVF_ASSERT(grid != NULL);
|
||||
size_t cellIndex = globalCells[cIdx].cellIndex();
|
||||
|
||||
size_t i, j, k;
|
||||
grid->ijkFromCellIndex(cellIndex, &i, &j, &k);
|
||||
|
||||
size_t pi, pj, pk;
|
||||
RigGridBase* parentGrid = NULL;
|
||||
|
||||
if (grid->isMainGrid())
|
||||
{
|
||||
pi = i;
|
||||
pj = j;
|
||||
pk = k;
|
||||
parentGrid = grid;
|
||||
}
|
||||
else
|
||||
{
|
||||
size_t parentCellIdx = globalCells[cIdx].parentCellIndex();
|
||||
parentGrid = (static_cast<RigLocalGrid*>(grid))->parentGrid();
|
||||
CVF_ASSERT(parentGrid != NULL);
|
||||
parentGrid->ijkFromCellIndex(parentCellIdx, &pi, &pj, &pk);
|
||||
}
|
||||
|
||||
gridNumber.push_back(static_cast<qint32>(grid->gridIndex()));
|
||||
cellI.push_back(static_cast<qint32>(i + 1)); // NB: 1-based index in Octave
|
||||
cellJ.push_back(static_cast<qint32>(j + 1)); // NB: 1-based index in Octave
|
||||
cellK.push_back(static_cast<qint32>(k + 1)); // NB: 1-based index in Octave
|
||||
|
||||
parentGridNumber.push_back(static_cast<qint32>(parentGrid->gridIndex()));
|
||||
hostCellI.push_back(static_cast<qint32>(pi + 1)); // NB: 1-based index in Octave
|
||||
hostCellJ.push_back(static_cast<qint32>(pj + 1)); // NB: 1-based index in Octave
|
||||
hostCellK.push_back(static_cast<qint32>(pk + 1)); // NB: 1-based index in Octave
|
||||
|
||||
size_t coarseningIdx = globalCells[cIdx].coarseningBoxIndex();
|
||||
if (coarseningIdx != cvf::UNDEFINED_SIZE_T)
|
||||
{
|
||||
size_t globalCoarseningIdx = globalCoarseningBoxIndexStart[grid->gridIndex()] + coarseningIdx;
|
||||
|
||||
globalCoarseningBoxIdx.push_back(static_cast<qint32>(globalCoarseningIdx + 1)); // NB: 1-based index in Octave
|
||||
}
|
||||
else
|
||||
{
|
||||
globalCoarseningBoxIdx.push_back(-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
static bool RiaGetActiveCellInfo_init = RiaSocketCommandFactory::instance()->registerCreator<RiaGetActiveCellInfo>(RiaGetActiveCellInfo::commandName());
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
class RiaGetCoarseningInfo : public RiaSocketCommand
|
||||
{
|
||||
public:
|
||||
static QString commandName () { return QString("GetCoarseningInfo"); }
|
||||
|
||||
virtual bool interpretCommand(RiaSocketServer* server, const QList<QByteArray>& args, QDataStream& socketStream)
|
||||
{
|
||||
int argCaseGroupId = -1;
|
||||
|
||||
if (args.size() == 2)
|
||||
{
|
||||
argCaseGroupId = args[1].toInt();
|
||||
}
|
||||
|
||||
RimCase* rimCase = server->findReservoir(argCaseGroupId);
|
||||
if (!rimCase || !rimCase->reservoirData() || !rimCase->reservoirData()->mainGrid())
|
||||
{
|
||||
quint64 byteCount = 0;
|
||||
|
||||
socketStream << byteCount;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Write data back to octave: I1, I2, J1, J2, K1, K2 for all coarsening boxes
|
||||
|
||||
if (rimCase && rimCase->reservoirData() && rimCase->reservoirData()->mainGrid())
|
||||
{
|
||||
size_t globalCoarseningBoxCount = 0;
|
||||
|
||||
for (size_t gridIdx = 0; gridIdx < rimCase->reservoirData()->gridCount(); gridIdx++)
|
||||
{
|
||||
RigGridBase* grid = rimCase->reservoirData()->grid(gridIdx);
|
||||
|
||||
size_t localCoarseningBoxCount = grid->coarseningBoxCount();
|
||||
globalCoarseningBoxCount += localCoarseningBoxCount;
|
||||
}
|
||||
|
||||
quint64 byteCount = globalCoarseningBoxCount * 6 * sizeof(qint32);
|
||||
socketStream << byteCount;
|
||||
|
||||
for (size_t gridIdx = 0; gridIdx < rimCase->reservoirData()->gridCount(); gridIdx++)
|
||||
{
|
||||
RigGridBase* grid = rimCase->reservoirData()->grid(gridIdx);
|
||||
|
||||
size_t localCoarseningBoxCount = grid->coarseningBoxCount();
|
||||
for (size_t boxIdx = 0; boxIdx < localCoarseningBoxCount; boxIdx++)
|
||||
{
|
||||
size_t i1, i2, j1, j2, k1, k2;
|
||||
grid->coarseningBox(boxIdx, &i1, &i2, &j1, &j2, &k1, &k2);
|
||||
|
||||
// Write 1-based coordinates for coarsening box
|
||||
socketStream << static_cast<qint32>(i1 + 1);
|
||||
socketStream << static_cast<qint32>(i2 + 1);
|
||||
socketStream << static_cast<qint32>(j1 + 1);
|
||||
socketStream << static_cast<qint32>(j2 + 1);
|
||||
socketStream << static_cast<qint32>(k1 + 1);
|
||||
socketStream << static_cast<qint32>(k2 + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
static bool RiaGetCoarseningInfo_init = RiaSocketCommandFactory::instance()->registerCreator<RiaGetCoarseningInfo>(RiaGetCoarseningInfo::commandName());
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
class RiaGetGridDimensions : public RiaSocketCommand
|
||||
{
|
||||
public:
|
||||
static QString commandName () { return QString("GetGridDimensions"); }
|
||||
|
||||
virtual bool interpretCommand(RiaSocketServer* server, const QList<QByteArray>& args, QDataStream& socketStream)
|
||||
{
|
||||
int argCaseGroupId = -1;
|
||||
|
||||
if (args.size() == 2)
|
||||
{
|
||||
argCaseGroupId = args[1].toInt();
|
||||
}
|
||||
|
||||
RimCase* rimCase = server->findReservoir(argCaseGroupId);
|
||||
if (!rimCase || !rimCase->reservoirData() || !rimCase->reservoirData()->mainGrid())
|
||||
{
|
||||
quint64 byteCount = 0;
|
||||
|
||||
socketStream << byteCount;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Write data back to octave: I, J, K dimensions
|
||||
|
||||
|
||||
if (rimCase && rimCase->reservoirData() && rimCase->reservoirData()->mainGrid())
|
||||
{
|
||||
std::vector<RigGridBase*> grids;
|
||||
rimCase->reservoirData()->allGrids(&grids);
|
||||
|
||||
quint64 byteCount = grids.size() * 3 * sizeof(quint64);
|
||||
socketStream << byteCount;
|
||||
|
||||
for (size_t i = 0; i < grids.size(); i++)
|
||||
{
|
||||
size_t iCount = 0;
|
||||
size_t jCount = 0;
|
||||
size_t kCount = 0;
|
||||
|
||||
iCount = grids[i]->cellCountI();
|
||||
jCount = grids[i]->cellCountJ();
|
||||
kCount = grids[i]->cellCountK();
|
||||
|
||||
socketStream << (quint64)iCount << (quint64)jCount << (quint64)kCount;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
static bool RiaGetGridDimensions_init = RiaSocketCommandFactory::instance()->registerCreator<RiaGetGridDimensions>(RiaGetGridDimensions::commandName());
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
class RiaGetTimeStepDates : public RiaSocketCommand
|
||||
{
|
||||
public:
|
||||
static QString commandName () { return QString("GetTimeStepDates"); }
|
||||
virtual bool interpretCommand(RiaSocketServer* server, const QList<QByteArray>& args, QDataStream& socketStream)
|
||||
{
|
||||
int argCaseGroupId = -1;
|
||||
|
||||
if (args.size() == 2)
|
||||
{
|
||||
argCaseGroupId = args[1].toInt();
|
||||
}
|
||||
|
||||
RimCase* rimCase = server->findReservoir(argCaseGroupId);
|
||||
|
||||
bool canFetchData = true;
|
||||
|
||||
if (!rimCase || !rimCase->reservoirData())
|
||||
{
|
||||
canFetchData = false;
|
||||
}
|
||||
|
||||
size_t scalarIndexWithMaxTimeStepCount = cvf::UNDEFINED_SIZE_T;
|
||||
if (rimCase && rimCase->reservoirData())
|
||||
{
|
||||
rimCase->reservoirData()->results(RifReaderInterface::MATRIX_RESULTS)->maxTimeStepCount(&scalarIndexWithMaxTimeStepCount);
|
||||
if (scalarIndexWithMaxTimeStepCount == cvf::UNDEFINED_SIZE_T)
|
||||
{
|
||||
canFetchData = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Did not find any result to fetch data from, return zero data found
|
||||
if (!canFetchData)
|
||||
{
|
||||
quint64 timeStepCount = 0;
|
||||
quint64 byteCount = sizeof(quint64);
|
||||
|
||||
socketStream << byteCount;
|
||||
socketStream << timeStepCount;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
std::vector<QDateTime> timeStepDates = rimCase->reservoirData()->results(RifReaderInterface::MATRIX_RESULTS)->timeStepDates(scalarIndexWithMaxTimeStepCount);
|
||||
|
||||
quint64 timeStepCount = timeStepDates.size();
|
||||
quint64 byteCount = sizeof(quint64) + 6 * timeStepCount * sizeof(qint32);
|
||||
|
||||
socketStream << byteCount;
|
||||
socketStream << timeStepCount;
|
||||
|
||||
for (size_t i = 0; i < timeStepCount; i++)
|
||||
{
|
||||
qint32 intValue = 0;
|
||||
|
||||
intValue = timeStepDates[i].date().year();
|
||||
socketStream << intValue;
|
||||
|
||||
intValue = timeStepDates[i].date().month();
|
||||
socketStream << intValue;
|
||||
|
||||
intValue = timeStepDates[i].date().day();
|
||||
socketStream << intValue;
|
||||
|
||||
intValue = timeStepDates[i].time().hour();
|
||||
socketStream << intValue;
|
||||
|
||||
intValue = timeStepDates[i].time().minute();
|
||||
socketStream << intValue;
|
||||
|
||||
intValue = timeStepDates[i].time().second();
|
||||
socketStream << intValue;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
static bool RiaGetTimeStepDates_init = RiaSocketCommandFactory::instance()->registerCreator<RiaGetTimeStepDates>(RiaGetTimeStepDates::commandName());
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
class RiaGetTimeStepDays : public RiaSocketCommand
|
||||
{
|
||||
public:
|
||||
static QString commandName () { return QString("GetTimeStepDays"); }
|
||||
virtual bool interpretCommand(RiaSocketServer* server, const QList<QByteArray>& args, QDataStream& socketStream)
|
||||
{
|
||||
int argCaseGroupId = -1;
|
||||
|
||||
if (args.size() == 2)
|
||||
{
|
||||
argCaseGroupId = args[1].toInt();
|
||||
}
|
||||
|
||||
RimCase* rimCase = server->findReservoir(argCaseGroupId);
|
||||
|
||||
bool canFetchData = true;
|
||||
|
||||
if (!rimCase || !rimCase->reservoirData())
|
||||
{
|
||||
canFetchData = false;
|
||||
}
|
||||
|
||||
size_t scalarIndexWithMaxTimeStepCount = cvf::UNDEFINED_SIZE_T;
|
||||
if (rimCase && rimCase->reservoirData())
|
||||
{
|
||||
rimCase->reservoirData()->results(RifReaderInterface::MATRIX_RESULTS)->maxTimeStepCount(&scalarIndexWithMaxTimeStepCount);
|
||||
if (scalarIndexWithMaxTimeStepCount == cvf::UNDEFINED_SIZE_T)
|
||||
{
|
||||
canFetchData = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Did not find any result to fetch data from, return zero data found
|
||||
if (!canFetchData)
|
||||
{
|
||||
quint64 timeStepCount = 0;
|
||||
quint64 byteCount = sizeof(quint64);
|
||||
|
||||
socketStream << byteCount;
|
||||
socketStream << timeStepCount;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
std::vector<QDateTime> timeStepDates = rimCase->reservoirData()->results(RifReaderInterface::MATRIX_RESULTS)->timeStepDates(scalarIndexWithMaxTimeStepCount);
|
||||
|
||||
quint64 timeStepCount = timeStepDates.size();
|
||||
quint64 byteCount = sizeof(quint64) + timeStepCount * sizeof(qint32);
|
||||
|
||||
socketStream << byteCount;
|
||||
socketStream << timeStepCount;
|
||||
|
||||
if (timeStepCount > 0)
|
||||
{
|
||||
double secondsInADay = 24 * 60 * 60;
|
||||
|
||||
for (size_t i = 0; i < timeStepCount; i++)
|
||||
{
|
||||
double secondsDiff = timeStepDates[0].secsTo(timeStepDates[i]);
|
||||
|
||||
double decimalDaysDiff = secondsDiff / secondsInADay;
|
||||
|
||||
socketStream << decimalDaysDiff;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
static bool RiaGetTimeStepDays_init = RiaSocketCommandFactory::instance()->registerCreator<RiaGetTimeStepDays>(RiaGetTimeStepDays::commandName());
|
||||
|
||||
@@ -0,0 +1,432 @@
|
||||
//
|
||||
// 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 "RiaSocketCommand.h"
|
||||
#include "RiaSocketServer.h"
|
||||
|
||||
#include "RimReservoirView.h"
|
||||
#include "RimResultSlot.h"
|
||||
#include "RimCellEdgeResultSlot.h"
|
||||
#include "RimCellRangeFilterCollection.h"
|
||||
#include "RimCellPropertyFilterCollection.h"
|
||||
#include "RimWellCollection.h"
|
||||
#include "Rim3dOverlayInfoConfig.h"
|
||||
#include "RimReservoirCellResultsCacher.h"
|
||||
|
||||
#include "RimCase.h"
|
||||
#include "RigCaseData.h"
|
||||
#include "RigCaseCellResultsData.h"
|
||||
|
||||
#include <QTcpSocket>
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
class RiaGetCellCenters : public RiaSocketCommand
|
||||
{
|
||||
public:
|
||||
static QString commandName () { return QString("GetCellCenters"); }
|
||||
|
||||
virtual bool interpretCommand(RiaSocketServer* server, const QList<QByteArray>& args, QDataStream& socketStream)
|
||||
{
|
||||
int argCaseGroupId = -1;
|
||||
size_t argGridIndex = 0;
|
||||
|
||||
if (args.size() == 2)
|
||||
{
|
||||
argGridIndex = args[1].toInt();
|
||||
}
|
||||
else if (args.size() == 3)
|
||||
{
|
||||
argCaseGroupId = args[1].toInt();
|
||||
argGridIndex = args[2].toUInt();
|
||||
}
|
||||
|
||||
RimCase* rimCase = server->findReservoir(argCaseGroupId);
|
||||
if (!rimCase || !rimCase->reservoirData() || (argGridIndex >= rimCase->reservoirData()->gridCount()) )
|
||||
{
|
||||
// No data available
|
||||
socketStream << (quint64)0 << (quint64)0 << (quint64)0 << (quint64)0 << (quint64)0;
|
||||
return true;
|
||||
}
|
||||
|
||||
RigGridBase* rigGrid = rimCase->reservoirData()->grid(argGridIndex);
|
||||
|
||||
quint64 cellCount = (quint64)rigGrid->cellCount();
|
||||
quint64 cellCountI = (quint64)rigGrid->cellCountI();
|
||||
quint64 cellCountJ = (quint64)rigGrid->cellCountJ();
|
||||
quint64 cellCountK = (quint64)rigGrid->cellCountK();
|
||||
|
||||
socketStream << cellCount;
|
||||
socketStream << cellCountI;
|
||||
socketStream << cellCountJ;
|
||||
socketStream << cellCountK;
|
||||
|
||||
size_t doubleValueCount = cellCount * 3;
|
||||
quint64 byteCount = doubleValueCount * sizeof(double);
|
||||
socketStream << byteCount;
|
||||
|
||||
// This structure is supposed to be received by Octave using a NDArray. The ordering of this loop is
|
||||
// defined by the ordering of the receiving NDArray
|
||||
//
|
||||
// See riGetCellCenters
|
||||
//
|
||||
// dim_vector dv;
|
||||
// dv.resize(4);
|
||||
// dv(0) = cellCountI;
|
||||
// dv(1) = cellCountJ;
|
||||
// dv(2) = cellCountK;
|
||||
// dv(3) = 3;
|
||||
|
||||
std::vector<double> cellCenterValues(doubleValueCount);
|
||||
cvf::Vec3d cornerVerts[8];
|
||||
quint64 coordCount = 0;
|
||||
for (int coordIdx = 0; coordIdx < 3; coordIdx++)
|
||||
{
|
||||
for (size_t k = 0; k < cellCountK; k++)
|
||||
{
|
||||
for (size_t j = 0; j < cellCountJ; j++)
|
||||
{
|
||||
for (size_t i = 0; i < cellCountI; i++)
|
||||
{
|
||||
size_t localCellIdx = rigGrid->cellIndexFromIJK(i, j, k);
|
||||
cvf::Vec3d center = rigGrid->cell(localCellIdx).center();
|
||||
|
||||
cellCenterValues[coordCount++] = center[coordIdx];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CVF_ASSERT(coordCount == doubleValueCount);
|
||||
|
||||
server->currentClient()->write((const char *)cellCenterValues.data(), byteCount);
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
static bool RiaGetCellCenters_init = RiaSocketCommandFactory::instance()->registerCreator<RiaGetCellCenters>(RiaGetCellCenters::commandName());
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
class RiaGetActiveCellCenters : public RiaSocketCommand
|
||||
{
|
||||
public:
|
||||
static QString commandName () { return QString("GetActiveCellCenters"); }
|
||||
|
||||
virtual bool interpretCommand(RiaSocketServer* server, const QList<QByteArray>& args, QDataStream& socketStream)
|
||||
{
|
||||
int argCaseGroupId = -1;
|
||||
QString porosityModelName;
|
||||
|
||||
if (args.size() == 2)
|
||||
{
|
||||
bool numberConversionOk = false;
|
||||
int tmpValue = args[1].toInt(&numberConversionOk);
|
||||
if (numberConversionOk)
|
||||
{
|
||||
argCaseGroupId = tmpValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
porosityModelName = args[1];
|
||||
}
|
||||
}
|
||||
else if (args.size() == 3)
|
||||
{
|
||||
bool numberConversionOk = false;
|
||||
int tmpValue = args[1].toInt(&numberConversionOk);
|
||||
if (numberConversionOk)
|
||||
{
|
||||
argCaseGroupId = args[1].toUInt();
|
||||
porosityModelName = args[2];
|
||||
}
|
||||
else
|
||||
{
|
||||
argCaseGroupId = args[2].toUInt();
|
||||
porosityModelName = args[1];
|
||||
}
|
||||
}
|
||||
|
||||
RifReaderInterface::PorosityModelResultType porosityModelEnum = RifReaderInterface::MATRIX_RESULTS;
|
||||
if (porosityModelName.toUpper() == "FRACTURE")
|
||||
{
|
||||
porosityModelEnum = RifReaderInterface::FRACTURE_RESULTS;
|
||||
}
|
||||
|
||||
RimCase* rimCase = server->findReservoir(argCaseGroupId);
|
||||
if (!rimCase || !rimCase->reservoirData())
|
||||
{
|
||||
// No data available
|
||||
socketStream << (quint64)0 << (quint64)0 ;
|
||||
return true;
|
||||
}
|
||||
|
||||
RigActiveCellInfo* actCellInfo = rimCase->reservoirData()->activeCellInfo(porosityModelEnum);
|
||||
RigMainGrid* mainGrid = rimCase->reservoirData()->mainGrid();
|
||||
|
||||
size_t activeCellCount = actCellInfo->globalActiveCellCount();
|
||||
size_t doubleValueCount = activeCellCount * 3;
|
||||
|
||||
// This structure is supposed to be received by Octave using a NDArray. The ordering of this loop is
|
||||
// defined by the ordering of the receiving NDArray
|
||||
//
|
||||
// See riGetActiveCellCenters
|
||||
//
|
||||
// dim_vector dv;
|
||||
// dv.resize(2);
|
||||
// dv(0) = coordCount;
|
||||
// dv(1) = 3;
|
||||
|
||||
std::vector<double> cellCenterValues(doubleValueCount);
|
||||
quint64 coordCount = 0;
|
||||
for (int coordIdx = 0; coordIdx < 3; coordIdx++)
|
||||
{
|
||||
for (size_t globalCellIdx = 0; globalCellIdx < mainGrid->cells().size(); globalCellIdx++)
|
||||
{
|
||||
if (!actCellInfo->isActive(globalCellIdx)) continue;
|
||||
|
||||
cvf::Vec3d center = mainGrid->cells()[globalCellIdx].center();
|
||||
|
||||
cellCenterValues[coordCount++] = center[coordIdx];
|
||||
}
|
||||
}
|
||||
|
||||
CVF_ASSERT(coordCount == doubleValueCount);
|
||||
|
||||
socketStream << (quint64)activeCellCount;
|
||||
quint64 byteCount = doubleValueCount * sizeof(double);
|
||||
socketStream << byteCount;
|
||||
|
||||
server->currentClient()->write((const char *)cellCenterValues.data(), byteCount);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
static bool RiaGetActiveCellCenters_init = RiaSocketCommandFactory::instance()->registerCreator<RiaGetActiveCellCenters>(RiaGetActiveCellCenters::commandName());
|
||||
|
||||
|
||||
// NB: Match this mapping with the mapping in RifReaderEclipseOutput.cpp
|
||||
static const size_t cellCornerMappingEclipse[8] = { 0, 1, 3, 2, 4, 5, 7, 6 };
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
class RiaGetCellCorners : public RiaSocketCommand
|
||||
{
|
||||
public:
|
||||
static QString commandName () { return QString("GetCellCorners"); }
|
||||
|
||||
virtual bool interpretCommand(RiaSocketServer* server, const QList<QByteArray>& args, QDataStream& socketStream)
|
||||
{
|
||||
int argCaseGroupId = -1;
|
||||
size_t argGridIndex = 0;
|
||||
|
||||
if (args.size() == 2)
|
||||
{
|
||||
argGridIndex = args[1].toInt();
|
||||
}
|
||||
else if (args.size() == 3)
|
||||
{
|
||||
argCaseGroupId = args[1].toInt();
|
||||
argGridIndex = args[2].toUInt();
|
||||
}
|
||||
|
||||
RimCase* rimCase = server->findReservoir(argCaseGroupId);
|
||||
if (!rimCase || !rimCase->reservoirData() || (argGridIndex >= rimCase->reservoirData()->gridCount()) )
|
||||
{
|
||||
// No data available
|
||||
socketStream << (quint64)0 << (quint64)0 << (quint64)0 << (quint64)0 << (quint64)0;
|
||||
return true;
|
||||
}
|
||||
|
||||
RigGridBase* rigGrid = rimCase->reservoirData()->grid(argGridIndex);
|
||||
|
||||
quint64 cellCount = (quint64)rigGrid->cellCount();
|
||||
quint64 cellCountI = (quint64)rigGrid->cellCountI();
|
||||
quint64 cellCountJ = (quint64)rigGrid->cellCountJ();
|
||||
quint64 cellCountK = (quint64)rigGrid->cellCountK();
|
||||
|
||||
size_t doubleValueCount = cellCount * 3 * 8;
|
||||
quint64 byteCount = doubleValueCount * sizeof(double);
|
||||
|
||||
socketStream << cellCount;
|
||||
socketStream << cellCountI;
|
||||
socketStream << cellCountJ;
|
||||
socketStream << cellCountK;
|
||||
socketStream << byteCount;
|
||||
|
||||
// This structure is supposed to be received by Octave using a NDArray. The ordering of this loop is
|
||||
// defined by the ordering of the receiving NDArray
|
||||
//
|
||||
// See riGetCellCorners
|
||||
//
|
||||
// dim_vector dv;
|
||||
// dv.resize(5);
|
||||
// dv(0) = cellCountI;
|
||||
// dv(1) = cellCountJ;
|
||||
// dv(2) = cellCountK;
|
||||
// dv(3) = 8;
|
||||
// dv(4) = 3;
|
||||
|
||||
std::vector<double> cellCornerValues(doubleValueCount);
|
||||
cvf::Vec3d cornerVerts[8];
|
||||
quint64 coordCount = 0;
|
||||
for (int coordIdx = 0; coordIdx < 3; coordIdx++)
|
||||
{
|
||||
for (size_t cornerIdx = 0; cornerIdx < 8; cornerIdx++)
|
||||
{
|
||||
size_t cornerIndexMapping = cellCornerMappingEclipse[cornerIdx];
|
||||
|
||||
for (size_t k = 0; k < cellCountK; k++)
|
||||
{
|
||||
for (size_t j = 0; j < cellCountJ; j++)
|
||||
{
|
||||
for (size_t i = 0; i < cellCountI; i++)
|
||||
{
|
||||
size_t localCellIdx = rigGrid->cellIndexFromIJK(i, j, k);
|
||||
rigGrid->cellCornerVertices(localCellIdx, cornerVerts);
|
||||
|
||||
cellCornerValues[coordCount++] = cornerVerts[cornerIndexMapping][coordIdx];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
server->currentClient()->write((const char *)cellCornerValues.data(), byteCount);
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
static bool RiaGetCellCorners_init = RiaSocketCommandFactory::instance()->registerCreator<RiaGetCellCorners>(RiaGetCellCorners::commandName());
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
class RiaGetActiveCellCorners : public RiaSocketCommand
|
||||
{
|
||||
public:
|
||||
static QString commandName () { return QString("GetActiveCellCorners"); }
|
||||
|
||||
virtual bool interpretCommand(RiaSocketServer* server, const QList<QByteArray>& args, QDataStream& socketStream)
|
||||
{
|
||||
int argCaseGroupId = -1;
|
||||
QString porosityModelName;
|
||||
|
||||
if (args.size() == 2)
|
||||
{
|
||||
bool numberConversionOk = false;
|
||||
int tmpValue = args[1].toInt(&numberConversionOk);
|
||||
if (numberConversionOk)
|
||||
{
|
||||
argCaseGroupId = tmpValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
porosityModelName = args[1];
|
||||
}
|
||||
}
|
||||
else if (args.size() == 3)
|
||||
{
|
||||
bool numberConversionOk = false;
|
||||
int tmpValue = args[1].toInt(&numberConversionOk);
|
||||
if (numberConversionOk)
|
||||
{
|
||||
argCaseGroupId = args[1].toUInt();
|
||||
porosityModelName = args[2];
|
||||
}
|
||||
else
|
||||
{
|
||||
argCaseGroupId = args[2].toUInt();
|
||||
porosityModelName = args[1];
|
||||
}
|
||||
}
|
||||
|
||||
RifReaderInterface::PorosityModelResultType porosityModelEnum = RifReaderInterface::MATRIX_RESULTS;
|
||||
if (porosityModelName.toUpper() == "FRACTURE")
|
||||
{
|
||||
porosityModelEnum = RifReaderInterface::FRACTURE_RESULTS;
|
||||
}
|
||||
|
||||
RimCase* rimCase = server->findReservoir(argCaseGroupId);
|
||||
if (!rimCase || !rimCase->reservoirData() )
|
||||
{
|
||||
// No data available
|
||||
socketStream << (quint64)0 << (quint64)0 ;
|
||||
return true;
|
||||
}
|
||||
|
||||
RigActiveCellInfo* actCellInfo = rimCase->reservoirData()->activeCellInfo(porosityModelEnum);
|
||||
RigMainGrid* mainGrid = rimCase->reservoirData()->mainGrid();
|
||||
|
||||
size_t activeCellCount = actCellInfo->globalActiveCellCount();
|
||||
size_t doubleValueCount = activeCellCount * 3 * 8;
|
||||
|
||||
// This structure is supposed to be received by Octave using a NDArray. The ordering of this loop is
|
||||
// defined by the ordering of the receiving NDArray
|
||||
//
|
||||
// See riGetCellCorners
|
||||
//
|
||||
// dim_vector dv;
|
||||
// dv.resize(3);
|
||||
// dv(0) = coordCount;
|
||||
// dv(1) = 8;
|
||||
// dv(2) = 3;
|
||||
|
||||
std::vector<double> cellCornerValues(doubleValueCount);
|
||||
cvf::Vec3d cornerVerts[8];
|
||||
quint64 coordCount = 0;
|
||||
for (int coordIdx = 0; coordIdx < 3; coordIdx++)
|
||||
{
|
||||
for (size_t cornerIdx = 0; cornerIdx < 8; cornerIdx++)
|
||||
{
|
||||
size_t cornerIndexMapping = cellCornerMappingEclipse[cornerIdx];
|
||||
|
||||
for (size_t globalCellIdx = 0; globalCellIdx < mainGrid->cells().size(); globalCellIdx++)
|
||||
{
|
||||
if (!actCellInfo->isActive(globalCellIdx)) continue;
|
||||
|
||||
mainGrid->cellCornerVertices(globalCellIdx, cornerVerts);
|
||||
|
||||
cellCornerValues[coordCount++] = cornerVerts[cornerIndexMapping][coordIdx];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
socketStream << (quint64)activeCellCount;
|
||||
quint64 byteCount = doubleValueCount * sizeof(double);
|
||||
socketStream << byteCount;
|
||||
|
||||
server->currentClient()->write((const char *)cellCornerValues.data(), byteCount);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
static bool RiaGetActiveCellCorners_init = RiaSocketCommandFactory::instance()->registerCreator<RiaGetActiveCellCorners>(RiaGetActiveCellCorners::commandName());
|
||||
@@ -0,0 +1,309 @@
|
||||
//
|
||||
// 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 "RiaSocketCommand.h"
|
||||
#include "RiaSocketServer.h"
|
||||
#include "RiaSocketTools.h"
|
||||
|
||||
#include "RimReservoirView.h"
|
||||
#include "RimResultSlot.h"
|
||||
#include "RimCellEdgeResultSlot.h"
|
||||
#include "RimCellRangeFilterCollection.h"
|
||||
#include "RimCellPropertyFilterCollection.h"
|
||||
#include "RimWellCollection.h"
|
||||
#include "Rim3dOverlayInfoConfig.h"
|
||||
#include "RimReservoirCellResultsCacher.h"
|
||||
|
||||
#include "RimCase.h"
|
||||
#include "RigCaseData.h"
|
||||
#include "RigCaseCellResultsData.h"
|
||||
#include "RiuMainWindow.h"
|
||||
#include "RiaApplication.h"
|
||||
#include "RimProject.h"
|
||||
#include "RimIdenticalGridCaseGroup.h"
|
||||
#include "RimCaseCollection.h"
|
||||
#include "RimScriptCollection.h"
|
||||
#include "RimWellPathCollection.h"
|
||||
#include "RimOilField.h"
|
||||
#include "RimAnalysisModels.h"
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void getCaseInfoFromCases(std::vector<RimCase*>& cases, std::vector<qint64>& caseIds, std::vector<QString>& caseNames, std::vector<QString> &caseTypes, std::vector<qint64>& caseGroupIds)
|
||||
{
|
||||
for (size_t i = 0; i < cases.size(); i++)
|
||||
{
|
||||
RimCase* rimCase = cases[i];
|
||||
|
||||
qint64 caseId = -1;
|
||||
QString caseName;
|
||||
QString caseType;
|
||||
qint64 caseGroupId = -1;
|
||||
RiaSocketTools::getCaseInfoFromCase(rimCase, caseId, caseName, caseType, caseGroupId);
|
||||
|
||||
caseIds.push_back(rimCase->caseId);
|
||||
caseNames.push_back(rimCase->caseUserDescription);
|
||||
caseTypes.push_back(caseType);
|
||||
caseGroupIds.push_back(caseGroupId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
class RiaGetCurrentCase : public RiaSocketCommand
|
||||
{
|
||||
public:
|
||||
static QString commandName () { return QString("GetCurrentCase"); }
|
||||
virtual bool interpretCommand(RiaSocketServer* server, const QList<QByteArray>& args, QDataStream& socketStream)
|
||||
{
|
||||
qint64 caseId = server->currentCaseId();
|
||||
QString caseName;
|
||||
QString caseType;
|
||||
qint64 caseGroupId = -1;
|
||||
|
||||
RimCase* rimCase = server->findReservoir(caseId);
|
||||
|
||||
if (rimCase)
|
||||
{
|
||||
RiaSocketTools::getCaseInfoFromCase(rimCase, caseId, caseName, caseType, caseGroupId);
|
||||
}
|
||||
|
||||
quint64 byteCount = 2*sizeof(qint64);
|
||||
byteCount += caseName.size()*sizeof(QChar);
|
||||
byteCount += caseType.size()*sizeof(QChar);
|
||||
|
||||
socketStream << byteCount;
|
||||
|
||||
socketStream << caseId;
|
||||
socketStream << caseName;
|
||||
socketStream << caseType;
|
||||
socketStream << caseGroupId;
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
static bool RiaGetCurrentCase_init = RiaSocketCommandFactory::instance()->registerCreator<RiaGetCurrentCase>(RiaGetCurrentCase::commandName());
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
class RiaGetSelectedCases: public RiaSocketCommand
|
||||
{
|
||||
public:
|
||||
static QString commandName () { return QString("GetSelectedCases"); }
|
||||
|
||||
virtual bool interpretCommand(RiaSocketServer* server, const QList<QByteArray>& args, QDataStream& socketStream)
|
||||
{
|
||||
RiuMainWindow* ruiMainWindow = RiuMainWindow::instance();
|
||||
if (ruiMainWindow)
|
||||
{
|
||||
std::vector<RimCase*> cases;
|
||||
ruiMainWindow->selectedCases(cases);
|
||||
|
||||
std::vector<qint64> caseIds;
|
||||
std::vector<QString> caseNames;
|
||||
std::vector<QString> caseTypes;
|
||||
std::vector<qint64> caseGroupIds;
|
||||
|
||||
getCaseInfoFromCases(cases, caseIds, caseNames, caseTypes, caseGroupIds);
|
||||
|
||||
quint64 byteCount = sizeof(quint64);
|
||||
quint64 selectionCount = caseIds.size();
|
||||
|
||||
for (size_t i = 0; i < selectionCount; i++)
|
||||
{
|
||||
byteCount += 2*sizeof(qint64);
|
||||
byteCount += caseNames[i].size() * sizeof(QChar);
|
||||
byteCount += caseTypes[i].size() * sizeof(QChar);
|
||||
}
|
||||
|
||||
socketStream << byteCount;
|
||||
socketStream << selectionCount;
|
||||
|
||||
for (size_t i = 0; i < selectionCount; i++)
|
||||
{
|
||||
socketStream << caseIds[i];
|
||||
socketStream << caseNames[i];
|
||||
socketStream << caseTypes[i];
|
||||
socketStream << caseGroupIds[i];
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
static bool RiaGetSelectedCases_init = RiaSocketCommandFactory::instance()->registerCreator<RiaGetSelectedCases>(RiaGetSelectedCases::commandName());
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
class RiaGetCaseGroups : public RiaSocketCommand
|
||||
{
|
||||
public:
|
||||
static QString commandName () { return QString("GetCaseGroups"); }
|
||||
virtual bool interpretCommand(RiaSocketServer* server, const QList<QByteArray>& args, QDataStream& socketStream)
|
||||
{
|
||||
RimProject* proj = RiaApplication::instance()->project();
|
||||
RimAnalysisModels* analysisModels = (proj && proj->activeOilField()) ? proj->activeOilField()->analysisModels() : NULL;
|
||||
if (analysisModels)
|
||||
{
|
||||
std::vector<QString> groupNames;
|
||||
std::vector<qint64> groupIds;
|
||||
|
||||
size_t caseGroupCount = analysisModels->caseGroups().size();
|
||||
quint64 byteCount = 0;
|
||||
|
||||
for (size_t i = 0; i < caseGroupCount; i++)
|
||||
{
|
||||
RimIdenticalGridCaseGroup* cg = analysisModels->caseGroups()[i];
|
||||
|
||||
QString caseGroupName = cg->name;
|
||||
qint64 caseGroupId = cg->groupId;
|
||||
|
||||
byteCount += caseGroupName.size() * sizeof(QChar);
|
||||
byteCount += sizeof(qint64);
|
||||
|
||||
groupNames.push_back(caseGroupName);
|
||||
groupIds.push_back(caseGroupId);
|
||||
}
|
||||
|
||||
socketStream << (quint64)byteCount;
|
||||
socketStream << (quint64)caseGroupCount;
|
||||
|
||||
for (size_t i = 0; i < caseGroupCount; i++)
|
||||
{
|
||||
socketStream << groupNames[i];
|
||||
socketStream << groupIds[i];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// ERROR
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
static bool RiaGetCaseGroups_init = RiaSocketCommandFactory::instance()->registerCreator<RiaGetCaseGroups>(RiaGetCaseGroups::commandName());
|
||||
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
class RiaGetCases : public RiaSocketCommand
|
||||
{
|
||||
public:
|
||||
static QString commandName () { return QString("GetCases"); }
|
||||
|
||||
virtual bool interpretCommand(RiaSocketServer* server, const QList<QByteArray>& args, QDataStream& socketStream)
|
||||
{
|
||||
int argCaseGroupId = -1;
|
||||
|
||||
if (args.size() == 2)
|
||||
{
|
||||
argCaseGroupId = args[1].toInt();
|
||||
}
|
||||
|
||||
RimProject* proj = RiaApplication::instance()->project();
|
||||
RimAnalysisModels* analysisModels = (proj && proj->activeOilField()) ? proj->activeOilField()->analysisModels() : NULL;
|
||||
if (analysisModels)
|
||||
{
|
||||
|
||||
std::vector<RimCase*> cases;
|
||||
if (argCaseGroupId == -1)
|
||||
{
|
||||
proj->allCases(cases);
|
||||
}
|
||||
else
|
||||
{
|
||||
RimIdenticalGridCaseGroup* caseGroup = NULL;
|
||||
for (size_t i = 0; i < analysisModels->caseGroups().size(); i++)
|
||||
{
|
||||
RimIdenticalGridCaseGroup* cg = analysisModels->caseGroups()[i];
|
||||
|
||||
if (argCaseGroupId == cg->groupId())
|
||||
{
|
||||
caseGroup = cg;
|
||||
}
|
||||
}
|
||||
|
||||
if (caseGroup)
|
||||
{
|
||||
for (size_t i = 0; i < caseGroup->statisticsCaseCollection()->reservoirs.size(); i++)
|
||||
{
|
||||
cases.push_back(caseGroup->statisticsCaseCollection()->reservoirs[i]);
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < caseGroup->caseCollection()->reservoirs.size(); i++)
|
||||
{
|
||||
cases.push_back(caseGroup->caseCollection()->reservoirs[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
std::vector<qint64> caseIds;
|
||||
std::vector<QString> caseNames;
|
||||
std::vector<QString> caseTypes;
|
||||
std::vector<qint64> caseGroupIds;
|
||||
|
||||
getCaseInfoFromCases(cases, caseIds, caseNames, caseTypes, caseGroupIds);
|
||||
|
||||
quint64 byteCount = sizeof(quint64);
|
||||
quint64 caseCount = caseIds.size();
|
||||
|
||||
for (size_t i = 0; i < caseCount; i++)
|
||||
{
|
||||
byteCount += 2*sizeof(qint64);
|
||||
byteCount += caseNames[i].size() * sizeof(QChar);
|
||||
byteCount += caseTypes[i].size() * sizeof(QChar);
|
||||
}
|
||||
|
||||
socketStream << byteCount;
|
||||
socketStream << caseCount;
|
||||
|
||||
for (size_t i = 0; i < caseCount; i++)
|
||||
{
|
||||
socketStream << caseIds[i];
|
||||
socketStream << caseNames[i];
|
||||
socketStream << caseTypes[i];
|
||||
socketStream << caseGroupIds[i];
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
static bool RiaGetCases_init = RiaSocketCommandFactory::instance()->registerCreator<RiaGetCases>(RiaGetCases::commandName());
|
||||
@@ -0,0 +1,999 @@
|
||||
//
|
||||
// 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 "RiaSocketCommand.h"
|
||||
#include "RiaSocketServer.h"
|
||||
#include "RiaSocketTools.h"
|
||||
|
||||
#include "RiuMainWindow.h"
|
||||
|
||||
#include "RigCaseData.h"
|
||||
#include "RigCaseCellResultsData.h"
|
||||
|
||||
#include "RimReservoirCellResultsCacher.h"
|
||||
#include "RimCase.h"
|
||||
#include "RimInputCase.h"
|
||||
#include "RimInputPropertyCollection.h"
|
||||
#include "RimUiTreeModelPdm.h"
|
||||
#include "RimReservoirView.h"
|
||||
#include "RimResultSlot.h"
|
||||
#include "RimCellEdgeResultSlot.h"
|
||||
#include "RimCellRangeFilterCollection.h"
|
||||
#include "RimCellPropertyFilterCollection.h"
|
||||
#include "RimWellCollection.h"
|
||||
#include "Rim3dOverlayInfoConfig.h"
|
||||
|
||||
#include <QTcpSocket>
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
class RiaGetActiveCellProperty: public RiaSocketCommand
|
||||
{
|
||||
public:
|
||||
static QString commandName () { return QString("GetActiveCellProperty"); }
|
||||
|
||||
virtual bool interpretCommand(RiaSocketServer* server, const QList<QByteArray>& args, QDataStream& socketStream)
|
||||
{
|
||||
RimCase* rimCase = RiaSocketTools::findCaseFromArgs(server, args);
|
||||
|
||||
QString propertyName = args[2];
|
||||
QString porosityModelName = args[3];
|
||||
|
||||
RifReaderInterface::PorosityModelResultType porosityModelEnum = RifReaderInterface::MATRIX_RESULTS;
|
||||
if (porosityModelName == "Fracture")
|
||||
{
|
||||
porosityModelEnum = RifReaderInterface::FRACTURE_RESULTS;
|
||||
}
|
||||
|
||||
// Find the requested data
|
||||
|
||||
size_t scalarResultIndex = cvf::UNDEFINED_SIZE_T;
|
||||
std::vector< std::vector<double> >* scalarResultFrames = NULL;
|
||||
|
||||
if (rimCase && rimCase->results(porosityModelEnum))
|
||||
{
|
||||
scalarResultIndex = rimCase->results(porosityModelEnum)->findOrLoadScalarResult(propertyName);
|
||||
|
||||
if (scalarResultIndex != cvf::UNDEFINED_SIZE_T)
|
||||
{
|
||||
scalarResultFrames = &(rimCase->results(porosityModelEnum)->cellResults()->cellScalarResults(scalarResultIndex));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (scalarResultFrames == NULL)
|
||||
{
|
||||
server->errorMessageDialog()->showMessage(RiaSocketServer::tr("ResInsight SocketServer: \n") + RiaSocketServer::tr("Could not find the %1 model property named: \"%2\"").arg(porosityModelName).arg(propertyName));
|
||||
}
|
||||
|
||||
// Write data back : timeStepCount, bytesPrTimestep, dataForTimestep0 ... dataForTimestepN
|
||||
|
||||
if ( scalarResultFrames == NULL)
|
||||
{
|
||||
// No data available
|
||||
socketStream << (quint64)0 << (quint64)0 ;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Create a list of all the requested timesteps
|
||||
|
||||
std::vector<size_t> requestedTimesteps;
|
||||
|
||||
if (args.size() <= 4)
|
||||
{
|
||||
// Select all
|
||||
for (size_t tsIdx = 0; tsIdx < scalarResultFrames->size(); ++tsIdx)
|
||||
{
|
||||
requestedTimesteps.push_back(tsIdx);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
bool timeStepReadError = false;
|
||||
for (int argIdx = 4; argIdx < args.size(); ++argIdx)
|
||||
{
|
||||
bool conversionOk = false;
|
||||
int tsIdx = args[argIdx].toInt(&conversionOk);
|
||||
|
||||
if (conversionOk)
|
||||
{
|
||||
requestedTimesteps.push_back(tsIdx);
|
||||
}
|
||||
else
|
||||
{
|
||||
timeStepReadError = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (timeStepReadError)
|
||||
{
|
||||
server->errorMessageDialog()->showMessage(RiaSocketServer::tr("ResInsight SocketServer: riGetActiveCellProperty : \n") + RiaSocketServer::tr("An error occured while interpreting the requested timesteps."));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// First write timestep count
|
||||
quint64 timestepCount = (quint64)requestedTimesteps.size();
|
||||
socketStream << timestepCount;
|
||||
|
||||
// then the byte-size of the result values in one timestep
|
||||
|
||||
const RigActiveCellInfo* activeInfo = rimCase->reservoirData()->activeCellInfo(porosityModelEnum);
|
||||
size_t timestepResultCount = activeInfo->globalActiveCellCount();
|
||||
|
||||
quint64 timestepByteCount = (quint64)(timestepResultCount*sizeof(double));
|
||||
socketStream << timestepByteCount ;
|
||||
|
||||
// Then write the data.
|
||||
|
||||
size_t globalCellCount = activeInfo->globalCellCount();
|
||||
for (size_t tIdx = 0; tIdx < requestedTimesteps.size(); ++tIdx)
|
||||
{
|
||||
for (size_t gcIdx = 0; gcIdx < globalCellCount; ++gcIdx)
|
||||
{
|
||||
size_t resultIdx = activeInfo->cellResultIndex(gcIdx);
|
||||
if (resultIdx != cvf::UNDEFINED_SIZE_T)
|
||||
{
|
||||
if (resultIdx < scalarResultFrames->at(requestedTimesteps[tIdx]).size())
|
||||
{
|
||||
socketStream << scalarResultFrames->at(requestedTimesteps[tIdx])[resultIdx];
|
||||
}
|
||||
else
|
||||
{
|
||||
socketStream << HUGE_VAL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#if 0
|
||||
// This aproach is faster but does not handle coarsening
|
||||
size_t timestepResultCount = scalarResultFrames->front().size();
|
||||
quint64 timestepByteCount = (quint64)(timestepResultCount*sizeof(double));
|
||||
socketStream << timestepByteCount ;
|
||||
|
||||
// Then write the data.
|
||||
|
||||
for (size_t tIdx = 0; tIdx < requestedTimesteps.size(); ++tIdx)
|
||||
{
|
||||
#if 1 // Write data as raw bytes, fast but does not handle byteswapping
|
||||
server->currentClient()->write((const char *)scalarResultFrames->at(requestedTimesteps[tIdx]).data(), timestepByteCount); // Raw print of data. Fast but no platform conversion
|
||||
#else // Write data using QDataStream, does byteswapping for us. Must use QDataStream on client as well
|
||||
for (size_t cIdx = 0; cIdx < scalarResultFrames->at(requestedTimesteps[tIdx]).size(); ++cIdx)
|
||||
{
|
||||
socketStream << scalarResultFrames->at(tIdx)[cIdx];
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
static bool RiaGetActiveCellProperty_init = RiaSocketCommandFactory::instance()->registerCreator<RiaGetActiveCellProperty>(RiaGetActiveCellProperty::commandName());
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
class RiaGetGridProperty: public RiaSocketCommand
|
||||
{
|
||||
public:
|
||||
static QString commandName () { return QString("GetGridProperty"); }
|
||||
|
||||
virtual bool interpretCommand(RiaSocketServer* server, const QList<QByteArray>& args, QDataStream& socketStream)
|
||||
{
|
||||
int caseId = args[1].toInt();
|
||||
int gridIdx = args[2].toInt();
|
||||
QString propertyName = args[3];
|
||||
QString porosityModelName = args[4];
|
||||
|
||||
RimCase*rimCase = server->findReservoir(caseId);
|
||||
if (rimCase == NULL)
|
||||
{
|
||||
server->errorMessageDialog()->showMessage(RiaSocketServer::tr("ResInsight SocketServer: \n") + RiaSocketServer::tr("Could not find the case with ID: \"%1\"").arg(caseId));
|
||||
|
||||
// No data available
|
||||
socketStream << (quint64)0 << (quint64)0 << (quint64)0 << (quint64)0 ;
|
||||
return true;
|
||||
}
|
||||
|
||||
RifReaderInterface::PorosityModelResultType porosityModelEnum = RifReaderInterface::MATRIX_RESULTS;
|
||||
if (porosityModelName == "Fracture")
|
||||
{
|
||||
porosityModelEnum = RifReaderInterface::FRACTURE_RESULTS;
|
||||
}
|
||||
|
||||
size_t scalarResultIndex = cvf::UNDEFINED_SIZE_T;
|
||||
std::vector< std::vector<double> >* scalarResultFrames = NULL;
|
||||
|
||||
if (gridIdx < 0 || rimCase->reservoirData()->gridCount() <= (size_t)gridIdx)
|
||||
{
|
||||
server->errorMessageDialog()->showMessage("ResInsight SocketServer: riGetGridProperty : \n"
|
||||
"The gridIndex \"" + QString::number(gridIdx) + "\" does not point to an existing grid." );
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
// Find the requested data
|
||||
|
||||
if (rimCase && rimCase->results(porosityModelEnum))
|
||||
{
|
||||
scalarResultIndex = rimCase->results(porosityModelEnum)->findOrLoadScalarResult(propertyName);
|
||||
|
||||
if (scalarResultIndex != cvf::UNDEFINED_SIZE_T)
|
||||
{
|
||||
scalarResultFrames = &(rimCase->results(porosityModelEnum)->cellResults()->cellScalarResults(scalarResultIndex));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (scalarResultFrames == NULL)
|
||||
{
|
||||
server->errorMessageDialog()->showMessage(RiaSocketServer::tr("ResInsight SocketServer: \n") + RiaSocketServer::tr("Could not find the %1 model property named: \"%2\"").arg(porosityModelName).arg(propertyName));
|
||||
|
||||
// No data available
|
||||
socketStream << (quint64)0 << (quint64)0 << (quint64)0 << (quint64)0 ;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Create a list of all the requested time steps
|
||||
|
||||
std::vector<size_t> requestedTimesteps;
|
||||
|
||||
if (args.size() <= 5)
|
||||
{
|
||||
// Select all
|
||||
for (size_t tsIdx = 0; tsIdx < scalarResultFrames->size(); ++tsIdx)
|
||||
{
|
||||
requestedTimesteps.push_back(tsIdx);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
bool timeStepReadError = false;
|
||||
for (int argIdx = 5; argIdx < args.size(); ++argIdx)
|
||||
{
|
||||
bool conversionOk = false;
|
||||
int tsIdx = args[argIdx].toInt(&conversionOk);
|
||||
|
||||
if (conversionOk)
|
||||
{
|
||||
requestedTimesteps.push_back(tsIdx);
|
||||
}
|
||||
else
|
||||
{
|
||||
timeStepReadError = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (timeStepReadError)
|
||||
{
|
||||
server->errorMessageDialog()->showMessage(RiaSocketServer::tr("ResInsight SocketServer: riGetGridProperty : \n")
|
||||
+ RiaSocketServer::tr("An error occured while interpreting the requested timesteps."));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
RigGridBase* rigGrid = rimCase->reservoirData()->grid(gridIdx);
|
||||
const RigActiveCellInfo* activeInfo = rimCase->reservoirData()->activeCellInfo(porosityModelEnum);
|
||||
|
||||
quint64 cellCountI = (quint64)rigGrid->cellCountI();
|
||||
quint64 cellCountJ = (quint64)rigGrid->cellCountJ();
|
||||
quint64 cellCountK = (quint64)rigGrid->cellCountK();
|
||||
|
||||
socketStream << cellCountI;
|
||||
socketStream << cellCountJ;
|
||||
socketStream << cellCountK;
|
||||
|
||||
// Write time step count
|
||||
|
||||
quint64 timestepCount = (quint64)requestedTimesteps.size();
|
||||
socketStream << timestepCount;
|
||||
|
||||
size_t doubleValueCount = cellCountI * cellCountJ * cellCountK * timestepCount * sizeof(double);
|
||||
std::vector<double> values(doubleValueCount);
|
||||
size_t valueIdx = 0;
|
||||
|
||||
for (size_t tsIdx = 0; tsIdx < timestepCount; tsIdx++)
|
||||
{
|
||||
for (size_t k = 0; k < cellCountK; k++)
|
||||
{
|
||||
for (size_t j = 0; j < cellCountJ; j++)
|
||||
{
|
||||
for (size_t i = 0; i < cellCountI; i++)
|
||||
{
|
||||
size_t localCellIndex = rigGrid->cellIndexFromIJK(i,j,k);
|
||||
size_t gcIdx = rigGrid->globalGridCellIndex(localCellIndex);
|
||||
|
||||
size_t resultIdx = activeInfo->cellResultIndex(gcIdx);
|
||||
|
||||
if (resultIdx < scalarResultFrames->at(requestedTimesteps[tsIdx]).size())
|
||||
{
|
||||
values[valueIdx++] = scalarResultFrames->at(requestedTimesteps[tsIdx])[resultIdx];
|
||||
}
|
||||
else
|
||||
{
|
||||
values[valueIdx++] = HUGE_VAL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
server->currentClient()->write((const char *)values.data(), doubleValueCount);
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
static bool RiaGetGridProperty_init = RiaSocketCommandFactory::instance()->registerCreator<RiaGetGridProperty>(RiaGetGridProperty::commandName());
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
class RiaSetActiveCellProperty: public RiaSocketCommand
|
||||
{
|
||||
public:
|
||||
RiaSetActiveCellProperty() :
|
||||
m_currentReservoir(NULL),
|
||||
m_scalarResultsToAdd(NULL),
|
||||
m_currentScalarIndex(cvf::UNDEFINED_SIZE_T),
|
||||
m_timeStepCountToRead(0),
|
||||
m_bytesPerTimeStepToRead(0),
|
||||
m_currentTimeStepNumberToRead(0),
|
||||
m_invalidActiveCellCountDetected(false),
|
||||
m_porosityModelEnum(RifReaderInterface::MATRIX_RESULTS)
|
||||
{}
|
||||
|
||||
static QString commandName () { return QString("SetActiveCellProperty"); }
|
||||
|
||||
virtual bool interpretCommand(RiaSocketServer* server, const QList<QByteArray>& args, QDataStream& socketStream)
|
||||
{
|
||||
RimCase* rimCase = RiaSocketTools::findCaseFromArgs(server, args);
|
||||
|
||||
QString propertyName = args[2];
|
||||
QString porosityModelName = args[3];
|
||||
|
||||
if (porosityModelName == "Fracture")
|
||||
{
|
||||
m_porosityModelEnum = RifReaderInterface::FRACTURE_RESULTS;
|
||||
}
|
||||
|
||||
// Find the requested data, Or create a set if we are setting data and it is not found
|
||||
|
||||
size_t scalarResultIndex = cvf::UNDEFINED_SIZE_T;
|
||||
std::vector< std::vector<double> >* scalarResultFrames = NULL;
|
||||
|
||||
if (rimCase && rimCase->results(m_porosityModelEnum))
|
||||
{
|
||||
scalarResultIndex = rimCase->results(m_porosityModelEnum)->findOrLoadScalarResult(RimDefines::GENERATED, propertyName);
|
||||
|
||||
if (scalarResultIndex == cvf::UNDEFINED_SIZE_T)
|
||||
{
|
||||
scalarResultIndex = rimCase->results(m_porosityModelEnum)->cellResults()->addEmptyScalarResult(RimDefines::GENERATED, propertyName, true);
|
||||
}
|
||||
|
||||
if (scalarResultIndex != cvf::UNDEFINED_SIZE_T)
|
||||
{
|
||||
scalarResultFrames = &(rimCase->results(m_porosityModelEnum)->cellResults()->cellScalarResults(scalarResultIndex));
|
||||
m_currentScalarIndex = scalarResultIndex;
|
||||
m_currentPropertyName = propertyName;
|
||||
}
|
||||
}
|
||||
|
||||
if (scalarResultFrames == NULL)
|
||||
{
|
||||
server->errorMessageDialog()->showMessage(RiaSocketServer::tr("ResInsight SocketServer: \n") + RiaSocketServer::tr("Could not find the %1 model property named: \"%2\"").arg(porosityModelName).arg(propertyName));
|
||||
return true;
|
||||
}
|
||||
|
||||
// If we have not read the header and there are data enough: Read it.
|
||||
// Do nothing if we have not enough data
|
||||
|
||||
if (m_timeStepCountToRead == 0 || m_bytesPerTimeStepToRead == 0)
|
||||
{
|
||||
if (server->currentClient()->bytesAvailable() < (int)sizeof(quint64)*2) return true;
|
||||
|
||||
socketStream >> m_timeStepCountToRead;
|
||||
socketStream >> m_bytesPerTimeStepToRead;
|
||||
}
|
||||
|
||||
// std::cout << "RiaSetActiveCellProperty: " << propertyName.data() << " timeStepCount " << m_timeStepCountToRead << " bytesPerTimeStep " << m_bytesPerTimeStepToRead;
|
||||
|
||||
// Create a list of all the requested timesteps
|
||||
|
||||
m_requestedTimesteps.clear();
|
||||
|
||||
if (args.size() <= 4)
|
||||
{
|
||||
// Select all
|
||||
for (size_t tsIdx = 0; tsIdx < m_timeStepCountToRead; ++tsIdx)
|
||||
{
|
||||
m_requestedTimesteps.push_back(tsIdx);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
bool timeStepReadError = false;
|
||||
for (int argIdx = 4; argIdx < args.size(); ++argIdx)
|
||||
{
|
||||
bool conversionOk = false;
|
||||
int tsIdx = args[argIdx].toInt(&conversionOk);
|
||||
|
||||
if (conversionOk)
|
||||
{
|
||||
m_requestedTimesteps.push_back(tsIdx);
|
||||
}
|
||||
else
|
||||
{
|
||||
timeStepReadError = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (timeStepReadError)
|
||||
{
|
||||
server->errorMessageDialog()->showMessage(RiaSocketServer::tr("ResInsight SocketServer: riGetActiveCellProperty : \n") + RiaSocketServer::tr("An error occured while interpreting the requested timesteps."));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (! m_requestedTimesteps.size())
|
||||
{
|
||||
server->errorMessageDialog()->showMessage(RiaSocketServer::tr("ResInsight SocketServer: \n") + RiaSocketServer::tr("No time steps specified").arg(porosityModelName).arg(propertyName));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Resize the result container to be able to receive timesteps at the specified timestep idices
|
||||
|
||||
std::vector<size_t>::iterator maxTimeStepIt = std::max_element(m_requestedTimesteps.begin(), m_requestedTimesteps.end());
|
||||
CVF_ASSERT(maxTimeStepIt != m_requestedTimesteps.end());
|
||||
|
||||
size_t maxTimeStepIdx = (*maxTimeStepIt);
|
||||
if (scalarResultFrames->size() <= maxTimeStepIdx)
|
||||
{
|
||||
scalarResultFrames->resize(maxTimeStepIdx+1);
|
||||
}
|
||||
|
||||
m_currentReservoir = rimCase;
|
||||
m_scalarResultsToAdd = scalarResultFrames;
|
||||
|
||||
if (server->currentClient()->bytesAvailable())
|
||||
{
|
||||
return this->interpretMore(server, server->currentClient());
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual bool interpretMore(RiaSocketServer* server, QTcpSocket* currentClient)
|
||||
{
|
||||
// std::cout << "RiaSetActiveCellProperty, interpretMore: scalarIndex : " << m_currentScalarIndex;
|
||||
|
||||
if (m_invalidActiveCellCountDetected) return true;
|
||||
|
||||
if (!currentClient->bytesAvailable()) return false;
|
||||
|
||||
QDataStream socketStream(currentClient);
|
||||
socketStream.setVersion(riOctavePlugin::qtDataStreamVersion);
|
||||
|
||||
if (m_timeStepCountToRead != m_requestedTimesteps.size())
|
||||
{
|
||||
CVF_ASSERT(false);
|
||||
}
|
||||
|
||||
// If nothing should be read, or we already have read everything, do nothing
|
||||
|
||||
if ((m_timeStepCountToRead == 0) || (m_currentTimeStepNumberToRead >= m_timeStepCountToRead) ) return true;
|
||||
|
||||
// Check if a complete timestep is available, return and whait for readyRead() if not
|
||||
if (currentClient->bytesAvailable() < (int)m_bytesPerTimeStepToRead) return false;
|
||||
|
||||
size_t cellCountFromOctave = m_bytesPerTimeStepToRead / sizeof(double);
|
||||
|
||||
RigActiveCellInfo* activeCellInfo = m_currentReservoir->reservoirData()->activeCellInfo(m_porosityModelEnum);
|
||||
|
||||
size_t globalActiveCellCount = activeCellInfo->globalActiveCellCount();
|
||||
size_t totalCellCount = activeCellInfo->globalCellCount();
|
||||
size_t globalCellResultCount = activeCellInfo->globalCellResultCount();
|
||||
|
||||
bool isCoarseningActive = globalCellResultCount != globalActiveCellCount;
|
||||
|
||||
if (cellCountFromOctave != globalActiveCellCount )
|
||||
{
|
||||
server->errorMessageDialog()->showMessage(RiaSocketServer::tr("ResInsight SocketServer: \n") +
|
||||
RiaSocketServer::tr("The number of cells in the data coming from octave does not match the case") + ":\"" + m_currentReservoir->caseUserDescription() + "\"\n"
|
||||
" Octave: " + QString::number(cellCountFromOctave) + "\n"
|
||||
" " + m_currentReservoir->caseUserDescription() + ": Active cell count: " + QString::number(globalActiveCellCount) + " Total cell count: " + QString::number(totalCellCount)) ;
|
||||
|
||||
cellCountFromOctave = 0;
|
||||
m_invalidActiveCellCountDetected = true;
|
||||
currentClient->abort();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Make sure the size of the retreiving container is correct.
|
||||
// If it is, this is noops
|
||||
|
||||
for (size_t tIdx = 0; tIdx < m_timeStepCountToRead; ++tIdx)
|
||||
{
|
||||
size_t tsId = m_requestedTimesteps[tIdx];
|
||||
m_scalarResultsToAdd->at(tsId).resize(globalCellResultCount, HUGE_VAL);
|
||||
}
|
||||
|
||||
std::vector<double> readBuffer;
|
||||
double * internalMatrixData = NULL;
|
||||
|
||||
if (isCoarseningActive)
|
||||
{
|
||||
readBuffer.resize(cellCountFromOctave, HUGE_VAL);
|
||||
internalMatrixData = readBuffer.data();
|
||||
}
|
||||
|
||||
// Read available complete timestepdata
|
||||
|
||||
while ((currentClient->bytesAvailable() >= (int)m_bytesPerTimeStepToRead) && (m_currentTimeStepNumberToRead < m_timeStepCountToRead))
|
||||
{
|
||||
qint64 bytesRead = 0;
|
||||
if ( !isCoarseningActive)
|
||||
{
|
||||
internalMatrixData = m_scalarResultsToAdd->at(m_requestedTimesteps[m_currentTimeStepNumberToRead]).data();
|
||||
}
|
||||
|
||||
#if 1 // Use raw data transfer. Faster.
|
||||
bytesRead = currentClient->read((char*)(internalMatrixData), m_bytesPerTimeStepToRead);
|
||||
#else
|
||||
for (size_t cIdx = 0; cIdx < cellCountFromOctave; ++cIdx)
|
||||
{
|
||||
socketStream >> internalMatrixData[cIdx];
|
||||
|
||||
if (socketStream.status() == QDataStream::Ok) bytesRead += sizeof(double);
|
||||
}
|
||||
#endif
|
||||
// Map data from active to result index based container ( Coarsening is active)
|
||||
if (isCoarseningActive)
|
||||
{
|
||||
size_t acIdx = 0;
|
||||
for (size_t gcIdx = 0; gcIdx < totalCellCount; ++gcIdx)
|
||||
{
|
||||
if (activeCellInfo->isActive(gcIdx))
|
||||
{
|
||||
m_scalarResultsToAdd->at(m_requestedTimesteps[m_currentTimeStepNumberToRead])[activeCellInfo->cellResultIndex(gcIdx)] = readBuffer[acIdx];
|
||||
++acIdx;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((int)m_bytesPerTimeStepToRead != bytesRead)
|
||||
{
|
||||
server->errorMessageDialog()->showMessage(RiaSocketServer::tr("ResInsight SocketServer: \n") +
|
||||
RiaSocketServer::tr("Could not read binary double data properly from socket"));
|
||||
}
|
||||
|
||||
++m_currentTimeStepNumberToRead;
|
||||
}
|
||||
|
||||
// std::cout << "RiaSetActiveCellProperty, completed " << std::endl;
|
||||
// currentClient->disconnect();
|
||||
// std::cout << "RiaSetActiveCellProperty, completed (after disconnect) " << std::endl;
|
||||
|
||||
// If we have read all the data, refresh the views
|
||||
|
||||
if (m_currentTimeStepNumberToRead == m_timeStepCountToRead)
|
||||
{
|
||||
if (m_currentReservoir != NULL)
|
||||
{
|
||||
// Create a new input property if we have an input reservoir
|
||||
RimInputCase* inputRes = dynamic_cast<RimInputCase*>(m_currentReservoir);
|
||||
if (inputRes)
|
||||
{
|
||||
RimInputProperty* inputProperty = NULL;
|
||||
inputProperty = inputRes->m_inputPropertyCollection->findInputProperty(m_currentPropertyName);
|
||||
if (!inputProperty)
|
||||
{
|
||||
inputProperty = new RimInputProperty;
|
||||
inputProperty->resultName = m_currentPropertyName;
|
||||
inputProperty->eclipseKeyword = "";
|
||||
inputProperty->fileName = "";
|
||||
inputRes->m_inputPropertyCollection->inputProperties.push_back(inputProperty);
|
||||
RimUiTreeModelPdm* treeModel = RiuMainWindow::instance()->uiPdmModel();
|
||||
treeModel->updateUiSubTree(inputRes->m_inputPropertyCollection());
|
||||
}
|
||||
inputProperty->resolvedState = RimInputProperty::RESOLVED_NOT_SAVED;
|
||||
}
|
||||
|
||||
if( m_currentScalarIndex != cvf::UNDEFINED_SIZE_T &&
|
||||
m_currentReservoir->reservoirData() &&
|
||||
m_currentReservoir->reservoirData()->results(m_porosityModelEnum) )
|
||||
{
|
||||
m_currentReservoir->reservoirData()->results(m_porosityModelEnum)->recalculateMinMax(m_currentScalarIndex);
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < m_currentReservoir->reservoirViews.size(); ++i)
|
||||
{
|
||||
if (m_currentReservoir->reservoirViews[i])
|
||||
{
|
||||
m_currentReservoir->reservoirViews[i]->updateCurrentTimeStepAndRedraw();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// std::cout << "RiaSetActiveCellProperty, completed : scalarIndex : " << m_currentScalarIndex;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
private:
|
||||
RimCase* m_currentReservoir;
|
||||
std::vector< std::vector<double> >* m_scalarResultsToAdd;
|
||||
size_t m_currentScalarIndex;
|
||||
QString m_currentPropertyName;
|
||||
std::vector<size_t> m_requestedTimesteps;
|
||||
RifReaderInterface::PorosityModelResultType m_porosityModelEnum;
|
||||
|
||||
quint64 m_timeStepCountToRead;
|
||||
quint64 m_bytesPerTimeStepToRead;
|
||||
size_t m_currentTimeStepNumberToRead;
|
||||
|
||||
bool m_invalidActiveCellCountDetected;
|
||||
};
|
||||
|
||||
static bool RiaSetActiveCellProperty_init = RiaSocketCommandFactory::instance()->registerCreator<RiaSetActiveCellProperty>(RiaSetActiveCellProperty::commandName());
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
class RiaSetGridProperty : public RiaSocketCommand
|
||||
{
|
||||
public:
|
||||
RiaSetGridProperty() :
|
||||
m_currentReservoir(NULL),
|
||||
m_scalarResultsToAdd(NULL),
|
||||
m_currentGridIndex(cvf::UNDEFINED_SIZE_T),
|
||||
m_currentScalarIndex(cvf::UNDEFINED_SIZE_T),
|
||||
m_timeStepCountToRead(0),
|
||||
m_bytesPerTimeStepToRead(0),
|
||||
m_currentTimeStepNumberToRead(0),
|
||||
m_invalidDataDetected(false),
|
||||
m_porosityModelEnum(RifReaderInterface::MATRIX_RESULTS)
|
||||
{}
|
||||
|
||||
static QString commandName () { return QString("SetGridProperty"); }
|
||||
|
||||
virtual bool interpretCommand(RiaSocketServer* server, const QList<QByteArray>& args, QDataStream& socketStream)
|
||||
{
|
||||
int caseId = args[1].toInt();
|
||||
RimCase* rimCase = server->findReservoir(caseId);
|
||||
if (!rimCase)
|
||||
{
|
||||
server->errorMessageDialog()->showMessage(RiaSocketServer::tr("ResInsight SocketServer: \n") + RiaSocketServer::tr("Could not find the case with ID : \"%1\"").arg(caseId));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
m_currentGridIndex = args[2].toInt();
|
||||
QString propertyName = args[3];
|
||||
QString porosityModelName = args[4];
|
||||
|
||||
if (porosityModelName == "Fracture")
|
||||
{
|
||||
m_porosityModelEnum = RifReaderInterface::FRACTURE_RESULTS;
|
||||
}
|
||||
|
||||
RigGridBase* grid = rimCase->reservoirData()->grid(m_currentGridIndex);
|
||||
if (!grid)
|
||||
{
|
||||
server->errorMessageDialog()->showMessage(RiaSocketServer::tr("ResInsight SocketServer: \n") + RiaSocketServer::tr("Could not find the grid index : %1").arg(m_currentGridIndex));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// Read header
|
||||
if (server->currentClient()->bytesAvailable() < (int)sizeof(quint64)*5) return true;
|
||||
|
||||
quint64 cellCountI = 0;
|
||||
quint64 cellCountJ = 0;
|
||||
quint64 cellCountK = 0;
|
||||
socketStream >> cellCountI;
|
||||
socketStream >> cellCountJ;
|
||||
socketStream >> cellCountK;
|
||||
|
||||
if (grid->cellCountI() != cellCountI ||
|
||||
grid->cellCountJ() != cellCountJ ||
|
||||
grid->cellCountK() != cellCountK)
|
||||
{
|
||||
server->errorMessageDialog()->showMessage(RiaSocketServer::tr("ResInsight SocketServer: \n") + RiaSocketServer::tr("Destination grid size do not match incoming grid size for grid index : %1").arg(m_currentGridIndex));
|
||||
return true;
|
||||
}
|
||||
|
||||
socketStream >> m_timeStepCountToRead;
|
||||
socketStream >> m_bytesPerTimeStepToRead;
|
||||
|
||||
if (m_timeStepCountToRead == 0 || m_bytesPerTimeStepToRead == 0)
|
||||
{
|
||||
server->errorMessageDialog()->showMessage(RiaSocketServer::tr("ResInsight SocketServer: \n") +
|
||||
RiaSocketServer::tr("Zero data to read for ") + ":\"" + m_currentReservoir->caseUserDescription() + "\"\n");
|
||||
}
|
||||
|
||||
|
||||
size_t scalarResultIndex = cvf::UNDEFINED_SIZE_T;
|
||||
std::vector< std::vector<double> >* scalarResultFrames = NULL;
|
||||
|
||||
if (rimCase && rimCase->results(m_porosityModelEnum))
|
||||
{
|
||||
scalarResultIndex = rimCase->results(m_porosityModelEnum)->findOrLoadScalarResult(RimDefines::GENERATED, propertyName);
|
||||
|
||||
if (scalarResultIndex == cvf::UNDEFINED_SIZE_T)
|
||||
{
|
||||
scalarResultIndex = rimCase->results(m_porosityModelEnum)->cellResults()->addEmptyScalarResult(RimDefines::GENERATED, propertyName, true);
|
||||
}
|
||||
|
||||
if (scalarResultIndex != cvf::UNDEFINED_SIZE_T)
|
||||
{
|
||||
scalarResultFrames = &(rimCase->results(m_porosityModelEnum)->cellResults()->cellScalarResults(scalarResultIndex));
|
||||
m_currentScalarIndex = scalarResultIndex;
|
||||
m_currentPropertyName = propertyName;
|
||||
}
|
||||
}
|
||||
|
||||
if (scalarResultFrames == NULL)
|
||||
{
|
||||
server->errorMessageDialog()->showMessage(RiaSocketServer::tr("ResInsight SocketServer: \n") + RiaSocketServer::tr("Could not find the %1 model property named: \"%2\"").arg(porosityModelName).arg(propertyName));
|
||||
return true;
|
||||
}
|
||||
|
||||
// Create a list of all the requested timesteps
|
||||
|
||||
m_requestedTimesteps.clear();
|
||||
|
||||
if (args.size() <= 5)
|
||||
{
|
||||
// Select all
|
||||
for (size_t tsIdx = 0; tsIdx < m_timeStepCountToRead; ++tsIdx)
|
||||
{
|
||||
m_requestedTimesteps.push_back(tsIdx);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
bool timeStepReadError = false;
|
||||
for (int argIdx = 5; argIdx < args.size(); ++argIdx)
|
||||
{
|
||||
bool conversionOk = false;
|
||||
int tsIdx = args[argIdx].toInt(&conversionOk);
|
||||
|
||||
if (conversionOk)
|
||||
{
|
||||
m_requestedTimesteps.push_back(tsIdx);
|
||||
}
|
||||
else
|
||||
{
|
||||
timeStepReadError = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (timeStepReadError)
|
||||
{
|
||||
server->errorMessageDialog()->showMessage(RiaSocketServer::tr("ResInsight SocketServer: riGetActiveCellProperty : \n") + RiaSocketServer::tr("An error occured while interpreting the requested timesteps."));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (! m_requestedTimesteps.size())
|
||||
{
|
||||
server->errorMessageDialog()->showMessage(RiaSocketServer::tr("ResInsight SocketServer: \n") + RiaSocketServer::tr("No time steps specified").arg(porosityModelName).arg(propertyName));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Resize the result container to be able to receive time steps at the specified time step indices
|
||||
|
||||
std::vector<size_t>::iterator maxTimeStepIt = std::max_element(m_requestedTimesteps.begin(), m_requestedTimesteps.end());
|
||||
CVF_ASSERT(maxTimeStepIt != m_requestedTimesteps.end());
|
||||
|
||||
size_t maxTimeStepIdx = (*maxTimeStepIt);
|
||||
if (scalarResultFrames->size() <= maxTimeStepIdx)
|
||||
{
|
||||
scalarResultFrames->resize(maxTimeStepIdx+1);
|
||||
}
|
||||
|
||||
m_currentReservoir = rimCase;
|
||||
m_scalarResultsToAdd = scalarResultFrames;
|
||||
|
||||
if (server->currentClient()->bytesAvailable())
|
||||
{
|
||||
return this->interpretMore(server, server->currentClient());
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual bool interpretMore(RiaSocketServer* server, QTcpSocket* currentClient)
|
||||
{
|
||||
if (m_invalidDataDetected) return true;
|
||||
|
||||
if (!currentClient->bytesAvailable()) return false;
|
||||
|
||||
QDataStream socketStream(currentClient);
|
||||
socketStream.setVersion(riOctavePlugin::qtDataStreamVersion);
|
||||
|
||||
RigGridBase* grid = m_currentReservoir->reservoirData()->grid(m_currentGridIndex);
|
||||
if (!grid)
|
||||
{
|
||||
server->errorMessageDialog()->showMessage(RiaSocketServer::tr("ResInsight SocketServer: \n") +
|
||||
RiaSocketServer::tr("No grid found") + ":\"" + m_currentReservoir->caseUserDescription() + "\"\n");
|
||||
|
||||
m_invalidDataDetected = true;
|
||||
currentClient->abort();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Do nothing if we have not enough data
|
||||
if (m_timeStepCountToRead == 0 || m_bytesPerTimeStepToRead == 0)
|
||||
{
|
||||
server->errorMessageDialog()->showMessage(RiaSocketServer::tr("ResInsight SocketServer: \n") +
|
||||
RiaSocketServer::tr("Zero data to read for ") + ":\"" + m_currentReservoir->caseUserDescription() + "\"\n");
|
||||
|
||||
m_invalidDataDetected = true;
|
||||
currentClient->abort();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (m_timeStepCountToRead != m_requestedTimesteps.size())
|
||||
{
|
||||
CVF_ASSERT(false);
|
||||
}
|
||||
|
||||
// If nothing should be read, or we already have read everything, do nothing
|
||||
|
||||
if ((m_timeStepCountToRead == 0) || (m_currentTimeStepNumberToRead >= m_timeStepCountToRead) ) return true;
|
||||
|
||||
// Check if a complete timestep is available, return and whait for readyRead() if not
|
||||
if (currentClient->bytesAvailable() < (int)m_bytesPerTimeStepToRead) return false;
|
||||
|
||||
size_t cellCountFromOctave = m_bytesPerTimeStepToRead / sizeof(double);
|
||||
|
||||
RigActiveCellInfo* activeCellInfo = m_currentReservoir->reservoirData()->activeCellInfo(m_porosityModelEnum);
|
||||
size_t globalCellResultCount = activeCellInfo->globalCellResultCount();
|
||||
|
||||
// Make sure the size of the retreiving container is correct.
|
||||
// If it is, this is noops
|
||||
|
||||
for (size_t tIdx = 0; tIdx < m_timeStepCountToRead; ++tIdx)
|
||||
{
|
||||
size_t tsId = m_requestedTimesteps[tIdx];
|
||||
m_scalarResultsToAdd->at(tsId).resize(globalCellResultCount, HUGE_VAL);
|
||||
}
|
||||
|
||||
if ((currentClient->bytesAvailable() >= (int)m_bytesPerTimeStepToRead) && (m_currentTimeStepNumberToRead < m_timeStepCountToRead))
|
||||
{
|
||||
// Read a single time step with data
|
||||
|
||||
std::vector<double> doubleValues(cellCountFromOctave);
|
||||
|
||||
qint64 bytesRead = currentClient->read((char*)(doubleValues.data()), m_bytesPerTimeStepToRead);
|
||||
size_t doubleValueIndex = 0;
|
||||
|
||||
for (size_t k = 0; k < grid->cellCountK(); k++)
|
||||
{
|
||||
for (size_t j = 0; j < grid->cellCountJ(); j++)
|
||||
{
|
||||
for (size_t i = 0; i < grid->cellCountI(); i++)
|
||||
{
|
||||
size_t localCellIndex = grid->cellIndexFromIJK(i,j,k);
|
||||
size_t gcIdx = grid->globalGridCellIndex(localCellIndex);
|
||||
|
||||
size_t resultIdx = activeCellInfo->cellResultIndex(gcIdx);
|
||||
|
||||
if (resultIdx < m_scalarResultsToAdd->at(m_requestedTimesteps[m_currentTimeStepNumberToRead]).size())
|
||||
{
|
||||
m_scalarResultsToAdd->at(m_requestedTimesteps[m_currentTimeStepNumberToRead])[resultIdx] = doubleValues[doubleValueIndex];
|
||||
}
|
||||
|
||||
doubleValueIndex++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
++m_currentTimeStepNumberToRead;
|
||||
}
|
||||
|
||||
// If we have read all the data, refresh the views
|
||||
|
||||
if (m_currentTimeStepNumberToRead == m_timeStepCountToRead)
|
||||
{
|
||||
if (m_currentReservoir != NULL)
|
||||
{
|
||||
// Create a new input property if we have an input reservoir
|
||||
RimInputCase* inputRes = dynamic_cast<RimInputCase*>(m_currentReservoir);
|
||||
if (inputRes)
|
||||
{
|
||||
RimInputProperty* inputProperty = NULL;
|
||||
inputProperty = inputRes->m_inputPropertyCollection->findInputProperty(m_currentPropertyName);
|
||||
if (!inputProperty)
|
||||
{
|
||||
inputProperty = new RimInputProperty;
|
||||
inputProperty->resultName = m_currentPropertyName;
|
||||
inputProperty->eclipseKeyword = "";
|
||||
inputProperty->fileName = "";
|
||||
inputRes->m_inputPropertyCollection->inputProperties.push_back(inputProperty);
|
||||
RimUiTreeModelPdm* treeModel = RiuMainWindow::instance()->uiPdmModel();
|
||||
treeModel->updateUiSubTree(inputRes->m_inputPropertyCollection());
|
||||
}
|
||||
inputProperty->resolvedState = RimInputProperty::RESOLVED_NOT_SAVED;
|
||||
}
|
||||
|
||||
if( m_currentScalarIndex != cvf::UNDEFINED_SIZE_T &&
|
||||
m_currentReservoir->reservoirData() &&
|
||||
m_currentReservoir->reservoirData()->results(m_porosityModelEnum) )
|
||||
{
|
||||
m_currentReservoir->reservoirData()->results(m_porosityModelEnum)->recalculateMinMax(m_currentScalarIndex);
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < m_currentReservoir->reservoirViews.size(); ++i)
|
||||
{
|
||||
if (m_currentReservoir->reservoirViews[i])
|
||||
{
|
||||
m_currentReservoir->reservoirViews[i]->updateCurrentTimeStepAndRedraw();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private:
|
||||
RimCase* m_currentReservoir;
|
||||
std::vector< std::vector<double> >* m_scalarResultsToAdd;
|
||||
size_t m_currentGridIndex;
|
||||
size_t m_currentScalarIndex;
|
||||
QString m_currentPropertyName;
|
||||
std::vector<size_t> m_requestedTimesteps;
|
||||
RifReaderInterface::PorosityModelResultType m_porosityModelEnum;
|
||||
|
||||
quint64 m_timeStepCountToRead;
|
||||
quint64 m_bytesPerTimeStepToRead;
|
||||
size_t m_currentTimeStepNumberToRead;
|
||||
|
||||
bool m_invalidDataDetected;
|
||||
};
|
||||
|
||||
static bool RiaSetGridProperty_init = RiaSocketCommandFactory::instance()->registerCreator<RiaSetGridProperty>(RiaSetGridProperty::commandName());
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Socket commands, to be moved into a separate file
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class RiaSocketServer;
|
||||
class QTcpSocket;
|
||||
|
||||
class RiaSocketCommand
|
||||
{
|
||||
public:
|
||||
virtual ~RiaSocketCommand() {}
|
||||
virtual bool interpretCommand(RiaSocketServer* server, const QList<QByteArray>& args, QDataStream& socketStream) = 0;
|
||||
virtual bool interpretMore(RiaSocketServer* server, QTcpSocket* currentClient) { return true; }
|
||||
};
|
||||
|
||||
#include "cafFactory.h"
|
||||
typedef caf::Factory<RiaSocketCommand, QString> RiaSocketCommandFactory;
|
||||
|
||||
|
||||