Updated to version 0.8.0

This commit is contained in:
unknown 2012-06-26 16:10:41 +02:00
parent 80dbfbaf1f
commit 2c9695e594
327 changed files with 15604 additions and 21837 deletions

View File

@ -1,28 +0,0 @@
//
// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
// The one and only version info for the application
// The application should use STRPRODUCTVER to display product version information
//
// The PRODUCTVER define is used in VersionInfo block fields FILEVERSION, PRODUCTVERSION and "FileVersion"
// The STRPRODUCTVER define is used in VersionInfo block fields "ProductVersion"
// See file "*.rc2"
//
// PRODUCTVER define contains : <major version>, <minor version>, <unused>, <build number>
//
// Externally shipped versions should have even build numbers
#define PRODUCTVER "0,4,0,8"
#define STRPRODUCTVER "0.4.8"

View File

@ -35,17 +35,17 @@
#include "RIProcessMonitor.h"
#include "RIPreferences.h"
#include "RimReservoir.h"
#include "RimResultReservoir.h"
#include "RimInputReservoir.h"
#include "RimReservoirView.h"
#include "RigReservoir.h"
#include "RigCell.h"
#include "RigReservoirBuilderMock.h"
#include "RimReservoirView.h"
#include <QSettings>
#include "cafPdmDocument.h"
#include "RifReaderInterfaceMock.h"
#include "RifReaderMockModel.h"
#include "cafCeetronNavigation.h"
#include "cafCadNavigation.h"
@ -149,7 +149,7 @@ void RIApplication::setWindowCaptionFromAppState()
#endif
{
QString projFileName = m_currentProjectFileName;
QString projFileName = m_project->fileName();
if (projFileName.isEmpty()) projFileName = "Untitled project";
capt = projFileName + QString("[*]") + QString(" - ") + capt;
@ -222,7 +222,6 @@ bool RIApplication::loadProject(const QString& projectFileName)
}
else
{
m_currentProjectFileName = projectFileName;
m_preferences->lastUsedProjectFileName = projectFileName;
writePreferences();
@ -263,13 +262,15 @@ bool RIApplication::loadLastUsedProject()
//--------------------------------------------------------------------------------------------------
bool RIApplication::saveProject()
{
if (!QFile::exists(m_currentProjectFileName))
CVF_ASSERT(m_project.notNull());
if (!QFile::exists(m_project->fileName()))
{
return saveProjectPromptForFileName();
}
else
{
return saveProjectAs(m_currentProjectFileName);
return saveProjectAs(m_project->fileName());
}
}
@ -282,9 +283,9 @@ bool RIApplication::saveProjectPromptForFileName()
//if (m_project.isNull()) return true;
QString startPath;
if (!m_currentProjectFileName.isEmpty())
if (!m_project->fileName().isEmpty())
{
QFileInfo fi(m_currentProjectFileName);
QFileInfo fi(m_project->fileName());
startPath = fi.absolutePath();
}
else
@ -316,7 +317,6 @@ bool RIApplication::saveProjectAs(const QString& fileName)
m_project->fileName = fileName;
m_project->writeFile();
m_currentProjectFileName = fileName;
m_preferences->lastUsedProjectFileName = fileName;
writePreferences();
@ -380,9 +380,9 @@ void RIApplication::onProjectOpenedOrClosed()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RIApplication::lastProjectFileName() const
QString RIApplication::currentProjectFileName() const
{
return "";
return m_project->fileName();
}
@ -395,24 +395,27 @@ bool RIApplication::openEclipseCaseFromFile(const QString& fileName)
QFileInfo gridFileName(fileName);
QString caseName = gridFileName.completeBaseName();
QString casePath = gridFileName.absolutePath();
return openEclipseCase(caseName, casePath);
return openEclipseCase(caseName, fileName);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RIApplication::openEclipseCase(const QString& caseName, const QString& casePath)
bool RIApplication::openEclipseCase(const QString& caseName, const QString& caseFileName)
{
RimReservoir* rimReservoir = new RimReservoir();
rimReservoir->caseName = caseName;
rimReservoir->caseDirectory = casePath;
QFileInfo gridFileName(caseFileName);
QString casePath = gridFileName.absolutePath();
m_project->reservoirs.push_back(rimReservoir);
RimResultReservoir* rimResultReservoir = new RimResultReservoir();
rimResultReservoir->caseName = caseName;
rimResultReservoir->caseFileName = caseFileName;
rimResultReservoir->caseDirectory = casePath;
RimReservoirView* riv = rimReservoir->createAndAddReservoirView();
m_project->reservoirs.push_back(rimResultReservoir);
RimReservoirView* riv = rimResultReservoir->createAndAddReservoirView();
// Select SOIL as default result variable
riv->cellResult()->resultType = RimDefines::DYNAMIC_NATIVE;
@ -423,7 +426,36 @@ bool RIApplication::openEclipseCase(const QString& caseName, const QString& case
if (!riv->cellResult()->hasResult())
{
riv->cellResult()->resultVariable = "";
riv->cellResult()->resultVariable = RimDefines::nonSelectedResultName();
}
onProjectOpenedOrClosed();
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RIApplication::openInputEclipseCase(const QString& caseName, const QStringList& caseFileNames)
{
RimInputReservoir* rimInputReservoir = new RimInputReservoir();
rimInputReservoir->caseName = caseName;
rimInputReservoir->openDataFileSet(caseFileNames);
m_project->reservoirs.push_back(rimInputReservoir);
RimReservoirView* riv = rimInputReservoir->createAndAddReservoirView();
riv->cellResult()->resultType = RimDefines::INPUT_PROPERTY;
riv->animationMode = true;
riv->loadDataAndUpdate();
if (!riv->cellResult()->hasResult())
{
riv->cellResult()->resultVariable = RimDefines::nonSelectedResultName();
}
onProjectOpenedOrClosed();
@ -438,7 +470,7 @@ bool RIApplication::openEclipseCase(const QString& caseName, const QString& case
//--------------------------------------------------------------------------------------------------
void RIApplication::createMockModel()
{
openEclipseCase("Mock Debug Model Simple", "");
openEclipseCase("Result Mock Debug Model Simple", "Result Mock Debug Model Simple");
}
//--------------------------------------------------------------------------------------------------
@ -446,7 +478,7 @@ void RIApplication::createMockModel()
//--------------------------------------------------------------------------------------------------
void RIApplication::createResultsMockModel()
{
openEclipseCase("Mock Debug Model With Results", "");
openEclipseCase("Result Mock Debug Model With Results", "Result Mock Debug Model With Results");
}
@ -455,9 +487,16 @@ void RIApplication::createResultsMockModel()
//--------------------------------------------------------------------------------------------------
void RIApplication::createLargeResultsMockModel()
{
openEclipseCase("Mock Debug Model Large With Results", "");
openEclipseCase("Result Mock Debug Model Large With Results", "Result Mock Debug Model Large With Results");
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RIApplication::createInputMockModel()
{
openInputEclipseCase("Input Mock Debug Model Simple", QStringList("Input Mock Debug Model Simple"));
}
//--------------------------------------------------------------------------------------------------
///

View File

@ -73,11 +73,14 @@ public:
void createMockModel();
void createResultsMockModel();
void createLargeResultsMockModel();
void createInputMockModel();
bool openEclipseCaseFromFile(const QString& fileName);
bool openEclipseCase(const QString& caseName, const QString& casePath);
bool openEclipseCase(const QString& caseName, const QString& caseFileName);
bool openInputEclipseCase(const QString& caseName, const QStringList& caseFileNames);
bool loadLastUsedProject();
QString lastProjectFileName() const;
QString currentProjectFileName() const;
bool loadProject(const QString& fileName);
bool saveProject();
bool saveProjectAs(const QString& fileName);
@ -110,6 +113,7 @@ private:
void onProjectOpenedOrClosed();
void setWindowCaptionFromAppState();
private slots:
void slotWorkerProcessFinished(int exitCode, QProcess::ExitStatus exitStatus);
@ -119,7 +123,6 @@ private:
caf::PdmPointer<RimReservoirView> m_activeReservoirView;
caf::PdmPointer<RimProject> m_project;
QString m_currentProjectFileName;
RiaSocketServer* m_socketServer;
caf::UiProcess* m_workerProcess;

View File

@ -18,6 +18,7 @@
#include "RIStdInclude.h"
#include "RIPreferences.h"
#include "cafPdmUiFilePathEditor.h"
CAF_PDM_SOURCE_INIT(RIPreferences, "RIPreferences");
//--------------------------------------------------------------------------------------------------
@ -28,14 +29,19 @@ RIPreferences::RIPreferences(void)
CAF_PDM_InitField(&navigationPolicy, "navigationPolicy", caf::AppEnum<RIApplication::RINavigationPolicy>(RIApplication::NAVIGATION_POLICY_CAD), "Navigation mode", "", "", "");
CAF_PDM_InitFieldNoDefault(&scriptDirectory, "scriptDirectory", "Shared Script Folder", "", "", "");
scriptDirectory.setUiEditorTypeName(caf::PdmUiFilePathEditor::uiEditorTypeName());
CAF_PDM_InitField(&scriptEditorExecutable, "scriptEditorExecutable", QString("kate"), "Script Editor", "", "", "");
scriptEditorExecutable.setUiEditorTypeName(caf::PdmUiFilePathEditor::uiEditorTypeName());
CAF_PDM_InitField(&octaveExecutable, "octaveExecutable", QString("octave"), "Octave", "", "", "");
octaveExecutable.setUiEditorTypeName(caf::PdmUiFilePathEditor::uiEditorTypeName());
CAF_PDM_InitField(&useShaders, "useShaders", true, "Use Shaders", "", "", "");
CAF_PDM_InitField(&showHud, "showHud", true, "Show 3D Information", "", "", "");
CAF_PDM_InitFieldNoDefault(&lastUsedProjectFileName,"lastUsedProjectFileName", "Last Used Project File", "", "", "");
lastUsedProjectFileName.setHidden(true);
lastUsedProjectFileName.setUiHidden(true);
}
//--------------------------------------------------------------------------------------------------
@ -45,3 +51,19 @@ RIPreferences::~RIPreferences(void)
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RIPreferences::defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute * attribute)
{
if (field == &scriptDirectory)
{
caf::PdmUiFilePathEditorAttribute* myAttr = static_cast<caf::PdmUiFilePathEditorAttribute*>(attribute);
if (myAttr)
{
myAttr->m_selectDirectory = true;
}
}
}

View File

@ -40,4 +40,7 @@ public: // Pdm Fields
caf::PdmField<bool> showHud;
caf::PdmField<QString> lastUsedProjectFileName;
protected:
virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute);
};

View File

@ -2,7 +2,19 @@ cmake_minimum_required (VERSION 2.8)
project (ApplicationCode)
CONFIGURE_FILE( ${CMAKE_SOURCE_DIR}/ApplicationCode/Adm/RIVersionInfo.h.cmake ${CMAKE_SOURCE_DIR}/ApplicationCode/Adm/RIVersionInfo.h)
# NB: The generated file is written to Cmake binary folder to avoid source tree pollution
# This folder is added to include_directories
CONFIGURE_FILE( ${CMAKE_SOURCE_DIR}/ApplicationCode/Adm/RIVersionInfo.h.cmake
${CMAKE_BINARY_DIR}/Generated/RIVersionInfo.h
)
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set ( ERT_ROOT "Ert" )
elseif (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
set ( ERT_ROOT "Ert-windows" )
endif()
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}
@ -14,10 +26,12 @@ include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/UserInterface
${CMAKE_CURRENT_SOURCE_DIR}/ProjectDataModel
${CMAKE_CURRENT_SOURCE_DIR}/ReservoirDataModel
${CMAKE_CURRENT_SOURCE_DIR}/../ThirdParty/Ert/ecl/include
${CMAKE_CURRENT_SOURCE_DIR}/../ThirdParty/Ert/util/include
${CMAKE_CURRENT_SOURCE_DIR}/../ThirdParty/Ert/geometry/include
${CMAKE_CURRENT_SOURCE_DIR}/../ThirdParty/Ert/well/include
${CMAKE_CURRENT_SOURCE_DIR}/../ThirdParty/${ERT_ROOT}/ecl/include
${CMAKE_CURRENT_SOURCE_DIR}/../ThirdParty/${ERT_ROOT}/util/include
${CMAKE_CURRENT_SOURCE_DIR}/../ThirdParty/${ERT_ROOT}/geometry/include
${CMAKE_CURRENT_SOURCE_DIR}/../ThirdParty/${ERT_ROOT}/well/include
${CMAKE_BINARY_DIR}/Generated
)
@ -46,12 +60,14 @@ list( APPEND CPP_SOURCES
)
list( APPEND CPP_SOURCES
FileInterface/RifReaderEclipseFileAccess.cpp
FileInterface/RifReaderEclipseRestartFiles.cpp
FileInterface/RifReaderEclipseResultAccess.cpp
FileInterface/RifReaderEclipseUnifiedRestartFile.cpp
FileInterface/RifReaderInterfaceEcl.cpp
FileInterface/RifReaderInterfaceMock.cpp
FileInterface/RifEclipseInputFileTools.cpp
FileInterface/RifEclipseOutputFileTools.cpp
FileInterface/RifEclipseRestartFilesetAccess.cpp
FileInterface/RifEclipseRestartDataAccess.cpp
FileInterface/RifEclipseUnifiedRestartFileAccess.cpp
FileInterface/RifReaderEclipseInput.cpp
FileInterface/RifReaderEclipseOutput.cpp
FileInterface/RifReaderMockModel.cpp
)
list( APPEND CPP_SOURCES
@ -68,15 +84,23 @@ list( APPEND CPP_SOURCES
ProjectDataModel/RimLegendConfig.cpp
ProjectDataModel/RimProject.cpp
ProjectDataModel/RimReservoir.cpp
ProjectDataModel/RimInputProperty.cpp
ProjectDataModel/RimInputPropertyCollection.cpp
ProjectDataModel/RimInputReservoir.cpp
ProjectDataModel/RimResultReservoir.cpp
ProjectDataModel/RimReservoirView.cpp
ProjectDataModel/RimResultDefinition.cpp
ProjectDataModel/RimResultSlot.cpp
ProjectDataModel/RimCellEdgeResultSlot.cpp
ProjectDataModel/RimUiTreeModelPdm.cpp
ProjectDataModel/RimWell.cpp
ProjectDataModel/RimWellCollection.cpp
ProjectDataModel/RimScriptCollection.cpp
ProjectDataModel/RimCalcScript.cpp
ProjectDataModel/RimExportInputPropertySettings.cpp
ProjectDataModel/RimBinaryExportSettings.cpp
ProjectDataModel/RimUiTreeModelPdm.cpp
ProjectDataModel/RimUiTreeView.cpp
)
list( APPEND CPP_SOURCES
@ -103,7 +127,10 @@ list( APPEND CPP_SOURCES
# Define files for MOC-ing
set ( QT_MOC_HEADERS
Application/RIApplication.h
ProjectDataModel/RimUiTreeModelPdm.h
ProjectDataModel/RimUiTreeView.h
UserInterface/RIMainWindow.h
UserInterface/RIPreferencesDialog.h
UserInterface/RIResultInfoPanel.h
@ -144,11 +171,13 @@ list( REMOVE_ITEM RAW_SOURCES ModelVisualization/RivWellHeadPartMgr.cpp)
list( REMOVE_ITEM RAW_SOURCES
FileInterface/RifReaderEclipseFileAccess.cpp
FileInterface/RifReaderEclipseRestartFiles.cpp
FileInterface/RifReaderEclipseResultAccess.cpp
FileInterface/RifReaderEclipseUnifiedRestartFile.cpp
FileInterface/RifReaderInterfaceEcl.cpp
FileInterface/RifEclipseInputFileTools.cpp
FileInterface/RifEclipseOutputFileTools.cpp
FileInterface/RifEclipseRestartFilesetAccess.cpp
FileInterface/RifEclipseRestartDataAccess.cpp
FileInterface/RifEclipseUnifiedRestartFileAccess.cpp
FileInterface/RifReaderEclipseInput.cpp
FileInterface/RifReaderEclipseOutput.cpp
)
include( CustomPCH.cmake )
@ -183,13 +212,12 @@ add_executable(ResInsight
set( LINK_LIBRARIES
cafProjectDataModel
cafPdmCvf
cafUserInterface
cafViewer
cafAnimControl
cafProjectDataModel
cafViewer
cafAnimControl
CommonCode
QtPropertyBrowser
LibGuiQt
LibViewing
LibRender
@ -199,33 +227,54 @@ set( LINK_LIBRARIES
${QT_LIBRARIES}
)
IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set ( LINUX_LINK_LIBRARIES
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set ( EXTERNAL_LINK_LIBRARIES
${CMAKE_CURRENT_SOURCE_DIR}/../ThirdParty/Ert/ecl/lib/libecl.a
${CMAKE_CURRENT_SOURCE_DIR}/../ThirdParty/Ert/util/lib/libutil.a
${CMAKE_CURRENT_SOURCE_DIR}/../ThirdParty/Ert/geometry/lib/libgeometry.a
${CMAKE_CURRENT_SOURCE_DIR}/../ThirdParty/Ert/well/lib/libwell.a
lapack
)
ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
set ( EXTERNAL_LINK_LIBRARIES
${CMAKE_CURRENT_SOURCE_DIR}/../ThirdParty/Ert-windows/ecl/lib/libecl.lib
${CMAKE_CURRENT_SOURCE_DIR}/../ThirdParty/Ert-windows/util/lib/libutil.lib
${CMAKE_CURRENT_SOURCE_DIR}/../ThirdParty/Ert-windows/geometry/lib/libgeometry.lib
${CMAKE_CURRENT_SOURCE_DIR}/../ThirdParty/Ert-windows/well/lib/libwell.lib
)
endif()
target_link_libraries( ResInsight ${LINK_LIBRARIES} ${LINUX_LINK_LIBRARIES})
target_link_libraries( ResInsight ${LINK_LIBRARIES} ${EXTERNAL_LINK_LIBRARIES})
# Copy Qt Dlls
# Copy Dlls
if (MSVC)
set (QTLIBLIST QtCore QtGui QtOpenGl QtNetwork)
# Qt DLLs
set (QTLIBLIST QtCore QtCored QtGui QtGuid QtOpenGl QtOpenGld QtNetwork QtNetworkd)
foreach (qtlib ${QTLIBLIST})
# Debug
execute_process(COMMAND cmake -E copy_if_different ${QT_BINARY_DIR}/${qtlib}d4.dll ${CMAKE_CURRENT_BINARY_DIR}/Debug/${qtlib}d4.dll)
# Release
execute_process(COMMAND cmake -E copy_if_different ${QT_BINARY_DIR}/${qtlib}4.dll ${CMAKE_CURRENT_BINARY_DIR}/Release/${qtlib}4.dll)
# Release With debug info
execute_process(COMMAND cmake -E copy_if_different ${QT_BINARY_DIR}/${qtlib}4.dll ${CMAKE_CURRENT_BINARY_DIR}/RelWithDebInfo/${qtlib}4.dll)
add_custom_command(TARGET ResInsight POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"${QT_BINARY_DIR}/${qtlib}4.dll"
${CMAKE_CURRENT_BINARY_DIR}/$<CONFIGURATION>)
endforeach( qtlib )
# DLLs ERT depends on
add_custom_command(TARGET ResInsight POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
"${PROJECT_SOURCE_DIR}/../ThirdParty/Ert-windows/bin/"
${CMAKE_CURRENT_BINARY_DIR}/$<CONFIGURATION>)
# ERT DLLs
set (ERT_MODULES ecl geometry util well)
foreach (ert_module ${ERT_MODULES})
add_custom_command(TARGET ResInsight POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"${CMAKE_CURRENT_SOURCE_DIR}/../ThirdParty/Ert-windows/${ert_module}/lib/lib${ert_module}.dll"
${CMAKE_CURRENT_BINARY_DIR}/$<CONFIGURATION>)
endforeach()
endif(MSVC)
#############################################################################
@ -234,16 +283,15 @@ endif(MSVC)
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set_target_properties(ResInsight PROPERTIES INSTALL_RPATH "${RESINSIGHT_FINAL_INSTALL_PATH};.")
set (RESINSIGHT_FILES
${QT_LIBRARY_DIR}/libQtCore.so.4.7.3
${QT_LIBRARY_DIR}/libQtGui.so.4.7.3
${QT_LIBRARY_DIR}/libQtOpenGL.so.4.7.3
${QT_LIBRARY_DIR}/libQtNetwork.so.4.7.3
${QT_LIBRARY_DIR}/libQtCore.so.4
${QT_LIBRARY_DIR}/libQtGui.so.4
${QT_LIBRARY_DIR}/libQtOpenGL.so.4
${QT_LIBRARY_DIR}/libQtNetwork.so.4
# Find Qt libraries and sym links
file (GLOB RESINSIGHT_FILES
${QT_LIBRARY_DIR}/libQtCore.so*
${QT_LIBRARY_DIR}/libQtGui.so*
${QT_LIBRARY_DIR}/libQtOpenGL.so*
${QT_LIBRARY_DIR}/libQtNetwork.so*
)
endif()
if (${CMAKE_SYSTEM_NAME} MATCHES "Windows")

View File

@ -7,6 +7,12 @@ project ( ${ProjectName} )
find_package (Qt4 COMPONENTS QtCore QtGui QtMain QtOpenGl REQUIRED)
include (${QT_USE_FILE})
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set ( ERT_ROOT "Ert" )
elseif (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
set ( ERT_ROOT "Ert-windows" )
endif()
include_directories(
${LibCore_SOURCE_DIR}
${LibGeometry_SOURCE_DIR}
@ -23,19 +29,22 @@ include_directories(
${ResInsight_SOURCE_DIR}/CommonCode
${ResInsight_SOURCE_DIR}/ThirdParty/Ert/ecl/include
${ResInsight_SOURCE_DIR}/ThirdParty/Ert/util/include
${ResInsight_SOURCE_DIR}/ThirdParty/Ert/well/include
${ResInsight_SOURCE_DIR}/ThirdParty/${ERT_ROOT}/ecl/include
${ResInsight_SOURCE_DIR}/ThirdParty/${ERT_ROOT}/util/include
${ResInsight_SOURCE_DIR}/ThirdParty/${ERT_ROOT}/well/include
)
set( FILEINTERFACE_CPP_SOURCES
../RifReaderEclipseFileAccess.cpp
../RifReaderEclipseRestartFiles.cpp
../RifReaderEclipseResultAccess.cpp
../RifReaderEclipseUnifiedRestartFile.cpp
../RifReaderInterfaceEcl.cpp
../RifReaderInterfaceMock.cpp
../RifEclipseInputFileTools.cpp
../RifEclipseOutputFileTools.cpp
../RifEclipseRestartFilesetAccess.cpp
../RifEclipseRestartDataAccess.cpp
../RifEclipseUnifiedRestartFileAccess.cpp
../RifReaderEclipseOutput.cpp
../RifReaderEclipseInput.cpp
../RifReaderMockModel.cpp
)
set( RESERVOIRDATAMODEL_CPP_SOURCES
@ -47,6 +56,7 @@ set( RESERVOIRDATAMODEL_CPP_SOURCES
${ResInsight_SOURCE_DIR}/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.cpp
${ResInsight_SOURCE_DIR}/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.cpp
${ResInsight_SOURCE_DIR}/ApplicationCode/ReservoirDataModel/RigWellResults.cpp
${ResInsight_SOURCE_DIR}/cafUserInterface/cafProgressInfo.cpp
)
set( CPP_SOURCES
@ -59,7 +69,7 @@ source_group( "ReservoirDataModel" FILES ${RESERVOIRDATAMODEL_CPP_SOURCES} )
set( UNIT_TEST_CPP_SOURCES
main.cpp
RifReaderInterfaceEcl-Test.cpp
RifReaderEclipseOutput-Test.cpp
Ert-Test.cpp
)
@ -76,6 +86,7 @@ set( LINK_LIBRARIES
)
add_executable( ${ProjectName}
${CPP_SOURCES}
${UNIT_TEST_CPP_SOURCES}
@ -85,35 +96,55 @@ add_executable( ${ProjectName}
IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set ( LINUX_LINK_LIBRARIES
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set ( EXTERNAL_LINK_LIBRARIES
${CMAKE_CURRENT_SOURCE_DIR}/../../../ThirdParty/Ert/ecl/lib/libecl.a
${CMAKE_CURRENT_SOURCE_DIR}/../../../ThirdParty/Ert/util/lib/libutil.a
${CMAKE_CURRENT_SOURCE_DIR}/../../../ThirdParty/Ert/geometry/lib/libgeometry.a
${CMAKE_CURRENT_SOURCE_DIR}/../../../ThirdParty/Ert/well/lib/libwell.a
lapack
)
# Linux specific code
set(CMAKE_CXX_FLAGS "-DCVF_LINUX -DUSE_ECL_LIB -pipe -Wextra -Woverloaded-virtual -Wformat")
set(CMAKE_CXX_FLAGS_DEBUG "-g -DDEBUG -D_DEBUG")
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNO_DEBUG")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp")
ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
elseif (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
set ( EXTERNAL_LINK_LIBRARIES
${CMAKE_CURRENT_SOURCE_DIR}/../../../ThirdParty/Ert-windows/ecl/lib/libecl.lib
${CMAKE_CURRENT_SOURCE_DIR}/../../../ThirdParty/Ert-windows/util/lib/libutil.lib
${CMAKE_CURRENT_SOURCE_DIR}/../../../ThirdParty/Ert-windows/geometry/lib/libgeometry.lib
${CMAKE_CURRENT_SOURCE_DIR}/../../../ThirdParty/Ert-windows/well/lib/libwell.lib
)
endif()
target_link_libraries( ${ProjectName} ${LINK_LIBRARIES} ${LINUX_LINK_LIBRARIES})
target_link_libraries( ${ProjectName} ${LINK_LIBRARIES} ${EXTERNAL_LINK_LIBRARIES})
# Copy Qt Dlls
# Copy Dlls
if (MSVC)
set (QTLIBLIST QtCore QtGui QtOpenGl)
# Qt DLLs
set (QTLIBLIST QtCore QtCored QtGui QtGuid QtOpenGl QtOpenGld QtNetwork QtNetworkd)
foreach (qtlib ${QTLIBLIST})
# Debug
execute_process(COMMAND cmake -E copy_if_different ${QT_BINARY_DIR}/${qtlib}d4.dll ${CMAKE_CURRENT_BINARY_DIR}/Debug/${qtlib}d4.dll)
# Release
execute_process(COMMAND cmake -E copy_if_different ${QT_BINARY_DIR}/${qtlib}4.dll ${CMAKE_CURRENT_BINARY_DIR}/Release/${qtlib}4.dll)
add_custom_command(TARGET ${ProjectName} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"${QT_BINARY_DIR}/${qtlib}4.dll"
${CMAKE_CURRENT_BINARY_DIR}/$<CONFIGURATION>)
endforeach( qtlib )
# DLLs ERT depends on
add_custom_command(TARGET ${ProjectName} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
"${PROJECT_SOURCE_DIR}/../../../ThirdParty/Ert-windows/bin/"
${CMAKE_CURRENT_BINARY_DIR}/$<CONFIGURATION>)
# ERT DLLs
set (ERT_MODULES ecl geometry util well)
foreach (ert_module ${ERT_MODULES})
add_custom_command(TARGET ${ProjectName} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"${CMAKE_CURRENT_SOURCE_DIR}/../../../ThirdParty/Ert-windows/${ert_module}/lib/lib${ert_module}.dll"
${CMAKE_CURRENT_BINARY_DIR}/$<CONFIGURATION>)
endforeach()
endif(MSVC)

View File

@ -38,8 +38,10 @@
#include "gtest/gtest.h"
#include "RigReservoir.h"
#include "RifReaderEclipseInput.h"
#if 0
//--------------------------------------------------------------------------------------------------
/// This file contains test code taken from the test cases in ERT source code.
// There is a typedef issue (center) between ERT and QTextStream, so this file does not include any
@ -47,7 +49,7 @@
//--------------------------------------------------------------------------------------------------
TEST(RigReservoirTest, WellTestErt)
{
char filename[1024] = "/mnt/hgfs/Statoil/testcase_juli_2011/data/TEST10K_FLT_LGR_NNC.UNRST";
char filename[1024] = "TEST10K_FLT_LGR_NNC.UNRST";
well_info_type * well_info = well_info_alloc( NULL );
well_info_load_rstfile( well_info , filename);
@ -100,5 +102,20 @@ TEST(RigReservoirTest, WellTestErt)
well_info_free( well_info );
}
#endif
//--------------------------------------------------------------------------------------------------
/// This file contains test code taken from the test cases in ERT source code.
// There is a typedef issue (center) between ERT and QTextStream, so this file does not include any
// Qt files.
//--------------------------------------------------------------------------------------------------
TEST(RigReservoirTest, ElipseInputGridFile)
{
RigReservoir res;
RifReaderEclipseInput inputReader;
bool result = inputReader.open("TEST10K_FLT_LGR_NNC.grdecl", &res);
EXPECT_TRUE(result);
EXPECT_EQ(size_t(1), res.mainGrid()->cells().size());
EXPECT_EQ(size_t(1), res.mainGrid()->numActiveCells());
}
#endif //USE_ECL_LIB

View File

@ -23,18 +23,67 @@
#include "RigReservoir.h"
#include "RifReaderInterfaceEcl.h"
#include "RifReaderEclipseOutput.h"
//#include "RifEclipseUnifiedRestartFileAccess.h"
/*
TEST(RigReservoirTest, UnifiedTestFile)
{
// Location of test dataset received from Håkon Høgstøl in July 2011 with 10k active cells
#ifdef WIN32
QString filename("d:/Models/Statoil/testcase_juli_2011/data/TEST10K_FLT_LGR_NNC.UNRST");
#else
QString filename("/mnt/hgfs/Statoil/testcase_juli_2011/data/TEST10K_FLT_LGR_NNC.UNRST");
#endif
size_t numActiveCells = 11125;
size_t numGrids = 2;
{
cvf::ref<RifEclipseUnifiedRestartFileAccess> restartFile = new RifEclipseUnifiedRestartFileAccess(numGrids, numActiveCells);
QStringList fileNameList;
fileNameList << filename;
restartFile->open(fileNameList);
QStringList resultNames = restartFile->resultNames();
qDebug() << "Result names\n" << resultNames;
QStringList timeStepText = restartFile->timeStepsText();
qDebug() << "Time step texts\n" << timeStepText;
std::vector<double> resultValues;
size_t timeStep = 0;
restartFile->results(resultNames[0], timeStep, &resultValues);
size_t i;
for (i = 0; i < 500; i++)
{
qDebug() << resultValues[i];
}
}
}
*/
#if 0
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
TEST(RigReservoirTest, BasicTest)
{
cvf::ref<RifReaderInterfaceECL> readerInterfaceEcl = new RifReaderInterfaceECL;
cvf::ref<RifReaderEclipseOutput> readerInterfaceEcl = new RifReaderEclipseOutput;
cvf::ref<RigReservoir> reservoir = new RigReservoir;
// Location of test dataset received from Håkon Høgstøl in July 2011 with 10k active cells
#ifdef WIN32
QString filename("TEST10K_FLT_LGR_NNC.EGRID");
#else
QString filename("/mnt/hgfs/Statoil/testcase_juli_2011/data/TEST10K_FLT_LGR_NNC.EGRID");
#endif
bool result = readerInterfaceEcl->open(filename, reservoir.p());
EXPECT_TRUE(result);
@ -83,17 +132,21 @@ TEST(RigReservoirTest, BasicTest)
//--------------------------------------------------------------------------------------------------
TEST(RigReservoirTest, WellTest)
{
cvf::ref<RifReaderInterfaceECL> readerInterfaceEcl = new RifReaderInterfaceECL;
cvf::ref<RifReaderEclipseOutput> readerInterfaceEcl = new RifReaderEclipseOutput;
cvf::ref<RigReservoir> reservoir = new RigReservoir;
// Location of test dataset received from Håkon Høgstøl in July 2011 with 10k active cells
#ifdef WIN32
QString filename("TEST10K_FLT_LGR_NNC.EGRID");
#else
QString filename("/mnt/hgfs/Statoil/testcase_juli_2011/data/TEST10K_FLT_LGR_NNC.EGRID");
#endif
bool result = readerInterfaceEcl->open(filename, reservoir.p());
EXPECT_TRUE(result);
cvf::UByteArray* mainGridWellCells = reservoir->wellCellsInGrid(0);
EXPECT_TRUE(mainGridWellCells->size() == reservoir->mainGrid()->cellCount());
}
#endif

View File

@ -0,0 +1,434 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RifEclipseInputFileTools.h"
#include "RifReaderEclipseOutput.h"
#include "RigReservoirCellResults.h"
#include "RigReservoir.h"
#include "cafProgressInfo.h"
#include <vector>
#include <cmath>
#include <iostream>
#include <QFile>
#include <QTextStream>
#ifdef USE_ECL_LIB
#include "ecl_grid.h"
#include "well_state.h"
#include "util.h"
#endif
#include <fstream>
//--------------------------------------------------------------------------------------------------
/// Constructor
//--------------------------------------------------------------------------------------------------
RifEclipseInputFileTools::RifEclipseInputFileTools()
{
}
//--------------------------------------------------------------------------------------------------
/// Destructor
//--------------------------------------------------------------------------------------------------
RifEclipseInputFileTools::~RifEclipseInputFileTools()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RifEclipseInputFileTools::openGridFile(const QString& fileName, RigReservoir* reservoir)
{
CVF_ASSERT(reservoir);
FILE* gridFilePointer = util_fopen(fileName.toLatin1().data(), "r");
if (!gridFilePointer) return false;
// Main grid Dimentions
// SPECGRID - This is whats normally available, but not really the input to Eclipse.
// DIMENS - Is what Eclipse expects and uses, but is not defined in the GRID section and is not (?) available normally
// ZCORN, COORD, ACTNUM, MAPAXES
//ecl_kw_type * ecl_kw_fscanf_alloc_grdecl_dynamic__( FILE * stream , const char * kw , bool strict , ecl_type_enum ecl_type);
//ecl_grid_type * ecl_grid_alloc_GRDECL_kw( int nx, int ny , int nz , const ecl_kw_type * zcorn_kw , const ecl_kw_type * coord_kw , const ecl_kw_type * actnum_kw , const ecl_kw_type * mapaxes_kw );
ecl_kw_type* specGridKw = NULL;
ecl_kw_type* zCornKw = NULL;
ecl_kw_type* coordKw = NULL;
ecl_kw_type* actNumKw = NULL;
ecl_kw_type* mapAxesKw = NULL;
// Try to read all the needed keywords. Early exit if some are not found
caf::ProgressInfo progress(7, "Read Grid from Eclipse Input file");
bool allKwReadOk = true;
allKwReadOk = allKwReadOk && NULL != (specGridKw = ecl_kw_fscanf_alloc_grdecl_dynamic__( gridFilePointer , "SPECGRID" , false , ECL_INT_TYPE));
progress.setProgress(1);
allKwReadOk = allKwReadOk && NULL != (zCornKw = ecl_kw_fscanf_alloc_grdecl_dynamic__( gridFilePointer , "ZCORN" , false , ECL_FLOAT_TYPE));
progress.setProgress(2);
allKwReadOk = allKwReadOk && NULL != (coordKw = ecl_kw_fscanf_alloc_grdecl_dynamic__( gridFilePointer , "COORD" , false , ECL_FLOAT_TYPE));
progress.setProgress(3);
allKwReadOk = allKwReadOk && NULL != (actNumKw = ecl_kw_fscanf_alloc_grdecl_dynamic__( gridFilePointer , "ACTNUM" , false , ECL_INT_TYPE));
progress.setProgress(4);
allKwReadOk = allKwReadOk && NULL != (mapAxesKw = ecl_kw_fscanf_alloc_grdecl_dynamic__( gridFilePointer , "MAPAXES" , false , ECL_FLOAT_TYPE));
if (!allKwReadOk)
{
if(specGridKw) ecl_kw_free(specGridKw);
if(zCornKw) ecl_kw_free(zCornKw);
if(coordKw) ecl_kw_free(coordKw);
if(actNumKw) ecl_kw_free(actNumKw);
if(mapAxesKw) ecl_kw_free(mapAxesKw);
return false;
}
progress.setProgress(5);
int nx = ecl_kw_iget_int(specGridKw, 0);
int ny = ecl_kw_iget_int(specGridKw, 1);
int nz = ecl_kw_iget_int(specGridKw, 2);
ecl_grid_type* inputGrid = ecl_grid_alloc_GRDECL_kw( nx, ny, nz, zCornKw, coordKw, actNumKw, mapAxesKw );
progress.setProgress(6);
RifReaderEclipseOutput::transferGeometry(inputGrid, reservoir);
progress.setProgress(7);
progress.setProgressDescription("Cleaning up ...");
ecl_kw_free(specGridKw);
ecl_kw_free(zCornKw);
ecl_kw_free(coordKw);
ecl_kw_free(actNumKw);
ecl_kw_free(mapAxesKw);
ecl_grid_free(inputGrid);
util_fclose(gridFilePointer);
return true;
}
//--------------------------------------------------------------------------------------------------
/// Read known properties from the input file
//--------------------------------------------------------------------------------------------------
std::map<QString, QString> RifEclipseInputFileTools::readProperties(const QString &fileName, RigReservoir *reservoir)
{
CVF_ASSERT(reservoir);
std::set<QString> knownKeywordSet;
{
const std::vector<QString>& knownKeywords = RifEclipseInputFileTools::knownPropertyKeywords();
for( size_t fkIt = 0; fkIt < knownKeywords.size(); ++fkIt) knownKeywordSet.insert(knownKeywords[fkIt]);
}
caf::ProgressInfo mainProgress(2, "Reading Eclipse Input properties");
caf::ProgressInfo startProgress(knownKeywordSet.size(), "Scanning for known properties");
std::vector<QString> fileKeywords = RifEclipseInputFileTools::findKeywordsOnFile(fileName);
mainProgress.setProgress(1);
caf::ProgressInfo progress(fileKeywords.size(), "Reading properties");
FILE* gridFilePointer = util_fopen(fileName.toLatin1().data(), "r");
if (!gridFilePointer || !fileKeywords.size() )
{
return std::map<QString, QString>();
}
bool isSomethingRead = false;
std::map<QString, QString> newResults;
for (size_t i = 0; i < fileKeywords.size(); ++i)
{
std::cout << fileKeywords[i].toLatin1().data() << std::endl;
if (knownKeywordSet.count(fileKeywords[i]))
{
ecl_kw_type* eclKeyWordData = ecl_kw_fscanf_alloc_grdecl_dynamic__( gridFilePointer , fileKeywords[i].toLatin1().data() , false , ECL_FLOAT_TYPE);
if (eclKeyWordData)
{
QString newResultName = reservoir->mainGrid()->results()->makeResultNameUnique(fileKeywords[i]);
size_t resultIndex = reservoir->mainGrid()->results()->addEmptyScalarResult(RimDefines::INPUT_PROPERTY, newResultName); // Should really merge with inputProperty object information because we need to use PropertyName, and not keyword
std::vector< std::vector<double> >& newPropertyData = reservoir->mainGrid()->results()->cellScalarResults(resultIndex);
newPropertyData.push_back(std::vector<double>());
newPropertyData[0].resize(ecl_kw_get_size(eclKeyWordData), HUGE_VAL);
ecl_kw_get_data_as_double(eclKeyWordData, newPropertyData[0].data());
ecl_kw_free(eclKeyWordData);
newResults[newResultName] = fileKeywords[i];
}
}
progress.setProgress(i);
}
util_fclose(gridFilePointer);
return newResults;
}
//--------------------------------------------------------------------------------------------------
/// Read all the keywords from a file
//--------------------------------------------------------------------------------------------------
std::vector<QString> RifEclipseInputFileTools::findKeywordsOnFile(const QString &fileName)
{
std::vector<QString> keywords;
std::ifstream is(fileName.toLatin1().data());
while (is)
{
std::string word;
is >> word;
if (word.size() && isalpha(word[0]))
{
keywords.push_back(word.c_str());
}
is.ignore(20000, '\n');
}
is.close();
/*
FILE* gridFilePointer = util_fopen(fileName.toLatin1().data(), "r");
if (!gridFilePointer) return keywords;
char * keyWordString = NULL;
keyWordString = ecl_kw_grdecl_alloc_next_header(gridFilePointer);
while(keyWordString)
{
keywords.push_back(keyWordString);
util_realloc(keyWordString, 0, "RifEclipseInputFileTools::findKeywordsOnFile");
keyWordString = ecl_kw_grdecl_alloc_next_header(gridFilePointer);
}
util_fclose(gridFilePointer);
*/
return keywords;
}
//--------------------------------------------------------------------------------------------------
/// Reads the property data requested into the \a reservoir, overwriting any previous
/// propeties with the same name.
//--------------------------------------------------------------------------------------------------
bool RifEclipseInputFileTools::readProperty(const QString& fileName, RigReservoir* reservoir, const QString& eclipseKeyWord, const QString& resultName)
{
CVF_ASSERT(reservoir);
FILE* filePointer = util_fopen(fileName.toLatin1().data(), "r");
if (!filePointer) return false;
ecl_kw_type* eclKeyWordData = ecl_kw_fscanf_alloc_grdecl_dynamic__( filePointer , eclipseKeyWord.toLatin1().data() , false , ECL_FLOAT_TYPE);
bool isOk = false;
if (eclKeyWordData)
{
QString newResultName = resultName;
size_t resultIndex = reservoir->mainGrid()->results()->findScalarResultIndex(newResultName);
if (resultIndex == cvf::UNDEFINED_SIZE_T)
{
resultIndex = reservoir->mainGrid()->results()->addEmptyScalarResult(RimDefines::INPUT_PROPERTY, newResultName);
}
std::vector< std::vector<double> >& newPropertyData = reservoir->mainGrid()->results()->cellScalarResults(resultIndex);
newPropertyData.resize(1);
newPropertyData[0].resize(ecl_kw_get_size(eclKeyWordData), HUGE_VAL);
ecl_kw_get_data_as_double(eclKeyWordData, newPropertyData[0].data());
isOk = true;
ecl_kw_free(eclKeyWordData);
}
util_fclose(filePointer);
return isOk;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const std::vector<QString>& RifEclipseInputFileTools::knownPropertyKeywords()
{
static std::vector<QString> knownKeywords;
static bool isInitialized = false;
if (!isInitialized)
{
knownKeywords.push_back("AQUIFERA");
knownKeywords.push_back("ACTNUM");
knownKeywords.push_back("EQLNUM");
knownKeywords.push_back("FIPNUM");
knownKeywords.push_back("KRG");
knownKeywords.push_back("KRGR");
knownKeywords.push_back("KRO");
knownKeywords.push_back("KRORG");
knownKeywords.push_back("KRORW");
knownKeywords.push_back("KRW");
knownKeywords.push_back("KRWR");
knownKeywords.push_back("MINPVV");
knownKeywords.push_back("MULTPV");
knownKeywords.push_back("MULTX");
knownKeywords.push_back("MULTX-");
knownKeywords.push_back("MULTY");
knownKeywords.push_back("MULTY-");
knownKeywords.push_back("MULTZ");
knownKeywords.push_back("NTG");
knownKeywords.push_back("PCG");
knownKeywords.push_back("PCW");
knownKeywords.push_back("PERMX");
knownKeywords.push_back("PERMY");
knownKeywords.push_back("PERMZ");
knownKeywords.push_back("PORO");
knownKeywords.push_back("PVTNUM");
knownKeywords.push_back("SATNUM");
knownKeywords.push_back("SGCR");
knownKeywords.push_back("SGL");
knownKeywords.push_back("SGLPC");
knownKeywords.push_back("SGU");
knownKeywords.push_back("SGWCR");
knownKeywords.push_back("SWATINIT");
knownKeywords.push_back("SWCR");
knownKeywords.push_back("SWGCR");
knownKeywords.push_back("SWL");
knownKeywords.push_back("SWLPC");
knownKeywords.push_back("TRANX");
knownKeywords.push_back("TRANY");
knownKeywords.push_back("TRANZ");
isInitialized = true;
}
return knownKeywords;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RifEclipseInputFileTools::writePropertyToTextFile(const QString& fileName, RigReservoir* reservoir, size_t timeStep, const QString& resultName, const QString& eclipseKeyWord)
{
CVF_ASSERT(reservoir);
size_t resultIndex = reservoir->mainGrid()->results()->findScalarResultIndex(resultName);
if (resultIndex == cvf::UNDEFINED_SIZE_T)
{
return false;
}
QFile file(fileName);
if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
{
return false;
}
std::vector< std::vector<double> >& resultData = reservoir->mainGrid()->results()->cellScalarResults(resultIndex);
if (resultData.size() == 0)
{
return false;
}
std::vector<double>& singleTimeStepData = resultData[timeStep];
writeDataToTextFile(&file, eclipseKeyWord, singleTimeStepData);
return true;
}
//--------------------------------------------------------------------------------------------------
/// Create and write a result vector with values for all cells.
/// undefinedValue is used for cells with no result
//--------------------------------------------------------------------------------------------------
bool RifEclipseInputFileTools::writeBinaryResultToTextFile(const QString& fileName, RigReservoir* reservoir, size_t timeStep, const QString& resultName, const QString& eclipseKeyWord, const double undefinedValue)
{
CVF_ASSERT(reservoir);
size_t resultIndex = reservoir->mainGrid()->results()->findScalarResultIndex(resultName);
if (resultIndex == cvf::UNDEFINED_SIZE_T)
{
return false;
}
QFile file(fileName);
if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
{
return false;
}
std::vector<double> resultData;
size_t i, j, k;
for (k = 0; k < reservoir->mainGrid()->cellCountK(); k++)
{
for (j = 0; j < reservoir->mainGrid()->cellCountJ(); j++)
{
for (i = 0; i < reservoir->mainGrid()->cellCountI(); i++)
{
double resultValue = reservoir->mainGrid()->cellScalar(timeStep, resultIndex, i, j, k);
if (resultValue == HUGE_VAL)
{
resultValue = undefinedValue;
}
resultData.push_back(resultValue);
}
}
}
writeDataToTextFile(&file, eclipseKeyWord, resultData);
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RifEclipseInputFileTools::writeDataToTextFile(QFile* file, const QString& eclipseKeyWord, const std::vector<double>& resultData)
{
QTextStream out(file);
out << "\n";
out << "-- Exported from ResInsight" << "\n";
out << eclipseKeyWord << "\n" << right << qSetFieldWidth(16);
caf::ProgressInfo pi(resultData.size(), QString("Writing data to file %1").arg(file->fileName()) );
int progressSteps = resultData.size() / 20;
size_t i;
for (i = 0; i < resultData.size(); i++)
{
out << resultData[i];
if ( (i + 1) % 5 == 0)
{
out << "\n";
}
if (i % progressSteps == 0)
{
pi.setProgress(i);
}
}
out << "\n" << "/" << "\n";
}

View File

@ -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 "cvfBase.h"
#include "cvfObject.h"
#include "cvfLibCore.h"
#include <map>
class RigReservoir;
class QString;
class QFile;
//==================================================================================================
//
// Class for access to Eclipse "keyword" files using libecl
//
//==================================================================================================
class RifEclipseInputFileTools : public cvf::Object
{
public:
RifEclipseInputFileTools();
virtual ~RifEclipseInputFileTools();
static bool openGridFile(const QString& fileName, RigReservoir* reservoir);
// Returns map of assigned resultName and Eclipse Keyword.
static std::map<QString, QString> readProperties(const QString& fileName, RigReservoir* reservoir);
static bool readProperty (const QString& fileName, RigReservoir* reservoir, const QString& eclipseKeyWord, const QString& resultName );
static std::vector<QString> findKeywordsOnFile(const QString &fileName);
static const std::vector<QString>& knownPropertyKeywords();
static bool writePropertyToTextFile(const QString& fileName, RigReservoir* reservoir, size_t timeStep, const QString& resultName, const QString& eclipseKeyWord);
static bool writeBinaryResultToTextFile(const QString& fileName, RigReservoir* reservoir, size_t timeStep, const QString& resultName, const QString& eclipseKeyWord, const double undefinedValue);
private:
static void writeDataToTextFile(QFile* file, const QString& eclipseKeyWord, const std::vector<double>& resultData);
};

View File

@ -16,9 +16,10 @@
//
/////////////////////////////////////////////////////////////////////////////////
#include "RifReaderEclipseFileAccess.h"
#include "RifEclipseOutputFileTools.h"
#ifdef USE_ECL_LIB
#include "util.h"
#include "ecl_file.h"
#include "ecl_intehead.h"
#endif //USE_ECL_LIB
@ -28,7 +29,7 @@
//--------------------------------------------------------------------------------------------------
/// Constructor
//--------------------------------------------------------------------------------------------------
RifReaderEclipseFileAccess::RifReaderEclipseFileAccess()
RifEclipseOutputFileTools::RifEclipseOutputFileTools()
{
#ifdef USE_ECL_LIB
m_file = NULL;
@ -39,7 +40,7 @@ RifReaderEclipseFileAccess::RifReaderEclipseFileAccess()
//--------------------------------------------------------------------------------------------------
/// Destructor
//--------------------------------------------------------------------------------------------------
RifReaderEclipseFileAccess::~RifReaderEclipseFileAccess()
RifEclipseOutputFileTools::~RifEclipseOutputFileTools()
{
close();
}
@ -48,7 +49,7 @@ RifReaderEclipseFileAccess::~RifReaderEclipseFileAccess()
//--------------------------------------------------------------------------------------------------
/// Open file given by name
//--------------------------------------------------------------------------------------------------
bool RifReaderEclipseFileAccess::open(const QString& fileName)
bool RifEclipseOutputFileTools::open(const QString& fileName)
{
#ifdef USE_ECL_LIB
// Close current file if any
@ -67,7 +68,7 @@ bool RifReaderEclipseFileAccess::open(const QString& fileName)
//--------------------------------------------------------------------------------------------------
/// Close file
//--------------------------------------------------------------------------------------------------
void RifReaderEclipseFileAccess::close()
void RifEclipseOutputFileTools::close()
{
#ifdef USE_ECL_LIB
if (m_file)
@ -82,7 +83,7 @@ void RifReaderEclipseFileAccess::close()
//--------------------------------------------------------------------------------------------------
/// Get the number of occurrences of the given keyword
//--------------------------------------------------------------------------------------------------
size_t RifReaderEclipseFileAccess::numOccurrences(const QString& keyword)
size_t RifEclipseOutputFileTools::numOccurrences(const QString& keyword)
{
#ifdef USE_ECL_LIB
CVF_ASSERT(m_file);
@ -97,7 +98,7 @@ size_t RifReaderEclipseFileAccess::numOccurrences(const QString& keyword)
/// Get keywords found on file given by name.
/// If numDataItems > -1, get keywords with that exact number of data items only.
//--------------------------------------------------------------------------------------------------
bool RifReaderEclipseFileAccess::keywordsOnFile(QStringList* keywords, size_t numDataItems, size_t numSteps)
bool RifEclipseOutputFileTools::keywordsOnFile(QStringList* keywords, size_t numDataItems, size_t numSteps)
{
#ifdef USE_ECL_LIB
CVF_ASSERT(m_file);
@ -159,7 +160,7 @@ bool RifReaderEclipseFileAccess::keywordsOnFile(QStringList* keywords, size_t nu
//--------------------------------------------------------------------------------------------------
/// Get list of time step texts (dates)
//--------------------------------------------------------------------------------------------------
bool RifReaderEclipseFileAccess::timeStepsText(QStringList* timeSteps)
bool RifEclipseOutputFileTools::timeStepsText(QStringList* timeSteps)
{
#ifdef USE_ECL_LIB
CVF_ASSERT(timeSteps);
@ -208,7 +209,7 @@ bool RifReaderEclipseFileAccess::timeStepsText(QStringList* timeSteps)
//--------------------------------------------------------------------------------------------------
/// Get list of time step texts (dates)
//--------------------------------------------------------------------------------------------------
bool RifReaderEclipseFileAccess::timeSteps(QList<QDateTime>* timeSteps)
bool RifEclipseOutputFileTools::timeSteps(QList<QDateTime>* timeSteps)
{
#ifdef USE_ECL_LIB
CVF_ASSERT(timeSteps);
@ -256,7 +257,7 @@ bool RifReaderEclipseFileAccess::timeSteps(QList<QDateTime>* timeSteps)
//--------------------------------------------------------------------------------------------------
/// Get first occurrence of file of given type in given list of filenames, as filename or NULL if not found
//--------------------------------------------------------------------------------------------------
bool RifReaderEclipseFileAccess::keywordData(const QString& keyword, size_t index, std::vector<double>* values)
bool RifEclipseOutputFileTools::keywordData(const QString& keyword, size_t index, std::vector<double>* values)
{
#ifdef USE_ECL_LIB
CVF_ASSERT(m_file);
@ -285,7 +286,7 @@ bool RifReaderEclipseFileAccess::keywordData(const QString& keyword, size_t inde
/// Get first occurrence of file of given type in given list of filenames, as filename or NULL if not found
//--------------------------------------------------------------------------------------------------
#ifdef USE_ECL_LIB
QString RifReaderEclipseFileAccess::fileNameByType(const QStringList& fileSet, ecl_file_enum fileType)
QString RifEclipseOutputFileTools::fileNameByType(const QStringList& fileSet, ecl_file_enum fileType)
{
int i;
for (i = 0; i < fileSet.count(); i++)
@ -307,7 +308,7 @@ QString RifReaderEclipseFileAccess::fileNameByType(const QStringList& fileSet, e
/// Get all files of file of given type in given list of filenames, as filename or NULL if not found
//--------------------------------------------------------------------------------------------------
#ifdef USE_ECL_LIB
QStringList RifReaderEclipseFileAccess::fileNamesByType(const QStringList& fileSet, ecl_file_enum fileType)
QStringList RifEclipseOutputFileTools::fileNamesByType(const QStringList& fileSet, ecl_file_enum fileType)
{
QStringList fileNames;
@ -330,13 +331,14 @@ QStringList RifReaderEclipseFileAccess::fileNamesByType(const QStringList& fileS
//--------------------------------------------------------------------------------------------------
/// Get set of Eclipse files based on an input file and its path
//--------------------------------------------------------------------------------------------------
bool RifReaderEclipseFileAccess::fileSet(const QString& fileName, QStringList* fileSet)
bool RifEclipseOutputFileTools::fileSet(const QString& fileName, QStringList* fileSet)
{
CVF_ASSERT(fileSet);
fileSet->clear();
#ifdef USE_ECL_LIB
QString filePath = QFileInfo(fileName).path();
QString filePath = QFileInfo(fileName).absoluteFilePath();
filePath = QFileInfo(filePath).path();
QString fileNameBase = QFileInfo(fileName).baseName();
stringlist_type* eclipseFiles = stringlist_alloc_new();
@ -358,7 +360,7 @@ bool RifReaderEclipseFileAccess::fileSet(const QString& fileName, QStringList* f
///
//--------------------------------------------------------------------------------------------------
#ifdef USE_ECL_LIB
ecl_file_type* RifReaderEclipseFileAccess::filePointer()
ecl_file_type* RifEclipseOutputFileTools::filePointer()
{
return m_file;
}

View File

@ -35,11 +35,11 @@
// Class for access to Eclipse "keyword" files using libecl
//
//==================================================================================================
class RifReaderEclipseFileAccess : public cvf::Object
class RifEclipseOutputFileTools : public cvf::Object
{
public:
RifReaderEclipseFileAccess();
virtual ~RifReaderEclipseFileAccess();
RifEclipseOutputFileTools();
virtual ~RifEclipseOutputFileTools();
bool open(const QString& fileName);
void close();

View File

@ -16,13 +16,13 @@
//
/////////////////////////////////////////////////////////////////////////////////
#include "RifReaderEclipseResultAccess.h"
#include "RifEclipseRestartDataAccess.h"
//--------------------------------------------------------------------------------------------------
/// Constructor
//--------------------------------------------------------------------------------------------------
RifReaderEclipseResultsAccess::RifReaderEclipseResultsAccess(size_t numGrids, size_t numActiveCells)
RifEclipseRestartDataAccess::RifEclipseRestartDataAccess(size_t numGrids, size_t numActiveCells)
{
m_numGrids = numGrids;
m_numActiveCells = numActiveCells;
@ -32,6 +32,6 @@ RifReaderEclipseResultsAccess::RifReaderEclipseResultsAccess(size_t numGrids, si
//--------------------------------------------------------------------------------------------------
/// Destructor
//--------------------------------------------------------------------------------------------------
RifReaderEclipseResultsAccess::~RifReaderEclipseResultsAccess()
RifEclipseRestartDataAccess::~RifEclipseRestartDataAccess()
{
}

View File

@ -36,11 +36,11 @@
// Abstract class for results access
//
//==================================================================================================
class RifReaderEclipseResultsAccess : public cvf::Object
class RifEclipseRestartDataAccess : public cvf::Object
{
public:
RifReaderEclipseResultsAccess(size_t numGrids, size_t numActiveCells);
virtual ~RifReaderEclipseResultsAccess();
RifEclipseRestartDataAccess(size_t numGrids, size_t numActiveCells);
virtual ~RifEclipseRestartDataAccess();
virtual bool open(const QStringList& fileSet) = 0;
virtual void close() = 0;

View File

@ -16,22 +16,22 @@
//
/////////////////////////////////////////////////////////////////////////////////
#include "RifReaderEclipseRestartFiles.h"
#include "RifReaderEclipseFileAccess.h"
#include "RifEclipseRestartFilesetAccess.h"
#include "RifEclipseOutputFileTools.h"
//--------------------------------------------------------------------------------------------------
/// Constructor
//--------------------------------------------------------------------------------------------------
RifReaderEclipseRestartFiles::RifReaderEclipseRestartFiles(size_t numGrids, size_t numActiveCells)
: RifReaderEclipseResultsAccess(numGrids, numActiveCells)
RifEclipseRestartFilesetAccess::RifEclipseRestartFilesetAccess(size_t numGrids, size_t numActiveCells)
: RifEclipseRestartDataAccess(numGrids, numActiveCells)
{
}
//--------------------------------------------------------------------------------------------------
/// Destructor
//--------------------------------------------------------------------------------------------------
RifReaderEclipseRestartFiles::~RifReaderEclipseRestartFiles()
RifEclipseRestartFilesetAccess::~RifEclipseRestartFilesetAccess()
{
close();
}
@ -39,7 +39,7 @@ RifReaderEclipseRestartFiles::~RifReaderEclipseRestartFiles()
//--------------------------------------------------------------------------------------------------
/// Open files
//--------------------------------------------------------------------------------------------------
bool RifReaderEclipseRestartFiles::open(const QStringList& fileSet)
bool RifEclipseRestartFilesetAccess::open(const QStringList& fileSet)
{
close();
@ -47,7 +47,7 @@ bool RifReaderEclipseRestartFiles::open(const QStringList& fileSet)
size_t i;
for (i = 0; i < numFiles; i++)
{
cvf::ref<RifReaderEclipseFileAccess> fileAccess = new RifReaderEclipseFileAccess;
cvf::ref<RifEclipseOutputFileTools> fileAccess = new RifEclipseOutputFileTools;
if (!fileAccess->open(fileSet[i]))
{
close();
@ -63,7 +63,7 @@ bool RifReaderEclipseRestartFiles::open(const QStringList& fileSet)
//--------------------------------------------------------------------------------------------------
/// Close files
//--------------------------------------------------------------------------------------------------
void RifReaderEclipseRestartFiles::close()
void RifEclipseRestartFilesetAccess::close()
{
m_files.clear();
}
@ -71,7 +71,7 @@ void RifReaderEclipseRestartFiles::close()
//--------------------------------------------------------------------------------------------------
/// Get the number of time steps
//--------------------------------------------------------------------------------------------------
size_t RifReaderEclipseRestartFiles::numTimeSteps()
size_t RifEclipseRestartFilesetAccess::numTimeSteps()
{
return m_files.size();
}
@ -79,7 +79,7 @@ size_t RifReaderEclipseRestartFiles::numTimeSteps()
//--------------------------------------------------------------------------------------------------
/// Get the time step texts
//--------------------------------------------------------------------------------------------------
QStringList RifReaderEclipseRestartFiles::timeStepsText()
QStringList RifEclipseRestartFilesetAccess::timeStepsText()
{
QStringList timeSteps;
@ -98,7 +98,7 @@ QStringList RifReaderEclipseRestartFiles::timeStepsText()
//--------------------------------------------------------------------------------------------------
/// Get the time steps
//--------------------------------------------------------------------------------------------------
QList<QDateTime> RifReaderEclipseRestartFiles::timeSteps()
QList<QDateTime> RifEclipseRestartFilesetAccess::timeSteps()
{
QList<QDateTime> timeSteps;
@ -125,7 +125,7 @@ QList<QDateTime> RifReaderEclipseRestartFiles::timeSteps()
//--------------------------------------------------------------------------------------------------
/// Get list of result names
//--------------------------------------------------------------------------------------------------
QStringList RifReaderEclipseRestartFiles::resultNames()
QStringList RifEclipseRestartFilesetAccess::resultNames()
{
CVF_ASSERT(numTimeSteps() > 0);
@ -139,7 +139,7 @@ QStringList RifReaderEclipseRestartFiles::resultNames()
//--------------------------------------------------------------------------------------------------
/// Get result values for given time step
//--------------------------------------------------------------------------------------------------
bool RifReaderEclipseRestartFiles::results(const QString& resultName, size_t timeStep, std::vector<double>* values)
bool RifEclipseRestartFilesetAccess::results(const QString& resultName, size_t timeStep, std::vector<double>* values)
{
size_t numOccurrences = m_files[timeStep]->numOccurrences(resultName);
CVF_ASSERT(m_numGrids == numOccurrences);
@ -164,7 +164,7 @@ bool RifReaderEclipseRestartFiles::results(const QString& resultName, size_t tim
///
//--------------------------------------------------------------------------------------------------
#ifdef USE_ECL_LIB
void RifReaderEclipseRestartFiles::readWellData(well_info_type* well_info)
void RifEclipseRestartFilesetAccess::readWellData(well_info_type* well_info)
{
if (!well_info) return;

View File

@ -18,22 +18,22 @@
#pragma once
#include "RifReaderEclipseResultAccess.h"
#include "RifEclipseRestartDataAccess.h"
#include <vector>
class RifReaderEclipseFileAccess;
class RifEclipseOutputFileTools;
//==================================================================================================
//
// Class for access to results from a set of restart files
//
//==================================================================================================
class RifReaderEclipseRestartFiles : public RifReaderEclipseResultsAccess
class RifEclipseRestartFilesetAccess : public RifEclipseRestartDataAccess
{
public:
RifReaderEclipseRestartFiles(size_t numGrids, size_t numActiveCells);
virtual ~RifReaderEclipseRestartFiles();
RifEclipseRestartFilesetAccess(size_t numGrids, size_t numActiveCells);
virtual ~RifEclipseRestartFilesetAccess();
bool open(const QStringList& fileSet);
void close();
@ -50,5 +50,5 @@ public:
#endif //USE_ECL_LIB
private:
std::vector< cvf::ref<RifReaderEclipseFileAccess> > m_files;
std::vector< cvf::ref<RifEclipseOutputFileTools> > m_files;
};

View File

@ -16,8 +16,8 @@
//
/////////////////////////////////////////////////////////////////////////////////
#include "RifReaderEclipseUnifiedRestartFile.h"
#include "RifReaderEclipseFileAccess.h"
#include "RifEclipseUnifiedRestartFileAccess.h"
#include "RifEclipseOutputFileTools.h"
#ifdef USE_ECL_LIB
#include <well_state.h>
@ -29,15 +29,15 @@
//--------------------------------------------------------------------------------------------------
/// Constructor
//--------------------------------------------------------------------------------------------------
RifReaderEclipseUnifiedRestartFile::RifReaderEclipseUnifiedRestartFile(size_t numGrids, size_t numActiveCells)
: RifReaderEclipseResultsAccess(numGrids, numActiveCells)
RifEclipseUnifiedRestartFileAccess::RifEclipseUnifiedRestartFileAccess(size_t numGrids, size_t numActiveCells)
: RifEclipseRestartDataAccess(numGrids, numActiveCells)
{
}
//--------------------------------------------------------------------------------------------------
/// Destructor
//--------------------------------------------------------------------------------------------------
RifReaderEclipseUnifiedRestartFile::~RifReaderEclipseUnifiedRestartFile()
RifEclipseUnifiedRestartFileAccess::~RifEclipseUnifiedRestartFileAccess()
{
close();
}
@ -45,12 +45,12 @@ RifReaderEclipseUnifiedRestartFile::~RifReaderEclipseUnifiedRestartFile()
//--------------------------------------------------------------------------------------------------
/// Open file
//--------------------------------------------------------------------------------------------------
bool RifReaderEclipseUnifiedRestartFile::open(const QStringList& fileSet)
bool RifEclipseUnifiedRestartFileAccess::open(const QStringList& fileSet)
{
#ifdef USE_ECL_LIB
QString fileName = fileSet[0];
cvf::ref<RifReaderEclipseFileAccess> fileAccess = new RifReaderEclipseFileAccess;
cvf::ref<RifEclipseOutputFileTools> fileAccess = new RifEclipseOutputFileTools;
if (!fileAccess->open(fileName))
{
return false;
@ -67,7 +67,7 @@ bool RifReaderEclipseUnifiedRestartFile::open(const QStringList& fileSet)
//--------------------------------------------------------------------------------------------------
/// Close file
//--------------------------------------------------------------------------------------------------
void RifReaderEclipseUnifiedRestartFile::close()
void RifEclipseUnifiedRestartFileAccess::close()
{
if (m_file.notNull())
{
@ -79,7 +79,7 @@ void RifReaderEclipseUnifiedRestartFile::close()
//--------------------------------------------------------------------------------------------------
/// Get the number of time steps
//--------------------------------------------------------------------------------------------------
size_t RifReaderEclipseUnifiedRestartFile::numTimeSteps()
size_t RifEclipseUnifiedRestartFileAccess::numTimeSteps()
{
QStringList timeSteps = timeStepsText();
return timeSteps.size();
@ -88,9 +88,9 @@ size_t RifReaderEclipseUnifiedRestartFile::numTimeSteps()
//--------------------------------------------------------------------------------------------------
/// Get the time step texts
//--------------------------------------------------------------------------------------------------
QStringList RifReaderEclipseUnifiedRestartFile::timeStepsText()
QStringList RifEclipseUnifiedRestartFileAccess::timeStepsText()
{
RifReaderEclipseFileAccess* file = m_file.p();
RifEclipseOutputFileTools* file = m_file.p();
CVF_ASSERT(file != NULL);
QStringList timeSteps;
@ -102,9 +102,9 @@ QStringList RifReaderEclipseUnifiedRestartFile::timeStepsText()
//--------------------------------------------------------------------------------------------------
/// Get the time steps
//--------------------------------------------------------------------------------------------------
QList<QDateTime> RifReaderEclipseUnifiedRestartFile::timeSteps()
QList<QDateTime> RifEclipseUnifiedRestartFileAccess::timeSteps()
{
RifReaderEclipseFileAccess* file = m_file.p();
RifEclipseOutputFileTools* file = m_file.p();
CVF_ASSERT(file != NULL);
QList<QDateTime> timeSteps;
@ -116,7 +116,7 @@ QList<QDateTime> RifReaderEclipseUnifiedRestartFile::timeSteps()
//--------------------------------------------------------------------------------------------------
/// Get list of result names
//--------------------------------------------------------------------------------------------------
QStringList RifReaderEclipseUnifiedRestartFile::resultNames()
QStringList RifEclipseUnifiedRestartFileAccess::resultNames()
{
// Get the results found on the UNRST file
QStringList resultsList;
@ -128,7 +128,7 @@ QStringList RifReaderEclipseUnifiedRestartFile::resultNames()
//--------------------------------------------------------------------------------------------------
/// Get result values for given time step
//--------------------------------------------------------------------------------------------------
bool RifReaderEclipseUnifiedRestartFile::results(const QString& resultName, size_t timeStep, std::vector<double>* values)
bool RifEclipseUnifiedRestartFileAccess::results(const QString& resultName, size_t timeStep, std::vector<double>* values)
{
size_t numOccurrences = m_file->numOccurrences(resultName);
size_t startIndex = timeStep*m_numGrids;
@ -154,7 +154,7 @@ bool RifReaderEclipseUnifiedRestartFile::results(const QString& resultName, size
///
//--------------------------------------------------------------------------------------------------
#ifdef USE_ECL_LIB
void RifReaderEclipseUnifiedRestartFile::readWellData(well_info_type* well_info)
void RifEclipseUnifiedRestartFileAccess::readWellData(well_info_type* well_info)
{
if (!well_info) return;

View File

@ -18,9 +18,9 @@
#pragma once
#include "RifReaderEclipseResultAccess.h"
#include "RifEclipseRestartDataAccess.h"
class RifReaderEclipseFileAccess;
class RifEclipseOutputFileTools;
#ifdef USE_ECL_LIB
#include "well_info.h"
@ -31,11 +31,11 @@ class RifReaderEclipseFileAccess;
// Class for access to results from a unified restart file
//
//==================================================================================================
class RifReaderEclipseUnifiedRestartFile : public RifReaderEclipseResultsAccess
class RifEclipseUnifiedRestartFileAccess : public RifEclipseRestartDataAccess
{
public:
RifReaderEclipseUnifiedRestartFile(size_t numGrids, size_t numActiveCells);
virtual ~RifReaderEclipseUnifiedRestartFile();
RifEclipseUnifiedRestartFileAccess(size_t numGrids, size_t numActiveCells);
virtual ~RifEclipseUnifiedRestartFileAccess();
bool open(const QStringList& fileSet);
void close();
@ -52,5 +52,5 @@ public:
#endif
private:
cvf::ref<RifReaderEclipseFileAccess> m_file;
cvf::ref<RifEclipseOutputFileTools> m_file;
};

View File

@ -0,0 +1,95 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "cvfBase.h"
#include "RigMainGrid.h"
#include "RigReservoir.h"
#include "RigReservoirCellResults.h"
#include "RifReaderEclipseInput.h"
#include "RifReaderEclipseOutput.h"
#include "RifEclipseInputFileTools.h"
#include <iostream>
#include <cmath>
#ifdef USE_ECL_LIB
#include "ecl_grid.h"
#include "well_state.h"
#endif //USE_ECL_LIB
#include "util.h"
//==================================================================================================
//
// Class RifReaderEclipseInput
//
//==================================================================================================
//--------------------------------------------------------------------------------------------------
/// Constructor
//--------------------------------------------------------------------------------------------------
RifReaderEclipseInput::RifReaderEclipseInput()
{
}
//--------------------------------------------------------------------------------------------------
/// Destructor
//--------------------------------------------------------------------------------------------------
RifReaderEclipseInput::~RifReaderEclipseInput()
{
}
//--------------------------------------------------------------------------------------------------
/// Open file and read geometry into given reservoir object
//--------------------------------------------------------------------------------------------------
bool RifReaderEclipseInput::open(const QString& fileName, RigReservoir* reservoir)
{
CVF_ASSERT(reservoir);
// Make sure everything's closed
close();
// Should we handle gridless properties ?
// If so, they must match dimentions, and a grid afterwards must match dimension
// Add file:
// Open file
// If we do not have any grid data,
// Search for grid keywords
// If grid data found
// Read grid keywords,
// produce ecl_grid,
// Transfer data to RigReservoir
// if not
// find include
// else
// Search through file for property keywords
// If found,
// read them,
// create InputProperty object
bool isOk = false;
if (reservoir->mainGrid()->gridPointDimensions() == cvf::Vec3st(0,0,0))
{
isOk = RifEclipseInputFileTools::openGridFile(fileName, reservoir);
}
return isOk;
}

View File

@ -0,0 +1,44 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RifReaderInterface.h"
//==================================================================================================
//
// File interface for Eclipse output files
//
//==================================================================================================
class RifReaderEclipseInput : public RifReaderInterface
{
public:
RifReaderEclipseInput();
virtual ~RifReaderEclipseInput();
// Virtual interface implementation
virtual bool open(const QString& fileName, RigReservoir* reservoir);
virtual void close() {}
virtual bool staticResult(const QString& result, std::vector<double>* values) { return false; }
virtual bool dynamicResult(const QString& result, size_t stepIndex, std::vector<double>* values) { return false; }
};

View File

@ -20,12 +20,12 @@
#include "RigMainGrid.h"
#include "RigReservoir.h"
#include "RigReservoirCellResults.h"
#include "RifReaderInterfaceEcl.h"
#include "RifReaderEclipseFileAccess.h"
#include "RifReaderEclipseUnifiedRestartFile.h"
#include "RifReaderEclipseRestartFiles.h"
#include "RifReaderEclipseOutput.h"
#include "RifEclipseOutputFileTools.h"
#include "RifEclipseUnifiedRestartFileAccess.h"
#include "RifEclipseRestartFilesetAccess.h"
#include <iostream>
@ -33,6 +33,7 @@
#include "ecl_grid.h"
#include "well_state.h"
#endif //USE_ECL_LIB
#include "cafProgressInfo.h"
//--------------------------------------------------------------------------------------------------
/// ECLIPSE cell numbering layout:
@ -85,7 +86,7 @@ static const size_t cellMappingECLRi[8] = { 0, 1, 3, 2, 4, 5, 7, 6 };
//**************************************************************************************************
#ifdef USE_ECL_LIB
bool transferGridCellData(RigMainGrid* mainGrid, RigGridBase* localGrid, ecl_grid_type* localEclGrid, size_t activeStartIndex)
bool transferGridCellData(RigMainGrid* mainGrid, RigGridBase* localGrid, const ecl_grid_type* localEclGrid, size_t activeStartIndex)
{
int cellCount = ecl_grid_get_global_size(localEclGrid);
size_t cellStartIndex = mainGrid->cells().size();
@ -97,6 +98,8 @@ bool transferGridCellData(RigMainGrid* mainGrid, RigGridBase* localGrid, ecl_gri
mainGrid->nodes().resize(nodeStartIndex + cellCount*8, cvf::Vec3d(0,0,0));
caf::ProgressInfo progInfo(cellCount, "");
size_t computedCellCount = 0;
// Loop over cells and fill them with data
#pragma omp parallel for
@ -142,7 +145,14 @@ bool transferGridCellData(RigMainGrid* mainGrid, RigGridBase* localGrid, ecl_gri
CVF_ASSERT(subGridFileIndex > 0);
cell.setSubGrid(static_cast<RigLocalGrid*>(mainGrid->gridByIndex(subGridFileIndex)));
}
#pragma omp atomic
computedCellCount++;
if (computedCellCount%5000 < 20)
progInfo.setProgress(computedCellCount);
}
return true;
}
#endif
@ -155,7 +165,7 @@ bool transferGridCellData(RigMainGrid* mainGrid, RigGridBase* localGrid, ecl_gri
//--------------------------------------------------------------------------------------------------
/// Constructor
//--------------------------------------------------------------------------------------------------
RifReaderInterfaceECL::RifReaderInterfaceECL()
RifReaderEclipseOutput::RifReaderEclipseOutput()
{
ground();
}
@ -163,30 +173,26 @@ RifReaderInterfaceECL::RifReaderInterfaceECL()
//--------------------------------------------------------------------------------------------------
/// Destructor
//--------------------------------------------------------------------------------------------------
RifReaderInterfaceECL::~RifReaderInterfaceECL()
RifReaderEclipseOutput::~RifReaderEclipseOutput()
{
}
//--------------------------------------------------------------------------------------------------
/// Ground members
//--------------------------------------------------------------------------------------------------
void RifReaderInterfaceECL::ground()
void RifReaderEclipseOutput::ground()
{
m_fileName.clear();
m_fileSet.clear();
m_staticResults.clear();
m_dynamicResults.clear();
m_timeStepTexts.clear();
m_timeSteps.clear();
m_numGrids = 0;
}
//--------------------------------------------------------------------------------------------------
/// Close interface (for now, no files are kept open after calling methods, so just clear members)
//--------------------------------------------------------------------------------------------------
void RifReaderInterfaceECL::close()
void RifReaderEclipseOutput::close()
{
m_staticResultsAccess = NULL;
m_dynamicResultsAccess = NULL;
@ -197,12 +203,12 @@ void RifReaderInterfaceECL::close()
//--------------------------------------------------------------------------------------------------
/// Read geometry from file given by name into given reservoir object
//--------------------------------------------------------------------------------------------------
bool RifReaderInterfaceECL::readGeometry(const QString& filename, RigReservoir* reservoir)
bool RifReaderEclipseOutput::transferGeometry(const ecl_grid_type* mainEclGrid, RigReservoir* reservoir)
{
CVF_ASSERT(reservoir);
#ifdef USE_ECL_LIB
ecl_grid_type * mainEclGrid = ecl_grid_alloc( filename.toAscii().data() );
if (!mainEclGrid)
{
// Some error
@ -249,22 +255,25 @@ bool RifReaderInterfaceECL::readGeometry(const QString& filename, RigReservoir*
mainGrid->cells().reserve(totalCellCount);
mainGrid->nodes().reserve(8*totalCellCount);
caf::ProgressInfo progInfo(1 + numLGRs, "");
progInfo.setProgressDescription("Main Grid");
transferGridCellData(mainGrid, mainGrid, mainEclGrid, 0);
progInfo.setProgress(1);
size_t globalActiveSize = ecl_grid_get_active_size(mainEclGrid);
for (lgrIdx = 0; lgrIdx < numLGRs; ++lgrIdx)
{
progInfo.setProgressDescription("LGR number " + QString::number(lgrIdx+1));
ecl_grid_type* localEclGrid = ecl_grid_iget_lgr(mainEclGrid, lgrIdx);
transferGridCellData(mainGrid, static_cast<RigLocalGrid*>(mainGrid->gridByIndex(lgrIdx+1)), localEclGrid, globalActiveSize);
globalActiveSize += ecl_grid_get_active_size(localEclGrid);
progInfo.setProgress(1 + lgrIdx);
}
ecl_grid_free( mainEclGrid );
// !! Maybe this should set somewhere else, in a method that builds meta data !!
m_numGrids = numLGRs + 1;
#endif
return true;
@ -274,60 +283,93 @@ bool RifReaderInterfaceECL::readGeometry(const QString& filename, RigReservoir*
//--------------------------------------------------------------------------------------------------
/// Open file and read geometry into given reservoir object
//--------------------------------------------------------------------------------------------------
bool RifReaderInterfaceECL::open(const QString& fileName, RigReservoir* reservoir)
bool RifReaderEclipseOutput::open(const QString& fileName, RigReservoir* reservoir)
{
CVF_ASSERT(reservoir);
caf::ProgressInfo progInfo(4, "");
progInfo.setProgressDescription("Reading Grid");
// Make sure everything's closed
close();
// Get set of files
QStringList fileSet;
if (!RifReaderEclipseFileAccess::fileSet(fileName, &fileSet)) return false;
if (!RifEclipseOutputFileTools::fileSet(fileName, &fileSet)) return false;
// Keep the set of files of interest
m_fileSet = fileSet;
// Read geometry
if (!readGeometry(fileName, reservoir)) return false;
#ifdef USE_ECL_LIB
ecl_grid_type * mainEclGrid = ecl_grid_alloc( fileName.toAscii().data() );
progInfo.setProgress(1);
progInfo.setProgressDescription("Transferring grid geometry");
if (!transferGeometry(mainEclGrid, reservoir)) return false;
ecl_grid_free( mainEclGrid );
progInfo.setProgress(2);
progInfo.setProgressDescription("Reading Result index");
#endif
// Build results meta data
if (!buildMetaData(reservoir)) return false;
progInfo.setProgress(3);
progInfo.setProgressDescription("Reading Well information");
readWellCells(reservoir);
return true;
}
//--------------------------------------------------------------------------------------------------
/// Build meta data - get states and results info
//--------------------------------------------------------------------------------------------------
bool RifReaderInterfaceECL::buildMetaData(RigReservoir* reservoir)
bool RifReaderEclipseOutput::buildMetaData(RigReservoir* reservoir)
{
#ifdef USE_ECL_LIB
CVF_ASSERT(reservoir);
CVF_ASSERT(m_fileSet.size() > 0);
caf::ProgressInfo progInfo(2,"");
// Get the number of active cells in the grid
size_t numActiveCells = reservoir->mainGrid()->numActiveCells();
size_t numGrids = reservoir->mainGrid()->gridCount();
// Create access object for dynamic results
m_dynamicResultsAccess = dynamicResultsAccess(m_fileSet, m_numGrids, numActiveCells);
m_dynamicResultsAccess = dynamicResultsAccess(m_fileSet, numGrids, numActiveCells);
RigReservoirCellResults* resCellResults = reservoir->mainGrid()->results();
if (m_dynamicResultsAccess.notNull())
{
// Get time steps texts
m_timeStepTexts = m_dynamicResultsAccess->timeStepsText();
// Get time steps
m_timeSteps = m_dynamicResultsAccess->timeSteps();
// Get the names of the dynamic results
m_dynamicResults = m_dynamicResultsAccess->resultNames();
QStringList dynamicResultNames = m_dynamicResultsAccess->resultNames();
for (size_t i = 0; i < static_cast<size_t>(dynamicResultNames.size()); ++i)
{
size_t resIndex = resCellResults->addEmptyScalarResult(RimDefines::DYNAMIC_NATIVE, dynamicResultNames[i]);
resCellResults->setTimeStepDates(resIndex, m_timeSteps);
}
}
QString initFileName = RifReaderEclipseFileAccess::fileNameByType(m_fileSet, ECL_INIT_FILE);
progInfo.setProgress(1);
QString initFileName = RifEclipseOutputFileTools::fileNameByType(m_fileSet, ECL_INIT_FILE);
if (initFileName.size() > 0)
{
// Open init file
cvf::ref<RifReaderEclipseFileAccess> initFile = new RifReaderEclipseFileAccess;
cvf::ref<RifEclipseOutputFileTools> initFile = new RifEclipseOutputFileTools;
if (!initFile->open(initFileName))
{
return false;
@ -336,7 +378,15 @@ bool RifReaderInterfaceECL::buildMetaData(RigReservoir* reservoir)
// Get the names of the static results
QStringList staticResults;
initFile->keywordsOnFile(&staticResults, numActiveCells);
m_staticResults = staticResults;
QStringList staticResultNames = staticResults;
QList<QDateTime> staticDate;
staticDate.push_back(m_timeSteps.front());
for (size_t i = 0; i < static_cast<size_t>(staticResultNames.size()); ++i)
{
size_t resIndex = resCellResults->addEmptyScalarResult(RimDefines::STATIC_NATIVE, staticResultNames[i]);
resCellResults->setTimeStepDates(resIndex, staticDate);
}
m_staticResultsAccess = initFile;
}
@ -350,16 +400,16 @@ bool RifReaderInterfaceECL::buildMetaData(RigReservoir* reservoir)
//--------------------------------------------------------------------------------------------------
/// Create results access object (.UNRST or .X0001 ... .XNNNN)
//--------------------------------------------------------------------------------------------------
RifReaderEclipseResultsAccess* RifReaderInterfaceECL::dynamicResultsAccess(const QStringList& fileSet, size_t numGrids, size_t numActiveCells)
RifEclipseRestartDataAccess* RifReaderEclipseOutput::dynamicResultsAccess(const QStringList& fileSet, size_t numGrids, size_t numActiveCells)
{
RifReaderEclipseResultsAccess* resultsAccess = NULL;
RifEclipseRestartDataAccess* resultsAccess = NULL;
#ifdef USE_ECL_LIB
// Look for unified restart file
QString unrstFileName = RifReaderEclipseFileAccess::fileNameByType(fileSet, ECL_UNIFIED_RESTART_FILE);
QString unrstFileName = RifEclipseOutputFileTools::fileNameByType(fileSet, ECL_UNIFIED_RESTART_FILE);
if (unrstFileName.size() > 0)
{
resultsAccess = new RifReaderEclipseUnifiedRestartFile(numGrids, numActiveCells);
resultsAccess = new RifEclipseUnifiedRestartFileAccess(numGrids, numActiveCells);
if (!resultsAccess->open(QStringList(unrstFileName)))
{
delete resultsAccess;
@ -369,10 +419,10 @@ RifReaderEclipseResultsAccess* RifReaderInterfaceECL::dynamicResultsAccess(const
else
{
// Look for set of restart files (one file per time step)
QStringList restartFiles = RifReaderEclipseFileAccess::fileNamesByType(fileSet, ECL_RESTART_FILE);
QStringList restartFiles = RifEclipseOutputFileTools::fileNamesByType(fileSet, ECL_RESTART_FILE);
if (restartFiles.size() > 0)
{
resultsAccess = new RifReaderEclipseRestartFiles(numGrids, numActiveCells);
resultsAccess = new RifEclipseRestartFilesetAccess(numGrids, numActiveCells);
if (!resultsAccess->open(restartFiles))
{
delete resultsAccess;
@ -388,34 +438,10 @@ RifReaderEclipseResultsAccess* RifReaderInterfaceECL::dynamicResultsAccess(const
return resultsAccess;
}
//--------------------------------------------------------------------------------------------------
/// Get the names of all static results
//--------------------------------------------------------------------------------------------------
const QStringList& RifReaderInterfaceECL::staticResults() const
{
return m_staticResults;
}
//--------------------------------------------------------------------------------------------------
/// Get the names of all dynamic results
//--------------------------------------------------------------------------------------------------
const QStringList& RifReaderInterfaceECL::dynamicResults() const
{
return m_dynamicResults;
}
//--------------------------------------------------------------------------------------------------
/// Get the number of time steps
//--------------------------------------------------------------------------------------------------
size_t RifReaderInterfaceECL::numTimeSteps() const
{
return m_timeStepTexts.size();
}
//--------------------------------------------------------------------------------------------------
/// Get all values of a given static result as doubles
//--------------------------------------------------------------------------------------------------
bool RifReaderInterfaceECL::staticResult(const QString& result, std::vector<double>* values)
bool RifReaderEclipseOutput::staticResult(const QString& result, std::vector<double>* values)
{
CVF_ASSERT(values);
CVF_ASSERT(m_staticResultsAccess.notNull());
@ -435,24 +461,16 @@ bool RifReaderInterfaceECL::staticResult(const QString& result, std::vector<doub
//--------------------------------------------------------------------------------------------------
/// Get dynamic result at given step index. Will concatenate values for the main grid and all sub grids.
//--------------------------------------------------------------------------------------------------
bool RifReaderInterfaceECL::dynamicResult(const QString& result, size_t stepIndex, std::vector<double>* values)
bool RifReaderEclipseOutput::dynamicResult(const QString& result, size_t stepIndex, std::vector<double>* values)
{
CVF_ASSERT(m_dynamicResultsAccess.notNull());
return m_dynamicResultsAccess->results(result, stepIndex, values);
}
//--------------------------------------------------------------------------------------------------
/// Get list of time step texts
//--------------------------------------------------------------------------------------------------
const QStringList& RifReaderInterfaceECL::timeStepText() const
{
return m_timeStepTexts;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const QList<QDateTime>& RifReaderInterfaceECL::timeSteps() const
const QList<QDateTime>& RifReaderEclipseOutput::timeSteps() const
{
return m_timeSteps;
}
@ -460,7 +478,7 @@ const QList<QDateTime>& RifReaderInterfaceECL::timeSteps() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RifReaderInterfaceECL::readWellCells(RigReservoir* reservoir)
void RifReaderEclipseOutput::readWellCells(RigReservoir* reservoir)
{
CVF_ASSERT(reservoir);
@ -500,7 +518,7 @@ void RifReaderInterfaceECL::readWellCells(RigReservoir* reservoir)
RigWellResultFrame& wellResFrame = wellResults->m_wellCellsTimeSteps[timeIdx];
// Build timestamp for well
// Also see RifReaderEclipseFileAccess::timeStepsText for accessing time_t structures
// Also see RifEclipseOutputFileAccess::timeStepsText for accessing time_t structures
{
time_t stepTime = well_state_get_sim_time(ert_well_state);
wellResFrame.m_timestamp = QDateTime::fromTime_t(stepTime);
@ -586,7 +604,9 @@ void RifReaderInterfaceECL::readWellCells(RigReservoir* reservoir)
RigWellResultCell& data = wellSegment.m_wellCells[existingConnCount + connIdx];
data.m_gridIndex = gridNr;
data.m_gridCellIndex = grids[gridNr]->cellIndexFromIJK(ert_connection->i, ert_connection->j, ert_connection->k);
data.m_isOpen = ert_connection->open;
data.m_isOpen = ert_connection->open;
data.m_branchId = ert_connection->branch;
data.m_segmentId = ert_connection->segment;
}
}
}

View File

@ -0,0 +1,69 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RifReaderInterface.h"
#include <QList>
#include <QDateTime>
class RifEclipseOutputFileTools;
class RifEclipseRestartDataAccess;
typedef struct ecl_grid_struct ecl_grid_type;
//==================================================================================================
//
// File interface for Eclipse output files
//
//==================================================================================================
class RifReaderEclipseOutput : public RifReaderInterface
{
public:
RifReaderEclipseOutput();
virtual ~RifReaderEclipseOutput();
bool open(const QString& fileName, RigReservoir* reservoir);
void close();
const QList<QDateTime>& timeSteps() const;
bool staticResult(const QString& result, std::vector<double>* values);
bool dynamicResult(const QString& result, size_t stepIndex, std::vector<double>* values);
#ifdef USE_ECL_LIB
static bool transferGeometry(const ecl_grid_type* mainEclGrid, RigReservoir* reservoir);
#endif
private:
void ground();
bool buildMetaData(RigReservoir* reservoir);
void readWellCells(RigReservoir* reservoir);
static RifEclipseRestartDataAccess* staticResultsAccess(const QStringList& fileSet, size_t numGrids, size_t numActiveCells);
static RifEclipseRestartDataAccess* dynamicResultsAccess(const QStringList& fileSet, size_t numGrids, size_t numActiveCells);
private:
QString m_fileName; // Name of file used to start accessing Eclipse output files
QStringList m_fileSet; // Set of files in filename's path with same base name as filename
QList<QDateTime> m_timeSteps;
cvf::ref<RifEclipseOutputFileTools> m_staticResultsAccess; // File access to static results
cvf::ref<RifEclipseRestartDataAccess> m_dynamicResultsAccess; // File access to dynamic results
};

View File

@ -41,12 +41,9 @@ public:
virtual bool open(const QString& fileName, RigReservoir* reservoir) = 0;
virtual void close() = 0;
virtual const QStringList& staticResults() const = 0;
virtual const QStringList& dynamicResults() const = 0;
virtual size_t numTimeSteps() const = 0;
virtual const QStringList& timeStepText() const = 0;
virtual bool staticResult(const QString& result, std::vector<double>* values) = 0;
virtual bool dynamicResult(const QString& result, size_t stepIndex, std::vector<double>* values) = 0;
};

View File

@ -1,70 +0,0 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "RifReaderInterface.h"
class RifReaderEclipseFileAccess;
class RifReaderEclipseResultsAccess;
//==================================================================================================
//
// File interface for Eclipse output files
//
//==================================================================================================
class RifReaderInterfaceECL : public RifReaderInterface
{
public:
RifReaderInterfaceECL();
virtual ~RifReaderInterfaceECL();
bool open(const QString& fileName, RigReservoir* reservoir);
void close();
const QStringList& staticResults() const;
const QStringList& dynamicResults() const;
size_t numTimeSteps() const;
const QStringList& timeStepText() const;
const QList<QDateTime>& timeSteps() const;
bool staticResult(const QString& result, std::vector<double>* values);
bool dynamicResult(const QString& result, size_t stepIndex, std::vector<double>* values);
private:
void ground();
bool buildMetaData(RigReservoir* reservoir);
bool readGeometry(const QString& fileName, RigReservoir* reservoir);
void readWellCells(RigReservoir* reservoir);
static RifReaderEclipseResultsAccess* staticResultsAccess(const QStringList& fileSet, size_t numGrids, size_t numActiveCells);
static RifReaderEclipseResultsAccess* dynamicResultsAccess(const QStringList& fileSet, size_t numGrids, size_t numActiveCells);
private:
QString m_fileName; // Name of file used to start accessing Eclipse output files
QStringList m_fileSet; // Set of files in filename's path with same base name as filename
QStringList m_staticResults; // List of names of static results
QStringList m_dynamicResults; // List of names of dynamic results
QStringList m_timeStepTexts; // List of time step infos (dates)
QList<QDateTime> m_timeSteps;
size_t m_numGrids; // Total number of grids (main grid and all sub grids)
cvf::ref<RifReaderEclipseFileAccess> m_staticResultsAccess; // File access to static results
cvf::ref<RifReaderEclipseResultsAccess> m_dynamicResultsAccess; // File access to dynamic results
};

View File

@ -1,58 +0,0 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "RifReaderInterface.h"
#include "RigReservoirBuilderMock.h"
class RifReaderInterfaceMock : public RifReaderInterface
{
public:
RifReaderInterfaceMock();
virtual ~RifReaderInterfaceMock();
void setWorldCoordinates(cvf::Vec3d minWorldCoordinate, cvf::Vec3d maxWorldCoordinate);
void setGridPointDimensions(const cvf::Vec3st& gridPointDimensions);
void setResultInfo(size_t resultCount, size_t timeStepCount);
void addLocalGridRefinement(const cvf::Vec3st& minCellPosition, const cvf::Vec3st& maxCellPosition, const cvf::Vec3st& singleCellRefinementFactors);
virtual bool open( const QString& fileName, RigReservoir* reservoir );
virtual void close();
virtual const QStringList& staticResults() const;
virtual const QStringList& dynamicResults() const;
virtual size_t numTimeSteps() const;
const QStringList& timeStepText() const;
virtual bool staticResult( const QString& result, std::vector<double>* values );
virtual bool dynamicResult( const QString& result, size_t stepIndex, std::vector<double>* values );
private:
void populateReservoir(RigReservoir* reservoir);
QStringList m_staticResults;
QStringList m_dynamicResults;
QStringList m_timeStepTexts;
RigReservoirBuilderMock m_reservoirBuilder;
cvf::ref<RigReservoir> m_reservoir;
};

View File

@ -18,28 +18,39 @@
#include "RIStdInclude.h"
#include "RifReaderInterfaceMock.h"
#include "RifReaderMockModel.h"
#include "RigReservoirCellResults.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RifReaderInterfaceMock::open(const QString& fileName, RigReservoir* reservoir)
bool RifReaderMockModel::open(const QString& fileName, RigReservoir* reservoir)
{
m_reservoirBuilder.populateReservoir(reservoir);
m_reservoir = reservoir;
m_dynamicResults.clear();
m_staticResults.clear();
m_timeStepTexts.clear();
RigReservoirCellResults* cellResults = reservoir->mainGrid()->results();
size_t i;
for (i = 0; i < m_reservoirBuilder.resultCount(); i++)
QList<QDateTime> dates;
for (size_t i = 0; i < m_reservoirBuilder.timeStepCount(); i++)
{
m_dynamicResults.push_back(QString("Dynamic_Result_%1").arg(i));
dates.push_back(QDateTime(QDate(2012+i, 6, 1)));
}
for (i = 0; i < m_reservoirBuilder.resultCount(); i++)
for (size_t i = 0; i < m_reservoirBuilder.resultCount(); i++)
{
size_t resIdx = cellResults->addEmptyScalarResult(RimDefines::DYNAMIC_NATIVE, QString("Dynamic_Result_%1").arg(i));
cellResults->setTimeStepDates(resIdx, dates);
}
if (m_reservoirBuilder.timeStepCount() == 0) return true;
QList<QDateTime> staticDates;
staticDates.push_back(dates[0]);
for (size_t i = 0; i < m_reservoirBuilder.resultCount(); i++)
{
QString varEnd;
if (i == 0) varEnd = "X";
@ -47,54 +58,50 @@ bool RifReaderInterfaceMock::open(const QString& fileName, RigReservoir* reservo
int resIndex = 0;
if (i > 1) resIndex = i;
m_staticResults.push_back(QString("Static_Result_%1%2").arg(resIndex).arg(varEnd));
size_t resIdx = cellResults->addEmptyScalarResult(RimDefines::STATIC_NATIVE, QString("Static_Result_%1%2").arg(resIndex).arg(varEnd));
cellResults->setTimeStepDates(resIdx, staticDates);
}
for (i = 0; i < m_reservoirBuilder.timeStepCount(); i++)
{
m_timeStepTexts.push_back(QString("Timestep %1").arg(i));
#define ADD_INPUT_PROPERTY(Name) \
{ \
size_t resIdx; \
QString resultName(Name); \
resIdx = cellResults->addEmptyScalarResult(RimDefines::INPUT_PROPERTY, resultName); \
cellResults->setTimeStepDates(resIdx, staticDates); \
cellResults->cellScalarResults(resIdx).resize(1); \
std::vector<double>& values = cellResults->cellScalarResults(resIdx)[0]; \
this->inputProperty(resultName, &values); \
}
ADD_INPUT_PROPERTY("PORO");
ADD_INPUT_PROPERTY("PERM");
ADD_INPUT_PROPERTY("MULTX");
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RifReaderInterfaceMock::close()
void RifReaderMockModel::close()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RifReaderMockModel::inputProperty(const QString& propertyName, std::vector<double>* values)
{
return m_reservoirBuilder.inputProperty(m_reservoir.p(), propertyName, values);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const QStringList& RifReaderInterfaceMock::staticResults() const
{
return m_staticResults;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const QStringList& RifReaderInterfaceMock::dynamicResults() const
{
return m_dynamicResults;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
size_t RifReaderInterfaceMock::numTimeSteps() const
{
return m_reservoirBuilder.timeStepCount();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RifReaderInterfaceMock::staticResult(const QString& result, std::vector<double>* values)
bool RifReaderMockModel::staticResult(const QString& result, std::vector<double>* values)
{
m_reservoirBuilder.staticResult(m_reservoir.p(), result, values);
@ -104,7 +111,7 @@ bool RifReaderInterfaceMock::staticResult(const QString& result, std::vector<dou
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RifReaderInterfaceMock::dynamicResult(const QString& result, size_t stepIndex, std::vector<double>* values)
bool RifReaderMockModel::dynamicResult(const QString& result, size_t stepIndex, std::vector<double>* values)
{
m_reservoirBuilder.dynamicResult(m_reservoir.p(), result, stepIndex, values);
@ -114,7 +121,7 @@ bool RifReaderInterfaceMock::dynamicResult(const QString& result, size_t stepInd
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RifReaderInterfaceMock::RifReaderInterfaceMock()
RifReaderMockModel::RifReaderMockModel()
{
/*
m_cellResults.push_back("Dummy results");
@ -122,7 +129,7 @@ RifReaderInterfaceMock::RifReaderInterfaceMock()
*/
}
RifReaderInterfaceMock::~RifReaderInterfaceMock()
RifReaderMockModel::~RifReaderMockModel()
{
}
@ -130,7 +137,7 @@ RifReaderInterfaceMock::~RifReaderInterfaceMock()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RifReaderInterfaceMock::setWorldCoordinates(cvf::Vec3d minWorldCoordinate, cvf::Vec3d maxWorldCoordinate)
void RifReaderMockModel::setWorldCoordinates(cvf::Vec3d minWorldCoordinate, cvf::Vec3d maxWorldCoordinate)
{
m_reservoirBuilder.setWorldCoordinates(minWorldCoordinate, maxWorldCoordinate);
}
@ -138,7 +145,7 @@ void RifReaderInterfaceMock::setWorldCoordinates(cvf::Vec3d minWorldCoordinate,
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RifReaderInterfaceMock::setGridPointDimensions(const cvf::Vec3st& gridPointDimensions)
void RifReaderMockModel::setGridPointDimensions(const cvf::Vec3st& gridPointDimensions)
{
m_reservoirBuilder.setGridPointDimensions(gridPointDimensions);
}
@ -146,7 +153,7 @@ void RifReaderInterfaceMock::setGridPointDimensions(const cvf::Vec3st& gridPoint
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RifReaderInterfaceMock::setResultInfo(size_t resultCount, size_t timeStepCount)
void RifReaderMockModel::setResultInfo(size_t resultCount, size_t timeStepCount)
{
m_reservoirBuilder.setResultInfo(resultCount, timeStepCount);
}
@ -154,7 +161,7 @@ void RifReaderInterfaceMock::setResultInfo(size_t resultCount, size_t timeStepCo
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RifReaderInterfaceMock::addLocalGridRefinement(const cvf::Vec3st& minCellPosition, const cvf::Vec3st& maxCellPosition, const cvf::Vec3st& singleCellRefinementFactors)
void RifReaderMockModel::addLocalGridRefinement(const cvf::Vec3st& minCellPosition, const cvf::Vec3st& maxCellPosition, const cvf::Vec3st& singleCellRefinementFactors)
{
m_reservoirBuilder.addLocalGridRefinement(minCellPosition, maxCellPosition, singleCellRefinementFactors);
}
@ -162,17 +169,8 @@ void RifReaderInterfaceMock::addLocalGridRefinement(const cvf::Vec3st& minCellPo
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RifReaderInterfaceMock::populateReservoir(RigReservoir* reservoir)
void RifReaderMockModel::populateReservoir(RigReservoir* reservoir)
{
m_reservoirBuilder.populateReservoir(reservoir);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const QStringList& RifReaderInterfaceMock::timeStepText() const
{
return m_timeStepTexts;
}

View File

@ -0,0 +1,49 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "RifReaderInterface.h"
#include "RigReservoirBuilderMock.h"
class RifReaderMockModel : public RifReaderInterface
{
public:
RifReaderMockModel();
virtual ~RifReaderMockModel();
void setWorldCoordinates(cvf::Vec3d minWorldCoordinate, cvf::Vec3d maxWorldCoordinate);
void setGridPointDimensions(const cvf::Vec3st& gridPointDimensions);
void setResultInfo(size_t resultCount, size_t timeStepCount);
void addLocalGridRefinement(const cvf::Vec3st& minCellPosition, const cvf::Vec3st& maxCellPosition, const cvf::Vec3st& singleCellRefinementFactors);
virtual bool open( const QString& fileName, RigReservoir* reservoir );
virtual void close();
virtual bool staticResult( const QString& result, std::vector<double>* values );
virtual bool dynamicResult( const QString& result, size_t stepIndex, std::vector<double>* values );
private:
void populateReservoir(RigReservoir* reservoir);
bool inputProperty( const QString& propertyName, std::vector<double>* values );
RigReservoirBuilderMock m_reservoirBuilder;
cvf::ref<RigReservoir> m_reservoir;
};

View File

@ -88,7 +88,10 @@ void RivCellEdgeGeometryGenerator::addCellEdgeResultsToDrawableGeo(
CVF_ASSERT(grid != NULL);
const std::vector< double >* cellScalarResults = NULL;
bool cellScalarResultUseGlobalActiveIndex = true;
const std::vector< double >* edgeScalarResults[6] = {NULL, NULL, NULL, NULL, NULL, NULL};
bool edgeScalarResultUseGlobalActiveIndex[6];
if (cellResultSlot->hasResult())
{
@ -101,6 +104,8 @@ void RivCellEdgeGeometryGenerator::addCellEdgeResultsToDrawableGeo(
{
cellScalarResults = &scalarResultTimeSteps[0];
}
cellScalarResultUseGlobalActiveIndex = grid->mainGrid()->results()->isUsingGlobalActiveIndex(cellResultSlot->gridScalarIndex());
}
size_t resultIndices[6];
@ -115,6 +120,7 @@ void RivCellEdgeGeometryGenerator::addCellEdgeResultsToDrawableGeo(
{
const std::vector< std::vector<double> >& scalarResultTimeSteps = grid->mainGrid()->results()->cellScalarResults(resultIndices[cubeFaceIdx]);
edgeScalarResults[cubeFaceIdx] = &scalarResultTimeSteps[0]; // Assuming only static edge results
edgeScalarResultUseGlobalActiveIndex[cubeFaceIdx] = grid->mainGrid()->results()->isUsingGlobalActiveIndex(resultIndices[cubeFaceIdx]);
}
}
}
@ -136,7 +142,12 @@ void RivCellEdgeGeometryGenerator::addCellEdgeResultsToDrawableGeo(
float cellColorTextureCoord = 0.5f; // If no results exists, the texture will have a special color
size_t cellIndex = quadToCell[quadIdx];
size_t resultIndex = grid->cell(cellIndex).globalActiveIndex();
size_t resultIndex = cellIndex;
if (cellScalarResultUseGlobalActiveIndex)
{
resultIndex = grid->cell(cellIndex).globalActiveIndex();
}
if (cellScalarResults )
{
@ -163,6 +174,12 @@ void RivCellEdgeGeometryGenerator::addCellEdgeResultsToDrawableGeo(
{
edgeColor = -1.0f; // Undefined texture coord. Shader handles this.
resultIndex = cellIndex;
if (edgeScalarResultUseGlobalActiveIndex[cubeFaceIdx])
{
resultIndex = grid->cell(cellIndex).globalActiveIndex();
}
if (resultIndices[cubeFaceIdx] != cvf::UNDEFINED_SIZE_T && resultIndex != cvf::UNDEFINED_SIZE_T)
{
double scalarValue = (*(edgeScalarResults[cubeFaceIdx]))[resultIndex];

View File

@ -22,6 +22,7 @@
#include "RimReservoirView.h"
#include "RimWellCollection.h"
#include "RivWellPipesPartMgr.h"
#include "RivWellHeadPartMgr.h"
//--------------------------------------------------------------------------------------------------
@ -52,7 +53,7 @@ void RivReservoirPipesPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasic
if (m_reservoirView->wellCollection()->wells.size() != m_wellPipesPartMgrs.size())
{
m_wellPipesPartMgrs.clear();
m_wellPipesPartMgrs.clear();
m_wellHeadPartMgrs.clear();
for (size_t i = 0; i < m_reservoirView->wellCollection()->wells.size(); ++i)
{

View File

@ -22,10 +22,10 @@
#include "cvfCollection.h"
#include "RivWellHeadPartMgr.h"
class RimReservoirView;
class RivWellPipesPartMgr;
class RivWellHeadPartMgr;
class RivReservoirPipesPartMgr : public cvf::Object
{

View File

@ -601,17 +601,23 @@ void RivReservoirViewPartMgr::computePropertyVisibility(cvf::UByteArray* cellVis
}
const RimCellFilter::FilterModeType filterType = (*pfIt)->filterMode();
bool useGlobalActiveIndex = grid->mainGrid()->results()->isUsingGlobalActiveIndex((*pfIt)->resultDefinition->gridScalarIndex());
#pragma omp parallel for schedule(dynamic)
for (int cellIndex = 0; cellIndex < static_cast<int>(grid->cellCount()); cellIndex++)
{
if ( (*cellVisibility)[cellIndex] )
{
size_t resultIndex = grid->cell(cellIndex).globalActiveIndex();
double value = HUGE_VAL;
if (resultIndex != cvf::UNDEFINED_SIZE_T) value = (*scalarResult)[resultIndex];
size_t resultIndex = cellIndex;
if (useGlobalActiveIndex)
{
resultIndex = grid->cell(cellIndex).globalActiveIndex();
}
double scalarValue = HUGE_VAL;
if (resultIndex != cvf::UNDEFINED_SIZE_T) scalarValue = (*scalarResult)[resultIndex];
if (lowerBound <= value && value <= upperBound)
if (lowerBound <= scalarValue && scalarValue <= upperBound)
{
if (filterType == RimCellFilter::EXCLUDE)
{

View File

@ -18,6 +18,8 @@
#include "RivWellHeadPartMgr.h"
#include "cvfLibCore.h"
#include "cvfModelBasicList.h"
@ -38,7 +40,6 @@
#include "RigCell.h"
#include "RivPipeGeometryGenerator.h"
#include "RivWellHeadPartMgr.h"
#include "RivWellPipesPartMgr.h"
@ -49,6 +50,8 @@ RivWellHeadPartMgr::RivWellHeadPartMgr(RimReservoirView* reservoirView, RimWell*
{
m_rimReservoirView = reservoirView;
m_rimWell = well;
m_font = new cvf::FixedAtlasFont(cvf::FixedAtlasFont::LARGE);
}
//--------------------------------------------------------------------------------------------------
@ -110,7 +113,7 @@ void RivWellHeadPartMgr::buildWellHeadParts(size_t frameIndex)
cvf::ref<RivPipeGeometryGenerator> pipeGeomGenerator = new RivPipeGeometryGenerator;
pipeGeomGenerator->setPipeCenterCoords(wellHeadPipeCoords.p());
pipeGeomGenerator->setPipeColor(well->wellPipeColor());
pipeGeomGenerator->setCrossSectionVertexCount(12);
pipeGeomGenerator->setCrossSectionVertexCount(m_rimReservoirView->wellCollection()->pipeCrossSectionVertexCount());
double pipeRadius = m_rimReservoirView->wellCollection()->pipeRadiusScaleFactor() * m_rimWell->pipeRadiusScaleFactor() * characteristicCellSize;
pipeGeomGenerator->setRadius(pipeRadius);
@ -121,6 +124,7 @@ void RivWellHeadPartMgr::buildWellHeadParts(size_t frameIndex)
if (pipeSurface.notNull())
{
cvf::ref<cvf::Part> part = new cvf::Part;
part->setName("RivWellHeadPartMgr: surface " + cvfqt::Utils::fromQString(well->name()));
part->setDrawable(pipeSurface.p());
caf::SurfaceEffectGenerator surfaceGen(cvf::Color4f(well->wellPipeColor()), true);
@ -134,6 +138,7 @@ void RivWellHeadPartMgr::buildWellHeadParts(size_t frameIndex)
if (centerLineDrawable.notNull())
{
cvf::ref<cvf::Part> part = new cvf::Part;
part->setName("RivWellHeadPartMgr: centerline " + cvfqt::Utils::fromQString(well->name()));
part->setDrawable(centerLineDrawable.p());
caf::MeshEffectGenerator meshGen(well->wellPipeColor());
@ -172,6 +177,7 @@ void RivWellHeadPartMgr::buildWellHeadParts(size_t frameIndex)
gen.setShaftRelativeRadius(0.5f);
gen.setHeadRelativeRadius(1.0f);
gen.setHeadRelativeLength(0.4f);
gen.setNumSlices(m_rimReservoirView->wellCollection()->pipeCrossSectionVertexCount());
gen.generate(&builder);
cvf::ref<cvf::Vec3fArray> vertices = builder.vertices();
@ -193,6 +199,7 @@ void RivWellHeadPartMgr::buildWellHeadParts(size_t frameIndex)
{
cvf::ref<cvf::Part> part = new cvf::Part;
part->setName("RivWellHeadPartMgr: arrow " + cvfqt::Utils::fromQString(well->name()));
part->setDrawable(geo1.p());
cvf::Color4f headColor(cvf::Color3::GRAY);
@ -226,7 +233,7 @@ void RivWellHeadPartMgr::buildWellHeadParts(size_t frameIndex)
if (m_rimReservoirView->wellCollection()->showWellLabel() && well->showWellLabel())
{
cvf::ref<cvf::DrawableText> drawableText = new cvf::DrawableText;
drawableText->setFont(new cvf::FixedAtlasFont(cvf::FixedAtlasFont::LARGE));
drawableText->setFont(m_font.p());
drawableText->setCheckPosVisible(false);
drawableText->setDrawBorder(false);
drawableText->setDrawBackground(false);
@ -239,6 +246,7 @@ void RivWellHeadPartMgr::buildWellHeadParts(size_t frameIndex)
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;

View File

@ -18,14 +18,22 @@
#pragma once
#include "cvfBase.h"
#include "cvfAssert.h"
#include "cvfObject.h"
#include "cafPdmPointer.h"
#include "cvfCollection.h"
namespace cvf
{
class Part;
class ModelBasicList;
class Transform;
class Font;
}
class RimWell;
class RimReservoirView;
class RivWellHeadPartMgr : public cvf::Object
{
@ -48,4 +56,6 @@ private:
cvf::ref<cvf::Transform> m_scaleTransform;
cvf::Collection< cvf::Part > m_wellHeadParts;
cvf::ref<cvf::Font> m_font;
};

View File

@ -41,6 +41,26 @@ RivWellPipesPartMgr::RivWellPipesPartMgr(RimReservoirView* reservoirView, RimWel
m_rimReservoirView = reservoirView;
m_rimWell = well;
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->setLevelsFromColorCount(4);
m_scalarMapper = scalarMapper;
caf::ScalarMapperEffectGenerator surfEffGen(scalarMapper.p(), true);
m_scalarMapperSurfaceEffect = surfEffGen.generateEffect();
caf::ScalarMapperMeshEffectGenerator meshEffGen(scalarMapper.p());
m_scalarMapperMeshEffect = meshEffGen.generateEffect();
}
//--------------------------------------------------------------------------------------------------
@ -62,25 +82,24 @@ void RivWellPipesPartMgr::buildWellPipeParts()
std::vector< size_t > pipeBranchIds;
std::vector< std::vector <cvf::Vec3d> > pipeBranchesCLCoords;
std::vector< std::vector <CellId> > pipeBranchesCellIds;
std::vector< std::vector <RigWellResultCell> > pipeBranchesCellIds;
calculateWellPipeCenterline( pipeBranchIds, pipeBranchesCLCoords, pipeBranchesCellIds);
calculateWellPipeCenterline(pipeBranchesCLCoords, pipeBranchesCellIds);
double characteristicCellSize = m_rimReservoirView->eclipseCase()->reservoirData()->mainGrid()->characteristicCellSize();
double pipeRadius = m_rimReservoirView->wellCollection()->pipeRadiusScaleFactor() *m_rimWell->pipeRadiusScaleFactor() * characteristicCellSize;
for (size_t brIdx = 0; brIdx < pipeBranchIds.size(); ++brIdx)
for (size_t brIdx = 0; brIdx < pipeBranchesCellIds.size(); ++brIdx)
{
m_wellBranches.push_back(RivPipeBranchData());
RivPipeBranchData& pbd = m_wellBranches.back();
pbd.m_branchId = pipeBranchIds[brIdx];
pbd.m_cellIds = pipeBranchesCellIds[brIdx];
pbd.m_pipeGeomGenerator = new RivPipeGeometryGenerator;
pbd.m_pipeGeomGenerator->setRadius(pipeRadius);
pbd.m_pipeGeomGenerator->setCrossSectionVertexCount(12);
pbd.m_pipeGeomGenerator->setCrossSectionVertexCount(m_rimReservoirView->wellCollection()->pipeCrossSectionVertexCount());
pbd.m_pipeGeomGenerator->setPipeColor( m_rimWell->wellPipeColor());
cvf::ref<cvf::Vec3dArray> cvfCoords = new cvf::Vec3dArray;
@ -131,12 +150,13 @@ void RivWellPipesPartMgr::buildWellPipeParts()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivWellPipesPartMgr::calculateWellPipeCenterline( std::vector< size_t >& pipeBranchIds,
std::vector< std::vector <cvf::Vec3d> >& pipeBranchesCLCoords,
std::vector< std::vector <CellId> >& pipeBranchesCellIds) const
void RivWellPipesPartMgr::calculateWellPipeCenterline( std::vector< std::vector <cvf::Vec3d> >& pipeBranchesCLCoords,
std::vector< std::vector <RigWellResultCell> >& pipeBranchesCellIds) const
{
CVF_ASSERT(m_rimWell.notNull());
CVF_ASSERT(m_rimReservoirView.notNull());
bool isAutoDetectBranches = m_rimReservoirView->wellCollection()->isAutoDetectingBranches();
RigReservoir* rigReservoir = m_rimReservoirView->eclipseCase()->reservoirData();
RigWellResults* wellResults = m_rimWell->wellResults();
@ -151,7 +171,6 @@ void RivWellPipesPartMgr::calculateWellPipeCenterline( std::vector< size_t >& p
if (staticWellFrame.m_wellResultBranches.size() == 0) return;
// Initialize the return arrays
pipeBranchIds.clear();
pipeBranchesCLCoords.clear();
pipeBranchesCellIds.clear();
@ -163,115 +182,134 @@ void RivWellPipesPartMgr::calculateWellPipeCenterline( std::vector< size_t >& p
// Loop over all the well branches
const std::vector<RigWellResultBranch>& resBranches = staticWellFrame.m_wellResultBranches;
for (size_t brIdx = 0; brIdx < resBranches.size(); brIdx++)
bool hasResultCells = false;
if (resBranches.size())
{
if (resBranches[brIdx].m_wellCells.size() == 0) continue; // Skip empty branches. Do not know why they exist, but they make problems.
for (size_t i = 0 ; i < resBranches.size(); ++i)
{
if (resBranches[i].m_wellCells.size() != 0)
{
hasResultCells = true;
}
}
}
if (hasResultCells)
{
// Create a new branch from wellhead
// Create a new branch
pipeBranchIds.push_back(resBranches[brIdx].m_branchNumber);
pipeBranchesCLCoords.push_back(std::vector<cvf::Vec3d>());
pipeBranchesCellIds.push_back(std::vector <CellId>());
pipeBranchesCellIds.push_back(std::vector <RigWellResultCell>());
// We start by entering the first cell (the wellhead)
const RigWellResultCell* prevResCell = whResCell;
pipeBranchesCLCoords.back().push_back(whStartPos);
pipeBranchesCellIds.back().push_back(CellId(prevResCell->m_gridIndex, prevResCell->m_gridCellIndex));
pipeBranchesCellIds.back().push_back(*prevResCell );
// Add extra coordinate between cell face and cell center
// to make sure the well pipe terminated in a segment parallel to z-axis
cvf::Vec3d whIntermediate = whStartPos;
whIntermediate.z() = (whStartPos.z() + whCell.center().z()) / 2.0;
pipeBranchesCLCoords.back().push_back(whIntermediate);
pipeBranchesCellIds.back().push_back(CellId(prevResCell->m_gridIndex, prevResCell->m_gridCellIndex));
pipeBranchesCellIds.back().push_back(*prevResCell );
// Loop over all the resultCells in the branch
const std::vector<RigWellResultCell>& resBranchCells = resBranches[brIdx].m_wellCells;
for (size_t cIdx = 0; cIdx < resBranchCells.size(); cIdx++)
for (size_t brIdx = 0; brIdx < resBranches.size(); brIdx++)
{
std::vector<cvf::Vec3d>& branchCLCoords = pipeBranchesCLCoords.back();
std::vector<CellId>& branchCellIds = pipeBranchesCellIds.back();
if (resBranches[brIdx].m_wellCells.size() == 0)
continue; // Skip empty branches. Do not know why they exist, but they make problems.
const RigWellResultCell& resCell = resBranchCells[cIdx];
const RigCell& cell = rigReservoir->cellFromWellResultCell(resCell);
// Loop over all the resultCells in the branch
const std::vector<RigWellResultCell>& resBranchCells = resBranches[brIdx].m_wellCells;
// Check if this and the previous cells has shared faces
cvf::StructGridInterface::FaceType sharedFace;
if (rigReservoir->findSharedSourceFace(sharedFace, resCell, *prevResCell))
for (int cIdx = 0; cIdx < static_cast<int>(resBranchCells.size()); cIdx++) // Need int because cIdx can temporarily end on -1
{
branchCLCoords.push_back(cell.faceCenter(sharedFace));
branchCellIds.push_back(CellId(resCell.m_gridIndex, resCell.m_gridCellIndex));
}
else
{
// This and the previous cell does not share a face. We need to go out of the previous cell, before entering this.
const RigCell& prevCell = rigReservoir->cellFromWellResultCell(*prevResCell);
cvf::Vec3d centerPrevCell = prevCell.center();
cvf::Vec3d centerThisCell = cell.center();
std::vector<cvf::Vec3d>& branchCLCoords = pipeBranchesCLCoords.back();
std::vector<RigWellResultCell>& branchCellIds = pipeBranchesCellIds.back();
// First make sure this cell is not starting a new "display" branch
if ( (prevResCell == whResCell) || (centerThisCell-centerPrevCell).lengthSquared() <= (centerThisCell - whStartPos).lengthSquared())
const RigWellResultCell& resCell = resBranchCells[cIdx];
const RigCell& cell = rigReservoir->cellFromWellResultCell(resCell);
// Check if this and the previous cells has shared faces
cvf::StructGridInterface::FaceType sharedFace;
if (rigReservoir->findSharedSourceFace(sharedFace, resCell, *prevResCell))
{
// Create ray and intersect with cells
cvf::Ray rayToThisCell;
rayToThisCell.setOrigin(centerPrevCell);
rayToThisCell.setDirection((centerThisCell - centerPrevCell).getNormalized());
cvf::Vec3d outOfPrevCell(centerPrevCell);
cvf::Vec3d intoThisCell(centerThisCell);
bool intersectionOk = prevCell.firstIntersectionPoint(rayToThisCell, &outOfPrevCell);
//CVF_ASSERT(intersectionOk);
intersectionOk = cell.firstIntersectionPoint(rayToThisCell, &intoThisCell);
//CVF_ASSERT(intersectionOk);
if ((intoThisCell - outOfPrevCell).lengthSquared() > 1e-3)
{
branchCLCoords.push_back(outOfPrevCell);
branchCellIds.push_back(CellId(cvf::UNDEFINED_SIZE_T, cvf::UNDEFINED_SIZE_T));
}
branchCLCoords.push_back(intoThisCell);
branchCellIds.push_back(CellId(resCell.m_gridIndex, resCell.m_gridCellIndex));
branchCLCoords.push_back(cell.faceCenter(sharedFace));
branchCellIds.push_back(resCell);
}
else
{
// This cell is further from the previous cell than from the well head,
// thus we interpret it as a new branch.
// This and the previous cell does not share a face. We need to go out of the previous cell, before entering this.
const RigCell& prevCell = rigReservoir->cellFromWellResultCell(*prevResCell);
cvf::Vec3d centerPrevCell = prevCell.center();
cvf::Vec3d centerThisCell = cell.center();
// First finish the current branch
branchCLCoords.push_back(branchCLCoords.back() + 1.5*(centerPrevCell - branchCLCoords.back()) );
// First make sure this cell is not starting a new "display" branch
if ( !isAutoDetectBranches || (prevResCell == whResCell)
|| (centerThisCell-centerPrevCell).lengthSquared() <= (centerThisCell - whStartPos).lengthSquared())
{
// Not starting a "display" branch
// Create ray and intersect with cells
// Create new display branch
pipeBranchIds.push_back(resBranches[brIdx].m_branchNumber);
pipeBranchesCLCoords.push_back(std::vector<cvf::Vec3d>());
pipeBranchesCellIds.push_back(std::vector <CellId>());
cvf::Ray rayToThisCell;
rayToThisCell.setOrigin(centerPrevCell);
rayToThisCell.setDirection((centerThisCell - centerPrevCell).getNormalized());
// Start the new branch by entering the first cell (the wellhead) and intermediate
prevResCell = whResCell;
pipeBranchesCLCoords.back().push_back(whStartPos);
pipeBranchesCellIds.back().push_back(CellId(prevResCell->m_gridIndex, prevResCell->m_gridCellIndex));
cvf::Vec3d outOfPrevCell(centerPrevCell);
cvf::Vec3d intoThisCell(centerThisCell);
// Include intermediate
pipeBranchesCLCoords.back().push_back(whIntermediate);
pipeBranchesCellIds.back().push_back(CellId(prevResCell->m_gridIndex, prevResCell->m_gridCellIndex));
bool intersectionOk = prevCell.firstIntersectionPoint(rayToThisCell, &outOfPrevCell);
//CVF_ASSERT(intersectionOk);
intersectionOk = cell.firstIntersectionPoint(rayToThisCell, &intoThisCell);
//CVF_ASSERT(intersectionOk);
if ((intoThisCell - outOfPrevCell).lengthSquared() > 1e-3)
{
branchCLCoords.push_back(outOfPrevCell);
branchCellIds.push_back(RigWellResultCell());
}
branchCLCoords.push_back(intoThisCell);
branchCellIds.push_back(resCell);
}
else
{
// This cell is further from the previous cell than from the well head,
// thus we interpret it as a new branch.
// Well now we need to step one back to take this cell again, but in the new branch.
cIdx--;
continue;
// First finish the current branch
branchCLCoords.push_back(branchCLCoords.back() + 1.5*(centerPrevCell - branchCLCoords.back()) );
// Create new display branch
pipeBranchesCLCoords.push_back(std::vector<cvf::Vec3d>());
pipeBranchesCellIds.push_back(std::vector <RigWellResultCell>());
// Start the new branch by entering the first cell (the wellhead) and intermediate
prevResCell = whResCell;
pipeBranchesCLCoords.back().push_back(whStartPos);
pipeBranchesCellIds.back().push_back(*prevResCell);
// Include intermediate
pipeBranchesCLCoords.back().push_back(whIntermediate);
pipeBranchesCellIds.back().push_back(*prevResCell);
// Well now we need to step one back to take this cell again, but in the new branch.
cIdx--;
continue;
}
}
}
prevResCell = &resCell;
prevResCell = &resCell;
// If we are looking at last cell, add the point 0.5 past the center of that cell
if (cIdx == resBranchCells.size() -1)
{
branchCLCoords.push_back(branchCLCoords.back() + 1.5*(cell.center() - branchCLCoords.back()) );
}
}
}
// For the last cell, add the point 0.5 past the center of that cell
const RigCell& prevCell = rigReservoir->cellFromWellResultCell(*prevResCell);
cvf::Vec3d centerPrevCell = prevCell.center();
pipeBranchesCLCoords.back().push_back(pipeBranchesCLCoords.back().back() + 1.5*(centerPrevCell - pipeBranchesCLCoords.back().back()) );
}
CVF_ASSERT(pipeBranchesCellIds.size() == pipeBranchesCLCoords.size());
@ -324,18 +362,6 @@ void RivWellPipesPartMgr::updatePipeResultColor(size_t frameIndex)
if (frameIndex < wRes->firstResultTimeStep()) return; // Or reset colors or something
// 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->setLevelsFromColorCount(4);
const double closed = -0.1, producing = 1.5, water = 2.5, hcInjection = 3.5; // Closed set to -0.1 instead of 0.5 to workaround bug in the scalar mapper.
std::list<RivPipeBranchData>::iterator brIt;
@ -345,77 +371,48 @@ void RivWellPipesPartMgr::updatePipeResultColor(size_t frameIndex)
for (brIt = m_wellBranches.begin(); brIt != m_wellBranches.end(); ++brIt)
{
size_t branchId = brIt->m_branchId;
// find corresponding result branch
size_t i;
for ( i = 0; i < wResFrame.m_wellResultBranches.size(); ++i)
{
if (wResFrame.m_wellResultBranches[i].m_branchNumber == branchId) break;
}
// Initialize well states to "closed" state
wellCellStates.clear();
wellCellStates.resize(brIt->m_cellIds.size(), closed);
// Find result values
if (i >= wResFrame.m_wellResultBranches.size())
const std::vector <RigWellResultCell>& cellIds = brIt->m_cellIds;
for (size_t wcIdx = 0; wcIdx < cellIds.size(); ++wcIdx)
{
// Branch not found in results. Do nothing. Keep the "closed" states
}
else
{
const std::vector<RigWellResultCell>& resBranch = wResFrame.m_wellResultBranches[i].m_wellCells;
const std::vector <CellId>& cellIds = brIt->m_cellIds;
// we need a faster lookup, I guess
const RigWellResultCell* wResCell = wResFrame.findResultCell(cellIds[wcIdx].m_gridIndex, cellIds[wcIdx].m_gridCellIndex);
// Find cellIds[wcIdx] in resBranch
// ifFound then give color from cell state
// else give closed color
// The search can be simplified to comparing the current element against
// the first unmatched element in the result branch vector since the result is (supposed) to be
// a subset of the complete branch where all elements have the same order
size_t rcIdx = 0; // index to first unmatched element in results
for (size_t wcIdx = 0; wcIdx < cellIds.size(); ++wcIdx)
if (wResCell == NULL)
{
if (rcIdx >= resBranch.size())
// We cant find any state. This well cell is closed.
}
else
{
double cellState = closed;
if (wResCell->m_isOpen)
{
// We are beyond the result cells. This well cell is closed.
}
else
{
if ( cellIds[wcIdx].gridIndex == resBranch[rcIdx].m_gridIndex
&& cellIds[wcIdx].cellIndex == resBranch[rcIdx].m_gridCellIndex)
switch (wResFrame.m_productionType)
{
double cellState = closed;
if (resBranch[rcIdx].m_isOpen)
{
switch (wResFrame.m_productionType)
{
case RigWellResultFrame::PRODUCER:
cellState = producing;
break;
case RigWellResultFrame::OIL_INJECTOR:
cellState = hcInjection;
break;
case RigWellResultFrame::GAS_INJECTOR:
cellState = hcInjection;
break;
case RigWellResultFrame::WATER_INJECTOR:
cellState = water;
break;
case RigWellResultFrame::UNDEFINED_PRODUCTION_TYPE:
cellState = closed;
break;
}
}
wellCellStates[wcIdx] = cellState;
rcIdx++;
case RigWellResultFrame::PRODUCER:
cellState = producing;
break;
case RigWellResultFrame::OIL_INJECTOR:
cellState = hcInjection;
break;
case RigWellResultFrame::GAS_INJECTOR:
cellState = hcInjection;
break;
case RigWellResultFrame::WATER_INJECTOR:
cellState = water;
break;
case RigWellResultFrame::UNDEFINED_PRODUCTION_TYPE:
cellState = closed;
break;
}
}
wellCellStates[wcIdx] = cellState;
}
}
@ -430,13 +427,10 @@ void RivWellPipesPartMgr::updatePipeResultColor(size_t frameIndex)
surfTexCoords = new cvf::Vec2fArray;
}
brIt->m_pipeGeomGenerator->pipeSurfaceTextureCoords( surfTexCoords.p(), wellCellStates, scalarMapper.p());
brIt->m_pipeGeomGenerator->pipeSurfaceTextureCoords( surfTexCoords.p(), wellCellStates, m_scalarMapper.p());
brIt->m_surfaceDrawable->setTextureCoordArray( surfTexCoords.p());
caf::ScalarMapperEffectGenerator surfEffGen(scalarMapper.p(), true);
cvf::ref<cvf::Effect> seff = surfEffGen.generateEffect();
brIt->m_surfacePart->setEffect(seff.p());
brIt->m_surfacePart->setEffect(m_scalarMapperSurfaceEffect.p());
}
// Find or create texture coords array for pipe center line
@ -450,7 +444,7 @@ void RivWellPipesPartMgr::updatePipeResultColor(size_t frameIndex)
}
// Calculate new texture coordinates
brIt->m_pipeGeomGenerator->centerlineTextureCoords( lineTexCoords.p(), wellCellStates, scalarMapper.p());
brIt->m_pipeGeomGenerator->centerlineTextureCoords( lineTexCoords.p(), wellCellStates, m_scalarMapper.p());
// Set the new texture coordinates
@ -458,10 +452,7 @@ void RivWellPipesPartMgr::updatePipeResultColor(size_t frameIndex)
// Set effects
caf::ScalarMapperMeshEffectGenerator meshEffGen(scalarMapper.p());
cvf::ref<cvf::Effect> meff = meshEffGen.generateEffect();
brIt->m_centerLinePart->setEffect(meff.p());
brIt->m_centerLinePart->setEffect(m_scalarMapperMeshEffect.p());
}
}
}

View File

@ -20,12 +20,14 @@
#include "cafPdmPointer.h"
#include <list>
#include "RigWellResults.h"
namespace cvf
{
class Part;
class ModelBasicList;
class Transform;
class Effect;
}
class RivPipeGeometryGenerator;
@ -54,33 +56,17 @@ private:
bool m_needsTransformUpdate;
void buildWellPipeParts();
class CellId
{
public:
CellId() :
gridIndex(cvf::UNDEFINED_SIZE_T),
cellIndex(cvf::UNDEFINED_SIZE_T)
{ }
CellId(size_t gidx, size_t cIdx) :
gridIndex(gidx),
cellIndex(cIdx)
{ }
size_t gridIndex;
size_t cellIndex;
};
//void calculateWellPipeCenterline(std::vector<cvf::Vec3d>& coords) const;
void calculateWellPipeCenterline(std::vector< size_t >& pipeBranchIds,
std::vector< std::vector <cvf::Vec3d> >& pipeBranchesCLCoords,
std::vector< std::vector <CellId> >& pipeBranchesCellIds ) const;
void calculateWellPipeCenterline(std::vector< std::vector <cvf::Vec3d> >& pipeBranchesCLCoords,
std::vector< std::vector <RigWellResultCell> >& pipeBranchesCellIds ) const;
struct RivPipeBranchData
{
size_t m_branchId;
std::vector <CellId> m_cellIds;
std::vector <RigWellResultCell> m_cellIds;
//std::vector< std::vector<WellCellStatus> > m_cellStatusPrFrame;
cvf::ref<RivPipeGeometryGenerator> m_pipeGeomGenerator;
cvf::ref<cvf::Part> m_surfacePart;
@ -91,5 +77,8 @@ private:
};
std::list<RivPipeBranchData> m_wellBranches;
cvf::Collection< cvf::Part > m_wellPipeParts;
cvf::ref<cvf::ScalarMapper> m_scalarMapper;
cvf::ref<cvf::Effect> m_scalarMapperSurfaceEffect;
cvf::ref<cvf::Effect> m_scalarMapperMeshEffect;
};

View File

@ -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.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RIStdInclude.h"
#include "RimBinaryExportSettings.h"
#include "cafPdmUiFilePathEditor.h"
CAF_PDM_SOURCE_INIT(RimBinaryExportSettings, "RimBinaryExportSettings");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimBinaryExportSettings::RimBinaryExportSettings()
{
CAF_PDM_InitObject("RimBinaryExportSettings", "", "", "");
CAF_PDM_InitFieldNoDefault(&fileName, "Filename", "Export filename", "", "", "");
fileName.setUiEditorTypeName(caf::PdmUiFilePathEditor::uiEditorTypeName());
CAF_PDM_InitFieldNoDefault(&eclipseKeyword, "EclipseKeyword", "Eclipse Keyword", "", "", "");
CAF_PDM_InitField(&undefinedValue, "UndefinedValue", 0.0, "Undefined value", "", "", "");
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimBinaryExportSettings::defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute * attribute)
{
if (field == &fileName)
{
caf::PdmUiFilePathEditorAttribute* myAttr = static_cast<caf::PdmUiFilePathEditorAttribute*>(attribute);
if (myAttr)
{
myAttr->m_selectSaveFileName = true;
}
}
}

View File

@ -0,0 +1,42 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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"
//==================================================================================================
///
///
//==================================================================================================
class RimBinaryExportSettings : public caf::PdmObject
{
CAF_PDM_HEADER_INIT;
public:
RimBinaryExportSettings();
caf::PdmField<QString> fileName;
caf::PdmField<QString> eclipseKeyword;
caf::PdmField<double> undefinedValue;
protected:
virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute);
};

View File

@ -21,6 +21,7 @@
#include "cafPdmField.h"
#include "RimCalcScript.h"
#include "cafPdmUiFilePathEditor.h"
CAF_PDM_SOURCE_INIT(RimCalcScript, "CalcScript");
@ -33,7 +34,9 @@ RimCalcScript::RimCalcScript()
CAF_PDM_InitField(&absolutePath, "AbsolutePath", QString(), "Location", "", "" ,"");
CAF_PDM_InitField(&content, "Content", QString(), "Directory", "", "" ,"");
content.setHidden(true);
content.setUiHidden(true);
absolutePath.setUiEditorTypeName(caf::PdmUiFilePathEditor::uiEditorTypeName());
}
//--------------------------------------------------------------------------------------------------

View File

@ -25,7 +25,8 @@
#include "RimReservoirView.h"
#include "RigReservoirCellResults.h"
#include "RigReservoir.h"
#include "RifReaderInterface.h"
#include "cafPdmUiListEditor.h"
CAF_PDM_SOURCE_INIT(RimCellEdgeResultSlot, "CellEdgeResultSlot");
@ -37,9 +38,11 @@ RimCellEdgeResultSlot::RimCellEdgeResultSlot()
{
CAF_PDM_InitObject("Cell Edge Result", "", "", "");
CAF_PDM_InitFieldNoDefault(&resultVariable, "CellEdgeVariable", "Result variable", ":/Default.png", "", "");
CAF_PDM_InitFieldNoDefault(&resultVariable, "CellEdgeVariable", "Result variable", "", "", "");
CAF_PDM_InitFieldNoDefault(&legendConfig, "LegendDefinition", "Legend Definition", ":/Legend.png", "", "");
resultVariable.setUiEditorTypeName(caf::PdmUiListEditor::uiEditorTypeName());
legendConfig = new RimLegendConfig();
m_ignoredResultScalar = cvf::UNDEFINED_DOUBLE;
@ -68,13 +71,16 @@ void RimCellEdgeResultSlot::setReservoirView(RimReservoirView* ownerReservoirVie
//--------------------------------------------------------------------------------------------------
void RimCellEdgeResultSlot::loadResult()
{
CVF_ASSERT(m_reservoirView && m_reservoirView->gridCellResults());
resetResultIndices();
QStringList vars = findResultVariableNames();
updateIgnoredScalarValue();
int i;
for (i = 0; i < vars.size(); ++i)
{
size_t resultindex = gridCellResults()->loadResultIntoGrid(RimDefines::STATIC_NATIVE, vars[i]);
size_t resultindex = m_reservoirView->gridCellResults()->findOrLoadScalarResult(RimDefines::STATIC_NATIVE, vars[i]);
int cubeFaceIdx;
for (cubeFaceIdx = 0; cubeFaceIdx < 6; ++cubeFaceIdx)
{
@ -124,10 +130,13 @@ QList<caf::PdmOptionItemInfo> RimCellEdgeResultSlot::calculateValueOptions(const
{
if (fieldNeedingOptions == &resultVariable)
{
if (fileReaderinterface())
if (m_reservoirView && m_reservoirView->gridCellResults())
{
QStringList varList;
varList = fileReaderinterface()->staticResults();
varList = m_reservoirView->gridCellResults()->resultNames(RimDefines::STATIC_NATIVE);
//TODO: Must also handle input properties
//varList += m_reservoirView->gridCellResults()->resultNames(RimDefines::INPUT_PROPERTY);
QList<caf::PdmOptionItemInfo> optionList;
@ -196,10 +205,12 @@ QStringList RimCellEdgeResultSlot::findResultVariableNames()
{
QStringList varNames;
if (fileReaderinterface() && !resultVariable().isEmpty())
if (m_reservoirView && m_reservoirView->gridCellResults() && !resultVariable().isEmpty())
{
QStringList varList;
varList = fileReaderinterface()->staticResults();
varList = m_reservoirView->gridCellResults()->resultNames(RimDefines::STATIC_NATIVE);
//TODO: Must handle Input properties
int i;
for (i = 0; i < varList.size(); ++i)
{
@ -212,33 +223,7 @@ QStringList RimCellEdgeResultSlot::findResultVariableNames()
return varNames;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigReservoirCellResults* RimCellEdgeResultSlot::gridCellResults()
{
CVF_ASSERT(m_reservoirView != NULL
&& m_reservoirView->eclipseCase()
&& m_reservoirView->eclipseCase()->reservoirData()
&& m_reservoirView->eclipseCase()->reservoirData()->mainGrid());
return m_reservoirView->eclipseCase()->reservoirData()->mainGrid()->results();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RifReaderInterface* RimCellEdgeResultSlot::fileReaderinterface()
{
if (m_reservoirView && m_reservoirView->eclipseCase())
{
return m_reservoirView->eclipseCase()->fileInterface();
}
else
{
return NULL;
}
}
//--------------------------------------------------------------------------------------------------
///

View File

@ -75,9 +75,6 @@ protected:
QStringList findResultVariableNames();
private:
RigReservoirCellResults* gridCellResults();
RifReaderInterface* fileReaderinterface();
void resetResultIndices();
void updateIgnoredScalarValue();
protected:

View File

@ -53,7 +53,16 @@ RimCellPropertyFilter::RimCellPropertyFilter()
CAF_PDM_InitFieldNoDefault(&resultDefinition, "ResultDefinition", "Result definition", "", "", "");
resultDefinition = new RimResultDefinition();
resultDefinition.setHidden(true);
// Take ownership of the fields in RimResultDefinition to be able to trap fieldChangedByUi in this class
resultDefinition->resultType.setOwnerObject(this);
resultDefinition->resultVariable.setOwnerObject(this);
resultDefinition->resultType.setUiName("");
resultDefinition->resultVariable.setUiName("");
// Set to hidden to avoid this item to been displayed as a child item
// Fields in this object are displayed using defineUiOrdering()
resultDefinition.setUiHidden(true);
CAF_PDM_InitField(&lowerBound, "LowerBound", 0.0, "Min", "", "", "");
CAF_PDM_InitField(&upperBound, "UpperBound", 0.0, "Max", "", "", "");
@ -76,8 +85,10 @@ void RimCellPropertyFilter::fieldChangedByUi(const caf::PdmFieldHandle* changedF
if (changedField == &name)
{
}
else if (&resultDefinition == changedField)
else if (&(resultDefinition->resultType) == changedField || &(resultDefinition->resultVariable) == changedField)
{
resultDefinition->fieldChangedByUi(changedField, oldValue, newValue);
setDefaultValues();
m_parentContainer->fieldChangedByUi(changedField, oldValue, newValue);
}
@ -86,71 +97,6 @@ void RimCellPropertyFilter::fieldChangedByUi(const caf::PdmFieldHandle* changedF
m_parentContainer->fieldChangedByUi(changedField, oldValue, newValue);
this->updateIconState();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimCellPropertyFilter::isCellRejected(const RigGridBase* grid, size_t timeStepIndex, size_t cellIndex) const
{
CVF_ASSERT(grid);
if (resultDefinition->gridScalarIndex() == cvf::UNDEFINED_SIZE_T)
{
return false;
}
size_t resultIndex = 0;
if (resultDefinition->hasDynamicResult())
{
resultIndex = timeStepIndex;
}
double scalarValue = grid->cellScalar(resultIndex, resultDefinition->gridScalarIndex(), cellIndex);
bool rejected = false;
if (scalarValue < lowerBound || scalarValue > upperBound)
{
rejected = true;
}
if (filterMode == INCLUDE)
{
return rejected;
}
else
{
return !rejected;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::CellRangeFilter::CellStateType RimCellPropertyFilter::cellFilterState(const RigGridBase* grid, size_t timeStepIndex, size_t cellIndex) const
{
CVF_TIGHT_ASSERT(grid);
CVF_TIGHT_ASSERT(resultDefinition->gridScalarIndex() != cvf::UNDEFINED_SIZE_T);
size_t tStepIdx = 0;
if (resultDefinition->hasDynamicResult())
{
tStepIdx = timeStepIndex;
}
double scalarValue = grid->cellScalar(tStepIdx, resultDefinition->gridScalarIndex(), cellIndex);
if ( lowerBound <= scalarValue && scalarValue <= upperBound)
{
if (filterMode == INCLUDE) return cvf::CellRangeFilter::INCLUDED;
else return cvf::CellRangeFilter::EXCLUDED;
}
else
{
return cvf::CellRangeFilter::NOT_INCLUDED;
}
}
//--------------------------------------------------------------------------------------------------
@ -204,3 +150,26 @@ void RimCellPropertyFilter::setDefaultValues()
upperBound.setUiName(QString("Max (%1)").arg(max));
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimCellPropertyFilter::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) const
{
// Fields declared in RimCellFilter
uiOrdering.add(&name);
// Fields declared in RimResultDefinition
caf::PdmUiGroup* group1 = uiOrdering.addNewGroup("Result");
group1->add(&(resultDefinition->resultType));
group1->add(&(resultDefinition->resultVariable));
// Fields declared in RimCellFilter
uiOrdering.add(&active);
uiOrdering.add(&filterMode);
// Fields declared in this class (RimCellPropertyFilter)
uiOrdering.add(&lowerBound);
uiOrdering.add(&upperBound);
uiOrdering.add(&filterMode);
}

View File

@ -33,6 +33,7 @@ class RimResultDefinition;
class RigGridBase;
class RigReservoirCellResults;
namespace cvf
{
//enum CellRangeFilter::CellStateType;
@ -66,13 +67,13 @@ public:
caf::PdmField<double> upperBound;
caf::PdmField< caf::AppEnum< EvaluationRegionType > > evaluationRegion;
bool isCellRejected(const RigGridBase* grid, size_t timeStepIndex, size_t cellIndex) const;
cvf::CellRangeFilter::CellStateType cellFilterState(const RigGridBase* grid, size_t timeStepIndex, size_t cellIndex) const;
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue);
virtual QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly );
protected:
virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) const;
private:
RimCellPropertyFilterCollection* m_parentContainer;
};

View File

@ -102,64 +102,6 @@ RimCellPropertyFilter* RimCellPropertyFilterCollection::createAndAppendPropertyF
return propertyFilter;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimCellPropertyFilterCollection::isCellRejected(const RigGridBase* grid, size_t timeStepIndex, size_t cellIndex) const
{
std::list< caf::PdmPointer< RimCellPropertyFilter > >::const_iterator it;
if (propertyFilters.v().empty()) return false;
bool rejectCell = true;
for (it = propertyFilters.v().begin(); it != propertyFilters.v().end(); ++it)
{
if (!(*it)->isCellRejected(grid, timeStepIndex, cellIndex))
{
rejectCell = false;
}
}
return rejectCell;
}
cvf::CellRangeFilter::CellStateType RimCellPropertyFilterCollection::cellFilterState(const RigGridBase* grid, cvf::CellRangeFilter::CellStateType rangeCellState, size_t timeStepIndex, size_t cellIndex) const
{
bool included = false;
std::list< caf::PdmPointer< RimCellPropertyFilter > >::const_iterator it;
for (it = propertyFilters.v().begin(); it != propertyFilters.v().end(); ++it)
{
RimCellPropertyFilter* propertyFilter = *it;
CVF_ASSERT(propertyFilter);
if (propertyFilter->active() && propertyFilter->resultDefinition->hasResult())
{
// No property filter evaluation outside evaluation region
if (propertyFilter->evaluationRegion == RimCellPropertyFilter::RANGE_FILTER_REGION && rangeCellState != cvf::CellRangeFilter::INCLUDED)
{
continue;
}
bool rejected = propertyFilter->isCellRejected(grid, timeStepIndex, cellIndex);
if (propertyFilter->filterMode == RimCellFilter::EXCLUDE)
{
if (rejected)
{
// Reject from exclude filters will always win
return cvf::CellRangeFilter::EXCLUDED;
}
}
if (!rejected)
{
included = true;
}
}
}
return included ? cvf::CellRangeFilter::INCLUDED : cvf::CellRangeFilter::EXCLUDED;
}
//--------------------------------------------------------------------------------------------------
///

View File

@ -39,9 +39,6 @@ public:
RimCellPropertyFilter* createAndAppendPropertyFilter();
void remove(RimCellPropertyFilter* propertyFilter);
bool isCellRejected(const RigGridBase* grid, size_t timeStepIndex, size_t cellIndex) const;
cvf::CellRangeFilter::CellStateType cellFilterState(const RigGridBase* grid, cvf::CellRangeFilter::CellStateType rangeCellState, size_t timeStepIndex, size_t cellIndex) const;
bool hasActiveFilters() const;
bool hasActiveDynamicFilters() const;

View File

@ -20,7 +20,6 @@
#include "RimDefines.h"
#include "cafAppEnum.h"
#include "RifReaderInterface.h"
namespace caf
@ -30,7 +29,8 @@ namespace caf
{
addItem(RimDefines::DYNAMIC_NATIVE, "DYNAMIC_NATIVE", "Dynamic");
addItem(RimDefines::STATIC_NATIVE, "STATIC_NATIVE", "Static");
addItem(RimDefines::GENERATED, "Generated", "Generated");
addItem(RimDefines::GENERATED, "GENERATED", "Generated");
addItem(RimDefines::INPUT_PROPERTY, "INPUT_PROPERTY", "Input Property");
setDefault(RimDefines::DYNAMIC_NATIVE);
}

View File

@ -18,11 +18,7 @@
#pragma once
#include "cafPdmUiItem.h"
#include <QList>
class RifReaderInterface;
#include <QString>
class RimDefines
{
@ -32,8 +28,11 @@ public:
{
DYNAMIC_NATIVE,
STATIC_NATIVE,
GENERATED
GENERATED,
INPUT_PROPERTY,
REMOVED
};
static QString nonSelectedResultName() { return "None"; }
};

View File

@ -0,0 +1,54 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RIStdInclude.h"
#include "RimExportInputPropertySettings.h"
#include "cafPdmUiFilePathEditor.h"
CAF_PDM_SOURCE_INIT(RimExportInputSettings, "RimExportInputSettings");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimExportInputSettings::RimExportInputSettings()
{
CAF_PDM_InitObject("RimExportInputSettings", "", "", "");
CAF_PDM_InitFieldNoDefault(&fileName, "Filename", "Export filename", "", "", "");
fileName.setUiEditorTypeName(caf::PdmUiFilePathEditor::uiEditorTypeName());
CAF_PDM_InitFieldNoDefault(&eclipseKeyword, "Eclipse Keyword", "Keyword", "", "", "");
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimExportInputSettings::defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute * attribute)
{
if (field == &fileName)
{
caf::PdmUiFilePathEditorAttribute* myAttr = static_cast<caf::PdmUiFilePathEditorAttribute*>(attribute);
if (myAttr)
{
myAttr->m_selectSaveFileName = true;
}
}
}

View File

@ -0,0 +1,41 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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"
//==================================================================================================
///
///
//==================================================================================================
class RimExportInputSettings : public caf::PdmObject
{
CAF_PDM_HEADER_INIT;
public:
RimExportInputSettings();
caf::PdmField<QString> fileName;
caf::PdmField<QString> eclipseKeyword;
protected:
virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute);
};

View File

@ -0,0 +1,72 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RIStdInclude.h"
#include "RimInputProperty.h"
#include "cvfAssert.h"
#include "cafPdmUiLineEditor.h"
#include <QString>
namespace caf {
template<>
void RimInputProperty::ResolveStateEnum::setUp()
{
addItem(RimInputProperty::UNKNOWN, "UNKNOWN", "Unknown");
addItem(RimInputProperty::FILE_MISSING, "FILE_MISSING", "No data loaded, can't find the file");
addItem(RimInputProperty::KEYWORD_NOT_IN_FILE, "KEYWORD_NOT_IN_FILE", "No data loaded, can't find the keyword");
addItem(RimInputProperty::RESOLVED_NOT_SAVED, "RESOLVED_NOT_SAVED", "Ok, but not saved");
addItem(RimInputProperty::RESOLVED, "RESOLVED", "Loaded, Ok");
setDefault(RimInputProperty::UNKNOWN);
}
}
CAF_PDM_SOURCE_INIT(RimInputProperty, "RimInputProperty");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimInputProperty::RimInputProperty()
{
CAF_PDM_InitObject("Input Property", ":/EclipseInput48x48.png", "", "");
CAF_PDM_InitField(&resultName, "ResultName", QString(), "Result name", "", "" ,"");
CAF_PDM_InitField(&eclipseKeyword, "EclipseKeyword", QString(), "Eclipse Keyword", "", "" ,"");
CAF_PDM_InitField(&fileName, "FileName", QString(), "Filename", "", "" ,"");
CAF_PDM_InitField(&resolvedState, "ResolvedState", (ResolveStateEnum)UNKNOWN, "Data state", "", "", "");
resolvedState.setUiReadOnly(true);
resolvedState.setIOReadable(false);
resolvedState.setIOWritable(false);
resolvedState.setUiEditorTypeName(caf::PdmUiLineEditor::uiEditorTypeName());
fileName.setUiReadOnly(true);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimInputProperty::~RimInputProperty()
{
}

View File

@ -0,0 +1,64 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cvfBase.h"
#include "cvfObject.h"
#include "cafPdmField.h"
#include "cafPdmObject.h"
#include "cafAppEnum.h"
class QString;
//==================================================================================================
//
//
//
//==================================================================================================
class RimInputProperty : public caf::PdmObject
{
CAF_PDM_HEADER_INIT;
public:
RimInputProperty();
virtual ~RimInputProperty();
enum ResolveState
{
UNKNOWN,
FILE_MISSING,
KEYWORD_NOT_IN_FILE,
RESOLVED_NOT_SAVED,
RESOLVED
};
typedef caf::AppEnum<ResolveState> ResolveStateEnum;
// Fields:
caf::PdmField<QString> resultName;
caf::PdmField<QString> eclipseKeyword;
caf::PdmField<QString> fileName; // ReadOnly Serves as key to syncronize read eclipse prop data and this inputProp object.
caf::PdmField<ResolveStateEnum> resolvedState; // ReadOnly and not writable
// PdmObject Overrides
virtual caf::PdmFieldHandle* userDescriptionField() { return &resultName;}
private:
// Possibly the resultIndex, but it should be superfluous
};

View File

@ -0,0 +1,97 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RIStdInclude.h"
#include "RimInputPropertyCollection.h"
CAF_PDM_SOURCE_INIT(RimInputPropertyCollection, "RimInputPropertyCollection");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimInputPropertyCollection::RimInputPropertyCollection()
{
CAF_PDM_InitObject("Input Properties", ":/EclipseInput48x48.png", "", "");
CAF_PDM_InitFieldNoDefault(&inputProperties, "InputProperties", "", "", "", "");
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimInputPropertyCollection::~RimInputPropertyCollection()
{
}
//--------------------------------------------------------------------------------------------------
/// Returns the InputProperties pointing to the same file as \a fileName
//--------------------------------------------------------------------------------------------------
std::vector<RimInputProperty*> RimInputPropertyCollection::findInputProperties(QString fileName)
{
QFileInfo fileInfo(fileName);
std::vector<RimInputProperty*> result;
for (size_t i = 0; i < this->inputProperties.size(); ++i)
{
if (!inputProperties[i]) continue;
QFileInfo propFile(inputProperties[i]->fileName());
if (fileInfo == propFile) result.push_back(inputProperties[i]);
}
return result;
}
//--------------------------------------------------------------------------------------------------
/// Remove given input property from collection and checks if the associated file is referenced by other input
/// properties
//--------------------------------------------------------------------------------------------------
void RimInputPropertyCollection::removeInputProperty(RimInputProperty* inputProperty, bool& isPropertyFileReferencedByOthers)
{
CVF_ASSERT(inputProperty);
this->inputProperties.removeChildObject(inputProperty);
isPropertyFileReferencedByOthers = false;
for (size_t i = 0; i < this->inputProperties.size(); i++)
{
if (inputProperties[i]->fileName() == inputProperty->fileName)
{
isPropertyFileReferencedByOthers = true;
}
}
}
//--------------------------------------------------------------------------------------------------
/// Returns the InputProperty with resultName \a resultName
//--------------------------------------------------------------------------------------------------
RimInputProperty * RimInputPropertyCollection::findInputProperty(QString resultName)
{
for (size_t i = 0; i < this->inputProperties.size(); i++)
{
if (inputProperties[i] && inputProperties[i]->resultName() == resultName)
{
return inputProperties[i];
}
}
return NULL;
}

View File

@ -0,0 +1,50 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cvfBase.h"
#include "cvfObject.h"
#include "cafPdmField.h"
#include "cafPdmObject.h"
#include "RimInputProperty.h"
//==================================================================================================
//
//
//
//==================================================================================================
class RimInputPropertyCollection : public caf::PdmObject
{
CAF_PDM_HEADER_INIT;
public:
RimInputPropertyCollection();
virtual ~RimInputPropertyCollection();
std::vector<RimInputProperty*> findInputProperties(QString fileName);
RimInputProperty* findInputProperty(QString resultName);
void removeInputProperty(RimInputProperty* inputProperty, bool& isPropertyFileReferencedByOthers);
// Fields:
caf::PdmPointersField<RimInputProperty*> inputProperties;
};

View File

@ -0,0 +1,398 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RIStdInclude.h"
#include "RimInputReservoir.h"
#include "RimInputProperty.h"
#include "RimReservoirView.h"
#include "RifReaderEclipseInput.h"
#include "RigReservoir.h"
#include "RigReservoirCellResults.h"
#include "cvfAssert.h"
#include <QString>
#include "RifReaderMockModel.h"
#include "RifEclipseInputFileTools.h"
#include "cafProgressInfo.h"
CAF_PDM_SOURCE_INIT(RimInputReservoir, "RimInputReservoir");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimInputReservoir::RimInputReservoir()
: RimReservoir()
{
CAF_PDM_InitObject("RimInputReservoir", ":/EclipseInput48x48.png", "", "");
CAF_PDM_InitField(&m_gridFileName, "GridFileName", QString(), "Case grid filename", "", "" ,"");
CAF_PDM_InitFieldNoDefault(&m_additionalFileNames, "AdditionalFileNames", "Additional files", "", "" ,"");
CAF_PDM_InitFieldNoDefault(&m_inputPropertyCollection, "InputPropertyCollection", "", "", "", "");
m_inputPropertyCollection = new RimInputPropertyCollection;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimInputReservoir::~RimInputReservoir()
{
delete m_inputPropertyCollection;
}
//--------------------------------------------------------------------------------------------------
/// Open the supplied file set. If no grid data has been read, it will first find the possible
/// grid data among the files then read all supported properties from the files matching the grid
//--------------------------------------------------------------------------------------------------
void RimInputReservoir::openDataFileSet(const QStringList& filenames)
{
if (caseName().contains("Input Mock Debug Model"))
{
cvf::ref<RifReaderInterface> readerInterface = this->createMockModel(this->caseName());
m_rigReservoir->mainGrid()->results()->setReaderInterface(readerInterface.p());
return;
}
if (m_rigReservoir.isNull())
{
RigReservoir* reservoir = new RigReservoir;
m_rigReservoir = reservoir;
}
// First find and read the grid data
if (this->reservoirData()->mainGrid()->gridPointDimensions() == cvf::Vec3st(0,0,0))
{
for (int i = 0; i < filenames.size(); i++)
{
if (RifEclipseInputFileTools::openGridFile(filenames[i], this->reservoirData()))
{
m_gridFileName = filenames[i];
m_rigReservoir->computeFaults();
m_rigReservoir->mainGrid()->computeCachedData();
break;
}
}
}
if (this->reservoirData()->mainGrid()->gridPointDimensions() == cvf::Vec3st(0,0,0))
{
return ; // No grid present
}
// Then read the properties possibly in the grid file
QStringList filesToRead;
for (int i = 0; i < filenames.size(); i++)
{
size_t j;
bool exist = false;
for (j = 0; j < m_additionalFileNames().size(); j++)
{
if (m_additionalFileNames()[j] == filenames[i])
{
exist = true;
}
}
if (!exist)
{
filesToRead.push_back(filenames[i]);
}
}
for (int i = 0; i < filesToRead.size(); i++)
{
QString propertyFileName = filesToRead[i];
std::map<QString, QString> readProperties = RifEclipseInputFileTools::readProperties(propertyFileName, this->reservoirData());
std::map<QString, QString>::iterator it;
for (it = readProperties.begin(); it != readProperties.end(); ++it)
{
RimInputProperty* inputProperty = new RimInputProperty;
inputProperty->resultName = it->first;
inputProperty->eclipseKeyword = it->second;
inputProperty->fileName = propertyFileName;
inputProperty->resolvedState = RimInputProperty::RESOLVED;
m_inputPropertyCollection->inputProperties.push_back(inputProperty);
}
if (propertyFileName != m_gridFileName)
{
m_additionalFileNames.v().push_back(propertyFileName);
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimInputReservoir::openEclipseGridFile()
{
// Early exit if reservoir data is created
if (m_rigReservoir.notNull()) return true;
cvf::ref<RifReaderInterface> readerInterface;
if (caseName().contains("Input Mock Debug Model"))
{
readerInterface = this->createMockModel(this->caseName());
}
else
{
RigReservoir* reservoir = new RigReservoir;
readerInterface = new RifReaderEclipseInput;
if (!readerInterface->open(m_gridFileName, reservoir))
{
delete reservoir;
return false;
}
m_rigReservoir = reservoir;
loadAndSyncronizeInputProperties();
}
CVF_ASSERT(m_rigReservoir.notNull());
CVF_ASSERT(readerInterface.notNull());
m_rigReservoir->mainGrid()->results()->setReaderInterface(readerInterface.p());
m_rigReservoir->computeFaults();
m_rigReservoir->mainGrid()->computeCachedData();
return true;
}
#define for_all(stdVector, indexName) for (size_t indexName = 0; indexName < stdVector.size(); ++indexName)
//--------------------------------------------------------------------------------------------------
/// Loads input property data from the gridFile and additional files
/// Creates new InputProperties if necessary, and flags the unused ones as obsolete
//--------------------------------------------------------------------------------------------------
void RimInputReservoir::loadAndSyncronizeInputProperties()
{
// Make sure we actually have reservoir data
CVF_ASSERT(m_rigReservoir.notNull());
CVF_ASSERT(this->reservoirData()->mainGrid()->gridPointDimensions() != cvf::Vec3st(0,0,0));
// Then read the properties from all the files referenced by the InputReservoir
std::vector<QString> filenames = m_additionalFileNames;
filenames.push_back(m_gridFileName);
const std::vector<QString>& knownKeywords = RifEclipseInputFileTools::knownPropertyKeywords();
size_t inputPropCount = this->m_inputPropertyCollection()->inputProperties.size();
caf::ProgressInfo progInfo(filenames.size() *( inputPropCount + knownKeywords.size()), "Reading Input properties" );
int progress = 0;
for_all(filenames, i)
{
progress = i*( inputPropCount + knownKeywords.size());
// Find all the keywords present on the file
progInfo.setProgressDescription(filenames[i]);
QFileInfo fileNameInfo(filenames[i]);
bool isExistingFile = fileNameInfo.exists();
std::set<QString> fileKeywordSet;
if (isExistingFile)
{
std::vector<QString> fileKeywords = RifEclipseInputFileTools::findKeywordsOnFile(filenames[i]);
for_all(fileKeywords, fkIt) fileKeywordSet.insert(fileKeywords[fkIt]);
}
// Find the input property objects referring to the file
std::vector<RimInputProperty*> ipsUsingThisFile = this->m_inputPropertyCollection()->findInputProperties(filenames[i]);
// Read property data for each inputProperty
for_all(ipsUsingThisFile, ipIdx)
{
if (!isExistingFile)
{
ipsUsingThisFile[ipIdx]->resolvedState = RimInputProperty::FILE_MISSING;
}
else
{
QString kw = ipsUsingThisFile[ipIdx]->eclipseKeyword();
ipsUsingThisFile[ipIdx]->resolvedState = RimInputProperty::KEYWORD_NOT_IN_FILE;
if (fileKeywordSet.count(kw))
{
if (RifEclipseInputFileTools::readProperty(filenames[i], this->reservoirData(), kw, ipsUsingThisFile[ipIdx]->resultName ))
{
ipsUsingThisFile[ipIdx]->resolvedState = RimInputProperty::RESOLVED;
}
}
fileKeywordSet.erase(kw);
}
progInfo.setProgress(progress + ipIdx );
}
progInfo.setProgress(progress + inputPropCount);
// Check if there are more known property keywords left on file. If it is, read them and create inputProperty objects
if (!fileKeywordSet.empty())
{
std::vector<QString> knownKwsLeft;
for_all(knownKeywords, fkIt)
{
if (fileKeywordSet.count(knownKeywords[fkIt]))
{
QString resultName = this->reservoirData()->mainGrid()->results()->makeResultNameUnique(knownKeywords[fkIt]);
if (RifEclipseInputFileTools::readProperty(filenames[i], this->reservoirData(), knownKeywords[fkIt], resultName))
{
RimInputProperty* inputProperty = new RimInputProperty;
inputProperty->resultName = resultName;
inputProperty->eclipseKeyword = knownKeywords[fkIt];
inputProperty->fileName = filenames[i];
inputProperty->resolvedState = RimInputProperty::RESOLVED;
m_inputPropertyCollection->inputProperties.push_back(inputProperty);
}
}
progInfo.setProgress(progress + inputPropCount + fkIt);
}
}
}
for_all(m_inputPropertyCollection->inputProperties, i)
{
if (m_inputPropertyCollection->inputProperties[i]->resolvedState() == RimInputProperty::UNKNOWN)
{
m_inputPropertyCollection->inputProperties[i]->resolvedState = RimInputProperty::FILE_MISSING;
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimInputReservoir::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimInputReservoir::addFiles(const QStringList& newFileNames)
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimInputReservoir::removeFiles(const QStringList& obsoleteFileNames)
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimInputReservoir::removeProperty(RimInputProperty* inputProperty)
{
bool isPropertyFileReferencedByOthers = false;
m_inputPropertyCollection->removeInputProperty(inputProperty, isPropertyFileReferencedByOthers);
if (!isPropertyFileReferencedByOthers)
{
std::vector<QString> newList;
size_t i;
for (i = 0; i < m_additionalFileNames().size(); i++)
{
if (m_additionalFileNames()[i] != inputProperty->fileName)
{
newList.push_back(m_additionalFileNames()[i]);
}
}
m_additionalFileNames.v() = newList;
}
// Remove the results pointed to by this input property
RigReservoirCellResults* results = m_rigReservoir->mainGrid()->results();
results->removeResult(inputProperty->resultName);
this->removeResult(inputProperty->resultName);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::ref<RifReaderInterface> RimInputReservoir::createMockModel(QString modelName)
{
cvf::ref<RigReservoir> reservoir = new RigReservoir;
cvf::ref<RifReaderMockModel> mockFileInterface = new RifReaderMockModel;
if (modelName == "Input Mock Debug Model Simple")
{
// Create the mock file interface and and RigSerervoir and set them up.
mockFileInterface->setWorldCoordinates(cvf::Vec3d(10, 10, 10), cvf::Vec3d(20, 20, 20));
mockFileInterface->setGridPointDimensions(cvf::Vec3st(4, 5, 6));
mockFileInterface->addLocalGridRefinement(cvf::Vec3st(0, 2, 2), cvf::Vec3st(0, 2, 2), cvf::Vec3st(3, 3, 3));
mockFileInterface->setResultInfo(3, 10);
mockFileInterface->open("", reservoir.p());
{
size_t idx = reservoir->mainGrid()->cellIndexFromIJK(1, 3, 4);
reservoir->mainGrid()->cell(idx).setActive(false);
}
{
size_t idx = reservoir->mainGrid()->cellIndexFromIJK(2, 2, 3);
reservoir->mainGrid()->cell(idx).setActive(false);
}
// Add a property
RimInputProperty* inputProperty = new RimInputProperty;
inputProperty->resultName = "PORO";
inputProperty->eclipseKeyword = "PORO";
inputProperty->fileName = "PORO.prop";
m_inputPropertyCollection->inputProperties.push_back(inputProperty);
}
m_rigReservoir = reservoir;
return mockFileInterface.p();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimInputReservoir::locationOnDisc() const
{
if (m_gridFileName().isEmpty()) return QString();
QFileInfo fi(m_gridFileName);
return fi.absolutePath();
}

View File

@ -0,0 +1,73 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cvfBase.h"
#include "cvfObject.h"
#include "cafPdmField.h"
#include "cafPdmObject.h"
#include "RimReservoir.h"
#include "RimInputPropertyCollection.h"
class QString;
class RifReaderInterface;
//==================================================================================================
//
//
//
//==================================================================================================
class RimInputReservoir : public RimReservoir
{
CAF_PDM_HEADER_INIT;
public:
RimInputReservoir();
virtual ~RimInputReservoir();
// Fields
caf::PdmField<std::vector<QString> > m_additionalFileNames;
caf::PdmField<QString> m_gridFileName;
caf::PdmField<RimInputPropertyCollection*> m_inputPropertyCollection;
// File open methods
void openDataFileSet(const QStringList& filenames);
void loadAndSyncronizeInputProperties();
void removeProperty(RimInputProperty* inputProperty);
// RimReservoir overrides
virtual bool openEclipseGridFile(); // Find grid file among file set. Read, Find read and validate property date. Syncronize child property sets.
// PdmObject overrides
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue);
virtual QString locationOnDisc() const;
private:
void addFiles(const QStringList& newFileNames);
void removeFiles(const QStringList& obsoleteFileNames);
cvf::ref<RifReaderInterface> createMockModel(QString modelName);
};

View File

@ -20,6 +20,9 @@
#include "RimLegendConfig.h"
#include "RimReservoirView.h"
#include "cafFactory.h"
#include "cafPdmUiLineEditor.h"
#include "cafPdmUiComboBoxEditor.h"
CAF_PDM_SOURCE_INIT(RimLegendConfig, "Legend");
@ -78,7 +81,7 @@ RimLegendConfig::RimLegendConfig()
CAF_PDM_InitField(&m_userDefinedMaxValue, "UserDefinedMax", 1.0, "Max", "", "Min value of the legend", "");
CAF_PDM_InitField(&m_userDefinedMinValue, "UserDefinedMin", 0.0, "Min", "", "Max value of the legend", "");
CAF_PDM_InitField(&resultVariableName, "ResultVariableUsage", QString(""), "", "", "", "");
resultVariableName.setHidden(true);
resultVariableName.setUiHidden(true);
m_linDiscreteScalarMapper = new cvf::ScalarMapperUniformLevels;
m_linDiscreteScalarMapper->setTextureSize(1024);
@ -300,13 +303,13 @@ void RimLegendConfig::updateFieldVisibility()
{
if (m_rangeMode == USER_DEFINED)
{
m_userDefinedMaxValue.setHidden(false);
m_userDefinedMinValue.setHidden(false);
m_userDefinedMaxValue.setUiHidden(false);
m_userDefinedMinValue.setUiHidden(false);
}
else
{
m_userDefinedMaxValue.setHidden(true);
m_userDefinedMinValue.setHidden(true);
m_userDefinedMaxValue.setUiHidden(true);
m_userDefinedMinValue.setUiHidden(true);
}
}

View File

@ -30,13 +30,13 @@ CAF_PDM_SOURCE_INIT(RimProject, "ResInsightProject");
RimProject::RimProject(void)
{
CAF_PDM_InitFieldNoDefault(&m_projectFileVersionString, "ProjectFileVersionString", "", "", "", "");
m_projectFileVersionString.setHidden(true);
m_projectFileVersionString.setUiHidden(true);
CAF_PDM_InitFieldNoDefault(&reservoirs, "Reservoirs", "", "", "", "");
CAF_PDM_InitFieldNoDefault(&scriptCollection, "ScriptCollection", "Scripts", ":/Default.png", "", "");
scriptCollection = new RimScriptCollection();
scriptCollection->directory.setHidden(true);
scriptCollection->directory.setUiHidden(true);
initAfterRead();
}
@ -48,7 +48,7 @@ RimProject::~RimProject(void)
{
if (scriptCollection()) delete scriptCollection();
reservoirs.deleteChildren();
reservoirs.deleteAllChildObjects();
}
//--------------------------------------------------------------------------------------------------
@ -56,7 +56,7 @@ RimProject::~RimProject(void)
//--------------------------------------------------------------------------------------------------
void RimProject::close()
{
reservoirs.deleteChildren();
reservoirs.deleteAllChildObjects();
fileName = "";
}
@ -89,8 +89,8 @@ void RimProject::setupBeforeSave()
//--------------------------------------------------------------------------------------------------
void RimProject::setUserScriptPath(const QString& scriptDirectory)
{
scriptCollection->calcScripts().deleteChildren();
scriptCollection->subDirectories().deleteChildren();
scriptCollection->calcScripts().deleteAllChildObjects();
scriptCollection->subDirectories().deleteAllChildObjects();
QDir dir(scriptDirectory);

View File

@ -18,45 +18,31 @@
#include "RIStdInclude.h"
#include "RifReaderInterfaceEcl.h"
#include "RifReaderEclipseOutput.h"
#include "RimReservoir.h"
#include "RigReservoir.h"
#include "RigMainGrid.h"
#include "RigReservoirCellResults.h"
#include "RimWell.h"
#include "RimWellCollection.h"
#include "RimReservoirView.h"
#include "cvfAssert.h"
#include <QString>
#include "RifReaderInterfaceMock.h"
#include "RifReaderMockModel.h"
CAF_PDM_SOURCE_INIT(RimReservoir, "EclipseCase");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimReservoir::RimReservoir()
{
m_rigReservoir = NULL;
m_fileInterface = NULL;
CAF_PDM_InitObject("Reservoir", ":/AppLogo48x48.png", "", "");
CAF_PDM_InitField(&caseName, "CaseName", QString(), "Case name", "", "" ,"");
CAF_PDM_InitField(&caseDirectory, "CaseFolder", QString(), "Directory", "", "" ,"");
CAF_PDM_InitFieldNoDefault(&reservoirViews, "ReservoirViews", "", "", "", "");
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimReservoir::RimReservoir(RigReservoir* reservoir)
{
m_rigReservoir = reservoir;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -73,144 +59,6 @@ const RigReservoir* RimReservoir::reservoirData() const
return m_rigReservoir.p();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RifReaderInterface* RimReservoir::fileInterface()
{
return m_fileInterface.p();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const RifReaderInterface* RimReservoir::fileInterface() const
{
return m_fileInterface.p();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimReservoir::openEclipseGridFile()
{
// Early exit if reservoir data is created
if (m_rigReservoir.notNull()) return true;
if (caseName().contains("Mock Debug Model"))
{
this->createMockModel(this->caseName());
}
else
{
QString fullCaseName = caseName + ".EGRID";
QDir dir(caseDirectory.v());
if (!dir.exists(fullCaseName))
{
fullCaseName = caseName + ".GRID";
if (!dir.exists(fullCaseName))
{
return false;
}
}
QString fname = dir.absoluteFilePath(fullCaseName);
RigReservoir* reservoir = new RigReservoir;
m_fileInterface = new RifReaderInterfaceECL;
if (!m_fileInterface->open(fname, reservoir))
{
delete reservoir;
return false;
}
m_rigReservoir = reservoir;
}
CVF_ASSERT(m_rigReservoir.notNull());
CVF_ASSERT(m_fileInterface.notNull());
m_rigReservoir->mainGrid()->results()->setReaderInterface(m_fileInterface.p());
m_rigReservoir->computeFaults();
m_rigReservoir->mainGrid()->computeCachedData();
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimReservoir::createMockModel(QString modelName)
{
cvf::ref<RifReaderInterfaceMock> mockFileInterface = new RifReaderInterfaceMock;
cvf::ref<RigReservoir> reservoir = new RigReservoir;
if (modelName == "Mock Debug Model Simple")
{
// Create the mock file interface and and RigSerervoir and set them up.
mockFileInterface->setWorldCoordinates(cvf::Vec3d(10, 10, 10), cvf::Vec3d(20, 20, 20));
mockFileInterface->setGridPointDimensions(cvf::Vec3st(4, 5, 6));
mockFileInterface->addLocalGridRefinement(cvf::Vec3st(0, 2, 2), cvf::Vec3st(0, 2, 2), cvf::Vec3st(3, 3, 3));
mockFileInterface->open("", reservoir.p());
{
size_t idx = reservoir->mainGrid()->cellIndexFromIJK(1, 3, 4);
reservoir->mainGrid()->cell(idx).setActive(false);
}
{
size_t idx = reservoir->mainGrid()->cellIndexFromIJK(2, 2, 3);
reservoir->mainGrid()->cell(idx).setActive(false);
}
}
else if (modelName == "Mock Debug Model With Results")
{
mockFileInterface->setWorldCoordinates(cvf::Vec3d(10, 10, 10), cvf::Vec3d(-20, -20, -20));
mockFileInterface->setGridPointDimensions(cvf::Vec3st(5, 10, 20));
mockFileInterface->addLocalGridRefinement(cvf::Vec3st(0, 3, 3), cvf::Vec3st(1, 4, 9), cvf::Vec3st(2, 2, 2));
mockFileInterface->setResultInfo(3, 10);
mockFileInterface->open("", reservoir.p());
// Make a fault
cvf::Vec3d& tmp = reservoir->mainGrid()->nodes()[1];
tmp += cvf::Vec3d(1, 0, 0);
}
else if (modelName =="Mock Debug Model Large With Results")
{
double startX = 0;
double startY = 0;
double startZ = 0;
double widthX = 6000;
double widthY = 12000;
double widthZ = 500;
double offsetX = 0;
double offsetY = 0;
double offsetZ = 0;
// Test code to simulate UTM coordinates
offsetX = 400000;
offsetY = 6000000;
offsetZ = 0;
mockFileInterface->setWorldCoordinates(cvf::Vec3d(startX + offsetX, startY + offsetY, startZ + offsetZ), cvf::Vec3d(startX + widthX + offsetX, startY + widthY + offsetY, startZ + widthZ + offsetZ));
mockFileInterface->setGridPointDimensions(cvf::Vec3st(50, 100, 200));
mockFileInterface->addLocalGridRefinement(cvf::Vec3st(0, 30, 30), cvf::Vec3st(1, 40, 90), cvf::Vec3st(2, 2, 2));
mockFileInterface->setResultInfo(3, 10);
mockFileInterface->open("", reservoir.p());
}
m_rigReservoir = reservoir;
m_fileInterface = mockFileInterface;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -231,7 +79,7 @@ void RimReservoir::initAfterRead()
//--------------------------------------------------------------------------------------------------
RimReservoir::~RimReservoir()
{
reservoirViews.deleteChildren();
reservoirViews.deleteAllChildObjects();
}
//--------------------------------------------------------------------------------------------------
@ -274,3 +122,54 @@ void RimReservoir::removeReservoirView(RimReservoirView* reservoirView)
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimReservoir::removeResult(const QString& resultName)
{
size_t i;
for (i = 0; i < reservoirViews().size(); i++)
{
RimReservoirView* reservoirView = reservoirViews()[i];
CVF_ASSERT(reservoirView);
RimResultSlot* result = reservoirView->cellResult;
CVF_ASSERT(result);
bool rebuildDisplayModel = false;
// Set cell result variable to none if displaying
if (result->resultVariable() == resultName)
{
result->resultVariable.v() = QString("None");
result->loadResult();
rebuildDisplayModel = true;
}
std::list< caf::PdmPointer< RimCellPropertyFilter > >::iterator it;
RimCellPropertyFilterCollection* propFilterCollection = reservoirView->propertyFilterCollection();
for (it = propFilterCollection->propertyFilters.v().begin(); it != propFilterCollection->propertyFilters.v().end(); ++it)
{
RimCellPropertyFilter* propertyFilter = *it;
if (propertyFilter->resultDefinition->resultVariable.v() == resultName)
{
propertyFilter->resultDefinition->resultVariable.v() = QString("None");
propertyFilter->resultDefinition->loadResult();
propertyFilter->setDefaultValues();
rebuildDisplayModel = true;
}
}
if (rebuildDisplayModel)
{
reservoirViews()[i]->createDisplayModelAndRedraw();
}
// TODO
// CellEdgeResults are not considered, as they do not support display of input properties yet
}
}

View File

@ -23,57 +23,51 @@
#include "cafPdmField.h"
#include "cafPdmObject.h"
#include "RimWellCollection.h"
class QString;
class RigReservoir;
class RifReaderInterface;
class RimWellCollection;
class RigGridBase;
class RimReservoirView;
//==================================================================================================
//
//
//
// Interface for reservoirs.
// As this is a pure virtual class, the factory macros are not relevant (nor possible) to use
// CAF_PDM_HEADER_INIT and CAF_PDM_SOURCE_INIT
//
//==================================================================================================
class RimReservoir : public caf::PdmObject, public cvf::Object
class RimReservoir : public caf::PdmObject
{
CAF_PDM_HEADER_INIT;
public:
RimReservoir();
RimReservoir(RigReservoir* reservoir);
virtual ~RimReservoir();
bool openEclipseGridFile();
virtual bool openEclipseGridFile() = 0;
RigReservoir* reservoirData();
const RigReservoir* reservoirData() const;
RifReaderInterface* fileInterface();
const RifReaderInterface* fileInterface() const;
RimReservoirView* createAndAddReservoirView();
void removeReservoirView(RimReservoirView* reservoirView);
void removeResult(const QString& resultName);
// Fields:
caf::PdmField<QString> caseName;
caf::PdmField<QString> caseDirectory;
caf::PdmPointersField<RimReservoirView*> reservoirViews;
virtual caf::PdmFieldHandle* userDescriptionField() { return &caseName;}
virtual caf::PdmFieldHandle* userDescriptionField() { return &caseName; }
virtual QString locationOnDisc() const { return QString(); }
protected:
// Overridden methods
virtual void initAfterRead();
private:
void createMockModel(QString modelName);
private:
protected:
cvf::ref<RigReservoir> m_rigReservoir;
cvf::ref<RifReaderInterface> m_fileInterface;
};

View File

@ -41,7 +41,6 @@
#include "cafCadNavigation.h"
#include "cafCeetronNavigation.h"
#include "RimReservoir.h"
#include "RifReaderInterface.h"
namespace caf {
@ -90,13 +89,13 @@ RimReservoirView::RimReservoirView()
CAF_PDM_InitField(&name, "UserDescription", QString(""), "Name", "", "", "");
CAF_PDM_InitField(&scaleZ, "GridZScale", 1.0, "Z Scale", "", "Scales the scene in the Z direction", "");
CAF_PDM_InitField(&showWindow, "ShowWindow", true, "Show 3D viewer", "", "", "");
showWindow.setHidden(true);
showWindow.setUiHidden(true);
CAF_PDM_InitField(&m_currentTimeStep, "CurrentTimeStep", 0, "Current Time Step","", "", "");
m_currentTimeStep.setHidden(true);
m_currentTimeStep.setUiHidden(true);
CAF_PDM_InitField(&animationMode, "AnimationMode", false, "Animation Mode","", "", "");
animationMode.setHidden(true);
animationMode.setUiHidden(true);
CAF_PDM_InitFieldNoDefault(&wellCollection, "WellCollection","Wells", "", "", "");
wellCollection = new RimWellCollection;
@ -113,7 +112,7 @@ RimReservoirView::RimReservoirView()
CAF_PDM_InitFieldNoDefault(&surfaceMode, "SurfaceMode", "Grid surface", "", "", "");
CAF_PDM_InitField(&maximumFrameRate, "MaximumFrameRate", 10, "Maximum frame rate","", "", "");
maximumFrameRate.setHidden(true);
maximumFrameRate.setUiHidden(true);
// Visualization fields
CAF_PDM_InitField(&showMainGrid, "ShowMainGrid", true, "Show Main Grid", "", "", "");
@ -404,12 +403,6 @@ void RimReservoirView::createDisplayModel()
if (m_reservoir && m_reservoir->reservoirData())
{
RigReservoir* reservoir = m_reservoir->reservoirData();
CVF_ASSERT(reservoir);
RigReservoirCellResults* results = reservoir->mainGrid()->results();
CVF_ASSERT(results);
// Define a vector containing time step indices to produce geometry for.
// First entry in this vector is used to define the geometry only result mode with no results.
std::vector<size_t> timeStepIndices;
@ -417,12 +410,16 @@ void RimReservoirView::createDisplayModel()
// The one and only geometry entry
timeStepIndices.push_back(0);
// Find the number of time frames the animation needs to show the requested data.
if (this->cellResult()->hasDynamicResult()
|| this->propertyFilterCollection()->hasActiveDynamicFilters()
|| this->wellCollection->hasVisibleWellPipes())
{
CVF_ASSERT(gridCellResults());
size_t i;
for (i = 0; i < m_reservoir->fileInterface()->numTimeSteps(); i++)
for (i = 0; i < gridCellResults()->maxTimeStepCount(); i++)
{
timeStepIndices.push_back(i);
}
@ -522,16 +519,16 @@ void RimReservoirView::createDisplayModel()
// Create Scenes from the frameModels
// Animation frames for results display, starts from frame 1
size_t modelIndex;
for (modelIndex = 0; modelIndex < frameModels.size(); modelIndex++)
size_t frameIndex;
for (frameIndex = 0; frameIndex < frameModels.size(); frameIndex++)
{
cvf::ModelBasicList* model = frameModels.at(modelIndex);
cvf::ModelBasicList* model = frameModels.at(frameIndex);
model->updateBoundingBoxesRecursive();
cvf::ref<cvf::Scene> scene = new cvf::Scene;
scene->addModel(model);
if (modelIndex == 0)
if (frameIndex == 0)
m_viewer->setMainScene(scene.p());
else
m_viewer->addFrame(scene.p());
@ -552,7 +549,6 @@ void RimReservoirView::createDisplayModel()
//--------------------------------------------------------------------------------------------------
void RimReservoirView::updateCurrentTimeStep()
{
updateLegends();
std::vector<RivReservoirViewPartMgr::ReservoirGeometryCacheType> geometriesToRecolor;
@ -622,14 +618,33 @@ void RimReservoirView::updateCurrentTimeStep()
cvf::Scene* frameScene = m_viewer->frame(m_currentTimeStep);
if (frameScene)
{
cvf::ref<cvf::ModelBasicList> frameParts = new cvf::ModelBasicList;
m_pipesPartManager->appendDynamicGeometryPartsToModel(frameParts.p(), m_currentTimeStep);
cvf::String modelName = "WellPipeModel";
std::vector<cvf::Model*> models;
for (i = 0; i < frameScene->modelCount(); i++)
{
if (frameScene->model(i)->name() == modelName)
{
models.push_back(frameScene->model(i));
}
}
for (i = 0; i < models.size(); i++)
{
frameScene->removeModel(models[i]);
}
cvf::ref<cvf::ModelBasicList> pipeModel = new cvf::ModelBasicList;
pipeModel->setName(modelName);
m_pipesPartManager->appendDynamicGeometryPartsToModel(pipeModel.p(), m_currentTimeStep);
m_pipesPartManager->updatePipeResultColor(m_currentTimeStep);
frameParts->updateBoundingBoxesRecursive();
frameScene->addModel(frameParts.p());
pipeModel->updateBoundingBoxesRecursive();
frameScene->addModel(pipeModel.p());
}
}
updateLegends();
}
//--------------------------------------------------------------------------------------------------
@ -643,7 +658,7 @@ void RimReservoirView::loadDataAndUpdate()
{
if (!m_reservoir->openEclipseGridFile())
{
QMessageBox::warning(RIMainWindow::instance(), "Error when opening project file", "Could not open the Eclipse Grid file (EGRID/GRID): \n"+ m_reservoir->caseName() + "\nIn directory " + m_reservoir->caseDirectory());
QMessageBox::warning(RIMainWindow::instance(), "Error when opening project file", "Could not open the Eclipse Grid file (EGRID/GRID): \n"+ m_reservoir->caseName());
}
else
{

View File

@ -40,7 +40,6 @@
class RIViewer;
class RigGridBase;
class RigGridCellFaceVisibilityFilter;
class RimReservoir;
class RivReservoirViewPartMgr;
namespace cvf

View File

@ -25,7 +25,7 @@
#include "RigReservoirCellResults.h"
#include "RigReservoir.h"
#include "RigMainGrid.h"
#include "RifReaderInterface.h"
#include "cafPdmUiListEditor.h"
CAF_PDM_SOURCE_INIT(RimResultDefinition, "ResultDefinition");
@ -38,8 +38,10 @@ RimResultDefinition::RimResultDefinition()
{
CAF_PDM_InitObject("Result Definition", "", "", "");
CAF_PDM_InitFieldNoDefault(&resultType, "ResultType","Result type", "", "", "");
CAF_PDM_InitFieldNoDefault(&resultVariable, "ResultVariable","Variable", "", "", "" );
CAF_PDM_InitFieldNoDefault(&resultType, "ResultType", "Type", "", "", "");
CAF_PDM_InitField(&resultVariable, "ResultVariable", RimDefines::nonSelectedResultName(), "Variable", "", "", "" );
resultVariable.setUiEditorTypeName(caf::PdmUiListEditor::uiEditorTypeName());
}
//--------------------------------------------------------------------------------------------------
@ -65,21 +67,10 @@ void RimResultDefinition::fieldChangedByUi(const caf::PdmFieldHandle* changedFie
{
if (changedField == &resultType)
{
resultVariable = "";
resultVariable = RimDefines::nonSelectedResultName();
}
loadResult();
// Notify the parent objects that this object has changed
// In this case the RimCellPropertyFilter.
// The RimReservoirView can also be a parent, but the call should have no effect there
std::vector<caf::PdmFieldHandle*> parentFields;
this->parentFields(parentFields);
for (size_t i = 0; i < parentFields.size(); ++i)
{
parentFields[i]->ownerObject()->fieldChangedByUi(parentFields[i], QVariant(), QVariant());
}
}
//--------------------------------------------------------------------------------------------------
@ -89,17 +80,13 @@ QList<caf::PdmOptionItemInfo> RimResultDefinition::calculateValueOptions(const c
{
if (fieldNeedingOptions == &resultVariable)
{
if (m_reservoirView &&
m_reservoirView->eclipseCase() &&
m_reservoirView->eclipseCase()->fileInterface())
if (m_reservoirView && m_reservoirView->gridCellResults())
{
RifReaderInterface* readerInterface = m_reservoirView->eclipseCase()->fileInterface();
CVF_ASSERT(readerInterface);
/*
QStringList varList;
if (resultType() == RimDefines::DYNAMIC_NATIVE)
{
varList = readerInterface->dynamicResults();
varList = readerInterface->dynamicResultNames();
if (!varList.contains("SOIL", Qt::CaseInsensitive))
{
@ -112,20 +99,26 @@ QList<caf::PdmOptionItemInfo> RimResultDefinition::calculateValueOptions(const c
}
else if (resultType == RimDefines::STATIC_NATIVE)
{
varList = readerInterface->staticResults();
varList = readerInterface->staticResultNames();
}
else if (resultType == RimDefines::GENERATED)
{
varList = m_reservoirView->eclipseCase()->reservoirData()->mainGrid()->results()->resultNames(resultType());
}
else if (resultType == RimDefines::INPUT_PROPERTY)
{
varList = readerInterface->inputPropertyNames();
}
*/
QStringList varList = m_reservoirView->gridCellResults()->resultNames(resultType());
QList<caf::PdmOptionItemInfo> optionList;
int i;
for (i = 0; i < varList.size(); ++i)
{
optionList.push_back(caf::PdmOptionItemInfo( varList[i], varList[i]));
}
optionList.push_front(caf::PdmOptionItemInfo( "None", "" ));
optionList.push_front(caf::PdmOptionItemInfo( RimDefines::nonSelectedResultName(), RimDefines::nonSelectedResultName() ));
if (useOptionsOnly) *useOptionsOnly = true;
@ -144,7 +137,7 @@ size_t RimResultDefinition::gridScalarIndex() const
if (m_gridScalarResultIndex == cvf::UNDEFINED_SIZE_T)
{
const RigReservoirCellResults* gridCellResults = m_reservoirView->gridCellResults();
if (gridCellResults) m_gridScalarResultIndex = gridCellResults->findGridScalarIndex(resultType(), resultVariable());
if (gridCellResults) m_gridScalarResultIndex = gridCellResults->findScalarResultIndex(resultType(), resultVariable());
}
return m_gridScalarResultIndex;
}
@ -157,7 +150,7 @@ void RimResultDefinition::loadResult()
RigReservoirCellResults* gridCellResults = m_reservoirView->gridCellResults();
if (gridCellResults)
{
m_gridScalarResultIndex = gridCellResults->loadResultIntoGrid(resultType(), resultVariable);
m_gridScalarResultIndex = gridCellResults->findOrLoadScalarResult(resultType(), resultVariable);
}
else
{
@ -167,7 +160,8 @@ void RimResultDefinition::loadResult()
//--------------------------------------------------------------------------------------------------
///
/// Returns whether the result requested by the definition is a single frame result
/// The result needs to be loaded before asking
//--------------------------------------------------------------------------------------------------
bool RimResultDefinition::hasStaticResult() const
{
@ -183,7 +177,7 @@ bool RimResultDefinition::hasStaticResult() const
}
//--------------------------------------------------------------------------------------------------
///
/// Returns whether the result requested by the definition is loaded or possible to load from the result file
//--------------------------------------------------------------------------------------------------
bool RimResultDefinition::hasResult() const
{
@ -192,7 +186,7 @@ bool RimResultDefinition::hasResult() const
const RigReservoirCellResults* gridCellResults = m_reservoirView->gridCellResults();
if (gridCellResults)
{
m_gridScalarResultIndex = gridCellResults->findGridScalarIndex(resultType(), resultVariable());
m_gridScalarResultIndex = gridCellResults->findScalarResultIndex(resultType(), resultVariable());
return m_gridScalarResultIndex != cvf::UNDEFINED_SIZE_T;
}
@ -200,7 +194,8 @@ bool RimResultDefinition::hasResult() const
}
//--------------------------------------------------------------------------------------------------
///
/// Returns whether the result requested by the definition is a multi frame result
/// The result needs to be loaded before asking
//--------------------------------------------------------------------------------------------------
bool RimResultDefinition::hasDynamicResult() const
{
@ -210,3 +205,11 @@ bool RimResultDefinition::hasDynamicResult() const
else
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimReservoirView* RimResultDefinition::reservoirView()
{
return m_reservoirView;
}

View File

@ -40,8 +40,9 @@ public:
virtual ~RimResultDefinition();
virtual void setReservoirView(RimReservoirView* ownerReservoirView);
RimReservoirView* reservoirView();
caf::PdmField< caf::AppEnum< RimDefines::ResultCatType > > resultType;
caf::PdmField< caf::AppEnum< RimDefines::ResultCatType > > resultType;
caf::PdmField<QString> resultVariable;
void loadResult();
@ -52,9 +53,6 @@ public:
virtual QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly );
protected:
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue);
protected:

View File

@ -0,0 +1,191 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RIStdInclude.h"
#include "RimResultReservoir.h"
#include "RigReservoir.h"
#include "RifReaderEclipseOutput.h"
#include "RigReservoirCellResults.h"
#include "RimReservoirView.h"
#include "RifReaderMockModel.h"
#include "RifReaderEclipseInput.h"
#include "cafProgressInfo.h"
CAF_PDM_SOURCE_INIT(RimResultReservoir, "EclipseCase");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimResultReservoir::RimResultReservoir()
: RimReservoir()
{
CAF_PDM_InitField(&caseFileName, "CaseFileName", QString(), "Case file name", "", "" ,"");
CAF_PDM_InitField(&caseDirectory, "CaseFolder", QString(), "Directory", "", "" ,"");
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimResultReservoir::openEclipseGridFile()
{
caf::ProgressInfo progInfo(2, "Reading Eclipse Grid File");
progInfo.setProgressDescription("Open Grid File");
// Early exit if reservoir data is created
if (m_rigReservoir.notNull()) return true;
cvf::ref<RifReaderInterface> readerInterface;
if (caseName().contains("Result Mock Debug Model"))
{
readerInterface = this->createMockModel(this->caseName());
}
else
{
QString fullCaseName = caseName + ".EGRID";
QDir dir(caseDirectory.v());
if (!dir.exists(fullCaseName))
{
fullCaseName = caseName + ".GRID";
if (!dir.exists(fullCaseName))
{
return false;
}
}
QString fname = dir.absoluteFilePath(fullCaseName);
RigReservoir* reservoir = new RigReservoir;
readerInterface = new RifReaderEclipseOutput;
if (!readerInterface->open(fname, reservoir))
{
delete reservoir;
return false;
}
m_rigReservoir = reservoir;
}
progInfo.setProgress(1);
CVF_ASSERT(m_rigReservoir.notNull());
CVF_ASSERT(readerInterface.notNull());
m_rigReservoir->mainGrid()->results()->setReaderInterface(readerInterface.p());
progInfo.setProgressDescription("Computing Faults");
m_rigReservoir->computeFaults();
progInfo.setProgressDescription("Computing Cache");
m_rigReservoir->mainGrid()->computeCachedData();
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::ref<RifReaderInterface> RimResultReservoir::createMockModel(QString modelName)
{
cvf::ref<RifReaderMockModel> mockFileInterface = new RifReaderMockModel;
cvf::ref<RigReservoir> reservoir = new RigReservoir;
if (modelName == "Result Mock Debug Model Simple")
{
// Create the mock file interface and and RigSerervoir and set them up.
mockFileInterface->setWorldCoordinates(cvf::Vec3d(10, 10, 10), cvf::Vec3d(20, 20, 20));
mockFileInterface->setGridPointDimensions(cvf::Vec3st(4, 5, 6));
mockFileInterface->addLocalGridRefinement(cvf::Vec3st(0, 2, 2), cvf::Vec3st(0, 2, 2), cvf::Vec3st(3, 3, 3));
mockFileInterface->open("", reservoir.p());
{
size_t idx = reservoir->mainGrid()->cellIndexFromIJK(1, 3, 4);
reservoir->mainGrid()->cell(idx).setActive(false);
}
{
size_t idx = reservoir->mainGrid()->cellIndexFromIJK(2, 2, 3);
reservoir->mainGrid()->cell(idx).setActive(false);
}
}
else if (modelName == "Result Mock Debug Model With Results")
{
mockFileInterface->setWorldCoordinates(cvf::Vec3d(10, 10, 10), cvf::Vec3d(-20, -20, -20));
mockFileInterface->setGridPointDimensions(cvf::Vec3st(5, 10, 20));
mockFileInterface->addLocalGridRefinement(cvf::Vec3st(0, 3, 3), cvf::Vec3st(1, 4, 9), cvf::Vec3st(2, 2, 2));
mockFileInterface->setResultInfo(3, 10);
mockFileInterface->open("", reservoir.p());
// Make a fault
cvf::Vec3d& tmp = reservoir->mainGrid()->nodes()[1];
tmp += cvf::Vec3d(1, 0, 0);
}
else if (modelName =="Result Mock Debug Model Large With Results")
{
double startX = 0;
double startY = 0;
double startZ = 0;
double widthX = 6000;
double widthY = 12000;
double widthZ = 500;
double offsetX = 0;
double offsetY = 0;
double offsetZ = 0;
// Test code to simulate UTM coordinates
offsetX = 400000;
offsetY = 6000000;
offsetZ = 0;
mockFileInterface->setWorldCoordinates(cvf::Vec3d(startX + offsetX, startY + offsetY, startZ + offsetZ), cvf::Vec3d(startX + widthX + offsetX, startY + widthY + offsetY, startZ + widthZ + offsetZ));
mockFileInterface->setGridPointDimensions(cvf::Vec3st(50, 100, 200));
mockFileInterface->addLocalGridRefinement(cvf::Vec3st(0, 30, 30), cvf::Vec3st(1, 40, 90), cvf::Vec3st(2, 2, 2));
mockFileInterface->setResultInfo(3, 10);
mockFileInterface->open("", reservoir.p());
}
m_rigReservoir = reservoir;
return mockFileInterface.p();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimResultReservoir::~RimResultReservoir()
{
reservoirViews.deleteAllChildObjects();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimResultReservoir::locationOnDisc() const
{
return caseDirectory;
}

View File

@ -0,0 +1,56 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cvfBase.h"
#include "cvfObject.h"
#include "cafPdmField.h"
#include "cafPdmObject.h"
#include "RimReservoir.h"
class RifReaderInterface;
//==================================================================================================
//
//
//
//==================================================================================================
class RimResultReservoir : public RimReservoir
{
CAF_PDM_HEADER_INIT;
public:
RimResultReservoir();
virtual ~RimResultReservoir();
// Fields:
caf::PdmField<QString> caseFileName;
caf::PdmField<QString> caseDirectory;
virtual bool openEclipseGridFile();
//virtual caf::PdmFieldHandle* userDescriptionField() { return &caseName;}
virtual QString locationOnDisc() const;
private:
cvf::ref<RifReaderInterface> createMockModel(QString modelName);
};

View File

@ -37,7 +37,7 @@ RimResultSlot::RimResultSlot()
CAF_PDM_InitFieldNoDefault(&legendConfig, "LegendDefinition", "Legend Definition", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_legendConfigData, "ResultVarLegendDefinitionList", "", "", "", "");
m_legendConfigData.setHidden(true);
m_legendConfigData.setUiHidden(true);
legendConfig = new RimLegendConfig();
}

View File

@ -24,6 +24,7 @@
#include "cafUtils.h"
#include "RIMainWindow.h"
#include "RimUiTreeModelPdm.h"
#include "cafPdmUiFilePathEditor.h"
CAF_PDM_SOURCE_INIT(RimScriptCollection, "ScriptLocation");
@ -37,6 +38,8 @@ RimScriptCollection::RimScriptCollection()
CAF_PDM_InitFieldNoDefault(&directory, "ScriptDirectory", "Dir", "", "", "");
CAF_PDM_InitFieldNoDefault(&calcScripts, "CalcScripts", "", "", "", "");
CAF_PDM_InitFieldNoDefault(&subDirectories, "SubDirectories", "", "", "", "");
directory.setUiEditorTypeName(caf::PdmUiFilePathEditor::uiEditorTypeName());
}
//--------------------------------------------------------------------------------------------------
@ -44,8 +47,8 @@ RimScriptCollection::RimScriptCollection()
//--------------------------------------------------------------------------------------------------
RimScriptCollection::~RimScriptCollection()
{
calcScripts.deleteChildren();
subDirectories.deleteChildren();
calcScripts.deleteAllChildObjects();
subDirectories.deleteAllChildObjects();
}
//--------------------------------------------------------------------------------------------------
@ -53,7 +56,7 @@ RimScriptCollection::~RimScriptCollection()
//--------------------------------------------------------------------------------------------------
void RimScriptCollection::readContentFromDisc()
{
calcScripts.deleteChildren();
calcScripts.deleteAllChildObjects();
if (directory().isEmpty())
{
@ -91,7 +94,7 @@ void RimScriptCollection::readContentFromDisc()
{
QDir dir(directory);
QFileInfoList fileInfoList = dir.entryInfoList(QDir::AllDirs | QDir::NoDotAndDotDot);
subDirectories.deleteChildren();
subDirectories.deleteAllChildObjects();
QStringList retFileNames;
@ -162,3 +165,15 @@ void RimScriptCollection::fieldChangedByUi(const caf::PdmFieldHandle *changedFie
if (treeModel) treeModel->rebuildUiSubTree(this);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimScriptCollection::defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute)
{
if (field == &directory)
{
caf::PdmUiFilePathEditorAttribute* myAttr = static_cast<caf::PdmUiFilePathEditorAttribute*>(attribute);
myAttr->m_selectDirectory = true;
}
}

View File

@ -22,6 +22,12 @@
#include "cafPdmObject.h"
#include "RimCalcScript.h"
namespace caf
{
class PdmUiEditorAttribute;
}
//==================================================================================================
///
///
@ -47,5 +53,6 @@ public: // Methods
// Overrides from PdmObject
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue);
protected:
virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute );
};

View File

@ -31,6 +31,10 @@
#include "RimCalcScript.h"
#include "RIApplication.h"
#include "RIMainWindow.h"
#include "RimInputProperty.h"
#include "RimInputPropertyCollection.h"
#include "cafPdmField.h"
#include "RimInputReservoir.h"
//--------------------------------------------------------------------------------------------------
///
@ -103,7 +107,7 @@ bool RimUiTreeModelPdm::insertRows(int position, int rows, const QModelIndex &pa
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimUiTreeModelPdm::removePropertyFilter(const QModelIndex& itemIndex)
bool RimUiTreeModelPdm::deletePropertyFilter(const QModelIndex& itemIndex)
{
CVF_ASSERT(itemIndex.isValid());
@ -140,7 +144,7 @@ bool RimUiTreeModelPdm::removePropertyFilter(const QModelIndex& itemIndex)
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimUiTreeModelPdm::removeRangeFilter(const QModelIndex& itemIndex)
bool RimUiTreeModelPdm::deleteRangeFilter(const QModelIndex& itemIndex)
{
CVF_ASSERT(itemIndex.isValid());
@ -178,7 +182,7 @@ bool RimUiTreeModelPdm::removeRangeFilter(const QModelIndex& itemIndex)
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimUiTreeModelPdm::removeReservoirView(const QModelIndex& itemIndex)
bool RimUiTreeModelPdm::deleteReservoirView(const QModelIndex& itemIndex)
{
CVF_ASSERT(itemIndex.isValid());
@ -354,493 +358,64 @@ void RimUiTreeModelPdm::slotRefreshScriptTree(QString path)
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimTreeView::RimTreeView(QWidget *parent /*= 0*/)
: QTreeView(parent)
void RimUiTreeModelPdm::addInputProperty(const QModelIndex& itemIndex, const QStringList& fileNames)
{
setHeaderHidden(true);
}
caf::PdmUiTreeItem* currentItem = getTreeItemFromIndex(itemIndex);
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimTreeView::contextMenuEvent(QContextMenuEvent* event)
{
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
if (myModel)
RimInputPropertyCollection* inputPropertyCollection = dynamic_cast<RimInputPropertyCollection*>(currentItem->dataObject().p());
CVF_ASSERT(inputPropertyCollection);
std::vector<caf::PdmObject*> parentObjects;
inputPropertyCollection->parentObjects(parentObjects);
CVF_ASSERT(parentObjects.size() == 1);
RimInputReservoir* inputReservoir = dynamic_cast<RimInputReservoir*>(parentObjects[0]);
CVF_ASSERT(inputReservoir);
if (inputReservoir)
{
caf::PdmUiTreeItem* uiItem = myModel->getTreeItemFromIndex(currentIndex());
if (uiItem && uiItem->dataObject())
{
// Range filters
if (dynamic_cast<RimReservoirView*>(uiItem->dataObject().p()))
{
QMenu menu;
menu.addAction(QString("Show 3D Window"), this, SLOT(slotShowWindow()));
menu.addAction(QString("New View"), this, SLOT(slotAddView()));
menu.addAction(QString("Delete"), this, SLOT(slotDeleteView()));
menu.exec(event->globalPos());
}
else if (dynamic_cast<RimCellRangeFilterCollection*>(uiItem->dataObject().p()))
{
QMenu menu;
menu.addAction(QString("New Range Filter"), this, SLOT(slotAddRangeFilter()));
menu.addAction(QString("Slice I Filter"), this, SLOT(slotAddSliceFilterI()));
menu.addAction(QString("Slice J Filter"), this, SLOT(slotAddSliceFilterJ()));
menu.addAction(QString("Slice K Filter"), this, SLOT(slotAddSliceFilterK()));
menu.exec(event->globalPos());
}
else if (dynamic_cast<RimCellRangeFilter*>(uiItem->dataObject().p()))
{
QMenu menu;
menu.addAction(QString("Insert Range Filter"), this, SLOT(slotAddRangeFilter()));
menu.addAction(QString("Slice I Filter"), this, SLOT(slotAddSliceFilterI()));
menu.addAction(QString("Slice J Filter"), this, SLOT(slotAddSliceFilterJ()));
menu.addAction(QString("Slice K Filter"), this, SLOT(slotAddSliceFilterK()));
menu.addSeparator();
menu.addAction(QString("Delete"), this, SLOT(slotDeleteRangeFilter()));
menu.exec(event->globalPos());
}
else if (dynamic_cast<RimCellPropertyFilterCollection*>(uiItem->dataObject().p()))
{
QMenu menu;
menu.addAction(QString("New Property Filter"), this, SLOT(slotAddPropertyFilter()));
menu.exec(event->globalPos());
}
else if (dynamic_cast<RimCellPropertyFilter*>(uiItem->dataObject().p()))
{
QMenu menu;
menu.addAction(QString("Insert Property Filter"), this, SLOT(slotAddPropertyFilter()));
menu.addSeparator();
menu.addAction(QString("Delete"), this, SLOT(slotDeletePropertyFilter()));
menu.exec(event->globalPos());
}
else if (dynamic_cast<RimCalcScript*>(uiItem->dataObject().p()))
{
RIApplication* app = RIApplication::instance();
QMenu menu;
{
QAction* action = menu.addAction(QString("Edit"), this, SLOT(slotEditScript()));
if (app->scriptEditorPath().isEmpty())
{
action->setEnabled(false);
}
}
menu.addAction(QString("New"), this, SLOT(slotNewScript()));
//menu.addAction(QString("ReadFromFile"), this, SLOT(slotReadScriptContentFromFile()));
menu.addSeparator();
{
QAction* action = menu.addAction(QString("Execute"), this, SLOT(slotExecuteScript()));
if (app->octavePath().isEmpty())
{
action->setEnabled(false);
}
}
menu.exec(event->globalPos());
}
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimTreeView::slotAddChildItem()
{
QModelIndex index = currentIndex();
QAbstractItemModel* myModel = model();
// Insert a single row at the end of the collection of items
int itemCount = myModel->rowCount(index);
if (!myModel->insertRow(itemCount, index))
return;
selectionModel()->setCurrentIndex(myModel->index(0, 0, index), QItemSelectionModel::ClearAndSelect);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimTreeView::slotDeleteItem()
{
QModelIndex index = currentIndex();
QAbstractItemModel* myModel = model();
if (!myModel->removeRow(index.row(), index.parent()))
return;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimTreeView::slotShowWindow()
{
QModelIndex index = currentIndex();
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
caf::PdmUiTreeItem* uiItem = myModel->getTreeItemFromIndex(currentIndex());
RimReservoirView * riv = NULL;
if (riv = dynamic_cast<RimReservoirView*>(uiItem->dataObject().p()))
{
riv->showWindow = true;
bool generateDisplayModel = (riv->viewer() == NULL);
riv->updateViewerWidget();
if (generateDisplayModel)
{
riv->createDisplayModelAndRedraw();
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimTreeView::slotDeletePropertyFilter()
{
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
if (myModel)
{
myModel->removePropertyFilter(currentIndex());
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimTreeView::slotDeleteRangeFilter()
{
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
if (myModel)
{
myModel->removeRangeFilter(currentIndex());
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimTreeView::slotAddPropertyFilter()
{
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
if (myModel)
{
QModelIndex insertedIndex;
RimCellPropertyFilter* propFilter = myModel->addPropertyFilter(currentIndex(), insertedIndex);
setCurrentIndex(insertedIndex);
if (propFilter)
{
propFilter->parentContainer()->reservoirView()->createDisplayModelAndRedraw();
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimTreeView::slotAddRangeFilter()
{
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
if (myModel)
{
QModelIndex insertedIndex;
RimCellRangeFilter* newFilter = myModel->addRangeFilter(currentIndex(), insertedIndex);
setCurrentIndex(insertedIndex);
if (newFilter && newFilter->parentContainer())
{
newFilter->parentContainer()->reservoirView()->createDisplayModelAndRedraw();
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimTreeView::slotAddSliceFilterI()
{
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
if (myModel)
{
QModelIndex insertedIndex;
RimCellRangeFilter* rangeFilter = myModel->addRangeFilter(currentIndex(), insertedIndex);
RimCellRangeFilterCollection* rangeFilterCollection = rangeFilter->parentContainer();
rangeFilter->name = QString("Slice I (%1)").arg(rangeFilterCollection->rangeFilters().size());
rangeFilter->cellCountI = 1;
rangeFilterCollection->reservoirView()->scheduleGeometryRegen(RivReservoirViewPartMgr::RANGE_FILTERED);
rangeFilterCollection->reservoirView()->scheduleGeometryRegen(RivReservoirViewPartMgr::RANGE_FILTERED_INACTIVE);
rangeFilterCollection->reservoirView()->createDisplayModelAndRedraw();
setCurrentIndex(insertedIndex);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimTreeView::slotAddSliceFilterJ()
{
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
if (myModel)
{
QModelIndex insertedIndex;
RimCellRangeFilter* rangeFilter = myModel->addRangeFilter(currentIndex(), insertedIndex);
RimCellRangeFilterCollection* rangeFilterCollection = rangeFilter->parentContainer();
rangeFilter->name = QString("Slice J (%1)").arg(rangeFilterCollection->rangeFilters().size());
rangeFilter->cellCountJ = 1;
rangeFilterCollection->reservoirView()->scheduleGeometryRegen(RivReservoirViewPartMgr::RANGE_FILTERED);
rangeFilterCollection->reservoirView()->scheduleGeometryRegen(RivReservoirViewPartMgr::RANGE_FILTERED_INACTIVE);
rangeFilterCollection->reservoirView()->createDisplayModelAndRedraw();
setCurrentIndex(insertedIndex);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimTreeView::slotAddSliceFilterK()
{
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
if (myModel)
{
QModelIndex insertedIndex;
RimCellRangeFilter* rangeFilter = myModel->addRangeFilter(currentIndex(), insertedIndex);
RimCellRangeFilterCollection* rangeFilterCollection = rangeFilter->parentContainer();
rangeFilter->name = QString("Slice K (%1)").arg(rangeFilterCollection->rangeFilters().size());
rangeFilter->cellCountK = 1;
rangeFilterCollection->reservoirView()->scheduleGeometryRegen(RivReservoirViewPartMgr::RANGE_FILTERED);
rangeFilterCollection->reservoirView()->scheduleGeometryRegen(RivReservoirViewPartMgr::RANGE_FILTERED_INACTIVE);
rangeFilterCollection->reservoirView()->createDisplayModelAndRedraw();
setCurrentIndex(insertedIndex);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimTreeView::slotReadScriptContentFromFile()
{
QModelIndex index = currentIndex();
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
caf::PdmUiTreeItem* uiItem = myModel->getTreeItemFromIndex(currentIndex());
if (uiItem)
{
RimCalcScript* calcScript = dynamic_cast<RimCalcScript*>(uiItem->dataObject().p());
if (calcScript)
{
calcScript->readContentFromFile();
}
inputReservoir->openDataFileSet(fileNames);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimTreeView::slotEditScript()
{
QModelIndex index = currentIndex();
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
caf::PdmUiTreeItem* uiItem = myModel->getTreeItemFromIndex(currentIndex());
if (uiItem)
{
RimCalcScript* calcScript = dynamic_cast<RimCalcScript*>(uiItem->dataObject().p());
RIApplication* app = RIApplication::instance();
QString scriptEditor = app->scriptEditorPath();
if (!scriptEditor.isEmpty())
{
QStringList arguments;
arguments << calcScript->absolutePath;
QProcess* myProcess = new QProcess(this);
myProcess->start(scriptEditor, arguments);
if (!myProcess->waitForStarted(1000))
{
QMessageBox::warning(RIMainWindow::instance(), "Script editor", "Failed to start script editor executable\n" + scriptEditor);
}
}
}
this->rebuildUiSubTree(inputPropertyCollection);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimTreeView::slotNewScript()
void RimUiTreeModelPdm::deleteInputProperty(const QModelIndex& itemIndex)
{
QModelIndex index = currentIndex();
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
caf::PdmUiTreeItem* uiItem = myModel->getTreeItemFromIndex(currentIndex());
RimCalcScript* calcScript = NULL;
RimScriptCollection * scriptColl = NULL;
if (!itemIndex.isValid()) return;
calcScript = dynamic_cast<RimCalcScript*>(uiItem->dataObject().p());
scriptColl = dynamic_cast<RimScriptCollection*>(uiItem->dataObject().p());
QString fullPathNewScript;
caf::PdmUiTreeItem* uiItem = getTreeItemFromIndex(itemIndex);
if (!uiItem) return;
if (calcScript )
{
QFileInfo existingScriptFileInfo(calcScript->absolutePath());
fullPathNewScript = existingScriptFileInfo.absolutePath();
}
else if (scriptColl)
{
fullPathNewScript = scriptColl->directory();
}
else
{
return;
}
caf::PdmObject* object = uiItem->dataObject().p();
RimInputProperty* inputProperty = dynamic_cast<RimInputProperty*>(object);
if (!inputProperty) return;
QString fullPathFilenameNewScript;
// Remove item from UI tree model before delete of project data structure
removeRow(itemIndex.row(), itemIndex.parent());
fullPathFilenameNewScript = fullPathNewScript + "/untitled.m";
int num= 1;
while (QFileInfo(fullPathFilenameNewScript).exists())
{
fullPathFilenameNewScript = fullPathNewScript + "/untitled" + QString::number(num) + ".m";
num++;
}
std::vector<caf::PdmObject*> parentObjects;
object->parentObjects(parentObjects);
CVF_ASSERT(parentObjects.size() == 1);
RIApplication* app = RIApplication::instance();
QString scriptEditor = app->scriptEditorPath();
if (!scriptEditor.isEmpty())
{
QStringList arguments;
arguments << fullPathFilenameNewScript;
RimInputPropertyCollection* inputPropertyCollection = dynamic_cast<RimInputPropertyCollection*>(parentObjects[0]);
if (!inputPropertyCollection) return;
QProcess* myProcess = new QProcess(this);
myProcess->start(scriptEditor, arguments);
std::vector<caf::PdmObject*> parentObjects2;
inputPropertyCollection->parentObjects(parentObjects2);
CVF_ASSERT(parentObjects2.size() == 1);
if (!myProcess->waitForStarted(1000))
{
QMessageBox::warning(RIMainWindow::instance(), "Script editor", "Failed to start script editor executable\n" + scriptEditor);
}
}
RimInputReservoir* inputReservoir = dynamic_cast<RimInputReservoir*>(parentObjects2[0]);
if (!inputReservoir) return;
inputReservoir->removeProperty(inputProperty);
delete inputProperty;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimTreeView::slotExecuteScript()
{
QModelIndex index = currentIndex();
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
caf::PdmUiTreeItem* uiItem = myModel->getTreeItemFromIndex(currentIndex());
if (uiItem)
{
RimCalcScript* calcScript = dynamic_cast<RimCalcScript*>(uiItem->dataObject().p());
RIApplication* app = RIApplication::instance();
QString octavePath = app->octavePath();
if (!octavePath.isEmpty())
{
QStringList arguments;
arguments << calcScript->absolutePath();
if (!RIApplication::instance()->launchProcess(octavePath, arguments))
{
QMessageBox::warning(RIMainWindow::instance(), "Script execution", "Failed to start script executable located at\n" + octavePath);
}
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimTreeView::slotAddView()
{
QModelIndex index = currentIndex();
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
caf::PdmUiTreeItem* uiItem = myModel->getTreeItemFromIndex(currentIndex());
RimReservoirView* rimView = dynamic_cast<RimReservoirView*>(uiItem->dataObject().p());
if (rimView)
{
QModelIndex insertedIndex;
myModel->addReservoirView(index, insertedIndex);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimTreeView::slotDeleteView()
{
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
if (myModel)
{
myModel->removeReservoirView(currentIndex());
RIApplication* app = RIApplication::instance();
app->setActiveReservoirView(NULL);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimUiPropertyCreatorPdm::RimUiPropertyCreatorPdm(QObject* parent)
: caf::UiPropertyCreatorPdm(parent)
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimUiPropertyCreatorPdm::uiFields(const caf::PdmObject* object, std::vector<caf::PdmFieldHandle*>& fields) const
{
const RimCellPropertyFilter* propertyFilter = dynamic_cast<const RimCellPropertyFilter*>(object);
if (propertyFilter)
{
caf::UiPropertyCreatorPdm::uiFields(object, fields);
CVF_ASSERT(propertyFilter->resultDefinition);
// Append fields from result definition object
std::vector<caf::PdmFieldHandle*> childFields;
propertyFilter->resultDefinition->fields(childFields);
size_t i;
for (i = 0; i < childFields.size(); i++)
{
fields.push_back(childFields[i]);
}
}
else
{
caf::UiPropertyCreatorPdm::uiFields(object, fields);
}
}

View File

@ -21,14 +21,13 @@
#include "cafPdmObject.h"
#include "cafPdmPointer.h"
#include "cafUiTreeModelPdm.h"
#include "RimCellRangeFilter.h"
#include <QTreeView>
#include "cafUiPropertyCreatorPdm.h"
class QFileSystemWatcher;
class RimCellPropertyFilter;
class RimCellRangeFilter;
class RimReservoirView;
class RimInputProperty;
//==================================================================================================
///
@ -45,13 +44,15 @@ public:
virtual bool insertRows(int position, int rows, const QModelIndex &parent = QModelIndex());
// Special edit methods
bool removeRangeFilter(const QModelIndex& itemIndex);
bool removePropertyFilter(const QModelIndex& itemIndex);
bool removeReservoirView(const QModelIndex& itemIndex);
bool deleteRangeFilter(const QModelIndex& itemIndex);
bool deletePropertyFilter(const QModelIndex& itemIndex);
bool deleteReservoirView(const QModelIndex& itemIndex);
void deleteInputProperty(const QModelIndex& itemIndex);
RimCellPropertyFilter* addPropertyFilter(const QModelIndex& itemIndex, QModelIndex& insertedModelIndex);
RimCellRangeFilter* addRangeFilter(const QModelIndex& itemIndex, QModelIndex& insertedModelIndex);
RimReservoirView* addReservoirView(const QModelIndex& itemIndex, QModelIndex& insertedModelIndex);
void addInputProperty(const QModelIndex& itemIndex, const QStringList& fileNames);
void updateScriptPaths();
@ -64,50 +65,5 @@ private:
//==================================================================================================
///
///
//==================================================================================================
class RimTreeView : public QTreeView
{
Q_OBJECT
public:
RimTreeView(QWidget *parent = 0);
protected:
void contextMenuEvent(QContextMenuEvent* event);
private slots:
void slotAddChildItem();
void slotDeleteItem();
void slotShowWindow();
void slotAddRangeFilter();
void slotAddSliceFilterI();
void slotAddSliceFilterJ();
void slotAddSliceFilterK();
void slotAddPropertyFilter();
void slotDeletePropertyFilter();
void slotDeleteRangeFilter();
void slotReadScriptContentFromFile();
void slotEditScript();
void slotNewScript();
void slotExecuteScript();
void slotAddView();
void slotDeleteView();
};
class RimUiPropertyCreatorPdm : public caf::UiPropertyCreatorPdm
{
public:
RimUiPropertyCreatorPdm(QObject* parent);
virtual void uiFields(const caf::PdmObject* object, std::vector<caf::PdmFieldHandle*>& fields) const;
};

View File

@ -0,0 +1,707 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RIStdInclude.h"
#include "RimUiTreeView.h"
#include "RimUiTreeModelPdm.h"
#include "RimReservoirView.h"
#include "RimCalcScript.h"
#include "RIApplication.h"
#include "RIMainWindow.h"
#include "RimInputPropertyCollection.h"
#include "RimExportInputPropertySettings.h"
#include "RIPreferencesDialog.h"
#include "RifEclipseInputFileTools.h"
#include "RimInputReservoir.h"
#include "RimBinaryExportSettings.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimUiTreeView::RimUiTreeView(QWidget *parent /*= 0*/)
: QTreeView(parent)
{
setHeaderHidden(true);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimUiTreeView::contextMenuEvent(QContextMenuEvent* event)
{
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
if (myModel)
{
caf::PdmUiTreeItem* uiItem = myModel->getTreeItemFromIndex(currentIndex());
if (uiItem && uiItem->dataObject())
{
// Range filters
if (dynamic_cast<RimReservoirView*>(uiItem->dataObject().p()))
{
QMenu menu;
menu.addAction(QString("Show 3D Window"), this, SLOT(slotShowWindow()));
menu.addAction(QString("New View"), this, SLOT(slotAddView()));
menu.addAction(QString("Delete"), this, SLOT(slotDeleteView()));
menu.exec(event->globalPos());
}
else if (dynamic_cast<RimCellRangeFilterCollection*>(uiItem->dataObject().p()))
{
QMenu menu;
menu.addAction(QString("New Range Filter"), this, SLOT(slotAddRangeFilter()));
menu.addAction(QString("Slice I Filter"), this, SLOT(slotAddSliceFilterI()));
menu.addAction(QString("Slice J Filter"), this, SLOT(slotAddSliceFilterJ()));
menu.addAction(QString("Slice K Filter"), this, SLOT(slotAddSliceFilterK()));
menu.exec(event->globalPos());
}
else if (dynamic_cast<RimCellRangeFilter*>(uiItem->dataObject().p()))
{
QMenu menu;
menu.addAction(QString("Insert Range Filter"), this, SLOT(slotAddRangeFilter()));
menu.addAction(QString("Slice I Filter"), this, SLOT(slotAddSliceFilterI()));
menu.addAction(QString("Slice J Filter"), this, SLOT(slotAddSliceFilterJ()));
menu.addAction(QString("Slice K Filter"), this, SLOT(slotAddSliceFilterK()));
menu.addSeparator();
menu.addAction(QString("Delete"), this, SLOT(slotDeleteRangeFilter()));
menu.exec(event->globalPos());
}
else if (dynamic_cast<RimCellPropertyFilterCollection*>(uiItem->dataObject().p()))
{
QMenu menu;
menu.addAction(QString("New Property Filter"), this, SLOT(slotAddPropertyFilter()));
menu.exec(event->globalPos());
}
else if (dynamic_cast<RimCellPropertyFilter*>(uiItem->dataObject().p()))
{
QMenu menu;
menu.addAction(QString("Insert Property Filter"), this, SLOT(slotAddPropertyFilter()));
menu.addSeparator();
menu.addAction(QString("Delete"), this, SLOT(slotDeletePropertyFilter()));
menu.exec(event->globalPos());
}
else if (dynamic_cast<RimCalcScript*>(uiItem->dataObject().p()))
{
RIApplication* app = RIApplication::instance();
QMenu menu;
{
QAction* action = menu.addAction(QString("Edit"), this, SLOT(slotEditScript()));
if (app->scriptEditorPath().isEmpty())
{
action->setEnabled(false);
}
}
menu.addAction(QString("New"), this, SLOT(slotNewScript()));
//menu.addAction(QString("ReadFromFile"), this, SLOT(slotReadScriptContentFromFile()));
menu.addSeparator();
{
QAction* action = menu.addAction(QString("Execute"), this, SLOT(slotExecuteScript()));
if (app->octavePath().isEmpty())
{
action->setEnabled(false);
}
}
menu.exec(event->globalPos());
}
else if (dynamic_cast<RimInputPropertyCollection*>(uiItem->dataObject().p()))
{
QMenu menu;
menu.addAction(QString("Add Input Property"), this, SLOT(slotAddInputProperty()));
menu.exec(event->globalPos());
}
else if (dynamic_cast<RimInputProperty*>(uiItem->dataObject().p()))
{
QMenu menu;
menu.addAction(QString("Delete"), this, SLOT(slotDeleteObjectFromContainer()));
menu.addAction(QString("Write"), this, SLOT(slotWriteInputProperty()));
menu.exec(event->globalPos());
}
else if (dynamic_cast<RimResultSlot*>(uiItem->dataObject().p()))
{
QMenu menu;
menu.addAction(QString("Write"), this, SLOT(slotWriteBinaryResultAsInputProperty()));
menu.exec(event->globalPos());
}
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimUiTreeView::slotAddChildItem()
{
QModelIndex index = currentIndex();
QAbstractItemModel* myModel = model();
// Insert a single row at the end of the collection of items
int itemCount = myModel->rowCount(index);
if (!myModel->insertRow(itemCount, index))
return;
selectionModel()->setCurrentIndex(myModel->index(0, 0, index), QItemSelectionModel::ClearAndSelect);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimUiTreeView::slotDeleteItem()
{
QModelIndex index = currentIndex();
QAbstractItemModel* myModel = model();
if (!myModel->removeRow(index.row(), index.parent()))
return;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimUiTreeView::slotShowWindow()
{
QModelIndex index = currentIndex();
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
caf::PdmUiTreeItem* uiItem = myModel->getTreeItemFromIndex(currentIndex());
RimReservoirView * riv = NULL;
if (riv = dynamic_cast<RimReservoirView*>(uiItem->dataObject().p()))
{
riv->showWindow = true;
bool generateDisplayModel = (riv->viewer() == NULL);
riv->updateViewerWidget();
if (generateDisplayModel)
{
riv->createDisplayModelAndRedraw();
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimUiTreeView::slotDeletePropertyFilter()
{
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
if (myModel)
{
myModel->deletePropertyFilter(currentIndex());
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimUiTreeView::slotDeleteRangeFilter()
{
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
if (myModel)
{
myModel->deleteRangeFilter(currentIndex());
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimUiTreeView::slotAddPropertyFilter()
{
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
if (myModel)
{
QModelIndex insertedIndex;
RimCellPropertyFilter* propFilter = myModel->addPropertyFilter(currentIndex(), insertedIndex);
setCurrentIndex(insertedIndex);
if (propFilter)
{
propFilter->parentContainer()->reservoirView()->createDisplayModelAndRedraw();
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimUiTreeView::slotAddRangeFilter()
{
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
if (myModel)
{
QModelIndex insertedIndex;
RimCellRangeFilter* newFilter = myModel->addRangeFilter(currentIndex(), insertedIndex);
setCurrentIndex(insertedIndex);
if (newFilter && newFilter->parentContainer())
{
newFilter->parentContainer()->reservoirView()->createDisplayModelAndRedraw();
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimUiTreeView::slotAddSliceFilterI()
{
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
if (myModel)
{
QModelIndex insertedIndex;
RimCellRangeFilter* rangeFilter = myModel->addRangeFilter(currentIndex(), insertedIndex);
RimCellRangeFilterCollection* rangeFilterCollection = rangeFilter->parentContainer();
rangeFilter->name = QString("Slice I (%1)").arg(rangeFilterCollection->rangeFilters().size());
rangeFilter->cellCountI = 1;
rangeFilterCollection->reservoirView()->scheduleGeometryRegen(RivReservoirViewPartMgr::RANGE_FILTERED);
rangeFilterCollection->reservoirView()->scheduleGeometryRegen(RivReservoirViewPartMgr::RANGE_FILTERED_INACTIVE);
rangeFilterCollection->reservoirView()->createDisplayModelAndRedraw();
setCurrentIndex(insertedIndex);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimUiTreeView::slotAddSliceFilterJ()
{
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
if (myModel)
{
QModelIndex insertedIndex;
RimCellRangeFilter* rangeFilter = myModel->addRangeFilter(currentIndex(), insertedIndex);
RimCellRangeFilterCollection* rangeFilterCollection = rangeFilter->parentContainer();
rangeFilter->name = QString("Slice J (%1)").arg(rangeFilterCollection->rangeFilters().size());
rangeFilter->cellCountJ = 1;
rangeFilterCollection->reservoirView()->scheduleGeometryRegen(RivReservoirViewPartMgr::RANGE_FILTERED);
rangeFilterCollection->reservoirView()->scheduleGeometryRegen(RivReservoirViewPartMgr::RANGE_FILTERED_INACTIVE);
rangeFilterCollection->reservoirView()->createDisplayModelAndRedraw();
setCurrentIndex(insertedIndex);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimUiTreeView::slotAddSliceFilterK()
{
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
if (myModel)
{
QModelIndex insertedIndex;
RimCellRangeFilter* rangeFilter = myModel->addRangeFilter(currentIndex(), insertedIndex);
RimCellRangeFilterCollection* rangeFilterCollection = rangeFilter->parentContainer();
rangeFilter->name = QString("Slice K (%1)").arg(rangeFilterCollection->rangeFilters().size());
rangeFilter->cellCountK = 1;
rangeFilterCollection->reservoirView()->scheduleGeometryRegen(RivReservoirViewPartMgr::RANGE_FILTERED);
rangeFilterCollection->reservoirView()->scheduleGeometryRegen(RivReservoirViewPartMgr::RANGE_FILTERED_INACTIVE);
rangeFilterCollection->reservoirView()->createDisplayModelAndRedraw();
setCurrentIndex(insertedIndex);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimUiTreeView::slotReadScriptContentFromFile()
{
QModelIndex index = currentIndex();
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
caf::PdmUiTreeItem* uiItem = myModel->getTreeItemFromIndex(currentIndex());
if (uiItem)
{
RimCalcScript* calcScript = dynamic_cast<RimCalcScript*>(uiItem->dataObject().p());
if (calcScript)
{
calcScript->readContentFromFile();
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimUiTreeView::slotEditScript()
{
QModelIndex index = currentIndex();
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
caf::PdmUiTreeItem* uiItem = myModel->getTreeItemFromIndex(currentIndex());
if (uiItem)
{
RimCalcScript* calcScript = dynamic_cast<RimCalcScript*>(uiItem->dataObject().p());
RIApplication* app = RIApplication::instance();
QString scriptEditor = app->scriptEditorPath();
if (!scriptEditor.isEmpty())
{
QStringList arguments;
arguments << calcScript->absolutePath;
QProcess* myProcess = new QProcess(this);
myProcess->start(scriptEditor, arguments);
if (!myProcess->waitForStarted(1000))
{
QMessageBox::warning(RIMainWindow::instance(), "Script editor", "Failed to start script editor executable\n" + scriptEditor);
}
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimUiTreeView::slotNewScript()
{
QModelIndex index = currentIndex();
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
caf::PdmUiTreeItem* uiItem = myModel->getTreeItemFromIndex(currentIndex());
RimCalcScript* calcScript = NULL;
RimScriptCollection * scriptColl = NULL;
calcScript = dynamic_cast<RimCalcScript*>(uiItem->dataObject().p());
scriptColl = dynamic_cast<RimScriptCollection*>(uiItem->dataObject().p());
QString fullPathNewScript;
if (calcScript )
{
QFileInfo existingScriptFileInfo(calcScript->absolutePath());
fullPathNewScript = existingScriptFileInfo.absolutePath();
}
else if (scriptColl)
{
fullPathNewScript = scriptColl->directory();
}
else
{
return;
}
QString fullPathFilenameNewScript;
fullPathFilenameNewScript = fullPathNewScript + "/untitled.m";
int num= 1;
while (QFileInfo(fullPathFilenameNewScript).exists())
{
fullPathFilenameNewScript = fullPathNewScript + "/untitled" + QString::number(num) + ".m";
num++;
}
RIApplication* app = RIApplication::instance();
QString scriptEditor = app->scriptEditorPath();
if (!scriptEditor.isEmpty())
{
QStringList arguments;
arguments << fullPathFilenameNewScript;
QProcess* myProcess = new QProcess(this);
myProcess->start(scriptEditor, arguments);
if (!myProcess->waitForStarted(1000))
{
QMessageBox::warning(RIMainWindow::instance(), "Script editor", "Failed to start script editor executable\n" + scriptEditor);
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimUiTreeView::slotExecuteScript()
{
QModelIndex index = currentIndex();
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
caf::PdmUiTreeItem* uiItem = myModel->getTreeItemFromIndex(currentIndex());
if (uiItem)
{
RimCalcScript* calcScript = dynamic_cast<RimCalcScript*>(uiItem->dataObject().p());
RIApplication* app = RIApplication::instance();
QString octavePath = app->octavePath();
if (!octavePath.isEmpty())
{
QStringList arguments;
arguments.append("-q");
arguments << calcScript->absolutePath();
if (!RIApplication::instance()->launchProcess(octavePath, arguments))
{
QMessageBox::warning(RIMainWindow::instance(), "Script execution", "Failed to start script executable located at\n" + octavePath);
}
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimUiTreeView::slotAddView()
{
QModelIndex index = currentIndex();
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
caf::PdmUiTreeItem* uiItem = myModel->getTreeItemFromIndex(currentIndex());
RimReservoirView* rimView = dynamic_cast<RimReservoirView*>(uiItem->dataObject().p());
if (rimView)
{
QModelIndex insertedIndex;
myModel->addReservoirView(index, insertedIndex);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimUiTreeView::slotDeleteView()
{
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
if (myModel)
{
myModel->deleteReservoirView(currentIndex());
RIApplication* app = RIApplication::instance();
app->setActiveReservoirView(NULL);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimUiTreeView::slotSelectionChanged(const QItemSelection & selected, const QItemSelection & deselected)
{
caf::PdmObject* pdmObject = NULL;
if (selected.indexes().size() == 1)
{
QModelIndex mi = selected.indexes()[0];
if (mi.isValid())
{
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
if (myModel)
{
caf::PdmUiTreeItem* treeItem = myModel->getTreeItemFromIndex(mi);
if (treeItem && treeItem->dataObject())
{
pdmObject = treeItem->dataObject();
}
}
}
}
emit selectedObjectChanged(pdmObject);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimUiTreeView::setModel(QAbstractItemModel* model)
{
QTreeView::setModel(model);
if (selectionModel())
{
connect(selectionModel(), SIGNAL(selectionChanged( const QItemSelection & , const QItemSelection & )), SLOT(slotSelectionChanged( const QItemSelection & , const QItemSelection & )));
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimUiTreeView::slotAddInputProperty()
{
QStringList fileNames = QFileDialog::getOpenFileNames(this, "Select Eclipse Input Property Files", NULL, "All Files (*.* *)");
if (fileNames.isEmpty()) return;
QModelIndex index = currentIndex();
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
caf::PdmUiTreeItem* uiItem = myModel->getTreeItemFromIndex(currentIndex());
RimInputPropertyCollection* inputPropertyCollection = dynamic_cast<RimInputPropertyCollection*>(uiItem->dataObject().p());
if (inputPropertyCollection)
{
myModel->addInputProperty(index, fileNames);
setCurrentIndex(index);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimUiTreeView::slotDeleteObjectFromContainer()
{
QModelIndex index = currentIndex();
if (!index.isValid()) return;
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
if (myModel) myModel->deleteInputProperty(index);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimUiTreeView::slotWriteInputProperty()
{
QModelIndex index = currentIndex();
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
caf::PdmUiTreeItem* uiItem = myModel->getTreeItemFromIndex(currentIndex());
RimInputProperty* inputProperty = dynamic_cast<RimInputProperty*>(uiItem->dataObject().p());
if (!inputProperty) return;
{
bool isResolved = false;
if (inputProperty->resolvedState == RimInputProperty::RESOLVED || inputProperty->resolvedState == RimInputProperty::RESOLVED_NOT_SAVED)
{
isResolved = true;
}
if (!isResolved)
{
QMessageBox::warning(RIMainWindow::instance(), "Export failure", "Property is not resolved, and then it is not possible to export the property.");
return;
}
}
RimExportInputSettings exportSettings;
exportSettings.eclipseKeyword = inputProperty->eclipseKeyword;
// Find input reservoir for this property
RimInputReservoir* inputReservoir = NULL;
{
std::vector<caf::PdmObject*> parentObjects;
inputProperty->parentObjects(parentObjects);
CVF_ASSERT(parentObjects.size() == 1);
RimInputPropertyCollection* inputPropertyCollection = dynamic_cast<RimInputPropertyCollection*>(parentObjects[0]);
if (!inputPropertyCollection) return;
std::vector<caf::PdmObject*> parentObjects2;
inputPropertyCollection->parentObjects(parentObjects2);
CVF_ASSERT(parentObjects2.size() == 1);
inputReservoir = dynamic_cast<RimInputReservoir*>(parentObjects2[0]);
}
if (!inputReservoir) return;
{
QString projectFolder;
RIApplication* app = RIApplication::instance();
QString projectFileName = app->currentProjectFileName();
if (!projectFileName.isEmpty())
{
QFileInfo fi(projectFileName);
projectFolder = fi.absolutePath();
}
else
{
projectFolder = inputReservoir->locationOnDisc();
}
QString outputFileName = projectFolder + "/" + inputProperty->eclipseKeyword;
exportSettings.fileName = outputFileName;
}
RIPreferencesDialog preferencesDialog(this, &exportSettings, "Export Eclipse Property to Text File");
if (preferencesDialog.exec() == QDialog::Accepted)
{
bool isOk = RifEclipseInputFileTools::writePropertyToTextFile(exportSettings.fileName, inputReservoir->reservoirData(), 0, inputProperty->resultName, exportSettings.eclipseKeyword);
if (isOk)
{
inputProperty->fileName = exportSettings.fileName;
inputProperty->eclipseKeyword = exportSettings.eclipseKeyword;
inputProperty->resolvedState = RimInputProperty::RESOLVED;
inputProperty->updateConnectedEditors();
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimUiTreeView::slotWriteBinaryResultAsInputProperty()
{
QModelIndex index = currentIndex();
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
caf::PdmUiTreeItem* uiItem = myModel->getTreeItemFromIndex(currentIndex());
RimResultSlot* resultSlot = dynamic_cast<RimResultSlot*>(uiItem->dataObject().p());
if (!resultSlot) return;
if (!resultSlot->reservoirView()) return;
if (!resultSlot->reservoirView()->eclipseCase()) return;
if (!resultSlot->reservoirView()->eclipseCase()->reservoirData()) return;
RimBinaryExportSettings exportSettings;
exportSettings.eclipseKeyword = resultSlot->resultVariable;
{
QString projectFolder;
RIApplication* app = RIApplication::instance();
QString projectFileName = app->currentProjectFileName();
if (!projectFileName.isEmpty())
{
QFileInfo fi(projectFileName);
projectFolder = fi.absolutePath();
}
else
{
projectFolder = resultSlot->reservoirView()->eclipseCase()->locationOnDisc();
}
QString outputFileName = projectFolder + "/" + resultSlot->resultVariable;
exportSettings.fileName = outputFileName;
}
RIPreferencesDialog preferencesDialog(this, &exportSettings, "Export Binary Eclipse Data to Text File");
if (preferencesDialog.exec() == QDialog::Accepted)
{
size_t timeStep = resultSlot->reservoirView()->currentTimeStep();
bool isOk = RifEclipseInputFileTools::writeBinaryResultToTextFile(exportSettings.fileName, resultSlot->reservoirView()->eclipseCase()->reservoirData(), timeStep, resultSlot->resultVariable, exportSettings.eclipseKeyword, exportSettings.undefinedValue);
if (!isOk)
{
QMessageBox::critical(NULL, "File export", "Failed to exported current result to " + exportSettings.fileName);
}
}
}

View File

@ -0,0 +1,77 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "cafPdmObject.h"
#include <QTreeView>
class QItemSelection;
//==================================================================================================
///
///
//==================================================================================================
class RimUiTreeView : public QTreeView
{
Q_OBJECT
public:
RimUiTreeView(QWidget *parent = 0);
virtual void setModel(QAbstractItemModel* model);
protected:
void contextMenuEvent(QContextMenuEvent* event);
private slots:
void slotAddChildItem();
void slotDeleteItem();
void slotShowWindow();
void slotAddRangeFilter();
void slotAddSliceFilterI();
void slotAddSliceFilterJ();
void slotAddSliceFilterK();
void slotDeleteRangeFilter();
void slotAddPropertyFilter();
void slotDeletePropertyFilter();
void slotReadScriptContentFromFile();
void slotEditScript();
void slotNewScript();
void slotExecuteScript();
void slotAddView();
void slotDeleteView();
void slotAddInputProperty();
void slotDeleteObjectFromContainer();
void slotWriteInputProperty();
void slotWriteBinaryResultAsInputProperty();
void slotSelectionChanged(const QItemSelection & selected, const QItemSelection & deselected);
signals:
void selectedObjectChanged( caf::PdmObject* pdmObject );
};

View File

@ -49,7 +49,8 @@ RimWell::RimWell()
name.setHidden(true);
name.setUiHidden(true);
name.setUiReadOnly(true);
m_reservoirView = NULL;
}

View File

@ -66,7 +66,10 @@ RimWellCollection::RimWellCollection()
CAF_PDM_InitField(&wellHeadScaleFactor, "WellHeadScale", 1.0, " Well head scale", "", "", "");
CAF_PDM_InitField(&wellPipeVisibility, "GlobalWellPipeVisibility", WellVisibilityEnum(ALL_ON), "Global well pipe visibility", "", "", "");
CAF_PDM_InitField(&pipeRadiusScaleFactor, "WellPipeRadiusScale", 0.1, " Pipe radius scale", "", "", "");
CAF_PDM_InitField(&pipeRadiusScaleFactor, "WellPipeRadiusScale", 0.1, " Pipe radius scale", "", "", "");
CAF_PDM_InitField(&pipeCrossSectionVertexCount, "WellPipeVertexCount", 12, "Pipe vertex count", "", "", "");
pipeCrossSectionVertexCount.setUiHidden(true);
CAF_PDM_InitField(&wellCellVisibility, "GlobalWellCellVisibility", WellVisibilityEnum(FORCE_ALL_OFF), "Add cells to range filter", "", "", "");
CAF_PDM_InitField(&showWellCellFences, "ShowWellFences", false, " Use well fence", "", "", "");
@ -74,6 +77,8 @@ RimWellCollection::RimWellCollection()
CAF_PDM_InitField(&wellCellTransparencyLevel, "WellCellTransparency", 0.5, "Well cell transparency", "", "", "");
CAF_PDM_InitField(&isAutoDetectingBranches, "IsAutoDetectingBranches", true, "Geometry based branch detection", "", "Toggle wether the well pipe visualization will try to detect when a part of the well \nis really a branch, and thus is starting from wellhead", "");
CAF_PDM_InitFieldNoDefault(&wells, "Wells", "Wells", "", "", "");
m_reservoirView = NULL;
@ -84,7 +89,7 @@ RimWellCollection::RimWellCollection()
//--------------------------------------------------------------------------------------------------
RimWellCollection::~RimWellCollection()
{
wells.deleteChildren();
wells.deleteAllChildObjects();
}
//--------------------------------------------------------------------------------------------------
@ -199,7 +204,11 @@ void RimWellCollection::fieldChangedByUi(const caf::PdmFieldHandle* changedField
m_reservoirView->createDisplayModelAndRedraw();
}
}
else if (&pipeRadiusScaleFactor == changedField || &wellHeadScaleFactor == changedField || &showWellHead == changedField)
else if ( &pipeCrossSectionVertexCount == changedField
|| &pipeRadiusScaleFactor == changedField
|| &wellHeadScaleFactor == changedField
|| &showWellHead == changedField
|| &isAutoDetectingBranches == changedField)
{
if (m_reservoirView)
{

View File

@ -68,9 +68,13 @@ public:
caf::PdmField<WellVisibilityEnum> wellPipeVisibility;
caf::PdmField<double> pipeRadiusScaleFactor;
caf::PdmField<int> pipeCrossSectionVertexCount;
caf::PdmField<double> wellHeadScaleFactor;
caf::PdmField<bool> showWellHead;
caf::PdmField<bool> isAutoDetectingBranches;
caf::PdmPointersField<RimWell*> wells;
RimWell* findWell(QString name);

View File

@ -32,6 +32,5 @@
#include <QtCore/QtCore>
#include <QtGui/QtGui>
#include <QtOpenGL/QtOpenGL>
#endif // USE_PRECOMPILED_HEADERS

View File

@ -250,8 +250,15 @@ double RigGridBase::cellScalar(size_t timeStepIndex, size_t scalarSetIndex, size
//--------------------------------------------------------------------------------------------------
double RigGridBase::cellScalar(size_t timeStepIndex, size_t scalarSetIndex, size_t cellIndex) const
{
size_t resultIndex = cell(cellIndex).globalActiveIndex(); // !! Assumes results are given for active cells only !!
if (resultIndex == cvf::UNDEFINED_SIZE_T) return HUGE_VAL;
size_t resultIndex = cellIndex;
bool useGlobalActiveIndex = m_mainGrid->results()->isUsingGlobalActiveIndex(scalarSetIndex);
if (useGlobalActiveIndex)
{
resultIndex = cell(cellIndex).globalActiveIndex();
if (resultIndex == cvf::UNDEFINED_SIZE_T) return HUGE_VAL;
}
const std::vector< std::vector<double> >& scalarResult = m_mainGrid->results()->cellScalarResults(scalarSetIndex);
if (!(timeStepIndex < scalarResult.size() && resultIndex < scalarResult[timeStepIndex].size())) return HUGE_VAL;

View File

@ -31,7 +31,7 @@ RigMainGrid::RigMainGrid(void)
m_validCellPositionMax(cvf::Vec3st::UNDEFINED),
m_activeCellCount(cvf::UNDEFINED_SIZE_T)
{
m_results = new RigReservoirCellResults;
m_results = new RigReservoirCellResults(this);
m_activeCellsBoundingBox.add(cvf::Vec3d::ZERO);
m_gridIndex = 0;

View File

@ -22,6 +22,11 @@
#include "RigReservoir.h"
/* rand example: guess the number */
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -250,6 +255,28 @@ void RigReservoirBuilderMock::setWorldCoordinates(cvf::Vec3d minWorldCoordinate,
m_maxWorldCoordinate = maxWorldCoordinate;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RigReservoirBuilderMock::inputProperty(RigReservoir* reservoir, const QString& propertyName, std::vector<double>* values)
{
size_t k;
/* initialize random seed: */
srand ( time(NULL) );
/* generate secret number: */
int iSecret = rand() % 20 + 1;
for (k = 0; k < reservoir->mainGrid()->cellCount(); k++)
{
values->push_back(k * iSecret);
}
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -24,7 +24,6 @@
#include "cvfVector3.h"
#include "RigCell.h"
#include "RigReservoir.h"
#include "RifReaderInterface.h"
class LocalGridRefinement
{
@ -58,6 +57,7 @@ public:
void populateReservoir(RigReservoir* reservoir);
bool inputProperty(RigReservoir* reservoir, const QString& propertyName, std::vector<double>* values );
bool staticResult(RigReservoir* reservoir, const QString& result, std::vector<double>* values );
bool dynamicResult(RigReservoir* reservoir, const QString& result, size_t stepIndex, std::vector<double>* values );

View File

@ -20,14 +20,18 @@
#include "RigReservoirCellResults.h"
#include "RifReaderInterface.h"
#include "RigMainGrid.h"
#include <QDateTime>
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigReservoirCellResults::RigReservoirCellResults()
RigReservoirCellResults::RigReservoirCellResults(RigMainGrid* ownerGrid)
{
CVF_ASSERT(ownerGrid != NULL);
m_ownerMainGrid = ownerGrid;
}
//--------------------------------------------------------------------------------------------------
@ -117,21 +121,6 @@ void RigReservoirCellResults::minMaxCellScalarValues(size_t scalarResultIndex, s
m_maxMinValuesPrTs[scalarResultIndex][timeStepIndex].second= max;
}
//--------------------------------------------------------------------------------------------------
/// Allocates resultCount of result containers and allocates
/// timeStepCount entries for last result container
//--------------------------------------------------------------------------------------------------
void RigReservoirCellResults::initialize( size_t resultCount, size_t timeStepCount )
{
m_cellScalarResults.resize(resultCount);
if (m_cellScalarResults.size() > 0)
{
m_cellScalarResults[resultCount - 1].resize(timeStepCount);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -173,74 +162,55 @@ const std::vector< std::vector<double> >& RigReservoirCellResults::cellScalarRes
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
size_t RigReservoirCellResults::loadResultIntoGrid(RimDefines::ResultCatType type, const QString& resultName)
size_t RigReservoirCellResults::findOrLoadScalarResult(RimDefines::ResultCatType type, const QString& resultName)
{
size_t resultGridIndex = cvf::UNDEFINED_SIZE_T;
resultGridIndex = findGridScalarIndex(type, resultName);
if (resultGridIndex != cvf::UNDEFINED_SIZE_T) return resultGridIndex;
resultGridIndex = findScalarResultIndex(type, resultName);
if (resultGridIndex == cvf::UNDEFINED_SIZE_T) return cvf::UNDEFINED_SIZE_T;
if (cellScalarResults(resultGridIndex).size()) return resultGridIndex;
// Generated and Input properties should always be loaded up front.
CVF_ASSERT(type == RimDefines::STATIC_NATIVE || type == RimDefines::DYNAMIC_NATIVE);
if (m_readerInterface.notNull())
{
// Add one more result to result container
resultGridIndex = resultCount();
size_t timeStepCount = m_readerInterface->numTimeSteps();
size_t timeStepCount = m_resultInfos[resultGridIndex].m_timeStepDates.size();
bool resultLoadingSucess = true;
if (type == RimDefines::DYNAMIC_NATIVE && timeStepCount > 0)
{
initialize(resultGridIndex + 1, timeStepCount);
if (m_readerInterface->dynamicResults().indexOf(resultName) >= 0)
m_cellScalarResults[resultGridIndex].resize(timeStepCount);
size_t i;
for (i = 0; i < timeStepCount; i++)
{
size_t i;
for (i = 0; i < timeStepCount; i++)
{
std::vector<double>& values = m_cellScalarResults[resultGridIndex][i];
if (!m_readerInterface->dynamicResult(resultName, i, &values))
{
resultLoadingSucess = false;
}
}
}
else
{
resultLoadingSucess = false;
}
}
else if (type == RimDefines::STATIC_NATIVE)
{
initialize(resultGridIndex + 1, 1);
if (m_readerInterface->staticResults().indexOf(resultName) >= 0)
{
std::vector<double>& values = m_cellScalarResults[resultGridIndex][0];
if (!m_readerInterface->staticResult(resultName, &values))
std::vector<double>& values = m_cellScalarResults[resultGridIndex][i];
if (!m_readerInterface->dynamicResult(resultName, i, &values))
{
resultLoadingSucess = false;
}
}
else
}
else if (type == RimDefines::STATIC_NATIVE)
{
m_cellScalarResults[resultGridIndex].resize(1);
std::vector<double>& values = m_cellScalarResults[resultGridIndex][0];
if (!m_readerInterface->staticResult(resultName, &values))
{
resultLoadingSucess = false;
}
}
else
{
resultLoadingSucess = false;
}
if (resultLoadingSucess)
{
ResultMapper mapper(type, resultName, resultGridIndex);
m_resultMap.push_back(mapper);
}
else
if (!resultLoadingSucess)
{
// Remove last scalar result because loading of result failed
m_cellScalarResults.resize(resultGridIndex);
resultGridIndex = cvf::UNDEFINED_SIZE_T;
m_cellScalarResults[resultGridIndex].clear();
}
}
@ -258,10 +228,10 @@ void RigReservoirCellResults::setReaderInterface(RifReaderInterface* readerInter
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
size_t RigReservoirCellResults::findGridScalarIndex(RimDefines::ResultCatType type, const QString& resultName) const
size_t RigReservoirCellResults::findScalarResultIndex(RimDefines::ResultCatType type, const QString& resultName) const
{
std::list<ResultMapper>::const_iterator it;
for (it = m_resultMap.begin(); it != m_resultMap.end(); it++)
std::vector<ResultInfo>::const_iterator it;
for (it = m_resultInfos.begin(); it != m_resultInfos.end(); it++)
{
if (it->m_resultType == type && it->m_resultName == resultName)
{
@ -272,23 +242,50 @@ size_t RigReservoirCellResults::findGridScalarIndex(RimDefines::ResultCatType ty
return cvf::UNDEFINED_SIZE_T;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
size_t RigReservoirCellResults::findScalarResultIndex(const QString& resultName) const
{
size_t scalarResultIndex = cvf::UNDEFINED_SIZE_T;
scalarResultIndex = this->findScalarResultIndex(RimDefines::STATIC_NATIVE, resultName);
if (scalarResultIndex == cvf::UNDEFINED_SIZE_T)
{
scalarResultIndex = this->findScalarResultIndex(RimDefines::DYNAMIC_NATIVE, resultName);
}
if (scalarResultIndex == cvf::UNDEFINED_SIZE_T)
{
scalarResultIndex = this->findScalarResultIndex(RimDefines::GENERATED, resultName);
}
if (scalarResultIndex == cvf::UNDEFINED_SIZE_T)
{
scalarResultIndex = this->findScalarResultIndex(RimDefines::INPUT_PROPERTY, resultName);
}
return scalarResultIndex;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigReservoirCellResults::loadOrComputeSOIL()
{
size_t resultGridIndex = loadResultIntoGrid(RimDefines::DYNAMIC_NATIVE, "SOIL");
size_t resultGridIndex = findOrLoadScalarResult(RimDefines::DYNAMIC_NATIVE, "SOIL");
if (resultGridIndex == cvf::UNDEFINED_SIZE_T)
{
size_t scalarIndexSWAT = loadResultIntoGrid(RimDefines::DYNAMIC_NATIVE, "SWAT");
size_t scalarIndexSGAS = loadResultIntoGrid(RimDefines::DYNAMIC_NATIVE, "SGAS");
size_t scalarIndexSWAT = findOrLoadScalarResult(RimDefines::DYNAMIC_NATIVE, "SWAT");
size_t scalarIndexSGAS = findOrLoadScalarResult(RimDefines::DYNAMIC_NATIVE, "SGAS");
if (scalarIndexSGAS != cvf::UNDEFINED_SIZE_T && scalarIndexSWAT != cvf::UNDEFINED_SIZE_T)
{
resultGridIndex = resultCount();
size_t timeStepCount = m_readerInterface->numTimeSteps();
initialize(resultGridIndex + 1, timeStepCount);
size_t timeStepCount = m_resultInfos[scalarIndexSWAT].m_timeStepDates.size();
resultGridIndex = addEmptyScalarResult(RimDefines::DYNAMIC_NATIVE, "SOIL");
m_cellScalarResults[resultGridIndex].resize(timeStepCount);
const std::vector< std::vector<double> >& sgas = cellScalarResults(scalarIndexSGAS);
const std::vector< std::vector<double> >& swat = cellScalarResults(scalarIndexSWAT);
@ -307,10 +304,6 @@ void RigReservoirCellResults::loadOrComputeSOIL()
soil[timeStepIdx][idx] = 1.0 - sgas[timeStepIdx][idx] - swat[timeStepIdx][idx];
}
}
QString resName = "SOIL";
ResultMapper mapper(RimDefines::DYNAMIC_NATIVE, resName, resultGridIndex);
m_resultMap.push_back(mapper);
}
}
}
@ -322,15 +315,21 @@ size_t RigReservoirCellResults::findOrLoadScalarResult(const QString& resultName
{
size_t scalarResultIndex = cvf::UNDEFINED_SIZE_T;
scalarResultIndex = this->loadResultIntoGrid(RimDefines::STATIC_NATIVE, resultName);
scalarResultIndex = this->findOrLoadScalarResult(RimDefines::STATIC_NATIVE, resultName);
if (scalarResultIndex == cvf::UNDEFINED_SIZE_T)
{
scalarResultIndex = this->loadResultIntoGrid(RimDefines::DYNAMIC_NATIVE, resultName);
scalarResultIndex = this->findOrLoadScalarResult(RimDefines::DYNAMIC_NATIVE, resultName);
}
if (scalarResultIndex == cvf::UNDEFINED_SIZE_T)
{
scalarResultIndex = this->findGridScalarIndex(RimDefines::GENERATED, resultName);
scalarResultIndex = this->findScalarResultIndex(RimDefines::GENERATED, resultName);
}
if (scalarResultIndex == cvf::UNDEFINED_SIZE_T)
{
scalarResultIndex = this->findScalarResultIndex(RimDefines::INPUT_PROPERTY, resultName);
}
return scalarResultIndex;
@ -344,13 +343,13 @@ size_t RigReservoirCellResults::addEmptyScalarResult(RimDefines::ResultCatType t
{
size_t scalarResultIndex = cvf::UNDEFINED_SIZE_T;
scalarResultIndex = this->findGridScalarIndex(type, resultName);
scalarResultIndex = this->findScalarResultIndex(type, resultName);
if (scalarResultIndex == cvf::UNDEFINED_SIZE_T)
{
scalarResultIndex = this->resultCount();
m_cellScalarResults.push_back(std::vector<std::vector<double> >());
ResultMapper mapper(type, resultName, scalarResultIndex);
m_resultMap.push_back(mapper);
ResultInfo resInfo(type, resultName, scalarResultIndex);
m_resultInfos.push_back(resInfo);
}
return scalarResultIndex;
@ -359,11 +358,11 @@ size_t RigReservoirCellResults::addEmptyScalarResult(RimDefines::ResultCatType t
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QStringList RigReservoirCellResults::resultNames(RimDefines::ResultCatType resType)
QStringList RigReservoirCellResults::resultNames(RimDefines::ResultCatType resType) const
{
QStringList varList;
std::list<ResultMapper>::const_iterator it;
for (it = m_resultMap.begin(); it != m_resultMap.end(); it++)
std::vector<ResultInfo>::const_iterator it;
for (it = m_resultInfos.begin(); it != m_resultInfos.end(); it++)
{
if (it->m_resultType == resType )
{
@ -391,3 +390,88 @@ void RigReservoirCellResults::recalculateMinMax(size_t scalarResultIndex)
m_maxMinValuesPrTs[scalarResultIndex].clear();
}
}
//--------------------------------------------------------------------------------------------------
/// Returns whether the result data in question is addressed by Active Cell Index
//--------------------------------------------------------------------------------------------------
bool RigReservoirCellResults::isUsingGlobalActiveIndex(size_t scalarResultIndex) const
{
CVF_TIGHT_ASSERT(scalarResultIndex < m_cellScalarResults.size());
if (!m_cellScalarResults[scalarResultIndex].size()) return true;
if (m_cellScalarResults[scalarResultIndex][0].size() == m_ownerMainGrid->numActiveCells()) return true;
if (m_cellScalarResults[scalarResultIndex][0].size() == m_ownerMainGrid->cellCount()) return false;
CVF_TIGHT_ASSERT(false); // Wrong number of results
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QList<QDateTime> RigReservoirCellResults::timeStepDates(size_t scalarResultIndex) const
{
if (scalarResultIndex < m_resultInfos.size() )
return m_resultInfos[scalarResultIndex].m_timeStepDates;
else
return QList<QDateTime>();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigReservoirCellResults::setTimeStepDates(size_t scalarResultIndex, const QList<QDateTime>& dates)
{
CVF_ASSERT(scalarResultIndex < m_resultInfos.size() );
m_resultInfos[scalarResultIndex].m_timeStepDates = dates;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
size_t RigReservoirCellResults::maxTimeStepCount() const
{
size_t maxTsCount = 0;
for (size_t i = 0; i < m_cellScalarResults.size(); ++i)
{
maxTsCount = m_cellScalarResults[i].size() > maxTsCount ? m_cellScalarResults[i].size() : maxTsCount;
}
return maxTsCount;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RigReservoirCellResults::makeResultNameUnique(const QString& resultNameProposal) const
{
QString newResultName = resultNameProposal;
size_t resultIndex = cvf::UNDEFINED_SIZE_T;
int nameNum = 1;
int stringLength = newResultName.size();
while (true)
{
resultIndex = this->findScalarResultIndex(newResultName);
if (resultIndex == cvf::UNDEFINED_SIZE_T) break;
newResultName.truncate(stringLength);
newResultName += "_" + QString::number(nameNum);
++nameNum;
}
return newResultName;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigReservoirCellResults::removeResult(const QString& resultName)
{
size_t resultIdx = findScalarResultIndex(resultName);
if (resultIdx == cvf::UNDEFINED_SIZE_T) return;
m_cellScalarResults[resultIdx].clear();
m_resultInfos[resultIdx].m_resultType = RimDefines::REMOVED;
}

View File

@ -19,24 +19,11 @@
#pragma once
#include "RimDefines.h"
#include <QDateTime>
#include <vector>
class ResultMapper
{
public:
ResultMapper(RimDefines::ResultCatType resultType, QString resultName, size_t gridScalarResultIndex)
: m_resultType(resultType),
m_resultName(resultName),
m_gridScalarResultIndex(gridScalarResultIndex)
{
}
public:
RimDefines::ResultCatType m_resultType;
QString m_resultName;
size_t m_gridScalarResultIndex;
};
class RifReaderInterface;
class RigMainGrid;
//==================================================================================================
/// Class containing the results for the complete number of active cells. Both main grid and LGR's
@ -44,36 +31,61 @@ public:
class RigReservoirCellResults : public cvf::Object
{
public:
RigReservoirCellResults();
RigReservoirCellResults(RigMainGrid* ownerGrid);
void setReaderInterface(RifReaderInterface* readerInterface);
void minMaxCellScalarValues(size_t scalarResultIndex, double& min, double& max);
void minMaxCellScalarValues(size_t scalarResultIndex, size_t timeStepIndex, double& min, double& max);
void setReaderInterface(RifReaderInterface* readerInterface);
size_t resultCount() const;
size_t timeStepCount(size_t scalarResultIndex) const; ///< This one must be modified to ask for a specific resultIndex
// Max and min values of the results
void recalculateMinMax(size_t scalarResultIndex);
void minMaxCellScalarValues(size_t scalarResultIndex, double& min, double& max);
void minMaxCellScalarValues(size_t scalarResultIndex, size_t timeStepIndex, double& min, double& max);
void loadOrComputeSOIL();
size_t loadResultIntoGrid(RimDefines::ResultCatType type, const QString& resultName);
size_t addEmptyScalarResult(RimDefines::ResultCatType type, const QString& resultName);
QStringList resultNames(RimDefines::ResultCatType type);
size_t findOrLoadScalarResult(const QString& resultName); ///< Simplified search. Assumes unique names across types.
size_t findGridScalarIndex(RimDefines::ResultCatType type, const QString& resultName) const;
// Access meta-information about the results
size_t resultCount() const;
size_t timeStepCount(size_t scalarResultIndex) const;
size_t maxTimeStepCount() const;
QStringList resultNames(RimDefines::ResultCatType type) const;
bool isUsingGlobalActiveIndex(size_t scalarResultIndex) const;
QList<QDateTime> timeStepDates(size_t scalarResultIndex) const;
void setTimeStepDates(size_t scalarResultIndex, const QList<QDateTime>& dates);
void recalculateMinMax(size_t scalarResultIndex);
// Find or create a slot for the results
size_t findOrLoadScalarResult(RimDefines::ResultCatType type, const QString& resultName);
size_t findOrLoadScalarResult(const QString& resultName); ///< Simplified search. Assumes unique names across types.
size_t findScalarResultIndex(RimDefines::ResultCatType type, const QString& resultName) const;
size_t findScalarResultIndex(const QString& resultName) const;
size_t addEmptyScalarResult(RimDefines::ResultCatType type, const QString& resultName);
QString makeResultNameUnique(const QString& resultNameProposal) const;
std::vector< std::vector<double> > & cellScalarResults(size_t scalarResultIndex);
const std::vector< std::vector<double> >& cellScalarResults(size_t scalarResultIndex) const;
void removeResult(const QString& resultName);
private:
void initialize(size_t resultCount, size_t timeStepCount);
void loadOrComputeSOIL();
// Access the results data
std::vector< std::vector<double> > & cellScalarResults(size_t scalarResultIndex);
const std::vector< std::vector<double> >& cellScalarResults(size_t scalarResultIndex) const;
private:
std::vector< std::vector< std::vector<double> > > m_cellScalarResults; ///< Scalar results for each timestep for each Result index (ResultVariable)
std::vector< std::pair<double, double> > m_maxMinValues; ///< Max min values for each Result index
std::vector< std::vector< std::pair<double, double> > > m_maxMinValuesPrTs; ///< Max min values for each timestep and Result index
std::list<ResultMapper> m_resultMap;
cvf::ref<RifReaderInterface> m_readerInterface;
class ResultInfo
{
public:
ResultInfo(RimDefines::ResultCatType resultType, QString resultName, size_t gridScalarResultIndex)
: m_resultType(resultType), m_resultName(resultName), m_gridScalarResultIndex(gridScalarResultIndex) { }
public:
RimDefines::ResultCatType m_resultType;
QString m_resultName;
size_t m_gridScalarResultIndex;
QList<QDateTime> m_timeStepDates;
};
std::vector<ResultInfo> m_resultInfos;
cvf::ref<RifReaderInterface> m_readerInterface;
RigMainGrid* m_ownerMainGrid;
};

View File

@ -105,25 +105,6 @@ size_t RigWellResults::firstResultTimeStep() const
return cvf::UNDEFINED_SIZE_T;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
class cellId
{
public:
cellId() :
gridIndex(cvf::UNDEFINED_SIZE_T),
cellIndex(cvf::UNDEFINED_SIZE_T)
{ }
cellId(size_t gidx, size_t cIdx) :
gridIndex(gidx),
cellIndex(cIdx)
{ }
size_t gridIndex;
size_t cellIndex;
};
//--------------------------------------------------------------------------------------------------
///
@ -132,7 +113,7 @@ void RigWellResults::computeStaticWellCellPath()
{
if (m_wellCellsTimeSteps.size() == 0) return;
std::map < size_t, std::list< cellId > > staticWellBranches;
std::map < size_t, std::list< RigWellResultCell > > staticWellBranches;
// Add ResultCell data from the first timestep to the final result.
@ -140,15 +121,12 @@ void RigWellResults::computeStaticWellCellPath()
{
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< cellId >& branch = staticWellBranches[branchNumber];
std::list< RigWellResultCell >& branch = staticWellBranches[branchNumber];
for(size_t cIdx = 0; cIdx < frameCells.size(); ++cIdx)
{
cellId cId;
cId.gridIndex = frameCells[cIdx].m_gridIndex;
cId.cellIndex = frameCells[cIdx].m_gridCellIndex;
branch.push_back(cId);
branch.push_back(frameCells[cIdx]);
}
}
@ -163,10 +141,10 @@ void RigWellResults::computeStaticWellCellPath()
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< cellId >& stBranch = staticWellBranches[branchNumber];
std::list< cellId >::iterator it;
std::list< cellId >::iterator sStartIt;
std::list< cellId >::iterator sEndIt;
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;
@ -179,17 +157,19 @@ void RigWellResults::computeStaticWellCellPath()
// First detect if we have cells on the start of the result frame, that is not in the static frame
{
sEndIt = stBranch.begin();
sGridIdx = sEndIt->gridIndex;
sCellIdx = sEndIt->cellIndex;
bool found = false;
for (rEndIdx = 0; !found && rEndIdx < resBranch.size(); ++rEndIdx)
if (stBranch.size())
{
rGridIdx = resBranch[rEndIdx].m_gridIndex;
rCellIdx = resBranch[rEndIdx].m_gridCellIndex;
sGridIdx = sEndIt->m_gridIndex;
sCellIdx = sEndIt->m_gridCellIndex;
if (sGridIdx == rGridIdx && sCellIdx == rCellIdx) { found = true; break; }
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)
@ -199,9 +179,7 @@ void RigWellResults::computeStaticWellCellPath()
// Found cells in start, merge them in
for (size_t cIdx = 0; cIdx < rEndIdx; ++cIdx)
{
rGridIdx = resBranch[cIdx].m_gridIndex;
rCellIdx = resBranch[cIdx].m_gridCellIndex;
stBranch.insert(sEndIt, cellId(rGridIdx, rCellIdx));
stBranch.insert(sEndIt, resBranch[cIdx]);
}
}
}
@ -222,10 +200,11 @@ void RigWellResults::computeStaticWellCellPath()
// 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
for ( ++sEndIt; sEndIt != stBranch.end() ; ++sEndIt)
if (sEndIt != stBranch.end()) ++sEndIt;
for ( ; sEndIt != stBranch.end() ; ++sEndIt)
{
sGridIdx = sEndIt->gridIndex;
sCellIdx = sEndIt->cellIndex;
sGridIdx = sEndIt->m_gridIndex;
sCellIdx = sEndIt->m_gridCellIndex;
bool found = false;
for (rEndIdx += 1; !found && rEndIdx < resBranch.size(); ++rEndIdx)
@ -243,9 +222,7 @@ void RigWellResults::computeStaticWellCellPath()
// 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)
{
rGridIdx = resBranch[cIdx].m_gridIndex;
rCellIdx = resBranch[cIdx].m_gridCellIndex;
stBranch.insert(sEndIt, cellId(rGridIdx, rCellIdx));
stBranch.insert(sEndIt, resBranch[cIdx]);
}
}
}
@ -262,35 +239,31 @@ void RigWellResults::computeStaticWellCellPath()
// 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)
{
rGridIdx = resBranch[cIdx].m_gridIndex;
rCellIdx = resBranch[cIdx].m_gridCellIndex;
stBranch.push_back(cellId(rGridIdx, rCellIdx));
stBranch.push_back(resBranch[cIdx]);
}
}
}
// Populate the static well info
std::map < size_t, std::list< cellId > >::iterator bIt;
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)
for (bIt = staticWellBranches.begin(); bIt != staticWellBranches.end(); ++bIt)
{
RigWellResultBranch rigBranch;
rigBranch.m_branchNumber = bIt->first;
std::list< cellId >& branch = bIt->second;
std::list< cellId >::iterator cIt;
std::list< RigWellResultCell >& branch = bIt->second;
std::list< RigWellResultCell >::iterator cIt;
for (cIt = branch.begin(); cIt != branch.end(); ++cIt)
{
RigWellResultCell rwc;
rwc.m_gridIndex = cIt->gridIndex;
rwc.m_gridCellIndex = cIt->cellIndex;
rigBranch.m_wellCells.push_back(rwc);
RigWellResultCell rwc = *cIt;
rwc.m_isOpen = false; // Reset the dynamic property
rigBranch.m_wellCells.push_back(*cIt);
}
m_staticWellCells.m_wellResultBranches.push_back(rigBranch);

View File

@ -26,14 +26,17 @@ struct RigWellResultCell
RigWellResultCell() :
m_gridIndex(cvf::UNDEFINED_SIZE_T),
m_gridCellIndex(cvf::UNDEFINED_SIZE_T),
m_isOpen(false),
m_isTemporarilyOut(false)
m_branchId(-1),
m_segmentId(-1),
m_isOpen(false)
{ }
size_t m_gridIndex;
size_t m_gridCellIndex; //< Index to cell which is included in the well
int m_branchId;
int m_segmentId;
bool m_isOpen; //< Marks the well as open or closed as of Eclipse simulation
bool m_isTemporarilyOut; //< Marks the cell as not member of the well at the current time step, (but it is a member at some other time step)
};
struct RigWellResultBranch
@ -57,6 +60,28 @@ public:
m_productionType(UNDEFINED_PRODUCTION_TYPE)
{ }
const RigWellResultCell* findResultCell(size_t gridIndex, size_t gridCellIndex) const
{
if (m_wellHead.m_gridCellIndex == gridCellIndex && m_wellHead.m_gridIndex == gridIndex )
{
return &m_wellHead;
}
for (size_t wb = 0; wb < m_wellResultBranches.size(); ++wb)
{
for (size_t wc = 0; wc < m_wellResultBranches[wb].m_wellCells.size(); ++wc)
{
if ( m_wellResultBranches[wb].m_wellCells[wc].m_gridCellIndex == gridCellIndex
&& m_wellResultBranches[wb].m_wellCells[wc].m_gridIndex == gridIndex )
{
return &(m_wellResultBranches[wb].m_wellCells[wc]);
}
}
}
return NULL;
}
WellProductionType m_productionType;
bool m_isOpen;
RigWellResultCell m_wellHead;

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

@ -22,7 +22,8 @@
<file>WellCollection.png</file>
<file>octave.png</file>
<file>Folder.png</file>
</qresource>
<file>EclipseInput48x48.png</file>
</qresource>
<qresource prefix="/Shader/">
<file>fs_CellFace.glsl</file>
<file>vs_CellFace.glsl</file>

View File

@ -31,12 +31,12 @@ varying vec3 v_ecPosition;
varying vec3 v_ecNormal;
// End native vz stuff
#define POS_I 0
#define NEG_I 1
#define POS_J 2
#define NEG_J 3
#define POS_K 4
#define NEG_K 5
#define POS_I 0.0
#define NEG_I 1.0
#define POS_J 2.0
#define NEG_J 3.0
#define POS_K 4.0
#define NEG_K 5.0
//
// 7---------6
@ -60,7 +60,7 @@ varying vec3 v_ecNormal;
vec4 getColorFromTextureCoord(float textureCoord, vec4 cellColor)
{
if (textureCoord < 0)
if (textureCoord < 0.0)
return cellColor;
else
return texture2D(u_edgeTexture2D, vec2(textureCoord, 0.5f ));
@ -73,7 +73,7 @@ void main()
{
v_localCoord = a_localCoord;
if ( a_colorCell < 0)
if ( a_colorCell < 0.0)
v_cellColor = vec4(0.75, 0.75, 0.75, 1); // Light grayish
else
v_cellColor = texture2D(u_cellTexture2D, vec2( a_colorCell, 0.5f));

View File

@ -30,6 +30,9 @@
#include "RigReservoir.h"
#include "RigReservoirCellResults.h"
#include <QDebug>
#include "RimInputProperty.h"
#include "RimInputReservoir.h"
#include "RimUiTreeModelPdm.h"
//--------------------------------------------------------------------------------------------------
///
@ -118,6 +121,7 @@ void RiaSocketServer::handleClientConnection(QTcpSocket* clientToHandle)
m_currentTimeStepToRead = 0;
m_currentReservoir = NULL;
m_currentScalarIndex = cvf::UNDEFINED_SIZE_T;
m_currentPropertyName = "";
connect(m_currentClient, SIGNAL(disconnected()), this, SLOT(slotCurrentClientDisconnected()));
@ -211,8 +215,9 @@ void RiaSocketServer::slotReadCommand()
bool isGetProperty = args[0] == "GetProperty"; // GetProperty [casename/index] PropertyName
bool isSetProperty = args[0] == "SetProperty"; // SetProperty [casename/index] PropertyName
bool isGetCellInfo = args[0] == "GetActiveCellInfo"; // GetActiveCellInfo [casename/index]
bool isGetGridDim = args[0] == "GetMainGridDimensions"; // GetMainGridDimensions [casename/index]
if (!(isGetProperty || isSetProperty || isGetCellInfo))
if (!(isGetProperty || isSetProperty || isGetCellInfo || isGetGridDim))
{
m_errorMessageDialog->showMessage(tr("ResInsight SocketServer: \n") + tr("Unknown command: %1").arg(args[0].data()));
return;
@ -236,7 +241,7 @@ void RiaSocketServer::slotReadCommand()
propertyName = args[2];
}
}
else if (isGetCellInfo)
else if (isGetCellInfo || isGetGridDim)
{
if (args.size() > 1)
{
@ -272,6 +277,7 @@ void RiaSocketServer::slotReadCommand()
{
scalarResultFrames = &(reservoir->reservoirData()->mainGrid()->results()->cellScalarResults(scalarResultIndex));
m_currentScalarIndex = scalarResultIndex;
m_currentPropertyName = propertyName;
}
}
@ -374,6 +380,23 @@ void RiaSocketServer::slotReadCommand()
#endif
}
}
else if (isGetGridDim)
{
// Write data back to octave: I, J, K dimensions
size_t iCount = 0;
size_t jCount = 0;
size_t kCount = 0;
if (reservoir && reservoir->reservoirData() && reservoir->reservoirData()->mainGrid())
{
iCount = reservoir->reservoirData()->mainGrid()->cellCountI();
jCount = reservoir->reservoirData()->mainGrid()->cellCountJ();
kCount = reservoir->reservoirData()->mainGrid()->cellCountK();
}
socketStream << (quint64)iCount << (quint64)jCount << (quint64)kCount;
}
}
//--------------------------------------------------------------------------------------------------
@ -402,20 +425,23 @@ void RiaSocketServer::slotReadPropertyData()
// Check if a complete timestep is available, return and whait for readyRead() if not
if (m_currentClient->bytesAvailable() < (int)m_bytesPerTimeStepToRead) return;
size_t activeCellCount = m_bytesPerTimeStepToRead / sizeof(double);
size_t cellCountFromOctave = m_bytesPerTimeStepToRead / sizeof(double);
size_t gridActiveCellCount = m_currentReservoir->reservoirData()->mainGrid()->numActiveCells();
if (gridActiveCellCount != activeCellCount)
size_t gridTotalCellCount = m_currentReservoir->reservoirData()->mainGrid()->cellCount();
if (cellCountFromOctave != gridActiveCellCount && cellCountFromOctave != gridTotalCellCount)
{
m_errorMessageDialog->showMessage(tr("ResInsight SocketServer: \n") + tr("The number of active cells in the data coming from octave does not match the case") + ":\"" + m_currentReservoir->caseName() + "\"\n"
" Octave: " + QString::number(activeCellCount) + "\n"
" " + m_currentReservoir->caseName() + ": " + QString::number(gridActiveCellCount));
m_errorMessageDialog->showMessage(tr("ResInsight SocketServer: \n") +
tr("The number of cells in the data coming from octave does not match the case") + ":\"" + m_currentReservoir->caseName() + "\"\n"
" Octave: " + QString::number(cellCountFromOctave) + "\n"
" " + m_currentReservoir->caseName() + ": Active cell count: " + QString::number(gridActiveCellCount) + " Total cell count: " + QString::number(gridTotalCellCount)) ;
activeCellCount = 0;
m_invalidActiveCellCountDetected = true;
m_currentClient->abort();
cellCountFromOctave = 0;
m_invalidActiveCellCountDetected = true;
m_currentClient->abort();
return;
return;
}
// Make sure the size of the retreiving container is correct.
@ -423,7 +449,7 @@ void RiaSocketServer::slotReadPropertyData()
m_scalarResultsToAdd->resize(m_timeStepCountToRead);
for (size_t tIdx = 0; tIdx < m_timeStepCountToRead; ++tIdx)
{
m_scalarResultsToAdd->at(tIdx).resize(activeCellCount, HUGE_VAL);
m_scalarResultsToAdd->at(tIdx).resize(cellCountFromOctave, HUGE_VAL);
}
// Read available complete timestepdata
@ -435,7 +461,7 @@ void RiaSocketServer::slotReadPropertyData()
#if 1 // Use raw data transfer. Faster.
bytesRead = m_currentClient->read((char*)(internalMatrixData), m_bytesPerTimeStepToRead);
#else
for (size_t cIdx = 0; cIdx < activeCellCount; ++cIdx)
for (size_t cIdx = 0; cIdx < cellCountFromOctave; ++cIdx)
{
socketStream >> internalMatrixData[cIdx];
@ -456,6 +482,25 @@ void RiaSocketServer::slotReadPropertyData()
{
if (m_currentReservoir != NULL)
{
// Create a new input property if we have an input reservoir
RimInputReservoir* inputRes = dynamic_cast<RimInputReservoir*>(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 = RIMainWindow::instance()->uiPdmModel();
treeModel->rebuildUiSubTree(inputRes->m_inputPropertyCollection());
}
inputProperty->resolvedState = RimInputProperty::RESOLVED_NOT_SAVED;
}
if( m_currentScalarIndex != cvf::UNDEFINED_SIZE_T &&
m_currentReservoir->reservoirData() &&
m_currentReservoir->reservoirData()->mainGrid() &&
@ -501,6 +546,7 @@ void RiaSocketServer::slotCurrentClientDisconnected()
m_currentTimeStepToRead = 0;
m_currentReservoir = NULL;
m_currentScalarIndex = cvf::UNDEFINED_SIZE_T;
m_currentPropertyName = "";
m_invalidActiveCellCountDetected = false;
QTcpSocket *newClient = m_tcpServer->nextPendingConnection();

View File

@ -62,6 +62,7 @@ private:
std::vector< std::vector<double> >* m_scalarResultsToAdd;
RimReservoir* m_currentReservoir;
size_t m_currentScalarIndex;
QString m_currentPropertyName;
bool m_invalidActiveCellCountDetected;
};

View File

@ -27,21 +27,19 @@
#include "RIPreferences.h"
#include "RIPreferencesDialog.h"
#include "RifReaderInterface.h"
#include "RigReservoir.h"
#include "RigReservoirCellResults.h"
#include "RimReservoir.h"
#include "RimUiTreeModelPdm.h"
#include "cvfqtBasicAboutDialog.h"
#include "cafUtils.h"
#include "cafUiPropertyCreatorPdm.h"
#include "cafFrameAnimationControl.h"
#include "cafAnimationToolBar.h"
#include "qttreepropertybrowser.h"
#include "qtbuttonpropertybrowser.h"
#include "qtgroupboxpropertybrowser.h"
#include "cafPdmUiPropertyView.h"
#include "RimUiTreeView.h"
@ -61,7 +59,6 @@ RIMainWindow* RIMainWindow::sm_mainWindowInstance = NULL;
//--------------------------------------------------------------------------------------------------
RIMainWindow::RIMainWindow()
: m_treeView(NULL),
m_uiManagerPdm(NULL),
m_pdmRoot(NULL),
m_mainViewer(NULL),
m_windowMenu(NULL)
@ -133,6 +130,11 @@ void RIMainWindow::cleanupGuiBeforeProjectClose()
{
setPdmRoot(NULL);
setResultInfo("");
if (m_pdmUiPropertyView)
{
m_pdmUiPropertyView->showProperties(NULL);
}
m_processMonitor->startMonitorWorkProcess(NULL);
}
@ -179,12 +181,14 @@ void RIMainWindow::createActions()
{
// File actions
m_openAction = new QAction(QIcon(":/AppLogo48x48.png"), "&Open Eclipse Case", this);
m_openInputEclipseFileAction= new QAction(QIcon(":/EclipseInput48x48.png"), "&Open Input Eclipse Case", this);
m_openProjectAction = new QAction(style()->standardIcon(QStyle::SP_DirOpenIcon), "&Open Project", this);
m_openLastUsedProjectAction = new QAction("Open &Last Used Project", this);
m_mockModelAction = new QAction("&Mock Model", this);
m_mockResultsModelAction = new QAction("Mock Model With &Results", this);
m_mockLargeResultsModelAction = new QAction("Large Mock Model", this);
m_mockInputModelAction = new QAction("Input Mock Model", this);
m_saveProjectAction = new QAction(QIcon(":/Save.png"), "&Save Project", this);
m_saveProjectAsAction = new QAction(QIcon(":/Save.png"), "Save Project &As", this);
@ -192,13 +196,15 @@ void RIMainWindow::createActions()
m_closeAction = new QAction("&Close", this);
m_exitAction = new QAction("E&xit", this);
connect(m_openAction, SIGNAL(triggered()), SLOT(slotOpenFile()));
connect(m_openAction, SIGNAL(triggered()), SLOT(slotOpenBinaryGridFiles()));
connect(m_openInputEclipseFileAction,SIGNAL(triggered()), SLOT(slotOpenInputFiles()));
connect(m_openProjectAction, SIGNAL(triggered()), SLOT(slotOpenProject()));
connect(m_openLastUsedProjectAction,SIGNAL(triggered()), SLOT(slotOpenLastUsedProject()));
connect(m_mockModelAction, SIGNAL(triggered()), SLOT(slotMockModel()));
connect(m_mockResultsModelAction, SIGNAL(triggered()), SLOT(slotMockResultsModel()));
connect(m_mockLargeResultsModelAction, SIGNAL(triggered()), SLOT(slotMockLargeResultsModel()));
connect(m_mockInputModelAction, SIGNAL(triggered()), SLOT(slotInputMockModel()));
connect(m_saveProjectAction, SIGNAL(triggered()), SLOT(slotSaveProject()));
connect(m_saveProjectAsAction, SIGNAL(triggered()), SLOT(slotSaveProjectAs()));
@ -245,6 +251,8 @@ void RIMainWindow::createActions()
m_performanceHud->setCheckable(true);
connect(m_performanceHud, SIGNAL(triggered(bool)), SLOT(slotShowPerformanceInfo(bool)));
m_newPropertyView = new QAction("New Property View", this);
connect(m_newPropertyView, SIGNAL(triggered()), SLOT(slotNewObjectPropertyView()));
// Help actions
m_aboutAction = new QAction("&About", this);
@ -260,6 +268,7 @@ void RIMainWindow::createMenus()
// File menu
QMenu* fileMenu = menuBar()->addMenu("&File");
fileMenu->addAction(m_openAction);
fileMenu->addAction(m_openInputEclipseFileAction);
fileMenu->addAction(m_openProjectAction);
fileMenu->addAction(m_openLastUsedProjectAction);
@ -298,9 +307,11 @@ void RIMainWindow::createMenus()
debugMenu->addAction(m_mockModelAction);
debugMenu->addAction(m_mockResultsModelAction);
debugMenu->addAction(m_mockLargeResultsModelAction);
debugMenu->addAction(m_mockInputModelAction);
debugMenu->addSeparator();
debugMenu->addAction(m_debugUseShaders);
debugMenu->addAction(m_performanceHud);
debugMenu->addAction(m_newPropertyView);
connect(debugMenu, SIGNAL(aboutToShow()), SLOT(slotRefreshDebugActions()));
@ -323,6 +334,7 @@ void RIMainWindow::createToolBars()
m_standardToolBar->setObjectName(m_standardToolBar->windowTitle());
m_standardToolBar->addAction(m_openAction);
m_standardToolBar->addAction(m_openInputEclipseFileAction);
m_standardToolBar->addAction(m_openProjectAction);
//m_standardToolBar->addAction(m_openLastUsedProjectAction);
m_standardToolBar->addAction(m_saveProjectAction);
@ -352,42 +364,19 @@ void RIMainWindow::createToolBars()
void RIMainWindow::createDockPanels()
{
m_uiManagerPdm = new RimUiPropertyCreatorPdm(this);
{
QDockWidget* dockWidget = new QDockWidget("Project", this);
dockWidget->setObjectName("dockWidget");
dockWidget->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
m_treeView = new RimTreeView(dockWidget);
m_treeView = new RimUiTreeView(dockWidget);
m_treeView->setModel(m_treeModelPdm);
dockWidget->setWidget(m_treeView);
addDockWidget(Qt::LeftDockWidgetArea, dockWidget);
}
{
QDockWidget* dockWidget = new QDockWidget("Properties", this);
dockWidget->setObjectName("dockWidget");
dockWidget->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
#if 0
QtButtonPropertyBrowser* treePropertyBrowser = new QtButtonPropertyBrowser(dockWidget);
#elif 1
QtGroupBoxPropertyBrowser * treePropertyBrowser = new QtGroupBoxPropertyBrowser (dockWidget);
#else
QtTreePropertyBrowser* treePropertyBrowser = new QtTreePropertyBrowser(dockWidget);
treePropertyBrowser->setPropertiesWithoutValueMarked(true);
treePropertyBrowser->setRootIsDecorated(true);
treePropertyBrowser->setResizeMode(QtTreePropertyBrowser::ResizeToContents);
#endif
m_uiManagerPdm->setPropertyBrowser(treePropertyBrowser);
dockWidget->setWidget(treePropertyBrowser);
addDockWidget(Qt::LeftDockWidgetArea, dockWidget);
}
{
QDockWidget* dockPanel = new QDockWidget("Result Info", this);
dockPanel->setObjectName("dockResultInfoPanel");
@ -408,6 +397,19 @@ void RIMainWindow::createDockPanels()
addDockWidget(Qt::BottomDockWidgetArea, dockPanel);
}
{
QDockWidget* dockWidget = new QDockWidget("Properties", this);
dockWidget->setObjectName("dockWidget");
dockWidget->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
m_pdmUiPropertyView = new caf::PdmUiPropertyView(dockWidget);
dockWidget->setWidget(m_pdmUiPropertyView);
connect(m_treeView, SIGNAL(selectedObjectChanged( caf::PdmObject* )), m_pdmUiPropertyView, SLOT(showProperties( caf::PdmObject* )));
addDockWidget(Qt::LeftDockWidgetArea, dockWidget);
}
setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea);
setCorner(Qt::BottomRightCorner, Qt::BottomDockWidgetArea);
}
@ -534,13 +536,18 @@ void RIMainWindow::refreshAnimationActions()
{
enableAnimControls = true;
if (app->activeReservoirView()->eclipseCase() && app->activeReservoirView()->eclipseCase()->fileInterface())
if (app->activeReservoirView()->gridCellResults())
{
if (app->activeReservoirView()->cellResult()->hasDynamicResult()
|| app->activeReservoirView()->propertyFilterCollection()->hasActiveDynamicFilters()
|| app->activeReservoirView()->wellCollection()->hasVisibleWellPipes())
{
timeStepStrings = app->activeReservoirView()->eclipseCase()->fileInterface()->timeStepText();
QList<QDateTime> timeStepDates = app->activeReservoirView()->gridCellResults()->timeStepDates(0);
int i;
for (i = 0; i < timeStepDates.size(); i++)
{
timeStepStrings += timeStepDates[i].toString("dd.MMM yyyy");
}
currentTimeStepIndex = RIApplication::instance()->activeReservoirView()->currentTimeStep();
}
else
@ -594,24 +601,49 @@ void RIMainWindow::slotAbout()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RIMainWindow::slotOpenFile()
void RIMainWindow::slotOpenBinaryGridFiles()
{
if (checkForDocumentModifications())
{
#ifdef USE_ECL_LIB
QString fileName = QFileDialog::getOpenFileName(this, "Open Eclipse File", NULL, "Eclipse Grid Files (*.GRID *.EGRID)");
QStringList fileNames = QFileDialog::getOpenFileNames(this, "Open Eclipse File", NULL, "Eclipse Grid Files (*.GRID *.EGRID)");
#else
QString fileName = "dummy";
QStringList fileNames;
fileNames << "dummy";
#endif
if (fileName.isEmpty()) return;
RIApplication* app = RIApplication::instance();
app->openEclipseCaseFromFile(fileName);
}
//m_mainViewer->setDefaultView();
int i;
for (i = 0; i < fileNames.size(); i++)
{
QString fileName = fileNames[i];
if (!fileNames.isEmpty())
{
app->openEclipseCaseFromFile(fileName);
}
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RIMainWindow::slotOpenInputFiles()
{
if (checkForDocumentModifications())
{
QStringList fileNames = QFileDialog::getOpenFileNames(this, "Open Eclipse Input Files", NULL, "Eclipse Input Files and Input Properties (*.GRDECL *)");
if (fileNames.isEmpty()) return;
RIApplication* app = RIApplication::instance();
app->openInputEclipseCase("Eclipse Input Files", fileNames);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -671,6 +703,16 @@ void RIMainWindow::slotMockLargeResultsModel()
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RIMainWindow::slotInputMockModel()
{
RIApplication* app = RIApplication::instance();
app->createInputMockModel();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -805,21 +847,11 @@ void RIMainWindow::setPdmRoot(caf::PdmObject* pdmRoot)
caf::PdmUiTreeItem* treeItemRoot = caf::UiTreeItemBuilderPdm::buildViewItems(NULL, -1, m_pdmRoot);
m_treeModelPdm->setRoot(treeItemRoot);
m_treeView->setModel(m_treeModelPdm);
m_treeView->expandAll();
if (treeItemRoot)
if (treeItemRoot && m_treeView->selectionModel())
{
m_uiManagerPdm->setModel(m_treeModelPdm, m_treeView->selectionModel());
if (m_treeView->selectionModel())
{
connect(m_treeView->selectionModel(), SIGNAL(currentChanged ( const QModelIndex & , const QModelIndex & )), SLOT(slotCurrentChanged( const QModelIndex & , const QModelIndex & )));
}
}
else
{
m_uiManagerPdm->setModel(NULL, NULL);
connect(m_treeView->selectionModel(), SIGNAL(currentChanged ( const QModelIndex & , const QModelIndex & )), SLOT(slotCurrentChanged( const QModelIndex & , const QModelIndex & )));
}
}
@ -1014,7 +1046,7 @@ void RIMainWindow::slotRefreshDebugActions()
void RIMainWindow::slotEditPreferences()
{
RIApplication* app = RIApplication::instance();
RIPreferencesDialog preferencesDialog(this, app->preferences());
RIPreferencesDialog preferencesDialog(this, app->preferences(), "Preferences");
if (preferencesDialog.exec() == QDialog::Accepted)
{
// Write preferences using QSettings and apply them to the application
@ -1116,3 +1148,43 @@ void RIMainWindow::slotCurrentChanged(const QModelIndex & current, const QModelI
tmp = tmp.parent();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RIMainWindow::slotNewObjectPropertyView()
{
if (!m_treeModelPdm) return;
RimUiTreeView* treeView = NULL;
{
QDockWidget* dockWidget = new QDockWidget("Project", this);
dockWidget->setObjectName("dockWidget");
dockWidget->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
treeView = new RimUiTreeView(dockWidget);
dockWidget->setWidget(treeView);
addDockWidget(Qt::RightDockWidgetArea, dockWidget);
}
treeView->setModel(m_treeModelPdm);
treeView->expandAll();
{
QDockWidget* dockWidget = new QDockWidget("Properties", this);
dockWidget->setObjectName("dockWidget");
dockWidget->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
caf::PdmUiPropertyView* propView = new caf::PdmUiPropertyView(dockWidget);
dockWidget->setWidget(propView);
addDockWidget(Qt::RightDockWidgetArea, dockWidget);
connect(treeView, SIGNAL(selectedObjectChanged( caf::PdmObject* )), propView, SLOT(showProperties( caf::PdmObject* )));
}
}

View File

@ -30,6 +30,7 @@ class QMdiSubWindow;
class QComboBox;
class QLabel;
class QLineEdit;
class QItemSelection;
class RIViewer;
class RIResultInfoPanel;
@ -43,6 +44,7 @@ namespace caf
class PdmObject;
class FrameAnimationControl;
class AnimationToolBar;
class PdmUiPropertyView;
}
//==================================================================================================
@ -101,11 +103,13 @@ private:
private:
// File actions
QAction* m_openAction;
QAction* m_openInputEclipseFileAction;
QAction* m_openProjectAction;
QAction* m_openLastUsedProjectAction;
QAction* m_mockModelAction;
QAction* m_mockResultsModelAction;
QAction* m_mockLargeResultsModelAction;
QAction* m_mockInputModelAction;
QAction* m_saveProjectAction;
QAction* m_saveProjectAsAction;
QAction* m_closeAction;
@ -126,6 +130,7 @@ private:
// Debug actions
QAction* m_debugUseShaders;
QAction* m_performanceHud;
QAction* m_newPropertyView;
// Help actions
QAction* m_aboutAction;
@ -151,13 +156,15 @@ private:
private slots:
// File slots
void slotOpenFile();
void slotOpenBinaryGridFiles();
void slotOpenInputFiles();
void slotOpenProject();
void slotOpenLastUsedProject();
void slotMockModel();
void slotMockResultsModel();
void slotMockLargeResultsModel();
void slotInputMockModel();
void slotSaveProject();
void slotSaveProjectAs();
@ -183,6 +190,7 @@ private slots:
void slotRefreshDebugActions();
void slotUseShaders(bool enable);
void slotShowPerformanceInfo(bool enable);
void slotNewObjectPropertyView();
// Windows slots
void slotBuildWindowActions();
@ -202,10 +210,8 @@ public:
void setPdmRoot(caf::PdmObject* pdmRoot);
private:
QTreeView* m_treeView;
caf::UiPropertyCreatorPdm* m_uiManagerPdm;
RimUiTreeModelPdm* m_treeModelPdm;
caf::PdmObject* m_pdmRoot;
QTreeView* m_treeView;
RimUiTreeModelPdm* m_treeModelPdm;
caf::PdmObject* m_pdmRoot;
caf::PdmUiPropertyView* m_pdmUiPropertyView;
};

View File

@ -23,19 +23,20 @@
#include "cafPdmObject.h"
#include "RimUiTreeModelPdm.h"
#include "qtgroupboxpropertybrowser.h"
#include "cafPdmUiPropertyView.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RIPreferencesDialog::RIPreferencesDialog(QWidget* parent, caf::PdmObject* object)
RIPreferencesDialog::RIPreferencesDialog(QWidget* parent, caf::PdmObject* object, const QString& windowTitle)
: QDialog(parent)
{
CVF_ASSERT(object);
m_pdmObject = object;
m_windowTitle = windowTitle;
setupUi();
}
@ -45,18 +46,15 @@ RIPreferencesDialog::RIPreferencesDialog(QWidget* parent, caf::PdmObject* object
//--------------------------------------------------------------------------------------------------
void RIPreferencesDialog::setupUi()
{
setWindowTitle("Preferences");
setWindowTitle(m_windowTitle);
m_uiManagerPdm = new RimUiPropertyCreatorPdm(this);
m_pdmUiPropertyView = new caf::PdmUiPropertyView(this);
QVBoxLayout* dialogLayout = new QVBoxLayout;
setLayout(dialogLayout);
QtGroupBoxPropertyBrowser* groupPropertyBrowser = new QtGroupBoxPropertyBrowser();
m_uiManagerPdm->setPropertyBrowser(groupPropertyBrowser);
m_uiManagerPdm->createAndShowPropertiesForObject(m_pdmObject);
dialogLayout->addWidget(groupPropertyBrowser);
dialogLayout->addWidget(m_pdmUiPropertyView);
m_pdmUiPropertyView->showProperties(m_pdmObject);
// Buttons
QDialogButtonBox* buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);

View File

@ -23,7 +23,7 @@
namespace caf
{
class PdmObject;
class UiPropertyCreatorPdm;
class PdmUiPropertyView;
}
@ -37,12 +37,13 @@ class RIPreferencesDialog : public QDialog
Q_OBJECT
public:
RIPreferencesDialog(QWidget* parent, caf::PdmObject* object);
RIPreferencesDialog(QWidget* parent, caf::PdmObject* object, const QString& windowTitle);
private:
void setupUi();
private:
QString m_windowTitle;
caf::PdmObject* m_pdmObject;
caf::UiPropertyCreatorPdm* m_uiManagerPdm;
caf::PdmUiPropertyView* m_pdmUiPropertyView;
};

View File

@ -78,12 +78,11 @@ RIViewer::~RIViewer()
//--------------------------------------------------------------------------------------------------
void RIViewer::setColorLegend1(cvf::OverlayColorLegend* legend)
{
if (m_legend1.notNull() && legend == NULL)
{
m_mainRendering->removeOverlayItem(m_legend1.p());
}
m_mainRendering->removeOverlayItem(m_legend1.p());
m_legend1 = legend;
this->updateLegends();
}
@ -92,14 +91,34 @@ void RIViewer::setColorLegend1(cvf::OverlayColorLegend* legend)
//--------------------------------------------------------------------------------------------------
void RIViewer::setColorLegend2(cvf::OverlayColorLegend* legend)
{
if (m_legend2.notNull() && legend == NULL)
{
m_mainRendering->removeOverlayItem(m_legend2.p());
}
m_mainRendering->removeOverlayItem(m_legend2.p());
m_legend2 = legend;
this->updateLegends();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RIViewer::updateLegends()
{
cvf::Rendering* firstRendering = m_renderingSequence->firstRendering();
CVF_ASSERT(firstRendering);
firstRendering->removeOverlayItem(m_legend1.p());
firstRendering->removeOverlayItem(m_legend2.p());
if (m_legend1.notNull())
{
firstRendering->addOverlayItem(m_legend1.p(), cvf::OverlayItem::BOTTOM_LEFT, cvf::OverlayItem::VERTICAL);
}
if (m_legend2.notNull())
{
firstRendering->addOverlayItem(m_legend2.p(), cvf::OverlayItem::BOTTOM_LEFT, cvf::OverlayItem::VERTICAL);
}
}
//--------------------------------------------------------------------------------------------------
///
@ -133,8 +152,7 @@ void RIViewer::setDefaultView()
}
}
m_mainCamera->fitView(bb, cvf::Vec3d::Y_AXIS, cvf::Vec3d::Z_AXIS);
// m_trackball->setRotationPoint(bb.center());
m_mainCamera->fitView(bb, -cvf::Vec3d::Z_AXIS, cvf::Vec3d::Y_AXIS);
}
@ -247,21 +265,10 @@ void RIViewer::slotSetCurrentFrame(int frameIndex)
cvf::Rendering* firstRendering = m_renderingSequence->firstRendering();
CVF_ASSERT(firstRendering);
firstRendering->removeOverlayItem(m_legend1.p());
firstRendering->removeOverlayItem(m_legend2.p());
if (m_legend1.notNull())
{
firstRendering->addOverlayItem(m_legend1.p(), cvf::OverlayItem::BOTTOM_LEFT, cvf::OverlayItem::VERTICAL);
}
if (m_legend2.notNull())
{
firstRendering->addOverlayItem(m_legend2.p(), cvf::OverlayItem::BOTTOM_LEFT, cvf::OverlayItem::VERTICAL);
}
if (m_reservoirView) m_reservoirView->setCurrentTimeStep(frameIndex);
this->updateLegends();
caf::Viewer::slotSetCurrentFrame(frameIndex);
}

View File

@ -58,13 +58,14 @@ public slots:
virtual void slotEndAnimation();
protected:
void keyPressEvent(QKeyEvent* event);
void mouseReleaseEvent(QMouseEvent* event);
void keyPressEvent(QKeyEvent* event);
void mouseReleaseEvent(QMouseEvent* event);
void handlePickAction(int winPosX, int winPosY);
cvf::Part* pickPointAndFace(int winPosX, int winPosY, uint* faceHit, cvf::Vec3d* localIntersectionPoint);
void handlePickAction(int winPosX, int winPosY);
cvf::Part* pickPointAndFace(int winPosX, int winPosY, uint* faceHit, cvf::Vec3d* localIntersectionPoint);
private:
void updateLegends();
caf::QtMouseState m_mouseState;
cvf::ref<cvf::OverlayColorLegend> m_legend1;

View File

@ -24,7 +24,7 @@ IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp")
# set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -g1")
ELSE()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /openmp")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /openmp -DUSE_ECL_LIB")
ENDIF()
@ -33,8 +33,8 @@ ENDIF()
################################################################################
set(CMAKE_MAJOR_VERSION 0)
set(CMAKE_MINOR_VERSION 4)
set(CMAKE_PATCH_VERSION 8)
set(CMAKE_MINOR_VERSION 8)
set(CMAKE_PATCH_VERSION 0)
set(PRODUCTVER ${CMAKE_MAJOR_VERSION},${CMAKE_MINOR_VERSION},0,${CMAKE_PATCH_VERSION})
set(STRPRODUCTVER ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION})
@ -74,17 +74,11 @@ include_directories(
################################################################################
add_subdirectory(cafProjectDataModel)
add_subdirectory(cafPdmCvf)
add_subdirectory(CommonCode)
add_subdirectory(QtPropertyBrowser)
add_subdirectory(cafAnimControl)
add_subdirectory(cafViewer)
include_directories(
${QtPropertyBrowser_SOURCE_DIR}
)
add_subdirectory(cafUserInterface)
add_subdirectory(cafPdmCvf)
include_directories(
${cafUserInterface_SOURCE_DIR}
@ -109,6 +103,7 @@ set (CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/Install/)
################################################################################
add_subdirectory(ApplicationCode)
add_subdirectory(OctavePlugin)
#
################################################################################
# Unit tests
@ -117,8 +112,8 @@ add_subdirectory(ApplicationCode/ReservoirDataModel/ReservoirDataModel_UnitTests
add_subdirectory(ApplicationCode/FileInterface/FileInterface_UnitTests)
add_subdirectory(ApplicationCode/ModelVisualization/ModelVisualization_UnitTests)
#add_subdirectory(cafTests/cafProjectDataModel_UnitTests)
#add_subdirectory(cafTests/cafTestApplication)

View File

@ -4,6 +4,7 @@ set(CPP_SOURCES
riGetActiveCellProperty.cpp
riSetActiveCellProperty.cpp
riGetActiveCellInfo.cpp
riGetMainGridDimensions.cpp
)
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
@ -48,7 +49,12 @@ else()
#add_custom_target(oct-files ALL DEPENDS "${OCTAVE_BINARY_OCT_FILES}")
add_custom_target(octave_plugins ALL DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/riGetActiveCellProperty.oct" "${CMAKE_CURRENT_BINARY_DIR}/riSetActiveCellProperty.oct" "${CMAKE_CURRENT_BINARY_DIR}/riGetActiveCellInfo.oct")
add_custom_target(octave_plugins ALL DEPENDS
"${CMAKE_CURRENT_BINARY_DIR}/riGetActiveCellProperty.oct"
"${CMAKE_CURRENT_BINARY_DIR}/riSetActiveCellProperty.oct"
"${CMAKE_CURRENT_BINARY_DIR}/riGetActiveCellInfo.oct"
"${CMAKE_CURRENT_BINARY_DIR}/riGetMainGridDimensions.oct"
)
endif()
install(FILES ${OCTAVE_BINARY_OCT_FILES} DESTINATION ${RESINSIGHT_FINAL_NAME})

View File

@ -0,0 +1,12 @@
addpath("/home/builder/Projects/ResInsightBuildDir/OctavePlugin");
PORO = riGetActiveCellProperty("PORO");
PERMX = riGetActiveCellProperty("PERMX");
IJK = riGetMainGridDimensions();
GENERATED = PORO .* PERMX;
GENERATED(10:IJK(1):IJK(1)*IJK(2)*IJK(3)) = 100;
GENERATED(10*IJK(1):1:11*IJK(1)) = 100;
GENERATED(11*IJK(1):1:12*IJK(1)) = 100;
GENERATED(12*IJK(1):1:13*IJK(1)) = 100;
riSetActiveCellProperty(GENERATED, "PORO*PERMX");

View File

@ -0,0 +1,114 @@
#include <QtNetwork>
#include <octave/oct.h>
void getMainGridDimensions(int32NDArray& gridDimensions, const QString &hostName, quint16 port, QString caseName)
{
QString serverName = hostName;
quint16 serverPort = port;
const int Timeout = 5 * 1000;
QTcpSocket socket;
socket.connectToHost(serverName, serverPort);
if (!socket.waitForConnected(Timeout))
{
error((("Connection: ") + socket.errorString()).toLatin1().data());
return;
}
// Create command and send it:
QString command("GetMainGridDimensions ");
command += caseName;
QByteArray cmdBytes = command.toLatin1();
QDataStream socketStream(&socket);
socketStream.setVersion(QDataStream::Qt_4_0);
socketStream << (qint64)(cmdBytes.size());
socket.write(cmdBytes);
// Get response. First wait for the header
while (socket.bytesAvailable() < (int)(3*sizeof(quint64)))
{
if (!socket.waitForReadyRead(Timeout))
{
error((("Wating for header: ") + socket.errorString()).toLatin1().data());
return;
}
}
// Read timestep count and blocksize
quint64 iCount;
quint64 jCount;
quint64 kCount;
socketStream >> iCount;
socketStream >> jCount;
socketStream >> kCount;
dim_vector dv (1);
dv(0) = 3;
gridDimensions.resize(dv);
gridDimensions(0) = iCount;
gridDimensions(1) = jCount;
gridDimensions(2) = kCount;
QString tmp = QString("riGetMainGridDimensions : Read main grid dimensions");
if (caseName.isEmpty())
{
tmp += QString(" from active case.");
}
else
{
tmp += QString(" from %1.").arg(caseName);
}
octave_stdout << tmp.toStdString() << " Dimensions: " << iCount << ", " << jCount << ", " << kCount << std::endl;
return;
}
DEFUN_DLD (riGetMainGridDimensions, args, nargout,
"Usage:\n"
"\n"
" riGetMainGridDimensions( [CaseName/CaseIndex])\n"
"\n"
"Returns a vector of size 3: [ICount, JCount, KCount] \n"
"Containing the dimentions of the main grid in the requested case.\n"
"If the Eclipse Case is not defined, the active View in ResInsight is used."
)
{
int nargin = args.length ();
if (nargin > 1)
{
error("riGetActiveCellInfo: Too many arguments. Only the name or index of the case is valid input.\n");
print_usage();
}
else if (nargout < 1)
{
error("riGetActiveCellInfo: Missing output argument.\n");
print_usage();
}
else
{
int32NDArray propertyFrames;
if (nargin > 0)
getMainGridDimensions(propertyFrames, "127.0.0.1", 40001, args(0).char_matrix_value().row_as_string(0).c_str());
else
getMainGridDimensions(propertyFrames, "127.0.0.1", 40001, "");
return octave_value(propertyFrames);
}
return octave_value_list ();
}

Binary file not shown.

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