Merge pull request #290 from OPM/dev-geomech

Geomechanics into ResInsight dev
This commit is contained in:
Jacob Støren committed 2015-05-18 15:45:16 +02:00
commit a7991ac151
142 files changed
+7076 -1628

No files matched your search

+82 -25
View File
@@ -83,6 +83,10 @@
#include "cvfProgramOptions.h"
#include "cvfqtUtils.h"
#include "RimCommandObject.h"
#include "RimGeoMechCase.h"
#include "RimGeoMechModels.h"
#include "RimGeoMechView.h"
#include "RimGeoMechResultSlot.h"
namespace caf
@@ -366,17 +370,17 @@ bool RiaApplication::loadProject(const QString& projectFileName, ProjectLoadActi
for (size_t cIdx = 0; cIdx < casesToLoad.size(); ++cIdx)
{
RimCase* ri = casesToLoad[cIdx];
CVF_ASSERT(ri);
RimCase* cas = casesToLoad[cIdx];
CVF_ASSERT(cas);
caseProgress.setProgressDescription(ri->caseUserDescription());
caf::ProgressInfo viewProgress(ri->reservoirViews().size() , "Creating Views");
caseProgress.setProgressDescription(cas->caseUserDescription());
std::vector<RimView*> views = cas->views();
caf::ProgressInfo viewProgress(views.size() , "Creating Views");
size_t j;
for (j = 0; j < ri->reservoirViews().size(); j++)
for (j = 0; j < views.size(); j++)
{
RimReservoirView* riv = ri->reservoirViews[j];
RimView* riv = views[j];
CVF_ASSERT(riv);
viewProgress.setProgressDescription(riv->name());
@@ -702,6 +706,50 @@ bool RiaApplication::openInputEclipseCaseFromFileNames(const QStringList& fileNa
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiaApplication::openOdbCaseFromFile(const QString& fileName)
{
if (!QFile::exists(fileName)) return false;
QFileInfo gridFileName(fileName);
QString caseName = gridFileName.completeBaseName();
RimGeoMechCase* geoMechCase = new RimGeoMechCase();
geoMechCase->setFileName(fileName);
geoMechCase->caseUserDescription = caseName;
RimGeoMechModels* geoMechModelCollection = m_project->activeOilField() ? m_project->activeOilField()->geoMechModels() : NULL;
// Create the geoMech model container if it is not there already
if (geoMechModelCollection == NULL)
{
geoMechModelCollection = new RimGeoMechModels();
m_project->activeOilField()->geoMechModels = geoMechModelCollection;
}
geoMechModelCollection->cases.push_back(geoMechCase);
RimGeoMechView* riv = geoMechCase->createAndAddReservoirView();
riv->loadDataAndUpdate();
//if (!riv->cellResult()->hasResult())
//{
// riv->cellResult()->setResultVariable(RimDefines::undefinedResultName());
//}
RimUiTreeModelPdm* uiModel = RiuMainWindow::instance()->uiPdmModel();
uiModel->updateUiSubTree(m_project);
RiuMainWindow::instance()->setCurrentObjectInTreeView(riv->cellResult());
return true;
}
//--------------------------------------------------------------------------------------------------
///
@@ -748,7 +796,7 @@ void RiaApplication::createInputMockModel()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const RimReservoirView* RiaApplication::activeReservoirView() const
const RimView* RiaApplication::activeReservoirView() const
{
return m_activeReservoirView;
}
@@ -756,7 +804,7 @@ const RimReservoirView* RiaApplication::activeReservoirView() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimReservoirView* RiaApplication::activeReservoirView()
RimView* RiaApplication::activeReservoirView()
{
return m_activeReservoirView;
}
@@ -764,7 +812,7 @@ RimReservoirView* RiaApplication::activeReservoirView()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaApplication::setActiveReservoirView(RimReservoirView* rv)
void RiaApplication::setActiveReservoirView(RimView* rv)
{
m_activeReservoirView = rv;
}
@@ -1483,12 +1531,14 @@ void RiaApplication::saveSnapshotForAllViews(const QString& snapshotFolderName)
for (size_t i = 0; i < projectCases.size(); i++)
{
RimCase* ri = projectCases[i];
if (!ri) continue;
RimCase* cas = projectCases[i];
if (!cas) continue;
for (size_t j = 0; j < ri->reservoirViews().size(); j++)
std::vector<RimView*> views = cas->views();
for (size_t j = 0; j < views.size(); j++)
{
RimReservoirView* riv = ri->reservoirViews()[j];
RimView* riv = views[j];
if (riv && riv->viewer())
{
@@ -1500,7 +1550,7 @@ void RiaApplication::saveSnapshotForAllViews(const QString& snapshotFolderName)
// Process all events to avoid a black image when grabbing frame buffer
QCoreApplication::processEvents();
QString fileName = ri->caseUserDescription() + "-" + riv->name();
QString fileName = cas->caseUserDescription() + "-" + riv->name();
fileName.replace(" ", "_");
QString absoluteFileName = caf::Utils::constructFullFileName(absSnapshotPath, fileName, ".png");
@@ -1921,7 +1971,7 @@ QString RiaApplication::commandLineParameterHelp() const
/// Schedule a creation of the Display model and redraw of the reservoir view
/// The redraw will happen as soon as the event loop is entered
//--------------------------------------------------------------------------------------------------
void RiaApplication::scheduleDisplayModelUpdateAndRedraw(RimReservoirView* resViewToUpdate)
void RiaApplication::scheduleDisplayModelUpdateAndRedraw(RimView* resViewToUpdate)
{
m_resViewsToUpdate.push_back(resViewToUpdate);
@@ -1944,13 +1994,13 @@ void RiaApplication::scheduleDisplayModelUpdateAndRedraw(RimReservoirView* resVi
void RiaApplication::slotUpdateScheduledDisplayModels()
{
// Compress to remove duplicates
std::set<RimReservoirView*> resViewsToUpdate;
std::set<RimView*> resViewsToUpdate;
for (size_t i = 0; i < m_resViewsToUpdate.size(); ++i)
{
resViewsToUpdate.insert(m_resViewsToUpdate[i]);
}
for (std::set<RimReservoirView*>::iterator it = resViewsToUpdate.begin(); it != resViewsToUpdate.end(); ++it )
for (std::set<RimView*>::iterator it = resViewsToUpdate.begin(); it != resViewsToUpdate.end(); ++it )
{
if (*it)
{
@@ -2059,14 +2109,17 @@ void RiaApplication::regressionTestConfigureProject()
std::vector<RimCase*> projectCases;
m_project->allCases(projectCases);
for (size_t i = 0; i < projectCases.size(); i++)
{
RimCase* ri = projectCases[i];
if (!ri) continue;
RimCase* cas = projectCases[i];
if (!cas) continue;
for (size_t j = 0; j < ri->reservoirViews().size(); j++)
std::vector<RimView*> views = cas->views();
for (size_t j = 0; j < views.size(); j++)
{
RimReservoirView* riv = ri->reservoirViews()[j];
RimView* riv = views[j];
if (riv && riv->viewer())
{
@@ -2074,9 +2127,13 @@ void RiaApplication::regressionTestConfigureProject()
riv->viewer()->setFixedSize(1000, 745);
}
riv->faultCollection->setShowFaultsOutsideFilters(false);
riv->faultResultSettings->showCustomFaultResult.setValueFromUi(false);
RimReservoirView* resvView = dynamic_cast<RimReservoirView*>(riv);
if (resvView)
{
resvView->faultCollection->setShowFaultsOutsideFilters(false);
resvView->faultResultSettings->showCustomFaultResult.setValueFromUi(false);
}
}
}
}
+10 -7
View File
@@ -33,11 +33,12 @@
class RIProcess;
class RigCaseData;
class RimCase;
class RimEclipseCase;
class Drawable;
class RiaSocketServer;
class RiaPreferences;
class RimReservoirView;
class RimView;
class RimProject;
class RimCommandObject;
class RiaProjectModifier;
@@ -72,11 +73,11 @@ public:
void executeRegressionTests(const QString& regressionTestPath);
void setActiveReservoirView(RimReservoirView*);
RimReservoirView* activeReservoirView();
const RimReservoirView* activeReservoirView() const;
void setActiveReservoirView(RimView*);
RimView* activeReservoirView();
const RimView* activeReservoirView() const;
void scheduleDisplayModelUpdateAndRedraw(RimReservoirView* resViewToUpdate);
void scheduleDisplayModelUpdateAndRedraw(RimView* resViewToUpdate);
RimProject* project();
@@ -94,6 +95,8 @@ public:
bool addEclipseCases(const QStringList& fileNames);
bool openInputEclipseCaseFromFileNames(const QStringList& fileNames);
bool openOdbCaseFromFile(const QString& fileName);
QString currentProjectFileName() const;
QString createAbsolutePathFromProjectRelativePath(QString projectRelativePath);
bool loadProject(const QString& projectFileName);
@@ -169,10 +172,10 @@ private slots:
void slotUpdateScheduledDisplayModels();
private:
caf::PdmPointer<RimReservoirView> m_activeReservoirView;
caf::PdmPointer<RimView> m_activeReservoirView;
caf::PdmPointer<RimProject> m_project;
std::vector<caf::PdmPointer<RimReservoirView> > m_resViewsToUpdate;
std::vector<caf::PdmPointer<RimView> > m_resViewsToUpdate;
QTimer* m_resViewUpdateTimer;
RiaSocketServer* m_socketServer;
@@ -191,30 +191,24 @@ bool RiaProjectModifier::replaceSourceCases(RimProject* project)
bool RiaProjectModifier::replaceCase(RimProject* project)
{
bool didReplacement = false;
std::vector<RimCase*> allCases;
project->allCases(allCases);
for (size_t oilFieldIdx = 0; oilFieldIdx < project->oilFields().size(); oilFieldIdx++)
for (size_t caseIdx = 0; caseIdx < allCases.size(); ++caseIdx)
{
RimOilField* oilField = project->oilFields[oilFieldIdx];
RimAnalysisModels* analysisModels = oilField ? oilField->analysisModels() : NULL;
if (analysisModels)
RimResultCase* resultCase = dynamic_cast<RimResultCase*>(allCases[caseIdx]);
if (resultCase)
{
for (size_t caseIdx = 0; caseIdx < analysisModels->cases.size(); ++caseIdx)
if (m_replaceCase_caseId == FIRST_OCCURENCE ||
m_replaceCase_caseId == resultCase->caseId())
{
RimResultCase* resultCase = dynamic_cast<RimResultCase*>(analysisModels->cases[caseIdx]);
if (resultCase)
{
if (m_replaceCase_caseId == FIRST_OCCURENCE ||
m_replaceCase_caseId == resultCase->caseId())
{
resultCase->setGridFileName(m_replaceCase_gridFileName);
resultCase->caseUserDescription = caseNameFromGridFileName(m_replaceCase_gridFileName);
didReplacement = true;
resultCase->setGridFileName(m_replaceCase_gridFileName);
resultCase->caseUserDescription = caseNameFromGridFileName(m_replaceCase_gridFileName);
didReplacement = true;
if (m_replaceCase_caseId == FIRST_OCCURENCE)
{
return true;
}
}
if (m_replaceCase_caseId == FIRST_OCCURENCE)
{
return true;
}
}
}
+128 -54
View File
@@ -18,12 +18,20 @@ include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/ModelVisualization
${CMAKE_CURRENT_SOURCE_DIR}/UserInterface
${CMAKE_CURRENT_SOURCE_DIR}/ProjectDataModel
${CMAKE_CURRENT_SOURCE_DIR}/ResultStatisticsCache
${CMAKE_CURRENT_SOURCE_DIR}/ReservoirDataModel
${CMAKE_CURRENT_SOURCE_DIR}/WellPathImportSsihub
${CMAKE_CURRENT_SOURCE_DIR}/GeoMech/OdbReader
${CMAKE_CURRENT_SOURCE_DIR}/GeoMech/GeoMechDataModel
${CMAKE_CURRENT_SOURCE_DIR}/GeoMech/GeoMechVisualization
${CMAKE_BINARY_DIR}/Generated
${CMAKE_CURRENT_BINARY_DIR}
)
#############################################################################
# Defining all the source (and header) files
#############################################################################
# Use all h files in the subdirectories to make them available in the project
file( GLOB_RECURSE HEADER_FILES *.h )
@@ -76,6 +84,7 @@ list( APPEND REFERENCED_CMAKE_FILES
FileInterface/CMakeLists_files.cmake
ProjectDataModel/CMakeLists_files.cmake
ModelVisualization/CMakeLists_files.cmake
GeoMech/GeoMechVisualization/CMakeLists_files.cmake
)
# Include source file lists from *.cmake files
@@ -87,10 +96,29 @@ list( APPEND CPP_SOURCES
${CODE_SOURCE_FILES}
)
#############################################################################
# Sub-directory projects
#############################################################################
add_subdirectory(WellPathImportSsihub)
add_subdirectory(ResultStatisticsCache)
#
# Odb api
#
set(RESINSIGHT_ODB_API_DIR "" CACHE PATH "Path to the ODB api from Simulia")
if(NOT ${RESINSIGHT_ODB_API_DIR} EQUAL "")
add_definitions(-DUSE_ODB_API)
add_subdirectory(GeoMech/OdbReader)
SET(RESINSIGHT_USE_ODB_API 1)
endif()
add_subdirectory(GeoMech/GeoMechDataModel)
#############################################################################
# Qt specifics: Moc, ui, resources
#############################################################################
# Define files for MOC-ing
set ( QT_MOC_HEADERS
Application/RiaApplication.h
@@ -139,55 +167,55 @@ endif()
# creating PCH's for MSVC and GCC on Linux
#############################################################################
set( RAW_SOURCES ${CPP_SOURCES} )
list( REMOVE_ITEM RAW_SOURCES
RiaStdInclude.cpp
${CODE_SOURCE_FILES}
ModelVisualization/RivCellEdgeEffectGenerator.cpp
ModelVisualization/RivPipeGeometryGenerator.cpp
ModelVisualization/RivWellPipesPartMgr.cpp
ModelVisualization/RivWellHeadPartMgr.cpp
Application/RiaImageFileCompare.cpp
Application/RiaImageCompareReporter.cpp
Application/RiaRegressionTest.cpp
SocketInterface/RiaSocketDataTransfer.cpp
FileInterface/RifEclipseInputFileTools.cpp
FileInterface/RifEclipseOutputFileTools.cpp
FileInterface/RifEclipseRestartFilesetAccess.cpp
FileInterface/RifEclipseRestartDataAccess.cpp
FileInterface/RifEclipseUnifiedRestartFileAccess.cpp
FileInterface/RifReaderEclipseInput.cpp
FileInterface/RifReaderEclipseOutput.cpp
UserInterface/RiuSimpleHistogramWidget.cpp
UserInterface/RiuMultiCaseImportDialog.cpp
UserInterface/RiuResultTextBuilder.cpp
)
include( CustomPCH.cmake )
set( ALL_INCLUDES
${LibCore_SOURCE_DIR}
${LibGeometry_SOURCE_DIR}
${LibGuiQt_SOURCE_DIR}
${LibRender_SOURCE_DIR}
${LibViewing_SOURCE_DIR}
${QT_INCLUDES}
)
set( PCH_NAME RiaStdInclude )
set( GCC_PCH_TARGET gccPCH )
set( PCH_COMPILER_DEFINE EMPTY )
IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set( PCH_COMPILER_DEFINE CVF_LINUX)
ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
precompiled_header( RAW_SOURCES ALL_INCLUDES ${GCC_PCH_TARGET} ${PCH_NAME} ${PCH_COMPILER_DEFINE} )
#set( RAW_SOURCES ${CPP_SOURCES} )
#
#list( REMOVE_ITEM RAW_SOURCES
# RiaStdInclude.cpp
#
# ${CODE_SOURCE_FILES}
#
# ModelVisualization/RivCellEdgeEffectGenerator.cpp
# ModelVisualization/RivPipeGeometryGenerator.cpp
# ModelVisualization/RivWellPipesPartMgr.cpp
# ModelVisualization/RivWellHeadPartMgr.cpp
#
# Application/RiaImageFileCompare.cpp
# Application/RiaImageCompareReporter.cpp
# Application/RiaRegressionTest.cpp
#
# SocketInterface/RiaSocketDataTransfer.cpp
#
# FileInterface/RifEclipseInputFileTools.cpp
# FileInterface/RifEclipseOutputFileTools.cpp
# FileInterface/RifEclipseRestartFilesetAccess.cpp
# FileInterface/RifEclipseRestartDataAccess.cpp
# FileInterface/RifEclipseUnifiedRestartFileAccess.cpp
# FileInterface/RifReaderEclipseInput.cpp
# FileInterface/RifReaderEclipseOutput.cpp
#
# UserInterface/RiuSimpleHistogramWidget.cpp
# UserInterface/RiuMultiCaseImportDialog.cpp
# UserInterface/RiuResultTextBuilder.cpp
#)
#
#include( CustomPCH.cmake )
#set( ALL_INCLUDES
# ${LibCore_SOURCE_DIR}
# ${LibGeometry_SOURCE_DIR}
# ${LibGuiQt_SOURCE_DIR}
# ${LibRender_SOURCE_DIR}
# ${LibViewing_SOURCE_DIR}
# ${QT_INCLUDES}
#)
#
#set( PCH_NAME RiaStdInclude )
#set( GCC_PCH_TARGET gccPCH )
#set( PCH_COMPILER_DEFINE EMPTY )
#IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
# set( PCH_COMPILER_DEFINE CVF_LINUX)
#ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
#
#precompiled_header( RAW_SOURCES ALL_INCLUDES ${GCC_PCH_TARGET} ${PCH_NAME} ${PCH_COMPILER_DEFINE} )
################################################################################
@@ -199,6 +227,10 @@ source_group( "UserInterface" FILES ${USER_INTERFACE_FILES} )
source_group( "SocketInterface" FILES ${SOCKET_INTERFACE_FILES} )
#############################################################################
# Set up the main executable with its source files
#############################################################################
# Default behaviour for a Qt application is a console application, resulting in a console window always being launced at startup
# The following statement is used to control this behaviour
# set_target_properties( MY_TARGET PROPERTIES LINK_FLAGS_DEBUG "/SUBSYSTEM:WINDOWS")
@@ -220,13 +252,17 @@ set( EXE_FILES
${QRC_FILES_CPP}
${WIN_RESOURCE}
${HEADER_FILES}
${REFERENCED_CMAKE_FILES}
${REFERENCED_CMAKE_FILES}
../ResInsightVersion.cmake
)
add_executable( ResInsight ${EXE_FILES} )
#############################################################################
# Application icon for MacOS X bundle
#############################################################################
if (APPLE)
add_custom_command (OUTPUT Resources/ResInsight.icns
COMMAND sips -s format icns ${CMAKE_CURRENT_SOURCE_DIR}/Resources/AppLogo48x48.png --out ${CMAKE_CURRENT_BINARY_DIR}/Resources/ResInsight.icns
@@ -239,6 +275,10 @@ if (APPLE)
MACOSX_BUNDLE_ICON_FILE ${CMAKE_CURRENT_BINARY_DIR}/Resources/ResInsight.icns)
endif ()
#############################################################################
# Set up libraries and dependent projects to link with
#############################################################################
set( LINK_LIBRARIES
WellPathImportSsihub
@@ -254,6 +294,9 @@ set( LINK_LIBRARIES
LibGeometry
LibCore
ResultStatisticsCache
RigGeoMechDataModel
ecl
ert_util
ert_geometry
@@ -272,18 +315,49 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
)
endif()
# Add the odb reader if we are compiling with odb support
IF (${RESINSIGHT_USE_ODB_API})
set ( LINK_LIBRARIES ${LINK_LIBRARIES} RifOdbReader)
ENDIF()
target_link_libraries( ResInsight ${LINK_LIBRARIES} ${EXTERNAL_LINK_LIBRARIES})
# Copy Dlls
if (MSVC)
#############################################################################
# Copy Dlls on MSVC
#############################################################################
# Copy Odb Dlls
if ((MSVC) AND (${RESINSIGHT_USE_ODB_API}))
# Find all the dlls
file (GLOB RI_ALL_ODB_DLLS ${RESINSIGHT_ODB_API_DIR}/lib/*.dll)
# Strip off the path
foreach (aDLL ${RI_ALL_ODB_DLLS})
get_filename_component(filenameWithExt ${aDLL} NAME)
list(APPEND RI_ODB_DLLS ${filenameWithExt} )
endforeach(aDLL)
# Copy to target directory
foreach (aDLL ${RI_ODB_DLLS})
add_custom_command(TARGET ResInsight POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"${RESINSIGHT_ODB_API_DIR}/lib/${aDLL}"
"${CMAKE_CURRENT_BINARY_DIR}/$<CONFIGURATION>")
endforeach()
endif()
# Qt DLLs
if (MSVC)
set (QTLIBLIST QtCore QtCored QtGui QtGuid QtOpenGl QtOpenGld QtNetwork QtNetworkd QtScript QtScriptd QtScriptTools QtScriptToolsd)
foreach (qtlib ${QTLIBLIST})
add_custom_command(TARGET ResInsight POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"${QT_BINARY_DIR}/${qtlib}4.dll"
${CMAKE_CURRENT_BINARY_DIR}/$<CONFIGURATION>)
"${CMAKE_CURRENT_BINARY_DIR}/$<CONFIGURATION>")
endforeach( qtlib )
endif(MSVC)
@@ -40,4 +40,4 @@ list(APPEND CODE_SOURCE_FILES
${SOURCE_GROUP_SOURCE_FILES}
)
source_group( "FileInterface" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} )
source_group( "FileInterface" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CEE_CURRENT_LIST_DIR}CMakeLists_files.cmake )
@@ -10,7 +10,8 @@ include (${QT_USE_FILE})
include_directories(
${ResInsight_SOURCE_DIR}/ApplicationCode
${ResInsight_SOURCE_DIR}/ApplicationCode/ReservoirDataModel
${ResInsight_SOURCE_DIR}/ApplicationCode/ResultStatisticsCache
${ResInsight_SOURCE_DIR}/ApplicationCode/ReservoirDataModel
${ResInsight_SOURCE_DIR}/ApplicationCode/FileInterface
${ResInsight_SOURCE_DIR}/ApplicationCode/ProjectDataModel
${ResInsight_SOURCE_DIR}/ThirdParty
@@ -63,6 +64,8 @@ set( LINK_LIBRARIES
cafProjectDataModel
CommonCode
ResultStatisticsCache
LibViewing
LibRender
LibGeometry
@@ -0,0 +1,29 @@
cmake_minimum_required (VERSION 2.8)
project (RigGeoMechDataModel)
include_directories(
${LibCore_SOURCE_DIR}
../../ResultStatisticsCache
../OdbReader
)
add_library( ${PROJECT_NAME}
RigFemPart.h
RigFemPart.cpp
RigFemTypes.h
RigFemTypes.cpp
RigGeoMechCaseData.cpp
RigGeoMechCaseData.h
RigFemPartCollection.cpp
RigFemPartCollection.h
RigFemPartResults.h
RigFemPartResults.cpp
RigFemScalarResultFrames.h
RigFemScalarResultFrames.cpp
RigFemNativeStatCalc.h
RigFemNativeStatCalc.cpp
)
target_link_libraries( ${PROJECT_NAME} LibCore ResultStatisticsCache)
@@ -0,0 +1,92 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions 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 "RigFemNativeStatCalc.h"
#include "RigFemScalarResultFrames.h"
#include <math.h>
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigFemNativeStatCalc::RigFemNativeStatCalc(RigFemScalarResultFrames* cellResultsData)
{
m_resultsData = cellResultsData;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigFemNativeStatCalc::minMaxCellScalarValues(size_t timeStepIndex, double& min, double& max)
{
std::vector<float>& values = m_resultsData->frameData(timeStepIndex);
size_t i;
for (i = 0; i < values.size(); i++)
{
if (values[i] == HUGE_VAL) // TODO
{
continue;
}
if (values[i] < min)
{
min = values[i];
}
if (values[i] > max)
{
max = values[i];
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigFemNativeStatCalc::posNegClosestToZero(size_t timeStepIndex, double& pos, double& neg)
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigFemNativeStatCalc::valueSumAndSampleCount(double& valueSum, size_t& sampleCount)
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigFemNativeStatCalc::addDataToHistogramCalculator(RigHistogramCalculator& histogramCalculator)
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
size_t RigFemNativeStatCalc::timeStepCount()
{
return m_resultsData->frameCount();
}
@@ -0,0 +1,46 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions 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 "RigStatisticsCalculator.h"
class RigFemScalarResultFrames;
class RigFemNativeStatCalc : public RigStatisticsCalculator
{
public:
RigFemNativeStatCalc(RigFemScalarResultFrames* cellResultsData);
virtual void minMaxCellScalarValues(size_t timeStepIndex, double& min, double& max);
virtual void posNegClosestToZero(size_t timeStepIndex, double& pos, double& neg);
virtual void valueSumAndSampleCount(double& valueSum, size_t& sampleCount);
virtual void addDataToHistogramCalculator(RigHistogramCalculator& histogramCalculator);
virtual size_t timeStepCount();
private:
RigFemScalarResultFrames* m_resultsData;
};
@@ -0,0 +1,66 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions 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 "RigFemPart.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigFemPart::RigFemPart()
:m_elementPartId(-1)
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigFemPart::~RigFemPart()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigFemPart::preAllocateElementStorage(int elementCount)
{
m_elementId.reserve(elementCount);
m_elementTypes.reserve(elementCount);
m_elementConnectivityStartIndices.reserve(elementCount);
m_allAlementConnectivities.reserve(elementCount*8);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigFemPart::appendElement(RigElementType elmType, int id, const int* connectivities)
{
m_elementId.push_back(id);
m_elementTypes.push_back(elmType);
m_elementConnectivityStartIndices.push_back(m_allAlementConnectivities.size());
int nodeCount = RigFemTypes::elmentNodeCount(elmType);
for (int lnIdx = 0; lnIdx < nodeCount; ++lnIdx)
{
m_allAlementConnectivities.push_back(connectivities[lnIdx]);
}
}
@@ -0,0 +1,69 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions 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 <stdlib.h>
#include "RigFemTypes.h"
#include "cvfObject.h"
#include "cvfAssert.h"
#include "cvfVector3.h"
#include <vector>
class RigFemPartNodes
{
public:
std::vector<int> nodeIds;
std::vector<cvf::Vec3f> coordinates;
};
class RigFemPart : public cvf::Object
{
public:
RigFemPart();
virtual ~RigFemPart();
int elementPartId() const { return m_elementPartId; }
void setElementPartId(int partId) { m_elementPartId = partId; }
void preAllocateElementStorage(int elementCount);
void appendElement(RigElementType elmType, int elementId, const int* connectivities);
size_t elementCount() const { return m_elementId.size(); }
int elmId(size_t elementIdx) const { return m_elementId[elementIdx]; }
RigElementType elementType(size_t elementIdx) const { return m_elementTypes[elementIdx]; }
const int* connectivities(size_t elementIdx) const { return &m_allAlementConnectivities[m_elementConnectivityStartIndices[elementIdx]];}
size_t elementNodeResultIdx(int elementIdx, int elmLocalNodeIdx) const { return m_elementConnectivityStartIndices[elementIdx] + elmLocalNodeIdx;}
RigFemPartNodes& nodes() {return m_nodes;}
const RigFemPartNodes& nodes() const {return m_nodes;}
private:
int m_elementPartId;
std::vector<int> m_elementId;
std::vector<RigElementType> m_elementTypes;
std::vector<size_t> m_elementConnectivityStartIndices;
std::vector<int> m_allAlementConnectivities;
RigFemPartNodes m_nodes;
};
@@ -0,0 +1,73 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions 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 "RigFemPartCollection.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigFemPartCollection::RigFemPartCollection()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigFemPartCollection::~RigFemPartCollection()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigFemPartCollection::addFemPart(RigFemPart* part)
{
m_femParts.push_back(part);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigFemPart* RigFemPartCollection::part(size_t index)
{
return m_femParts[index].p();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const RigFemPart* RigFemPartCollection::part(size_t index) const
{
return m_femParts[index].p();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RigFemPartCollection::partCount() const
{
return static_cast<int>(m_femParts.size());
}
@@ -0,0 +1,44 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions 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 "RigFemPart.h"
#include "cvfCollection.h"
class RigFemPartCollection: public cvf::Object
{
public:
RigFemPartCollection();
~RigFemPartCollection();
void addFemPart(RigFemPart* part);
RigFemPart* part(size_t index);
const RigFemPart* part(size_t index) const ;
int partCount() const;
private:
cvf::Collection<RigFemPart> m_femParts;
};
@@ -0,0 +1,72 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions 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 <stdlib.h>
#include "RigFemPartResults.h"
#include "RigFemResultAddress.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigFemPartResults::RigFemPartResults()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigFemPartResults::~RigFemPartResults()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigFemPartResults::initResultStages(const std::vector<std::string>& stageNames)
{
m_femAnalysisStages.clear();
m_femAnalysisStages.resize(stageNames.size());
for (size_t sIdx = 0; sIdx < stageNames.size(); ++sIdx)
{
m_femAnalysisStages[sIdx].stageName = stageNames[sIdx];
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigFemScalarResultFrames* RigFemPartResults::createScalarResult(size_t stageIndex,
const RigFemResultAddress& resVarAddr,
const std::vector<double>& frameTimes)
{
RigFemScalarResultFrames * resFrames = new RigFemScalarResultFrames(frameTimes);
m_femAnalysisStages[stageIndex].resultSets[resVarAddr] = resFrames;
return resFrames;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigFemScalarResultFrames* RigFemPartResults::findScalarResult(size_t stageIndex,
const RigFemResultAddress& resVarAddr)
{
return m_femAnalysisStages[stageIndex].resultSets[resVarAddr].p();
}
@@ -0,0 +1,60 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions 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 "cvfObject.h"
#include "RigFemResultPosEnum.h"
#include <string>
#include <vector>
#include <map>
#include "RigFemScalarResultFrames.h"
#include "RigFemResultAddress.h"
//==================================================================================================
///
//==================================================================================================
class RigFemPartResults : public cvf::Object
{
public:
RigFemPartResults();
~RigFemPartResults();
void initResultStages( const std::vector<std::string>& stageNames);
RigFemScalarResultFrames* createScalarResult( size_t stageIndex,
const RigFemResultAddress& resVarAddr,
const std::vector<double>& frameTimes);
RigFemScalarResultFrames* findScalarResult( size_t stageIndex,
const RigFemResultAddress& resVarAddr);
private:
struct RigAnalysisStage
{
std::string stageName;
std::map<RigFemResultAddress, cvf::ref<RigFemScalarResultFrames> > resultSets;
};
std::vector<RigAnalysisStage> m_femAnalysisStages;
};
@@ -0,0 +1,58 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions 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 "RigFemResultPosEnum.h"
#include <string>
//==================================================================================================
///
//==================================================================================================
class RigFemResultAddress
{
public:
RigFemResultAddress(RigFemResultPosEnum resPosType,
const std::string& aFieldName,
const std::string& aComponentName)
: resultPosType(resPosType), fieldName(aFieldName), componentName(aComponentName)
{}
RigFemResultPosEnum resultPosType;
std::string fieldName;
std::string componentName;
bool operator< (const RigFemResultAddress& other ) const
{
if (resultPosType != other.resultPosType)
{
return (resultPosType < other.resultPosType);
}
if (fieldName != other.fieldName)
{
return (fieldName < other.fieldName);
}
return (componentName < other.componentName);
}
};
@@ -0,0 +1,7 @@
#pragma once
enum RigFemResultPosEnum {
RIG_NODAL,
RIG_ELEMENT_NODAL,
RIG_INTEGRATION_POINT
};
@@ -0,0 +1,72 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions 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 <stdlib.h>
#include "RigFemScalarResultFrames.h"
#include "RigFemNativeStatCalc.h"
#include "RigStatisticsDataCache.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigFemScalarResultFrames::RigFemScalarResultFrames(const std::vector<double>& frameTimes)
: m_frameTimes(frameTimes)
{
m_dataForEachFrame.resize(m_frameTimes.size());
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigFemScalarResultFrames::~RigFemScalarResultFrames()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
size_t RigFemScalarResultFrames::frameCount()
{
return m_frameTimes.size();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigStatisticsDataCache* RigFemScalarResultFrames::statistics()
{
if (m_statistics.isNull())
{
RigFemNativeStatCalc* calculator = new RigFemNativeStatCalc(this);
m_statistics = new RigStatisticsDataCache(calculator);
}
return m_statistics.p();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<float>& RigFemScalarResultFrames::frameData(size_t frameIndex)
{
return m_dataForEachFrame[frameIndex];
}
@@ -0,0 +1,47 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions 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 "cvfObject.h"
#include <vector>
//==================================================================================================
///
//==================================================================================================
class RigStatisticsDataCache;
class RigFemScalarResultFrames: public cvf::Object
{
public:
RigFemScalarResultFrames(const std::vector<double>& frameTimes);
virtual ~RigFemScalarResultFrames();
std::vector<float>& frameData(size_t frameIndex);
size_t frameCount();
RigStatisticsDataCache* statistics();
private:
std::vector< std::vector<float> > m_dataForEachFrame;
std::vector<double> m_frameTimes;
cvf::ref<RigStatisticsDataCache> m_statistics;
};
@@ -0,0 +1,79 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions 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 "RigFemTypes.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const int RigFemTypes::elmentNodeCount(RigElementType elmType)
{
static int elementTypeCounts[2] ={ 8, 4 };
return elementTypeCounts[elmType];
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const int RigFemTypes::elmentFaceCount(RigElementType elmType)
{
const static int elementFaceCounts[2] ={ 6, 1 };
return elementFaceCounts[elmType];
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
// HEX8
// 7---------6
// /| /| |k
// / | / | | /j
// 4---------5 | |/
// | 3------|--2 *---i
// | / | /
// |/ |/
// 0---------1
const int* RigFemTypes::localElmNodeIndicesForFace(RigElementType elmType, int faceIdx, int* faceNodeCount)
{
static const int HEX8_Faces[6][4] ={ { 1, 2, 6, 5 }, { 0, 4, 7, 3 }, { 3, 7, 6, 2 }, { 0, 1, 5, 4 }, { 4, 5, 6, 7 }, { 0, 3, 2, 1 } };
static const int CAX4_Faces[4] ={ 0, 1, 2, 3 };
switch (elmType)
{
case HEX8:
(*faceNodeCount) = 4;
return HEX8_Faces[faceIdx];
break;
case CAX4:
(*faceNodeCount) = 4;
return CAX4_Faces;
break;
default:
assert(false); // Element type not supported
break;
}
return CAX4_Faces;
}
@@ -0,0 +1,37 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions 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 <assert.h>
enum RigElementType
{
HEX8,
CAX4,
UNKNOWN_ELM_TYPE
};
class RigFemTypes
{
public:
static const int elmentNodeCount(RigElementType elmType);
static const int elmentFaceCount(RigElementType elmType);
static const int* localElmNodeIndicesForFace(RigElementType elmType, int faceIdx, int* faceNodeCount);
};
@@ -0,0 +1,314 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions 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 <stdlib.h>
#include "RigGeoMechCaseData.h"
#include "RigFemPartCollection.h"
#include "RifGeoMechReaderInterface.h"
#ifdef USE_ODB_API
#include "RifOdbReader.h"
#endif
#include "RigFemScalarResultFrames.h"
#include "RigStatisticsDataCache.h"
#include <cmath>
#include "cvfBoundingBox.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigGeoMechCaseData::RigGeoMechCaseData(const std::string& fileName)
{
m_geoMechCaseFileName = fileName;
m_femParts = new RigFemPartCollection();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigGeoMechCaseData::~RigGeoMechCaseData()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigFemPartCollection* RigGeoMechCaseData::femParts()
{
return m_femParts.p();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const RigFemPartCollection* RigGeoMechCaseData::femParts() const
{
return m_femParts.p();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RigGeoMechCaseData::openAndReadFemParts()
{
#ifdef USE_ODB_API
m_readerInterface = new RifOdbReader;
#endif
if (m_readerInterface.notNull() && m_readerInterface->openFile(m_geoMechCaseFileName))
{
m_femParts = new RigFemPartCollection();
if (m_readerInterface->readFemParts(m_femParts.p()))
{
// Initialize results containers
m_femPartResults.resize(m_femParts->partCount());
std::vector<std::string> stepNames = m_readerInterface->stepNames();
for (int pIdx = 0; pIdx < m_femPartResults.size(); ++pIdx)
{
m_femPartResults[pIdx] = new RigFemPartResults;
m_femPartResults[pIdx]->initResultStages(stepNames);
}
return true;
}
}
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::map<std::string, std::vector<std::string> > RigGeoMechCaseData::scalarFieldAndComponentNames(RigFemResultPosEnum resPos)
{
std::map<std::string, std::vector<std::string> > fieldCompNames;
if (m_readerInterface.notNull())
{
if (resPos == RIG_NODAL)
{
fieldCompNames = m_readerInterface->scalarNodeFieldAndComponentNames();
}
else if (resPos == RIG_ELEMENT_NODAL)
{
fieldCompNames = m_readerInterface->scalarElementNodeFieldAndComponentNames();
}
else if (resPos == RIG_INTEGRATION_POINT)
{
fieldCompNames = m_readerInterface->scalarIntegrationPointFieldAndComponentNames();
}
}
return fieldCompNames;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigFemScalarResultFrames* RigGeoMechCaseData::findOrLoadScalarResult(int partIndex, int stepIndex,
const RigFemResultAddress& resVarAddr)
{
CVF_ASSERT(partIndex < m_femParts->partCount());
CVF_ASSERT(m_readerInterface.notNull());
RigFemScalarResultFrames* frames = m_femPartResults[partIndex]->findScalarResult(stepIndex, resVarAddr);
if (frames) return frames;
std::vector<double > frameTimes = m_readerInterface->frameTimes((int)stepIndex);
frames = m_femPartResults[partIndex]->createScalarResult( stepIndex, resVarAddr, frameTimes);
for (int fIdx = 0; (size_t)fIdx < frameTimes.size(); ++fIdx)
{
std::vector<float>* frameData = &(frames->frameData(fIdx));
switch (resVarAddr.resultPosType)
{
case RIG_NODAL:
m_readerInterface->readScalarNodeField(resVarAddr.fieldName, resVarAddr.componentName, partIndex, stepIndex, fIdx, frameData);
break;
case RIG_ELEMENT_NODAL:
m_readerInterface->readScalarElementNodeField(resVarAddr.fieldName, resVarAddr.componentName, partIndex, stepIndex, fIdx, frameData);
break;
case RIG_INTEGRATION_POINT:
m_readerInterface->readScalarIntegrationPointField(resVarAddr.fieldName, resVarAddr.componentName, partIndex, stepIndex, fIdx, frameData);
break;
}
}
return frames;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<std::string> RigGeoMechCaseData::stepNames()
{
CVF_ASSERT(m_readerInterface.notNull());
return m_readerInterface->stepNames();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigGeoMechCaseData::minMaxScalarValues(const RigFemResultAddress& resVarAddr, int stepIndex, int frameIndex,
double* localMin, double* localMax)
{
minMaxScalarValuesInternal(resVarAddr, stepIndex, frameIndex, localMin, localMax);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigGeoMechCaseData::minMaxScalarValues(const RigFemResultAddress& resVarAddr, int stepIndex,
double* globalMin, double* globalMax)
{
minMaxScalarValuesInternal(resVarAddr, stepIndex, -1, globalMin, globalMax);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigGeoMechCaseData::minMaxScalarValuesInternal(const RigFemResultAddress& resVarAddr, int stepIndex, int frameIndex, double* overallMin, double* overallMax)
{
CVF_ASSERT(overallMax && overallMin);
double min = HUGE_VAL;
double max = -HUGE_VAL;
for (int pIdx = 0; pIdx < m_femPartResults.size(); ++pIdx)
{
if (m_femPartResults[pIdx].notNull())
{
RigFemScalarResultFrames* frames = findOrLoadScalarResult(pIdx, stepIndex, resVarAddr);
if (frames)
{
double lmin;
double lmax;
RigStatisticsDataCache* stats = frames->statistics();
if (frameIndex == -1)
{
stats->minMaxCellScalarValues(lmin, lmax);
}
else
{
stats->minMaxCellScalarValues(frameIndex, lmin, lmax);
}
min = lmin < min ? lmin: min;
max = lmax > max ? lmax: max;
}
}
}
*overallMax = max;
*overallMin = min;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigGeoMechCaseData::posNegClosestToZero(const RigFemResultAddress& resVarAddr, int stepIndex, int frameIndex, double* localPosClosestToZero, double* localNegClosestToZero)
{
posNegClosestToZeroInternal(resVarAddr, stepIndex, frameIndex, localPosClosestToZero, localNegClosestToZero);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigGeoMechCaseData::posNegClosestToZero(const RigFemResultAddress& resVarAddr, int stepIndex, double* globalPosClosestToZero, double* globalNegClosestToZero)
{
posNegClosestToZeroInternal(resVarAddr, stepIndex, -1, globalPosClosestToZero, globalNegClosestToZero);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigGeoMechCaseData::posNegClosestToZeroInternal(const RigFemResultAddress& resVarAddr, int stepIndex, int frameIndex,
double* overallPosClosestToZero, double* overallNegClosestToZero)
{
CVF_ASSERT(overallPosClosestToZero && overallNegClosestToZero);
double posClosestToZero = HUGE_VAL;
double negClosestToZero = -HUGE_VAL;
for (int pIdx = 0; pIdx < m_femPartResults.size(); ++pIdx)
{
if (m_femPartResults[pIdx].notNull())
{
RigFemScalarResultFrames* frames = findOrLoadScalarResult(pIdx, stepIndex, resVarAddr);
if (frames)
{
double partNeg, partPos;
RigStatisticsDataCache* stats = frames->statistics();
if (frameIndex == -1)
{
stats->posNegClosestToZero(partPos, partNeg);
}
else
{
stats->posNegClosestToZero(frameIndex, partPos, partNeg);
}
if (partNeg > negClosestToZero && partNeg < 0) negClosestToZero = partNeg;
if (partPos < posClosestToZero && partPos > 0) posClosestToZero = partPos;
}
}
}
*overallPosClosestToZero = posClosestToZero;
*overallNegClosestToZero = negClosestToZero;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
size_t RigGeoMechCaseData::frameCount(int stepIndex, const RigFemResultAddress& resVarAddr)
{
size_t maxFrameCount = 0;
for (int pIdx = 0; pIdx < m_femPartResults.size(); ++pIdx)
{
if (m_femPartResults[pIdx].notNull())
{
RigFemScalarResultFrames* frames = m_femPartResults[pIdx]->findScalarResult(stepIndex, resVarAddr);
if (frames)
{
size_t frameCount = frames->frameCount();
if (frameCount > maxFrameCount) maxFrameCount = frameCount;
}
}
}
return maxFrameCount;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigGeoMechCaseData::assertResultsLoaded(int stepIndex, const RigFemResultAddress& resVarAddr)
{
for (int pIdx = 0; pIdx < m_femPartResults.size(); ++pIdx)
{
if (m_femPartResults[pIdx].notNull())
{
findOrLoadScalarResult(pIdx, stepIndex, resVarAddr);
}
}
}
@@ -0,0 +1,72 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions 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 "cvfObject.h"
#include <string>
#include <map>
#include <vector>
#include "RigFemResultPosEnum.h"
#include "cvfCollection.h"
#include "RigFemPartResults.h"
#include "RigFemResultAddress.h"
class RifGeoMechReaderInterface;
class RigFemPartCollection;
class RigFemScalarResultFrames;
class RigGeoMechCaseData: public cvf::Object
{
public:
RigGeoMechCaseData(const std::string& fileName);
~RigGeoMechCaseData();
bool openAndReadFemParts();
RigFemPartCollection* femParts();
const RigFemPartCollection* femParts() const;
std::map<std::string, std::vector<std::string> > scalarFieldAndComponentNames(RigFemResultPosEnum resPos);
std::vector<std::string> stepNames();
void assertResultsLoaded(int stepIndex, const RigFemResultAddress& resVarAddr);
RigFemScalarResultFrames* findOrLoadScalarResult(int partIndex,
int stepIndex,
const RigFemResultAddress& resVarAddr);
size_t frameCount(int stepIndex, const RigFemResultAddress& resVarAddr);
std::vector<double> frameTimes(int stepIndex, const RigFemResultAddress& resVarAddr);
void minMaxScalarValues (const RigFemResultAddress& resVarAddr, int stepIndex, int frameIndex, double* localMin, double* localMax);
void posNegClosestToZero(const RigFemResultAddress& resVarAddr, int stepIndex, int frameIndex, double* localPosClosestToZero, double* localNegClosestToZero);
void minMaxScalarValues (const RigFemResultAddress& resVarAddr, int stepIndex, double* globalMin, double* globalMax);
void posNegClosestToZero(const RigFemResultAddress& resVarAddr, int stepIndex, double* globalPosClosestToZero, double* globalNegClosestToZero);
private:
void minMaxScalarValuesInternal(const RigFemResultAddress& resVarAddr, int stepIndex, int frameIndex,
double* overallMin, double* overallMax);
void posNegClosestToZeroInternal(const RigFemResultAddress& resVarAddr, int stepIndex, int frameIndex,
double* localPosClosestToZero, double* localNegClosestToZero);
std::string m_geoMechCaseFileName;
cvf::ref<RigFemPartCollection> m_femParts;
cvf::Collection<RigFemPartResults> m_femPartResults;
cvf::ref<RifGeoMechReaderInterface> m_readerInterface;
cvf::ref<RigStatisticsDataCache> m_statistics;
};
@@ -0,0 +1,7 @@
#pragma once
enum RigFemResultPosEnum {
NODAL,
ELEMENT_NODAL,
INTEGRATION_POINT
};
@@ -0,0 +1,27 @@
# Use this workaround until we're on 2.8.3 on all platforms and can use CMAKE_CURRENT_LIST_DIR directly
if (${CMAKE_VERSION} VERSION_GREATER "2.8.2")
set(CEE_CURRENT_LIST_DIR ${CMAKE_CURRENT_LIST_DIR}/)
endif()
set (SOURCE_GROUP_HEADER_FILES
${CEE_CURRENT_LIST_DIR}RivFemPartGeometryGenerator.h
${CEE_CURRENT_LIST_DIR}RivFemPartPartMgr.h
${CEE_CURRENT_LIST_DIR}RivGeoMechPartMgr.h
)
set (SOURCE_GROUP_SOURCE_FILES
${CEE_CURRENT_LIST_DIR}RivFemPartGeometryGenerator.cpp
${CEE_CURRENT_LIST_DIR}RivFemPartPartMgr.cpp
${CEE_CURRENT_LIST_DIR}RivGeoMechPartMgr.cpp
)
list(APPEND CODE_HEADER_FILES
${SOURCE_GROUP_HEADER_FILES}
)
list(APPEND CODE_SOURCE_FILES
${SOURCE_GROUP_SOURCE_FILES}
)
source_group( "GeoMechViz" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CEE_CURRENT_LIST_DIR}CMakeLists_files.cmake )
@@ -0,0 +1,248 @@
#include <stdlib.h>
#include "RivFemPartGeometryGenerator.h"
#include "cvfBase.h"
#include "RigFemPart.h"
//#include "RigFemPartScalarDataAccess.h"
#include "cvfDebugTimer.h"
#include "cvfGeometryBuilderDrawableGeo.h"
#include "cvfPrimitiveSetIndexedUInt.h"
#include "cvfScalarMapper.h"
#include "cvfArray.h"
#include "cvfOutlineEdgeExtractor.h"
#include <cmath>
using namespace cvf;
//==================================================================================================
///
///
//==================================================================================================
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RivFemPartGeometryGenerator::RivFemPartGeometryGenerator(const RigFemPart* part)
: m_part(part)
{
CVF_ASSERT(part);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RivFemPartGeometryGenerator::~RivFemPartGeometryGenerator()
{
}
//--------------------------------------------------------------------------------------------------
/// Generate surface drawable geo from the specified region
///
//--------------------------------------------------------------------------------------------------
ref<DrawableGeo> RivFemPartGeometryGenerator::generateSurface()
{
computeArrays();
CVF_ASSERT(m_quadVertices.notNull());
if (m_quadVertices->size() == 0) return NULL;
ref<DrawableGeo> geo = new DrawableGeo;
geo->setFromQuadVertexArray(m_quadVertices.p());
return geo;
}
//--------------------------------------------------------------------------------------------------
/// Generates simplified mesh as line drawing
/// Must call generateSurface first
//--------------------------------------------------------------------------------------------------
ref<DrawableGeo> RivFemPartGeometryGenerator::createMeshDrawable()
{
if (!(m_quadVertices.notNull() && m_quadVertices->size() != 0)) return NULL;
ref<DrawableGeo> geo = new DrawableGeo;
geo->setVertexArray(m_quadVertices.p());
ref<UIntArray> indices = lineIndicesFromQuadVertexArray(m_quadVertices.p());
ref<PrimitiveSetIndexedUInt> prim = new PrimitiveSetIndexedUInt(PT_LINES);
prim->setIndices(indices.p());
geo->addPrimitiveSet(prim.p());
return geo;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
ref<DrawableGeo> RivFemPartGeometryGenerator::createOutlineMeshDrawable(double creaseAngle)
{
if (!(m_quadVertices.notNull() && m_quadVertices->size() != 0)) return NULL;
cvf::OutlineEdgeExtractor ee(creaseAngle, *m_quadVertices);
ref<UIntArray> indices = lineIndicesFromQuadVertexArray(m_quadVertices.p());
ee.addPrimitives(4, *indices);
ref<cvf::UIntArray> lineIndices = ee.lineIndices();
if (lineIndices->size() == 0)
{
return NULL;
}
ref<PrimitiveSetIndexedUInt> prim = new PrimitiveSetIndexedUInt(PT_LINES);
prim->setIndices(lineIndices.p());
ref<DrawableGeo> geo = new DrawableGeo;
geo->setVertexArray(m_quadVertices.p());
geo->addPrimitiveSet(prim.p());
return geo;
}
//--------------------------------------------------------------------------------------------------
///
///
///
///
//--------------------------------------------------------------------------------------------------
ref<UIntArray> RivFemPartGeometryGenerator::lineIndicesFromQuadVertexArray(const Vec3fArray* vertexArray)
{
CVF_ASSERT(vertexArray);
size_t numVertices = vertexArray->size();
int numQuads = static_cast<int>(numVertices/4);
CVF_ASSERT(numVertices%4 == 0);
ref<UIntArray> indices = new UIntArray;
indices->resize(numQuads*8);
#pragma omp parallel for
for (int i = 0; i < numQuads; i++)
{
int idx = 8*i;
indices->set(idx + 0, i*4 + 0);
indices->set(idx + 1, i*4 + 1);
indices->set(idx + 2, i*4 + 1);
indices->set(idx + 3, i*4 + 2);
indices->set(idx + 4, i*4 + 2);
indices->set(idx + 5, i*4 + 3);
indices->set(idx + 6, i*4 + 3);
indices->set(idx + 7, i*4 + 0);
}
return indices;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivFemPartGeometryGenerator::computeArrays()
{
std::vector<Vec3f> vertices;
m_quadVerticesToNodeIdx.clear();
m_quadVerticesToGlobalElmNodeIdx.clear();
size_t estimatedQuadVxCount = m_part->elementCount()*6*4;
vertices.reserve(estimatedQuadVxCount);
m_quadVerticesToNodeIdx.reserve(estimatedQuadVxCount);
m_quadVerticesToGlobalElmNodeIdx.reserve(estimatedQuadVxCount);
cvf::Vec3d offset = Vec3d::ZERO; //m_part->displayModelOffset();
const std::vector<cvf::Vec3f>& nodeCoordinates = m_part->nodes().coordinates;
#pragma omp parallel for schedule(dynamic)
for (int elmIdx = 0; elmIdx < static_cast<int>(m_part->elementCount()); elmIdx++)
{
if (m_elmVisibility.isNull() || (*m_elmVisibility)[elmIdx])
{
RigElementType eType = m_part->elementType(elmIdx);
int faceCount = RigFemTypes::elmentFaceCount(eType);
int elmQuadCount = 0;
const int* elmNodeIndices = m_part->connectivities(elmIdx);
for (int lfIdx = 0; lfIdx < faceCount; ++lfIdx)
{
int faceNodeCount = 0;
const int* localElmNodeIndicesForFace = RigFemTypes::localElmNodeIndicesForFace(eType, lfIdx, &faceNodeCount);
if (faceNodeCount == 4)
{
// Todo: Needs to get rid of opposite faces
const cvf::Vec3f* quadVxs[4];
quadVxs[0] = &(nodeCoordinates[ elmNodeIndices[localElmNodeIndicesForFace[0]] ]);
quadVxs[1] = &(nodeCoordinates[ elmNodeIndices[localElmNodeIndicesForFace[1]] ]);
quadVxs[2] = &(nodeCoordinates[ elmNodeIndices[localElmNodeIndicesForFace[2]] ]);
quadVxs[3] = &(nodeCoordinates[ elmNodeIndices[localElmNodeIndicesForFace[3]] ]);
int qNodeIdx[4];
qNodeIdx[0] = elmNodeIndices[localElmNodeIndicesForFace[0]];
qNodeIdx[1] = elmNodeIndices[localElmNodeIndicesForFace[1]];
qNodeIdx[2] = elmNodeIndices[localElmNodeIndicesForFace[2]];
qNodeIdx[3] = elmNodeIndices[localElmNodeIndicesForFace[3]];
size_t qElmNodeResIdx[4];
qElmNodeResIdx[0] = m_part->elementNodeResultIdx(elmIdx, localElmNodeIndicesForFace[0]);
qElmNodeResIdx[1] = m_part->elementNodeResultIdx(elmIdx, localElmNodeIndicesForFace[1]);
qElmNodeResIdx[2] = m_part->elementNodeResultIdx(elmIdx, localElmNodeIndicesForFace[2]);
qElmNodeResIdx[3] = m_part->elementNodeResultIdx(elmIdx, localElmNodeIndicesForFace[3]);
#pragma omp critical
{
vertices.push_back(*quadVxs[0]);
vertices.push_back(*quadVxs[1]);
vertices.push_back(*quadVxs[2]);
vertices.push_back(*quadVxs[3]);
m_quadVerticesToNodeIdx.push_back(qNodeIdx[0]);
m_quadVerticesToNodeIdx.push_back(qNodeIdx[1]);
m_quadVerticesToNodeIdx.push_back(qNodeIdx[2]);
m_quadVerticesToNodeIdx.push_back(qNodeIdx[3]);
m_quadVerticesToGlobalElmNodeIdx.push_back(qElmNodeResIdx[0]);
m_quadVerticesToGlobalElmNodeIdx.push_back(qElmNodeResIdx[1]);
m_quadVerticesToGlobalElmNodeIdx.push_back(qElmNodeResIdx[2]);
m_quadVerticesToGlobalElmNodeIdx.push_back(qElmNodeResIdx[3]);
}
}
else
{
// Handle triangles and 6 node and 8 node faces
}
}
}
}
m_quadVertices = new cvf::Vec3fArray;
m_quadVertices->assign(vertices);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivFemPartGeometryGenerator::setElementVisibility(const cvf::UByteArray* cellVisibility)
{
m_elmVisibility = cellVisibility;
}
@@ -0,0 +1,66 @@
#pragma once
#include "cvfObject.h"
#include "cvfArray.h"
#include "RigFemPart.h"
namespace cvf
{
class DrawableGeo;
class ScalarMapper;
}
class RigFemPartScalarDataAccess;
//==================================================================================================
//
//
//
//==================================================================================================
class RivFemPartGeometryGenerator : public cvf::Object
{
public:
RivFemPartGeometryGenerator(const RigFemPart* part);
~RivFemPartGeometryGenerator();
// Setup methods
void setElementVisibility(const cvf::UByteArray* cellVisibility);
// Access, valid after generation is done
const RigFemPart* activePart() { return m_part.p(); }
// Generated geometry
cvf::ref<cvf::DrawableGeo> generateSurface();
cvf::ref<cvf::DrawableGeo> createMeshDrawable();
cvf::ref<cvf::DrawableGeo> createOutlineMeshDrawable(double creaseAngle);
const std::vector<size_t>& quadVerticesToNodeIdxMapping() const { return m_quadVerticesToNodeIdx;}
const std::vector<size_t>& quadVerticesToGlobalElmNodeIdx() const { return m_quadVerticesToGlobalElmNodeIdx;}
private:
static cvf::ref<cvf::UIntArray>
lineIndicesFromQuadVertexArray(const cvf::Vec3fArray* vertexArray);
void computeArrays();
private:
// Input
cvf::cref<RigFemPart> m_part; // The part being processed
cvf::cref<cvf::UByteArray> m_elmVisibility;
// Created arrays
cvf::ref<cvf::Vec3fArray> m_quadVertices;
//cvf::ref<cvf::Vec3fArray> m_triangleVertices; // If needed, we will do it like this, I think
std::vector<size_t> m_quadVerticesToNodeIdx;
std::vector<size_t> m_quadVerticesToGlobalElmNodeIdx;
};
@@ -0,0 +1,287 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions 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 <stdlib.h>
#include "RivGeoMechPartMgr.h"
#include "RiaApplication.h"
#include "RiaPreferences.h"
#include "RimReservoirView.h"
#include "RimGeoMechResultSlot.h"
#include "RimLegendConfig.h"
#include "RivResultToTextureMapper.h"
#include "RivScalarMapperUtils.h"
#include "RivSourceInfo.h"
#include "RivTextureCoordsCreator.h"
#include "cafEffectGenerator.h"
#include "cvfDrawableGeo.h"
#include "cvfMath.h"
#include "cvfModelBasicList.h"
#include "cvfPart.h"
#include "cvfRenderStateBlending.h"
#include "cvfRenderStatePolygonOffset.h"
#include "cvfRenderState_FF.h"
#include "cvfShaderProgram.h"
#include "cvfShaderProgramGenerator.h"
#include "cvfShaderSourceProvider.h"
#include "cvfShaderSourceRepository.h"
#include "cvfStructGrid.h"
#include "cvfUniform.h"
#include "RifGeoMechReaderInterface.h"
#include "RigGeoMechCaseData.h"
#include "RigFemScalarResultFrames.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RivFemPartPartMgr::RivFemPartPartMgr(const RigFemPart* grid)
: m_surfaceGenerator(grid),
m_grid(grid),
m_opacityLevel(1.0f),
m_defaultColor(cvf::Color3::WHITE)
{
CVF_ASSERT(grid);
m_gridIdx = grid->elementPartId();
m_cellVisibility = new cvf::UByteArray;
m_surfaceFacesTextureCoords = new cvf::Vec2fArray;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivFemPartPartMgr::setTransform(cvf::Transform* scaleTransform)
{
m_scaleTransform = scaleTransform;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivFemPartPartMgr::setCellVisibility(cvf::UByteArray* cellVisibilities)
{
CVF_ASSERT(m_scaleTransform.notNull());
CVF_ASSERT(cellVisibilities);
m_cellVisibility = cellVisibilities;
m_surfaceGenerator.setElementVisibility(cellVisibilities);
generatePartGeometry(m_surfaceGenerator);
}
void RivFemPartPartMgr::generatePartGeometry(RivFemPartGeometryGenerator& geoBuilder)
{
bool useBufferObjects = true;
// Surface geometry
{
m_surfaceFaces = NULL; // To possibly free memory before adding the new stuff
cvf::ref<cvf::DrawableGeo> geo = geoBuilder.generateSurface();
if (geo.notNull())
{
geo->computeNormals();
if (useBufferObjects)
{
geo->setRenderMode(cvf::DrawableGeo::BUFFER_OBJECT);
}
cvf::ref<cvf::Part> part = new cvf::Part;
part->setName("FemPart " + cvf::String(m_gridIdx));
part->setId(m_gridIdx); // !! For now, use grid index as part ID (needed for pick info)
part->setDrawable(geo.p());
part->setTransform(m_scaleTransform.p());
// Set mapping from triangle face index to cell index
//cvf::ref<RivSourceInfo> si = new RivSourceInfo;
//si->m_cellFaceFromTriangleMapper = geoBuilder.triangleToCellFaceMapper();
//
//part->setSourceInfo(si.p());
part->updateBoundingBox();
// Set default effect
caf::SurfaceEffectGenerator geometryEffgen(cvf::Color4f(cvf::Color3f::WHITE), caf::PO_1);
cvf::ref<cvf::Effect> geometryOnlyEffect = geometryEffgen.generateEffect();
part->setEffect(geometryOnlyEffect.p());
part->setEnableMask(surfaceBit);
m_surfaceFaces = part;
}
}
// Mesh geometry
{
m_surfaceGridLines = NULL; // To possibly free memory before adding the new stuff
cvf::ref<cvf::DrawableGeo> geoMesh = geoBuilder.createMeshDrawable();
if (geoMesh.notNull())
{
if (useBufferObjects)
{
geoMesh->setRenderMode(cvf::DrawableGeo::BUFFER_OBJECT);
}
cvf::ref<cvf::Part> part = new cvf::Part;
part->setName("Grid mesh " + m_gridIdx);
part->setDrawable(geoMesh.p());
part->setTransform(m_scaleTransform.p());
part->updateBoundingBox();
RiaPreferences* prefs = RiaApplication::instance()->preferences();
cvf::ref<cvf::Effect> eff;
caf::MeshEffectGenerator effGen(prefs->defaultGridLineColors());
eff = effGen.generateEffect();
// Set priority to make sure fault lines are rendered first
part->setPriority(10);
part->setEnableMask(meshSurfaceBit);
part->setEffect(eff.p());
m_surfaceGridLines = part;
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivFemPartPartMgr::appendPartsToModel(cvf::ModelBasicList* model)
{
CVF_ASSERT(model != NULL);
if(m_surfaceFaces.notNull() ) model->addPart(m_surfaceFaces.p() );
if(m_surfaceGridLines.notNull()) model->addPart(m_surfaceGridLines.p());
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivFemPartPartMgr::updateCellColor(cvf::Color4f color)
{
if (m_surfaceFaces.isNull()) return;
// Set default effect
caf::SurfaceEffectGenerator geometryEffgen(color, caf::PO_1);
cvf::ref<cvf::Effect> geometryOnlyEffect = geometryEffgen.generateEffect();
if (m_surfaceFaces.notNull()) m_surfaceFaces->setEffect(geometryOnlyEffect.p());
if (color.a() < 1.0f)
{
// Set priority to make sure this transparent geometry are rendered last
if (m_surfaceFaces.notNull()) m_surfaceFaces->setPriority(100);
}
m_opacityLevel = color.a();
m_defaultColor = color.toColor3f();
// Update mesh colors as well, in case of change
RiaPreferences* prefs = RiaApplication::instance()->preferences();
cvf::ref<cvf::Effect> eff;
if (m_surfaceFaces.notNull())
{
caf::MeshEffectGenerator effGen(prefs->defaultGridLineColors());
eff = effGen.generateEffect();
m_surfaceGridLines->setEffect(eff.p());
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivFemPartPartMgr::updateCellResultColor(size_t timeStepIndex, RimGeoMechResultSlot* cellResultSlot)
{
CVF_ASSERT(cellResultSlot);
// RigCaseData* eclipseCase = cellResultSlot->reservoirView()->eclipseCase()->reservoirData();
cvf::ref<cvf::Color3ubArray> surfaceFacesColorArray;
// Outer surface
if (m_surfaceFaces.notNull())
{
const cvf::ScalarMapper* mapper = cellResultSlot->legendConfig()->scalarMapper();
RigGeoMechCaseData* caseData = cellResultSlot->ownerCaseData();
if (!caseData) return;
caf::AppEnum<RigFemResultPosEnum> resPosType = cellResultSlot->resultPositionType();
QString fieldName = cellResultSlot->resultFieldName();
QString compName = cellResultSlot->resultComponentName();
RigFemResultAddress resVarAddress(resPosType, fieldName.toStdString(), compName.toStdString());
RigFemScalarResultFrames* scalarResults = caseData->findOrLoadScalarResult(m_gridIdx, 0, resVarAddress);
std::vector<float>& resultValues = scalarResults->frameData(timeStepIndex);
const std::vector<size_t>* vxToResultMapping = NULL;
if (cellResultSlot->resultPositionType() == RIG_NODAL)
{
vxToResultMapping = &(m_surfaceGenerator.quadVerticesToNodeIdxMapping());
}
else if ( cellResultSlot->resultPositionType() == RIG_ELEMENT_NODAL
|| cellResultSlot->resultPositionType() == RIG_INTEGRATION_POINT)
{
vxToResultMapping = &(m_surfaceGenerator.quadVerticesToGlobalElmNodeIdx());
}
m_surfaceFacesTextureCoords->resize(vxToResultMapping->size());
cvf::Vec2f* rawPtr = m_surfaceFacesTextureCoords->ptr();
#pragma omp parallel for schedule(dynamic)
for (int vxIdx = 0; vxIdx < vxToResultMapping->size(); ++vxIdx)
{
float resultValue = resultValues[(*vxToResultMapping)[vxIdx]];
if (resultValue == HUGE_VAL || resultValue != resultValue) // a != a is true for NAN's
{
rawPtr[vxIdx][1] = 1.0f;
}
else
{
rawPtr[vxIdx] = mapper->mapToTextureCoord(resultValue);
}
}
RivScalarMapperUtils::applyTextureResultsToPart(m_surfaceFaces.p(), m_surfaceFacesTextureCoords.p(), mapper, m_opacityLevel, caf::FC_NONE);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RivFemPartPartMgr::~RivFemPartPartMgr()
{
}
@@ -0,0 +1,81 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions 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 "RivFemPartGeometryGenerator.h"
namespace cvf
{
class StructGridInterface;
class ModelBasicList;
class Transform;
class Part;
class Effect;
}
class RimGeoMechResultSlot;
class RigFemPart;
//==================================================================================================
///
/// RivGridGeometry: Class to handle visualization structures that embodies a specific grid at a specific time step.
/// frame on a certain level
/// LGR's have their own instance and the parent grid as well
///
//==================================================================================================
class RivFemPartPartMgr: public cvf::Object
{
public:
RivFemPartPartMgr(const RigFemPart* femPart);
~RivFemPartPartMgr();
void setTransform(cvf::Transform* scaleTransform);
void setCellVisibility(cvf::UByteArray* cellVisibilities );
cvf::ref<cvf::UByteArray> cellVisibility() { return m_cellVisibility;}
void updateCellColor(cvf::Color4f color);
void updateCellResultColor(size_t timeStepIndex, RimGeoMechResultSlot* cellResultSlot);
void appendPartsToModel(cvf::ModelBasicList* model);
private:
void generatePartGeometry(RivFemPartGeometryGenerator& geoBuilder);
private:
int m_gridIdx;
cvf::cref<RigFemPart> m_grid;
cvf::ref<cvf::Transform> m_scaleTransform;
float m_opacityLevel;
cvf::Color3f m_defaultColor;
// Surface visualization
RivFemPartGeometryGenerator m_surfaceGenerator;
cvf::ref<cvf::Part> m_surfaceFaces;
cvf::ref<cvf::Vec2fArray> m_surfaceFacesTextureCoords;
cvf::ref<cvf::Part> m_surfaceGridLines;
cvf::ref<cvf::UByteArray> m_cellVisibility;
};
@@ -0,0 +1,141 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions 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 <stdlib.h>
#include "RivGeoMechPartMgr.h"
#include "cvfPart.h"
#include "cvfModelBasicList.h"
#include "RigGeoMechCaseData.h"
#include "RigFemPartCollection.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RivGeoMechPartMgr::RivGeoMechPartMgr()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RivGeoMechPartMgr::~RivGeoMechPartMgr()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivGeoMechPartMgr::clearAndSetReservoir(const RigGeoMechCaseData* geoMechCase, RimGeoMechView* geomechView)
{
m_femPartPartMgrs.clear();
if (geoMechCase)
{
const RigFemPartCollection* femParts = geoMechCase->femParts();
for (size_t i = 0; i < femParts->partCount(); ++i)
{
m_femPartPartMgrs.push_back(new RivFemPartPartMgr(femParts->part(i)));
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivGeoMechPartMgr::setTransform(cvf::Transform* scaleTransform)
{
for (size_t i = 0; i < m_femPartPartMgrs.size() ; ++i)
{
m_femPartPartMgrs[i]->setTransform(scaleTransform);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivGeoMechPartMgr::setCellVisibility(size_t gridIndex, cvf::UByteArray* cellVisibilities)
{
CVF_ASSERT(gridIndex < m_femPartPartMgrs.size());
m_femPartPartMgrs[gridIndex]->setCellVisibility(cellVisibilities);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::ref<cvf::UByteArray> RivGeoMechPartMgr::cellVisibility(size_t gridIdx)
{
CVF_ASSERT(gridIdx < m_femPartPartMgrs.size());
return m_femPartPartMgrs[gridIdx]->cellVisibility();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivGeoMechPartMgr::updateCellColor(cvf::Color4f color)
{
for (size_t i = 0; i < m_femPartPartMgrs.size() ; ++i)
{
m_femPartPartMgrs[i]->updateCellColor(color);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivGeoMechPartMgr::updateCellResultColor(size_t timeStepIndex, RimGeoMechResultSlot* cellResultSlot)
{
for (size_t i = 0; i < m_femPartPartMgrs.size() ; ++i)
{
m_femPartPartMgrs[i]->updateCellResultColor(timeStepIndex, cellResultSlot);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivGeoMechPartMgr::appendGridPartsToModel(cvf::ModelBasicList* model)
{
for (size_t i = 0; i < m_femPartPartMgrs.size() ; ++i)
{
m_femPartPartMgrs[i]->appendPartsToModel(model);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivGeoMechPartMgr::appendGridPartsToModel(cvf::ModelBasicList* model, const std::vector<size_t>& gridIndices)
{
for (size_t i = 0; i < gridIndices.size() ; ++i)
{
if (gridIndices[i] < m_femPartPartMgrs.size())
{
m_femPartPartMgrs[gridIndices[i]]->appendPartsToModel(model);
}
}
}
@@ -0,0 +1,66 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions 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 "cvfArray.h"
#include "cvfCollection.h"
#include "RivFemPartPartMgr.h"
namespace cvf
{
class ModelBasicList;
class Transform;
}
class RimGeoMechResultSlot;
class RigGeoMechCaseData;
class RimGeoMechView;
//==================================================================================================
///
/// Class to handle visualization structures that embodies a complete Geo-mech reservoir at a specific
/// time step.
///
//==================================================================================================
class RivGeoMechPartMgr: public cvf::Object
{
public:
RivGeoMechPartMgr();
~RivGeoMechPartMgr();
void clearAndSetReservoir(const RigGeoMechCaseData* geoMechCase, RimGeoMechView* geomechView);
void setTransform(cvf::Transform* scaleTransform);
void setCellVisibility(size_t partIndex, cvf::UByteArray* cellVisibilities );
cvf::ref<cvf::UByteArray>
cellVisibility(size_t partIndex);
void updateCellColor(cvf::Color4f color);
void updateCellResultColor(size_t timeStepIndex, RimGeoMechResultSlot* cellResultSlot);
void appendGridPartsToModel(cvf::ModelBasicList* model, const std::vector<size_t>& partIndices);
void appendGridPartsToModel(cvf::ModelBasicList* model);
private:
cvf::Collection<RivFemPartPartMgr> m_femPartPartMgrs;
};
@@ -0,0 +1,89 @@
cmake_minimum_required (VERSION 2.8)
project (RifOdbReader)
if (MSVC)
add_definitions(-DHKS_NT)
add_definitions(-DABQ_WIN86_64)
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -c -fPIC -w -Wno-deprecated")
add_definitions(-DTYPENAME=typename)
add_definitions(-D_LINUX_SOURCE)
add_definitions(-DABQ_LINUX)
add_definitions(-DABQ_LNX86_64)
add_definitions(-DSMA_GNUC)
add_definitions(-DFOR_TRAIL)
add_definitions(-DHAS_BOOL)
add_definitions(-DASSERT_ENABLED)
add_definitions(-D_BSD_TYPES)
add_definitions(-D_BSD_SOURCE)
add_definitions(-D_GNU_SOURCE)
add_definitions(-D_POSIX_SOURCE)
add_definitions(-D_XOPEN_SOURCE_EXTENDED)
add_definitions(-D_XOPEN_SOURCE)
add_definitions(-DHAVE_OPENGL)
add_definitions(-DHKS_OPEN_GL)
add_definitions(-DGL_GLEXT_PROTOTYPES)
add_definitions(-DMULTI_THREADING_ENABLED)
add_definitions(-D_REENTRANT)
add_definitions(-DABQ_MPI_SUPPORT)
add_definitions(-DBIT64)
add_definitions(-D_LARGEFILE64_SOURCE)
add_definitions(-D_FILE_OFFSET_BITS=64)
add_definitions(-DABQ_MPI_PMPI)
endif(MSVC)
include_directories(
${RESINSIGHT_ODB_API_DIR}/include
${RigGeoMechDataModel_SOURCE_DIR}
${LibCore_SOURCE_DIR}
)
add_library( ${PROJECT_NAME}
RifOdbReader.h
RifOdbReader.cpp
RifGeoMechReaderInterface.h
RifGeoMechReaderInterface.cpp
OdbSetup.cmake
)
if (MSVC)
list(APPEND RI_ODB_LIBS
${RESINSIGHT_ODB_API_DIR}/lib/ABQSMAOdbDdbOdb.lib
${RESINSIGHT_ODB_API_DIR}/lib/ABQSMAOdbApi.lib
${RESINSIGHT_ODB_API_DIR}/lib/ABQSMAOdbCore.lib
${RESINSIGHT_ODB_API_DIR}/lib/ABQSMAOdbCoreGeom.lib
${RESINSIGHT_ODB_API_DIR}/lib/ABQSMAOdbAttrEO.lib
${RESINSIGHT_ODB_API_DIR}/lib/ABQSMAAbuBasicUtils.lib
${RESINSIGHT_ODB_API_DIR}/lib/ABQSMABasShared.lib
${RESINSIGHT_ODB_API_DIR}/lib/ABQSMABasCoreUtils.lib
${RESINSIGHT_ODB_API_DIR}/lib/ABQSMAStiCAE_StableTime.lib
${RESINSIGHT_ODB_API_DIR}/lib/ABQSMABasMem.lib
${RESINSIGHT_ODB_API_DIR}/lib/ABQSMAAbuGeom.lib
${RESINSIGHT_ODB_API_DIR}/lib/ABQSMARomDiagEx.lib
${RESINSIGHT_ODB_API_DIR}/lib/ABQSMASspUmaCore.lib
${RESINSIGHT_ODB_API_DIR}/lib/ABQSMASimInterface.lib
${RESINSIGHT_ODB_API_DIR}/lib/ABQSMAMtxCoreModule.lib
)
else()
list(APPEND RI_ODB_LIBS
${RESINSIGHT_ODB_API_DIR}/lib/libABQSMAOdbDdbOdb.so
${RESINSIGHT_ODB_API_DIR}/lib/libABQSMAOdbApi.so
${RESINSIGHT_ODB_API_DIR}/lib/libABQSMAOdbCore.so
${RESINSIGHT_ODB_API_DIR}/lib/libABQSMAOdbCoreGeom.so
${RESINSIGHT_ODB_API_DIR}/lib/libABQSMAOdbAttrEO.so
${RESINSIGHT_ODB_API_DIR}/lib/libABQSMAAbuBasicUtils.so
${RESINSIGHT_ODB_API_DIR}/lib/libABQSMABasShared.so
${RESINSIGHT_ODB_API_DIR}/lib/libABQSMABasCoreUtils.so
${RESINSIGHT_ODB_API_DIR}/lib/libABQSMAStiCAE_StableTime.so
${RESINSIGHT_ODB_API_DIR}/lib/libABQSMABasMem.so
${RESINSIGHT_ODB_API_DIR}/lib/libABQSMAAbuGeom.so
${RESINSIGHT_ODB_API_DIR}/lib/libABQSMARomDiagEx.so
${RESINSIGHT_ODB_API_DIR}/lib/libABQSMASspUmaCore.so
${RESINSIGHT_ODB_API_DIR}/lib/libABQSMASimInterface.so
${RESINSIGHT_ODB_API_DIR}/lib/libABQSMAMtxCoreModule.so
)
endif(MSVC)
target_link_libraries(${PROJECT_NAME} ${RI_ODB_LIBS} RigGeoMechDataModel LibCore)
@@ -0,0 +1,27 @@
# Copy Odb Dlls
set(RESINSIGHT_ODB_API_DIR "" CACHE PATH "Path tho the ODB api from Simulia")
if (MSVC)
# Find all the dlls
file (GLOB RI_ALL_ODB_DLLS ${RESINSIGHT_ODB_API_DIR}/lib/*.dll)
# Strip off the path
foreach (aDLL ${RI_ALL_ODB_DLLS})
get_filename_component(filenameWithExt ${aDLL} NAME)
list(APPEND RI_ODB_DLLS ${filenameWithExt} )
endforeach(aDLL)
# Copy to target directory
#foreach (aDLL ${RI_ODB_DLLS})
# add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
# COMMAND ${CMAKE_COMMAND} -E copy_if_different "${RI_ODB_API_DIR}/lib/${aDLL}" "$<TARGET_FILE_DIR:${PROJECT_NAME}>")
#endforeach()
foreach (aDLL ${RI_ODB_DLLS})
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"${RESINSIGHT_ODB_API_DIR}/lib/${aDLL}"
"${CMAKE_CURRENT_BINARY_DIR}/$<CONFIGURATION>")
endforeach()
endif(MSVC)
@@ -0,0 +1,38 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) Statoil ASA
// Copyright (C) Ceetron Solutions 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 "RifGeoMechReaderInterface.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RifGeoMechReaderInterface::RifGeoMechReaderInterface()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RifGeoMechReaderInterface::~RifGeoMechReaderInterface()
{
}
@@ -0,0 +1,60 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions AS
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cvfBase.h"
#include "cvfObject.h"
#include "cvfVector3.h"
#include <vector>
#include <map>
#include <string>
class RigFemPartCollection;
//==================================================================================================
//
// Data interface base class
//
//==================================================================================================
class RifGeoMechReaderInterface : public cvf::Object
{
public:
RifGeoMechReaderInterface();
virtual ~RifGeoMechReaderInterface();
virtual bool openFile(const std::string& fileName, std::string* errorMessage = 0) = 0;
virtual bool readFemParts(RigFemPartCollection* geoMechCase) = 0;
virtual std::vector<std::string> stepNames() = 0;
virtual std::vector<double> frameTimes(int stepIndex) = 0;
virtual std::map<std::string, std::vector<std::string> > scalarNodeFieldAndComponentNames() = 0;
virtual std::map<std::string, std::vector<std::string> > scalarElementNodeFieldAndComponentNames() = 0;
virtual std::map<std::string, std::vector<std::string> > scalarIntegrationPointFieldAndComponentNames() = 0;
virtual void readScalarNodeField(const std::string& fieldName, const std::string& componmentName, int partIndex, int stepIndex, int frameIndex, std::vector<float>* resultValues) = 0;
virtual void readScalarElementNodeField(const std::string& fieldName, const std::string& componmentName, int partIndex, int stepIndex, int frameIndex, std::vector<float>* resultValues) = 0;
virtual void readScalarIntegrationPointField(const std::string& fieldName, const std::string& componmentName, int partIndex, int stepIndex, int frameIndex, std::vector<float>* resultValues) = 0;
virtual void readDisplacements(int partIndex, int stepIndex, int frameIndex, std::vector<cvf::Vec3f>* displacements) = 0;
private:
};
@@ -0,0 +1,798 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) Statoil ASA
// Copyright (C) Ceetron Solutions 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.
//
/////////////////////////////////////////////////////////////////////////////////
// Get rid of warnings from compilation of ODB API
#ifdef _MSC_VER
#pragma warning(disable: 4482)
#pragma warning(disable: 4584)
#endif
#include "RifOdbReader.h"
#include "RigFemPartCollection.h"
#include "RigFemPart.h"
#include <odb_API.h>
#include <odb_Enum.h>
#include <map>
#include <iostream>
#include <limits>
#include <sstream>
size_t RifOdbReader::sm_instanceCount = 0;
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::map<std::string, RigElementType> initFemTypeMap()
{
std::map<std::string, RigElementType> typeMap;
typeMap["C3D8R"] = HEX8;
typeMap["C3D8"] = HEX8;
typeMap["C3D8P"] = HEX8;
typeMap["CAX4"] = CAX4;
return typeMap;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigElementType toRigElementType(const odb_String& odbTypeName)
{
static std::map<std::string, RigElementType> odbElmTypeToRigElmTypeMap = initFemTypeMap();
std::map<std::string, RigElementType>::iterator it = odbElmTypeToRigElmTypeMap.find(odbTypeName.cStr());
if (it == odbElmTypeToRigElmTypeMap.end())
{
#if 0
std::cout << "Unsupported element type :" << odbElm.type().cStr() << std::endl;
#endif
return UNKNOWN_ELM_TYPE;
}
return it->second;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const int* localElmNodeToIntegrationPointMapping(RigElementType elmType)
{
static const int HEX8_Mapping[8] ={ 0, 1, 3, 2, 4, 5, 7, 6 };
switch (elmType)
{
case HEX8:
return HEX8_Mapping;
break;
case CAX4:
return HEX8_Mapping; // First four is identical to HEX8
break;
default:
//assert(false); // Element type not supported
break;
}
return NULL;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RifOdbReader::RifOdbReader()
{
if (++sm_instanceCount == 1)
{
odb_initializeAPI();
}
m_odb = NULL;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RifOdbReader::~RifOdbReader()
{
close();
if (--sm_instanceCount == 0)
{
odb_finalizeAPI();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RifOdbReader::close()
{
if (m_odb)
{
m_odb->close();
m_odb = NULL;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RifOdbReader::openFile(const std::string& fileName, std::string* errorMessage)
{
close();
CVF_ASSERT(m_odb == NULL);
odb_String path = fileName.c_str();
try
{
m_odb = &openOdb(path, true);
}
catch (const nex_Exception& nex)
{
if (errorMessage)
{
*errorMessage = nex.UserReport().CStr();
}
return false;
}
catch (...)
{
if (errorMessage)
{
std::stringstream errStr;
errStr << "Unable to open file '" << fileName << "'.";
*errorMessage = errStr.str();
}
return false;
}
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RifOdbReader::buildMetaData()
{
CVF_ASSERT(m_odb != NULL);
m_resultsMetaData = resultsMetaData(m_odb);
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::map<std::string, std::vector<std::string> > scalarFieldAndComponentNames(odb_Odb* odb, odb_Enum::odb_ResultPositionEnum resultPosition)
{
CVF_ASSERT(odb != NULL);
std::map<std::string, std::vector<std::string> > resultNamesMap;
odb_StepRepository stepRepository = odb->steps();
odb_StepRepositoryIT sIter(stepRepository);
for (sIter.first(); !sIter.isDone(); sIter.next())
{
odb_SequenceFrame& stepFrames = stepRepository[sIter.currentKey()].frames();
int numFrames = stepFrames.size();
for (int f = 0; f < numFrames; f++)
{
odb_Frame frame = stepFrames.constGet(f);
odb_FieldOutputRepository& fieldCon = frame.fieldOutputs();
odb_FieldOutputRepositoryIT fieldConIT(fieldCon);
for (fieldConIT.first(); !fieldConIT.isDone(); fieldConIT.next())
{
odb_FieldOutput& field = fieldCon[fieldConIT.currentKey()];
odb_SequenceFieldLocation fieldLocations = field.locations();
for (int loc = 0; loc < fieldLocations.size(); loc++)
{
const odb_FieldLocation& fieldLocation = fieldLocations.constGet(loc);
if (fieldLocation.position() == resultPosition)
{
std::string fieldName = field.name().CStr();
odb_SequenceString components = field.componentLabels();
std::vector<std::string> compVec;
int numComp = components.size();
for (int comp = 0; comp < numComp; comp++)
{
compVec.push_back(components[comp].CStr());
}
resultNamesMap.insert(std::make_pair(fieldName, compVec));
break;
}
}
}
}
}
return resultNamesMap;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::map< RifOdbReader::ResPos, std::map<std::string, std::vector<std::string> > > RifOdbReader::resultsMetaData(odb_Odb* odb)
{
CVF_ASSERT(odb != NULL);
std::map< ResPos, std::map<std::string, std::vector<std::string> > > resultsMap;
odb_StepRepository stepRepository = odb->steps();
odb_StepRepositoryIT sIter(stepRepository);
for (sIter.first(); !sIter.isDone(); sIter.next())
{
odb_SequenceFrame& stepFrames = stepRepository[sIter.currentKey()].frames();
int numFrames = stepFrames.size();
for (int f = 0; f < numFrames; f++)
{
odb_Frame frame = stepFrames.constGet(f);
odb_FieldOutputRepository& fieldCon = frame.fieldOutputs();
odb_FieldOutputRepositoryIT fieldConIT(fieldCon);
for (fieldConIT.first(); !fieldConIT.isDone(); fieldConIT.next())
{
odb_FieldOutput& field = fieldCon[fieldConIT.currentKey()];
odb_SequenceFieldLocation fieldLocations = field.locations();
for (int loc = 0; loc < fieldLocations.size(); loc++)
{
const odb_FieldLocation& fieldLocation = fieldLocations.constGet(loc);
std::string fieldName = field.name().CStr();
odb_SequenceString components = field.componentLabels();
std::vector<std::string> compVec;
int numComp = components.size();
for (int comp = 0; comp < numComp; comp++)
{
compVec.push_back(components[comp].CStr());
}
switch (fieldLocation.position())
{
case odb_Enum::NODAL:
resultsMap[NODAL][fieldName] = compVec;
break;
case odb_Enum::ELEMENT_NODAL:
resultsMap[ELEMENT_NODAL][fieldName] = compVec;
break;
case odb_Enum::INTEGRATION_POINT:
resultsMap[INTEGRATION_POINT][fieldName] = compVec;
resultsMap[ELEMENT_NODAL][fieldName] = compVec;
break;
default:
break;
}
}
}
}
}
return resultsMap;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RifOdbReader::readFemParts(RigFemPartCollection* femParts)
{
CVF_ASSERT(femParts);
CVF_ASSERT(m_odb != NULL);
odb_Assembly& rootAssembly = m_odb->rootAssembly();
odb_InstanceRepository instanceRepository = m_odb->rootAssembly().instances();
odb_InstanceRepositoryIT iter(instanceRepository);
int instanceCount = 0;
for (iter.first(); !iter.isDone(); iter.next(), instanceCount++)
{
odb_Instance& inst = instanceRepository[iter.currentKey()];
RigFemPart* femPart = new RigFemPart;
// Extract nodes
const odb_SequenceNode& odbNodes = inst.nodes();
std::map<int, int> nodeIdToIdxMap;
int nodeCount = odbNodes.size();
femPart->nodes().nodeIds.resize(nodeCount);
femPart->nodes().coordinates.resize(nodeCount);
for (int nIdx = 0; nIdx < nodeCount; ++nIdx)
{
const odb_Node odbNode = odbNodes.node(nIdx);
femPart->nodes().nodeIds[nIdx] = odbNode.label();
const float * pos = odbNode.coordinates();
femPart->nodes().coordinates[nIdx].set(pos[0], pos[1], pos[2]);
nodeIdToIdxMap[odbNode.label()] = nIdx;
}
// Keep node id to index map per instance
m_nodeIdToIdxMaps.push_back(nodeIdToIdxMap);
// Extract elements
const odb_SequenceElement& elements = inst.elements();
int elmCount = elements.size();
femPart->preAllocateElementStorage(elmCount);
std::map<std::string, RigElementType>::const_iterator it;
std::vector<int> indexBasedConnectivities;
std::map<int, int> elementIdToIdxMap;
for (int elmIdx = 0; elmIdx < elmCount; ++elmIdx)
{
const odb_Element odbElm = elements.element(elmIdx);
elementIdToIdxMap[odbElm.label()] = elmIdx;
RigElementType elmType = toRigElementType(odbElm.type());
if (elmType == UNKNOWN_ELM_TYPE) continue;
int nodeCount = 0;
const int* idBasedConnectivities = odbElm.connectivity(nodeCount);
CVF_TIGHT_ASSERT(nodeCount == RigFemTypes::elmentNodeCount(elmType));
indexBasedConnectivities.resize(nodeCount);
for (int lnIdx = 0; lnIdx < nodeCount; ++lnIdx)
{
indexBasedConnectivities[lnIdx] = nodeIdToIdxMap[idBasedConnectivities[lnIdx]];
}
femPart->appendElement(elmType, odbElm.label(), indexBasedConnectivities.data());
}
// Keep element id to index map per instance
m_elementIdToIdxMaps.push_back(elementIdToIdxMap);
femPart->setElementPartId(femParts->partCount());
femParts->addFemPart(femPart);
}
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<std::string> RifOdbReader::stepNames()
{
CVF_ASSERT(m_odb != NULL);
std::vector<std::string> stepNames;
odb_StepRepository stepRepository = m_odb->steps();
odb_StepRepositoryIT sIter(stepRepository);
for (sIter.first(); !sIter.isDone(); sIter.next())
{
stepNames.push_back(stepRepository[sIter.currentKey()].name().CStr());
}
return stepNames;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<double> RifOdbReader::frameTimes(int stepIndex)
{
CVF_ASSERT(m_odb != NULL);
odb_StepRepository& stepRepository = m_odb->steps();
odb_StepList stepList = stepRepository.stepList();
odb_Step& step = stepList.Get(stepIndex);
odb_SequenceFrame& stepFrames = step.frames();
std::vector<double> frameValues;
int numFrames = stepFrames.size();
for (int f = 0; f < numFrames; f++)
{
odb_Frame frame = stepFrames.constGet(f);
frameValues.push_back(frame.frameValue());
}
return frameValues;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::map<std::string, std::vector<std::string> > RifOdbReader::scalarNodeFieldAndComponentNames()
{
return fieldAndComponentNames(NODAL);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::map<std::string, std::vector<std::string> > RifOdbReader::scalarElementNodeFieldAndComponentNames()
{
return fieldAndComponentNames(ELEMENT_NODAL);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::map<std::string, std::vector<std::string> > RifOdbReader::scalarIntegrationPointFieldAndComponentNames()
{
return fieldAndComponentNames(INTEGRATION_POINT);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
odb_Frame RifOdbReader::stepFrame(int stepIndex, int frameIndex) const
{
CVF_ASSERT(m_odb);
odb_StepRepository& stepRepository = m_odb->steps();
odb_StepList stepList = stepRepository.stepList();
odb_Step& step = stepList.Get(stepIndex);
odb_SequenceFrame& stepFrames = step.frames();
return stepFrames.constGet(frameIndex);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
odb_Instance* RifOdbReader::instance(int instanceIndex)
{
CVF_ASSERT(m_odb != NULL);
odb_Assembly& rootAssembly = m_odb->rootAssembly();
odb_InstanceRepository& instanceRepository = m_odb->rootAssembly().instances();
odb_InstanceRepositoryIT iter(instanceRepository);
int instanceCount = 0;
for (iter.first(); !iter.isDone(); iter.next(), instanceCount++)
{
odb_Instance& inst = instanceRepository[iter.currentKey()];
if (instanceCount == instanceIndex)
{
return &inst;
}
}
return NULL;
}
//--------------------------------------------------------------------------------------------------
/// Get the number of result items (== #nodes or #elements)
//--------------------------------------------------------------------------------------------------
size_t RifOdbReader::resultItemCount(const std::string& fieldName, int partIndex, int stepIndex, int frameIndex)
{
odb_Instance* partInstance = instance(partIndex);
CVF_ASSERT(partInstance != NULL);
const odb_Frame& frame = stepFrame(stepIndex, frameIndex);
const odb_FieldOutput& instanceFieldOutput = frame.fieldOutputs()[fieldName.c_str()].getSubset(*partInstance);
const odb_SequenceFieldBulkData& seqFieldBulkData = instanceFieldOutput.bulkDataBlocks();
size_t resultItemCount = 0;
int numBlocks = seqFieldBulkData.size();
for (int block = 0; block < numBlocks; block++)
{
const odb_FieldBulkData& bulkData = seqFieldBulkData[block];
resultItemCount += bulkData.length();
}
return resultItemCount;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RifOdbReader::componentIndex(ResPos position, const std::string& fieldName, const std::string& componentName) const
{
std::vector<std::string> compNames = componentNames(position, fieldName);
for (size_t i = 0; i < compNames.size(); i++)
{
if (compNames[i] == componentName)
{
return i;
}
}
return 0;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<std::string> RifOdbReader::componentNames(ResPos position, const std::string& fieldName) const
{
std::vector<std::string> compNames;
std::map< ResPos, std::map<std::string, std::vector<std::string> > >::const_iterator posMapIt = m_resultsMetaData.find(position);
if (posMapIt != m_resultsMetaData.end())
{
std::map<std::string, std::vector<std::string> >::const_iterator fieldNameMapIt = posMapIt->second.find(fieldName);
if (fieldNameMapIt != posMapIt->second.end())
{
compNames = fieldNameMapIt->second;
}
}
return compNames;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::map<std::string, std::vector<std::string> > RifOdbReader::fieldAndComponentNames(ResPos position)
{
if (m_resultsMetaData.empty())
{
buildMetaData();
}
return m_resultsMetaData[position];
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RifOdbReader::readScalarNodeField(const std::string& fieldName, const std::string& componentName, int partIndex, int stepIndex, int frameIndex, std::vector<float>* resultValues)
{
CVF_ASSERT(resultValues);
odb_Instance* partInstance = instance(partIndex);
CVF_ASSERT(partInstance != NULL);
std::map<int, int>& nodeIdToIdxMap = m_nodeIdToIdxMaps[partIndex];
size_t dataSize = nodeIdToIdxMap.size();
CVF_ASSERT(dataSize > 0);
resultValues->resize(dataSize);
resultValues->assign(dataSize, std::numeric_limits<float>::infinity());
int compIndex = componentIndex(NODAL, fieldName, componentName);
CVF_ASSERT(compIndex >= 0);
const odb_Frame& frame = stepFrame(stepIndex, frameIndex);
const odb_FieldOutput& instanceFieldOutput = frame.fieldOutputs()[fieldName.c_str()].getSubset(*partInstance);
const odb_FieldOutput& fieldOutput = instanceFieldOutput.getSubset(odb_Enum::NODAL);
const odb_SequenceFieldBulkData& seqFieldBulkData = fieldOutput.bulkDataBlocks();
size_t dataIndex = 0;
int numBlocks = seqFieldBulkData.size();
for (int block = 0; block < numBlocks; block++)
{
const odb_FieldBulkData& bulkData = seqFieldBulkData[block];
int numNodes = bulkData.length();
int numComp = bulkData.width();
float* data = bulkData.data();
int* nodeLabels = bulkData.nodeLabels();
for (int i = 0; i < numNodes; i++)
{
(*resultValues)[nodeIdToIdxMap[nodeLabels[i]]] = data[i*numComp + compIndex];
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RifOdbReader::readScalarElementNodeField(const std::string& fieldName, const std::string& componentName, int partIndex, int stepIndex, int frameIndex, std::vector<float>* resultValues)
{
CVF_ASSERT(resultValues);
odb_Instance* partInstance = instance(partIndex);
CVF_ASSERT(partInstance != NULL);
std::map<int, int>& elementIdToIdxMap = m_elementIdToIdxMaps[partIndex];
CVF_ASSERT(elementIdToIdxMap.size() > 0);
size_t dataSize = resultItemCount(fieldName, partIndex, stepIndex, frameIndex);
if (dataSize > 0)
{
resultValues->resize(dataSize);
resultValues->assign(dataSize, std::numeric_limits<float>::infinity());
}
int compIndex = componentIndex(ELEMENT_NODAL, fieldName, componentName);
CVF_ASSERT(compIndex >= 0);
const odb_Frame& frame = stepFrame(stepIndex, frameIndex);
const odb_FieldOutput& instanceFieldOutput = frame.fieldOutputs()[fieldName.c_str()].getSubset(*partInstance);
const odb_FieldOutput& fieldOutput = instanceFieldOutput.getSubset(odb_Enum::ELEMENT_NODAL);
const odb_SequenceFieldBulkData& seqFieldBulkData = fieldOutput.bulkDataBlocks();
size_t dataIndex = 0;
int numBlocks = seqFieldBulkData.size();
for (int block = 0; block < numBlocks; block++)
{
const odb_FieldBulkData& bulkData = seqFieldBulkData[block];
int numValues = bulkData.length();
int numComp = bulkData.width();
float* data = bulkData.data();
int elemCount = bulkData.numberOfElements();
int elemNodeCount = numValues/elemCount;
int* elementLabels = bulkData.elementLabels();
for (int elem = 0; elem < elemCount; elem++)
{
int elementIdx = elementIdToIdxMap[elementLabels[elem*elemNodeCount]];
int elementResultStartDestIdx = elementIdx*elemNodeCount; // Ikke generellt riktig !
int elementResultStartSourceIdx = elem*elemNodeCount*numComp;
for (int elemNode = 0; elemNode < elemNodeCount; elemNode++)
{
int destIdx = elementResultStartDestIdx + elemNode;
int srcIdx = elementResultStartSourceIdx + elemNode*numComp + compIndex;
(*resultValues)[destIdx] = data[srcIdx];
}
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RifOdbReader::readScalarIntegrationPointField(const std::string& fieldName, const std::string& componentName, int partIndex, int stepIndex, int frameIndex, std::vector<float>* resultValues)
{
CVF_ASSERT(resultValues);
odb_Instance* partInstance = instance(partIndex);
CVF_ASSERT(partInstance != NULL);
std::map<int, int>& elementIdToIdxMap = m_elementIdToIdxMaps[partIndex];
CVF_ASSERT(elementIdToIdxMap.size() > 0);
size_t dataSize = resultItemCount(fieldName, partIndex, stepIndex, frameIndex);
if (dataSize > 0)
{
resultValues->resize(dataSize);
resultValues->assign(dataSize, std::numeric_limits<float>::infinity());
}
int compIndex = componentIndex(INTEGRATION_POINT, fieldName, componentName);
CVF_ASSERT(compIndex >= 0);
const odb_Frame& frame = stepFrame(stepIndex, frameIndex);
const odb_FieldOutput& instanceFieldOutput = frame.fieldOutputs()[fieldName.c_str()].getSubset(*partInstance);
const odb_FieldOutput& fieldOutput = instanceFieldOutput.getSubset(odb_Enum::INTEGRATION_POINT);
const odb_SequenceFieldBulkData& seqFieldBulkData = fieldOutput.bulkDataBlocks();
size_t dataIndex = 0;
int numBlocks = seqFieldBulkData.size();
for (int block = 0; block < numBlocks; block++)
{
const odb_FieldBulkData& bulkData = seqFieldBulkData[block];
int numValues = bulkData.length();
int numComp = bulkData.width();
float* data = bulkData.data();
int elemCount = bulkData.numberOfElements();
int ipCount = numValues/elemCount;
int* elementLabels = bulkData.elementLabels();
RigElementType eType = toRigElementType(bulkData.baseElementType());
const int* elmNodeToIpResultMapping = localElmNodeToIntegrationPointMapping(eType);
if (!elmNodeToIpResultMapping) continue;
for (int elem = 0; elem < elemCount; elem++)
{
int elementIdx = elementIdToIdxMap[elementLabels[elem*ipCount]];
int elementResultStartDestIdx = elementIdx*ipCount; // Ikke generellt riktig !
int elementResultStartSourceIdx = elem*ipCount*numComp;
for (int ipIdx = 0; ipIdx < ipCount; ipIdx++)
{
int resultIpIdx = elmNodeToIpResultMapping[ipIdx];
int destIdx = elementResultStartDestIdx + ipIdx;
int srcIdx = elementResultStartSourceIdx + resultIpIdx*numComp + compIndex;
(*resultValues)[destIdx] = data[srcIdx];
}
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RifOdbReader::readDisplacements(int partIndex, int stepIndex, int frameIndex, std::vector<cvf::Vec3f>* displacements)
{
CVF_ASSERT(displacements);
odb_Instance* partInstance = instance(partIndex);
CVF_ASSERT(partInstance != NULL);
size_t dataSize = resultItemCount("U", partIndex, stepIndex, frameIndex);
if (dataSize > 0)
{
displacements->resize(dataSize);
}
const odb_Frame& frame = stepFrame(stepIndex, frameIndex);
const odb_FieldOutput& instanceFieldOutput = frame.fieldOutputs()["U"].getSubset(*partInstance);
const odb_SequenceFieldBulkData& seqFieldBulkData = instanceFieldOutput.bulkDataBlocks();
size_t dataIndex = 0;
int numBlocks = seqFieldBulkData.size();
for (int block = 0; block < numBlocks; block++)
{
const odb_FieldBulkData& bulkData = seqFieldBulkData[block];
if (bulkData.numberOfNodes() > 0)
{
int numNodes = bulkData.length();
int numComp = bulkData.width();
float* data = bulkData.data();
for (int i = 0; i < numNodes; i++)
{
(*displacements)[i + dataIndex].set(data[i*numComp], data[i*numComp + 1], data[i*numComp + 2]);
}
dataIndex += numNodes*numComp;
}
}
}
@@ -0,0 +1,86 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions 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 "RifGeoMechReaderInterface.h"
#include <string>
#include <map>
class RigFemPartCollection;
class odb_Odb;
class odb_Frame;
class odb_Instance;
//==================================================================================================
//
// Data interface base class
//
//==================================================================================================
class RifOdbReader : public RifGeoMechReaderInterface
{
public:
RifOdbReader();
virtual ~RifOdbReader();
virtual bool openFile(const std::string& fileName, std::string* errorMessage = 0);
virtual bool readFemParts(RigFemPartCollection* geoMechCase);
virtual std::vector<std::string> stepNames();
virtual std::vector<double> frameTimes(int stepIndex);
virtual std::map<std::string, std::vector<std::string> > scalarNodeFieldAndComponentNames();
virtual std::map<std::string, std::vector<std::string> > scalarElementNodeFieldAndComponentNames();
virtual std::map<std::string, std::vector<std::string> > scalarIntegrationPointFieldAndComponentNames();
virtual void readScalarNodeField(const std::string& fieldName, const std::string& componmentName, int partIndex, int stepIndex, int frameIndex, std::vector<float>* resultValues);
virtual void readScalarElementNodeField(const std::string& fieldName, const std::string& componmentName, int partIndex, int stepIndex, int frameIndex, std::vector<float>* resultValues);
virtual void readScalarIntegrationPointField(const std::string& fieldName, const std::string& componmentName, int partIndex, int stepIndex, int frameIndex, std::vector<float>* resultValues);
virtual void readDisplacements(int partIndex, int stepIndex, int frameIndex, std::vector<cvf::Vec3f>* displacements);
private:
enum ResPos
{
NODAL,
ELEMENT_NODAL,
INTEGRATION_POINT
};
bool buildMetaData();
void close();
size_t resultItemCount(const std::string& fieldName, int partIndex, int stepIndex, int frameIndex);
odb_Frame stepFrame(int stepIndex, int frameIndex) const;
odb_Instance* instance(int instanceIndex);
int componentIndex(ResPos position, const std::string& fieldName, const std::string& componentName) const;
std::vector<std::string> componentNames(ResPos position, const std::string& fieldName) const;
std::map<std::string, std::vector<std::string> > fieldAndComponentNames(ResPos position);
std::map< RifOdbReader::ResPos, std::map<std::string, std::vector<std::string> > > resultsMetaData(odb_Odb* odb);
private:
odb_Odb* m_odb;
std::map< ResPos, std::map<std::string, std::vector<std::string> > > m_resultsMetaData;
std::vector< std::map<int, int> > m_nodeIdToIdxMaps;
std::vector< std::map<int, int> > m_elementIdToIdxMaps;
static size_t sm_instanceCount;
};
@@ -0,0 +1,34 @@
cmake_minimum_required (VERSION 2.8)
project ( OdbReader_UnitTests )
set(RI_VIZ_FWK_ROOT ../../../Fwk/VizFwk CACHE PATH "Path to VizFwk")
set(RI_GTEST_ROOT ../../../ThirdParty CACHE PATH "Path to folder containing gtest folder")
set(RI_TEST_FILE "" CACHE FILEPATH "Path to test file")
include(${RI_VIZ_FWK_ROOT}/CMake/Utils/ceeDetermineCompilerFlags.cmake)
add_subdirectory(${RI_VIZ_FWK_ROOT}/LibCore buildVizFwk)
add_subdirectory(../../ResultStatisticsCache buildResultStatisticsCache)
add_subdirectory(../OdbReader buildOdbReader)
add_subdirectory(../GeoMechDataModel buildGeoMechDataModel)
add_definitions( -DTEST_FILE="${RI_TEST_FILE}")
include_directories(${RI_VIZ_FWK_ROOT}/LibCore)
include_directories(../../ResultStatisticsCache)
include_directories(../../ReservoirDataModel)
include_directories(../OdbReader)
include_directories(../GeoMechDataModel)
include_directories(${RI_GTEST_ROOT})
set( UNIT_TEST_CPP_SOURCES
main.cpp
RifOdbReader-Test.cpp
${RI_GTEST_ROOT}/gtest/gtest-all.cc
)
add_executable( ${PROJECT_NAME} ${UNIT_TEST_CPP_SOURCES} )
target_link_libraries( ${PROJECT_NAME} RifOdbReader)
include(../OdbReader/OdbSetup.cmake)
@@ -0,0 +1,125 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions AS
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "gtest/gtest.h"
#include "RifOdbReader.h"
#include "RigGeoMechCaseData.h"
#include "RigFemPartCollection.h"
#include "cvfDebugTimer.h"
#include <vector>
#include <string>
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
TEST(OdbReaderTest, BasicTests)
{
std::cout << TEST_FILE << std::endl;
std::cout << std::endl;
cvf::ref<RifOdbReader> reader = new RifOdbReader;
cvf::ref<RigGeoMechCaseData> femCase = new RigGeoMechCaseData("");
cvf::ref<RigFemPartCollection> femData = femCase->femParts();
cvf::DebugTimer timer("DebugTimer");
timer.reportTime();
reader->openFile(TEST_FILE);
reader->readFemParts(femData.p());
EXPECT_EQ(1, femData->partCount());
EXPECT_EQ(4320, femData->part(0)->elementCount());
EXPECT_EQ(HEX8, femData->part(0)->elementType(0));
EXPECT_EQ(true, reader->stepNames().size() == 1);
std::vector<std::string> steps = reader->stepNames();
EXPECT_EQ(true, steps.at(0).find("Date_20100930") >= 0);
EXPECT_EQ(2, reader->frameTimes(0).size());
EXPECT_EQ(1.0, reader->frameTimes(0)[1]);
std::map<std::string, std::vector<std::string> > scalarNodeFieldsMap = reader->scalarNodeFieldAndComponentNames();
EXPECT_EQ(3, scalarNodeFieldsMap.size());
std::map<std::string, std::vector<std::string> > scalarElementNodeFieldsMap = reader->scalarElementNodeFieldAndComponentNames();
EXPECT_EQ(0, scalarElementNodeFieldsMap.size());
std::map<std::string, std::vector<std::string> > scalarIntegrationPointFieldsMap = reader->scalarIntegrationPointFieldAndComponentNames();
EXPECT_EQ(6, scalarIntegrationPointFieldsMap.size());
std::vector<float> displacementValues;
reader->readScalarNodeField("U", "U2", 0, 0, 1, &displacementValues);
EXPECT_EQ(5168, displacementValues.size());
std::vector<float> integrationPointS22;
timer.restart();
reader->readScalarIntegrationPointField("S", "S22", 0, 0, 1, &integrationPointS22);
timer.reportLapTime("Read S/S22");
timer.restart();
reader->readScalarIntegrationPointField("S", "S22", 0, 0, 1, &integrationPointS22);
timer.reportLapTime("Read S/S22 2nd time");
timer.restart();
reader->readScalarIntegrationPointField("S", "S22", 0, 0, 1, &integrationPointS22);
timer.reportLapTime("Read S/S22 3rd time");
EXPECT_EQ(34560, integrationPointS22.size());
EXPECT_FLOAT_EQ(-1921117.3, integrationPointS22[0]);
EXPECT_FLOAT_EQ(-1408592.5, integrationPointS22[1]);
EXPECT_FLOAT_EQ(-1345666.9, integrationPointS22[2]);
std::vector<float> elementNodeS11;
reader->readScalarElementNodeField("S", "S11", 0, 0, 1, &elementNodeS11);
EXPECT_EQ(34560, elementNodeS11.size());
EXPECT_FLOAT_EQ(-2074357.3, elementNodeS11[0]);
EXPECT_FLOAT_EQ(-1353137.5, elementNodeS11[1]);
EXPECT_FLOAT_EQ(-1144559.4, elementNodeS11[2]);
std::vector<float> integrationPointE33;
reader->readScalarIntegrationPointField("E", "E33", 0, 0, 1, &integrationPointE33);
EXPECT_EQ(34560, integrationPointE33.size());
std::vector<float> integrationPointTEMP;
reader->readScalarIntegrationPointField("TEMP", "", 0, 0, 1, &integrationPointTEMP);
EXPECT_EQ(34560, integrationPointTEMP.size());
std::vector<cvf::Vec3f> displacements;
reader->readDisplacements(0, 0, 1, &displacements);
EXPECT_EQ(5168, displacements.size());
EXPECT_FLOAT_EQ(0.047638997, displacements[1].y());
EXPECT_FLOAT_EQ(-0.0036307564, displacements[6].x());
EXPECT_FLOAT_EQ(0.065709047, displacements[6].y());
EXPECT_FLOAT_EQ(-0.059760433, displacements[6].z());
std::vector<float> porValues;
reader->readScalarNodeField("POR", "", 0, 0, 1, &porValues);
EXPECT_EQ(5168, porValues.size());
std::vector<float> voidrValues;
reader->readScalarIntegrationPointField("VOIDR", "", 0, 0, 0, &voidrValues);
EXPECT_EQ(34560, voidrValues.size());
EXPECT_FLOAT_EQ(0.22864963, voidrValues[0]);
EXPECT_FLOAT_EQ(0.23406270, voidrValues[1]);
EXPECT_FLOAT_EQ(0.24549910, voidrValues[2]);
timer.restart();
reader->readScalarIntegrationPointField("S", "S22", 0, 0, 1, &integrationPointS22);
timer.reportLapTime("Read S/S22 final time");
}
@@ -0,0 +1,42 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2015 - Statoil ASA
// Copyright (C) 2015 - Ceetron Solutions 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 "gtest/gtest.h"
#include <stdio.h>
#include "cvfTrace.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int main(int argc, char **argv)
{
cvf::Assert::setReportMode(cvf::Assert::CONSOLE);
testing::InitGoogleTest(&argc, argv);
int result = RUN_ALL_TESTS();
std::cout << "Please press <Enter> to close the window.";
std::cin.get();
return result;
}
@@ -66,4 +66,4 @@ list(APPEND CODE_SOURCE_FILES
${SOURCE_GROUP_SOURCE_FILES}
)
source_group( "ModelVisualization" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} )
source_group( "ModelVisualization" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CEE_CURRENT_LIST_DIR}CMakeLists_files.cmake )
@@ -26,7 +26,7 @@
#include "RigGridBase.h"
#include "RigResultAccessor.h"
#include "RigResultAccessorFactory.h"
#include "RimCase.h"
#include "RimEclipseCase.h"
#include "RimCellEdgeResultSlot.h"
#include "RimReservoirView.h"
#include "RimResultSlot.h"
@@ -26,7 +26,7 @@
#include "RigCaseData.h"
#include "RigResultAccessor.h"
#include "RimCase.h"
#include "RimEclipseCase.h"
#include "RimFaultCollection.h"
#include "RimReservoirView.h"
#include "RimResultSlot.h"
@@ -27,7 +27,7 @@
#include "RigCaseData.h"
#include "RigResultAccessorFactory.h"
#include "RimCase.h"
#include "RimEclipseCase.h"
#include "RimCellEdgeResultSlot.h"
#include "RimReservoirCellResultsStorage.h"
#include "RimReservoirView.h"
@@ -31,7 +31,7 @@
#include "RimFaultResultSlot.h"
#include "RimReservoirView.h"
#include "RimResultSlot.h"
#include "RimCase.h"
#include "RimEclipseCase.h"
#include "RigCaseData.h"
//--------------------------------------------------------------------------------------------------
@@ -28,7 +28,7 @@
#include "RigResultAccessorFactory.h"
#include "Rim3dOverlayInfoConfig.h"
#include "RimCase.h"
#include "RimEclipseCase.h"
#include "RimCellEdgeResultSlot.h"
#include "RimCellPropertyFilterCollection.h"
#include "RimCellRangeFilterCollection.h"
@@ -37,7 +37,6 @@ public:
RivReservoirViewPartMgr(RimReservoirView * resv);
cvf::Transform* scaleTransform() { return m_scaleTransform.p();}
void setScaleTransform(cvf::Mat4d scale) { m_scaleTransform->setLocalTransform(scale);}
enum ReservoirGeometryCacheType
{
@@ -25,7 +25,7 @@
#include "RigResultAccessorFactory.h"
#include "RigTernaryResultAccessor2d.h"
#include "RimCase.h"
#include "RimEclipseCase.h"
#include "RimReservoirView.h"
#include "RimResultSlot.h"
#include "RimTernaryLegendConfig.h"
@@ -22,7 +22,7 @@
#include "RimResultSlot.h"
#include "RigCaseData.h"
#include "RimReservoirView.h"
#include "RimCase.h"
#include "RimEclipseCase.h"
#include "RigCaseCellResultsData.h"
#include "RigResultAccessorFactory.h"
#include "RigPipeInCellEvaluator.h"
@@ -47,7 +47,7 @@
#include "RimResultSlot.h"
#include "RimLegendConfig.h"
#include "RimCase.h"
#include "RimEclipseCase.h"
#include "RimWell.h"
#include "RigCaseData.h"
@@ -22,7 +22,7 @@
#include "cvfLibCore.h"
#include "RiaApplication.h"
#include "RimCase.h"
#include "RimEclipseCase.h"
#include "RimProject.h"
#include "RimWellPathCollection.h"
#include "RimReservoirCellResultsStorage.h"
@@ -36,7 +36,7 @@
#include "RigCell.h"
#include "RivPipeGeometryGenerator.h"
#include "RimCase.h"
#include "RimEclipseCase.h"
#include "RimReservoirView.h"
#include "RimWell.h"
#include "RimWellCollection.h"
@@ -16,7 +16,7 @@ ${CEE_CURRENT_LIST_DIR}RimDefines.h
${CEE_CURRENT_LIST_DIR}RimLegendConfig.h
${CEE_CURRENT_LIST_DIR}RimOilField.h
${CEE_CURRENT_LIST_DIR}RimProject.h
${CEE_CURRENT_LIST_DIR}RimCase.h
${CEE_CURRENT_LIST_DIR}RimEclipseCase.h
${CEE_CURRENT_LIST_DIR}RimIdenticalGridCaseGroup.h
${CEE_CURRENT_LIST_DIR}RimInputProperty.h
${CEE_CURRENT_LIST_DIR}RimInputPropertyCollection.h
@@ -51,6 +51,12 @@ ${CEE_CURRENT_LIST_DIR}RimTernaryLegendConfig.h
${CEE_CURRENT_LIST_DIR}RimFaultResultSlot.h
${CEE_CURRENT_LIST_DIR}RimNoCommonAreaNNC.h
${CEE_CURRENT_LIST_DIR}RimNoCommonAreaNncCollection.h
${CEE_CURRENT_LIST_DIR}RimGeoMechModels.h
${CEE_CURRENT_LIST_DIR}RimGeoMechCase.h
${CEE_CURRENT_LIST_DIR}RimGeoMechView.h
${CEE_CURRENT_LIST_DIR}RimGeoMechResultSlot.h
${CEE_CURRENT_LIST_DIR}RimView.h
${CEE_CURRENT_LIST_DIR}RimCase.h
)
set (SOURCE_GROUP_SOURCE_FILES
@@ -65,7 +71,7 @@ ${CEE_CURRENT_LIST_DIR}RimDefines.cpp
${CEE_CURRENT_LIST_DIR}RimLegendConfig.cpp
${CEE_CURRENT_LIST_DIR}RimOilField.cpp
${CEE_CURRENT_LIST_DIR}RimProject.cpp
${CEE_CURRENT_LIST_DIR}RimCase.cpp
${CEE_CURRENT_LIST_DIR}RimEclipseCase.cpp
${CEE_CURRENT_LIST_DIR}RimIdenticalGridCaseGroup.cpp
${CEE_CURRENT_LIST_DIR}RimInputProperty.cpp
${CEE_CURRENT_LIST_DIR}RimInputPropertyCollection.cpp
@@ -100,6 +106,12 @@ ${CEE_CURRENT_LIST_DIR}RimTernaryLegendConfig.cpp
${CEE_CURRENT_LIST_DIR}RimFaultResultSlot.cpp
${CEE_CURRENT_LIST_DIR}RimNoCommonAreaNNC.cpp
${CEE_CURRENT_LIST_DIR}RimNoCommonAreaNncCollection.cpp
${CEE_CURRENT_LIST_DIR}RimGeoMechModels.cpp
${CEE_CURRENT_LIST_DIR}RimGeoMechCase.cpp
${CEE_CURRENT_LIST_DIR}RimGeoMechView.cpp
${CEE_CURRENT_LIST_DIR}RimGeoMechResultSlot.cpp
${CEE_CURRENT_LIST_DIR}RimView.cpp
${CEE_CURRENT_LIST_DIR}RimCase.cpp
)
list(APPEND CODE_HEADER_FILES
@@ -110,4 +122,4 @@ list(APPEND CODE_SOURCE_FILES
${SOURCE_GROUP_SOURCE_FILES}
)
source_group( "ProjectDataModel" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} )
source_group( "ProjectDataModel" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CEE_CURRENT_LIST_DIR}CMakeLists_files.cmake )
@@ -22,7 +22,7 @@
#include "RigCaseCellResultsData.h"
#include "RigCaseData.h"
#include "RimCase.h"
#include "RimEclipseCase.h"
#include "RimCellEdgeResultSlot.h"
#include "RimCellPropertyFilterCollection.h"
#include "RimFaultCollection.h"
@@ -32,6 +32,8 @@
#include "RimResultSlot.h"
#include "RimWellCollection.h"
#include "RiuViewer.h"
#include "RimGeoMechView.h"
#include "RimView.h"
CAF_PDM_SOURCE_INIT(Rim3dOverlayInfoConfig, "View3dOverlayInfoConfig");
@@ -65,9 +67,9 @@ void Rim3dOverlayInfoConfig::fieldChangedByUi(const caf::PdmFieldHandle* changed
{
this->update3DInfo();
if (m_reservoirView && m_reservoirView->viewer())
if (m_viewDef && m_viewDef->viewer())
{
m_reservoirView->viewer()->update();
m_viewDef->viewer()->update();
}
}
@@ -86,22 +88,49 @@ void Rim3dOverlayInfoConfig::update3DInfo()
{
this->updateUiIconFromToggleField();
if (!m_reservoirView) return;
if (!m_reservoirView->viewer()) return;
if (!m_viewDef) return;
if (!m_viewDef->viewer()) return;
if (!this->active())
{
m_reservoirView->viewer()->showInfoText(false);
m_reservoirView->viewer()->showHistogram(false);
m_reservoirView->viewer()->showAnimationProgress(false);
m_viewDef->viewer()->showInfoText(false);
m_viewDef->viewer()->showHistogram(false);
m_viewDef->viewer()->showAnimationProgress(false);
return;
}
m_reservoirView->viewer()->showInfoText(showInfoText());
m_reservoirView->viewer()->showHistogram(false);
m_reservoirView->viewer()->showAnimationProgress(showAnimProgress());
m_viewDef->viewer()->showInfoText(showInfoText());
m_viewDef->viewer()->showHistogram(false);
m_viewDef->viewer()->showAnimationProgress(showAnimProgress());
RimReservoirView * reservoirView = dynamic_cast<RimReservoirView*>(m_viewDef.p());
if (reservoirView) updateReservoir3DInfo(reservoirView);
RimGeoMechView * geoMechView = dynamic_cast<RimGeoMechView*>(m_viewDef.p());
if (geoMechView) updateGeoMech3DInfo(geoMechView);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::PdmFieldHandle* Rim3dOverlayInfoConfig::objectToggleField()
{
return &active;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void Rim3dOverlayInfoConfig::setReservoirView(RimView* ownerReservoirView)
{
m_viewDef = ownerReservoirView;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void Rim3dOverlayInfoConfig::updateReservoir3DInfo(RimReservoirView * reservoirView)
{
if (showInfoText())
{
QString caseName;
@@ -115,64 +144,64 @@ void Rim3dOverlayInfoConfig::update3DInfo()
QString faultCellResultMapping;
if (m_reservoirView->eclipseCase() && m_reservoirView->eclipseCase()->reservoirData() && m_reservoirView->eclipseCase()->reservoirData()->mainGrid())
if (reservoirView->eclipseCase() && reservoirView->eclipseCase()->reservoirData() && reservoirView->eclipseCase()->reservoirData()->mainGrid())
{
caseName = m_reservoirView->eclipseCase()->caseUserDescription();
totCellCount = QString::number(m_reservoirView->eclipseCase()->reservoirData()->mainGrid()->cells().size());
size_t mxActCellCount = m_reservoirView->eclipseCase()->reservoirData()->activeCellInfo(RifReaderInterface::MATRIX_RESULTS)->reservoirActiveCellCount();
size_t frActCellCount = m_reservoirView->eclipseCase()->reservoirData()->activeCellInfo(RifReaderInterface::FRACTURE_RESULTS)->reservoirActiveCellCount();
caseName = reservoirView->eclipseCase()->caseUserDescription();
totCellCount = QString::number(reservoirView->eclipseCase()->reservoirData()->mainGrid()->cells().size());
size_t mxActCellCount = reservoirView->eclipseCase()->reservoirData()->activeCellInfo(RifReaderInterface::MATRIX_RESULTS)->reservoirActiveCellCount();
size_t frActCellCount = reservoirView->eclipseCase()->reservoirData()->activeCellInfo(RifReaderInterface::FRACTURE_RESULTS)->reservoirActiveCellCount();
if (frActCellCount > 0) activeCellCountText += "Matrix : ";
activeCellCountText += QString::number(mxActCellCount);
if (frActCellCount > 0) activeCellCountText += " Fracture : " + QString::number(frActCellCount);
iSize = QString::number(m_reservoirView->eclipseCase()->reservoirData()->mainGrid()->cellCountI());
jSize = QString::number(m_reservoirView->eclipseCase()->reservoirData()->mainGrid()->cellCountJ());
kSize = QString::number(m_reservoirView->eclipseCase()->reservoirData()->mainGrid()->cellCountK());
iSize = QString::number(reservoirView->eclipseCase()->reservoirData()->mainGrid()->cellCountI());
jSize = QString::number(reservoirView->eclipseCase()->reservoirData()->mainGrid()->cellCountJ());
kSize = QString::number(reservoirView->eclipseCase()->reservoirData()->mainGrid()->cellCountK());
zScale = QString::number(m_reservoirView->scaleZ());
zScale = QString::number(reservoirView->scaleZ());
propName = m_reservoirView->cellResult()->resultVariable();
cellEdgeName = m_reservoirView->cellEdgeResult()->resultVariable();
propName = reservoirView->cellResult()->resultVariable();
cellEdgeName = reservoirView->cellEdgeResult()->resultVariable();
}
QString infoText = QString(
"<p><b><center>-- %1 --</center></b><p> "
"<b>Cell count. Total:</b> %2 <b>Active:</b> %3 <br>"
"<b>Cell count. Total:</b> %2 <b>Active:</b> %3 <br>"
"<b>Main Grid I,J,K:</b> %4, %5, %6 <b>Z-Scale:</b> %7<br>").arg(caseName, totCellCount, activeCellCountText, iSize, jSize, kSize, zScale);
if (m_reservoirView->cellResult()->isTernarySaturationSelected())
if (reservoirView->cellResult()->isTernarySaturationSelected())
{
infoText += QString("<b>Cell Property:</b> %1 ").arg(propName);
}
if (m_reservoirView->animationMode() && m_reservoirView->cellResult()->hasResult())
if (reservoirView->animationMode() && reservoirView->cellResult()->hasResult())
{
infoText += QString("<b>Cell Property:</b> %1 ").arg(propName);
double min, max;
double p10, p90;
double mean;
size_t scalarIndex = m_reservoirView->cellResult()->scalarResultIndex();
m_reservoirView->currentGridCellResults()->cellResults()->minMaxCellScalarValues(scalarIndex, min, max);
m_reservoirView->currentGridCellResults()->cellResults()->p10p90CellScalarValues(scalarIndex, p10, p90);
m_reservoirView->currentGridCellResults()->cellResults()->meanCellScalarValues(scalarIndex, mean);
size_t scalarIndex = reservoirView->cellResult()->scalarResultIndex();
reservoirView->currentGridCellResults()->cellResults()->minMaxCellScalarValues(scalarIndex, min, max);
reservoirView->currentGridCellResults()->cellResults()->p10p90CellScalarValues(scalarIndex, p10, p90);
reservoirView->currentGridCellResults()->cellResults()->meanCellScalarValues(scalarIndex, mean);
//infoText += QString("<blockquote><b>Min:</b> %1 <b>P10:</b> %2 <b>Mean:</b> %3 <b>P90:</b> %4 <b>Max:</b> %5 </blockquote>").arg(min).arg(p10).arg(mean).arg(p90).arg(max);
//infoText += QString("<blockquote><pre>Min: %1 P10: %2 Mean: %3 \n P90: %4 Max: %5 </pre></blockquote>").arg(min).arg(p10).arg(mean).arg(p90).arg(max);
infoText += QString("<table border=0 cellspacing=5 ><tr><td>Min</td><td>P10</td> <td>Mean</td> <td>P90</td> <td>Max</td> </tr>"
"<tr><td>%1</td><td> %2</td><td> %3</td><td> %4</td><td> %5 </td></tr></table>").arg(min).arg(p10).arg(mean).arg(p90).arg(max);
infoText += QString("<table border=0 cellspacing=5 ><tr><td>Min</td><td>P10</td> <td>Mean</td> <td>P90</td> <td>Max</td> </tr>"
"<tr><td>%1</td><td> %2</td><td> %3</td><td> %4</td><td> %5 </td></tr></table>").arg(min).arg(p10).arg(mean).arg(p90).arg(max);
if (m_reservoirView->faultResultSettings()->hasValidCustomResult())
if (reservoirView->faultResultSettings()->hasValidCustomResult())
{
QString faultMapping;
bool isShowingGrid = m_reservoirView->faultCollection()->isGridVisualizationMode();
bool isShowingGrid = reservoirView->faultCollection()->isGridVisualizationMode();
if (!isShowingGrid)
{
if (m_reservoirView->faultCollection()->faultResult() == RimFaultCollection::FAULT_BACK_FACE_CULLING)
if (reservoirView->faultCollection()->faultResult() == RimFaultCollection::FAULT_BACK_FACE_CULLING)
{
faultMapping = "Cells behind fault";
}
else if (m_reservoirView->faultCollection()->faultResult() == RimFaultCollection::FAULT_FRONT_FACE_CULLING)
else if (reservoirView->faultCollection()->faultResult() == RimFaultCollection::FAULT_FRONT_FACE_CULLING)
{
faultMapping = "Cells in front of fault";
}
@@ -188,7 +217,7 @@ void Rim3dOverlayInfoConfig::update3DInfo()
infoText += QString("<b>Fault results: </b> %1<br>").arg(faultMapping);
infoText += QString("<b>Fault Property:</b> %1 <br>").arg(m_reservoirView->faultResultSettings()->customFaultResult()->resultVariable());
infoText += QString("<b>Fault Property:</b> %1 <br>").arg(reservoirView->faultResultSettings()->customFaultResult()->resultVariable());
}
}
else
@@ -197,43 +226,43 @@ void Rim3dOverlayInfoConfig::update3DInfo()
}
if (m_reservoirView->animationMode() && m_reservoirView->cellEdgeResult()->hasResult())
if (reservoirView->animationMode() && reservoirView->cellEdgeResult()->hasResult())
{
double min, max;
m_reservoirView->cellEdgeResult()->minMaxCellEdgeValues(min, max);
reservoirView->cellEdgeResult()->minMaxCellEdgeValues(min, max);
infoText += QString("<b>Cell Edge Property:</b> %1 <blockquote>Min: %2 Max: %3 </blockquote>").arg(cellEdgeName).arg(min).arg(max);
}
if ( m_reservoirView->cellResult()->hasDynamicResult()
|| m_reservoirView->propertyFilterCollection()->hasActiveDynamicFilters()
|| m_reservoirView->wellCollection()->hasVisibleWellPipes()
|| m_reservoirView->cellResult()->isTernarySaturationSelected())
if (reservoirView->cellResult()->hasDynamicResult()
|| reservoirView->propertyFilterCollection()->hasActiveDynamicFilters()
|| reservoirView->wellCollection()->hasVisibleWellPipes()
|| reservoirView->cellResult()->isTernarySaturationSelected())
{
int currentTimeStep = m_reservoirView->currentTimeStep();
QDateTime date = m_reservoirView->currentGridCellResults()->cellResults()->timeStepDate(0, currentTimeStep);
int currentTimeStep = reservoirView->currentTimeStep();
QDateTime date = reservoirView->currentGridCellResults()->cellResults()->timeStepDate(0, currentTimeStep);
infoText += QString("<b>Time Step:</b> %1 <b>Time:</b> %2").arg(currentTimeStep).arg(date.toString("dd.MMM yyyy"));
}
m_reservoirView->viewer()->setInfoText(infoText);
reservoirView->viewer()->setInfoText(infoText);
}
if (showHistogram())
{
if (m_reservoirView->animationMode() && m_reservoirView->cellResult()->hasResult())
if (reservoirView->animationMode() && reservoirView->cellResult()->hasResult())
{
double min, max;
double p10, p90;
double mean;
size_t scalarIndex = m_reservoirView->cellResult()->scalarResultIndex();
m_reservoirView->currentGridCellResults()->cellResults()->minMaxCellScalarValues(scalarIndex, min, max);
m_reservoirView->currentGridCellResults()->cellResults()->p10p90CellScalarValues(scalarIndex, p10, p90);
m_reservoirView->currentGridCellResults()->cellResults()->meanCellScalarValues(scalarIndex, mean);
size_t scalarIndex = reservoirView->cellResult()->scalarResultIndex();
reservoirView->currentGridCellResults()->cellResults()->minMaxCellScalarValues(scalarIndex, min, max);
reservoirView->currentGridCellResults()->cellResults()->p10p90CellScalarValues(scalarIndex, p10, p90);
reservoirView->currentGridCellResults()->cellResults()->meanCellScalarValues(scalarIndex, mean);
m_reservoirView->viewer()->showHistogram(true);
m_reservoirView->viewer()->setHistogram(min, max, m_reservoirView->currentGridCellResults()->cellResults()->cellScalarValuesHistogram(scalarIndex));
m_reservoirView->viewer()->setHistogramPercentiles(p10, p90, mean);
reservoirView->viewer()->showHistogram(true);
reservoirView->viewer()->setHistogram(min, max, reservoirView->currentGridCellResults()->cellResults()->cellScalarValuesHistogram(scalarIndex));
reservoirView->viewer()->setHistogramPercentiles(p10, p90, mean);
}
}
}
@@ -241,7 +270,16 @@ void Rim3dOverlayInfoConfig::update3DInfo()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::PdmFieldHandle* Rim3dOverlayInfoConfig::objectToggleField()
void Rim3dOverlayInfoConfig::updateGeoMech3DInfo(RimGeoMechView * geoMechView)
{
return &active;
if (showInfoText())
{
QString infoText = QString(
"<p><b><center>-- %1 --</center></b><p> ").arg("ToDo: Describe Geo Mech Case");
geoMechView->viewer()->setInfoText(infoText);
}
if (showHistogram())
{
}
}
@@ -28,6 +28,9 @@
#include "cvfVector2.h"
class RimReservoirView;
class RimGeoMechView;
class RimView;
//==================================================================================================
///
///
@@ -41,7 +44,7 @@ public:
void update3DInfo();
void setReservoirView(RimReservoirView* ownerReservoirView) {m_reservoirView = ownerReservoirView; }
void setReservoirView(RimView* ownerView);
void setPosition(cvf::Vec2ui position);
caf::PdmField<bool> active;
@@ -53,7 +56,13 @@ protected:
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue);
virtual caf::PdmFieldHandle* objectToggleField();
private:
caf::PdmPointer<RimReservoirView> m_reservoirView;
void updateReservoir3DInfo(RimReservoirView * reservoirView);
void updateGeoMech3DInfo(RimGeoMechView * geoMechView);
caf::PdmPointer<RimView> m_viewDef;
cvf::Vec2ui m_position;
};
@@ -23,7 +23,7 @@
#include "RiaApplication.h"
#include "RigCaseData.h"
#include "RigGridManager.h"
#include "RimCase.h"
#include "RimEclipseCase.h"
#include "RimCaseCollection.h"
#include "RimIdenticalGridCaseGroup.h"
#include "RimProject.h"
@@ -66,7 +66,7 @@ void RimAnalysisModels::close()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimIdenticalGridCaseGroup* RimAnalysisModels::createIdenticalCaseGroupFromMainCase(RimCase* mainCase)
RimIdenticalGridCaseGroup* RimAnalysisModels::createIdenticalCaseGroupFromMainCase(RimEclipseCase* mainCase)
{
CVF_ASSERT(mainCase);
@@ -78,7 +78,7 @@ RimIdenticalGridCaseGroup* RimAnalysisModels::createIdenticalCaseGroupFromMainCa
assert(RiaApplication::instance()->project());
RiaApplication::instance()->project()->assignIdToCaseGroup(group);
RimCase* createdCase = group->createAndAppendStatisticsCase();
RimEclipseCase* createdCase = group->createAndAppendStatisticsCase();
RiaApplication::instance()->project()->assignCaseIdToCase(createdCase);
group->addCase(mainCase);
@@ -90,7 +90,7 @@ RimIdenticalGridCaseGroup* RimAnalysisModels::createIdenticalCaseGroupFromMainCa
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimAnalysisModels::moveEclipseCaseIntoCaseGroup(RimCase* rimReservoir)
void RimAnalysisModels::moveEclipseCaseIntoCaseGroup(RimEclipseCase* rimReservoir)
{
CVF_ASSERT(rimReservoir);
@@ -130,7 +130,7 @@ void RimAnalysisModels::moveEclipseCaseIntoCaseGroup(RimCase* rimReservoir)
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimAnalysisModels::removeCaseFromAllGroups(RimCase* reservoir)
void RimAnalysisModels::removeCaseFromAllGroups(RimEclipseCase* reservoir)
{
m_gridCollection->removeCase(reservoir->reservoirData());
@@ -177,7 +177,7 @@ RigMainGrid* RimAnalysisModels::registerCaseInGridCollection(RigCaseData* rigEcl
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimAnalysisModels::insertCaseInCaseGroup(RimIdenticalGridCaseGroup* caseGroup, RimCase* rimReservoir)
void RimAnalysisModels::insertCaseInCaseGroup(RimIdenticalGridCaseGroup* caseGroup, RimEclipseCase* rimReservoir)
{
CVF_ASSERT(rimReservoir);
@@ -26,7 +26,7 @@
#include "cvfObject.h"
class RimCase;
class RimEclipseCase;
class RigGridManager;
class RimIdenticalGridCaseGroup;
class RigMainGrid;
@@ -45,15 +45,15 @@ public:
RimAnalysisModels(void);
virtual ~RimAnalysisModels(void);
caf::PdmPointersField<RimCase*> cases;
caf::PdmPointersField<RimEclipseCase*> cases;
caf::PdmPointersField<RimIdenticalGridCaseGroup*> caseGroups;
void close();
RimIdenticalGridCaseGroup* createIdenticalCaseGroupFromMainCase(RimCase* mainCase);
void insertCaseInCaseGroup(RimIdenticalGridCaseGroup* caseGroup, RimCase* rimReservoir);
void moveEclipseCaseIntoCaseGroup(RimCase* rimReservoir);
void removeCaseFromAllGroups(RimCase* rimReservoir);
RimIdenticalGridCaseGroup* createIdenticalCaseGroupFromMainCase(RimEclipseCase* mainCase);
void insertCaseInCaseGroup(RimIdenticalGridCaseGroup* caseGroup, RimEclipseCase* rimReservoir);
void moveEclipseCaseIntoCaseGroup(RimEclipseCase* rimReservoir);
void removeCaseFromAllGroups(RimEclipseCase* rimReservoir);
void recomputeStatisticsForAllCaseGroups();
+8 -376
View File
@@ -1,8 +1,7 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2011- Statoil ASA
// Copyright (C) 2013- Ceetron Solutions AS
// Copyright (C) 2011-2012 Ceetron AS
// Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions 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
@@ -19,64 +18,28 @@
/////////////////////////////////////////////////////////////////////////////////
#include "RimCase.h"
#include "cafPdmObjectFactory.h"
#include "RiaApplication.h"
#include "RiaPreferences.h"
#include "RigCaseCellResultsData.h"
#include "RigCaseData.h"
#include "RimCaseCollection.h"
#include "RimCellEdgeResultSlot.h"
#include "RimCellPropertyFilter.h"
#include "RimCellPropertyFilterCollection.h"
#include "RimReservoirCellResultsStorage.h"
#include "RimReservoirView.h"
#include "RimResultSlot.h"
#include "cafPdmDocument.h"
#include "cafProgressInfo.h"
#include "cafPdmAbstractClassSourceInit.h"
#include <QFile>
#include <QFileInfo>
#include <QDir>
#include <QDebug>
CAF_PDM_ABSTRACT_SOURCE_INIT(RimCase, "RimCase");
CAF_PDM_SOURCE_INIT(RimCase, "RimReservoir");
//------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimCase::RimCase()
{
CAF_PDM_InitField(&caseUserDescription, "CaseUserDescription", QString(), "Case name", "", "" ,"");
CAF_PDM_InitField(&caseId, "CaseId", -1, "Case ID", "", "" ,"");
caseId.setUiReadOnly(true);
CAF_PDM_InitFieldNoDefault(&reservoirViews, "ReservoirViews", "", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_matrixModelResults, "MatrixModelResults", "", "", "", "");
m_matrixModelResults.setUiHidden(true);
CAF_PDM_InitFieldNoDefault(&m_fractureModelResults, "FractureModelResults", "", "", "", "");
m_fractureModelResults.setUiHidden(true);
CAF_PDM_InitField(&flipXAxis, "FlipXAxis", false, "Flip X Axis", "", "", "");
CAF_PDM_InitField(&flipYAxis, "FlipYAxis", false, "Flip Y Axis", "", "", "");
CAF_PDM_InitFieldNoDefault(&filesContainingFaults, "FilesContainingFaults", "", "", "", "");
filesContainingFaults.setUiHidden(true);
// Obsolete field
CAF_PDM_InitField(&caseName, "CaseName", QString(), "Obsolete", "", "" ,"");
caseName.setIOWritable(false);
caseName.setUiHidden(true);
m_matrixModelResults = new RimReservoirCellResultsStorage;
m_fractureModelResults = new RimReservoirCellResultsStorage;
this->setReservoirData( NULL );
}
//--------------------------------------------------------------------------------------------------
@@ -84,303 +47,9 @@ RimCase::RimCase()
//--------------------------------------------------------------------------------------------------
RimCase::~RimCase()
{
reservoirViews.deleteAllChildObjects();
delete m_matrixModelResults();
delete m_fractureModelResults();
if (this->reservoirData())
{
// At this point, we assume that memory should be released
CVF_ASSERT(this->reservoirData()->refCount() == 1);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigCaseData* RimCase::reservoirData()
{
return m_rigEclipseCase.p();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const RigCaseData* RimCase::reservoirData() const
{
return m_rigEclipseCase.p();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimCase::initAfterRead()
{
size_t j;
for (j = 0; j < reservoirViews().size(); j++)
{
RimReservoirView* riv = reservoirViews()[j];
CVF_ASSERT(riv);
riv->setEclipseCase(this);
}
if (caseUserDescription().isEmpty() && !caseName().isEmpty())
{
caseUserDescription = caseName;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimReservoirView* RimCase::createAndAddReservoirView()
{
RimReservoirView* riv = new RimReservoirView();
riv->setEclipseCase(this);
caf::PdmDocument::updateUiIconStateRecursively(riv);
size_t i = reservoirViews().size();
riv->name = QString("View %1").arg(i + 1);
reservoirViews().push_back(riv);
return riv;
}
//--------------------------------------------------------------------------------------------------
/// TODO: Move this functionality to PdmPointersField
//--------------------------------------------------------------------------------------------------
void RimCase::removeReservoirView(RimReservoirView* reservoirView)
{
std::vector<size_t> indices;
size_t i;
for (i = 0; i < reservoirViews().size(); i++)
{
if (reservoirViews()[i] == reservoirView)
{
indices.push_back(i);
}
}
// NB! Make sure the ordering goes from large to low index
while (!indices.empty())
{
reservoirViews().erase(indices.back());
indices.pop_back();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimCase::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->setResultVariable(RimDefines::undefinedResultName());
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() == resultName)
{
propertyFilter->resultDefinition->setResultVariable(RimDefines::undefinedResultName());
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
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimCase::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
{
if (changedField == &releaseResultMemory)
{
if (this->reservoirData())
{
for (size_t i = 0; i < reservoirViews().size(); i++)
{
RimReservoirView* reservoirView = reservoirViews()[i];
CVF_ASSERT(reservoirView);
RimResultSlot* result = reservoirView->cellResult;
CVF_ASSERT(result);
result->setResultVariable(RimDefines::undefinedResultName());
result->loadResult();
RimCellEdgeResultSlot* cellEdgeResult = reservoirView->cellEdgeResult;
CVF_ASSERT(cellEdgeResult);
cellEdgeResult->resultVariable.v() = RimDefines::undefinedResultName();
cellEdgeResult->loadResult();
reservoirView->createDisplayModelAndRedraw();
}
RigCaseCellResultsData* matrixModelResults = reservoirData()->results(RifReaderInterface::MATRIX_RESULTS);
if (matrixModelResults)
{
matrixModelResults->clearAllResults();
}
RigCaseCellResultsData* fractureModelResults = reservoirData()->results(RifReaderInterface::FRACTURE_RESULTS);
if (fractureModelResults)
{
fractureModelResults->clearAllResults();
}
}
releaseResultMemory = oldValue.toBool();
}
else if (changedField == &flipXAxis || changedField == &flipYAxis)
{
RigCaseData* rigEclipseCase = reservoirData();
if (rigEclipseCase)
{
rigEclipseCase->mainGrid()->setFlipAxis(flipXAxis, flipYAxis);
computeCachedData();
for (size_t i = 0; i < reservoirViews().size(); i++)
{
RimReservoirView* reservoirView = reservoirViews()[i];
reservoirView->scheduleReservoirGridGeometryRegen();
reservoirView->schedulePipeGeometryRegen();
reservoirView->createDisplayModelAndRedraw();
}
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimCase::computeCachedData()
{
RigCaseData* rigEclipseCase = reservoirData();
if (rigEclipseCase)
{
caf::ProgressInfo pInf(30, "");
pInf.setNextProgressIncrement(1);
rigEclipseCase->computeActiveCellBoundingBoxes();
pInf.incrementProgress();
pInf.setNextProgressIncrement(10);
rigEclipseCase->mainGrid()->computeCachedData();
pInf.incrementProgress();
pInf.setProgressDescription("Calculating faults");
rigEclipseCase->mainGrid()->calculateFaults();
pInf.incrementProgress();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimCaseCollection* RimCase::parentCaseCollection()
{
std::vector<RimCaseCollection*> parentObjects;
this->parentObjectsOfType(parentObjects);
if (parentObjects.size() > 0)
{
return parentObjects[0];
}
return NULL;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimIdenticalGridCaseGroup* RimCase::parentGridCaseGroup()
{
RimCaseCollection* caseColl = parentCaseCollection();
if (caseColl)
{
return caseColl->parentCaseGroup();
}
else
{
return NULL;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimCase::setReservoirData(RigCaseData* eclipseCase)
{
m_rigEclipseCase = eclipseCase;
if (this->reservoirData())
{
m_fractureModelResults()->setCellResults(reservoirData()->results(RifReaderInterface::FRACTURE_RESULTS));
m_matrixModelResults()->setCellResults(reservoirData()->results(RifReaderInterface::MATRIX_RESULTS));
m_fractureModelResults()->setMainGrid(this->reservoirData()->mainGrid());
m_matrixModelResults()->setMainGrid(this->reservoirData()->mainGrid());
}
else
{
m_fractureModelResults()->setCellResults(NULL);
m_matrixModelResults()->setCellResults(NULL);
m_fractureModelResults()->setMainGrid(NULL);
m_matrixModelResults()->setMainGrid(NULL);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimReservoirCellResultsStorage* RimCase::results(RifReaderInterface::PorosityModelResultType porosityModel)
{
if (porosityModel == RifReaderInterface::MATRIX_RESULTS)
{
return m_matrixModelResults();
}
return m_fractureModelResults();
}
//--------------------------------------------------------------------------------------------------
@@ -536,41 +205,4 @@ QString RimCase::relocateFile(const QString& orgFileName, const QString& orgNew
if (foundFile) *foundFile = false;
return fileName;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimCase::openReserviorCase()
{
// If read already, return
if (this->reservoirData() != NULL) return true;
if (!openEclipseGridFile())
{
return false;
}
{
RimReservoirCellResultsStorage* results = this->results(RifReaderInterface::MATRIX_RESULTS);
if (results->cellResults())
{
results->cellResults()->createPlaceholderResultEntries();
// After the placeholder result for combined transmissibility is created,
// make sure the nnc transmissibilities can be addressed by this scalarResultIndex as well
size_t combinedTransResIdx = results->cellResults()->findScalarResultIndex(RimDefines::STATIC_NATIVE, RimDefines::combinedTransmissibilityResultName());
if (combinedTransResIdx != cvf::UNDEFINED_SIZE_T)
{
reservoirData()->mainGrid()->nncData()->setCombTransmisibilityScalarResultIndex(combinedTransResIdx);
}
}
}
{
RimReservoirCellResultsStorage* results = this->results(RifReaderInterface::FRACTURE_RESULTS);
if (results->cellResults()) results->cellResults()->createPlaceholderResultEntries();
}
return true;
}
}
+12 -68
View File
@@ -1,8 +1,7 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2011- Statoil ASA
// Copyright (C) 2013- Ceetron Solutions AS
// Copyright (C) 2011-2012 Ceetron AS
// Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions 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
@@ -19,90 +18,35 @@
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cvfBase.h"
#include "cvfObject.h"
#include "cafPdmField.h"
#include "cafPdmObject.h"
#include "RifReaderInterface.h"
class QString;
#include <vector>
class RigCaseData;
class RigGridBase;
class RimReservoirView;
class RimCaseCollection;
class RimIdenticalGridCaseGroup;
class RimReservoirCellResultsStorage;
class RimView;
//==================================================================================================
//
// Interface for reservoirs.
//
//==================================================================================================
class RimCase : public caf::PdmObject
{
CAF_PDM_HEADER_INIT;
public:
RimCase();
virtual ~RimCase();
// Fields:
caf::PdmField<QString> caseUserDescription;
caf::PdmField<int> caseId;
caf::PdmField<bool> releaseResultMemory;
caf::PdmPointersField<RimReservoirView*> reservoirViews;
caf::PdmField<bool> flipXAxis;
caf::PdmField<bool> flipYAxis;
caf::PdmField<std::vector<QString> > filesContainingFaults;
caf::PdmField<QString> caseUserDescription;
caf::PdmField<int> caseId;
virtual std::vector<RimView*> views() = 0;
bool openReserviorCase();
virtual bool openEclipseGridFile() { return false; }; // Should be pure virtual but PDM does not allow that.
RigCaseData* reservoirData();
const RigCaseData* reservoirData() const;
virtual void updateFilePathsFromProjectPath(const QString& projectPath, const QString& oldProjectPath) = 0;
RimReservoirCellResultsStorage* results(RifReaderInterface::PorosityModelResultType porosityModel);
RimReservoirView* createAndAddReservoirView();
void removeReservoirView(RimReservoirView* reservoirView);
void removeResult(const QString& resultName);
virtual QString locationOnDisc() const { return QString(); }
virtual QString gridFileName() const { return QString(); }
virtual void updateFilePathsFromProjectPath(const QString& projectPath, const QString& oldProjectPath) { };
RimCaseCollection* parentCaseCollection();
RimIdenticalGridCaseGroup* parentGridCaseGroup();
// Overridden methods from PdmObject
public:
virtual caf::PdmFieldHandle* userDescriptionField() { return &caseUserDescription; }
protected:
virtual void initAfterRead();
virtual void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue );
// Internal methods
protected:
void computeCachedData();
void setReservoirData(RigCaseData* eclipseCase);
static QString relocateFile(const QString& fileName, const QString& newProjectPath, const QString& oldProjectPath,
bool* foundFile, std::vector<QString>* searchedPaths);
private:
cvf::ref<RigCaseData> m_rigEclipseCase;
private:
caf::PdmField<RimReservoirCellResultsStorage*> m_matrixModelResults;
caf::PdmField<RimReservoirCellResultsStorage*> m_fractureModelResults;
// Obsolete fields
protected:
caf::PdmField<QString> caseName;
};
@@ -20,7 +20,7 @@
#include "RimCaseCollection.h"
#include "RimCase.h"
#include "RimEclipseCase.h"
#include "RimIdenticalGridCaseGroup.h"
@@ -63,7 +63,7 @@ RimIdenticalGridCaseGroup* RimCaseCollection::parentCaseGroup()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimCase* RimCaseCollection::findByDescription(const QString& caseDescription) const
RimEclipseCase* RimCaseCollection::findByDescription(const QString& caseDescription) const
{
for (size_t i = 0; i < reservoirs.size(); i++)
{
@@ -21,7 +21,7 @@
#include "cafPdmField.h"
#include "cafPdmObject.h"
class RimCase;
class RimEclipseCase;
class RimIdenticalGridCaseGroup;
//==================================================================================================
@@ -36,10 +36,10 @@ class RimCaseCollection : public caf::PdmObject
public:
RimCaseCollection();
virtual ~RimCaseCollection();
caf::PdmPointersField<RimCase*> reservoirs;
caf::PdmPointersField<RimEclipseCase*> reservoirs;
RimIdenticalGridCaseGroup* parentCaseGroup();
RimCase* findByDescription(const QString& caseDescription) const;
RimEclipseCase* findByDescription(const QString& caseDescription) const;
private:
@@ -25,7 +25,7 @@
#include "RigCaseData.h"
#include "RigGridBase.h"
#include "RigMainGrid.h"
#include "RimCase.h"
#include "RimEclipseCase.h"
#include "RimCellRangeFilterCollection.h"
#include "RimReservoirView.h"
@@ -20,7 +20,7 @@
#include "RimCellRangeFilterCollection.h"
#include "RimCase.h"
#include "RimEclipseCase.h"
#include "RigGridBase.h"
#include "RimReservoirView.h"
#include "RigCaseData.h"
@@ -0,0 +1,434 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2011- Statoil ASA
// Copyright (C) 2013- Ceetron Solutions AS
// Copyright (C) 2011-2012 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 "RimEclipseCase.h"
#include "RiaApplication.h"
#include "RiaPreferences.h"
#include "RigCaseCellResultsData.h"
#include "RigCaseData.h"
#include "RimCaseCollection.h"
#include "RimCellEdgeResultSlot.h"
#include "RimCellPropertyFilter.h"
#include "RimCellPropertyFilterCollection.h"
#include "RimReservoirCellResultsStorage.h"
#include "RimReservoirView.h"
#include "RimResultSlot.h"
#include "cafPdmDocument.h"
#include "cafProgressInfo.h"
#include <QFile>
#include <QFileInfo>
#include <QDir>
#include <QDebug>
#include "cafPdmAbstractClassSourceInit.h"
CAF_PDM_ABSTRACT_SOURCE_INIT(RimEclipseCase, "RimReservoir");
//------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimEclipseCase::RimEclipseCase()
{
CAF_PDM_InitFieldNoDefault(&reservoirViews, "ReservoirViews", "", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_matrixModelResults, "MatrixModelResults", "", "", "", "");
m_matrixModelResults.setUiHidden(true);
CAF_PDM_InitFieldNoDefault(&m_fractureModelResults, "FractureModelResults", "", "", "", "");
m_fractureModelResults.setUiHidden(true);
CAF_PDM_InitField(&flipXAxis, "FlipXAxis", false, "Flip X Axis", "", "", "");
CAF_PDM_InitField(&flipYAxis, "FlipYAxis", false, "Flip Y Axis", "", "", "");
CAF_PDM_InitFieldNoDefault(&filesContainingFaults, "FilesContainingFaults", "", "", "", "");
filesContainingFaults.setUiHidden(true);
// Obsolete field
CAF_PDM_InitField(&caseName, "CaseName", QString(), "Obsolete", "", "" ,"");
caseName.setIOWritable(false);
caseName.setUiHidden(true);
m_matrixModelResults = new RimReservoirCellResultsStorage;
m_fractureModelResults = new RimReservoirCellResultsStorage;
this->setReservoirData( NULL );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimEclipseCase::~RimEclipseCase()
{
reservoirViews.deleteAllChildObjects();
delete m_matrixModelResults();
delete m_fractureModelResults();
if (this->reservoirData())
{
// At this point, we assume that memory should be released
CVF_ASSERT(this->reservoirData()->refCount() == 1);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigCaseData* RimEclipseCase::reservoirData()
{
return m_rigEclipseCase.p();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const RigCaseData* RimEclipseCase::reservoirData() const
{
return m_rigEclipseCase.p();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipseCase::initAfterRead()
{
size_t j;
for (j = 0; j < reservoirViews().size(); j++)
{
RimReservoirView* riv = reservoirViews()[j];
CVF_ASSERT(riv);
riv->setEclipseCase(this);
}
if (caseUserDescription().isEmpty() && !caseName().isEmpty())
{
caseUserDescription = caseName;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimReservoirView* RimEclipseCase::createAndAddReservoirView()
{
RimReservoirView* riv = new RimReservoirView();
riv->setEclipseCase(this);
caf::PdmDocument::updateUiIconStateRecursively(riv);
size_t i = reservoirViews().size();
riv->name = QString("View %1").arg(i + 1);
reservoirViews().push_back(riv);
return riv;
}
//--------------------------------------------------------------------------------------------------
/// TODO: Move this functionality to PdmPointersField
//--------------------------------------------------------------------------------------------------
void RimEclipseCase::removeReservoirView(RimReservoirView* reservoirView)
{
std::vector<size_t> indices;
size_t i;
for (i = 0; i < reservoirViews().size(); i++)
{
if (reservoirViews()[i] == reservoirView)
{
indices.push_back(i);
}
}
// NB! Make sure the ordering goes from large to low index
while (!indices.empty())
{
reservoirViews().erase(indices.back());
indices.pop_back();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipseCase::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->setResultVariable(RimDefines::undefinedResultName());
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() == resultName)
{
propertyFilter->resultDefinition->setResultVariable(RimDefines::undefinedResultName());
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
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipseCase::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
{
if (changedField == &releaseResultMemory)
{
if (this->reservoirData())
{
for (size_t i = 0; i < reservoirViews().size(); i++)
{
RimReservoirView* reservoirView = reservoirViews()[i];
CVF_ASSERT(reservoirView);
RimResultSlot* result = reservoirView->cellResult;
CVF_ASSERT(result);
result->setResultVariable(RimDefines::undefinedResultName());
result->loadResult();
RimCellEdgeResultSlot* cellEdgeResult = reservoirView->cellEdgeResult;
CVF_ASSERT(cellEdgeResult);
cellEdgeResult->resultVariable.v() = RimDefines::undefinedResultName();
cellEdgeResult->loadResult();
reservoirView->createDisplayModelAndRedraw();
}
RigCaseCellResultsData* matrixModelResults = reservoirData()->results(RifReaderInterface::MATRIX_RESULTS);
if (matrixModelResults)
{
matrixModelResults->clearAllResults();
}
RigCaseCellResultsData* fractureModelResults = reservoirData()->results(RifReaderInterface::FRACTURE_RESULTS);
if (fractureModelResults)
{
fractureModelResults->clearAllResults();
}
}
releaseResultMemory = oldValue.toBool();
}
else if (changedField == &flipXAxis || changedField == &flipYAxis)
{
RigCaseData* rigEclipseCase = reservoirData();
if (rigEclipseCase)
{
rigEclipseCase->mainGrid()->setFlipAxis(flipXAxis, flipYAxis);
computeCachedData();
for (size_t i = 0; i < reservoirViews().size(); i++)
{
RimReservoirView* reservoirView = reservoirViews()[i];
reservoirView->scheduleReservoirGridGeometryRegen();
reservoirView->schedulePipeGeometryRegen();
reservoirView->createDisplayModelAndRedraw();
}
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipseCase::computeCachedData()
{
RigCaseData* rigEclipseCase = reservoirData();
if (rigEclipseCase)
{
caf::ProgressInfo pInf(30, "");
pInf.setNextProgressIncrement(1);
rigEclipseCase->computeActiveCellBoundingBoxes();
pInf.incrementProgress();
pInf.setNextProgressIncrement(10);
rigEclipseCase->mainGrid()->computeCachedData();
pInf.incrementProgress();
pInf.setProgressDescription("Calculating faults");
rigEclipseCase->mainGrid()->calculateFaults();
pInf.incrementProgress();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimCaseCollection* RimEclipseCase::parentCaseCollection()
{
std::vector<RimCaseCollection*> parentObjects;
this->parentObjectsOfType(parentObjects);
if (parentObjects.size() > 0)
{
return parentObjects[0];
}
return NULL;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimIdenticalGridCaseGroup* RimEclipseCase::parentGridCaseGroup()
{
RimCaseCollection* caseColl = parentCaseCollection();
if (caseColl)
{
return caseColl->parentCaseGroup();
}
else
{
return NULL;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipseCase::setReservoirData(RigCaseData* eclipseCase)
{
m_rigEclipseCase = eclipseCase;
if (this->reservoirData())
{
m_fractureModelResults()->setCellResults(reservoirData()->results(RifReaderInterface::FRACTURE_RESULTS));
m_matrixModelResults()->setCellResults(reservoirData()->results(RifReaderInterface::MATRIX_RESULTS));
m_fractureModelResults()->setMainGrid(this->reservoirData()->mainGrid());
m_matrixModelResults()->setMainGrid(this->reservoirData()->mainGrid());
}
else
{
m_fractureModelResults()->setCellResults(NULL);
m_matrixModelResults()->setCellResults(NULL);
m_fractureModelResults()->setMainGrid(NULL);
m_matrixModelResults()->setMainGrid(NULL);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimReservoirCellResultsStorage* RimEclipseCase::results(RifReaderInterface::PorosityModelResultType porosityModel)
{
if (porosityModel == RifReaderInterface::MATRIX_RESULTS)
{
return m_matrixModelResults();
}
return m_fractureModelResults();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimEclipseCase::openReserviorCase()
{
// If read already, return
if (this->reservoirData() != NULL) return true;
if (!openEclipseGridFile())
{
return false;
}
{
RimReservoirCellResultsStorage* results = this->results(RifReaderInterface::MATRIX_RESULTS);
if (results->cellResults())
{
results->cellResults()->createPlaceholderResultEntries();
// After the placeholder result for combined transmissibility is created,
// make sure the nnc transmissibilities can be addressed by this scalarResultIndex as well
size_t combinedTransResIdx = results->cellResults()->findScalarResultIndex(RimDefines::STATIC_NATIVE, RimDefines::combinedTransmissibilityResultName());
if (combinedTransResIdx != cvf::UNDEFINED_SIZE_T)
{
reservoirData()->mainGrid()->nncData()->setCombTransmisibilityScalarResultIndex(combinedTransResIdx);
}
}
}
{
RimReservoirCellResultsStorage* results = this->results(RifReaderInterface::FRACTURE_RESULTS);
if (results->cellResults()) results->cellResults()->createPlaceholderResultEntries();
}
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RimView*> RimEclipseCase::views()
{
std::vector<RimView*> views;
for (size_t vIdx = 0; vIdx < reservoirViews.size(); ++vIdx)
{
views.push_back(reservoirViews[vIdx]);
}
return views;
}
@@ -0,0 +1,107 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2011- Statoil ASA
// Copyright (C) 2013- Ceetron Solutions AS
// Copyright (C) 2011-2012 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 "RimCase.h"
#include "cvfBase.h"
#include "cvfObject.h"
#include "cafPdmField.h"
#include "cafPdmObject.h"
#include "RifReaderInterface.h"
class QString;
class RigCaseData;
class RigGridBase;
class RimReservoirView;
class RimCaseCollection;
class RimIdenticalGridCaseGroup;
class RimReservoirCellResultsStorage;
//==================================================================================================
//
// Interface for reservoirs.
//
//==================================================================================================
class RimEclipseCase : public RimCase
{
CAF_PDM_HEADER_INIT;
public:
RimEclipseCase();
virtual ~RimEclipseCase();
// Fields:
caf::PdmField<bool> releaseResultMemory;
caf::PdmPointersField<RimReservoirView*> reservoirViews;
caf::PdmField<bool> flipXAxis;
caf::PdmField<bool> flipYAxis;
caf::PdmField<std::vector<QString> > filesContainingFaults;
bool openReserviorCase();
virtual bool openEclipseGridFile() = 0;
RigCaseData* reservoirData();
const RigCaseData* reservoirData() const;
RimReservoirCellResultsStorage* results(RifReaderInterface::PorosityModelResultType porosityModel);
RimReservoirView* createAndAddReservoirView();
void removeReservoirView(RimReservoirView* reservoirView);
void removeResult(const QString& resultName);
virtual QString locationOnDisc() const { return QString(); }
virtual QString gridFileName() const { return QString(); }
RimCaseCollection* parentCaseCollection();
RimIdenticalGridCaseGroup* parentGridCaseGroup();
virtual std::vector<RimView*> views();
// Overridden methods from PdmObject
public:
protected:
virtual void initAfterRead();
virtual void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue );
// Internal methods
protected:
void computeCachedData();
void setReservoirData(RigCaseData* eclipseCase);
private:
cvf::ref<RigCaseData> m_rigEclipseCase;
private:
caf::PdmField<RimReservoirCellResultsStorage*> m_matrixModelResults;
caf::PdmField<RimReservoirCellResultsStorage*> m_fractureModelResults;
// Obsolete fields
protected:
caf::PdmField<QString> caseName;
};
@@ -22,7 +22,7 @@
#include "RiaApplication.h"
#include "RiaPreferences.h"
#include "RigCaseData.h"
#include "RimCase.h"
#include "RimEclipseCase.h"
#include "RimNoCommonAreaNNC.h"
#include "RimNoCommonAreaNncCollection.h"
#include "RimReservoirView.h"
@@ -22,7 +22,7 @@
#include "RigCaseData.h"
#include "RigMainGrid.h"
#include "RimCase.h"
#include "RimEclipseCase.h"
#include "RimReservoirView.h"
#include "RimResultSlot.h"
#include "RimUiTreeModelPdm.h"
@@ -0,0 +1,131 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions 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 "RimGeoMechCase.h"
#include "RimGeoMechView.h"
#include "RiaApplication.h"
#include "RiaPreferences.h"
#include "RifOdbReader.h"
#include "RigGeoMechCaseData.h"
#include <QFile>
CAF_PDM_SOURCE_INIT(RimGeoMechCase, "ResInsightGeoMechCase");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimGeoMechCase::RimGeoMechCase(void)
{
CAF_PDM_InitObject("Geomechanical Case", ":/GeoMechCase48x48.png", "", "");
CAF_PDM_InitField(&m_caseFileName, "CaseFileName", QString(), "Case file name", "", "", "");
m_caseFileName.setUiReadOnly(true);
CAF_PDM_InitFieldNoDefault(&geoMechViews, "GeoMechViews", "", "", "", "");
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimGeoMechCase::~RimGeoMechCase(void)
{
geoMechViews.deleteAllChildObjects();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimGeoMechView* RimGeoMechCase::createAndAddReservoirView()
{
RimGeoMechView* gmv = new RimGeoMechView();
size_t i = geoMechViews().size();
gmv->name = QString("View %1").arg(i + 1);
gmv->setGeoMechCase(this);
geoMechViews.push_back(gmv);
return gmv;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimGeoMechCase::openGeoMechCase()
{
// If read already, return
if (this->m_geoMechCaseData.notNull()) return true;
if (!QFile::exists(m_caseFileName()))
{
return false;
}
m_geoMechCaseData = new RigGeoMechCaseData(m_caseFileName().toStdString());
return m_geoMechCaseData->openAndReadFemParts();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimGeoMechCase::updateFilePathsFromProjectPath(const QString& newProjectPath, const QString& oldProjectPath)
{
bool foundFile = false;
std::vector<QString> searchedPaths;
// Update filename and folder paths when opening project from a different file location
m_caseFileName = relocateFile(m_caseFileName(), newProjectPath, oldProjectPath, &foundFile, &searchedPaths);
#if 0 // Output the search path for debugging
for (size_t i = 0; i < searchedPaths.size(); ++i)
qDebug() << searchedPaths[i];
#endif
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RimView*> RimGeoMechCase::views()
{
std::vector<RimView*> views;
for (size_t vIdx = 0; vIdx < geoMechViews.size(); ++vIdx)
{
views.push_back(geoMechViews[vIdx]);
}
return views;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimGeoMechCase::initAfterRead()
{
size_t j;
for (j = 0; j < geoMechViews().size(); j++)
{
RimGeoMechView* riv = geoMechViews()[j];
CVF_ASSERT(riv);
riv->setGeoMechCase(this);
}
}
@@ -0,0 +1,64 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions 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 "RimCase.h"
#include "cafPdmField.h"
#include "cafPdmObject.h"
#include "cafPdmPointer.h"
#include "cvfObject.h"
class RimGeoMechView;
class RigGeoMechCaseData;
class RifGeoMechReaderInterface;
//==================================================================================================
///
///
//==================================================================================================
class RimGeoMechCase : public RimCase
{
CAF_PDM_HEADER_INIT;
public:
RimGeoMechCase(void);
virtual ~RimGeoMechCase(void);
void setFileName(const QString& fileName) {m_caseFileName = fileName;}
QString caseFileName() const {return m_caseFileName();}
bool openGeoMechCase();
RigGeoMechCaseData* geoMechData() { return m_geoMechCaseData.p(); }
const RigGeoMechCaseData* geoMechData() const { return m_geoMechCaseData.p(); }
RimGeoMechView* createAndAddReservoirView();
virtual void updateFilePathsFromProjectPath(const QString& projectPath, const QString& oldProjectPath);
virtual std::vector<RimView*> views();
// Fields:
caf::PdmPointersField<RimGeoMechView*> geoMechViews;
private:
virtual void initAfterRead();
private:
cvf::ref<RigGeoMechCaseData> m_geoMechCaseData;
caf::PdmField<QString> m_caseFileName;
};
@@ -0,0 +1,44 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions 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 "RimGeoMechModels.h"
#include "RimGeoMechCase.h"
CAF_PDM_SOURCE_INIT(RimGeoMechModels, "ResInsightGeoMechModels");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimGeoMechModels::RimGeoMechModels(void)
{
CAF_PDM_InitObject("Geomechanical Models", ":/GeoMechCases48x48.png", "", "");
CAF_PDM_InitFieldNoDefault(&cases, "Cases", "", "", "", "");
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimGeoMechModels::~RimGeoMechModels(void)
{
cases.deleteAllChildObjects();
}
@@ -0,0 +1,43 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions AS
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cafPdmField.h"
#include "cafPdmObject.h"
#include "cafPdmPointer.h"
class RimGeoMechCase;
//==================================================================================================
///
///
//==================================================================================================
class RimGeoMechModels : public caf::PdmObject
{
CAF_PDM_HEADER_INIT;
public:
RimGeoMechModels(void);
virtual ~RimGeoMechModels(void);
caf::PdmPointersField<RimGeoMechCase*> cases;
private:
};
@@ -0,0 +1,253 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions 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 "RimGeoMechResultSlot.h"
#include "RimGeoMechView.h"
#include "RimLegendConfig.h"
#include "RimDefines.h"
#include "RimGeoMechCase.h"
#include "RifGeoMechReaderInterface.h"
#include "cafPdmUiListEditor.h"
#include "RigGeoMechCaseData.h"
namespace caf {
template<>
void caf::AppEnum< RigFemResultPosEnum >::setUp()
{
addItem(RIG_NODAL, "NODAL", "Nodal");
addItem(RIG_ELEMENT_NODAL, "ELEMENT_NODAL", "Element Nodal");
addItem(RIG_INTEGRATION_POINT,"INTEGRATION_POINT","Integration Point");
setDefault(RIG_NODAL);
}
}
CAF_PDM_SOURCE_INIT(RimGeoMechResultSlot, "GeoMechResultSlot");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimGeoMechResultSlot::RimGeoMechResultSlot(void)
{
CAF_PDM_InitObject("Color Result", ":/CellResult.png", "", "");
CAF_PDM_InitFieldNoDefault(&legendConfig, "LegendDefinition", "Legend Definition", "", "", "");
this->legendConfig = new RimLegendConfig();
CAF_PDM_InitFieldNoDefault(&m_resultPositionType, "ResultPositionType" , "Result Position", "", "", "");
m_resultPositionType.setUiHidden(true);
CAF_PDM_InitField(&m_resultFieldName, "ResultFieldName", QString(""), "Field Name", "", "", "");
m_resultFieldName.setUiHidden(true);
CAF_PDM_InitField(&m_resultComponentName, "ResultComponentName", QString(""), "Component", "", "", "");
m_resultComponentName.setUiHidden(true);
CAF_PDM_InitFieldNoDefault(&m_resultPositionTypeUiField, "ResultPositionTypeUi", "Result Position", "", "", "");
m_resultPositionTypeUiField.setIOWritable(false);
m_resultPositionTypeUiField.setIOReadable(false);
CAF_PDM_InitField(&m_resultVariableUiField, "ResultVariableUI", QString(""), "Value", "", "", "");
m_resultVariableUiField.setIOWritable(false);
m_resultVariableUiField.setIOReadable(false);
m_resultVariableUiField.setUiEditorTypeName(caf::PdmUiListEditor::uiEditorTypeName());
m_resultVariableUiField.setUiLabelPosition(caf::PdmUiItemInfo::TOP);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimGeoMechResultSlot::~RimGeoMechResultSlot(void)
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QList<caf::PdmOptionItemInfo> RimGeoMechResultSlot::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly)
{
QList<caf::PdmOptionItemInfo> options;
*useOptionsOnly = true;
if (m_reservoirView)
{
if (&m_resultVariableUiField == fieldNeedingOptions)
{
std::map<std::string, std::vector<std::string> > fieldCompNames = getResultMetaDataForUIFieldSetting();
QStringList uiVarNames;
QStringList varNames;
getUiAndResultVariableStringList(&uiVarNames, &varNames, fieldCompNames);
for (int oIdx = 0; oIdx < uiVarNames.size(); ++oIdx)
{
options.push_back(caf::PdmOptionItemInfo(uiVarNames[oIdx], varNames[oIdx]));
}
#if 0
for (auto fieldIt = fieldCompNames.begin(); fieldIt != fieldCompNames.end(); ++fieldIt)
{
options.push_back(caf::PdmOptionItemInfo(QString::fromStdString(fieldIt->first), QString::fromStdString(fieldIt->first)));
for (auto compIt = fieldIt->second.begin(); compIt != fieldIt->second.end(); ++compIt)
{
options.push_back(caf::PdmOptionItemInfo(QString::fromStdString(" " + *compIt), QString::fromStdString(fieldIt->first + " " + *compIt)));
}
}
#endif
}
}
return options;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimGeoMechResultSlot::setReservoirView(RimGeoMechView* ownerReservoirView)
{
m_reservoirView = ownerReservoirView;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimGeoMechResultSlot::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
{
if(&m_resultPositionTypeUiField == changedField)
{
std::map<std::string, std::vector<std::string> > fieldCompNames = getResultMetaDataForUIFieldSetting();
QStringList uiVarNames;
QStringList varNames;
getUiAndResultVariableStringList(&uiVarNames, &varNames, fieldCompNames);
if (m_resultPositionTypeUiField() == m_resultPositionType()
&& varNames.contains(composeUiVarString(m_resultFieldName(), m_resultComponentName())))
{
m_resultVariableUiField = composeUiVarString(m_resultFieldName(), m_resultComponentName());
}
else
{
m_resultVariableUiField = "";
}
}
if (&m_resultVariableUiField == changedField)
{
QStringList fieldComponentNames = m_resultVariableUiField().split(QRegExp("\\s+"));
if (fieldComponentNames.size() > 0)
{
m_resultPositionType = m_resultPositionTypeUiField;
m_resultFieldName = fieldComponentNames[0];
if (fieldComponentNames.size() > 1)
{
m_resultComponentName = fieldComponentNames[1];
}
else
{
m_resultComponentName = "";
}
m_reservoirView->geoMechCase()->geoMechData()->assertResultsLoaded(0, this->resultAddress());
if (m_reservoirView)
{
m_reservoirView->animationMode = true;
m_reservoirView->createDisplayModelAndRedraw();
}
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::map<std::string, std::vector<std::string> > RimGeoMechResultSlot::getResultMetaDataForUIFieldSetting()
{
RimGeoMechCase* gmCase = m_reservoirView->geoMechCase();
if (gmCase && gmCase->geoMechData())
{
return gmCase->geoMechData()->scalarFieldAndComponentNames(m_resultPositionTypeUiField());
}
else
{
return std::map<std::string, std::vector<std::string> >() ;
}
}
void RimGeoMechResultSlot::getUiAndResultVariableStringList(QStringList* uiNames, QStringList* variableNames,
const std::map<std::string, std::vector<std::string> >& fieldCompNames)
{
CVF_ASSERT(uiNames && variableNames);
std::map<std::string, std::vector<std::string> >::const_iterator fieldIt;
for (fieldIt = fieldCompNames.begin(); fieldIt != fieldCompNames.end(); ++fieldIt)
{
uiNames->push_back(QString::fromStdString(fieldIt->first));
variableNames->push_back(QString::fromStdString(fieldIt->first));
std::vector<std::string>::const_iterator compIt;
for (compIt = fieldIt->second.begin(); compIt != fieldIt->second.end(); ++compIt)
{
uiNames->push_back(QString::fromStdString(" " + *compIt));
variableNames->push_back(composeUiVarString(QString::fromStdString(fieldIt->first), QString::fromStdString(*compIt)));
}
}
}
QString RimGeoMechResultSlot::composeUiVarString(const QString& resultFieldName, const QString& resultComponentName)
{
return resultFieldName + " " + resultComponentName;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimGeoMechResultSlot::initAfterRead()
{
m_resultPositionTypeUiField = m_resultPositionType;
m_resultVariableUiField = composeUiVarString(m_resultFieldName(), m_resultComponentName());
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimGeoMechResultSlot::loadResult()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigGeoMechCaseData* RimGeoMechResultSlot::ownerCaseData()
{
return m_reservoirView->geoMechCase()->geoMechData();
}
@@ -0,0 +1,78 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions AS
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cafPdmField.h"
#include "cafPdmObject.h"
#include "cafPdmPointer.h"
#include "cafAppEnum.h"
#include "RigFemResultPosEnum.h"
#include "RigFemResultAddress.h"
class RimLegendConfig;
class RimGeoMechView;
class RifGeoMechReaderInterface;
class RigGeoMechCaseData;
//==================================================================================================
///
///
//==================================================================================================
class RimGeoMechResultSlot : public caf::PdmObject
{
CAF_PDM_HEADER_INIT;
public:
RimGeoMechResultSlot(void);
virtual ~RimGeoMechResultSlot(void);
void setReservoirView(RimGeoMechView* ownerReservoirView);
RigGeoMechCaseData* ownerCaseData();
RigFemResultAddress resultAddress() { return RigFemResultAddress(resultPositionType(), resultFieldName().toStdString(), resultComponentName().toStdString());}
RigFemResultPosEnum resultPositionType() { return m_resultPositionType();}
QString resultFieldName() { return m_resultFieldName();}
QString resultComponentName() { return m_resultComponentName();}
caf::PdmField<RimLegendConfig*> legendConfig;
private:
virtual QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions,
bool * useOptionsOnly);
std::map<std::string, std::vector<std::string> > getResultMetaDataForUIFieldSetting();
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue);
static void getUiAndResultVariableStringList(QStringList* uiNames, QStringList* variableNames,
const std::map<std::string, std::vector<std::string> >& fieldCompNames);
static QString composeUiVarString(const QString& resultFieldName, const QString& resultComponentName);
virtual void initAfterRead();
void loadResult();
caf::PdmField<caf::AppEnum<RigFemResultPosEnum> > m_resultPositionType;
caf::PdmField<QString> m_resultFieldName;
caf::PdmField<QString> m_resultComponentName;
caf::PdmField<caf::AppEnum<RigFemResultPosEnum> > m_resultPositionTypeUiField;
caf::PdmField<QString> m_resultVariableUiField;
caf::PdmPointer<RimGeoMechView> m_reservoirView;
};
@@ -0,0 +1,483 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions 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 "RimGeoMechView.h"
#include "Rim3dOverlayInfoConfig.h"
#include "RiaApplication.h"
#include "RiaPreferences.h"
#include "RimGeoMechResultSlot.h"
#include "RiuMainWindow.h"
#include "cafCeetronPlusNavigation.h"
#include "cafCadNavigation.h"
#include "RimLegendConfig.h"
#include "cvfOverlayScalarMapperLegend.h"
#include "RimGeoMechCase.h"
#include "cvfPart.h"
#include "cvfViewport.h"
#include "cvfModelBasicList.h"
#include "cvfScene.h"
#include "RimReservoirView.h"
#include "RiuViewer.h"
#include "RivGeoMechPartMgr.h"
#include "RigGeoMechCaseData.h"
#include "cvfqtUtils.h"
#include "RigFemPartCollection.h"
#include "cafFrameAnimationControl.h"
#include <QMessageBox>
CAF_PDM_SOURCE_INIT(RimGeoMechView, "GeoMechView");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimGeoMechView::RimGeoMechView(void)
{
RiaApplication* app = RiaApplication::instance();
RiaPreferences* preferences = app->preferences();
CVF_ASSERT(preferences);
CAF_PDM_InitObject("Geomechanical View", ":/ReservoirView.png", "", "");
CAF_PDM_InitFieldNoDefault(&cellResult, "GridCellResult", "Color Result", ":/CellResult.png", "", "");
cellResult = new RimGeoMechResultSlot();
this->cellResult()->setReservoirView(this);
this->cellResult()->legendConfig()->setPosition(cvf::Vec2ui(10, 120));
this->cellResult()->legendConfig()->setReservoirView(this);
m_scaleTransform = new cvf::Transform();
m_geoMechFullModel = new RivGeoMechPartMgr();
m_isGeoMechFullGenerated = false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimGeoMechView::~RimGeoMechView(void)
{
m_geomechCase = NULL;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimGeoMechView::updateViewerWidgetWindowTitle()
{
if (m_viewer)
{
QString windowTitle;
if (m_geomechCase.notNull())
{
windowTitle = QString("%1 - %2").arg(m_geomechCase->caseUserDescription()).arg(name);
}
else
{
windowTitle = name;
}
m_viewer->layoutWidget()->setWindowTitle(windowTitle);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimGeoMechView::loadDataAndUpdate()
{
updateScaleTransform();
if (m_geomechCase)
{
if (!m_geomechCase->openGeoMechCase())
{
QMessageBox::warning(RiuMainWindow::instance(),
"Error when opening project file",
"Could not open the Odb file: \n"+ m_geomechCase->caseFileName());
m_geomechCase = NULL;
return;
}
m_geoMechFullModel->clearAndSetReservoir(m_geomechCase->geoMechData(), this);
}
CVF_ASSERT(this->cellResult() != NULL);
m_geomechCase->geoMechData()->assertResultsLoaded(0, this->cellResult()->resultAddress());
updateViewerWidget();
createDisplayModelAndRedraw();
if (cameraPosition().isIdentity())
{
setDefaultView();
}
}
//--------------------------------------------------------------------------------------------------
///
/// Todo: Work in progress
///
//--------------------------------------------------------------------------------------------------
void RimGeoMechView::updateScaleTransform()
{
cvf::Mat4d scale = cvf::Mat4d::IDENTITY;
scale(2, 2) = scaleZ();
this->scaleTransform()->setLocalTransform(scale);
if (m_viewer) m_viewer->updateCachedValuesInScene();
}
//--------------------------------------------------------------------------------------------------
/// Create display model,
/// or at least empty scenes as frames that is delivered to the viewer
/// The real geometry generation is done inside RivReservoirViewGeometry and friends
//--------------------------------------------------------------------------------------------------
void RimGeoMechView::createDisplayModel()
{
if (m_viewer.isNull()) return;
if (!(m_geomechCase
&& m_geomechCase->geoMechData()
&& m_geomechCase->geoMechData()->femParts()))
return;
int partCount = m_geomechCase->geoMechData()->femParts()->partCount();
if (partCount <= 0) return;
// 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;
// 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 (isTimeStepDependentDataVisible())
{
size_t i;
for (i = 0; i < geoMechCase()->geoMechData()->frameCount(0, cellResult()->resultAddress()); i++)
{
timeStepIndices.push_back(i);
}
}
cvf::Collection<cvf::ModelBasicList> frameModels;
size_t timeIdx;
for (timeIdx = 0; timeIdx < timeStepIndices.size(); timeIdx++)
{
frameModels.push_back(new cvf::ModelBasicList);
}
// Remove all existing animation frames from the viewer.
// The parts are still cached in the RivReservoir geometry and friends
bool isAnimationActive = m_viewer->isAnimationActive();
m_viewer->removeAllFrames();
if (!m_isGeoMechFullGenerated)
{
for (int femPartIdx = 0; femPartIdx < partCount; ++femPartIdx)
{
cvf::ref<cvf::UByteArray> elmVisibility = m_geoMechFullModel->cellVisibility(femPartIdx);
m_geoMechFullModel->setTransform(m_scaleTransform.p());
RivElmVisibilityCalculator::computeAllVisible(elmVisibility.p(), m_geomechCase->geoMechData()->femParts()->part(femPartIdx));
m_geoMechFullModel->setCellVisibility(femPartIdx, elmVisibility.p());
}
m_isGeoMechFullGenerated = true;
}
size_t frameIdx;
for (frameIdx = 0; frameIdx < frameModels.size(); ++frameIdx)
{
m_geoMechFullModel->appendGridPartsToModel(frameModels[frameIdx].p());
}
// Set static colors
this->updateStaticCellColors();
// Create Scenes from the frameModels
// Animation frames for results display, starts from frame 1
size_t frameIndex;
for (frameIndex = 0; frameIndex < frameModels.size(); frameIndex++)
{
cvf::ModelBasicList* model = frameModels.at(frameIndex);
model->updateBoundingBoxesRecursive();
cvf::ref<cvf::Scene> scene = new cvf::Scene;
scene->addModel(model);
if (frameIndex == 0)
m_viewer->setMainScene(scene.p());
else
m_viewer->addFrame(scene.p());
}
// If the animation was active before recreating everything, make viewer view current frame
if (isAnimationActive || cellResult->resultFieldName() != "")
{
m_viewer->slotSetCurrentFrame(m_currentTimeStep);
}
updateLegends();
overlayInfoConfig()->update3DInfo();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimGeoMechView::updateCurrentTimeStep()
{
updateLegends();
if ((this->animationMode() && cellResult()->resultFieldName() != ""))
{
m_geoMechFullModel->updateCellResultColor(m_currentTimeStep(), this->cellResult());
}
else
{
this->updateStaticCellColors();
}
overlayInfoConfig()->update3DInfo();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimGeoMechView::updateStaticCellColors()
{
m_geoMechFullModel->updateCellColor(cvf::Color4f(cvf::Color3f::ORANGE));
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimGeoMechView::updateDisplayModelVisibility()
{
if (m_viewer.isNull()) return;
const cvf::uint uintSurfaceBit = surfaceBit;
const cvf::uint uintMeshSurfaceBit = meshSurfaceBit;
const cvf::uint uintFaultBit = faultBit;
const cvf::uint uintMeshFaultBit = meshFaultBit;
// Initialize the mask to show everything except the the bits controlled here
unsigned int mask = 0xffffffff & ~uintSurfaceBit & ~uintFaultBit & ~uintMeshSurfaceBit & ~uintMeshFaultBit ;
// Then turn the appropriate bits on according to the user settings
if (surfaceMode == SURFACE)
{
mask |= uintSurfaceBit;
mask |= uintFaultBit;
}
else if (surfaceMode == FAULTS)
{
mask |= uintFaultBit;
}
if (meshMode == FULL_MESH)
{
mask |= uintMeshSurfaceBit;
mask |= uintMeshFaultBit;
}
else if (meshMode == FAULTS_MESH)
{
mask |= uintMeshFaultBit;
}
m_viewer->setEnableMask(mask);
m_viewer->update();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimGeoMechView::setGeoMechCase(RimGeoMechCase* gmCase)
{
m_geomechCase = gmCase;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimGeoMechView::resetLegendsInViewer()
{
this->cellResult()->legendConfig->recreateLegend();
m_viewer->removeAllColorLegends();
m_viewer->addColorLegendToBottomLeftCorner(this->cellResult()->legendConfig->legend());
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimGeoMechView::updateLegends()
{
if (m_viewer)
{
m_viewer->removeAllColorLegends();
}
if (!m_geomechCase || !m_viewer || !m_geomechCase->geoMechData() )
{
return;
}
RigGeoMechCaseData* gmCase = m_geomechCase->geoMechData();
CVF_ASSERT(gmCase);
double localMin, localMax;
double localPosClosestToZero, localNegClosestToZero;
double globalMin, globalMax;
double globalPosClosestToZero, globalNegClosestToZero;
RigFemResultAddress resVarAddress = cellResult->resultAddress();
if (resVarAddress.fieldName != "")
{
gmCase->minMaxScalarValues(resVarAddress, 0, m_currentTimeStep, &localMin, &localMax);
gmCase->posNegClosestToZero(resVarAddress, 0, m_currentTimeStep, &localPosClosestToZero, &localNegClosestToZero);
gmCase->minMaxScalarValues(resVarAddress, 0, &globalMin, &globalMax);
gmCase->posNegClosestToZero(resVarAddress, 0, &globalPosClosestToZero, &globalNegClosestToZero);
cellResult->legendConfig->setClosestToZeroValues(globalPosClosestToZero, globalNegClosestToZero, localPosClosestToZero, localNegClosestToZero);
cellResult->legendConfig->setAutomaticRanges(globalMin, globalMax, localMin, localMax);
m_viewer->addColorLegendToBottomLeftCorner(cellResult->legendConfig->legend());
cellResult->legendConfig->legend()->setTitle(cvfqt::Utils::toString(
caf::AppEnum<RigFemResultPosEnum>(cellResult->resultPositionType()).uiText() + "\n"
+ cellResult->resultFieldName() + " " + cellResult->resultComponentName() ));
}
else
{
cellResult->legendConfig->setClosestToZeroValues(0, 0, 0, 0);
cellResult->legendConfig->setAutomaticRanges(cvf::UNDEFINED_DOUBLE, cvf::UNDEFINED_DOUBLE, cvf::UNDEFINED_DOUBLE, cvf::UNDEFINED_DOUBLE);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimGeoMechCase* RimGeoMechView::geoMechCase()
{
return m_geomechCase;
}
//--------------------------------------------------------------------------------------------------
/// Clamp the current timestep to actual possibilities
//--------------------------------------------------------------------------------------------------
void RimGeoMechView::clampCurrentTimestep()
{
size_t maxFrameCount = 0;
if (m_geomechCase){
maxFrameCount = m_geomechCase->geoMechData()->frameCount(0, cellResult()->resultAddress());
}
if (m_currentTimeStep >= maxFrameCount ) m_currentTimeStep = (int)(maxFrameCount -1);
if (m_currentTimeStep < 0 ) m_currentTimeStep = 0;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimGeoMechView::isTimeStepDependentDataVisible()
{
return (cellResult->resultFieldName() != "");
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::Transform* RimGeoMechView::scaleTransform()
{
return m_scaleTransform.p();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimGeoMechView::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
{
RimView::fieldChangedByUi(changedField, oldValue, newValue);
if (changedField == &showWindow)
{
if (showWindow)
{
bool generateDisplayModel = (viewer() == NULL);
updateViewerWidget();
if (generateDisplayModel)
{
scheduleCreateDisplayModelAndRedraw();
}
}
else
{
if (m_viewer)
{
RiuMainWindow::instance()->removeViewer(m_viewer);
delete m_viewer;
m_viewer = NULL;
}
}
this->updateUiIconFromToggleField();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimGeoMechView::initAfterRead()
{
this->cellResult()->setReservoirView(this);
this->updateUiIconFromToggleField();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivElmVisibilityCalculator::computeAllVisible(cvf::UByteArray* elmVisibilities, const RigFemPart* femPart)
{
elmVisibilities->resize(femPart->elementCount());
elmVisibilities->setAll(true);
}
@@ -0,0 +1,101 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions AS
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cafPdmField.h"
#include "cafPdmObject.h"
#include "cafPdmPointer.h"
#include "cafAppEnum.h"
#include "cafPdmFieldCvfColor.h"
#include "cafPdmFieldCvfMat4d.h"
#include "cvfObject.h"
#include "RimView.h"
class RimGeoMechResultSlot;
class Rim3dOverlayInfoConfig;
class RiuViewer;
class RimGeoMechCase;
class RivGeoMechPartMgr;
class RigFemPart;
namespace cvf {
class Transform;
}
//==================================================================================================
///
///
//==================================================================================================
class RimGeoMechView : public RimView
{
CAF_PDM_HEADER_INIT;
public:
RimGeoMechView(void);
virtual ~RimGeoMechView(void);
void setGeoMechCase(RimGeoMechCase* gmCase);
RimGeoMechCase* geoMechCase();
virtual void loadDataAndUpdate();
virtual void endAnimation() {}
caf::PdmField<RimGeoMechResultSlot*> cellResult;
bool isTimeStepDependentDataVisible();
private:
virtual void createDisplayModel();
virtual void updateDisplayModelVisibility();
virtual void updateScaleTransform();
virtual cvf::Transform* scaleTransform();
virtual void clampCurrentTimestep();
virtual void updateCurrentTimeStep();
virtual void updateStaticCellColors();
virtual void updateViewerWidgetWindowTitle();
virtual void resetLegendsInViewer();
void updateLegends();
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue);
virtual void initAfterRead();
caf::PdmPointer<RimGeoMechCase> m_geomechCase;
cvf::ref<RivGeoMechPartMgr> m_geoMechFullModel;
bool m_isGeoMechFullGenerated;
cvf::ref<cvf::Transform> m_scaleTransform;
};
#include "cvfArray.h"
class RivElmVisibilityCalculator
{
public:
static void computeAllVisible(cvf::UByteArray* elmVisibilities, const RigFemPart* femPart );
};
@@ -24,7 +24,7 @@
#include "RigCaseCellResultsData.h"
#include "RigCaseData.h"
#include "RigGridManager.h"
#include "RimCase.h"
#include "RimEclipseCase.h"
#include "RimCaseCollection.h"
#include "RimCellEdgeResultSlot.h"
#include "RimReservoirCellResultsStorage.h"
@@ -79,7 +79,7 @@ RimIdenticalGridCaseGroup::~RimIdenticalGridCaseGroup()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimIdenticalGridCaseGroup::addCase(RimCase* reservoir)
void RimIdenticalGridCaseGroup::addCase(RimEclipseCase* reservoir)
{
CVF_ASSERT(reservoir);
@@ -104,7 +104,7 @@ void RimIdenticalGridCaseGroup::addCase(RimCase* reservoir)
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimIdenticalGridCaseGroup::removeCase(RimCase* reservoir)
void RimIdenticalGridCaseGroup::removeCase(RimEclipseCase* reservoir)
{
if (caseCollection()->reservoirs().count(reservoir) == 0)
{
@@ -155,7 +155,7 @@ void RimIdenticalGridCaseGroup::loadMainCaseAndActiveCellInfo()
// The mainGrid from the first case is reused directly in for the other cases.
// When reading active cell info, only the total cell count is tested for consistency
RimCase* mainCase = caseCollection()->reservoirs[0];
RimEclipseCase* mainCase = caseCollection()->reservoirs[0];
mainCase->openEclipseGridFile();
RigCaseData* rigCaseData = mainCase->reservoirData();
if (rigCaseData)
@@ -198,7 +198,7 @@ void RimIdenticalGridCaseGroup::loadMainCaseAndActiveCellInfo()
bool foundResultsInCache = false;
for (size_t i = 0; i < statisticsCaseCollection()->reservoirs.size(); i++)
{
RimCase* rimReservoir = statisticsCaseCollection()->reservoirs[i];
RimEclipseCase* rimReservoir = statisticsCaseCollection()->reservoirs[i];
// Check if any results are stored in cache
if (rimReservoir->results(RifReaderInterface::MATRIX_RESULTS)->storedResultsCount() > 0 ||
@@ -257,7 +257,7 @@ void RimIdenticalGridCaseGroup::loadMainCaseAndActiveCellInfo()
for (size_t i = 0; i < statisticsCaseCollection()->reservoirs.size(); i++)
{
RimCase* rimReservoir = statisticsCaseCollection()->reservoirs[i];
RimEclipseCase* rimReservoir = statisticsCaseCollection()->reservoirs[i];
rimReservoir->openEclipseGridFile();
@@ -375,7 +375,7 @@ void RimIdenticalGridCaseGroup::updateMainGridAndActiveCellsForStatisticsCases()
{
for (size_t i = 0; i < statisticsCaseCollection->reservoirs().size(); i++)
{
RimCase* rimStaticsCase = statisticsCaseCollection->reservoirs[i];
RimEclipseCase* rimStaticsCase = statisticsCaseCollection->reservoirs[i];
rimStaticsCase->reservoirData()->setMainGrid(this->mainGrid());
@@ -393,7 +393,7 @@ void RimIdenticalGridCaseGroup::clearStatisticsResults()
{
for (size_t i = 0; i < statisticsCaseCollection->reservoirs().size(); i++)
{
RimCase* rimStaticsCase = statisticsCaseCollection->reservoirs[i];
RimEclipseCase* rimStaticsCase = statisticsCaseCollection->reservoirs[i];
if (!rimStaticsCase) continue;
rimStaticsCase->results(RifReaderInterface::MATRIX_RESULTS)->cellResults()->clearAllResults();
@@ -421,13 +421,13 @@ void RimIdenticalGridCaseGroup::clearActiveCellUnions()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimIdenticalGridCaseGroup::contains(RimCase* reservoir) const
bool RimIdenticalGridCaseGroup::contains(RimEclipseCase* reservoir) const
{
CVF_ASSERT(reservoir);
for (size_t i = 0; i < caseCollection()->reservoirs().size(); i++)
{
RimCase* rimReservoir = caseCollection()->reservoirs()[i];
RimEclipseCase* rimReservoir = caseCollection()->reservoirs()[i];
if (reservoir->gridFileName() == rimReservoir->gridFileName())
{
return true;
@@ -473,7 +473,7 @@ bool RimIdenticalGridCaseGroup::isStatisticsCaseCollection(RimCaseCollection* ri
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimCase* RimIdenticalGridCaseGroup::mainCase()
RimEclipseCase* RimIdenticalGridCaseGroup::mainCase()
{
if(caseCollection()->reservoirs().size())
{
@@ -488,7 +488,7 @@ RimCase* RimIdenticalGridCaseGroup::mainCase()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimIdenticalGridCaseGroup::canCaseBeAdded(RimCase* reservoir) const
bool RimIdenticalGridCaseGroup::canCaseBeAdded(RimEclipseCase* reservoir) const
{
CVF_ASSERT(reservoir && reservoir->reservoirData() && reservoir->reservoirData()->mainGrid());
@@ -30,7 +30,7 @@
class RimCaseCollection;
class RimStatisticsCase;
class RimCase;
class RimEclipseCase;
class RigMainGrid;
class RigActiveCellInfo;
@@ -52,16 +52,16 @@ public:
caf::PdmField<RimCaseCollection*> caseCollection;
caf::PdmField<RimCaseCollection*> statisticsCaseCollection;
void addCase(RimCase* reservoir);
void removeCase(RimCase* reservoir);
void addCase(RimEclipseCase* reservoir);
void removeCase(RimEclipseCase* reservoir);
bool contains(RimCase* reservoir) const;
bool canCaseBeAdded(RimCase* reservoir) const;
bool contains(RimEclipseCase* reservoir) const;
bool canCaseBeAdded(RimEclipseCase* reservoir) const;
RimStatisticsCase* createAndAppendStatisticsCase();
RimCase* mainCase();
RimEclipseCase* mainCase();
void loadMainCaseAndActiveCellInfo();
RigMainGrid* mainGrid();
@@ -42,7 +42,7 @@ CAF_PDM_SOURCE_INIT(RimInputCase, "RimInputReservoir");
///
//--------------------------------------------------------------------------------------------------
RimInputCase::RimInputCase()
: RimCase()
: RimEclipseCase()
{
CAF_PDM_InitObject("RimInputCase", ":/EclipseInput48x48.png", "", "");
CAF_PDM_InitField(&m_gridFileName, "GridFileName", QString(), "Case grid filename", "", "" ,"");
@@ -23,7 +23,7 @@
#include "cafPdmField.h"
#include "cafPdmObject.h"
#include "RimCase.h"
#include "RimEclipseCase.h"
class RifReaderInterface;
class RimInputPropertyCollection;
@@ -34,7 +34,7 @@ class RimInputProperty;
//
//
//==================================================================================================
class RimInputCase : public RimCase
class RimInputCase : public RimEclipseCase
{
CAF_PDM_HEADER_INIT;
@@ -39,7 +39,7 @@ namespace cvf
class ScalarMapper;
}
class RimReservoirView;
class RimView;
//==================================================================================================
///
@@ -52,7 +52,7 @@ public:
RimLegendConfig();
virtual ~RimLegendConfig();
void setReservoirView(RimReservoirView* ownerReservoirView) {m_reservoirView = ownerReservoirView; }
void setReservoirView(RimView* ownerReservoirView) {m_reservoirView = ownerReservoirView; }
caf::PdmField<QString> resultVariableName; // Used internally to describe the variable this legend setup is used for
@@ -111,7 +111,7 @@ private:
private:
caf::PdmPointer<RimReservoirView> m_reservoirView;
caf::PdmPointer<RimView> m_reservoirView;
cvf::ref<cvf::ScalarMapperDiscreteLinear> m_linDiscreteScalarMapper;
cvf::ref<cvf::ScalarMapperDiscreteLog> m_logDiscreteScalarMapper;
@@ -22,6 +22,7 @@
#include "RimAnalysisModels.h"
#include "RimWellPathCollection.h"
#include "RimGeoMechModels.h"
CAF_PDM_SOURCE_INIT(RimOilField, "ResInsightOilField");
//--------------------------------------------------------------------------------------------------
@@ -32,6 +33,7 @@ RimOilField::RimOilField(void)
CAF_PDM_InitObject("Oil Field", "", "", "");
CAF_PDM_InitFieldNoDefault(&analysisModels, "AnalysisModels", "Grid Models", ":/GridModels.png", "", "");
CAF_PDM_InitFieldNoDefault(&geoMechModels, "GeoMechModels", "Geo Mech Models", ":/GridModels.png", "", "");
CAF_PDM_InitFieldNoDefault(&wellPathCollection, "WellPathCollection", "Well Paths", ":/WellCollection.png", "", "");
analysisModels = new RimAnalysisModels();
@@ -43,6 +45,7 @@ RimOilField::RimOilField(void)
RimOilField::~RimOilField(void)
{
if (wellPathCollection()) delete wellPathCollection();
if (geoMechModels()) delete geoMechModels();
if (analysisModels()) delete analysisModels();
}
@@ -26,6 +26,7 @@
class RimWellPathCollection;
class RimAnalysisModels;
class RimGeoMechModels;
//==================================================================================================
///
@@ -40,5 +41,6 @@ public:
virtual ~RimOilField(void);
caf::PdmField<RimAnalysisModels*> analysisModels;
caf::PdmField<RimGeoMechModels*> geoMechModels;
caf::PdmField<RimWellPathCollection*> wellPathCollection;
};
+45 -22
View File
@@ -24,7 +24,7 @@
#include "RiaVersionInfo.h"
#include "RigCaseData.h"
#include "RimAnalysisModels.h"
#include "RimCase.h"
#include "RimEclipseCase.h"
#include "RimCaseCollection.h"
#include "RimIdenticalGridCaseGroup.h"
#include "RimOilField.h"
@@ -34,6 +34,8 @@
#include "RimWellPathImport.h"
#include <QDir>
#include "RimGeoMechModels.h"
#include "RimGeoMechCase.h"
CAF_PDM_SOURCE_INIT(RimProject, "ResInsightProject");
//--------------------------------------------------------------------------------------------------
@@ -234,7 +236,7 @@ void RimProject::initAfterRead()
bool movedOneRimCase = false;
for (size_t cIdx = 0; cIdx < casesObsolete().size(); ++cIdx)
{
RimCase* sourceCase = casesObsolete[cIdx];
RimEclipseCase* sourceCase = casesObsolete[cIdx];
if (analysisModels)
{
analysisModels->cases.push_back(sourceCase);
@@ -376,27 +378,44 @@ void RimProject::allCases(std::vector<RimCase*>& cases)
for (size_t oilFieldIdx = 0; oilFieldIdx < oilFields().size(); oilFieldIdx++)
{
RimOilField* oilField = oilFields[oilFieldIdx];
RimAnalysisModels* analysisModels = oilField ? oilField->analysisModels() : NULL;
if (analysisModels == NULL) continue;
if (!oilField) continue;
for (size_t caseIdx = 0; caseIdx < analysisModels->cases.size(); caseIdx++)
RimAnalysisModels* analysisModels = oilField->analysisModels();
if (analysisModels )
{
cases.push_back(analysisModels->cases[caseIdx]);
}
for (size_t cgIdx = 0; cgIdx < analysisModels->caseGroups.size(); cgIdx++)
{
// Load the Main case of each IdenticalGridCaseGroup
RimIdenticalGridCaseGroup* cg = analysisModels->caseGroups[cgIdx];
if (cg == NULL) continue;
for (size_t caseIdx = 0; caseIdx < cg->statisticsCaseCollection()->reservoirs.size(); caseIdx++)
for (size_t caseIdx = 0; caseIdx < analysisModels->cases.size(); caseIdx++)
{
cases.push_back(cg->statisticsCaseCollection()->reservoirs[caseIdx]);
cases.push_back(analysisModels->cases[caseIdx]);
}
for (size_t caseIdx = 0; caseIdx < cg->caseCollection()->reservoirs.size(); caseIdx++)
for (size_t cgIdx = 0; cgIdx < analysisModels->caseGroups.size(); cgIdx++)
{
cases.push_back(cg->caseCollection()->reservoirs[caseIdx]);
// Load the Main case of each IdenticalGridCaseGroup
RimIdenticalGridCaseGroup* cg = analysisModels->caseGroups[cgIdx];
if (cg == NULL) continue;
if (cg->statisticsCaseCollection())
{
for (size_t caseIdx = 0; caseIdx < cg->statisticsCaseCollection()->reservoirs.size(); caseIdx++)
{
cases.push_back(cg->statisticsCaseCollection()->reservoirs[caseIdx]);
}
}
if (cg->caseCollection())
{
for (size_t caseIdx = 0; caseIdx < cg->caseCollection()->reservoirs.size(); caseIdx++)
{
cases.push_back(cg->caseCollection()->reservoirs[caseIdx]);
}
}
}
}
RimGeoMechModels* geomModels = oilField->geoMechModels();
if (geomModels)
{
for (size_t caseIdx = 0; caseIdx < geomModels->cases.size(); caseIdx++)
{
cases.push_back(geomModels->cases[caseIdx]);
}
}
}
@@ -414,11 +433,11 @@ void RimProject::createDisplayModelAndRedrawAllViews()
{
RimCase* rimCase = cases[caseIdx];
if (rimCase == NULL) continue;
std::vector<RimView*> views = rimCase->views();
for (size_t viewIdx = 0; viewIdx < rimCase->reservoirViews.size(); viewIdx++)
for (size_t viewIdx = 0; viewIdx < views.size(); viewIdx++)
{
RimReservoirView* reservoirView = rimCase->reservoirViews[viewIdx];
reservoirView->scheduleCreateDisplayModelAndRedraw();
views[viewIdx]->scheduleCreateDisplayModelAndRedraw();
}
}
}
@@ -446,7 +465,7 @@ void RimProject::computeUtmAreaOfInterest()
for (size_t i = 0; i < cases.size(); i++)
{
RimCase* rimCase = cases[i];
RimEclipseCase* rimCase = dynamic_cast<RimEclipseCase*>(cases[i]);
if (rimCase && rimCase->reservoirData())
{
@@ -457,6 +476,10 @@ void RimProject::computeUtmAreaOfInterest()
projectBB.add(rigGrid->boundingBox());
}
}
else
{
// Todo : calculate BBox of GeoMechCase
}
}
if (projectBB.isValid())
+10 -6
View File
@@ -23,6 +23,7 @@
#include "cafPdmDocument.h"
class RimOilField;
class RimEclipseCase;
class RimCase;
class RigGridManager;
class RimScriptCollection;
@@ -50,10 +51,6 @@ public:
caf::PdmPointersField<RimCommandObject*> commandObjects;
caf::PdmField<QString> treeViewState;
caf::PdmField<QString> currentModelIndexPath;
caf::PdmField<int> nextValidCaseId; // Unique case ID within a project, used to identify a case from Octave scripts
caf::PdmField<int> nextValidCaseGroupId; // Unique case group ID within a project, used to identify a case group from Octave scripts
caf::PdmPointersField<RimCase*> casesObsolete; // obsolete
caf::PdmPointersField<RimIdenticalGridCaseGroup*> caseGroupsObsolete; // obsolete
void setScriptDirectories(const QString& scriptDirectories);
QString projectFileVersionString() const;
@@ -64,8 +61,8 @@ public:
void assignCaseIdToCase(RimCase* reservoirCase);
void assignIdToCaseGroup(RimIdenticalGridCaseGroup* caseGroup);
void allCases(std::vector<RimCase*>& cases); // VL endre impl
void createDisplayModelAndRedrawAllViews(); // VL endre impl
void allCases(std::vector<RimCase*>& cases);
void createDisplayModelAndRedrawAllViews();
void computeUtmAreaOfInterest();
@@ -79,4 +76,11 @@ protected:
private:
caf::PdmField<QString> m_projectFileVersionString;
caf::PdmField<int> nextValidCaseId; // Unique case ID within a project, used to identify a case from Octave scripts
caf::PdmField<int> nextValidCaseGroupId; // Unique case group ID within a project, used to identify a case group from Octave scripts
caf::PdmPointersField<RimEclipseCase*> casesObsolete; // obsolete
caf::PdmPointersField<RimIdenticalGridCaseGroup*> caseGroupsObsolete; // obsolete
};
@@ -25,7 +25,7 @@
#include "RigCell.h"
#include "RigMainGrid.h"
#include "RimCase.h"
#include "RimEclipseCase.h"
#include "RimTools.h"
#include "cafProgressInfo.h"
@@ -1489,7 +1489,7 @@ double RimReservoirCellResultsStorage::darchysValue()
double darchy = 0.008527; // (ECLIPSE 100) (METRIC)
RimCase* rimCase = NULL;
RimEclipseCase* rimCase = NULL;
this->firstAncestorOfType(rimCase);
if (rimCase && rimCase->reservoirData())
@@ -27,7 +27,7 @@
#include "RigResultAccessor.h"
#include "RigResultAccessorFactory.h"
#include "Rim3dOverlayInfoConfig.h"
#include "RimCase.h"
#include "RimEclipseCase.h"
#include "RimCellEdgeResultSlot.h"
#include "RimCellPropertyFilterCollection.h"
#include "RimCellRangeFilterCollection.h"
@@ -63,30 +63,6 @@
#include <limits.h>
namespace caf {
template<>
void caf::AppEnum< RimReservoirView::MeshModeType >::setUp()
{
addItem(RimReservoirView::FULL_MESH, "FULL_MESH", "All");
addItem(RimReservoirView::FAULTS_MESH, "FAULTS_MESH", "Faults only");
addItem(RimReservoirView::NO_MESH, "NO_MESH", "None");
setDefault(RimReservoirView::FULL_MESH);
}
template<>
void caf::AppEnum< RimReservoirView::SurfaceModeType >::setUp()
{
addItem(RimReservoirView::SURFACE, "SURFACE", "All");
addItem(RimReservoirView::FAULTS, "FAULTS", "Faults only");
addItem(RimReservoirView::NO_SURFACE, "NO_SURFACE", "None");
setDefault(RimReservoirView::SURFACE);
}
} // End namespace caf
CAF_PDM_SOURCE_INIT(RimReservoirView, "ReservoirView");
@@ -110,25 +86,7 @@ RimReservoirView::RimReservoirView()
CAF_PDM_InitFieldNoDefault(&faultResultSettings, "FaultResultSettings", "Separate Fault Result", "", "", "");
faultResultSettings = new RimFaultResultSlot();
CAF_PDM_InitFieldNoDefault(&overlayInfoConfig, "OverlayInfoConfig", "Info Box", "", "", "");
overlayInfoConfig = new Rim3dOverlayInfoConfig();
overlayInfoConfig->setReservoirView(this);
CAF_PDM_InitField(&name, "UserDescription", QString(""), "Name", "", "", "");
double defaultScaleFactor = 1.0;
if (preferences) defaultScaleFactor = preferences->defaultScaleFactorZ;
CAF_PDM_InitField(&scaleZ, "GridZScale", defaultScaleFactor, "Z Scale", "", "Scales the scene in the Z direction", "");
CAF_PDM_InitField(&showWindow, "ShowWindow", true, "Show 3D viewer", "", "", "");
showWindow.setUiHidden(true);
CAF_PDM_InitField(&m_currentTimeStep, "CurrentTimeStep", 0, "Current Time Step","", "", "");
m_currentTimeStep.setUiHidden(true);
CAF_PDM_InitField(&animationMode, "AnimationMode", false, "Animation Mode","", "", "");
animationMode.setUiHidden(true);
CAF_PDM_InitFieldNoDefault(&wellCollection, "WellCollection", "Simulation Wells", "", "", "");
wellCollection = new RimWellCollection;
@@ -143,25 +101,11 @@ RimReservoirView::RimReservoirView()
propertyFilterCollection = new RimCellPropertyFilterCollection();
propertyFilterCollection->setReservoirView(this);
caf::AppEnum<RimReservoirView::MeshModeType> defaultMeshType = NO_MESH;
if (preferences->defaultGridLines) defaultMeshType = FULL_MESH;
CAF_PDM_InitField(&meshMode, "MeshMode", defaultMeshType, "Grid lines", "", "", "");
CAF_PDM_InitFieldNoDefault(&surfaceMode, "SurfaceMode", "Grid surface", "", "", "");
CAF_PDM_InitField(&maximumFrameRate, "MaximumFrameRate", 10, "Maximum frame rate","", "", "");
maximumFrameRate.setUiHidden(true);
// Visualization fields
CAF_PDM_InitField(&showMainGrid, "ShowMainGrid", true, "Show Main Grid", "", "", "");
CAF_PDM_InitField(&showInactiveCells, "ShowInactiveCells", false, "Show Inactive Cells", "", "", "");
CAF_PDM_InitField(&showInvalidCells, "ShowInvalidCells", false, "Show Invalid Cells", "", "", "");
cvf::Color3f defBackgColor = preferences->defaultViewerBackgroundColor();
CAF_PDM_InitField(&backgroundColor, "ViewBackgroundColor", defBackgColor, "Background", "", "", "");
CAF_PDM_InitField(&cameraPosition, "CameraPosition", cvf::Mat4d::IDENTITY, "", "", "", "");
this->cellResult()->setReservoirView(this);
this->cellResult()->legendConfig()->setPosition(cvf::Vec2ui(10, 120));
@@ -177,7 +121,6 @@ RimReservoirView::RimReservoirView()
m_pipesPartManager = new RivReservoirPipesPartMgr(this);
m_reservoir = NULL;
m_previousGridModeMeshLinesWasFaults = false;
}
//--------------------------------------------------------------------------------------------------
@@ -188,90 +131,17 @@ RimReservoirView::~RimReservoirView()
delete this->faultResultSettings();
delete this->cellResult();
delete this->cellEdgeResult();
delete this->overlayInfoConfig();
delete rangeFilterCollection();
delete propertyFilterCollection();
delete wellCollection();
delete faultCollection();
if (m_viewer)
{
RiuMainWindow::instance()->removeViewer(m_viewer);
}
m_reservoirGridPartManager->clearGeometryCache();
delete m_viewer;
m_reservoir = NULL;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimReservoirView::updateViewerWidget()
{
if (showWindow())
{
bool isViewerCreated = false;
if (!m_viewer)
{
QGLFormat glFormat;
glFormat.setDirectRendering(RiaApplication::instance()->useShaders());
m_viewer = new RiuViewer(glFormat, NULL);
m_viewer->setOwnerReservoirView(this);
RiuMainWindow::instance()->addViewer(m_viewer);
m_viewer->setMinNearPlaneDistance(10);
this->cellResult()->legendConfig->recreateLegend();
this->cellResult()->ternaryLegendConfig->recreateLegend();
this->cellEdgeResult()->legendConfig->recreateLegend();
m_viewer->removeAllColorLegends();
m_viewer->addColorLegendToBottomLeftCorner(this->cellResult()->legendConfig->legend());
m_viewer->addColorLegendToBottomLeftCorner(this->cellEdgeResult()->legendConfig->legend());
if (RiaApplication::instance()->navigationPolicy() == RiaApplication::NAVIGATION_POLICY_CEETRON)
{
m_viewer->setNavigationPolicy(new caf::CeetronPlusNavigation);
}
else
{
m_viewer->setNavigationPolicy(new caf::CadNavigation);
}
m_viewer->enablePerfInfoHud(RiaApplication::instance()->showPerformanceInfo());
//m_viewer->layoutWidget()->showMaximized();
isViewerCreated = true;
}
RiuMainWindow::instance()->setActiveViewer(m_viewer);
if (isViewerCreated) m_viewer->mainCamera()->setViewMatrix(cameraPosition);
m_viewer->mainCamera()->viewport()->setClearColor(cvf::Color4f(backgroundColor()));
m_viewer->update();
}
else
{
if (m_viewer)
{
if (m_viewer->layoutWidget()->parentWidget())
{
m_viewer->layoutWidget()->parentWidget()->hide();
}
else
{
m_viewer->layoutWidget()->hide();
}
}
}
updateViewerWidgetWindowTitle();
}
//--------------------------------------------------------------------------------------------------
///
@@ -295,11 +165,10 @@ void RimReservoirView::updateViewerWidgetWindowTitle()
}
//--------------------------------------------------------------------------------------------------
///
/// Clamp the current timestep to actual possibilities
//--------------------------------------------------------------------------------------------------
void RimReservoirView::clampCurrentTimestep()
{
// Clamp the current timestep to actual possibilities
if (this->currentGridCellResults() && this->currentGridCellResults()->cellResults())
{
if (m_currentTimeStep() >= static_cast<int>(this->currentGridCellResults()->cellResults()->maxTimeStepCount()))
@@ -311,94 +180,15 @@ void RimReservoirView::clampCurrentTimestep()
if (m_currentTimeStep < 0 ) m_currentTimeStep = 0;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimReservoirView::scheduleCreateDisplayModelAndRedraw()
{
RiaApplication::instance()->scheduleDisplayModelUpdateAndRedraw(this);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimReservoirView::createDisplayModelAndRedraw()
{
if (m_viewer)
{
m_viewer->animationControl()->slotStop();
this->clampCurrentTimestep();
createDisplayModel();
updateDisplayModelVisibility();
if (m_viewer->frameCount() > 0)
{
m_viewer->animationControl()->setCurrentFrame(m_currentTimeStep);
}
}
RiuMainWindow::instance()->refreshAnimationActions();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimReservoirView::setDefaultView()
{
if (m_viewer)
{
m_viewer->setDefaultView();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimReservoirView::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
{
if (changedField == &scaleZ )
{
if (scaleZ < 1) scaleZ = 1;
RimView::fieldChangedByUi(changedField, oldValue, newValue);
// Regenerate well paths
RimOilField* oilFields = RiaApplication::instance()->project() ? RiaApplication::instance()->project()->activeOilField() : NULL;
RimWellPathCollection* wellPathCollection = (oilFields) ? oilFields->wellPathCollection() : NULL;
if (wellPathCollection) wellPathCollection->wellPathCollectionPartMgr()->scheduleGeometryRegen();
if (m_viewer)
{
cvf::Vec3d poi = m_viewer->pointOfInterest();
cvf::Vec3d eye, dir, up;
eye = m_viewer->mainCamera()->position();
dir = m_viewer->mainCamera()->direction();
up = m_viewer->mainCamera()->up();
eye[2] = poi[2]*scaleZ()/m_reservoirGridPartManager->scaleTransform()->worldTransform()(2,2) + (eye[2] - poi[2]);
poi[2] = poi[2]*scaleZ()/m_reservoirGridPartManager->scaleTransform()->worldTransform()(2,2);
m_viewer->mainCamera()->setFromLookAt(eye, eye + dir, up);
m_viewer->setPointOfInterest(poi);
updateScaleTransform();
createDisplayModelAndRedraw();
m_viewer->update();
}
RiuMainWindow::instance()->updateScaleValue();
}
else if (changedField == &maximumFrameRate)
{
// !! Use cvf::UNDEFINED_INT or something if we end up with frame rate 0?
// !! Should be able to specify legal range for number properties
if (m_viewer)
{
m_viewer->animationControl()->setTimeout(maximumFrameRate != 0 ? 1000/maximumFrameRate : INT_MAX);
}
}
else if (changedField == &showWindow )
if (changedField == &showWindow)
{
if (showWindow)
{
@@ -421,79 +211,49 @@ void RimReservoirView::fieldChangedByUi(const caf::PdmFieldHandle* changedField,
this->updateUiIconFromToggleField();
}
else if (changedField == &backgroundColor )
{
if (viewer() != NULL)
{
updateViewerWidget();
}
}
else if (changedField == &m_currentTimeStep)
{
if (m_viewer)
{
m_viewer->update();
}
}
else if (changedField == &showInvalidCells )
else if (changedField == &showInvalidCells)
{
m_reservoirGridPartManager->scheduleGeometryRegen(RivReservoirViewPartMgr::INACTIVE);
m_reservoirGridPartManager->scheduleGeometryRegen(RivReservoirViewPartMgr::RANGE_FILTERED_INACTIVE);
createDisplayModelAndRedraw();
}
else if ( changedField == &showInactiveCells )
}
else if (changedField == &showInactiveCells)
{
m_reservoirGridPartManager->scheduleGeometryRegen(RivReservoirViewPartMgr::INACTIVE);
m_reservoirGridPartManager->scheduleGeometryRegen(RivReservoirViewPartMgr::RANGE_FILTERED_INACTIVE);
createDisplayModelAndRedraw();
}
else if ( changedField == &showMainGrid )
}
else if (changedField == &showMainGrid)
{
createDisplayModelAndRedraw();
}
else if ( changedField == &rangeFilterCollection )
}
else if (changedField == &rangeFilterCollection)
{
m_reservoirGridPartManager->scheduleGeometryRegen(RivReservoirViewPartMgr::RANGE_FILTERED);
m_reservoirGridPartManager->scheduleGeometryRegen(RivReservoirViewPartMgr::RANGE_FILTERED_INACTIVE);
scheduleCreateDisplayModelAndRedraw();
}
else if ( changedField == &propertyFilterCollection)
}
else if (changedField == &propertyFilterCollection)
{
m_reservoirGridPartManager->scheduleGeometryRegen(RivReservoirViewPartMgr::PROPERTY_FILTERED);
scheduleCreateDisplayModelAndRedraw();
}
else if (changedField == &meshMode)
{
createDisplayModel();
updateDisplayModelVisibility();
RiuMainWindow::instance()->refreshDrawStyleActions();
}
else if (changedField == &surfaceMode)
{
createDisplayModel();
updateDisplayModelVisibility();
RiuMainWindow::instance()->refreshDrawStyleActions();
}
else if (changedField == &name)
{
updateViewerWidgetWindowTitle();
}
}
void RimReservoirView::updateScaleTransform()
{
CVF_ASSERT(m_reservoirGridPartManager.notNull());
CVF_ASSERT(m_pipesPartManager.notNull());
cvf::Mat4d scale = cvf::Mat4d::IDENTITY;
scale(2, 2) = scaleZ();
m_reservoirGridPartManager->setScaleTransform(scale);
m_pipesPartManager->setScaleTransform(m_reservoirGridPartManager->scaleTransform());
this->scaleTransform()->setLocalTransform(scale);
m_pipesPartManager->setScaleTransform(this->scaleTransform());
if (m_viewer) m_viewer->updateCachedValuesInScene();
}
@@ -962,24 +722,6 @@ void RimReservoirView::initAfterRead()
this->updateUiIconFromToggleField();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimReservoirView::setCurrentTimeStep(int frameIndex)
{
m_currentTimeStep = frameIndex;
this->animationMode = true;
this->updateCurrentTimeStep();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimReservoirView::endAnimation()
{
this->animationMode = false;
this->updateStaticCellColors();
}
//--------------------------------------------------------------------------------------------------
///
@@ -1025,14 +767,6 @@ void RimReservoirView::updateStaticCellColors(unsigned short geometryType)
m_reservoirGridPartManager->updateCellColor(static_cast<RivReservoirViewPartMgr::ReservoirGeometryCacheType>(geometryType), color);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuViewer* RimReservoirView::viewer()
{
return m_viewer;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -1076,18 +810,6 @@ void RimReservoirView::updateDisplayModelVisibility()
faultCollection->updateConnectedEditors();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimReservoirView::setupBeforeSave()
{
if (m_viewer)
{
animationMode = m_viewer->isAnimationActive();
cameraPosition = m_viewer->mainCamera()->viewMatrix();
}
}
//--------------------------------------------------------------------------------------------------
/// Convenience for quick access to results
//--------------------------------------------------------------------------------------------------
@@ -1145,15 +867,6 @@ void RimReservoirView::schedulePipeGeometryRegen()
m_pipesPartManager->scheduleGeometryRegen();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimReservoirView::updateCurrentTimeStepAndRedraw()
{
this->updateCurrentTimeStep();
if (m_viewer) m_viewer->update();
}
//--------------------------------------------------------------------------------------------------
///
@@ -1330,7 +1043,7 @@ void RimReservoirView::updateMinMaxValuesAndAddLegendToView(QString legendLabel,
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimReservoirView::setEclipseCase(RimCase* reservoir)
void RimReservoirView::setEclipseCase(RimEclipseCase* reservoir)
{
m_reservoir = reservoir;
}
@@ -1338,7 +1051,7 @@ void RimReservoirView::setEclipseCase(RimCase* reservoir)
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimCase* RimReservoirView::eclipseCase()
RimEclipseCase* RimReservoirView::eclipseCase()
{
return m_reservoir;
}
@@ -1546,127 +1259,6 @@ void RimReservoirView::updateDisplayModelForWellResults()
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimReservoirView::setMeshOnlyDrawstyle()
{
if (isGridVisualizationMode())
{
meshMode.setValueFromUi(FULL_MESH);
}
else
{
meshMode.setValueFromUi(FAULTS_MESH);
}
surfaceMode.setValueFromUi(NO_SURFACE);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimReservoirView::setMeshSurfDrawstyle()
{
if (isGridVisualizationMode())
{
surfaceMode.setValueFromUi(SURFACE);
meshMode.setValueFromUi(FULL_MESH);
}
else
{
surfaceMode.setValueFromUi(FAULTS);
meshMode.setValueFromUi(FAULTS_MESH);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimReservoirView::setFaultMeshSurfDrawstyle()
{
// Surf: No Fault Surf
// Mesh -------------
// No FF FF SF
// Fault FF FF SF
// Mesh SF SF SF
if (this->isGridVisualizationMode())
{
surfaceMode.setValueFromUi(SURFACE);
}
else
{
surfaceMode.setValueFromUi(FAULTS);
}
meshMode.setValueFromUi(FAULTS_MESH);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimReservoirView::setSurfOnlyDrawstyle()
{
if (isGridVisualizationMode())
{
surfaceMode.setValueFromUi(SURFACE);
}
else
{
surfaceMode.setValueFromUi(FAULTS);
}
meshMode.setValueFromUi(NO_MESH);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimReservoirView::setShowFaultsOnly(bool showFaults)
{
if (showFaults)
{
m_previousGridModeMeshLinesWasFaults = meshMode() == FAULTS_MESH;
if (surfaceMode() != NO_SURFACE) surfaceMode.setValueFromUi(FAULTS);
if (meshMode() != NO_MESH) meshMode.setValueFromUi(FAULTS_MESH);
}
else
{
if (surfaceMode() != NO_SURFACE) surfaceMode.setValueFromUi(SURFACE);
if (meshMode() != NO_MESH) meshMode.setValueFromUi(m_previousGridModeMeshLinesWasFaults ? FAULTS_MESH: FULL_MESH);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimReservoirView::setSurfaceDrawstyle()
{
if (surfaceMode() != NO_SURFACE) surfaceMode.setValueFromUi(SURFACE);
}
//--------------------------------------------------------------------------------------------------
///
// Surf: No Fault Surf
// Mesh -------------
// No F F G
// Fault F F G
// Mesh G G G
//
//--------------------------------------------------------------------------------------------------
bool RimReservoirView::isGridVisualizationMode() const
{
return ( this->surfaceMode() == SURFACE
|| this->meshMode() == FULL_MESH);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::PdmFieldHandle* RimReservoirView::objectToggleField()
{
return &showWindow;
}
//--------------------------------------------------------------------------------------------------
///
@@ -1845,3 +1437,25 @@ RimResultSlot* RimReservoirView::currentFaultResultSlot()
return faultResultSlot;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimReservoirView::resetLegendsInViewer()
{
this->cellResult()->legendConfig->recreateLegend();
this->cellResult()->ternaryLegendConfig->recreateLegend();
this->cellEdgeResult()->legendConfig->recreateLegend();
m_viewer->removeAllColorLegends();
m_viewer->addColorLegendToBottomLeftCorner(this->cellResult()->legendConfig->legend());
m_viewer->addColorLegendToBottomLeftCorner(this->cellEdgeResult()->legendConfig->legend());
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::Transform* RimReservoirView::scaleTransform()
{
return m_reservoirGridPartManager->scaleTransform();
}
@@ -33,13 +33,14 @@
#include "cafPdmFieldCvfMat4d.h"
#include "RivReservoirViewPartMgr.h"
#include "RimView.h"
class RigActiveCellInfo;
class RigCaseCellResultsData;
class RigGridBase;
class RigGridCellFaceVisibilityFilter;
class Rim3dOverlayInfoConfig;
class RimCase;
class RimEclipseCase;
class RimCellEdgeResultSlot;
class RimCellPropertyFilter;
class RimCellPropertyFilterCollection;
@@ -70,32 +71,17 @@ enum PartRenderMaskEnum
meshFaultBit = 0x00000008,
};
//==================================================================================================
///
///
//==================================================================================================
class RimReservoirView : public caf::PdmObject
class RimReservoirView : public RimView
{
CAF_PDM_HEADER_INIT;
public:
RimReservoirView(void);
virtual ~RimReservoirView(void);
enum MeshModeType
{
FULL_MESH,
FAULTS_MESH,
NO_MESH
};
enum SurfaceModeType
{
SURFACE,
FAULTS,
NO_SURFACE
};
// Fields containing child objects :
caf::PdmField<RimResultSlot*> cellResult;
@@ -109,28 +95,10 @@ public:
caf::PdmField<RimFaultCollection*> faultCollection;
caf::PdmField<Rim3dOverlayInfoConfig*> overlayInfoConfig;
// Visualization setup fields
caf::PdmField<QString> name;
caf::PdmField<double> scaleZ;
caf::PdmField<bool> showWindow;
caf::PdmField<bool> showInvalidCells;
caf::PdmField<bool> showInactiveCells;
caf::PdmField<bool> showMainGrid;
caf::PdmField< caf::AppEnum< MeshModeType > > meshMode;
caf::PdmField< caf::AppEnum< SurfaceModeType > > surfaceMode;
caf::PdmField< cvf::Color3f > backgroundColor;
caf::PdmField<cvf::Mat4d> cameraPosition;
caf::PdmField<int> maximumFrameRate;
caf::PdmField<bool> animationMode;
// Access internal objects
RimReservoirCellResultsStorage* currentGridCellResults();
@@ -138,38 +106,19 @@ public:
RimResultSlot* currentFaultResultSlot();
void setEclipseCase(RimCase* reservoir);
RimCase* eclipseCase();
void setEclipseCase(RimEclipseCase* reservoir);
RimEclipseCase* eclipseCase();
// Animation
int currentTimeStep() { return m_currentTimeStep;}
void setCurrentTimeStep(int frameIdx);
void updateCurrentTimeStepAndRedraw();
void endAnimation();
// 3D Viewer
RiuViewer* viewer();
void updateViewerWidget();
void updateViewerWidgetWindowTitle();
void setDefaultView();
void setMeshOnlyDrawstyle();
void setMeshSurfDrawstyle();
void setSurfOnlyDrawstyle();
void setFaultMeshSurfDrawstyle();
void setSurfaceDrawstyle();
void setShowFaultsOnly(bool showFaults);
bool isGridVisualizationMode() const;
public:
// Does this belong here, really ?
void calculateVisibleWellCellsIncFence(cvf::UByteArray* visibleCells, RigGridBase * grid);
// Display model generation
public:
void loadDataAndUpdate();
void createDisplayModelAndRedraw();
void scheduleCreateDisplayModelAndRedraw();
virtual void loadDataAndUpdate();
bool isTimeStepDependentDataVisible() const;
void scheduleGeometryRegen(unsigned short geometryType);
@@ -181,14 +130,23 @@ public:
visibleGridParts() const { return m_visibleGridParts;}
cvf::cref<RivReservoirViewPartMgr> reservoirGridPartManager() const { return m_reservoirGridPartManager.p(); }
private:
virtual void resetLegendsInViewer();
virtual void updateViewerWidgetWindowTitle();
// Display model generation
private:
void createDisplayModel();
void updateDisplayModelVisibility();
void updateCurrentTimeStep();
virtual void updateCurrentTimeStep();
void indicesToVisibleGrids(std::vector<size_t>* gridIndices);
void updateScaleTransform();
void updateStaticCellColors();
virtual void updateScaleTransform();
virtual cvf::Transform* scaleTransform();
virtual void updateStaticCellColors();
void updateStaticCellColors(unsigned short geometryType);
void updateLegends();
void updateMinMaxValuesAndAddLegendToView(QString legendLabel, RimResultSlot* resultSlot, RigCaseCellResultsData* cellResultsData);
@@ -202,12 +160,9 @@ private:
// Overridden PDM methods:
public:
virtual caf::PdmFieldHandle* userDescriptionField() { return &name; }
virtual caf::PdmFieldHandle* objectToggleField();
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue);
protected:
virtual void initAfterRead();
virtual void setupBeforeSave();
virtual void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering );
// Really private
@@ -216,11 +171,8 @@ private:
void clampCurrentTimestep();
private:
caf::PdmField<int> m_currentTimeStep;
QPointer<RiuViewer> m_viewer;
caf::PdmPointer<RimCase> m_reservoir;
caf::PdmPointer<RimEclipseCase> m_reservoir;
bool m_previousGridModeMeshLinesWasFaults;
std::vector<RivReservoirViewPartMgr::ReservoirGeometryCacheType> m_visibleGridParts;
};
@@ -44,7 +44,7 @@ CAF_PDM_SOURCE_INIT(RimResultCase, "EclipseCase");
///
//--------------------------------------------------------------------------------------------------
RimResultCase::RimResultCase()
: RimCase()
: RimEclipseCase()
{
CAF_PDM_InitObject("Eclipse Case", ":/Case48x48.png", "", "");
@@ -358,7 +358,7 @@ void RimResultCase::setCaseInfo(const QString& userDescription, const QString& c
//--------------------------------------------------------------------------------------------------
void RimResultCase::initAfterRead()
{
RimCase::initAfterRead();
RimEclipseCase::initAfterRead();
// Convert from old (9.0.2) way of storing the case file
if (caseFileName().isEmpty())
@@ -20,7 +20,7 @@
#pragma once
#include "RimCase.h"
#include "RimEclipseCase.h"
class RifReaderInterface;
class RigMainGrid;
@@ -30,7 +30,7 @@ class RigMainGrid;
//
//
//==================================================================================================
class RimResultCase : public RimCase
class RimResultCase : public RimEclipseCase
{
CAF_PDM_HEADER_INIT;
@@ -22,7 +22,7 @@
#include "RigCaseCellResultsData.h"
#include "RigCaseData.h"
#include "RimCase.h"
#include "RimEclipseCase.h"
#include "RimReservoirCellResultsStorage.h"
#include "RimReservoirView.h"
@@ -54,7 +54,7 @@ CAF_PDM_SOURCE_INIT(RimStatisticsCase, "RimStatisticalCalculation");
///
//--------------------------------------------------------------------------------------------------
RimStatisticsCase::RimStatisticsCase()
: RimCase()
: RimEclipseCase()
{
CAF_PDM_InitObject("Case Group Statistics", ":/Histogram16x16.png", "", "");
@@ -186,7 +186,7 @@ void RimStatisticsCase::computeStatistics()
CVF_ASSERT(gridCaseGroup);
gridCaseGroup->computeUnionOfActiveCells();
std::vector<RimCase*> sourceCases;
std::vector<RimEclipseCase*> sourceCases;
getSourceCases(sourceCases);
@@ -279,7 +279,7 @@ void RimStatisticsCase::scheduleACTIVEGeometryRegenOnReservoirViews()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimStatisticsCase::getSourceCases(std::vector<RimCase*>& sourceCases)
void RimStatisticsCase::getSourceCases(std::vector<RimEclipseCase*>& sourceCases)
{
RimIdenticalGridCaseGroup* gridCaseGroup = caseGroup();
if (gridCaseGroup)
@@ -290,7 +290,7 @@ void RimStatisticsCase::getSourceCases(std::vector<RimCase*>& sourceCases)
CVF_ASSERT(gridCaseGroup->caseCollection);
CVF_ASSERT(gridCaseGroup->caseCollection->reservoirs[i]);
RimCase* sourceCase = gridCaseGroup->caseCollection->reservoirs[i];
RimEclipseCase* sourceCase = gridCaseGroup->caseCollection->reservoirs[i];
sourceCases.push_back(sourceCase);
}
}
@@ -462,7 +462,7 @@ void RimStatisticsCase::fieldChangedByUi(const caf::PdmFieldHandle* changedField
RimUiTreeModelPdm* treeModel = RiuMainWindow::instance()->uiPdmModel();
// Find or load well data for given case
RimCase* sourceResultCase = caseGroup()->caseCollection()->findByDescription(m_wellDataSourceCase);
RimEclipseCase* sourceResultCase = caseGroup()->caseCollection()->findByDescription(m_wellDataSourceCase);
if (sourceResultCase)
{
sourceResultCase->openEclipseGridFile();
@@ -26,7 +26,7 @@
#include "cafPdmObject.h"
#include "cafAppEnum.h"
#include "RimCase.h"
#include "RimEclipseCase.h"
#include "RimDefines.h"
class RimIdenticalGridCaseGroup;
@@ -41,7 +41,7 @@ class RigSingleWellResultsData;
//
//
//==================================================================================================
class RimStatisticsCase : public RimCase
class RimStatisticsCase : public RimEclipseCase
{
CAF_PDM_HEADER_INIT;
@@ -70,11 +70,12 @@ public:
};
caf::PdmField< bool > m_calculateEditCommand;
virtual void updateFilePathsFromProjectPath(const QString& projectPath, const QString& oldProjectPath){}
private:
RimIdenticalGridCaseGroup* caseGroup();
void getSourceCases(std::vector<RimCase*>& sourceCases);
void getSourceCases(std::vector<RimEclipseCase*>& sourceCases);
void populateWithDefaultsIfNeeded();
@@ -153,7 +153,7 @@ void RimStatisticsCaseEvaluator::evaluateForResults(const QList<ResSpec>& result
cvf::Collection<RigResultAccessor> sourceDataAccessList;
for (size_t caseIdx = 0; caseIdx < m_sourceCases.size(); caseIdx++)
{
RimCase* sourceCase = m_sourceCases.at(caseIdx);
RimEclipseCase* sourceCase = m_sourceCases.at(caseIdx);
// Trigger loading of dataset
sourceCase->results(poroModel)->findOrLoadScalarResultForTimeStep(resultType, resultName, dataAccessTimeStepIndex);
@@ -282,7 +282,7 @@ void RimStatisticsCaseEvaluator::evaluateForResults(const QList<ResSpec>& result
for (size_t caseIdx = 0; caseIdx < m_sourceCases.size(); caseIdx++)
{
RimCase* eclipseCase = m_sourceCases.at(caseIdx);
RimEclipseCase* eclipseCase = m_sourceCases.at(caseIdx);
if (!eclipseCase->reservoirViews.size())
{
@@ -303,7 +303,7 @@ void RimStatisticsCaseEvaluator::evaluateForResults(const QList<ResSpec>& result
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimStatisticsCaseEvaluator::RimStatisticsCaseEvaluator(const std::vector<RimCase*>& sourceCases, const std::vector<size_t>& timeStepIndices, const RimStatisticsConfig& statisticsConfig, RigCaseData* destinationCase)
RimStatisticsCaseEvaluator::RimStatisticsCaseEvaluator(const std::vector<RimEclipseCase*>& sourceCases, const std::vector<size_t>& timeStepIndices, const RimStatisticsConfig& statisticsConfig, RigCaseData* destinationCase)
: m_sourceCases(sourceCases),
m_statisticsConfig(statisticsConfig),
m_destinationCase(destinationCase),
@@ -27,7 +27,7 @@
#include <math.h>
class RimCase;
class RimEclipseCase;
class RigCaseData;
class RigCaseCellResultsData;
@@ -56,7 +56,7 @@ public:
class RimStatisticsCaseEvaluator
{
public:
RimStatisticsCaseEvaluator(const std::vector<RimCase*>& sourceCases,
RimStatisticsCaseEvaluator(const std::vector<RimEclipseCase*>& sourceCases,
const std::vector<size_t>& timeStepIndices,
const RimStatisticsConfig& statisticsConfig,
RigCaseData* destinationCase);
@@ -82,7 +82,7 @@ private:
enum StatisticsParamType { MIN, MAX, RANGE, MEAN, STDEV, PMIN, PMID, PMAX, STAT_PARAM_COUNT };
private:
std::vector<RimCase*> m_sourceCases;
std::vector<RimEclipseCase*> m_sourceCases;
std::vector<size_t> m_timeStepIndices;
size_t m_reservoirCellCount;
@@ -23,7 +23,7 @@
#include "RiaApplication.h"
#include "RigGridManager.h"
#include "RimAnalysisModels.h"
#include "RimCase.h"
#include "RimEclipseCase.h"
#include "RimCaseCollection.h"
#include "RimCellPropertyFilterCollection.h"
#include "RimCellRangeFilterCollection.h"
@@ -228,7 +228,7 @@ bool RimUiTreeModelPdm::deleteReservoirView(const QModelIndex& itemIndex)
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimUiTreeModelPdm::deleteReservoir(RimCase* reservoir)
void RimUiTreeModelPdm::deleteReservoir(RimEclipseCase* reservoir)
{
if (reservoir->parentCaseCollection())
{
@@ -394,7 +394,7 @@ RimReservoirView* RimUiTreeModelPdm::addReservoirView(const QModelIndex& itemInd
collectionIndex = itemIndex.parent();
position = itemIndex.row();
}
else if (dynamic_cast<RimCase*>(currentItem->dataObject().p()))
else if (dynamic_cast<RimEclipseCase*>(currentItem->dataObject().p()))
{
collectionItem = currentItem;
collectionIndex = itemIndex;
@@ -403,7 +403,7 @@ RimReservoirView* RimUiTreeModelPdm::addReservoirView(const QModelIndex& itemInd
if (collectionItem)
{
RimCase* rimReservoir = dynamic_cast<RimCase*>(collectionItem->dataObject().p());
RimEclipseCase* rimReservoir = dynamic_cast<RimEclipseCase*>(collectionItem->dataObject().p());
RimReservoirView* insertedView = rimReservoir->createAndAddReservoirView();
// Must be run before buildViewItems, as wells are created in this function
@@ -590,7 +590,7 @@ RimIdenticalGridCaseGroup* RimUiTreeModelPdm::addCaseGroup(QModelIndex& inserted
RimIdenticalGridCaseGroup* createdObject = new RimIdenticalGridCaseGroup;
proj->assignIdToCaseGroup(createdObject);
RimCase* createdReservoir = createdObject->createAndAppendStatisticsCase();
RimEclipseCase* createdReservoir = createdObject->createAndAppendStatisticsCase();
proj->assignCaseIdToCase(createdReservoir);
createdObject->name = QString("Grid Case Group %1").arg(analysisModels->caseGroups().size() + 1);
@@ -725,7 +725,7 @@ void RimUiTreeModelPdm::addObjects(const QModelIndex& itemIndex, const caf::PdmO
return;
}
RimCase* rimCase = caseFromItemIndex(itemIndex);
RimEclipseCase* rimCase = caseFromItemIndex(itemIndex);
QModelIndex collectionIndex = getModelIndexFromPdmObject(rimCase);
caf::PdmUiTreeItem* collectionItem = getTreeItemFromIndex(collectionIndex);
@@ -770,7 +770,7 @@ void RimUiTreeModelPdm::moveObjects(const QModelIndex& itemIndex, caf::PdmObject
for (size_t i = 0; i < typedObjects.size(); i++)
{
RimCase* rimReservoir = typedObjects[i];
RimEclipseCase* rimReservoir = typedObjects[i];
deleteReservoir(rimReservoir);
}
}
@@ -859,7 +859,7 @@ Qt::ItemFlags RimUiTreeModelPdm::flags(const QModelIndex &index) const
{
return Qt::ItemIsDropEnabled | defaultFlags;
}
else if (dynamic_cast<RimCase*>(currentItem->dataObject().p()))
else if (dynamic_cast<RimEclipseCase*>(currentItem->dataObject().p()))
{
// TODO: Remember to handle reservoir holding the main grid
return Qt::ItemIsDragEnabled | defaultFlags;
@@ -943,9 +943,9 @@ RimIdenticalGridCaseGroup* RimUiTreeModelPdm::gridCaseGroupFromItemIndex(const Q
gridCaseGroup = caseCollection->parentCaseGroup();
}
else if (dynamic_cast<RimCase*>(currentItem->dataObject().p()))
else if (dynamic_cast<RimEclipseCase*>(currentItem->dataObject().p()))
{
RimCase* rimReservoir = dynamic_cast<RimCase*>(currentItem->dataObject().p());
RimEclipseCase* rimReservoir = dynamic_cast<RimEclipseCase*>(currentItem->dataObject().p());
CVF_ASSERT(rimReservoir);
RimCaseCollection* caseCollection = rimReservoir->parentCaseCollection();
@@ -980,15 +980,15 @@ void RimUiTreeModelPdm::addToParentAndBuildUiItems(caf::PdmUiTreeItem* parentTre
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimCase* RimUiTreeModelPdm::caseFromItemIndex(const QModelIndex& itemIndex)
RimEclipseCase* RimUiTreeModelPdm::caseFromItemIndex(const QModelIndex& itemIndex)
{
caf::PdmUiTreeItem* currentItem = getTreeItemFromIndex(itemIndex);
RimCase* rimCase = NULL;
RimEclipseCase* rimCase = NULL;
if (dynamic_cast<RimCase*>(currentItem->dataObject().p()))
if (dynamic_cast<RimEclipseCase*>(currentItem->dataObject().p()))
{
rimCase = dynamic_cast<RimCase*>(currentItem->dataObject().p());
rimCase = dynamic_cast<RimEclipseCase*>(currentItem->dataObject().p());
}
else if (dynamic_cast<RimReservoirView*>(currentItem->dataObject().p()))
{
@@ -29,7 +29,7 @@ class QFileSystemWatcher;
class RimCellPropertyFilter;
class RimCellRangeFilter;
class RimCase;
class RimEclipseCase;
class RimReservoirView;
class RimInputProperty;
class RimStatisticsCase;
@@ -56,7 +56,7 @@ public:
bool deletePropertyFilter(const QModelIndex& itemIndex);
bool deleteReservoirView(const QModelIndex& itemIndex);
void deleteInputProperty(const QModelIndex& itemIndex);
void deleteReservoir(RimCase* reservoir);
void deleteReservoir(RimEclipseCase* reservoir);
void deleteAllWellPaths(const QModelIndex& itemIndex);
RimCellPropertyFilter* addPropertyFilter(const QModelIndex& itemIndex, QModelIndex& insertedModelIndex);
@@ -91,7 +91,7 @@ private slots:
private:
void clearClipboard();
RimCase* caseFromItemIndex(const QModelIndex& itemIndex);
RimEclipseCase* caseFromItemIndex(const QModelIndex& itemIndex);
private:
QFileSystemWatcher* m_scriptChangeDetector;
};
@@ -193,7 +193,7 @@ void RimUiTreeView::contextMenuEvent(QContextMenuEvent* event)
menu.addAction(QString("Compute"), this, SLOT(slotComputeStatistics()));
menu.addAction(QString("Close"), this, SLOT(slotCloseCase()));
}
else if (dynamic_cast<RimCase*>(uiItem->dataObject().p()))
else if (dynamic_cast<RimEclipseCase*>(uiItem->dataObject().p()))
{
menu.addAction(QString("Copy"), this, SLOT(slotCopyPdmObjectToClipboard()));
menu.addAction(m_pasteAction);
@@ -604,12 +604,12 @@ void RimUiTreeView::slotExecuteScriptForSelectedCases()
myModel->populateObjectGroupFromModelIndexList(mil, &group);
std::vector<caf::PdmPointer<RimCase> > typedObjects;
std::vector<caf::PdmPointer<RimEclipseCase> > typedObjects;
group.objectsByType(&typedObjects);
for (size_t i = 0; i < typedObjects.size(); i++)
{
RimCase* rimReservoir = typedObjects[i];
RimEclipseCase* rimReservoir = typedObjects[i];
caseIdsInSelection.push_back(rimReservoir->caseId);
}
}
@@ -895,12 +895,12 @@ void RimUiTreeView::slotCloseCase()
QModelIndexList mil = m->selectedRows();
myModel->populateObjectGroupFromModelIndexList(mil, &group);
std::vector<caf::PdmPointer<RimCase> > typedObjects;
std::vector<caf::PdmPointer<RimEclipseCase> > typedObjects;
group.objectsByType(&typedObjects);
for (size_t i = 0; i < typedObjects.size(); i++)
{
RimCase* rimReservoir = typedObjects[i];
RimEclipseCase* rimReservoir = typedObjects[i];
myModel->deleteReservoir(rimReservoir);
}
}
@@ -1050,7 +1050,7 @@ void RimUiTreeView::keyPressEvent(QKeyEvent* keyEvent)
caf::PdmUiTreeItem* uiItem = myModel->getTreeItemFromIndex(currentIndex());
if (uiItem)
{
if (dynamic_cast<RimCase*>(uiItem->dataObject().p())
if (dynamic_cast<RimEclipseCase*>(uiItem->dataObject().p())
|| dynamic_cast<RimReservoirView*>(uiItem->dataObject().p()))
{
if (keyEvent->matches(QKeySequence::Copy))
@@ -1064,7 +1064,7 @@ void RimUiTreeView::keyPressEvent(QKeyEvent* keyEvent)
if (dynamic_cast<RimIdenticalGridCaseGroup*>(uiItem->dataObject().p())
|| dynamic_cast<RimCaseCollection*>(uiItem->dataObject().p())
|| dynamic_cast<RimCase*>(uiItem->dataObject().p())
|| dynamic_cast<RimEclipseCase*>(uiItem->dataObject().p())
|| dynamic_cast<RimReservoirView*>(uiItem->dataObject().p()))
{
if (keyEvent->matches(QKeySequence::Paste))
@@ -0,0 +1,452 @@
#include "RimView.h"
#include "cafPdmObjectFactory.h"
#include "RiaApplication.h"
#include "RiaPreferences.h"
#include "Rim3dOverlayInfoConfig.h"
#include "RiuViewer.h"
#include "RiuMainWindow.h"
#include "cafCeetronPlusNavigation.h"
#include "cafCadNavigation.h"
#include "cvfCamera.h"
#include "cvfViewport.h"
#include "cafFrameAnimationControl.h"
#include <limits.h>
#include "RimOilField.h"
#include "RimWellPathCollection.h"
#include "RimProject.h"
#include "RivWellPathCollectionPartMgr.h"
namespace caf {
template<>
void caf::AppEnum< RimView::MeshModeType >::setUp()
{
addItem(RimView::FULL_MESH, "FULL_MESH", "All");
addItem(RimView::FAULTS_MESH, "FAULTS_MESH", "Faults only");
addItem(RimView::NO_MESH, "NO_MESH", "None");
setDefault(RimView::FULL_MESH);
}
template<>
void caf::AppEnum< RimView::SurfaceModeType >::setUp()
{
addItem(RimView::SURFACE, "SURFACE", "All");
addItem(RimView::FAULTS, "FAULTS", "Faults only");
addItem(RimView::NO_SURFACE, "NO_SURFACE", "None");
setDefault(RimView::SURFACE);
}
} // End namespace caf
#include "cafPdmAbstractClassSourceInit.h"
CAF_PDM_ABSTRACT_SOURCE_INIT(RimView, "GenericView"); // Do not use. Abstract class
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimView::RimView(void)
{
RiaApplication* app = RiaApplication::instance();
RiaPreferences* preferences = app->preferences();
CVF_ASSERT(preferences);
CAF_PDM_InitField(&name, "UserDescription", QString(""), "Name", "", "", "");
CAF_PDM_InitField(&showWindow, "ShowWindow", true, "Show 3D viewer", "", "", "");
showWindow.setUiHidden(true);
CAF_PDM_InitField(&cameraPosition, "CameraPosition", cvf::Mat4d::IDENTITY, "", "", "", "");
double defaultScaleFactor = 1.0;
if (preferences) defaultScaleFactor = preferences->defaultScaleFactorZ;
CAF_PDM_InitField(&scaleZ, "GridZScale", defaultScaleFactor, "Z Scale", "", "Scales the scene in the Z direction", "");
cvf::Color3f defBackgColor = preferences->defaultViewerBackgroundColor();
CAF_PDM_InitField(&backgroundColor, "ViewBackgroundColor", defBackgColor, "Background", "", "", "");
CAF_PDM_InitField(&maximumFrameRate, "MaximumFrameRate", 10, "Maximum frame rate", "", "", "");
maximumFrameRate.setUiHidden(true);
CAF_PDM_InitField(&animationMode, "AnimationMode", false, "Animation Mode", "", "", "");
animationMode.setUiHidden(true);
CAF_PDM_InitField(&m_currentTimeStep, "CurrentTimeStep", 0, "Current Time Step", "", "", "");
m_currentTimeStep.setUiHidden(true);
CAF_PDM_InitFieldNoDefault(&overlayInfoConfig, "OverlayInfoConfig", "Info Box", "", "", "");
overlayInfoConfig = new Rim3dOverlayInfoConfig();
overlayInfoConfig->setReservoirView(this);
caf::AppEnum<RimView::MeshModeType> defaultMeshType = NO_MESH;
if (preferences->defaultGridLines) defaultMeshType = FULL_MESH;
CAF_PDM_InitField(&meshMode, "MeshMode", defaultMeshType, "Grid lines", "", "", "");
CAF_PDM_InitFieldNoDefault(&surfaceMode, "SurfaceMode", "Grid surface", "", "", "");
m_previousGridModeMeshLinesWasFaults = false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimView::~RimView(void)
{
delete this->overlayInfoConfig();
if (m_viewer)
{
RiuMainWindow::instance()->removeViewer(m_viewer);
}
delete m_viewer;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuViewer* RimView::viewer()
{
return m_viewer;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimView::updateViewerWidget()
{
if (showWindow())
{
bool isViewerCreated = false;
if (!m_viewer)
{
QGLFormat glFormat;
glFormat.setDirectRendering(RiaApplication::instance()->useShaders());
m_viewer = new RiuViewer(glFormat, NULL);
m_viewer->setOwnerReservoirView(this);
RiuMainWindow::instance()->addViewer(m_viewer);
m_viewer->setMinNearPlaneDistance(10);
this->resetLegendsInViewer();
if (RiaApplication::instance()->navigationPolicy() == RiaApplication::NAVIGATION_POLICY_CEETRON)
{
m_viewer->setNavigationPolicy(new caf::CeetronPlusNavigation);
}
else
{
m_viewer->setNavigationPolicy(new caf::CadNavigation);
}
m_viewer->enablePerfInfoHud(RiaApplication::instance()->showPerformanceInfo());
isViewerCreated = true;
}
RiuMainWindow::instance()->setActiveViewer(m_viewer);
if (isViewerCreated) m_viewer->mainCamera()->setViewMatrix(cameraPosition);
m_viewer->mainCamera()->viewport()->setClearColor(cvf::Color4f(backgroundColor()));
m_viewer->update();
}
else
{
if (m_viewer)
{
if (m_viewer->layoutWidget()->parentWidget())
{
m_viewer->layoutWidget()->parentWidget()->hide();
}
else
{
m_viewer->layoutWidget()->hide();
}
}
}
updateViewerWidgetWindowTitle();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimView::scheduleCreateDisplayModelAndRedraw()
{
RiaApplication::instance()->scheduleDisplayModelUpdateAndRedraw(this);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimView::setCurrentTimeStep(int frameIndex)
{
m_currentTimeStep = frameIndex;
this->animationMode = true;
this->updateCurrentTimeStep();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimView::updateCurrentTimeStepAndRedraw()
{
this->updateCurrentTimeStep();
if (m_viewer) m_viewer->update();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimView::createDisplayModelAndRedraw()
{
if (m_viewer)
{
m_viewer->animationControl()->slotStop();
this->clampCurrentTimestep();
createDisplayModel();
updateDisplayModelVisibility();
if (m_viewer->frameCount() > 0)
{
m_viewer->animationControl()->setCurrentFrame(m_currentTimeStep);
}
}
RiuMainWindow::instance()->refreshAnimationActions();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimView::setDefaultView()
{
if (m_viewer)
{
m_viewer->setDefaultView();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimView::endAnimation()
{
this->animationMode = false;
this->updateStaticCellColors();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimView::setupBeforeSave()
{
if (m_viewer)
{
animationMode = m_viewer->isAnimationActive();
cameraPosition = m_viewer->mainCamera()->viewMatrix();
}
}
//--------------------------------------------------------------------------------------------------
///
// Surf: No Fault Surf
// Mesh -------------
// No F F G
// Fault F F G
// Mesh G G G
//
//--------------------------------------------------------------------------------------------------
bool RimView::isGridVisualizationMode() const
{
return ( this->surfaceMode() == SURFACE
|| this->meshMode() == FULL_MESH);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimView::setMeshOnlyDrawstyle()
{
if (isGridVisualizationMode())
{
meshMode.setValueFromUi(FULL_MESH);
}
else
{
meshMode.setValueFromUi(FAULTS_MESH);
}
surfaceMode.setValueFromUi(NO_SURFACE);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimView::setMeshSurfDrawstyle()
{
if (isGridVisualizationMode())
{
surfaceMode.setValueFromUi(SURFACE);
meshMode.setValueFromUi(FULL_MESH);
}
else
{
surfaceMode.setValueFromUi(FAULTS);
meshMode.setValueFromUi(FAULTS_MESH);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimView::setFaultMeshSurfDrawstyle()
{
// Surf: No Fault Surf
// Mesh -------------
// No FF FF SF
// Fault FF FF SF
// Mesh SF SF SF
if (this->isGridVisualizationMode())
{
surfaceMode.setValueFromUi(SURFACE);
}
else
{
surfaceMode.setValueFromUi(FAULTS);
}
meshMode.setValueFromUi(FAULTS_MESH);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimView::setSurfOnlyDrawstyle()
{
if (isGridVisualizationMode())
{
surfaceMode.setValueFromUi(SURFACE);
}
else
{
surfaceMode.setValueFromUi(FAULTS);
}
meshMode.setValueFromUi(NO_MESH);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimView::setShowFaultsOnly(bool showFaults)
{
if (showFaults)
{
m_previousGridModeMeshLinesWasFaults = meshMode() == FAULTS_MESH;
if (surfaceMode() != NO_SURFACE) surfaceMode.setValueFromUi(FAULTS);
if (meshMode() != NO_MESH) meshMode.setValueFromUi(FAULTS_MESH);
}
else
{
if (surfaceMode() != NO_SURFACE) surfaceMode.setValueFromUi(SURFACE);
if (meshMode() != NO_MESH) meshMode.setValueFromUi(m_previousGridModeMeshLinesWasFaults ? FAULTS_MESH: FULL_MESH);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimView::setSurfaceDrawstyle()
{
if (surfaceMode() != NO_SURFACE) surfaceMode.setValueFromUi(SURFACE);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimView::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
{
if (changedField == &meshMode)
{
createDisplayModel();
updateDisplayModelVisibility();
RiuMainWindow::instance()->refreshDrawStyleActions();
}
else if (changedField == &scaleZ)
{
if (scaleZ < 1) scaleZ = 1;
// Regenerate well paths
RimOilField* oilFields = RiaApplication::instance()->project() ? RiaApplication::instance()->project()->activeOilField() : NULL;
RimWellPathCollection* wellPathCollection = (oilFields) ? oilFields->wellPathCollection() : NULL;
if (wellPathCollection) wellPathCollection->wellPathCollectionPartMgr()->scheduleGeometryRegen();
if (m_viewer)
{
cvf::Vec3d poi = m_viewer->pointOfInterest();
cvf::Vec3d eye, dir, up;
eye = m_viewer->mainCamera()->position();
dir = m_viewer->mainCamera()->direction();
up = m_viewer->mainCamera()->up();
eye[2] = poi[2]*scaleZ()/this->scaleTransform()->worldTransform()(2, 2) + (eye[2] - poi[2]);
poi[2] = poi[2]*scaleZ()/this->scaleTransform()->worldTransform()(2, 2);
m_viewer->mainCamera()->setFromLookAt(eye, eye + dir, up);
m_viewer->setPointOfInterest(poi);
updateScaleTransform();
createDisplayModelAndRedraw();
m_viewer->update();
}
RiuMainWindow::instance()->updateScaleValue();
}
else if (changedField == &surfaceMode)
{
createDisplayModel();
updateDisplayModelVisibility();
RiuMainWindow::instance()->refreshDrawStyleActions();
}
else if (changedField == &name)
{
updateViewerWidgetWindowTitle();
}
else if (changedField == &m_currentTimeStep)
{
if (m_viewer)
{
m_viewer->update();
}
}
else if (changedField == &backgroundColor)
{
if (viewer() != NULL)
{
updateViewerWidget();
}
}
else if (changedField == &maximumFrameRate)
{
// !! Use cvf::UNDEFINED_INT or something if we end up with frame rate 0?
// !! Should be able to specify legal range for number properties
if (m_viewer)
{
m_viewer->animationControl()->setTimeout(maximumFrameRate != 0 ? 1000/maximumFrameRate : INT_MAX);
}
}
}
+137
View File
@@ -0,0 +1,137 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions 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 "cafPdmField.h"
#include "cafPdmFieldCvfColor.h"
#include "cafPdmFieldCvfMat4d.h"
#include "cafAppEnum.h"
class RiuViewer;
class Rim3dOverlayInfoConfig;
namespace cvf
{
class Transform;
}
//==================================================================================================
///
///
//==================================================================================================
class RimView : public caf::PdmObject
{
CAF_PDM_HEADER_INIT;
public:
RimView(void);
virtual ~RimView(void);
// 3D Viewer
RiuViewer* viewer();
caf::PdmField<QString> name;
caf::PdmField<double> scaleZ;
caf::PdmField<bool> showWindow;
caf::PdmField<cvf::Mat4d> cameraPosition;
caf::PdmField< cvf::Color3f > backgroundColor;
caf::PdmField<int> maximumFrameRate;
caf::PdmField<bool> animationMode;
// Draw style
enum MeshModeType
{
FULL_MESH,
FAULTS_MESH,
NO_MESH
};
enum SurfaceModeType
{
SURFACE,
FAULTS,
NO_SURFACE
};
caf::PdmField< caf::AppEnum< MeshModeType > > meshMode;
caf::PdmField< caf::AppEnum< SurfaceModeType > > surfaceMode;
void setMeshOnlyDrawstyle();
void setMeshSurfDrawstyle();
void setSurfOnlyDrawstyle();
void setFaultMeshSurfDrawstyle();
void setSurfaceDrawstyle();
void setShowFaultsOnly(bool showFaults);
bool isGridVisualizationMode() const;
// Animation
int currentTimeStep() { return m_currentTimeStep;}
void setCurrentTimeStep(int frameIdx);
void updateCurrentTimeStepAndRedraw();
void endAnimation();
void scheduleCreateDisplayModelAndRedraw();
void createDisplayModelAndRedraw();
public:
virtual void loadDataAndUpdate() = 0;
virtual caf::PdmFieldHandle* objectToggleField() { return &showWindow; }
virtual caf::PdmFieldHandle* userDescriptionField() { return &name; }
protected:
void setDefaultView();
virtual void createDisplayModel() = 0;
virtual void updateDisplayModelVisibility() = 0;
virtual void clampCurrentTimestep() = 0;
virtual void updateCurrentTimeStep() = 0;
virtual void updateStaticCellColors() = 0;
virtual void updateScaleTransform() = 0;
virtual cvf::Transform* scaleTransform() = 0;
void updateViewerWidget();
virtual void updateViewerWidgetWindowTitle() = 0;
virtual void resetLegendsInViewer() = 0;
QPointer<RiuViewer> m_viewer;
caf::PdmField<int> m_currentTimeStep;
caf::PdmField<Rim3dOverlayInfoConfig*> overlayInfoConfig;
// Overridden PDM methods:
virtual void setupBeforeSave();
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue);
private:
bool m_previousGridModeMeshLinesWasFaults;
};
@@ -0,0 +1,8 @@
#pragma once
#define CAF_PDM_ABSTRACT_SOURCE_INIT(ClassName, keyword) \
bool ClassName::Error_You_forgot_to_add_the_macro_CAF_PDM_HEADER_INIT_and_or_CAF_PDM_SOURCE_INIT_to_your_cpp_file_for_this_class() { return false;} \
QString ClassName::classKeywordStatic() { assert(PdmObject::isValidXmlElementName(keyword)); return keyword; }
Loaded 100 of 142 files, more files were not shown because too many files have changed in this diff. Show more